Compare commits
744 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0dcf4d2bc9 | ||
|
|
0fd8f938e7 | ||
|
|
97f891b5c9 | ||
|
|
4a92d3f249 | ||
|
|
fac0e06b1d | ||
|
|
21d9dbddbc | ||
|
|
002ae8c7cf | ||
|
|
09ab08bec2 | ||
|
|
14ecfa8aab | ||
|
|
532e3bbb89 | ||
|
|
ce7a2ad97e | ||
|
|
bc7a0d80c4 | ||
|
|
074a4f0b52 | ||
|
|
c4e2bf1b4d | ||
|
|
53e6be6f4a | ||
|
|
37f1510399 | ||
|
|
dadd6917f9 | ||
|
|
d7dd4f64ba | ||
|
|
6f47321ee7 | ||
|
|
60b5f45c39 | ||
|
|
c714541434 | ||
|
|
162a650f53 | ||
|
|
21bed97226 | ||
|
|
07d4ad94bb | ||
|
|
0c403fd09e | ||
|
|
c8cdf74f02 | ||
|
|
ef6debdff2 | ||
|
|
dba37f9f2d | ||
|
|
1f02c40cb9 | ||
|
|
9351883ae0 | ||
|
|
2e3b66fe4a | ||
|
|
d6151ab333 | ||
|
|
1a56e5f08f | ||
|
|
e3335cb6e6 | ||
|
|
3a65e8b877 | ||
|
|
fa84a8e4cc | ||
|
|
257a3bcac4 | ||
|
|
f262613871 | ||
|
|
43215ad19f | ||
|
|
00541e43ef | ||
|
|
732693b71d | ||
|
|
eaaf320c04 | ||
|
|
79507637c2 | ||
|
|
a722235e97 | ||
|
|
53f29e6e4d | ||
|
|
89363f926a | ||
|
|
c06b5df768 | ||
|
|
909e2ab97f | ||
|
|
43ed19f456 | ||
|
|
5ec087c3ed | ||
|
|
20eee2b0ec | ||
|
|
821b9b9cb5 | ||
|
|
fff9783806 | ||
|
|
fd66b51169 | ||
|
|
f8a2dc622a | ||
|
|
9aeb35ac99 | ||
|
|
84bef5fcd1 | ||
|
|
0230e7cb4c | ||
|
|
fd9af964cc | ||
|
|
954391d468 | ||
|
|
c0ab878b91 | ||
|
|
af24887399 | ||
|
|
3cb9496252 | ||
|
|
a76d0e7121 | ||
|
|
a9e883fc86 | ||
|
|
6da977cc11 | ||
|
|
acbe81db93 | ||
|
|
0249a0e933 | ||
|
|
7748ef0cd6 | ||
|
|
5cb82abc9b | ||
|
|
4fa486bc27 | ||
|
|
4fb467988c | ||
|
|
adc0bcb3ee | ||
|
|
b8b41a3541 | ||
|
|
c02ee9e988 | ||
|
|
3ccc6c0853 | ||
|
|
b1c0aea317 | ||
|
|
651aed65fb | ||
|
|
f180d84ef2 | ||
|
|
2cee6f6ab2 | ||
|
|
bbf52e8b89 | ||
|
|
8ec67f8420 | ||
|
|
a431a05f0d | ||
|
|
37b80f02db | ||
|
|
7dff3ac865 | ||
|
|
7e1981672b | ||
|
|
e0c3ab3451 | ||
|
|
9ea526f0eb | ||
|
|
3307f63864 | ||
|
|
fb70f00da8 | ||
|
|
58cff26d37 | ||
|
|
a7c5e1baee | ||
|
|
29fc3ce916 | ||
|
|
d3365d01b1 | ||
|
|
04cbb6427e | ||
|
|
3680bc8849 | ||
|
|
5cfb3faece | ||
|
|
3217eea558 | ||
|
|
c3b2624307 | ||
|
|
12a401c690 | ||
|
|
d188f6d579 | ||
|
|
d2fb65c715 | ||
|
|
d370c72425 | ||
|
|
3e9f71f81a | ||
|
|
6b2c4eb55b | ||
|
|
88a7cf2f6e | ||
|
|
d7296f69d3 | ||
|
|
c298300a27 | ||
|
|
9b752a8915 | ||
|
|
0285e63dbf | ||
|
|
33097aa302 | ||
|
|
c6504a2fa3 | ||
|
|
8da93ab628 | ||
|
|
8ba4d3ddef | ||
|
|
74ceb3afb8 | ||
|
|
c886894e14 | ||
|
|
8d6c666f75 | ||
|
|
de2bce5a0a | ||
|
|
8e9d6f0ad1 | ||
|
|
eb13dabd16 | ||
|
|
af612095fa | ||
|
|
8132881f86 | ||
|
|
994ae0d770 | ||
|
|
da10ffc655 | ||
|
|
d987ae73d0 | ||
|
|
f4accbbf8c | ||
|
|
9887efd1e3 | ||
|
|
50f5a1a844 | ||
|
|
5cd590f165 | ||
|
|
1d031a75bc | ||
|
|
a17ef09727 | ||
|
|
ed20642e8b | ||
|
|
501825d05b | ||
|
|
6ee1b55924 | ||
|
|
1a206b8e69 | ||
|
|
52fe87b90d | ||
|
|
3ea85009e7 | ||
|
|
bd5a7b9bee | ||
|
|
799c7d6007 | ||
|
|
7f28089c14 | ||
|
|
4bb69b6b16 | ||
|
|
36d084d02f | ||
|
|
9d4ce48d8d | ||
|
|
6f7efd8a1c | ||
|
|
37ec4be8fc | ||
|
|
6b43f12769 | ||
|
|
06357abe97 | ||
|
|
86c92104dd | ||
|
|
c9551d8ec0 | ||
|
|
6b676eab08 | ||
|
|
2a6a507082 | ||
|
|
9a7c00a3c4 | ||
|
|
57dcd72979 | ||
|
|
486dcdee2e | ||
|
|
7f01b596cb | ||
|
|
4a672811c0 | ||
|
|
0ec64fc13d | ||
|
|
f9796c60a0 | ||
|
|
2fd0244889 | ||
|
|
7e6ab21a9e | ||
|
|
dd7578d8d3 | ||
|
|
4b766095c8 | ||
|
|
e8d718772a | ||
|
|
0a488655d2 | ||
|
|
aed978947d | ||
|
|
f4d35eebf7 | ||
|
|
97fe4e264b | ||
|
|
d53af0a3f4 | ||
|
|
3e7e4b663e | ||
|
|
a86506b28d | ||
|
|
b9250651a2 | ||
|
|
98ed4e3f1c | ||
|
|
73776578bf | ||
|
|
aa36db7f13 | ||
|
|
38c2550f0d | ||
|
|
4c8108bdf9 | ||
|
|
0ff6cabcf5 | ||
|
|
dd22bbb943 | ||
|
|
5bbe3f1ec9 | ||
|
|
1db53c4656 | ||
|
|
43f3f2f67d | ||
|
|
dc3ea8df5e | ||
|
|
f9776c4472 | ||
|
|
27f8c70a10 | ||
|
|
6842a44e2a | ||
|
|
b28ce5cc12 | ||
|
|
d56894debd | ||
|
|
2571e43f7e | ||
|
|
0d3f1b6b5d | ||
|
|
174374e514 | ||
|
|
f3fbe6e84d | ||
|
|
34d5d4ae22 | ||
|
|
666e47ce7e | ||
|
|
5a3b92b4f3 | ||
|
|
a300f793ec | ||
|
|
cccea1d87a | ||
|
|
19bac86e5e | ||
|
|
491057255c | ||
|
|
44fe74083a | ||
|
|
10fbc7e85a | ||
|
|
cdafe0488a | ||
|
|
df3c9d2507 | ||
|
|
5cbcd68f46 | ||
|
|
fe10b7d079 | ||
|
|
b8ffb51bdc | ||
|
|
404e733f65 | ||
|
|
2fd3d47ca1 | ||
|
|
a327552fba | ||
|
|
e95a6ff738 | ||
|
|
d2f1fca921 | ||
|
|
7df43604e2 | ||
|
|
96e40cf15f | ||
|
|
e6dfa5d59e | ||
|
|
b760f0e720 | ||
|
|
fec3059157 | ||
|
|
57fee8b273 | ||
|
|
6c62ada7cc | ||
|
|
ead52305cf | ||
|
|
662c8a9a27 | ||
|
|
101b340071 | ||
|
|
39a7461f82 | ||
|
|
c49605d993 | ||
|
|
3e3948d345 | ||
|
|
d32e4edaa3 | ||
|
|
d115ee2ec7 | ||
|
|
1a41766f2e | ||
|
|
b191bc294a | ||
|
|
d146f3fd83 | ||
|
|
eea839f5ad | ||
|
|
2c0c475f57 | ||
|
|
37ed36b433 | ||
|
|
548e0f9456 | ||
|
|
eb7ec70f39 | ||
|
|
cb32be70b2 | ||
|
|
8fbf432b5b | ||
|
|
e86937ec1b | ||
|
|
71e28d1403 | ||
|
|
de79896dc5 | ||
|
|
047e3a0feb | ||
|
|
97d59d8e0c | ||
|
|
fda9a3a6b2 | ||
|
|
82145250ae | ||
|
|
4df49422df | ||
|
|
db123792d4 | ||
|
|
526b6ae5e8 | ||
|
|
55e8688031 | ||
|
|
8001014454 | ||
|
|
188bacad88 | ||
|
|
a2cd96214d | ||
|
|
103693b28d | ||
|
|
07503c1763 | ||
|
|
03c72c7a14 | ||
|
|
58157cee37 | ||
|
|
806dd11b51 | ||
|
|
6a94435d33 | ||
|
|
a188f521bb | ||
|
|
2969966fd1 | ||
|
|
b4c6f55ef4 | ||
|
|
654124be75 | ||
|
|
384f541254 | ||
|
|
5e44313730 | ||
|
|
885c3a7127 | ||
|
|
b86289c49a | ||
|
|
144ac58468 | ||
|
|
03a4997cac | ||
|
|
fd4aefaf2b | ||
|
|
4edfddb33c | ||
|
|
f46fb696ce | ||
|
|
0bc6967d83 | ||
|
|
a37612626c | ||
|
|
5e8bb3f5a0 | ||
|
|
4226438075 | ||
|
|
cd30fc74af | ||
|
|
62c3f94857 | ||
|
|
5de8f1c78d | ||
|
|
d0295bfd40 | ||
|
|
b3b3436efd | ||
|
|
dea764783b | ||
|
|
f42d15780c | ||
|
|
d19cf5aef2 | ||
|
|
bf2e3d5b94 | ||
|
|
4145e30194 | ||
|
|
6ec1827178 | ||
|
|
3a05023540 | ||
|
|
b0437cfc62 | ||
|
|
883b4b56dc | ||
|
|
00b5e5393a | ||
|
|
948bef41ae | ||
|
|
fe54a11fde | ||
|
|
400004ec51 | ||
|
|
c6377f7155 | ||
|
|
20e6621bb5 | ||
|
|
fdc5156036 | ||
|
|
23583c77de | ||
|
|
6d599e19c0 | ||
|
|
4ff0d6e2be | ||
|
|
95f1c4d9b5 | ||
|
|
b13eb1fcdf | ||
|
|
0866649444 | ||
|
|
958160918b | ||
|
|
8bd98a72aa | ||
|
|
f7c3404328 | ||
|
|
ef2f341456 | ||
|
|
4e82b0a497 | ||
|
|
d0b671625b | ||
|
|
657d50b6e0 | ||
|
|
922e752684 | ||
|
|
873f6aa995 | ||
|
|
0cd4c0e28d | ||
|
|
97eebbb977 | ||
|
|
7ae6dc8143 | ||
|
|
a112cda485 | ||
|
|
116f753e45 | ||
|
|
3c41be1ad0 | ||
|
|
7ad15c70c3 | ||
|
|
bf53f4bb2f | ||
|
|
be819c01a0 | ||
|
|
899cb2ee16 | ||
|
|
b63b3ae05a | ||
|
|
48c2e93292 | ||
|
|
4395eb6dd6 | ||
|
|
e8bbbec0f9 | ||
|
|
b16c0f84ac | ||
|
|
6efee57cbc | ||
|
|
41ae099887 | ||
|
|
781bb79ae5 | ||
|
|
3b378296a3 | ||
|
|
703b83a2fd | ||
|
|
c7e1b5bf67 | ||
|
|
b8f45ac178 | ||
|
|
e9133c136a | ||
|
|
92881cf3b3 | ||
|
|
421fe47ecf | ||
|
|
0c2c99544e | ||
|
|
491716f0fc | ||
|
|
96f9bc736e | ||
|
|
ffe694f9d8 | ||
|
|
c7b6df92ab | ||
|
|
5b67f8ee84 | ||
|
|
179cb6fa2d | ||
|
|
15c8265a21 | ||
|
|
7ec0b9aa03 | ||
|
|
c1ac1774fb | ||
|
|
b46cd17ff4 | ||
|
|
2789a40fd0 | ||
|
|
6f71bc3fdb | ||
|
|
7a102dec51 | ||
|
|
320acac80d | ||
|
|
0cad9fa307 | ||
|
|
b03202ac71 | ||
|
|
32ae0778e2 | ||
|
|
faef164abe | ||
|
|
d9930c2b44 | ||
|
|
1a0fc291b0 | ||
|
|
bb14b1da49 | ||
|
|
c0edbaa92c | ||
|
|
bf69996427 | ||
|
|
1c734cdd7c | ||
|
|
b815a3b563 | ||
|
|
32745217a7 | ||
|
|
11cec0fc15 | ||
|
|
f9cc2acf11 | ||
|
|
ed529071ae | ||
|
|
9a288e3966 | ||
|
|
e5f0717838 | ||
|
|
c258892b45 | ||
|
|
151ced7625 | ||
|
|
73e8bab4a0 | ||
|
|
3dfa2ca62e | ||
|
|
f1d3c0b980 | ||
|
|
bcc986969f | ||
|
|
2d07e9c2b9 | ||
|
|
a213bace19 | ||
|
|
7552a99a34 | ||
|
|
2a52538a1e | ||
|
|
ec3f5825b4 | ||
|
|
1294c3ef3c | ||
|
|
ca2fd0b1c6 | ||
|
|
b5596548db | ||
|
|
6167466b2f | ||
|
|
5e18402017 | ||
|
|
ec76a5f2e2 | ||
|
|
369e422b4a | ||
|
|
349f15807a | ||
|
|
6fdf28ab81 | ||
|
|
c961287290 | ||
|
|
1fefb20f71 | ||
|
|
022c44a7d4 | ||
|
|
6b8a8ad666 | ||
|
|
c0e1d0e3b4 | ||
|
|
fb64d0c360 | ||
|
|
19cac3ea81 | ||
|
|
8bad88bdca | ||
|
|
e62ba6a95a | ||
|
|
d1b18871ce | ||
|
|
4d47a22904 | ||
|
|
d4b74fc48a | ||
|
|
38752f2666 | ||
|
|
77a9c23ed3 | ||
|
|
a991f60d29 | ||
|
|
966241aa52 | ||
|
|
e9cc0ced41 | ||
|
|
987b8b3d74 | ||
|
|
f398c7e6b8 | ||
|
|
9a759c39db | ||
|
|
856cba162e | ||
|
|
55d0208a32 | ||
|
|
b1d20cbd1a | ||
|
|
cca4d1a361 | ||
|
|
ae5a838fa3 | ||
|
|
06974e2bf7 | ||
|
|
b769ff34de | ||
|
|
0f8e302aff | ||
|
|
597051303c | ||
|
|
08bdc64999 | ||
|
|
3723127132 | ||
|
|
f8a1da1967 | ||
|
|
9352ee62b7 | ||
|
|
8816af5c75 | ||
|
|
2fb09d1fba | ||
|
|
c3ce8829f3 | ||
|
|
a3f0d5e367 | ||
|
|
d93b771422 | ||
|
|
4271dc3b7d | ||
|
|
6732697f46 | ||
|
|
4d94ab98a4 | ||
|
|
2c8418bf90 | ||
|
|
a1ed2b9dd2 | ||
|
|
9b7cabc549 | ||
|
|
21b0b99d7e | ||
|
|
db47f6ab20 | ||
|
|
ef261a24e4 | ||
|
|
898457e06c | ||
|
|
0f84c8a38c | ||
|
|
f416f650c2 | ||
|
|
f39b760aa0 | ||
|
|
bfbb8b05a2 | ||
|
|
3173a8f7d8 | ||
|
|
9dac978a69 | ||
|
|
b98c043bb8 | ||
|
|
2a1233c463 | ||
|
|
e1869fbbbc | ||
|
|
bfba692aaf | ||
|
|
1382e05e25 | ||
|
|
642928057a | ||
|
|
1749f6a1f2 | ||
|
|
4c08c5fe72 | ||
|
|
8a4961a0a6 | ||
|
|
05569fb0fc | ||
|
|
f203ad1c09 | ||
|
|
4d123211ee | ||
|
|
8a191e563d | ||
|
|
9c0db6f1c7 | ||
|
|
a7638d971a | ||
|
|
fa6a023b7c | ||
|
|
2ac4cacd2d | ||
|
|
b334212667 | ||
|
|
dc7f3f973e | ||
|
|
44f58dcd22 | ||
|
|
4c1643281d | ||
|
|
6e113746d4 | ||
|
|
6a1d6d32ff | ||
|
|
8d6d10fc47 | ||
|
|
c022611d08 | ||
|
|
5a15ba3a62 | ||
|
|
c526f295c3 | ||
|
|
0e0a08cfc9 | ||
|
|
d992e5eb87 | ||
|
|
5c0e24ee73 | ||
|
|
9d85de61a3 | ||
|
|
b23749b330 | ||
|
|
77debbbc20 | ||
|
|
8970ce5ffe | ||
|
|
7a36ac9c3f | ||
|
|
4363dfd558 | ||
|
|
1aac2e3068 | ||
|
|
d16cedde9a | ||
|
|
59b71ebd84 | ||
|
|
2e01c8c710 | ||
|
|
bff58b39fd | ||
|
|
887e622428 | ||
|
|
931f03a784 | ||
|
|
c1c43d9244 | ||
|
|
8a84a08316 | ||
|
|
2c72a61324 | ||
|
|
bf263a4f8c | ||
|
|
50ba0bad6e | ||
|
|
1d80e6e047 | ||
|
|
b5e9bb885d | ||
|
|
665b8f095b | ||
|
|
75bee6ca97 | ||
|
|
41055825ef | ||
|
|
6fd3a8eda7 | ||
|
|
c578a436b4 | ||
|
|
211ac4ed72 | ||
|
|
3d0a1c3c4d | ||
|
|
0c9c8e1366 | ||
|
|
0e28d34224 | ||
|
|
3b1425cd30 | ||
|
|
ce0bce99fb | ||
|
|
cde0042b85 | ||
|
|
622edaff07 | ||
|
|
ca760563d1 | ||
|
|
f278d629eb | ||
|
|
2c319bae5d | ||
|
|
809ff2793d | ||
|
|
3ba9c58f85 | ||
|
|
66b7f47e32 | ||
|
|
a96911e112 | ||
|
|
112481f36f | ||
|
|
65cd0d453a | ||
|
|
febd1b7a3e | ||
|
|
6b527855e4 | ||
|
|
cc1e28b80a | ||
|
|
a969d65ae4 | ||
|
|
acf123488a | ||
|
|
938a2d74ad | ||
|
|
33144a149c | ||
|
|
fbb0f845cd | ||
|
|
c71cd111ca | ||
|
|
04d9d5269f | ||
|
|
f53e4d65e3 | ||
|
|
c39d6fc1ef | ||
|
|
a1c69b4cb0 | ||
|
|
b57719b0f4 | ||
|
|
893945b98a | ||
|
|
a57c5f1f1b | ||
|
|
718389e88d | ||
|
|
3f4536e04f | ||
|
|
1f79285e83 | ||
|
|
31dca8b0b7 | ||
|
|
54791388d1 | ||
|
|
7fa05d3e7b | ||
|
|
daf07bd743 | ||
|
|
163ab0407d | ||
|
|
0361e7d63d | ||
|
|
bc422460ff | ||
|
|
53f0097884 | ||
|
|
bbfb63886d | ||
|
|
928f487a29 | ||
|
|
ff7a09061e | ||
|
|
911ec00ddb | ||
|
|
54137f2117 | ||
|
|
50d38a1dd4 | ||
|
|
e5ab62eb18 | ||
|
|
1a8a3114f4 | ||
|
|
a52ba2bd39 | ||
|
|
8195f0bc6e | ||
|
|
4df4a3de32 | ||
|
|
e65a1ee37e | ||
|
|
66e47e190a | ||
|
|
b9133664ec | ||
|
|
032e084265 | ||
|
|
49202b0f33 | ||
|
|
8755fd3285 | ||
|
|
982ef56b29 | ||
|
|
28070d3c51 | ||
|
|
d9a0a4aa86 | ||
|
|
1f0f6676ed | ||
|
|
ff44fe4eda | ||
|
|
42976b0113 | ||
|
|
55b170fb7d | ||
|
|
852bbf2236 | ||
|
|
cc6080c0c3 | ||
|
|
5672ca3f1e | ||
|
|
fc29544835 | ||
|
|
bf6ac1f61a | ||
|
|
8c17a5b0bb | ||
|
|
bc6ffa3bf9 | ||
|
|
dec0317790 | ||
|
|
091acd5849 | ||
|
|
056203fb21 | ||
|
|
415c9d33fe | ||
|
|
1820112093 | ||
|
|
c573a02fd6 | ||
|
|
4c6b9833eb | ||
|
|
8cb8d76357 | ||
|
|
fc105b84e0 | ||
|
|
f873a7ab69 | ||
|
|
61a67240a6 | ||
|
|
c0753ab23e | ||
|
|
9461d1f46e | ||
|
|
3036237fdf | ||
|
|
95e71b8da5 | ||
|
|
255786bc93 | ||
|
|
3c552fe5ed | ||
|
|
49ff415316 | ||
|
|
71315c60ea | ||
|
|
18b1ea0e0b | ||
|
|
c6a8da0b40 | ||
|
|
308498550b | ||
|
|
f7e917edc7 | ||
|
|
8221da46e0 | ||
|
|
3645b7edd7 | ||
|
|
606779f681 | ||
|
|
dce5f472f0 | ||
|
|
f4bf8c1d3c | ||
|
|
7ae9ac35d1 | ||
|
|
686ac2c181 | ||
|
|
b334ed9841 | ||
|
|
96dc9ced30 | ||
|
|
03d86f4552 | ||
|
|
6e3406f117 | ||
|
|
7e929d5ef3 | ||
|
|
49a5ed8157 | ||
|
|
f60170ef59 | ||
|
|
b34bf4f646 | ||
|
|
efc14821cf | ||
|
|
ba9c7df5ff | ||
|
|
3eb29a0c21 | ||
|
|
17ead3c2fc | ||
|
|
f661f174bd | ||
|
|
7792930277 | ||
|
|
18d3e45d2c | ||
|
|
c2b9f87688 | ||
|
|
0850bca4de | ||
|
|
ef25c669c1 | ||
|
|
df09afe868 | ||
|
|
e9a2329e38 | ||
|
|
9cb919eeae | ||
|
|
e2c9b07e91 | ||
|
|
3efb8460c1 | ||
|
|
0efa681bb9 | ||
|
|
a92c5bb01f | ||
|
|
408e182be2 | ||
|
|
ea3cf80472 | ||
|
|
28ecbb58e7 | ||
|
|
7b7ff6b534 | ||
|
|
5e6eb0969b | ||
|
|
9d6c528438 | ||
|
|
920725d21f | ||
|
|
3689bfbf6d | ||
|
|
8ed864210f | ||
|
|
a0d242716d | ||
|
|
a604e546a7 | ||
|
|
3e88da384a | ||
|
|
3c5f5eff24 | ||
|
|
c750b90719 | ||
|
|
553dce3c3b | ||
|
|
24d7a7e3eb | ||
|
|
b34a9c851c | ||
|
|
1274781223 | ||
|
|
ab21b88c90 | ||
|
|
9470bbf87f | ||
|
|
c4e27b6059 | ||
|
|
c26cb933dc | ||
|
|
83be3c7c64 | ||
|
|
999dd8db51 | ||
|
|
9570d0533c | ||
|
|
103fe83efc | ||
|
|
155f66dfb1 | ||
|
|
9ea8e8860a | ||
|
|
cc5e691531 | ||
|
|
9b33ed17ce | ||
|
|
bac263311a | ||
|
|
486541b14a | ||
|
|
1609608ae8 | ||
|
|
7cfb78b0e1 | ||
|
|
dbd96cfdac | ||
|
|
e4ed404f5e | ||
|
|
b6838fdbb1 | ||
|
|
ac9bfab3e6 | ||
|
|
dc57d092f8 | ||
|
|
357dded61a | ||
|
|
edba29bf2b | ||
|
|
410bd7b926 | ||
|
|
14d93526d4 | ||
|
|
273e02d626 | ||
|
|
88e7cc35a9 | ||
|
|
37cd210104 | ||
|
|
ed22a6cd99 | ||
|
|
ecaaea5da1 | ||
|
|
43e8cce970 | ||
|
|
f05ed0c3dc | ||
|
|
9be60f7805 | ||
|
|
366a651925 | ||
|
|
6c593694d0 | ||
|
|
09d3b891bb | ||
|
|
a841178d46 | ||
|
|
aea28d185d | ||
|
|
3af10a2a6b | ||
|
|
6e8160cf73 | ||
|
|
1c0a3b3035 | ||
|
|
b4a9852ecc | ||
|
|
05cd857c5f | ||
|
|
dba0e4512a | ||
|
|
23e55e0c27 | ||
|
|
5d2cdee14f | ||
|
|
8d91d98a20 | ||
|
|
a2d61702f1 | ||
|
|
893f8c3802 | ||
|
|
ac8c5bf466 | ||
|
|
e4c6208b22 | ||
|
|
f5144d7ba4 | ||
|
|
f50e10891b | ||
|
|
66819a577b | ||
|
|
85f3e55f04 | ||
|
|
8c270b71bb | ||
|
|
49ead6c42e | ||
|
|
1baa0d9d40 | ||
|
|
028ef4bd50 | ||
|
|
596231f50b | ||
|
|
f8fc8e4020 | ||
|
|
9417f0e67b | ||
|
|
5e70a9c7e3 | ||
|
|
df65d2393e | ||
|
|
7c4eee955c | ||
|
|
8ca2cf9ab9 | ||
|
|
97e70bfef0 | ||
|
|
b52f5fb552 | ||
|
|
bad6c6df57 | ||
|
|
8999fc9a26 | ||
|
|
40d28e0d93 | ||
|
|
8e2ad72dc8 | ||
|
|
49b08a84af | ||
|
|
2beee07f98 | ||
|
|
a21c92849e | ||
|
|
2844c812e0 | ||
|
|
aeeb1912d3 | ||
|
|
08d7f7dbbe | ||
|
|
73f87162c9 | ||
|
|
ccf7784848 | ||
|
|
704249b5cc | ||
|
|
6d0c03862c | ||
|
|
bd2a852105 | ||
|
|
c0778c265f | ||
|
|
a513f0e230 | ||
|
|
c2c9f2e556 | ||
|
|
712127228d | ||
|
|
3ee1b80ea2 | ||
|
|
b1c0f39a65 | ||
|
|
23233a5f11 | ||
|
|
424e2751a6 | ||
|
|
458f709931 | ||
|
|
9ad0b5d5ee | ||
|
|
47231f5121 | ||
|
|
4f749d3e98 | ||
|
|
7fb4670c87 | ||
|
|
451c346f3d | ||
|
|
2c996637d4 | ||
|
|
8e29b1422e | ||
|
|
c9c0cb2f2c | ||
|
|
18de6ec808 | ||
|
|
9f521489ab |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -20,4 +20,4 @@ Please tell us what version of Arnis and Minecraft you used.
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here. If you used any more custom settings, please provide them here too.
|
||||
Add any other context about the problem here. If you used any more custom settings, please provide them here too. If you experienced any issue with the application itself like a crash, please provide the log file which can be found at C:\Users\USERNAME\AppData\Local\com.louisdev.arnis\logs
|
||||
|
||||
66
.github/workflows/ci-build.yml
vendored
@@ -1,40 +1,74 @@
|
||||
name: CI Build
|
||||
|
||||
# Trigger on pull request creation, update, and on pushes to the main branch
|
||||
# Trigger CI on pull requests when relevant files change, and pushes to main
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- '.github/**'
|
||||
- 'src/**'
|
||||
- 'Cargo.toml'
|
||||
- 'Cargo.lock'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, macos-latest]
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
uses: dtolnay/rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
target: ${{ matrix.os == 'windows-latest' && 'x86_64-pc-windows-msvc' || 'x86_64-unknown-linux-gnu' || 'x86_64-apple-darwin' }}
|
||||
components: clippy
|
||||
|
||||
- name: Install Linux dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y software-properties-common
|
||||
sudo add-apt-repository universe
|
||||
echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
sudo apt update
|
||||
sudo apt install -y libgtk-3-dev build-essential pkg-config libglib2.0-dev libsoup-3.0-dev libwebkit2gtk-4.1-dev
|
||||
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Check formatting
|
||||
run: cargo fmt -- --check
|
||||
|
||||
- name: Check clippy lints
|
||||
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||
|
||||
- name: Install Rust dependencies
|
||||
run: cargo fetch
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
- name: Set up Rust
|
||||
uses: dtolnay/rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Install Linux dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y software-properties-common
|
||||
sudo add-apt-repository universe
|
||||
echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
sudo apt update
|
||||
sudo apt install -y libgtk-3-dev build-essential pkg-config libglib2.0-dev libsoup-3.0-dev libwebkit2gtk-4.1-dev
|
||||
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Build (all targets, all features)
|
||||
run: cargo build --all-targets --all-features --release
|
||||
|
||||
- name: Run unit tests
|
||||
run: cargo test --all-targets --all-features
|
||||
|
||||
111
.github/workflows/pr-benchmark.yml
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
name: PR Benchmark
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened]
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
benchmark:
|
||||
if: |
|
||||
github.event_name == 'pull_request' ||
|
||||
(github.event_name == 'issue_comment' &&
|
||||
github.event.issue.pull_request != null &&
|
||||
contains(github.event.comment.body, 'retrigger-benchmark'))
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Rust
|
||||
uses: dtolnay/rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Create dummy Minecraft world directory
|
||||
run: |
|
||||
mkdir -p "./world/region"
|
||||
|
||||
- name: Build for release
|
||||
run: cargo build --release --no-default-features
|
||||
|
||||
- name: Start timer
|
||||
id: start_time
|
||||
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Run benchmark command with memory tracking
|
||||
id: benchmark
|
||||
run: |
|
||||
/usr/bin/time -v ./target/release/arnis --path="./world" --terrain --bbox="48.101470,11.517792,48.168375,11.626968" 2> benchmark_log.txt
|
||||
grep "Maximum resident set size" benchmark_log.txt | awk '{print $6}' > peak_mem_kb.txt
|
||||
peak_kb=$(cat peak_mem_kb.txt)
|
||||
peak_mb=$((peak_kb / 1024))
|
||||
echo "peak_memory=${peak_mb}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: End timer and calculate duration
|
||||
id: end_time
|
||||
run: |
|
||||
end_time=$(date +%s)
|
||||
start_time=${{ steps.start_time.outputs.start_time }}
|
||||
duration=$((end_time - start_time))
|
||||
echo "duration=$duration" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Format duration and generate summary
|
||||
id: comment_body
|
||||
run: |
|
||||
duration=${{ steps.end_time.outputs.duration }}
|
||||
minutes=$((duration / 60))
|
||||
seconds=$((duration % 60))
|
||||
peak_mem=${{ steps.benchmark.outputs.peak_memory }}
|
||||
|
||||
baseline_time=135
|
||||
diff=$((duration - baseline_time))
|
||||
abs_diff=${diff#-}
|
||||
|
||||
if [ "$diff" -lt -5 ]; then
|
||||
verdict="✅ This PR **improves generation time**."
|
||||
elif [ "$abs_diff" -le 4 ]; then
|
||||
verdict="🟢 Generation time is unchanged."
|
||||
elif [ "$diff" -le 15 ]; then
|
||||
verdict="⚠️ This PR **worsens generation time**."
|
||||
else
|
||||
verdict="🚨 This PR **drastically worsens generation time**."
|
||||
fi
|
||||
|
||||
baseline_mem=5865
|
||||
mem_annotation=""
|
||||
if [ "$peak_mem" -gt 2000 ]; then
|
||||
mem_diff=$((peak_mem - baseline_mem))
|
||||
mem_percent=$((mem_diff * 100 / baseline_mem))
|
||||
mem_annotation=" (↗ ${mem_percent}% more)"
|
||||
fi
|
||||
|
||||
{
|
||||
echo "summary<<EOF"
|
||||
echo "⏱️ Benchmark run finished in **${minutes}m ${seconds}s**"
|
||||
echo "🧠 Peak memory usage: **${peak_mem} MB**${mem_annotation}"
|
||||
echo ""
|
||||
echo "📈 Compared against baseline: **${baseline_time}s**"
|
||||
echo "🧮 Delta: **${diff}s**"
|
||||
echo "🔢 Commit: [\`${GITHUB_SHA:0:7}\`](https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA})"
|
||||
echo ""
|
||||
echo "${verdict}"
|
||||
echo ""
|
||||
echo "_You can retrigger the benchmark by commenting \`retrigger-benchmark\`._"
|
||||
echo "EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Comment build time on PR
|
||||
uses: thollander/actions-comment-pull-request@v3
|
||||
with:
|
||||
message: ${{ steps.comment_body.outputs.summary }}
|
||||
comment-tag: benchmark-report
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.BENCHMARK_TOKEN }}
|
||||
92
.github/workflows/prerelease.yml.disabled
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
name: [DISABLED] Pre-release Dev Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
binary_name: arnis.exe
|
||||
asset_name: arnis-windows-x64.exe
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
binary_name: arnis
|
||||
asset_name: arnis-linux-x64
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Rust
|
||||
uses: dtolnay/rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y software-properties-common
|
||||
sudo add-apt-repository universe
|
||||
echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
sudo apt update
|
||||
sudo apt install -y libgtk-3-dev build-essential pkg-config libglib2.0-dev libsoup-3.0-dev libwebkit2gtk-4.1-dev
|
||||
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
|
||||
|
||||
- name: Install dependencies
|
||||
run: cargo fetch --locked
|
||||
|
||||
- name: Build
|
||||
run: cargo build --frozen --release
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.os }}-build
|
||||
path: target/release/${{ matrix.binary_name }}
|
||||
|
||||
prerelease:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Download Windows build artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: windows-latest-build
|
||||
path: ./builds/windows
|
||||
|
||||
- name: Download Linux build artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ubuntu-latest-build
|
||||
path: ./builds/linux
|
||||
|
||||
- name: Make Linux binary executable
|
||||
run: chmod +x ./builds/linux/arnis
|
||||
|
||||
- name: Create Pre-release on GitHub
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: "dev-build-${{ github.run_number }}"
|
||||
name: "Experimental Development Build #${{ github.run_number }}"
|
||||
body: "Automated pre-release built from the main branch for testing purposes. This build may contain experimental features. For the latest official version, please download the latest stable release."
|
||||
draft: false
|
||||
prerelease: true
|
||||
makeLatest: false
|
||||
files: |
|
||||
builds/windows/arnis.exe
|
||||
builds/linux/arnis
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
146
.github/workflows/release.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Build and Release Rust Project
|
||||
name: Build and Release Arnis
|
||||
|
||||
on:
|
||||
release:
|
||||
@@ -6,47 +6,155 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
binary_name: arnis.exe
|
||||
asset_name: arnis-windows.exe
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
binary_name: arnis
|
||||
asset_name: arnis-linux
|
||||
- os: macos-13 # Intel runner for x86_64 builds
|
||||
target: x86_64-apple-darwin
|
||||
binary_name: arnis
|
||||
asset_name: arnis-mac-intel
|
||||
- os: macos-latest # ARM64 runner for ARM64 builds
|
||||
target: aarch64-apple-darwin
|
||||
binary_name: arnis
|
||||
asset_name: arnis-mac-arm64
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Rust for Windows
|
||||
uses: actions-rs/toolchain@v1
|
||||
- name: Set up Rust
|
||||
uses: dtolnay/rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
target: x86_64-pc-windows-msvc
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y software-properties-common
|
||||
sudo add-apt-repository universe
|
||||
echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
|
||||
sudo apt update
|
||||
sudo apt install -y libgtk-3-dev build-essential pkg-config libglib2.0-dev libsoup-3.0-dev libwebkit2gtk-4.1-dev
|
||||
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
|
||||
|
||||
- name: Install dependencies
|
||||
run: cargo fetch
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
run: cargo build --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Upload artifact (Windows)
|
||||
uses: actions/upload-artifact@v3
|
||||
- name: Rename binary for release
|
||||
run: mv target/${{ matrix.target }}/release/${{ matrix.binary_name }} target/release/${{ matrix.asset_name }}
|
||||
|
||||
- name: Install Windows SDK
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: |
|
||||
choco install windows-sdk-10.1 -y
|
||||
$env:Path += ";C:\Program Files (x86)\Windows Kits\10\bin\x64"
|
||||
shell: powershell
|
||||
|
||||
- name: Locate signtool.exe
|
||||
if: matrix.os == 'windows-latest'
|
||||
id: locate_signtool
|
||||
run: |
|
||||
$env:ProgramFilesX86 = [System.Environment]::GetFolderPath('ProgramFilesX86')
|
||||
$signtoolPath = Get-ChildItem -Path "$env:ProgramFilesX86\Windows Kits\10\bin" -Recurse -Filter signtool.exe | Where-Object { $_.FullName -match '\\x64\\' } | Select-Object -First 1 -ExpandProperty FullName
|
||||
if (-not $signtoolPath) { throw "signtool.exe not found." }
|
||||
echo "signtool=$signtoolPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
shell: powershell
|
||||
|
||||
- name: Self-sign Windows executable
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: |
|
||||
$password = ConvertTo-SecureString -String $env:WINDOWS_CERT_PASSWORD -Force -AsPlainText
|
||||
$cert = New-SelfSignedCertificate -Type CodeSigningCert -Subject 'CN=Arnis' -CertStoreLocation Cert:\CurrentUser\My -NotAfter (Get-Date).AddYears(5)
|
||||
Export-PfxCertificate -Cert $cert -FilePath arnis-cert.pfx -Password $password
|
||||
& $env:signtool sign /f arnis-cert.pfx /p $env:WINDOWS_CERT_PASSWORD /t http://timestamp.digicert.com target/release/${{ matrix.asset_name }}
|
||||
env:
|
||||
WINDOWS_CERT_PASSWORD: ${{ secrets.WINDOWS_CERT_PASSWORD }}
|
||||
shell: powershell
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-latest-build
|
||||
path: target/release/arnis.exe
|
||||
name: ${{ matrix.os }}-${{ matrix.target }}-build
|
||||
path: target/release/${{ matrix.asset_name }}
|
||||
|
||||
create-universal-macos:
|
||||
needs: build
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Download macOS Intel build
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: macos-13-x86_64-apple-darwin-build
|
||||
path: ./intel
|
||||
|
||||
- name: Download macOS ARM64 build
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: macos-latest-aarch64-apple-darwin-build
|
||||
path: ./arm64
|
||||
|
||||
- name: Create universal binary
|
||||
run: |
|
||||
lipo -create -output arnis-mac-universal ./intel/arnis-mac-intel ./arm64/arnis-mac-arm64
|
||||
chmod +x arnis-mac-universal
|
||||
|
||||
- name: Upload universal binary
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: macos-universal-build
|
||||
path: arnis-mac-universal
|
||||
|
||||
release:
|
||||
runs-on: windows-latest
|
||||
needs: build
|
||||
needs: [build, create-universal-macos]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download Windows build artifact
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-latest-build
|
||||
name: windows-latest-x86_64-pc-windows-msvc-build
|
||||
path: ./builds/windows
|
||||
|
||||
- name: Download Linux build artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ubuntu-latest-x86_64-unknown-linux-gnu-build
|
||||
path: ./builds/linux
|
||||
|
||||
- name: Download macOS universal build artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: macos-universal-build
|
||||
path: ./builds/macos
|
||||
|
||||
- name: Make Linux and macOS binaries executable
|
||||
run: |
|
||||
chmod +x ./builds/linux/arnis-linux
|
||||
chmod +x ./builds/macos/arnis-mac-universal
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: |
|
||||
builds/windows/arnis.exe
|
||||
builds/windows/arnis-windows.exe
|
||||
builds/linux/arnis-linux
|
||||
builds/macos/arnis-mac-universal
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
100
.github/workflows/test-macos-build.yml.disabled
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
name: Test macOS Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
paths:
|
||||
- '.github/workflows/release.yml'
|
||||
- 'src/**'
|
||||
- 'Cargo.toml'
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
workflow_dispatch: # Allow manual triggering
|
||||
|
||||
jobs:
|
||||
test-macos-builds:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- target: x86_64-apple-darwin
|
||||
asset_name: arnis-mac-intel
|
||||
- target: aarch64-apple-darwin
|
||||
asset_name: arnis-mac-arm64
|
||||
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Rust
|
||||
uses: dtolnay/rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: cargo fetch
|
||||
|
||||
- name: Build for ${{ matrix.target }}
|
||||
run: cargo build --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Rename binary
|
||||
run: mv target/${{ matrix.target }}/release/arnis target/${{ matrix.target }}/release/${{ matrix.asset_name }}
|
||||
|
||||
- name: Check binary architecture
|
||||
run: |
|
||||
file target/${{ matrix.target }}/release/${{ matrix.asset_name }}
|
||||
lipo -info target/${{ matrix.target }}/release/${{ matrix.asset_name }}
|
||||
|
||||
- name: Test binary execution (basic check)
|
||||
run: |
|
||||
chmod +x target/${{ matrix.target }}/release/${{ matrix.asset_name }}
|
||||
# Test that it at least shows help/version (don't run full generation)
|
||||
target/${{ matrix.target }}/release/${{ matrix.asset_name }} --help || echo "Help command completed"
|
||||
|
||||
- name: Upload test artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-${{ matrix.target }}-build
|
||||
path: target/${{ matrix.target }}/release/${{ matrix.asset_name }}
|
||||
|
||||
test-universal-binary:
|
||||
needs: test-macos-builds
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Download Intel build
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: test-x86_64-apple-darwin-build
|
||||
path: ./intel
|
||||
|
||||
- name: Download ARM64 build
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: test-aarch64-apple-darwin-build
|
||||
path: ./arm64
|
||||
|
||||
- name: Create and test universal binary
|
||||
run: |
|
||||
lipo -create -output arnis-mac-universal ./intel/arnis-mac-intel ./arm64/arnis-mac-arm64
|
||||
chmod +x arnis-mac-universal
|
||||
|
||||
# Verify it's actually universal
|
||||
echo "=== Universal Binary Info ==="
|
||||
file arnis-mac-universal
|
||||
lipo -info arnis-mac-universal
|
||||
|
||||
# Test execution
|
||||
echo "=== Testing Universal Binary ==="
|
||||
./arnis-mac-universal --help || echo "Universal binary help command completed"
|
||||
|
||||
# Check file size (should be sum of both architectures roughly)
|
||||
echo "=== File Sizes ==="
|
||||
ls -lah ./intel/arnis-mac-intel ./arm64/arnis-mac-arm64 arnis-mac-universal
|
||||
|
||||
- name: Upload universal binary
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-universal-build
|
||||
path: arnis-mac-universal
|
||||
5
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
/wiki
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
.envrc
|
||||
@@ -27,6 +29,9 @@ Thumbs.db
|
||||
# Generated files
|
||||
/export.json
|
||||
/parsed_osm_data.txt
|
||||
/elevation_debug.png
|
||||
/terrain-tile-cache
|
||||
/arnis-tile-cache
|
||||
/gen/
|
||||
/build/
|
||||
*.rmeta
|
||||
|
||||
2338
Cargo.lock
generated
49
Cargo.toml
@@ -1,40 +1,53 @@
|
||||
[package]
|
||||
name = "arnis"
|
||||
version = "2.1.2"
|
||||
version = "2.3.0"
|
||||
edition = "2021"
|
||||
description = "Arnis - Generate real life cities in Minecraft"
|
||||
homepage = "https://github.com/louis-e/arnis"
|
||||
repository = "https://github.com/louis-e/arnis"
|
||||
license = "GPL-3.0"
|
||||
license = "Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
lto = "thin"
|
||||
overflow-checks = true
|
||||
|
||||
[features]
|
||||
default = ["gui"]
|
||||
gui = ["tauri", "tauri-plugin-log", "tauri-plugin-shell", "tokio", "rfd", "dirs", "tauri-build"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
tauri-build = {version = "2", optional = true}
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.1", features = ["derive"] }
|
||||
colored = "2.1.0"
|
||||
dirs = "5.0.1"
|
||||
clap = { version = "4.5", features = ["derive", "env"] }
|
||||
colored = "3.0.0"
|
||||
dirs = {version = "6.0.0", optional = true }
|
||||
fastanvil = "0.31.0"
|
||||
fastnbt = "2.5.0"
|
||||
flate2 = "1.0"
|
||||
flate2 = "1.1"
|
||||
fnv = "1.0.7"
|
||||
fs2 = "0.4"
|
||||
geo = "0.29.3"
|
||||
indicatif = "0.17.8"
|
||||
geo = "0.30.0"
|
||||
image = "0.25"
|
||||
indicatif = "0.17.11"
|
||||
itertools = "0.14.0"
|
||||
nalgebra = "0.33.0"
|
||||
once_cell = "1.19.0"
|
||||
log = "0.4.27"
|
||||
once_cell = "1.21.3"
|
||||
rand = "0.8.5"
|
||||
reqwest = { version = "0.12.7", features = ["blocking", "json"] }
|
||||
rfd = { version = "0.15.1", default-features = false, features = ["tokio"] }
|
||||
rayon = "1.10.0"
|
||||
reqwest = { version = "0.12.15", features = ["blocking", "json"] }
|
||||
rfd = { version = "0.15.4", optional = true }
|
||||
semver = "1.0.23"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri-plugin-dialog = "2.0.0"
|
||||
tauri-plugin-shell = "2"
|
||||
tokio = { version = "1.42.0", features = ["full"] }
|
||||
tauri = { version = "2", optional = true }
|
||||
tauri-plugin-log = { version = "2.6.0", optional = true }
|
||||
tauri-plugin-shell = { version = "2", optional = true }
|
||||
tokio = { version = "1.47.0", features = ["full"], optional = true }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows = { version = "0.61.1", features = ["Win32_System_Console"] }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.20.0"
|
||||
|
||||
875
LICENSE
@@ -1,674 +1,201 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
129
README.md
@@ -1,99 +1,41 @@
|
||||
<p align="center">
|
||||
<img width="456" height="125" src="https://github.com/louis-e/arnis/blob/main/gitassets/logo.png?raw=true">
|
||||
</p>
|
||||
<img src="https://github.com/louis-e/arnis/blob/main/gitassets/banner.png?raw=true" width="100%" alt="Banner">
|
||||
|
||||
# Arnis [](https://github.com/louis-e/arnis/actions) [<img alt="GitHub Release" src="https://img.shields.io/github/v/release/louis-e/arnis" />](https://github.com/louis-e/arnis/releases) [<img alt="GitHub Downloads (all assets, all releases" src="https://img.shields.io/github/downloads/louis-e/arnis/total" />](https://github.com/louis-e/arnis/releases)
|
||||
# Arnis [](https://github.com/louis-e/arnis/actions) [<img alt="GitHub Release" src="https://img.shields.io/github/v/release/louis-e/arnis" />](https://github.com/louis-e/arnis/releases) [<img alt="GitHub Downloads (all assets, all releases" src="https://img.shields.io/github/downloads/louis-e/arnis/total" />](https://github.com/louis-e/arnis/releases) [](https://github.com/louis-e/arnis/releases) [](https://discord.gg/mA2g69Fhxq)
|
||||
|
||||
This open source project written in Rust generates any chosen location from the real world in Minecraft Java Edition with a high level of detail.
|
||||
Arnis creates complex and accurate Minecraft Java Edition worlds that reflect real-world geography, topography, and architecture.
|
||||
|
||||
## :desktop_computer: Example
|
||||

|
||||
This free and open source project is designed to handle large-scale geographic data from the real world and generate detailed Minecraft worlds. The algorithm processes geospatial data from OpenStreetMap as well as elevation data to create an accurate Minecraft representation of terrain and architecture.
|
||||
Generate your hometown, big cities, and natural landscapes with ease!
|
||||
|
||||
By leveraging geospatial data from OpenStreetMap and utilizing the powerful capabilities of Rust, Arnis provides an efficient and robust solution for creating complex and accurate Minecraft worlds that reflect real-world geography and architecture.
|
||||
|
||||
Arnis is designed to handle large-scale data and generate rich, immersive environments that bring real-world cities, landmarks, and natural features into the Minecraft universe. Whether you're looking to replicate your hometown, explore urban environments, or simply build something unique and realistic, Arnis generates your vision.
|
||||

|
||||
<i>This Github page is the official project website. Do not download Arnis from any other website.</i>
|
||||
|
||||
## :keyboard: Usage
|
||||
<img width="60%" src="https://github.com/louis-e/arnis/blob/main/gitassets/gui.png?raw=true"><br>
|
||||
Download the [latest release](https://github.com/louis-e/arnis/releases/) or [compile](#trophy-open-source) the project on your own.
|
||||
|
||||
Choose your area in Arnis using the rectangle tool and select your Minecraft world - then simply click on 'Start Generation'!
|
||||
The world will always be generated starting from the Minecraft coordinates 0 0 0 (/tp 0 0 0). This is the top left of your selected area.
|
||||
|
||||
If you choose to select an own world, make sure to generate a new flat world in advance in Minecraft.
|
||||
Choose your area on the map using the rectangle tool and select your Minecraft world - then simply click on <i>Start Generation</i>!
|
||||
Additionally, you can customize various generation settings, such as world scale, spawn point, or building interior generation.
|
||||
|
||||
Minecraft version 1.16.5 and below is currently not supported, but we are working on it! For the best results, use Minecraft version 1.21.4.
|
||||
## 📚 Documentation
|
||||
|
||||
## :floppy_disk: How it works
|
||||

|
||||
<img src="https://github.com/louis-e/arnis/blob/main/gitassets/documentation.png?raw=true" width="100%" alt="Banner">
|
||||
|
||||
The raw data obtained from the API *[(see FAQ)](#question-faq)* includes each element (buildings, walls, fountains, farmlands, etc.) with its respective corner coordinates (nodes) and descriptive tags. When you run Arnis, the following steps are performed automatically to generate a Minecraft world:
|
||||
|
||||
#### Processing Pipeline
|
||||
1. **Fetching Data from the Overpass API:** The script retrieves geospatial data for the desired bounding box from the Overpass API.
|
||||
2. **Parsing Raw Data:** The raw data is parsed to extract essential information like nodes, ways, and relations. Nodes are converted into Minecraft coordinates, and relations are handled similarly to ways, ensuring all relevant elements are processed correctly. Relations and ways cluster several nodes into one specific object.
|
||||
3. **Prioritizing and Sorting Elements:** The elements (nodes, ways, relations) are sorted by priority to establish a layering system, which ensures that certain types of elements (e.g., entrances and buildings) are generated in the correct order to avoid conflicts and overlapping structures.
|
||||
4. **Generating Minecraft World:** The Minecraft world is generated using a series of element processors (generate_buildings, generate_highways, generate_landuse, etc.) that interpret the tags and nodes of each element to place the appropriate blocks in the Minecraft world. These processors handle the logic for creating 3D structures, roads, natural formations, and more, as specified by the processed data.
|
||||
5. **Generating Ground Layer:** A ground layer is generated based on the provided scale factors to provide a base for the entire Minecraft world. This step ensures all areas have an appropriate foundation (e.g., grass and dirt layers).
|
||||
6. **Saving the Minecraft World:** All the modified chunks are saved back to the Minecraft region files.
|
||||
|
||||
## :question: FAQ
|
||||
- *Wasn't this written in Python before?*<br>
|
||||
Yes! Arnis was initially developed in Python, which benefited from Python's open-source friendliness and ease of readability. This is why we strive for clear, well-documented code in the Rust port of this project to find the right balance. I decided to port the project to Rust to learn more about the language and push the algorithm's performance further. We were nearing the limits of optimization in Python, and Rust's capabilities allow for even better performance and efficiency. The old Python implementation is still available in the python-legacy branch.
|
||||
- *Where does the data come from?*<br>
|
||||
The geographic data is sourced from OpenStreetMap (OSM)[^1], a free, collaborative mapping project that serves as an open-source alternative to commercial mapping services. The data is accessed via the Overpass API, which queries OSM's database.
|
||||
- *How does the Minecraft world generation work?*<br>
|
||||
The script uses the [fastnbt](https://github.com/owengage/fastnbt) cargo package to interact with Minecraft's world format. This library allows Arnis to manipulate Minecraft region files, enabling the generation of real-world locations. The section 'Processing Pipeline' goes a bit further into the details and steps of the generation process itself.
|
||||
- *Where does the name come from?*<br>
|
||||
The project is named after the smallest city in Germany, Arnis[^2]. The city's small size made it an ideal test case for developing and debugging the algorithm efficiently.
|
||||
- *I don't have Minecraft installed but want to generate a world for my kids. How?*<br>
|
||||
When selecting a world, click on 'Select existing world' and choose a directory. The world will be generated there.
|
||||
- *Arnis instantly closes again or the window is empty!*<br>
|
||||
If you're on Windows, please install the [Evergreen Bootstrapper from Microsoft](https://developer.microsoft.com/en-us/microsoft-edge/webview2/?form=MA13LH#download).
|
||||
- *What Minecraft version should I use?*<br>
|
||||
Please use Minecraft version 1.21.4 for the best results. Minecraft version 1.16.5 and below is currently not supported, but we are working on it!
|
||||
- *The generation did finish, but there's nothing in the world!*<br>
|
||||
Make sure to teleport to the generation starting point (/tp 0 0 0). If there is still nothing, you might need to travel a bit further into the positive X and positive Z direction.
|
||||
|
||||
## :memo: ToDo and Known Bugs
|
||||
Feel free to choose an item from the To-Do or Known Bugs list, or bring your own idea to the table. Bug reports shall be raised as a Github issue. Contributions are highly welcome and appreciated!
|
||||
- [ ] Fix compilation for Linux
|
||||
- [ ] Rotate maps (https://github.com/louis-e/arnis/issues/97)
|
||||
- [ ] Add street names as signs
|
||||
- [ ] Add support for older Minecraft versions (<=1.16.5) (https://github.com/louis-e/arnis/issues/124, https://github.com/louis-e/arnis/issues/137)
|
||||
- [ ] Mapping real coordinates to Minecraft coordinates (https://github.com/louis-e/arnis/issues/29)
|
||||
- [ ] Add interior to buildings
|
||||
- [ ] Implement house roof types
|
||||
- [ ] Evaluate and implement elevation (https://github.com/louis-e/arnis/issues/66)
|
||||
- [ ] Add support for inner attribute in multipolygons and multipolygon elements other than buildings
|
||||
- [ ] Fix Github Action Workflow for releasing Linux & MacOS Binary
|
||||
- [ ] Evaluate and implement faster region saving
|
||||
- [ ] Refactor bridges implementation
|
||||
- [ ] Refactor railway implementation
|
||||
- [ ] Better code documentation
|
||||
- [ ] Refactor fountain structure implementation
|
||||
- [ ] Luanti Support (https://github.com/louis-e/arnis/issues/120)
|
||||
- [ ] Minecraft Bedrock Edition Support (https://github.com/louis-e/arnis/issues/148)
|
||||
- [x] Support multipolygons (https://github.com/louis-e/arnis/issues/112, https://github.com/louis-e/arnis/issues/114)
|
||||
- [x] Memory optimization
|
||||
- [x] Design and implement a GUI
|
||||
- [x] Automatic new world creation instead of using an existing world
|
||||
- [x] Fix faulty empty chunks ([https://github.com/owengage/fastnbt/issues/120](https://github.com/owengage/fastnbt/issues/120)) (workaround found)
|
||||
- [x] Setup fork of [https://github.com/aaronr/bboxfinder.com](https://github.com/aaronr/bboxfinder.com) for easy bbox picking
|
||||
Full documentation is available in the [GitHub Wiki](https://github.com/louis-e/arnis/wiki/), covering topics such as technical explanations, FAQs, contribution guidelines and roadmaps.
|
||||
|
||||
## :trophy: Open Source
|
||||
#### Key objectives of this project
|
||||
- **Modularity**: Ensure that all components (e.g., data fetching, processing, and world generation) are cleanly separated into distinct modules for better maintainability and scalability.
|
||||
- **Performance Optimization**: Utilize Rust’s memory safety and concurrency features to optimize the performance of the world generation process.
|
||||
- **Performance Optimization**: We aim to keep a good performance and speed of the world generation process.
|
||||
- **Comprehensive Documentation**: Detailed in-code documentation for a clear structure and logic.
|
||||
- **User-Friendly Experience**: Focus on making the project easy to use for end users.
|
||||
- **Cross-Platform Support**: Ensure the project runs smoothly on Windows, macOS, and Linux.
|
||||
- **Cross-Platform Support**: We want this project to run smoothly on Windows, macOS, and Linux.
|
||||
|
||||
#### How to contribute
|
||||
This project is open source and welcomes contributions from everyone! Whether you're interested in fixing bugs, improving performance, adding new features, or enhancing documentation, your input is valuable. Simply fork the repository, make your changes, and submit a pull request. We encourage discussions and suggestions to ensure the project remains modular, optimized, and easy to use for the community. You can use the parameter --debug to get a more detailed output of the processed values, which can be helpful for debugging and development. Contributions of all levels are appreciated, and your efforts help improve this tool for everyone.
|
||||
This project is open source and welcomes contributions from everyone! Whether you're interested in fixing bugs, improving performance, adding new features, or enhancing documentation, your input is valuable. Simply fork the repository, make your changes, and submit a pull request. Please respect the above mentioned key objectives. Contributions of all levels are appreciated, and your efforts help improve this tool for everyone.
|
||||
|
||||
Build and run it using: ```cargo run --release -- --path="C:/YOUR_PATH/.minecraft/saves/worldname" --bbox="min_lng,min_lat,max_lng,max_lat"```<br>
|
||||
For the GUI: ```cargo run --release```<br>
|
||||
Command line Build: ```cargo run --no-default-features -- --terrain --path="C:/YOUR_PATH/.minecraft/saves/worldname" --bbox="min_lng,min_lat,max_lng,max_lat"```<br>
|
||||
GUI Build: ```cargo run```<br>
|
||||
|
||||
After your pull request was merged, I will take care of regularly creating update releases which will include your changes.
|
||||
|
||||
@@ -107,15 +49,42 @@ After your pull request was merged, I will take care of regularly creating updat
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
## :copyright: License Information
|
||||
This project is licensed under the GNU General Public License v3.0 (GPL-3.0).[^3]
|
||||
## :newspaper: Academic & Press Recognition
|
||||
|
||||
<img src="https://github.com/louis-e/arnis/blob/main/gitassets/recognition.png?raw=true" width="100%" alt="Banner">
|
||||
|
||||
Arnis has been recognized in various academic and press publications after gaining a lot of attention in December 2024.
|
||||
|
||||
[Floodcraft: Game-based Interactive Learning Environment using Minecraft for Flood Mitigation and Preparedness for K-12 Education](https://www.researchgate.net/publication/384644535_Floodcraft_Game-based_Interactive_Learning_Environment_using_Minecraft_for_Flood_Mitigation_and_Preparedness_for_K-12_Education)
|
||||
|
||||
[Hackaday: Bringing OpenStreetMap Data into Minecraft](https://hackaday.com/2024/12/30/bringing-openstreetmap-data-into-minecraft/)
|
||||
|
||||
[TomsHardware: Minecraft Tool Lets You Create Scale Replicas of Real-World Locations](https://www.tomshardware.com/video-games/pc-gaming/minecraft-tool-lets-you-create-scale-replicas-of-real-world-locations-arnis-uses-geospatial-data-from-openstreetmap-to-generate-minecraft-maps)
|
||||
|
||||
[XDA Developers: Hometown Minecraft Map: Arnis](https://www.xda-developers.com/hometown-minecraft-map-arnis/)
|
||||
|
||||
## :copyright: License Information
|
||||
Copyright (c) 2022-2025 Louis Erbkamm (louis-e)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.[^3]
|
||||
|
||||
Download Arnis only from the official source (https://github.com/louis-e/arnis/). Every other website providing a download and claiming to be affiliated with the project is unofficial and may be malicious.
|
||||
|
||||
The logo was made by @nxfx21.
|
||||
|
||||
|
||||
[^1]: https://en.wikipedia.org/wiki/OpenStreetMap
|
||||
|
||||
[^2]: https://en.wikipedia.org/wiki/Arnis,_Germany
|
||||
|
||||
[^3]:
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
For the full license text, see the LICENSE file.
|
||||
[^3]: https://github.com/louis-e/arnis/blob/main/LICENSE
|
||||
|
||||
32
example_transformations.json
Normal file
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"comment": "this make all elements x+=2000, z+=2000",
|
||||
"operation": "translate",
|
||||
"config": {
|
||||
"type": "vector",
|
||||
"config": {
|
||||
"vector": {
|
||||
"dx": 2000,
|
||||
"dz": 2000
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": "This drags the map at point 2000,2000 to 100,100",
|
||||
"operation": "translate",
|
||||
"config": {
|
||||
"type": "startend",
|
||||
"config": {
|
||||
"start": {
|
||||
"x": 2000,
|
||||
"z": 2000
|
||||
},
|
||||
"end": {
|
||||
"x": 0,
|
||||
"z": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -21,6 +21,13 @@
|
||||
openssl.dev
|
||||
pkg-config
|
||||
fenixPkgs.toolchain
|
||||
wayland
|
||||
glib
|
||||
gdk-pixbuf
|
||||
pango
|
||||
gtk3
|
||||
libsoup_3.dev
|
||||
webkitgtk_4_1.dev
|
||||
];
|
||||
};
|
||||
});
|
||||
|
||||
BIN
gitassets/banner.png
Normal file
|
After Width: | Height: | Size: 163 KiB |
BIN
gitassets/documentation.png
Normal file
|
After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 198 KiB After Width: | Height: | Size: 196 KiB |
|
Before Width: | Height: | Size: 19 KiB |
BIN
gitassets/mc.gif
|
Before Width: | Height: | Size: 9.7 MiB |
BIN
gitassets/preview.jpg
Normal file
|
After Width: | Height: | Size: 790 KiB |
BIN
gitassets/recognition.png
Normal file
|
After Width: | Height: | Size: 127 KiB |
15
gui-src/arnis.desktop
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Arnis
|
||||
Comment=Generate cities from real life in Minecraft
|
||||
Comment[lt]=Sugeneruokite tikrovės miestus „Minecraft“ žaidime
|
||||
Comment[de]=Generiere echte Städte in Minecraft
|
||||
Comment[fr]=Générez des villes réelles dans Minecraft
|
||||
Comment[es]=Genera ciudades reales en Minecraft
|
||||
Comment[pt]=Gere cidades reais no Minecraft
|
||||
Comment[zh_CN]=在 Minecraft 中生成现实城市
|
||||
Icon=icon
|
||||
Exec=arnis
|
||||
Categories=Game;Education;Geoscience
|
||||
Keywords=OSM;OpenStreetMap;Minecraft
|
||||
StartupWMClass=arnis
|
||||
BIN
gui-src/css/maps/images/spritesheet - Kopie.png
vendored
|
Before Width: | Height: | Size: 3.5 KiB |
49
gui-src/css/maps/leaflet.draw.ie.css
vendored
@@ -1,49 +0,0 @@
|
||||
/* Conditional stylesheet for IE. */
|
||||
|
||||
.leaflet-draw-toolbar {
|
||||
border: 3px solid #999;
|
||||
}
|
||||
|
||||
.leaflet-draw-toolbar a {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.leaflet-draw-toolbar a:hover {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.leaflet-draw-actions {
|
||||
left: 32px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.leaflet-draw-actions li {
|
||||
display: inline;
|
||||
zoom: 1;
|
||||
}
|
||||
|
||||
.leaflet-edit-marker-selected {
|
||||
border: 4px dashed #fe93c2;
|
||||
}
|
||||
|
||||
.leaflet-draw-actions a {
|
||||
background-color: #999;
|
||||
}
|
||||
|
||||
.leaflet-draw-actions a:hover {
|
||||
background-color: #a5a5a5;
|
||||
}
|
||||
|
||||
.leaflet-draw-actions-top a {
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.leaflet-draw-actions-bottom a {
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
.leaflet-draw-actions-top.leaflet-draw-actions-bottom a {
|
||||
height: 27px;
|
||||
line-height: 27px;
|
||||
}
|
||||
51
gui-src/css/maps/leaflet.ie.css
vendored
@@ -1,51 +0,0 @@
|
||||
.leaflet-vml-shape {
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
.lvml {
|
||||
behavior: url(#default#VML);
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.leaflet-control {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.leaflet-popup-tip {
|
||||
width: 21px;
|
||||
_width: 27px;
|
||||
margin: 0 auto;
|
||||
_margin-top: -3px;
|
||||
|
||||
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
|
||||
}
|
||||
.leaflet-popup-tip-container {
|
||||
margin-top: -1px;
|
||||
}
|
||||
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
|
||||
border: 1px solid #999;
|
||||
}
|
||||
.leaflet-popup-content-wrapper {
|
||||
zoom: 1;
|
||||
}
|
||||
|
||||
.leaflet-control-zoom,
|
||||
.leaflet-control-layers {
|
||||
border: 3px solid #999;
|
||||
}
|
||||
.leaflet-control-layers-toggle {
|
||||
}
|
||||
.leaflet-control-attribution,
|
||||
.leaflet-control-layers,
|
||||
.leaflet-control-scale-line {
|
||||
background: white;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
filter: alpha(opacity=50);
|
||||
}
|
||||
.leaflet-control-attribution {
|
||||
border-top: 1px solid #bbb;
|
||||
border-left: 1px solid #bbb;
|
||||
}
|
||||
757
gui-src/css/maps/mapbox.standalone.css
vendored
@@ -1,757 +0,0 @@
|
||||
/* general typography */
|
||||
.leaflet-container {
|
||||
background:#fff;
|
||||
font:15px/25px 'Helvetica Neue', Arial, Helvetica, sans-serif;
|
||||
color:#404040;
|
||||
color:rgba(0,0,0,0.75);
|
||||
outline:0;
|
||||
overflow:hidden;
|
||||
-ms-touch-action:none;
|
||||
}
|
||||
.leaflet-container *,
|
||||
.leaflet-container *:after,
|
||||
.leaflet-container *:before {
|
||||
-webkit-box-sizing:border-box;
|
||||
-moz-box-sizing:border-box;
|
||||
box-sizing:border-box;
|
||||
}
|
||||
|
||||
.leaflet-container h1,
|
||||
.leaflet-container h2,
|
||||
.leaflet-container h3,
|
||||
.leaflet-container h4,
|
||||
.leaflet-container h5,
|
||||
.leaflet-container h6,
|
||||
.leaflet-container p {
|
||||
font-size:15px;
|
||||
line-height:25px;
|
||||
margin:0 0 10px;
|
||||
}
|
||||
.mapbox-small,
|
||||
.leaflet-control-attribution,
|
||||
.leaflet-control-scale,
|
||||
.leaflet-container input,
|
||||
.leaflet-container textarea,
|
||||
.leaflet-container label,
|
||||
.leaflet-container small {
|
||||
font-size:12px;
|
||||
line-height:20px;
|
||||
}
|
||||
|
||||
.leaflet-container a {
|
||||
color:#3887BE;
|
||||
font-weight:normal;
|
||||
text-decoration:none;
|
||||
}
|
||||
.leaflet-container a:hover { color:#63b6e5; }
|
||||
.leaflet-container.dark a { color:#63b6e5; }
|
||||
.leaflet-container.dark a:hover { color:#8fcaec; }
|
||||
|
||||
.leaflet-container.dark .mapbox-button,
|
||||
.leaflet-container .mapbox-button {
|
||||
background-color:#3887be;
|
||||
display:inline-block;
|
||||
height:40px;
|
||||
line-height:40px;
|
||||
text-decoration:none;
|
||||
color:#fff;
|
||||
font-size:12px;
|
||||
white-space:nowrap;
|
||||
text-overflow:ellipsis;
|
||||
}
|
||||
.leaflet-container.dark .mapbox-button:hover,
|
||||
.leaflet-container .mapbox-button:hover {
|
||||
color:#fff;
|
||||
background-color:#3bb2d0;
|
||||
}
|
||||
|
||||
/* Base Leaflet
|
||||
------------------------------------------------------- */
|
||||
.leaflet-map-pane,
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow,
|
||||
.leaflet-tile-pane,
|
||||
.leaflet-tile-container,
|
||||
.leaflet-overlay-pane,
|
||||
.leaflet-shadow-pane,
|
||||
.leaflet-marker-pane,
|
||||
.leaflet-popup-pane,
|
||||
.leaflet-overlay-pane svg,
|
||||
.leaflet-zoom-box,
|
||||
.leaflet-image-layer,
|
||||
.leaflet-layer {
|
||||
position:absolute;
|
||||
left:0;
|
||||
top:0;
|
||||
}
|
||||
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
-webkit-user-drag:none;
|
||||
-webkit-user-select:none;
|
||||
-moz-user-select:none;
|
||||
user-select:none;
|
||||
}
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.leaflet-tile {
|
||||
filter:inherit;
|
||||
visibility:hidden;
|
||||
}
|
||||
.leaflet-tile-loaded {
|
||||
visibility:inherit;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
width:0;
|
||||
height:0;
|
||||
}
|
||||
|
||||
.leaflet-tile-pane { z-index:2; }
|
||||
.leaflet-objects-pane { z-index:3; }
|
||||
.leaflet-overlay-pane { z-index:4; }
|
||||
.leaflet-shadow-pane { z-index:5; }
|
||||
.leaflet-marker-pane { z-index:6; }
|
||||
.leaflet-popup-pane { z-index:7; }
|
||||
|
||||
.leaflet-control {
|
||||
position:relative;
|
||||
z-index:7;
|
||||
pointer-events:auto;
|
||||
float:left;
|
||||
clear:both;
|
||||
}
|
||||
.leaflet-right .leaflet-control { float:right; }
|
||||
.leaflet-top .leaflet-control { margin-top:10px; }
|
||||
.leaflet-bottom .leaflet-control { margin-bottom:10px; }
|
||||
.leaflet-left .leaflet-control { margin-left:10px; }
|
||||
.leaflet-right .leaflet-control { margin-right:10px; }
|
||||
|
||||
.leaflet-top,
|
||||
.leaflet-bottom {
|
||||
position:absolute;
|
||||
z-index:1000;
|
||||
pointer-events:none;
|
||||
}
|
||||
.leaflet-top { top:0; }
|
||||
.leaflet-right { right:0; }
|
||||
.leaflet-bottom { bottom:0; }
|
||||
.leaflet-left { left:0; }
|
||||
|
||||
/* zoom and fade animations */
|
||||
.leaflet-fade-anim .leaflet-tile,
|
||||
.leaflet-fade-anim .leaflet-popup {
|
||||
opacity:0;
|
||||
-webkit-transition:opacity 0.2s linear;
|
||||
-moz-transition:opacity 0.2s linear;
|
||||
-o-transition:opacity 0.2s linear;
|
||||
transition:opacity 0.2s linear;
|
||||
}
|
||||
.leaflet-fade-anim .leaflet-tile-loaded,
|
||||
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
|
||||
opacity:1;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-animated {
|
||||
-webkit-transition:-webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
}
|
||||
.leaflet-zoom-anim .leaflet-tile,
|
||||
.leaflet-pan-anim .leaflet-tile,
|
||||
.leaflet-touching .leaflet-zoom-animated {
|
||||
-webkit-transition:none;
|
||||
-moz-transition:none;
|
||||
-o-transition:none;
|
||||
transition:none;
|
||||
}
|
||||
.leaflet-zoom-anim .leaflet-zoom-hide { visibility: hidden; }
|
||||
|
||||
/* cursors */
|
||||
.map-clickable,
|
||||
.leaflet-clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
.leaflet-popup-pane,
|
||||
.leaflet-control {
|
||||
cursor:auto;
|
||||
}
|
||||
.leaflet-container {
|
||||
cursor:-webkit-grab;
|
||||
cursor: -moz-grab;
|
||||
}
|
||||
.leaflet-dragging,
|
||||
.leaflet-dragging .map-clickable,
|
||||
.leaflet-dragging .leaflet-clickable,
|
||||
.leaflet-dragging .leaflet-container {
|
||||
cursor:move;
|
||||
cursor:-webkit-grabbing;
|
||||
cursor: -moz-grabbing;
|
||||
}
|
||||
|
||||
.leaflet-zoom-box {
|
||||
background:#fff;
|
||||
border:2px dotted #202020;
|
||||
opacity:0.5;
|
||||
}
|
||||
|
||||
/* general toolbar styles */
|
||||
.leaflet-control-layers,
|
||||
.leaflet-bar {
|
||||
background-color:#fff;
|
||||
border:1px solid #999;
|
||||
border-color:rgba(0,0,0,0.4);
|
||||
border-radius:3px;
|
||||
box-shadow:none;
|
||||
}
|
||||
.leaflet-bar a,
|
||||
.leaflet-bar a:hover {
|
||||
color:#404040;
|
||||
color:rgba(0,0,0,0.75);
|
||||
border-bottom:1px solid #ddd;
|
||||
border-bottom-color:rgba(0,0,0,0.10);
|
||||
}
|
||||
.leaflet-bar a:hover,
|
||||
.leaflet-bar a:active {
|
||||
background-color:#f8f8f8;
|
||||
cursor:pointer;
|
||||
}
|
||||
.leaflet-bar a:first-child {
|
||||
border-radius:3px 3px 0 0;
|
||||
}
|
||||
.leaflet-bar a:last-child {
|
||||
border-bottom:none;
|
||||
border-radius:0 0 3px 3px;
|
||||
}
|
||||
.leaflet-bar a:only-of-type {
|
||||
border-radius:3px;
|
||||
}
|
||||
|
||||
.leaflet-bar .leaflet-disabled {
|
||||
cursor:default;
|
||||
opacity:0.75;
|
||||
}
|
||||
.leaflet-control-zoom-in,
|
||||
.leaflet-control-zoom-out {
|
||||
display:block;
|
||||
content:'';
|
||||
text-indent:-999em;
|
||||
}
|
||||
|
||||
.leaflet-control-layers .leaflet-control-layers-list,
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
|
||||
display:none;
|
||||
}
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-list {
|
||||
display:block;
|
||||
position:relative;
|
||||
}
|
||||
|
||||
.leaflet-control-layers-expanded {
|
||||
background:#fff;
|
||||
padding:6px 10px 6px 6px;
|
||||
color:#404040;
|
||||
color:rgba(0,0,0,0.75);
|
||||
}
|
||||
.leaflet-control-layers-selector {
|
||||
margin-top:2px;
|
||||
position:relative;
|
||||
top:1px;
|
||||
}
|
||||
.leaflet-control-layers label {
|
||||
display: block;
|
||||
}
|
||||
.leaflet-control-layers-separator {
|
||||
height:0;
|
||||
border-top:1px solid #ddd;
|
||||
border-top-color:rgba(0,0,0,0.10);
|
||||
margin:5px -10px 5px -6px;
|
||||
}
|
||||
|
||||
.leaflet-container .leaflet-control-attribution {
|
||||
background-color:rgba(255,255,255,0.25);
|
||||
margin:0;
|
||||
box-shadow:none;
|
||||
}
|
||||
.leaflet-control-attribution a:hover,
|
||||
.map-info-container a:hover {
|
||||
color:inherit;
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
||||
.leaflet-control-attribution,
|
||||
.leaflet-control-scale-line {
|
||||
padding:0 5px;
|
||||
}
|
||||
.leaflet-left .leaflet-control-scale { margin-left:5px; }
|
||||
.leaflet-bottom .leaflet-control-scale { margin-bottom:5px; }
|
||||
|
||||
.leaflet-control-scale-line {
|
||||
background-color:rgba(255,255,255,0.5);
|
||||
border:1px solid #999;
|
||||
border-color:rgba(0,0,0,0.4);
|
||||
border-top:none;
|
||||
padding:2px 5px 1px;
|
||||
white-space:nowrap;
|
||||
overflow:hidden;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child) {
|
||||
border-top:2px solid #ddd;
|
||||
border-top-color:rgba(0,0,0,0.10);
|
||||
border-bottom:none;
|
||||
margin-top:-2px;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
|
||||
border-bottom:2px solid #777;
|
||||
}
|
||||
|
||||
/* popup */
|
||||
.leaflet-popup {
|
||||
position:absolute;
|
||||
text-align:center;
|
||||
pointer-events:none;
|
||||
}
|
||||
.leaflet-popup-content-wrapper {
|
||||
padding:1px;
|
||||
text-align:left;
|
||||
pointer-events:all;
|
||||
}
|
||||
.leaflet-popup-content {
|
||||
padding:10px 10px 15px;
|
||||
margin:0;
|
||||
line-height:inherit;
|
||||
}
|
||||
.leaflet-popup-tip-container {
|
||||
width:20px;
|
||||
height:20px;
|
||||
margin:0 auto;
|
||||
position:relative;
|
||||
}
|
||||
.leaflet-popup-tip {
|
||||
width:0;
|
||||
height:0;
|
||||
margin:0;
|
||||
border-left:10px solid transparent;
|
||||
border-right:10px solid transparent;
|
||||
border-top:10px solid #fff;
|
||||
box-shadow:none;
|
||||
}
|
||||
.leaflet-popup-close-button {
|
||||
text-indent:-999em;
|
||||
position:absolute;
|
||||
top:0;right:0;
|
||||
pointer-events:all;
|
||||
}
|
||||
.leaflet-popup-close-button:hover {
|
||||
background-color:#f8f8f8;
|
||||
}
|
||||
|
||||
.leaflet-popup-scrolled {
|
||||
overflow:auto;
|
||||
border-bottom:1px solid #ddd;
|
||||
border-top:1px solid #ddd;
|
||||
}
|
||||
|
||||
/* div icon */
|
||||
.leaflet-div-icon {
|
||||
background:#fff;
|
||||
border:1px solid #999;
|
||||
border-color:rgba(0,0,0,0.4);
|
||||
}
|
||||
.leaflet-editing-icon {
|
||||
border-radius:3px;
|
||||
}
|
||||
|
||||
/* Leaflet + Mapbox
|
||||
------------------------------------------------------- */
|
||||
.leaflet-bar a,
|
||||
.mapbox-icon,
|
||||
.map-tooltip.closable .close,
|
||||
.leaflet-control-layers-toggle,
|
||||
.leaflet-popup-close-button,
|
||||
.mapbox-button-icon:before {
|
||||
content:'';
|
||||
display:inline-block;
|
||||
width:26px;
|
||||
height:26px;
|
||||
vertical-align:middle;
|
||||
background-repeat:no-repeat;
|
||||
}
|
||||
.leaflet-bar a {
|
||||
display:block;
|
||||
}
|
||||
|
||||
.leaflet-control-zoom-in,
|
||||
.leaflet-control-zoom-out,
|
||||
.leaflet-popup-close-button,
|
||||
.leaflet-control-layers-toggle,
|
||||
.leaflet-container.dark .map-tooltip .close,
|
||||
.map-tooltip .close,
|
||||
.mapbox-icon {
|
||||
background-image:url(./images/icons-404040.png);
|
||||
background-repeat:no-repeat;
|
||||
background-size:26px 260px;
|
||||
}
|
||||
.mapbox-button-icon:before,
|
||||
.leaflet-container.dark .leaflet-control-zoom-in,
|
||||
.leaflet-container.dark .leaflet-control-zoom-out,
|
||||
.leaflet-container.dark .leaflet-control-layers-toggle,
|
||||
.leaflet-container.dark .mapbox-icon {
|
||||
background-image:url(./images/icons-ffffff.png);
|
||||
background-size:26px 260px;
|
||||
}
|
||||
.leaflet-bar .leaflet-control-zoom-in { background-position:0 0; }
|
||||
.leaflet-bar .leaflet-control-zoom-out { background-position:0 -26px; }
|
||||
.map-tooltip .close, .leaflet-popup-close-button { background-position:0 -52px; }
|
||||
.mapbox-icon-info { background-position:0 -78px; }
|
||||
.leaflet-control-layers-toggle { background-position:0 -104px; }
|
||||
.mapbox-icon-share:before, .mapbox-icon-share { background-position:0 -130px; }
|
||||
.mapbox-icon-geocoder:before, .mapbox-icon-geocoder { background-position:0 -156px; }
|
||||
.mapbox-icon-facebook:before, .mapbox-icon-facebook { background-position:0 -182px; }
|
||||
.mapbox-icon-twitter:before, .mapbox-icon-twitter { background-position:0 -208px; }
|
||||
.mapbox-icon-pinterest:before, .mapbox-icon-pinterest { background-position:0 -234px; }
|
||||
|
||||
@media
|
||||
(-webkit-min-device-pixel-ratio:2),
|
||||
(min-resolution:192dpi) {
|
||||
.leaflet-control-zoom-in,
|
||||
.leaflet-control-zoom-out,
|
||||
.leaflet-popup-close-button,
|
||||
.leaflet-control-layers-toggle,
|
||||
.mapbox-icon {
|
||||
background-image:url(./images/icons-404040@2x.png);
|
||||
}
|
||||
.mapbox-button-icon:before,
|
||||
.leaflet-container.dark .leaflet-control-zoom-in,
|
||||
.leaflet-container.dark .leaflet-control-zoom-out,
|
||||
.leaflet-container.dark .leaflet-control-layers-toggle,
|
||||
.leaflet-container.dark .mapbox-icon {
|
||||
background-image:url(./images/icons-ffffff@2x.png);
|
||||
}
|
||||
}
|
||||
|
||||
.leaflet-popup-content-wrapper,
|
||||
.map-legends,
|
||||
.map-tooltip {
|
||||
background:#fff;
|
||||
border-radius:3px;
|
||||
box-shadow:0 1px 2px rgba(0,0,0,0.10);
|
||||
}
|
||||
.map-legends,
|
||||
.map-tooltip {
|
||||
max-width:300px;
|
||||
}
|
||||
.map-legends .map-legend {
|
||||
padding:10px;
|
||||
}
|
||||
.map-tooltip {
|
||||
z-index:999999;
|
||||
padding:10px;
|
||||
min-width:180px;
|
||||
max-height:400px;
|
||||
overflow:auto;
|
||||
opacity:1;
|
||||
-webkit-transition:opacity 150ms;
|
||||
-moz-transition:opacity 150ms;
|
||||
-o-transition:opacity 150ms;
|
||||
transition:opacity 150ms;
|
||||
}
|
||||
|
||||
.map-tooltip .close {
|
||||
text-indent:-999em;
|
||||
overflow:hidden;
|
||||
display:none;
|
||||
}
|
||||
.map-tooltip.closable .close {
|
||||
position:absolute;
|
||||
top:0;right:0;
|
||||
border-radius:3px;
|
||||
}
|
||||
.map-tooltip.closable .close:active {
|
||||
background-color:#f8f8f8;
|
||||
}
|
||||
|
||||
.leaflet-control-interaction {
|
||||
position:absolute;
|
||||
top:10px;
|
||||
right:10px;
|
||||
width:300px;
|
||||
}
|
||||
.leaflet-popup-content .marker-title {
|
||||
font-weight:bold;
|
||||
}
|
||||
.leaflet-control .mapbox-button {
|
||||
background-color:#fff;
|
||||
border:1px solid #ddd;
|
||||
border-color:rgba(0,0,0,0.10);
|
||||
padding:5px 10px;
|
||||
border-radius:3px;
|
||||
}
|
||||
|
||||
/* Share modal
|
||||
------------------------------------------------------- */
|
||||
.mapbox-modal > div {
|
||||
position:absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
width:100%;
|
||||
height:100%;
|
||||
z-index:-1;
|
||||
overflow-y:auto;
|
||||
}
|
||||
.mapbox-modal.active > div {
|
||||
z-index:99999;
|
||||
transition:all .2s, z-index 0 0;
|
||||
}
|
||||
|
||||
.mapbox-modal .mapbox-modal-mask {
|
||||
background:rgba(0,0,0,0.5);
|
||||
opacity:0;
|
||||
}
|
||||
.mapbox-modal.active .mapbox-modal-mask { opacity:1; }
|
||||
|
||||
.mapbox-modal .mapbox-modal-content {
|
||||
-webkit-transform:translateY(-100%);
|
||||
-moz-transform:translateY(-100%);
|
||||
-ms-transform:translateY(-100%);
|
||||
transform:translateY(-100%);
|
||||
}
|
||||
.mapbox-modal.active .mapbox-modal-content {
|
||||
-webkit-transform:translateY(0);
|
||||
-moz-transform:translateY(0);
|
||||
-ms-transform:translateY(0);
|
||||
transform:translateY(0);
|
||||
}
|
||||
|
||||
.mapbox-modal-body {
|
||||
position:relative;
|
||||
background:#fff;
|
||||
padding:20px;
|
||||
z-index:1000;
|
||||
width:50%;
|
||||
margin:20px 0 20px 25%;
|
||||
}
|
||||
.mapbox-share-buttons {
|
||||
margin:0 0 20px;
|
||||
}
|
||||
.mapbox-share-buttons a {
|
||||
width:33.3333%;
|
||||
border-left:1px solid #fff;
|
||||
text-align:center;
|
||||
border-radius:0;
|
||||
}
|
||||
.mapbox-share-buttons a:last-child { border-radius:0 3px 3px 0; }
|
||||
.mapbox-share-buttons a:first-child { border:none; border-radius:3px 0 0 3px; }
|
||||
|
||||
.mapbox-modal input {
|
||||
width:100%;
|
||||
height:40px;
|
||||
padding:10px;
|
||||
border:1px solid #ddd;
|
||||
border-color:rgba(0,0,0,0.10);
|
||||
color:rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
/* Info Control
|
||||
------------------------------------------------------- */
|
||||
.leaflet-control.mapbox-control-info {
|
||||
margin:5px 30px 10px 10px;
|
||||
min-height:26px;
|
||||
}
|
||||
.leaflet-control.mapbox-control-info-right {
|
||||
margin:5px 10px 10px 30px;
|
||||
}
|
||||
|
||||
.mapbox-info-toggle {
|
||||
background-color:#fff;
|
||||
background-color:rgba(255,255,255,0.25);
|
||||
border-radius:50%;
|
||||
position:absolute;
|
||||
bottom:0;left:0;
|
||||
z-index:1;
|
||||
}
|
||||
.mapbox-control-info-right .mapbox-info-toggle { left:auto; right:0; }
|
||||
.mapbox-control-info.active .mapbox-info-toggle { background-color:#fff; }
|
||||
.mapbox-info-toggle:hover { background-color:rgba(255,255,255,0.5); }
|
||||
|
||||
.map-info-container {
|
||||
background:#fff;
|
||||
background:rgba(255,255,255,0.75);
|
||||
padding:3px 5px 3px 15px;
|
||||
display:none;
|
||||
position:relative;
|
||||
bottom:0;
|
||||
left:13px;
|
||||
border-radius:3px;
|
||||
}
|
||||
.mapbox-control-info.active .map-info-container { display:inline-block; }
|
||||
.mapbox-control-info-right .map-info-container {
|
||||
left:auto;
|
||||
right:13px;
|
||||
padding:3px 15px 3px 5px;
|
||||
}
|
||||
|
||||
/* Geocoder
|
||||
------------------------------------------------------- */
|
||||
.leaflet-control-mapbox-geocoder {
|
||||
position:relative;
|
||||
}
|
||||
.leaflet-control-mapbox-geocoder.searching {
|
||||
opacity:0.75;
|
||||
}
|
||||
.leaflet-control-mapbox-geocoder .leaflet-control-mapbox-geocoder-wrap {
|
||||
background:#fff;
|
||||
position:absolute;
|
||||
border:1px solid #999;
|
||||
border-color:rgba(0,0,0,0.4);
|
||||
border-bottom-width:0;
|
||||
overflow:hidden;
|
||||
left:26px;
|
||||
height:27px;
|
||||
width:0;
|
||||
top:-1px;
|
||||
border-radius:0 3px 3px 0;
|
||||
opacity:0;
|
||||
-webkit-transition:opacity 100ms;
|
||||
-moz-transition:opacity 100ms;
|
||||
-o-transition:opacity 100ms;
|
||||
transition:opacity 100ms;
|
||||
}
|
||||
.leaflet-control-mapbox-geocoder.active .leaflet-control-mapbox-geocoder-wrap {
|
||||
width:180px;
|
||||
opacity:1;
|
||||
}
|
||||
.leaflet-bar .leaflet-control-mapbox-geocoder-toggle,
|
||||
.leaflet-bar .leaflet-control-mapbox-geocoder-toggle:hover {
|
||||
border-bottom:none;
|
||||
}
|
||||
.leaflet-control-mapbox-geocoder-toggle {
|
||||
border-radius:3px;
|
||||
}
|
||||
.leaflet-control-mapbox-geocoder.active,
|
||||
.leaflet-control-mapbox-geocoder.active .leaflet-control-mapbox-geocoder-toggle {
|
||||
border-top-right-radius:0;
|
||||
border-bottom-right-radius:0;
|
||||
}
|
||||
.leaflet-control-mapbox-geocoder .leaflet-control-mapbox-geocoder-form input {
|
||||
background:transparent;
|
||||
border:0;
|
||||
width:180px;
|
||||
padding:0 0 0 10px;
|
||||
height:26px;
|
||||
outline:none;
|
||||
}
|
||||
.leaflet-control-mapbox-geocoder-results {
|
||||
width:180px;
|
||||
position:absolute;
|
||||
left:26px;
|
||||
top:25px;
|
||||
border-radius:0 0 3px 3px;
|
||||
}
|
||||
.leaflet-control-mapbox-geocoder.active .leaflet-control-mapbox-geocoder-results {
|
||||
background:#fff;
|
||||
border:1px solid #999;
|
||||
border-color:rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.leaflet-control-mapbox-geocoder-results a,
|
||||
.leaflet-control-mapbox-geocoder-results span {
|
||||
padding:0 10px;
|
||||
text-overflow:ellipsis;
|
||||
white-space:nowrap;
|
||||
display:block;
|
||||
width:100%;
|
||||
font-size:12px;
|
||||
line-height:26px;
|
||||
text-align:left;
|
||||
overflow:hidden;
|
||||
}
|
||||
.leaflet-control-mapbox-geocoder-results a:first-child {
|
||||
border-top:1px solid #999;
|
||||
border-top-color:rgba(0,0,0,0.4);
|
||||
border-radius:0;
|
||||
}
|
||||
.leaflet-container.dark .leaflet-control .leaflet-control-mapbox-geocoder-results a:hover,
|
||||
.leaflet-control-mapbox-geocoder-results a:hover {
|
||||
background:#f8f8f8;
|
||||
opacity:1;
|
||||
}
|
||||
|
||||
/* Dark Theme
|
||||
------------------------------------------------------- */
|
||||
.leaflet-container.dark .leaflet-bar {
|
||||
background-color:#404040;
|
||||
border-color:#202020;
|
||||
border-color:rgba(0,0,0,0.75);
|
||||
}
|
||||
.leaflet-container.dark .leaflet-bar a {
|
||||
color:#404040;
|
||||
border-color:rgba(0,0,0,0.5);
|
||||
}
|
||||
.leaflet-container.dark .leaflet-bar a:active,
|
||||
.leaflet-container.dark .leaflet-bar a:hover {
|
||||
background-color:#505050;
|
||||
}
|
||||
|
||||
.leaflet-container.dark .mapbox-info-toggle,
|
||||
.leaflet-container.dark .map-info-container,
|
||||
.leaflet-container.dark .leaflet-control-attribution {
|
||||
background-color:rgba(0,0,0,0.25);
|
||||
color:#f8f8f8;
|
||||
}
|
||||
.leaflet-container.dark .leaflet-bar a.leaflet-disabled,
|
||||
.leaflet-container.dark .leaflet-control .mapbox-button.disabled {
|
||||
background-color:#252525;
|
||||
color:#404040;
|
||||
}
|
||||
.leaflet-container.dark .leaflet-control-mapbox-geocoder > div {
|
||||
border-color:#202020;
|
||||
border-color:rgba(0,0,0,0.75);
|
||||
}
|
||||
.leaflet-container.dark .leaflet-control .leaflet-control-mapbox-geocoder-results a {
|
||||
border-color:#ddd #202020;
|
||||
border-color:rgba(0,0,0,0.10) rgba(0,0,0,0.75);
|
||||
}
|
||||
.leaflet-container.dark .leaflet-control .leaflet-control-mapbox-geocoder-results span {
|
||||
border-color:#202020;
|
||||
border-color:rgba(0,0,0,0.75);
|
||||
}
|
||||
|
||||
/* Larger Screens
|
||||
------------------------------------------------------- */
|
||||
@media only screen and (max-width:800px) {
|
||||
.mapbox-modal-body {
|
||||
width:83.3333%;
|
||||
margin-left:8.3333%;
|
||||
}
|
||||
}
|
||||
|
||||
/* Smaller Screens
|
||||
------------------------------------------------------- */
|
||||
@media only screen and (max-width:640px) {
|
||||
.mapbox-modal-body {
|
||||
width:100%;
|
||||
height:100%;
|
||||
margin:0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Browser Fixes
|
||||
------------------------------------------------------- */
|
||||
/* Map is broken in FF if you have max-width: 100% on tiles */
|
||||
.leaflet-container img { max-width:none!important; }
|
||||
/* Stupid Android 2 doesn't understand "max-width: none" properly */
|
||||
.leaflet-container img.leaflet-image-layer { max-width:15000px!important; }
|
||||
/* Android chrome makes tiles disappear without this */
|
||||
.leaflet-tile-container img { -webkit-backface-visibility:hidden; }
|
||||
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
|
||||
.leaflet-overlay-pane svg { -moz-user-select:none; }
|
||||
/* Older IEs don't support the translateY property for display animation */
|
||||
.leaflet-oldie .mapbox-modal .mapbox-modal-content { display:none; }
|
||||
.leaflet-oldie .mapbox-modal.active .mapbox-modal-content { display:block; }
|
||||
.map-tooltip { width:280px\8; /* < IE9 */ }
|
||||
1
gui-src/css/maps/mapbox.v3.2.0.css
vendored
97
gui-src/css/search.css
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
/* City Search Box Styles */
|
||||
#search-container {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
z-index: 1000;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
#search-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#city-search {
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px 0 0 3px;
|
||||
padding: 6px 10px;
|
||||
font-size: 13px;
|
||||
width: 200px;
|
||||
outline: none;
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
#city-search:focus {
|
||||
border-color: #007cbb;
|
||||
box-shadow: 0 0 5px rgba(0, 124, 187, 0.3);
|
||||
}
|
||||
|
||||
#search-btn {
|
||||
background: #007cbb;
|
||||
color: white;
|
||||
border: 1px solid #007cbb;
|
||||
border-radius: 0 3px 3px 0;
|
||||
padding: 4.5px 10px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
#search-results {
|
||||
max-height: 200px;
|
||||
max-width: 238px;
|
||||
overflow-y: auto;
|
||||
border-top: 1px solid #eee;
|
||||
display: none;
|
||||
background: white;
|
||||
border-radius: 0 0 3px 3px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.search-result-item {
|
||||
padding: 10px 12px;
|
||||
cursor: pointer;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.search-result-item:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.search-result-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.search-result-name {
|
||||
font-weight: bold;
|
||||
color: #007cbb;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.search-result-details {
|
||||
color: #666;
|
||||
font-size: 11px;
|
||||
margin-top: 2px;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.search-loading {
|
||||
padding: 10px 12px;
|
||||
text-align: center;
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.search-no-results {
|
||||
padding: 10px 12px;
|
||||
text-align: center;
|
||||
color: #999;
|
||||
}
|
||||
223
gui-src/css/styles.css
vendored
@@ -10,6 +10,11 @@
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
|
||||
/* CSS Variables for consistent theming */
|
||||
--primary-accent: #fecc44;
|
||||
--primary-accent-dark: #e6b73d;
|
||||
--primary-accent-light: #fff2cc;
|
||||
}
|
||||
|
||||
p {
|
||||
@@ -43,12 +48,13 @@ p {
|
||||
|
||||
a {
|
||||
font-weight: 500;
|
||||
color: #646cff;
|
||||
color: var(--primary-accent);
|
||||
text-decoration: inherit;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #535bf2;
|
||||
color: var(--primary-accent-dark);
|
||||
}
|
||||
|
||||
.flex-container {
|
||||
@@ -186,6 +192,7 @@ button:hover {
|
||||
button {
|
||||
color: #ffffff;
|
||||
background-color: #0f0f0f98;
|
||||
border-style: inherit;
|
||||
}
|
||||
button:active {
|
||||
background-color: #0f0f0f69;
|
||||
@@ -202,39 +209,6 @@ button:hover {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tooltip .tooltiptext {
|
||||
visibility: hidden;
|
||||
width: 90%;
|
||||
background-color: #808080;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 5px 0;
|
||||
border-radius: 6px;
|
||||
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
bottom: -100%;
|
||||
left: 5%;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.tooltip .tooltiptext::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: -10px;
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
border-width: 5px;
|
||||
border-style: solid;
|
||||
border-color: transparent transparent #808080 transparent;
|
||||
}
|
||||
|
||||
.tooltip:hover .tooltiptext {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.controls-box button {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -275,11 +249,35 @@ button:hover {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
#winter-toggle {
|
||||
#terrain-toggle {
|
||||
accent-color: #fecc44;
|
||||
}
|
||||
|
||||
.winter-toggle-container, .scale-slider-container {
|
||||
.terrain-toggle-container, .scale-slider-container {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
#fillground-toggle {
|
||||
accent-color: #fecc44;
|
||||
}
|
||||
|
||||
.fillground-toggle-container, .scale-slider-container {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
#interior-toggle {
|
||||
accent-color: #fecc44;
|
||||
}
|
||||
|
||||
.interior-toggle-container, .scale-slider-container {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
#roof-toggle {
|
||||
accent-color: #fecc44;
|
||||
}
|
||||
|
||||
.roof-toggle-container, .scale-slider-container {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
@@ -320,6 +318,132 @@ button:hover {
|
||||
box-shadow: 0 0 5px #fecc44;
|
||||
}
|
||||
|
||||
/* Settings Modal Layout */
|
||||
.settings-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.settings-row label {
|
||||
text-align: left;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.settings-control {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.settings-control input[type="range"] {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.settings-control input[type="text"],
|
||||
.settings-control input[type="number"] {
|
||||
width: 100%;
|
||||
max-width: 180px;
|
||||
padding: 5px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #fecc44;
|
||||
}
|
||||
|
||||
.license-button-row {
|
||||
justify-content: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.license-button {
|
||||
width: 80% !important;
|
||||
}
|
||||
|
||||
/* Buy Me a Coffee and Discord styling */
|
||||
.buymeacoffee-row {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
margin-top: 10px;
|
||||
margin-bottom: -10px;
|
||||
}
|
||||
|
||||
.buymeacoffee-link,
|
||||
.discord-link {
|
||||
display: inline-block;
|
||||
transition: transform 0.3s ease, opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.buymeacoffee-link:hover,
|
||||
.discord-link:hover {
|
||||
transform: scale(1.05);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.buymeacoffee-logo,
|
||||
.discord-logo {
|
||||
height: 35px;
|
||||
width: auto;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
/* Language dropdown styling */
|
||||
.language-dropdown {
|
||||
width: 100%;
|
||||
max-width: 180px;
|
||||
padding: 5px 8px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #fecc44;
|
||||
background-color: #ffffff;
|
||||
color: #0f0f0f;
|
||||
appearance: menulist;
|
||||
cursor: pointer;
|
||||
font-size: 15px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
.language-dropdown option {
|
||||
padding: 5px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.language-dropdown {
|
||||
background-color: #0f0f0f98;
|
||||
color: #ffffff;
|
||||
border: 1px solid #fecc44;
|
||||
}
|
||||
}
|
||||
|
||||
/* Theme dropdown styling */
|
||||
.theme-dropdown {
|
||||
width: 100%;
|
||||
max-width: 180px;
|
||||
padding: 5px 8px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #fecc44;
|
||||
background-color: #ffffff;
|
||||
color: #0f0f0f;
|
||||
appearance: menulist;
|
||||
cursor: pointer;
|
||||
font-size: 15px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
.theme-dropdown option {
|
||||
padding: 5px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.theme-dropdown {
|
||||
background-color: #0f0f0f98;
|
||||
color: #ffffff;
|
||||
border: 1px solid #fecc44;
|
||||
}
|
||||
}
|
||||
|
||||
.button-container {
|
||||
display: flex;
|
||||
@@ -356,3 +480,28 @@ button:hover {
|
||||
content: "⚙️";
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
/* Logo Animation */
|
||||
#arnis-logo {
|
||||
width: 35%;
|
||||
height: auto;
|
||||
opacity: 0;
|
||||
transform: scale(0) rotate(-10deg);
|
||||
animation: zoomInLogo 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
|
||||
}
|
||||
|
||||
/* Keyframe Animation */
|
||||
@keyframes zoomInLogo {
|
||||
0% {
|
||||
transform: scale(0) rotate(-10deg);
|
||||
opacity: 0;
|
||||
}
|
||||
60% {
|
||||
transform: scale(1.05) rotate(2deg);
|
||||
opacity: 0.8;
|
||||
}
|
||||
100% {
|
||||
transform: scale(1) rotate(0deg);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
BIN
gui-src/images/buymeacoffee.png
vendored
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
gui-src/images/discord.png
vendored
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
gui-src/images/logo.png
vendored
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 231 KiB |
BIN
gui-src/images/marker-icon.png
vendored
Normal file
|
After Width: | Height: | Size: 556 B |
162
gui-src/index.html
vendored
@@ -7,21 +7,23 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Arnis</title>
|
||||
<script type="module" src="./js/main.js" defer></script>
|
||||
<script type="module" src="./js/license.js" defer></script>
|
||||
<script type="module" src="./js/language-selector.js" defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="container">
|
||||
<div class="row">
|
||||
<a href="https://github.com/louis-e/arnis" target="_blank">
|
||||
<img src="./images/logo.png" class="logo arnis" alt="Arnis Logo" />
|
||||
<img src="./images/logo.png" id="arnis-logo" class="logo arnis" alt="Arnis Logo" style="width: 35%; height: auto;">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="flex-container">
|
||||
<!-- Left Box: Map and BBox Input -->
|
||||
<section class="section map-box" style="margin-bottom: 0; padding-bottom: 0;">
|
||||
<h2>Select Location</h2>
|
||||
<span id="bbox-text" style="font-size: 1.0em; display: block; margin-top: -8px; margin-bottom: 3px;">
|
||||
<h2 data-localize="select_location">Select Location</h2>
|
||||
<span id="bbox-text" style="font-size: 1.0em; display: block; margin-top: -8px; margin-bottom: 3px;" data-localize="zoom_in_and_choose">
|
||||
Zoom in and choose your area using the rectangle tool
|
||||
</span>
|
||||
<iframe src="maps.html" width="100%" height="300" class="map-container" title="Map Picker"></iframe>
|
||||
@@ -33,24 +35,21 @@
|
||||
<!-- Right Box: Directory Selection, Start Button, and Progress Bar -->
|
||||
<section class="section controls-box">
|
||||
<div class="controls-content">
|
||||
<h2>Select World</h2>
|
||||
<h2 data-localize="select_world">Select World</h2>
|
||||
|
||||
<!-- Updated Tooltip Structure -->
|
||||
<div class="tooltip" style="width: 100%;">
|
||||
<button type="button" onclick="openWorldPicker()" style="padding: 10px; line-height: 1.2; width: 100%;">
|
||||
Choose World
|
||||
<span id="choose_world">Choose World</span>
|
||||
<br>
|
||||
<span id="selected-world" style="font-size: 0.8em; color: #fecc44; display: block; margin-top: 4px;">
|
||||
<span id="selected-world" style="font-size: 0.8em; color: #fecc44; display: block; margin-top: 4px;" data-localize="no_world_selected">
|
||||
No world selected
|
||||
</span>
|
||||
</button>
|
||||
<span class="tooltiptext" style="font-size: 0.8em; line-height: 1.2;">
|
||||
Please select a Minecraft world that can be overwritten, as the generation process will replace existing structures in the chosen world!
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="button-container">
|
||||
<button type="button" id="start-button" class="start-button" onclick="startGeneration()">Start Generation</button>
|
||||
<button type="button" id="start-button" class="start-button" onclick="startGeneration()" data-localize="start_generation">Start Generation</button>
|
||||
<button type="button" class="settings-button" onclick="openSettings()">
|
||||
<i class="gear-icon"></i>
|
||||
</button>
|
||||
@@ -58,7 +57,7 @@
|
||||
<br><br>
|
||||
|
||||
<div class="progress-section">
|
||||
<h2>Progress</h2>
|
||||
<h2 data-localize="progress">Progress</h2>
|
||||
<div class="progress-bar-container">
|
||||
<div class="progress-bar" id="progress-bar"></div>
|
||||
</div>
|
||||
@@ -75,10 +74,10 @@
|
||||
<div id="world-modal" class="modal" style="display: none;">
|
||||
<div class="modal-content">
|
||||
<span class="close-button" onclick="closeWorldPicker()">×</span>
|
||||
<h2>Choose World</h2>
|
||||
<h2 data-localize="choose_world_modal_title">Choose World</h2>
|
||||
|
||||
<button type="button" id="select-world-button" class="select-world-button" onclick="selectWorld(false)">Select existing world</button>
|
||||
<button type="button" id="generate-world-button" class="generate-world-button" onclick="selectWorld(true)">Generate new world</button>
|
||||
<button type="button" id="select-world-button" class="select-world-button" onclick="selectWorld(false)" data-localize="select_existing_world">Select existing world</button>
|
||||
<button type="button" id="generate-world-button" class="generate-world-button" onclick="selectWorld(true)" data-localize="generate_new_world">Generate new world</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -86,45 +85,134 @@
|
||||
<div id="settings-modal" class="modal" style="display: none;">
|
||||
<div class="modal-content">
|
||||
<span class="close-button" onclick="closeSettings()">×</span>
|
||||
<h2>Customization Settings</h2>
|
||||
<h2 data-localize="customization_settings">Customization Settings</h2>
|
||||
|
||||
<!-- Winter Mode Toggle Button -->
|
||||
<div class="winter-toggle-container">
|
||||
<label for="winter-toggle">Winter Mode:</label>
|
||||
<input type="checkbox" id="winter-toggle" name="winter-toggle">
|
||||
<!-- Terrain Toggle Button -->
|
||||
<div class="settings-row">
|
||||
<label for="terrain-toggle" data-localize="terrain">Terrain</label>
|
||||
<div class="settings-control">
|
||||
<input type="checkbox" id="terrain-toggle" name="terrain-toggle" checked>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Interior Toggle Button -->
|
||||
<div class="settings-row">
|
||||
<label for="interior-toggle" data-localize="interior">Interior Generation</label>
|
||||
<div class="settings-control">
|
||||
<input type="checkbox" id="interior-toggle" name="interior-toggle" checked>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Roof Toggle Button -->
|
||||
<div class="settings-row">
|
||||
<label for="roof-toggle" data-localize="roof">Roof Generation</label>
|
||||
<div class="settings-control">
|
||||
<input type="checkbox" id="roof-toggle" name="roof-toggle" checked>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Fill ground Toggle Button -->
|
||||
<div class="settings-row">
|
||||
<label for="fillground-toggle" data-localize="fillground">Fill Ground</label>
|
||||
<div class="settings-control">
|
||||
<input type="checkbox" id="fillground-toggle" name="fillground-toggle">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- World Scale Slider -->
|
||||
<div class="scale-slider-container">
|
||||
<label for="scale-value-slider">World Scale:</label>
|
||||
<input type="range" id="scale-value-slider" name="scale-value-slider" min="0.30" max="2.5" step="0.1" value="1">
|
||||
<span id="slider-value">1.00</span>
|
||||
<div class="settings-row">
|
||||
<label for="scale-value-slider" data-localize="world_scale">World Scale</label>
|
||||
<div class="settings-control">
|
||||
<input type="range" id="scale-value-slider" name="scale-value-slider" min="0.30" max="2.5" step="0.1" value="1">
|
||||
<span id="slider-value">1.00</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Bounding Box Input -->
|
||||
<div class="bbox-input-container">
|
||||
<label for="bbox-coords">Custom Bounding Box:</label>
|
||||
<input type="text" id="bbox-coords" name="bbox-coords" maxlength="55" style="width: 280px;" autocomplete="one-time-code" placeholder="Format: lat,lng,lat,lng">
|
||||
<div class="settings-row">
|
||||
<label for="bbox-coords" data-localize="custom_bounding_box">Custom Bounding Box</label>
|
||||
<div class="settings-control">
|
||||
<input type="text" id="bbox-coords" name="bbox-coords" maxlength="55" placeholder="Format: lat,lng,lat,lng">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Floodfill Timeout Input -->
|
||||
<div class="timeout-input-container">
|
||||
<label for="floodfill-timeout">Floodfill Timeout (sec):</label>
|
||||
<input type="number" id="floodfill-timeout" name="floodfill-timeout" min="0" step="1" value="20" style="width: 100px;" placeholder="Seconds">
|
||||
</div><br>
|
||||
<div class="settings-row">
|
||||
<label for="floodfill-timeout" data-localize="floodfill_timeout">Floodfill Timeout (sec)</label>
|
||||
<div class="settings-control">
|
||||
<input type="number" id="floodfill-timeout" name="floodfill-timeout" min="0" step="1" value="20" placeholder="Seconds">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ground Level Input -->
|
||||
<div class="ground-level-input-container">
|
||||
<label for="ground-level">Ground Level:</label>
|
||||
<input type="number" id="ground-level" name="ground-level" min="-64" max="290" value="-62" style="width: 100px;" placeholder="Ground Level">
|
||||
<!-- Map Theme Selector -->
|
||||
<div class="settings-row">
|
||||
<label for="tile-theme-select" data-localize="map_theme">Map Theme</label>
|
||||
<div class="settings-control">
|
||||
<select id="tile-theme-select" name="tile-theme-select" class="theme-dropdown">
|
||||
<option value="osm">Standard</option>
|
||||
<option value="esri-imagery">Satellite</option>
|
||||
<option value="opentopomap">Topographic</option>
|
||||
<option value="stadia-bright">Smooth Bright</option>
|
||||
<option value="stadia-dark">Smooth Dark</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Language Selector -->
|
||||
<div class="settings-row">
|
||||
<label for="language-select" data-localize="language">Language</label>
|
||||
<div class="settings-control">
|
||||
<select id="language-select" name="language-select" class="language-dropdown">
|
||||
<option value="en">English</option>
|
||||
<option value="de">Deutsch</option>
|
||||
<option value="es">Español</option>
|
||||
<option value="fr-FR">Français</option>
|
||||
<option value="ru">Русский</option>
|
||||
<option value="zh-CN">中文 (简体)</option>
|
||||
<option value="ko">한국어</option>
|
||||
<option value="pl">Polski</option>
|
||||
<option value="sv">Svenska</option>
|
||||
<option value="ar">العربية</option>
|
||||
<option value="fi">Suomi</option>
|
||||
<option value="hu">Magyar</option>
|
||||
<option value="lt">Lietuvių</option>
|
||||
<option value="ua">Українська</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- License and Credits Button -->
|
||||
<div class="settings-row license-button-row">
|
||||
<button type="button" id="license-button" class="license-button" onclick="openLicense()" data-localize="license_and_credits">License and Credits</button>
|
||||
</div>
|
||||
|
||||
<!-- Buy Me a Coffee and Discord -->
|
||||
<div class="settings-row buymeacoffee-row">
|
||||
<a href="https://buymeacoffee.com/louisdev" target="_blank" class="buymeacoffee-link">
|
||||
<img src="./images/buymeacoffee.png" alt="Buy Me a Coffee" class="buymeacoffee-logo">
|
||||
</a>
|
||||
<a href="https://discord.gg/mA2g69Fhxq" target="_blank" class="discord-link">
|
||||
<img src="./images/discord.png" alt="Discord" class="discord-logo">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- License Modal -->
|
||||
<div id="license-modal" class="modal" style="display: none;">
|
||||
<div class="modal-content">
|
||||
<span class="close-button" onclick="closeLicense()">×</span>
|
||||
<h2 data-localize="license_and_credits">License and Credits</h2>
|
||||
<div id="license-content" style="overflow-y: auto; max-height: 300px; font-size: 0.85em; line-height: 1.3; padding: 10px; border: 1px solid #ccc; border-radius: 4px;">
|
||||
Loading...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="footer">
|
||||
<a href="https://github.com/louis-e/arnis" target="_blank" class="footer-link">
|
||||
© <span id="current-year"></span> Arnis v<span id="version-placeholder">x.x.x</span> by louis-e
|
||||
<a href="https://github.com/louis-e/arnis" target="_blank" class="footer-link" data-localize="footer_text">
|
||||
© {year} Arnis v{version} by louis-e
|
||||
</a>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
280
gui-src/js/bbox.js
vendored
@@ -322,7 +322,7 @@ function addLayer(layer, name, title, zIndex, on) {
|
||||
}
|
||||
link.innerHTML = name;
|
||||
link.title = title;
|
||||
link.onclick = function(e) {
|
||||
link.onclick = function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
@@ -429,7 +429,7 @@ function formatPoint(point, proj) {
|
||||
formattedBounds = y + ' ' + x;
|
||||
}
|
||||
}
|
||||
return formattedBounds
|
||||
return formattedPoint
|
||||
}
|
||||
|
||||
function validateStringAsBounds(bounds) {
|
||||
@@ -456,13 +456,122 @@ $(document).ready(function () {
|
||||
** on top of your DOM
|
||||
**
|
||||
*/
|
||||
$('input[type="textarea"]').on('click', function (evt) { this.select() });
|
||||
|
||||
// Have to init the projection input box as it is used to format the initial values
|
||||
// init the projection input box as it is used to format the initial values
|
||||
$('input[type="textarea"]').on('click', function (evt) { this.select() });
|
||||
$("#projection").val(currentproj);
|
||||
|
||||
L.mapbox.accessToken = 'pk.eyJ1IjoiY3Vnb3MiLCJhIjoiY2p4Nm43MzA3MDFmZDQwcGxsMjB4Z3hnNiJ9.SQbnMASwdqZe6G4n6OMvVw';
|
||||
map = L.mapbox.map('map').setView([50.114768, 8.687322], 4).addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'));
|
||||
// Initialize map
|
||||
map = L.map('map').setView([50.114768, 8.687322], 4);
|
||||
|
||||
// Define available tile themes
|
||||
var tileThemes = {
|
||||
'osm': {
|
||||
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
options: {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||
maxZoom: 19
|
||||
}
|
||||
},
|
||||
'esri-imagery': {
|
||||
url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
|
||||
options: {
|
||||
attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
|
||||
maxZoom: 18
|
||||
}
|
||||
},
|
||||
'opentopomap': {
|
||||
url: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
|
||||
options: {
|
||||
attribution: 'Map data: © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: © <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)',
|
||||
maxZoom: 17
|
||||
}
|
||||
},
|
||||
'stadia-bright': {
|
||||
url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}.{ext}',
|
||||
options: {
|
||||
minZoom: 0,
|
||||
maxZoom: 19,
|
||||
attribution: '© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a> © <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||
ext: 'png'
|
||||
}
|
||||
},
|
||||
'stadia-dark': {
|
||||
url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/{z}/{x}/{y}.{ext}',
|
||||
options: {
|
||||
minZoom: 0,
|
||||
maxZoom: 19,
|
||||
attribution: '© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a> © <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||
ext: 'png'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Global variable to store current tile layer
|
||||
var currentTileLayer = null;
|
||||
|
||||
// Function to change tile theme with automatic HTTP fallback
|
||||
function changeTileTheme(themeKey) {
|
||||
// Remove current tile layer if it exists
|
||||
if (currentTileLayer) {
|
||||
map.removeLayer(currentTileLayer);
|
||||
}
|
||||
|
||||
// Get the theme configuration
|
||||
var theme = tileThemes[themeKey];
|
||||
if (theme) {
|
||||
// Create and add new tile layer
|
||||
currentTileLayer = L.tileLayer(theme.url, theme.options);
|
||||
|
||||
// Add automatic HTTP fallback for HTTPS failures
|
||||
var failureCount = 0;
|
||||
currentTileLayer.on('tileerror', function(error) {
|
||||
failureCount++;
|
||||
|
||||
// After a few failures, try HTTP fallback
|
||||
if (failureCount >= 3 && !this._httpFallbackAttempted && theme.url.startsWith('https://')) {
|
||||
console.log('HTTPS tile loading failed, attempting HTTP fallback for', themeKey);
|
||||
this._httpFallbackAttempted = true;
|
||||
|
||||
// Create HTTP version of the URL
|
||||
var httpUrl = theme.url.replace('https://', 'http://');
|
||||
|
||||
// Remove the failed HTTPS layer
|
||||
map.removeLayer(this);
|
||||
|
||||
// Create new layer with HTTP URL
|
||||
var httpLayer = L.tileLayer(httpUrl, theme.options);
|
||||
httpLayer._httpFallbackAttempted = true;
|
||||
httpLayer.addTo(map);
|
||||
currentTileLayer = httpLayer;
|
||||
}
|
||||
});
|
||||
|
||||
currentTileLayer.addTo(map);
|
||||
|
||||
// Save preference to localStorage
|
||||
localStorage.setItem('selectedTileTheme', themeKey);
|
||||
}
|
||||
}
|
||||
|
||||
// Load saved theme or default to OSM
|
||||
var savedTheme = localStorage.getItem('selectedTileTheme') || 'osm';
|
||||
changeTileTheme(savedTheme);
|
||||
|
||||
// Listen for theme changes from parent window (settings modal)
|
||||
window.addEventListener('message', function(event) {
|
||||
if (event.data && event.data.type === 'changeTileTheme') {
|
||||
changeTileTheme(event.data.theme);
|
||||
}
|
||||
});
|
||||
|
||||
// Set the dropdown value in parent window if it exists
|
||||
if (window.parent && window.parent.document) {
|
||||
var dropdown = window.parent.document.getElementById('tile-theme-select');
|
||||
if (dropdown) {
|
||||
dropdown.value = savedTheme;
|
||||
}
|
||||
}
|
||||
|
||||
rsidebar = L.control.sidebar('rsidebar', {
|
||||
position: 'right',
|
||||
@@ -496,24 +605,53 @@ $(document).ready(function () {
|
||||
crosshair = new L.marker(map.getCenter(), { icon: crosshairIcon, clickable: false });
|
||||
crosshair.addTo(map);
|
||||
|
||||
// Override default tooltips
|
||||
L.drawLocal = L.drawLocal || {};
|
||||
L.drawLocal.draw = L.drawLocal.draw || {};
|
||||
L.drawLocal.draw.toolbar = L.drawLocal.draw.toolbar || {};
|
||||
L.drawLocal.draw.toolbar.buttons = L.drawLocal.draw.toolbar.buttons || {};
|
||||
L.drawLocal.draw.toolbar.buttons.rectangle = 'Choose area';
|
||||
L.drawLocal.draw.toolbar.buttons.marker = 'Set spawnpoint';
|
||||
|
||||
// Initialize the FeatureGroup to store editable layers
|
||||
drawnItems = new L.FeatureGroup();
|
||||
map.addLayer(drawnItems);
|
||||
|
||||
// Initialize the draw control and pass it the FeatureGroup of editable layers
|
||||
// Custom icon for drawn markers
|
||||
var customMarkerIcon = L.icon({
|
||||
iconUrl: 'images/marker-icon.png',
|
||||
iconSize: [20, 20],
|
||||
iconAnchor: [10, 10],
|
||||
popupAnchor: [0, -10]
|
||||
});
|
||||
|
||||
drawControl = new L.Control.Draw({
|
||||
edit: {
|
||||
featureGroup: drawnItems
|
||||
},
|
||||
draw: {
|
||||
rectangle: {
|
||||
shapeOptions: {
|
||||
color: '#fe57a1',
|
||||
opacity: 0.6,
|
||||
weight: 3,
|
||||
fillColor: '#fe57a1',
|
||||
fillOpacity: 0.1,
|
||||
dashArray: '10, 10',
|
||||
lineCap: 'round',
|
||||
lineJoin: 'round'
|
||||
},
|
||||
repeatMode: false
|
||||
},
|
||||
polyline: false,
|
||||
polygon: false,
|
||||
circle: false,
|
||||
marker: false
|
||||
marker: {
|
||||
icon: customMarkerIcon
|
||||
}
|
||||
}
|
||||
});
|
||||
map.addControl(drawControl);
|
||||
|
||||
/*
|
||||
**
|
||||
** create bounds layer
|
||||
@@ -523,17 +661,22 @@ $(document).ready(function () {
|
||||
**
|
||||
*/
|
||||
startBounds = new L.LatLngBounds([0.0, 0.0], [0.0, 0.0]);
|
||||
var bounds = new L.Rectangle(startBounds,
|
||||
{
|
||||
fill: false,
|
||||
opacity: 1.0,
|
||||
color: '#000'
|
||||
}
|
||||
);
|
||||
var bounds = new L.Rectangle(startBounds, {
|
||||
color: '#3778d4',
|
||||
opacity: 1.0,
|
||||
weight: 3,
|
||||
fill: '#3778d4',
|
||||
lineCap: 'round',
|
||||
lineJoin: 'round'
|
||||
});
|
||||
|
||||
bounds.on('bounds-set', function (e) {
|
||||
// move it to the end of the parent
|
||||
var parent = e.target._renderer._container.parentElement;
|
||||
$(parent).append(e.target._renderer._container);
|
||||
// move it to the end of the parent if renderer exists
|
||||
if (e.target._renderer && e.target._renderer._container) {
|
||||
var parent = e.target._renderer._container.parentElement;
|
||||
$(parent).append(e.target._renderer._container);
|
||||
}
|
||||
|
||||
// Set the hash
|
||||
var southwest = this.getBounds().getSouthWest();
|
||||
var northeast = this.getBounds().getNorthEast();
|
||||
@@ -543,13 +686,55 @@ $(document).ready(function () {
|
||||
var ymax = northeast.lat.toFixed(6);
|
||||
location.hash = ymin + ',' + xmin + ',' + ymax + ',' + xmax;
|
||||
});
|
||||
map.addLayer(bounds)
|
||||
map.addLayer(bounds);
|
||||
|
||||
map.on('draw:created', function (e) {
|
||||
// If it's a marker, make sure we only have one
|
||||
if (e.layerType === 'marker') {
|
||||
// Remove any existing markers
|
||||
drawnItems.eachLayer(function(layer) {
|
||||
if (layer instanceof L.Marker) {
|
||||
drawnItems.removeLayer(layer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Check if it's a rectangle and set proper styles before adding it to the layer
|
||||
if (e.layerType === 'rectangle') {
|
||||
e.layer.setStyle({
|
||||
color: '#3778d4',
|
||||
opacity: 1.0,
|
||||
weight: 3,
|
||||
fill: '#3778d4',
|
||||
lineCap: 'round',
|
||||
lineJoin: 'round'
|
||||
});
|
||||
}
|
||||
|
||||
drawnItems.addLayer(e.layer);
|
||||
bounds.setBounds(drawnItems.getBounds())
|
||||
$('#boxbounds').text(formatBounds(bounds.getBounds(), '4326'));
|
||||
$('#boxboundsmerc').text(formatBounds(bounds.getBounds(), currentproj));
|
||||
notifyBboxUpdate();
|
||||
|
||||
// Only update the bounds based on non-marker layers
|
||||
if (e.layerType !== 'marker') {
|
||||
// Calculate bounds only from non-marker layers
|
||||
const nonMarkerBounds = new L.LatLngBounds();
|
||||
let hasNonMarkerLayers = false;
|
||||
|
||||
drawnItems.eachLayer(function(layer) {
|
||||
if (!(layer instanceof L.Marker)) {
|
||||
hasNonMarkerLayers = true;
|
||||
nonMarkerBounds.extend(layer.getBounds());
|
||||
}
|
||||
});
|
||||
|
||||
// Only update bounds if there are non-marker layers
|
||||
if (hasNonMarkerLayers) {
|
||||
bounds.setBounds(nonMarkerBounds);
|
||||
$('#boxbounds').text(formatBounds(bounds.getBounds(), '4326'));
|
||||
$('#boxboundsmerc').text(formatBounds(bounds.getBounds(), currentproj));
|
||||
notifyBboxUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
if (!e.geojson &&
|
||||
!((drawnItems.getLayers().length == 1) && (drawnItems.getLayers()[0] instanceof L.Marker))) {
|
||||
map.fitBounds(bounds.getBounds());
|
||||
@@ -583,7 +768,22 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
map.on('draw:edited', function (e) {
|
||||
bounds.setBounds(drawnItems.getBounds())
|
||||
// Calculate bounds only from non-marker layers
|
||||
const nonMarkerBounds = new L.LatLngBounds();
|
||||
let hasNonMarkerLayers = false;
|
||||
|
||||
drawnItems.eachLayer(function(layer) {
|
||||
if (!(layer instanceof L.Marker)) {
|
||||
hasNonMarkerLayers = true;
|
||||
nonMarkerBounds.extend(layer.getBounds());
|
||||
}
|
||||
});
|
||||
|
||||
// Only update bounds if there are non-marker layers
|
||||
if (hasNonMarkerLayers) {
|
||||
bounds.setBounds(nonMarkerBounds);
|
||||
}
|
||||
|
||||
$('#boxbounds').text(formatBounds(bounds.getBounds(), '4326'));
|
||||
$('#boxboundsmerc').text(formatBounds(bounds.getBounds(), currentproj));
|
||||
notifyBboxUpdate();
|
||||
@@ -629,7 +829,14 @@ $(document).ready(function () {
|
||||
var splitBounds = initialBBox.split(',');
|
||||
startBounds = new L.LatLngBounds([splitBounds[0], splitBounds[1]],
|
||||
[splitBounds[2], splitBounds[3]]);
|
||||
var lyr = new L.Rectangle(startBounds);
|
||||
var lyr = new L.Rectangle(startBounds, {
|
||||
color: '#3778d4',
|
||||
opacity: 1.0,
|
||||
weight: 3,
|
||||
fill: '#3778d4',
|
||||
lineCap: 'round',
|
||||
lineJoin: 'round'
|
||||
});
|
||||
var evt = {
|
||||
layer: lyr,
|
||||
layerType: "polygon",
|
||||
@@ -655,3 +862,24 @@ function notifyBboxUpdate() {
|
||||
const bboxText = document.getElementById('boxbounds').textContent;
|
||||
window.parent.postMessage({ bboxText: bboxText }, '*');
|
||||
}
|
||||
|
||||
// Expose marker coordinates to the parent window
|
||||
function getSpawnPointCoords() {
|
||||
// Check if there are any markers in drawn items
|
||||
const markers = [];
|
||||
drawnItems.eachLayer(function(layer) {
|
||||
if (layer instanceof L.Marker) {
|
||||
const latLng = layer.getLatLng();
|
||||
markers.push({
|
||||
lat: latLng.lat,
|
||||
lng: latLng.lng
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Return the first marker found or null if none exists
|
||||
return markers.length > 0 ? markers[0] : null;
|
||||
}
|
||||
|
||||
// Expose the function to the parent window
|
||||
window.getSpawnPointCoords = getSpawnPointCoords;
|
||||
|
||||
45
gui-src/js/language-selector.js
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// Wait for DOM to be fully loaded
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Get language selector
|
||||
const languageSelect = document.getElementById('language-select');
|
||||
|
||||
if (languageSelect) {
|
||||
// Set initial value based on saved preference or browser language
|
||||
const savedLanguage = localStorage.getItem('arnis-language');
|
||||
const currentLang = savedLanguage || navigator.language;
|
||||
const availableOptions = Array.from(languageSelect.options).map(opt => opt.value);
|
||||
|
||||
// Try to match the exact language code first
|
||||
if (availableOptions.includes(currentLang)) {
|
||||
languageSelect.value = currentLang;
|
||||
}
|
||||
// Try to match just the base language code
|
||||
else if (availableOptions.includes(currentLang.split('-')[0])) {
|
||||
languageSelect.value = currentLang.split('-')[0];
|
||||
}
|
||||
|
||||
// Handle language change
|
||||
languageSelect.addEventListener('change', function () {
|
||||
const selectedLanguage = languageSelect.value;
|
||||
|
||||
// Store selection in localStorage
|
||||
localStorage.setItem('arnis-language', selectedLanguage);
|
||||
// Reload localization with the new language
|
||||
if (window.fetchLanguage) {
|
||||
window.fetchLanguage(selectedLanguage).then(localization => {
|
||||
if (window.applyLocalization) {
|
||||
window.applyLocalization(localization);
|
||||
|
||||
// Re-initialize the footer to ensure year and version are properly displayed
|
||||
if (window.initFooter) {
|
||||
window.initFooter();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// If the fetchLanguage function isn't exposed to window, just reload the page
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
33
gui-src/js/language.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
const DEFAULT_LOCALE_PATH = `./locales/en.json`;
|
||||
|
||||
/**
|
||||
* Checks if a JSON response is invalid or falls back to HTML
|
||||
* @param {Response} response - The fetch response object
|
||||
* @returns {boolean} True if the response is invalid JSON
|
||||
*/
|
||||
export function invalidJSON(response) {
|
||||
return !response.ok || response.headers.get("Content-Type") === "text/html";
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a specific language file
|
||||
* @param {string} languageCode - The language code to fetch
|
||||
* @returns {Promise<Object>} The localization JSON object
|
||||
*/
|
||||
export async function fetchLanguage(languageCode) {
|
||||
|
||||
let response = await fetch(`./locales/${languageCode}.json`);
|
||||
|
||||
// Try with only first part of language code if not found
|
||||
if (invalidJSON(response)) {
|
||||
response = await fetch(`./locales/${languageCode.split('-')[0]}.json`);
|
||||
|
||||
// Fallback to default English localization
|
||||
if (invalidJSON(response)) {
|
||||
response = await fetch(DEFAULT_LOCALE_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
const localization = await response.json();
|
||||
return localization;
|
||||
}
|
||||
88
gui-src/js/license.js
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
export const licenseText = `
|
||||
<b>Made with ♥️ in Munich by Louis Erbkamm</b>
|
||||
|
||||
<p>For a full list of contributors, please refer to the <a href="https://github.com/louis-e/arnis/graphs/contributors" style="color: inherit;" target="_blank">Github contributors page</a>. Logo made by nxfx21.
|
||||
|
||||
<p style="color: #ff8686;"><b>Download Arnis only from the official source:</b> <a href="https://github.com/louis-e/arnis" style="color: inherit;" target="_blank">https://github.com/louis-e/arnis/</a>. Every other website providing a download and claiming to be affiliated with the project is unofficial and may be malicious.</p>
|
||||
|
||||
<p><b>Third-Party Map Data and Tile Services:</b></p>
|
||||
<p>This application uses map tiles from multiple providers, each with their own licensing requirements:</p>
|
||||
|
||||
<b>OpenStreetMap:</b><br> © <a href="https://www.openstreetmap.org/copyright" style="color: inherit;" target="_blank">OpenStreetMap</a> contributors
|
||||
<br><br>
|
||||
|
||||
<b>Esri:</b><br> Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community
|
||||
<br><br>
|
||||
|
||||
<b>OpenTopoMap:</b><br> Map style: © <a href="https://opentopomap.org" style="color: inherit;" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" style="color: inherit;" target="_blank">CC-BY-SA</a>), Map data: © OpenStreetMap contributors, <a href="http://viewfinderpanoramas.org" style="color: inherit;" target="_blank">SRTM</a>
|
||||
<br><br>
|
||||
|
||||
<b>Stadia Maps:</b><br> © <a href="https://www.stadiamaps.com/" style="color: inherit;" target="_blank">Stadia Maps</a> © <a href="https://openmaptiles.org/" style="color: inherit;" target="_blank">OpenMapTiles</a> © OpenStreetMap contributors
|
||||
<p>Users of this software must comply with the respective licensing terms of these map data providers when using the application.</p>
|
||||
|
||||
|
||||
<p><b>License:</b></p>
|
||||
<pre style="white-space: pre-wrap; font-family: inherit;">
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and allother entities that control, are controlled by, or are under commoncontrol with that entity. For the purposes of this definition,"control" means (i) the power, direct or indirect, to cause thedirection or management of such entity, whether by contract orotherwise, or (ii) ownership of fifty percent (50%) or more of theoutstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entityexercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,including but not limited to software source code, documentationsource, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanicaltransformation or translation of a Source form, including butnot limited to compiled object code, generated documentation,and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source orObject form, made available under the License, as indicated by acopyright notice that is included in or attached to the work(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Objectform, that is based on (or derived from) the Work and for which theeditorial revisions, annotations, elaborations, or other modificationsrepresent, as a whole, an original work of authorship. For the purposesof this License, Derivative Works shall not include works that remainseparable from, or merely link (or bind by name) to the interfaces of,the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, includingthe original version of the Work and any modifications or additionsto that Work or Derivative Works thereof, that is intentionallysubmitted to Licensor for inclusion in the Work by the copyright owneror by an individual or Legal Entity authorized to submit on behalf ofthe copyright owner. For the purposes of this definition, "submitted"means any form of electronic, verbal, or written communication sentto the Licensor or its representatives, including but not limited tocommunication on electronic mailing lists, source code control systems,and issue tracking systems that are managed by, or on behalf of, theLicensor for the purpose of discussing and improving the Work, butexcluding communication that is conspicuously marked or otherwisedesignated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entityon behalf of whom a Contribution has been received by Licensor andsubsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions ofthis License, each Contributor hereby grants to You a perpetual,worldwide, non-exclusive, no-charge, royalty-free, irrevocablecopyright license to reproduce, prepare Derivative Works of,publicly display, publicly perform, sublicense, and distribute theWork and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions ofthis License, each Contributor hereby grants to You a perpetual,worldwide, non-exclusive, no-charge, royalty-free, irrevocable(except as stated in this section) patent license to make, have made,use, offer to sell, sell, import, and otherwise transfer the Work,where such license applies only to those patent claims licensableby such Contributor that are necessarily infringed by theirContribution(s) alone or by combination of their Contribution(s)with the Work to which such Contribution(s) was submitted. If Youinstitute patent litigation against any entity (including across-claim or counterclaim in a lawsuit) alleging that the Workor a Contribution incorporated within the Work constitutes director contributory patent infringement, then any patent licensesgranted to You under this License for that Work shall terminateas of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of theWork or Derivative Works thereof in any medium, with or withoutmodifications, and in Source or Object form, provided that Youmeet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications andmay provide additional or different license terms and conditionsfor use, reproduction, or distribution of Your modifications, orfor any such Derivative Works as a whole, provided Your use,reproduction, and distribution of the Work otherwise complies withthe conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,any Contribution intentionally submitted for inclusion in the Workby You to the Licensor shall be under the terms and conditions ofthis License, without any additional terms or conditions.Notwithstanding the above, nothing herein shall supersede or modifythe terms of any separate license agreement you may have executedwith Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the tradenames, trademarks, service marks, or product names of the Licensor,except as required for reasonable and customary use in describing theorigin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law oragreed to in writing, Licensor provides the Work (and eachContributor provides its Contributions) on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied, including, without limitation, any warranties or conditionsof TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR APARTICULAR PURPOSE. You are solely responsible for determining theappropriateness of using or redistributing the Work and assume anyrisks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,whether in tort (including negligence), contract, or otherwise,unless required by applicable law (such as deliberate and grosslynegligent acts) or agreed to in writing, shall any Contributor beliable to You for damages, including any direct, indirect, special,incidental, or consequential damages of any character arising as aresult of this License or out of the use or inability to use theWork (including but not limited to damages for loss of goodwill,work stoppage, computer failure or malfunction, or any and allother commercial damages or losses), even if such Contributorhas been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributingthe Work or Derivative Works thereof, You may choose to offer,and charge a fee for, acceptance of support, warranty, indemnity,or other liability obligations and/or rights consistent with thisLicense. However, in accepting such obligations, You may act onlyon Your own behalf and on Your sole responsibility, not on behalfof any other Contributor, and only if You agree to indemnify,defend, and hold each Contributor harmless for any liabilityincurred by, or claims asserted against, such Contributor by reasonof your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright ${new Date().getFullYear()} Louis Erbkamm
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions andlimitations under the License.
|
||||
</pre>
|
||||
`;
|
||||
473
gui-src/js/main.js
vendored
@@ -1,9 +1,19 @@
|
||||
const { invoke } = window.__TAURI__.core;
|
||||
import { licenseText } from './license.js';
|
||||
import { fetchLanguage, invalidJSON } from './language.js';
|
||||
|
||||
let invoke;
|
||||
if (window.__TAURI__) {
|
||||
invoke = window.__TAURI__.core.invoke;
|
||||
} else {
|
||||
function dummyFunc() { }
|
||||
window.__TAURI__ = { event: { listen: dummyFunc } };
|
||||
invoke = dummyFunc;
|
||||
}
|
||||
|
||||
const DEFAULT_LOCALE_PATH = `./locales/en.json`;
|
||||
|
||||
// Initialize elements and start the demo progress
|
||||
window.addEventListener("DOMContentLoaded", async () => {
|
||||
initFooter();
|
||||
await checkForUpdates();
|
||||
registerMessageEvent();
|
||||
window.selectWorld = selectWorld;
|
||||
window.startGeneration = startGeneration;
|
||||
@@ -11,20 +21,128 @@ window.addEventListener("DOMContentLoaded", async () => {
|
||||
initSettings();
|
||||
initWorldPicker();
|
||||
handleBboxInput();
|
||||
const localization = await getLocalization();
|
||||
await applyLocalization(localization);
|
||||
initFooter();
|
||||
await checkForUpdates();
|
||||
});
|
||||
|
||||
// Expose language functions to window for use by language-selector.js
|
||||
window.fetchLanguage = fetchLanguage;
|
||||
window.applyLocalization = applyLocalization;
|
||||
window.initFooter = initFooter;
|
||||
|
||||
/**
|
||||
* Fetches and returns localization data based on user's language
|
||||
* Falls back to English if requested language is not available
|
||||
* @returns {Promise<Object>} The localization JSON object
|
||||
*/
|
||||
async function getLocalization() {
|
||||
// Check if user has a saved language preference
|
||||
const savedLanguage = localStorage.getItem('arnis-language');
|
||||
|
||||
// If there's a saved preference, use it
|
||||
if (savedLanguage) {
|
||||
return await fetchLanguage(savedLanguage);
|
||||
}
|
||||
|
||||
// Otherwise use the browser's language
|
||||
const lang = navigator.language;
|
||||
return await fetchLanguage(lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an HTML element with localized text
|
||||
* @param {Object} json - Localization data
|
||||
* @param {Object} elementObject - Object containing element or selector
|
||||
* @param {string} localizedStringKey - Key for the localized string
|
||||
*/
|
||||
async function localizeElement(json, elementObject, localizedStringKey) {
|
||||
const element =
|
||||
(!elementObject.element || elementObject.element === "")
|
||||
? document.querySelector(elementObject.selector) : elementObject.element;
|
||||
const attribute = localizedStringKey.startsWith("placeholder_") ? "placeholder" : "textContent";
|
||||
|
||||
if (element) {
|
||||
if (localizedStringKey in json) {
|
||||
element[attribute] = json[localizedStringKey];
|
||||
} else {
|
||||
// Fallback to default (English) string
|
||||
const defaultJson = await fetchLanguage('en');
|
||||
element[attribute] = defaultJson[localizedStringKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function applyLocalization(localization) {
|
||||
const localizationElements = {
|
||||
"h2[data-localize='select_location']": "select_location",
|
||||
"#bbox-text": "zoom_in_and_choose",
|
||||
"h2[data-localize='select_world']": "select_world",
|
||||
"span[id='choose_world']": "choose_world",
|
||||
"#selected-world": "no_world_selected",
|
||||
"#start-button": "start_generation",
|
||||
"h2[data-localize='progress']": "progress",
|
||||
"h2[data-localize='choose_world_modal_title']": "choose_world_modal_title",
|
||||
"button[data-localize='select_existing_world']": "select_existing_world",
|
||||
"button[data-localize='generate_new_world']": "generate_new_world",
|
||||
"h2[data-localize='customization_settings']": "customization_settings",
|
||||
"label[data-localize='world_scale']": "world_scale",
|
||||
"label[data-localize='custom_bounding_box']": "custom_bounding_box",
|
||||
"label[data-localize='floodfill_timeout']": "floodfill_timeout",
|
||||
// DEPRECATED: Ground level localization removed
|
||||
// "label[data-localize='ground_level']": "ground_level",
|
||||
"label[data-localize='language']": "language",
|
||||
"label[data-localize='terrain']": "terrain",
|
||||
"label[data-localize='interior']": "interior",
|
||||
"label[data-localize='roof']": "roof",
|
||||
"label[data-localize='fillground']": "fillground",
|
||||
"label[data-localize='map_theme']": "map_theme",
|
||||
".footer-link": "footer_text",
|
||||
"button[data-localize='license_and_credits']": "license_and_credits",
|
||||
"h2[data-localize='license_and_credits']": "license_and_credits",
|
||||
|
||||
// Placeholder strings
|
||||
"input[id='bbox-coords']": "placeholder_bbox",
|
||||
"input[id='floodfill-timeout']": "placeholder_floodfill",
|
||||
// DEPRECATED: Ground level placeholder removed
|
||||
// "input[id='ground-level']": "placeholder_ground"
|
||||
};
|
||||
|
||||
for (const selector in localizationElements) {
|
||||
localizeElement(localization, { selector: selector }, localizationElements[selector]);
|
||||
}
|
||||
|
||||
// Update error messages
|
||||
window.localization = localization;
|
||||
}
|
||||
|
||||
// Function to initialize the footer with the current year and version
|
||||
async function initFooter() {
|
||||
const currentYear = new Date().getFullYear();
|
||||
document.getElementById("current-year").textContent = currentYear;
|
||||
let version = "x.x.x";
|
||||
|
||||
try {
|
||||
const version = await invoke('gui_get_version');
|
||||
const footerLink = document.querySelector(".footer-link");
|
||||
footerLink.textContent = `© ${currentYear} Arnis v${version} by louis-e`;
|
||||
version = await invoke('gui_get_version');
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch version:", error);
|
||||
}
|
||||
|
||||
const footerElement = document.querySelector(".footer-link");
|
||||
if (footerElement) {
|
||||
// Get the original text from localization if available, or use the current text
|
||||
let footerText = footerElement.textContent;
|
||||
|
||||
// Check if the text is from localization and contains placeholders
|
||||
if (window.localization && window.localization.footer_text) {
|
||||
footerText = window.localization.footer_text;
|
||||
}
|
||||
|
||||
// Replace placeholders with actual values
|
||||
footerElement.textContent = footerText
|
||||
.replace("{year}", currentYear)
|
||||
.replace("{version}", version);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to check for updates and display a notification if available
|
||||
@@ -42,7 +160,7 @@ async function checkForUpdates() {
|
||||
updateMessage.style.display = "block";
|
||||
updateMessage.style.textDecoration = "none";
|
||||
|
||||
updateMessage.textContent = "There's a new version available! Click here to download it.";
|
||||
localizeElement(window.localization, { element: updateMessage }, "new_version_available");
|
||||
footer.style.marginTop = "15px";
|
||||
footer.appendChild(updateMessage);
|
||||
}
|
||||
@@ -98,7 +216,7 @@ function initSettings() {
|
||||
const settingsModal = document.getElementById("settings-modal");
|
||||
const slider = document.getElementById("scale-value-slider");
|
||||
const sliderValue = document.getElementById("slider-value");
|
||||
|
||||
|
||||
// Open settings modal
|
||||
function openSettings() {
|
||||
settingsModal.style.display = "flex";
|
||||
@@ -110,7 +228,7 @@ function initSettings() {
|
||||
function closeSettings() {
|
||||
settingsModal.style.display = "none";
|
||||
}
|
||||
|
||||
|
||||
window.openSettings = openSettings;
|
||||
window.closeSettings = closeSettings;
|
||||
|
||||
@@ -118,12 +236,99 @@ function initSettings() {
|
||||
slider.addEventListener("input", () => {
|
||||
sliderValue.textContent = parseFloat(slider.value).toFixed(2);
|
||||
});
|
||||
|
||||
// Language selector
|
||||
const languageSelect = document.getElementById("language-select");
|
||||
const availableOptions = Array.from(languageSelect.options).map(opt => opt.value);
|
||||
|
||||
// Check for saved language preference first
|
||||
const savedLanguage = localStorage.getItem('arnis-language');
|
||||
let languageToSet = 'en'; // Default to English
|
||||
|
||||
if (savedLanguage && availableOptions.includes(savedLanguage)) {
|
||||
// Use saved language if it exists and is available
|
||||
languageToSet = savedLanguage;
|
||||
} else {
|
||||
// Otherwise use browser language
|
||||
const currentLang = navigator.language;
|
||||
|
||||
// Try to match the exact language code first
|
||||
if (availableOptions.includes(currentLang)) {
|
||||
languageToSet = currentLang;
|
||||
}
|
||||
// Try to match just the base language code
|
||||
else if (availableOptions.includes(currentLang.split('-')[0])) {
|
||||
languageToSet = currentLang.split('-')[0];
|
||||
}
|
||||
// languageToSet remains 'en' as default
|
||||
}
|
||||
|
||||
languageSelect.value = languageToSet;
|
||||
|
||||
// Handle language change
|
||||
languageSelect.addEventListener("change", async () => {
|
||||
const selectedLanguage = languageSelect.value;
|
||||
|
||||
// Store the selected language in localStorage for persistence
|
||||
localStorage.setItem('arnis-language', selectedLanguage);
|
||||
|
||||
// Reload localization with the new language
|
||||
const localization = await fetchLanguage(selectedLanguage);
|
||||
await applyLocalization(localization);
|
||||
});
|
||||
|
||||
// Tile theme selector
|
||||
const tileThemeSelect = document.getElementById("tile-theme-select");
|
||||
|
||||
// Load saved tile theme preference
|
||||
const savedTileTheme = localStorage.getItem('selectedTileTheme') || 'osm';
|
||||
tileThemeSelect.value = savedTileTheme;
|
||||
|
||||
// Handle tile theme change
|
||||
tileThemeSelect.addEventListener("change", () => {
|
||||
const selectedTheme = tileThemeSelect.value;
|
||||
|
||||
// Store the selected theme in localStorage for persistence
|
||||
localStorage.setItem('selectedTileTheme', selectedTheme);
|
||||
|
||||
// Send message to map iframe to change tile theme
|
||||
const mapIframe = document.querySelector('iframe[src="maps.html"]');
|
||||
if (mapIframe && mapIframe.contentWindow) {
|
||||
mapIframe.contentWindow.postMessage({
|
||||
type: 'changeTileTheme',
|
||||
theme: selectedTheme
|
||||
}, '*');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/// License and Credits
|
||||
function openLicense() {
|
||||
const licenseModal = document.getElementById("license-modal");
|
||||
const licenseContent = document.getElementById("license-content");
|
||||
|
||||
// Render the license text as HTML
|
||||
licenseContent.innerHTML = licenseText;
|
||||
|
||||
// Show the modal
|
||||
licenseModal.style.display = "flex";
|
||||
licenseModal.style.justifyContent = "center";
|
||||
licenseModal.style.alignItems = "center";
|
||||
}
|
||||
|
||||
function closeLicense() {
|
||||
const licenseModal = document.getElementById("license-modal");
|
||||
licenseModal.style.display = "none";
|
||||
}
|
||||
|
||||
window.openLicense = openLicense;
|
||||
window.closeLicense = closeLicense;
|
||||
}
|
||||
|
||||
function initWorldPicker() {
|
||||
// World Picker
|
||||
const worldPickerModal = document.getElementById("world-modal");
|
||||
|
||||
|
||||
// Open world picker modal
|
||||
function openWorldPicker() {
|
||||
worldPickerModal.style.display = "flex";
|
||||
@@ -135,68 +340,108 @@ function initWorldPicker() {
|
||||
function closeWorldPicker() {
|
||||
worldPickerModal.style.display = "none";
|
||||
}
|
||||
|
||||
|
||||
window.openWorldPicker = openWorldPicker;
|
||||
window.closeWorldPicker = closeWorldPicker;
|
||||
}
|
||||
|
||||
// Function to validate and handle bbox input
|
||||
/**
|
||||
* Validates and processes bounding box coordinates input
|
||||
* Supports both comma and space-separated formats
|
||||
* Updates the map display when valid coordinates are entered
|
||||
*/
|
||||
function handleBboxInput() {
|
||||
const inputBox = document.getElementById("bbox-coords");
|
||||
const bboxInfo = document.getElementById("bbox-info");
|
||||
|
||||
inputBox.addEventListener("input", function () {
|
||||
const input = inputBox.value.trim();
|
||||
const input = inputBox.value.trim();
|
||||
|
||||
if (input === "") {
|
||||
bboxInfo.textContent = "";
|
||||
bboxInfo.style.color = "";
|
||||
selectedBBox = "";
|
||||
return;
|
||||
}
|
||||
|
||||
// Regular expression to validate bbox input (supports both comma and space-separated formats)
|
||||
const bboxPattern = /^(-?\d+(\.\d+)?)[,\s](-?\d+(\.\d+)?)[,\s](-?\d+(\.\d+)?)[,\s](-?\d+(\.\d+)?)$/;
|
||||
|
||||
if (bboxPattern.test(input)) {
|
||||
const matches = input.match(bboxPattern);
|
||||
|
||||
// Extract coordinates (Lat / Lng order expected)
|
||||
const lat1 = parseFloat(matches[1]);
|
||||
const lng1 = parseFloat(matches[3]);
|
||||
const lat2 = parseFloat(matches[5]);
|
||||
const lng2 = parseFloat(matches[7]);
|
||||
|
||||
// Validate latitude and longitude ranges in the expected Lat / Lng order
|
||||
if (
|
||||
lat1 >= -90 && lat1 <= 90 &&
|
||||
lng1 >= -180 && lng1 <= 180 &&
|
||||
lat2 >= -90 && lat2 <= 90 &&
|
||||
lng2 >= -180 && lng2 <= 180
|
||||
) {
|
||||
// Input is valid; trigger the event
|
||||
const bboxText = `${lat1} ${lng1} ${lat2} ${lng2}`;
|
||||
window.dispatchEvent(new MessageEvent('message', { data: { bboxText } }));
|
||||
|
||||
// Update the info text
|
||||
bboxInfo.textContent = "Custom selection confirmed!";
|
||||
bboxInfo.style.color = "#7bd864";
|
||||
} else {
|
||||
// Valid numbers but invalid order or range
|
||||
bboxInfo.textContent = "Error: Coordinates are out of range or incorrectly ordered (Lat before Lng required).";
|
||||
bboxInfo.style.color = "#fecc44";
|
||||
selectedBBox = "";
|
||||
}
|
||||
if (input === "") {
|
||||
// Empty input - revert to map selection if available
|
||||
customBBoxValid = false;
|
||||
selectedBBox = mapSelectedBBox;
|
||||
|
||||
// Clear the info text only if no map selection exists
|
||||
if (!mapSelectedBBox) {
|
||||
bboxInfo.textContent = "";
|
||||
bboxInfo.style.color = "";
|
||||
} else {
|
||||
// Input doesn't match the required format
|
||||
bboxInfo.textContent = "Invalid format. Please use 'lat,lng,lat,lng' or 'lat lng lat lng'.";
|
||||
bboxInfo.style.color = "#fecc44";
|
||||
selectedBBox = "";
|
||||
// Restore map selection display
|
||||
displayBboxInfoText(mapSelectedBBox);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Regular expression to validate bbox input (supports both comma and space-separated formats)
|
||||
const bboxPattern = /^(-?\d+(\.\d+)?)[,\s](-?\d+(\.\d+)?)[,\s](-?\d+(\.\d+)?)[,\s](-?\d+(\.\d+)?)$/;
|
||||
|
||||
if (bboxPattern.test(input)) {
|
||||
const matches = input.match(bboxPattern);
|
||||
|
||||
// Extract coordinates (Lat / Lng order expected)
|
||||
const lat1 = parseFloat(matches[1]);
|
||||
const lng1 = parseFloat(matches[3]);
|
||||
const lat2 = parseFloat(matches[5]);
|
||||
const lng2 = parseFloat(matches[7]);
|
||||
|
||||
// Validate latitude and longitude ranges in the expected Lat / Lng order
|
||||
if (
|
||||
lat1 >= -90 && lat1 <= 90 &&
|
||||
lng1 >= -180 && lng1 <= 180 &&
|
||||
lat2 >= -90 && lat2 <= 90 &&
|
||||
lng2 >= -180 && lng2 <= 180
|
||||
) {
|
||||
// Input is valid; trigger the event with consistent comma-separated format
|
||||
const bboxText = `${lat1},${lng1},${lat2},${lng2}`;
|
||||
window.dispatchEvent(new MessageEvent('message', { data: { bboxText } }));
|
||||
|
||||
// Show custom bbox on the map
|
||||
let map_container = document.querySelector('.map-container');
|
||||
map_container.setAttribute('src', `maps.html#${lat1},${lng1},${lat2},${lng2}`);
|
||||
map_container.contentWindow.location.reload();
|
||||
|
||||
// Update the info text and mark custom input as valid
|
||||
customBBoxValid = true;
|
||||
selectedBBox = bboxText.replace(/,/g, ' '); // Convert to space format for consistency
|
||||
localizeElement(window.localization, { element: bboxInfo }, "custom_selection_confirmed");
|
||||
bboxInfo.style.color = "#7bd864";
|
||||
} else {
|
||||
// Valid numbers but invalid order or range
|
||||
customBBoxValid = false;
|
||||
// Don't clear selectedBBox - keep map selection if available
|
||||
if (!mapSelectedBBox) {
|
||||
selectedBBox = "";
|
||||
} else {
|
||||
selectedBBox = mapSelectedBBox;
|
||||
}
|
||||
localizeElement(window.localization, { element: bboxInfo }, "error_coordinates_out_of_range");
|
||||
bboxInfo.style.color = "#fecc44";
|
||||
}
|
||||
} else {
|
||||
// Input doesn't match the required format
|
||||
customBBoxValid = false;
|
||||
// Don't clear selectedBBox - keep map selection if available
|
||||
if (!mapSelectedBBox) {
|
||||
selectedBBox = "";
|
||||
} else {
|
||||
selectedBBox = mapSelectedBBox;
|
||||
}
|
||||
localizeElement(window.localization, { element: bboxInfo }, "invalid_format");
|
||||
bboxInfo.style.color = "#fecc44";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to calculate the bounding box "size" in square meters based on latitude and longitude
|
||||
/**
|
||||
* Calculates the approximate area of a bounding box in square meters
|
||||
* Uses the Haversine formula for geodesic calculations
|
||||
* @param {number} lng1 - First longitude coordinate
|
||||
* @param {number} lat1 - First latitude coordinate
|
||||
* @param {number} lng2 - Second longitude coordinate
|
||||
* @param {number} lat2 - Second latitude coordinate
|
||||
* @returns {number} Area in square meters
|
||||
*/
|
||||
function calculateBBoxSize(lng1, lat1, lng2, lat2) {
|
||||
// Approximate distance calculation using Haversine formula or geodesic formula
|
||||
const toRad = (angle) => (angle * Math.PI) / 180;
|
||||
@@ -217,14 +462,20 @@ function calculateBBoxSize(lng1, lat1, lng2, lat2) {
|
||||
return Math.abs(width * height);
|
||||
}
|
||||
|
||||
// Function to normalize longitude to the range [-180, 180]
|
||||
/**
|
||||
* Normalizes a longitude value to the range [-180, 180]
|
||||
* @param {number} lon - Longitude value to normalize
|
||||
* @returns {number} Normalized longitude value
|
||||
*/
|
||||
function normalizeLongitude(lon) {
|
||||
return ((lon + 180) % 360 + 360) % 360 - 180;
|
||||
}
|
||||
|
||||
const threshold1 = 12332660.00;
|
||||
const threshold2 = 36084700.00;
|
||||
const threshold1 = 30000000.00;
|
||||
const threshold2 = 45000000.00;
|
||||
let selectedBBox = "";
|
||||
let mapSelectedBBox = ""; // Tracks bbox from map selection
|
||||
let customBBoxValid = false; // Tracks if custom input is valid
|
||||
|
||||
// Function to handle incoming bbox data
|
||||
function displayBboxInfoText(bboxText) {
|
||||
@@ -233,14 +484,21 @@ function displayBboxInfoText(bboxText) {
|
||||
// Normalize longitudes
|
||||
lat1 = parseFloat(normalizeLongitude(lat1).toFixed(6));
|
||||
lat2 = parseFloat(normalizeLongitude(lat2).toFixed(6));
|
||||
selectedBBox = `${lng1} ${lat1} ${lng2} ${lat2}`;
|
||||
mapSelectedBBox = `${lng1} ${lat1} ${lng2} ${lat2}`;
|
||||
|
||||
// Map selection always takes priority - clear custom input and update selectedBBox
|
||||
selectedBBox = mapSelectedBBox;
|
||||
customBBoxValid = false;
|
||||
|
||||
const bboxInfo = document.getElementById("bbox-info");
|
||||
|
||||
// Reset the info text if the bbox is 0,0,0,0
|
||||
if (lng1 === 0 && lat1 === 0 && lng2 === 0 && lat2 === 0) {
|
||||
bboxInfo.textContent = "";
|
||||
selectedBBox = "";
|
||||
mapSelectedBBox = "";
|
||||
if (!customBBoxValid) {
|
||||
selectedBBox = "";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -248,38 +506,63 @@ function displayBboxInfoText(bboxText) {
|
||||
const selectedSize = calculateBBoxSize(lng1, lat1, lng2, lat2);
|
||||
|
||||
if (selectedSize > threshold2) {
|
||||
bboxInfo.textContent = "This area is very large and could exceed typical computing limits.";
|
||||
localizeElement(window.localization, { element: bboxInfo }, "area_too_large");
|
||||
bboxInfo.style.color = "#fa7878";
|
||||
} else if (selectedSize > threshold1) {
|
||||
bboxInfo.textContent = "The area is quite extensive and may take significant time and resources.";
|
||||
localizeElement(window.localization, { element: bboxInfo }, "area_extensive");
|
||||
bboxInfo.style.color = "#fecc44";
|
||||
} else {
|
||||
bboxInfo.textContent = "Selection confirmed!";
|
||||
localizeElement(window.localization, { element: bboxInfo }, "selection_confirmed");
|
||||
bboxInfo.style.color = "#7bd864";
|
||||
}
|
||||
}
|
||||
|
||||
let worldPath = "";
|
||||
let isNewWorld = false;
|
||||
|
||||
async function selectWorld(generate_new_world) {
|
||||
try {
|
||||
const worldName = await invoke('gui_select_world', { generateNew: generate_new_world } );
|
||||
const worldName = await invoke('gui_select_world', { generateNew: generate_new_world });
|
||||
if (worldName) {
|
||||
worldPath = worldName;
|
||||
isNewWorld = generate_new_world;
|
||||
const lastSegment = worldName.split(/[\\/]/).pop();
|
||||
document.getElementById('selected-world').textContent = lastSegment;
|
||||
document.getElementById('selected-world').style.color = "#fecc44";
|
||||
}
|
||||
} catch (error) {
|
||||
worldPath = error;
|
||||
console.error(error);
|
||||
document.getElementById('selected-world').textContent = error;
|
||||
document.getElementById('selected-world').style.color = "#fa7878";
|
||||
handleWorldSelectionError(error);
|
||||
}
|
||||
|
||||
closeWorldPicker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles world selection errors and displays appropriate messages
|
||||
* @param {number} errorCode - Error code from the backend
|
||||
*/
|
||||
function handleWorldSelectionError(errorCode) {
|
||||
const errorKeys = {
|
||||
1: "minecraft_directory_not_found",
|
||||
2: "world_in_use",
|
||||
3: "failed_to_create_world",
|
||||
4: "no_world_selected_error"
|
||||
};
|
||||
|
||||
const errorKey = errorKeys[errorCode] || "unknown_error";
|
||||
const selectedWorld = document.getElementById('selected-world');
|
||||
localizeElement(window.localization, { element: selectedWorld }, errorKey);
|
||||
selectedWorld.style.color = "#fa7878";
|
||||
worldPath = "";
|
||||
console.error(errorCode);
|
||||
}
|
||||
|
||||
let generationButtonEnabled = true;
|
||||
/**
|
||||
* Initiates the world generation process
|
||||
* Validates required inputs and sends generation parameters to the backend
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function startGeneration() {
|
||||
try {
|
||||
if (generationButtonEnabled === false) {
|
||||
@@ -287,40 +570,58 @@ async function startGeneration() {
|
||||
}
|
||||
|
||||
if (!selectedBBox || selectedBBox == "0.000000 0.000000 0.000000 0.000000") {
|
||||
document.getElementById('bbox-info').textContent = "Select a location first!";
|
||||
document.getElementById('bbox-info').style.color = "#fa7878";
|
||||
const bboxInfo = document.getElementById('bbox-info');
|
||||
localizeElement(window.localization, { element: bboxInfo }, "select_location_first");
|
||||
bboxInfo.style.color = "#fa7878";
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
worldPath === "No world selected" ||
|
||||
worldPath == "Invalid Minecraft world" ||
|
||||
worldPath == "The selected world is currently in use" ||
|
||||
worldPath == "Minecraft directory not found" ||
|
||||
worldPath === ""
|
||||
) {
|
||||
document.getElementById('selected-world').textContent = "Select a Minecraft world first!";
|
||||
document.getElementById('selected-world').style.color = "#fa7878";
|
||||
if (!worldPath || worldPath === "") {
|
||||
const selectedWorld = document.getElementById('selected-world');
|
||||
localizeElement(window.localization, { element: selectedWorld }, "select_minecraft_world_first");
|
||||
selectedWorld.style.color = "#fa7878";
|
||||
return;
|
||||
}
|
||||
|
||||
var winter_mode = document.getElementById("winter-toggle").checked;
|
||||
// Get the map iframe reference
|
||||
const mapFrame = document.querySelector('.map-container');
|
||||
// Get spawn point coordinates if marker exists
|
||||
let spawnPoint = null;
|
||||
if (mapFrame && mapFrame.contentWindow && mapFrame.contentWindow.getSpawnPointCoords) {
|
||||
const coords = mapFrame.contentWindow.getSpawnPointCoords();
|
||||
// Convert object format to tuple format if coordinates exist
|
||||
if (coords) {
|
||||
spawnPoint = [coords.lat, coords.lng];
|
||||
}
|
||||
}
|
||||
|
||||
var terrain = document.getElementById("terrain-toggle").checked;
|
||||
var interior = document.getElementById("interior-toggle").checked;
|
||||
var roof = document.getElementById("roof-toggle").checked;
|
||||
var fill_ground = document.getElementById("fillground-toggle").checked;
|
||||
var scale = parseFloat(document.getElementById("scale-value-slider").value);
|
||||
var floodfill_timeout = parseInt(document.getElementById("floodfill-timeout").value, 10);
|
||||
var ground_level = parseInt(document.getElementById("ground-level").value, 10);
|
||||
// var ground_level = parseInt(document.getElementById("ground-level").value, 10);
|
||||
// DEPRECATED: Ground level input removed from UI
|
||||
var ground_level = -62;
|
||||
|
||||
// Validate floodfill_timeout and ground_level
|
||||
floodfill_timeout = isNaN(floodfill_timeout) || floodfill_timeout < 0 ? 20 : floodfill_timeout;
|
||||
ground_level = isNaN(ground_level) || ground_level < -62 ? 20 : ground_level;
|
||||
|
||||
// Pass the bounding box and selected world to the Rust backend
|
||||
// Pass the selected options to the Rust backend
|
||||
await invoke("gui_start_generation", {
|
||||
bboxText: selectedBBox,
|
||||
selectedWorld: worldPath,
|
||||
worldScale: scale,
|
||||
groundLevel: ground_level,
|
||||
winterMode: winter_mode,
|
||||
floodfillTimeout: floodfill_timeout,
|
||||
terrainEnabled: terrain,
|
||||
interiorEnabled: interior,
|
||||
roofEnabled: roof,
|
||||
fillgroundEnabled: fill_ground,
|
||||
isNewWorld: isNewWorld,
|
||||
spawnPoint: spawnPoint
|
||||
});
|
||||
|
||||
console.log("Generation process started.");
|
||||
|
||||
9180
gui-src/js/maps/leaflet-src.js
vendored
2766
gui-src/js/maps/leaflet.draw-src.js
vendored
3
gui-src/js/maps/mapbox.standalone.js
vendored
66
gui-src/js/maps/mapbox.v3.2.0.js
vendored
3
gui-src/js/maps/proj4.js
vendored
158
gui-src/js/maps/test.runner.js
vendored
@@ -1,158 +0,0 @@
|
||||
(function( definition ) { // execute immeidately
|
||||
|
||||
if ( typeof module !== 'undefined' &&
|
||||
typeof module.exports !== 'undefined' ) {
|
||||
module.exports = definition();
|
||||
}
|
||||
else if ( typeof window === "object" ) {
|
||||
// example run syntax: BBOX_T( { 'url' : '/js/maps/testdata.js' } );
|
||||
window.BBOX_T = definition();
|
||||
}
|
||||
|
||||
|
||||
})( function() {
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
**
|
||||
** constructor
|
||||
**
|
||||
*/
|
||||
var TestRunner = function( options ) {
|
||||
options || ( options = {} );
|
||||
|
||||
if( !this || !(this instanceof TestRunner )){
|
||||
return new TestRunner( options );
|
||||
}
|
||||
|
||||
this.test_url = options.url || "";
|
||||
|
||||
this.global_setup(); // execute immediately
|
||||
};
|
||||
|
||||
/*
|
||||
**
|
||||
** functions
|
||||
**
|
||||
*/
|
||||
TestRunner.prototype.global_setup = function() {
|
||||
|
||||
var self = this; // hold ref to instance
|
||||
|
||||
$.ajax({
|
||||
'url' : this.test_url ,
|
||||
'dataType' : 'json'
|
||||
})
|
||||
.done( function( json_data ) {
|
||||
self.run_this_mother.call( self, json_data );
|
||||
})
|
||||
.fail( function( error ) {
|
||||
console.log( "The test data didn't load: ", error );
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
TestRunner.prototype.single_setup = function() {
|
||||
this.get_layer_count();
|
||||
};
|
||||
|
||||
TestRunner.prototype.tear_down = function() {
|
||||
if( this._draw_delete_handler ){
|
||||
this._draw_delete_handler.off('draw:deleted');
|
||||
}
|
||||
};
|
||||
|
||||
TestRunner.prototype.run_this_mother = function( json_data ) {
|
||||
for( var key in json_data ){
|
||||
console.log( "[ RUNNING ]: test " + json_data[key]['type'] + "->" + "simple=" + json_data[key]['simple'] );
|
||||
var data = json_data[key]['data'];
|
||||
if( json_data[key]['type'] === 'geojson' ) {
|
||||
data = JSON.stringify( data );
|
||||
}
|
||||
|
||||
/*
|
||||
** run different tests
|
||||
** the context here is jQuery, so change
|
||||
** to reference the instance
|
||||
*/
|
||||
this.single_setup();
|
||||
|
||||
this.test_parsing( data, json_data );
|
||||
this.test_add2map( json_data );
|
||||
this.test_deletable( json_data );
|
||||
|
||||
this.tear_down();
|
||||
}
|
||||
};
|
||||
|
||||
TestRunner.prototype.test_deletable = function(identifier){ // TODO: this needs work
|
||||
var toolbar = null;
|
||||
// get the right toolbar, depending on attributes
|
||||
for( var key in drawControl._toolbars ){
|
||||
var tbar = drawControl._toolbars[key];
|
||||
if ( !(tbar instanceof L.EditToolbar ) ){
|
||||
continue;
|
||||
}
|
||||
|
||||
toolbar = tbar; // set the right one;
|
||||
}
|
||||
|
||||
// create delete handler that makes sure things are deleted
|
||||
this._draw_delete_handler = map.on('draw:deleted', function (e) {
|
||||
try {
|
||||
e.layers.eachLayer(function (l) {
|
||||
drawnItems.removeLayer(l);
|
||||
});
|
||||
console.warn( "[ PASSED ]: test_deletable" );
|
||||
}
|
||||
catch ( err ) {
|
||||
console.error( "[ DELETE TEST FAIL ]: ", err.message, identifier );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// loop through this toolbars featureGroup, delete layers
|
||||
if ( !toolbar._activeMode ) {
|
||||
toolbar._modes['remove'].button.click(); // enable deletable
|
||||
}
|
||||
for( var indx in toolbar.options['featureGroup']._layers ) {
|
||||
try {
|
||||
var lyr = toolbar.options['featureGroup']._layers[indx];
|
||||
lyr.fire( 'click' ); // triggers delete
|
||||
}
|
||||
catch ( err ){
|
||||
console.error( "[ DELETE TEST FAIL ]: ", err.message, identifier );
|
||||
}
|
||||
}
|
||||
// WTF?
|
||||
$('a[title="Save changes."]')[0].click(); // disable deletable
|
||||
|
||||
};
|
||||
|
||||
TestRunner.prototype.test_add2map = function(identifier){
|
||||
var current_num = Object.keys( map._layers ).length;
|
||||
if( current_num <= this.num_layers_before_parse ){
|
||||
console.error( "[ ADD2MAP TEST FAIL ]: ", identifier );
|
||||
}
|
||||
else {
|
||||
console.warn( "[ PASSED ]: test_add2map" );
|
||||
}
|
||||
};
|
||||
|
||||
TestRunner.prototype.get_layer_count = function(){
|
||||
this.num_layers_before_parse = Object.keys( map._layers ).length;
|
||||
};
|
||||
|
||||
TestRunner.prototype.test_parsing = function( data, identifier ){
|
||||
var is_valid = FormatSniffer( { data : data } ).sniff();
|
||||
if ( !is_valid ) {
|
||||
console.error( "[ PARSE TEST FAIL ]: ", identifier );
|
||||
}
|
||||
else {
|
||||
console.warn( "[ PASSED ]: test_parsing" );
|
||||
}
|
||||
};
|
||||
|
||||
return TestRunner; // return class def
|
||||
|
||||
});
|
||||
184
gui-src/js/search.js
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
// City Search Functionality
|
||||
var citySearch = {
|
||||
searchTimeout: null,
|
||||
|
||||
init: function() {
|
||||
this.bindEvents();
|
||||
},
|
||||
|
||||
bindEvents: function() {
|
||||
var self = this;
|
||||
|
||||
// Search on button click
|
||||
$('#search-btn').on('click', function() {
|
||||
self.performSearch();
|
||||
});
|
||||
|
||||
// Search on Enter key
|
||||
$('#city-search').on('keypress', function(e) {
|
||||
if (e.which === 13) { // Enter key
|
||||
self.performSearch();
|
||||
}
|
||||
});
|
||||
|
||||
// Search as user types (debounced)
|
||||
$('#city-search').on('input', function() {
|
||||
clearTimeout(self.searchTimeout);
|
||||
var query = $(this).val().trim();
|
||||
|
||||
if (query.length >= 3) {
|
||||
self.searchTimeout = setTimeout(function() {
|
||||
self.performSearch(query);
|
||||
}, 500);
|
||||
} else {
|
||||
self.hideResults();
|
||||
}
|
||||
});
|
||||
|
||||
// Hide results when clicking outside
|
||||
$(document).on('click', function(e) {
|
||||
if (!$(e.target).closest('#search-container').length) {
|
||||
self.hideResults();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
performSearch: function(query) {
|
||||
var self = this;
|
||||
query = query || $('#city-search').val().trim();
|
||||
|
||||
if (query.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.showLoading();
|
||||
|
||||
// Use Nominatim geocoding service
|
||||
var url = 'https://nominatim.openstreetmap.org/search';
|
||||
var params = {
|
||||
q: query,
|
||||
format: 'json',
|
||||
limit: 5,
|
||||
addressdetails: 1,
|
||||
extratags: 1,
|
||||
'accept-language': 'en'
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: params,
|
||||
method: 'GET',
|
||||
timeout: 10000,
|
||||
success: function(data) {
|
||||
self.displayResults(data);
|
||||
},
|
||||
error: function() {
|
||||
self.showError('Search failed. Please try again.');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
showLoading: function() {
|
||||
$('#search-results').html('<div class="search-loading">Searching...</div>').show();
|
||||
},
|
||||
|
||||
showError: function(message) {
|
||||
$('#search-results').html('<div class="search-no-results">' + message + '</div>').show();
|
||||
},
|
||||
|
||||
hideResults: function() {
|
||||
$('#search-results').hide();
|
||||
},
|
||||
|
||||
displayResults: function(results) {
|
||||
var self = this;
|
||||
var $results = $('#search-results');
|
||||
|
||||
if (results.length === 0) {
|
||||
$results.html('<div class="search-no-results">No cities found</div>').show();
|
||||
return;
|
||||
}
|
||||
|
||||
var html = '';
|
||||
results.forEach(function(result) {
|
||||
var displayName = result.display_name;
|
||||
var nameParts = displayName.split(',');
|
||||
var mainName = nameParts[0];
|
||||
var details = nameParts.slice(1, 3).join(',');
|
||||
|
||||
html += '<div class="search-result-item" data-lat="' + result.lat + '" data-lon="' + result.lon + '">';
|
||||
html += '<div class="search-result-name">' + self.escapeHtml(mainName) + '</div>';
|
||||
html += '<div class="search-result-details">' + self.escapeHtml(details) + '</div>';
|
||||
html += '</div>';
|
||||
});
|
||||
|
||||
$results.html(html).show();
|
||||
|
||||
// Bind click events to results
|
||||
$('.search-result-item').on('click', function() {
|
||||
var lat = parseFloat($(this).data('lat'));
|
||||
var lon = parseFloat($(this).data('lon'));
|
||||
var name = $(this).find('.search-result-name').text();
|
||||
|
||||
self.goToLocation(lat, lon, name);
|
||||
self.hideResults();
|
||||
});
|
||||
},
|
||||
|
||||
goToLocation: function(lat, lon, name) {
|
||||
if (typeof map !== 'undefined' && map) {
|
||||
// Clear existing bbox selection and spawn points
|
||||
if (typeof drawnItems !== 'undefined' && drawnItems) {
|
||||
drawnItems.clearLayers();
|
||||
}
|
||||
|
||||
// Try to access bounds through the map layers or find the bounds rectangle
|
||||
var boundsLayer = null;
|
||||
map.eachLayer(function(layer) {
|
||||
if (layer instanceof L.Rectangle && layer.options.color === '#3778d4') {
|
||||
boundsLayer = layer;
|
||||
}
|
||||
});
|
||||
|
||||
if (boundsLayer) {
|
||||
boundsLayer.setBounds(new L.LatLngBounds([0.0, 0.0], [0.0, 0.0]));
|
||||
|
||||
// Update the bbox display
|
||||
if (typeof formatBounds === 'function') {
|
||||
$('#boxbounds').text(formatBounds(boundsLayer.getBounds(), '4326'));
|
||||
|
||||
if (typeof currentproj !== 'undefined') {
|
||||
$('#boxboundsmerc').text(formatBounds(boundsLayer.getBounds(), currentproj));
|
||||
}
|
||||
}
|
||||
|
||||
// Notify parent window of bbox update
|
||||
if (typeof notifyBboxUpdate === 'function') {
|
||||
notifyBboxUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// Simply zoom to location without adding markers or popups
|
||||
map.setView([lat, lon], 12);
|
||||
|
||||
// Clear search box
|
||||
$('#city-search').val('');
|
||||
}
|
||||
},
|
||||
|
||||
escapeHtml: function(text) {
|
||||
var div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize search when document is ready
|
||||
$(document).ready(function() {
|
||||
// Wait a bit for the map to be initialized
|
||||
setTimeout(function() {
|
||||
if (typeof map !== 'undefined') {
|
||||
citySearch.init();
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
44
gui-src/locales/ar.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "اختيار موقع",
|
||||
"zoom_in_and_choose": "قم بالتكبير واختر منطقتك باستخدام أداة المستطيل",
|
||||
"select_world": "تحديد عالم",
|
||||
"choose_world": "اختيار عالم",
|
||||
"no_world_selected": "لم يتم تحديد عالم",
|
||||
"start_generation": "بدء البناء",
|
||||
"progress": "التقدم",
|
||||
"custom_selection_confirmed": "تم تأكيد التحديد المخصص!",
|
||||
"error_coordinates_out_of_range": "خطأ: الإحداثيات خارج النطاق أو مرتبة بشكل غير صحيح (مطلوب خط العرض قبل خط الطول).",
|
||||
"invalid_format": "تنسيق غير صالح. استخدم 'lat,lng,lat,lng' أو 'lat lng lat lng'.",
|
||||
"generation_process_started": "بدأت عملية البناء.",
|
||||
"winter_mode": "وضع الشتاء",
|
||||
"world_scale": "مقياس العالم",
|
||||
"custom_bounding_box": "مربع الحدود المخصص",
|
||||
"floodfill_timeout": "مهلة ملء الفيضان (ثواني)",
|
||||
"ground_level": "مستوى الأرض",
|
||||
"choose_world_modal_title": "اختيار عالم",
|
||||
"select_existing_world": "اختيار عالم موجود مسبقًا",
|
||||
"generate_new_world": "إنشاء عالم جديد",
|
||||
"customization_settings": "إعدادات التخصيص",
|
||||
"footer_text": "© {year} Arnis v{version} من louis-e",
|
||||
"new_version_available": "هناك نسخة جديدة متاحة! انقر هنا لتنزيلها.",
|
||||
"minecraft_directory_not_found": "لم يتم العثور على مجلد ماين كرافت",
|
||||
"world_in_use": "العالم المحدد قيد الاستخدام حاليًا",
|
||||
"failed_to_create_world": "حدث خطأ عند محاولة إنشاء عالم جديد",
|
||||
"no_world_selected_error": "لم يتم تحديد عالم",
|
||||
"select_minecraft_world_first": "يرجى تحديد عالم ماين كرافت أولاً!",
|
||||
"select_location_first": "يرجى اختيار موقع أولاً!",
|
||||
"area_too_large": "تُعتبر هذه المنطقة كبيرة جدًا وقد تتجاوز حدود الحوسبة النموذجية.",
|
||||
"area_extensive": "المنطقة واسعة جدًا وقد تتطلب الكثير من الوقت والموارد.",
|
||||
"selection_confirmed": "تم تأكيد التحديد!",
|
||||
"unknown_error": "خطأ غير معروف",
|
||||
"license_and_credits": "الرخصة والمساهمون",
|
||||
"placeholder_bbox": "الصيغة: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "ثوانٍ",
|
||||
"placeholder_ground": "مستوى الأرض",
|
||||
"language": "اللغة",
|
||||
"map_theme": "موضوع الخريطة",
|
||||
"terrain": "التضاريس",
|
||||
"interior": "توليد الداخلية",
|
||||
"roof": "توليد السقف",
|
||||
"fillground": "ملء الأرض"
|
||||
}
|
||||
44
gui-src/locales/de.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "Standort auswählen",
|
||||
"zoom_in_and_choose": "Zoome hinein und wähle dein Gebiet aus",
|
||||
"select_world": "Welt auswählen",
|
||||
"choose_world": "Welt wählen",
|
||||
"no_world_selected": "Keine Welt ausgewählt",
|
||||
"start_generation": "Generierung starten",
|
||||
"progress": "Fortschritt",
|
||||
"custom_selection_confirmed": "Benutzerdefinierte Auswahl bestätigt!",
|
||||
"error_coordinates_out_of_range": "Fehler: Koordinaten sind außerhalb des Bereichs oder falsch geordnet (Lat vor Lng erforderlich).",
|
||||
"invalid_format": "Ungültiges Format. Bitte verwende 'lat,lng,lat,lng' oder 'lat lng lat lng'.",
|
||||
"generation_process_started": "Generierungsprozess gestartet.",
|
||||
"winter_mode": "Wintermodus",
|
||||
"world_scale": "Weltmaßstab",
|
||||
"custom_bounding_box": "Benutzerdefinierte BBOX",
|
||||
"floodfill_timeout": "Floodfill-Timeout (Sek)",
|
||||
"ground_level": "Bodenhöhe",
|
||||
"choose_world_modal_title": "Welt wählen",
|
||||
"select_existing_world": "Vorhandene Welt auswählen",
|
||||
"generate_new_world": "Neue Welt generieren",
|
||||
"customization_settings": "Einstellungen",
|
||||
"footer_text": "© {year} Arnis v{version} von louis-e",
|
||||
"new_version_available": "Eine neue Version ist verfügbar! Klicke hier, um sie herunterzuladen.",
|
||||
"minecraft_directory_not_found": "Minecraft Verzeichnis nicht gefunden",
|
||||
"world_in_use": "Die ausgewählte Welt ist gerade in Benutzung",
|
||||
"failed_to_create_world": "Neue Welt konnte nicht erstellt werden",
|
||||
"no_world_selected_error": "Keine Welt ausgewählt",
|
||||
"select_minecraft_world_first": "Wähle zuerst eine Minecraft Welt aus!",
|
||||
"select_location_first": "Wähle zuerst einen Standort aus!",
|
||||
"area_too_large": "Dieses Gebiet ist sehr groß und könnte das Berechnungslimit überschreiten.",
|
||||
"area_extensive": "Diese Gebietsgröße könnte längere Zeit für die Generierung benötigen.",
|
||||
"selection_confirmed": "Auswahl bestätigt!",
|
||||
"unknown_error": "Unbekannter Fehler",
|
||||
"license_and_credits": "Lizenz und Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Sekunden",
|
||||
"placeholder_ground": "Bodenhöhe",
|
||||
"language": "Sprache",
|
||||
"map_theme": "Kartenstil",
|
||||
"terrain": "Terrain",
|
||||
"interior": "Innenraum Generierung",
|
||||
"roof": "Dach Generierung",
|
||||
"fillground": "Boden füllen"
|
||||
}
|
||||
44
gui-src/locales/en-US.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "Select Location",
|
||||
"zoom_in_and_choose": "Zoom in and choose your area using the rectangle tool",
|
||||
"select_world": "Select World",
|
||||
"choose_world": "Choose World",
|
||||
"no_world_selected": "No world selected",
|
||||
"start_generation": "Start Generation",
|
||||
"progress": "Progress",
|
||||
"custom_selection_confirmed": "Custom selection confirmed!",
|
||||
"error_coordinates_out_of_range": "Error: Coordinates are out of range or incorrectly ordered (Lat before Lng required).",
|
||||
"invalid_format": "Invalid format. Please use 'lat,lng,lat,lng' or 'lat lng lat lng'.",
|
||||
"generation_process_started": "Generation process started.",
|
||||
"winter_mode": "Winter Mode",
|
||||
"world_scale": "World Scale",
|
||||
"custom_bounding_box": "Custom Bounding Box",
|
||||
"floodfill_timeout": "Floodfill Timeout (sec)",
|
||||
"ground_level": "Ground Level",
|
||||
"choose_world_modal_title": "Choose World",
|
||||
"select_existing_world": "Select existing world",
|
||||
"generate_new_world": "Generate new world",
|
||||
"customization_settings": "Customization Settings",
|
||||
"footer_text": "© {year} Arnis v{version} by louis-e",
|
||||
"new_version_available": "There's a new version available! Click here to download it.",
|
||||
"minecraft_directory_not_found": "Minecraft directory not found",
|
||||
"world_in_use": "The selected world is currently in use",
|
||||
"failed_to_create_world": "Failed to create new world",
|
||||
"no_world_selected_error": "No world selected",
|
||||
"select_minecraft_world_first": "Select a Minecraft world first!",
|
||||
"select_location_first": "Select a location first!",
|
||||
"area_too_large": "This area is very large and could exceed typical computing limits.",
|
||||
"area_extensive": "The area is quite extensive and may take significant time and resources.",
|
||||
"selection_confirmed": "Selection confirmed!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level",
|
||||
"language": "Language",
|
||||
"map_theme": "Map Theme",
|
||||
"terrain": "Terrain",
|
||||
"interior": "Interior Generation",
|
||||
"roof": "Roof Generation",
|
||||
"fillground": "Fill Ground"
|
||||
}
|
||||
1
gui-src/locales/en.json
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
en-US.json
|
||||
44
gui-src/locales/es.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "Seleccionar ubicación",
|
||||
"zoom_in_and_choose": "Acércate y elige tu área usando la herramienta de rectángulo",
|
||||
"select_world": "Seleccionar mundo",
|
||||
"choose_world": "Elegir mundo",
|
||||
"no_world_selected": "Ningún mundo seleccionado",
|
||||
"start_generation": "Iniciar generación",
|
||||
"progress": "Progreso",
|
||||
"custom_selection_confirmed": "¡Selección personalizada confirmada!",
|
||||
"error_coordinates_out_of_range": "Error: Las coordenadas están fuera de rango o están ordenadas incorrectamente (Lat antes de Lng requerido).",
|
||||
"invalid_format": "Formato inválido. Por favor, use 'lat,lng,lat,lng' o 'lat lng lat lng'.",
|
||||
"generation_process_started": "Proceso de generación iniciado.",
|
||||
"winter_mode": "Modo invierno",
|
||||
"world_scale": "Escala del mundo",
|
||||
"custom_bounding_box": "Caja delimitadora personalizada",
|
||||
"floodfill_timeout": "Tiempo de espera de relleno (seg)",
|
||||
"ground_level": "Nivel del suelo",
|
||||
"choose_world_modal_title": "Elegir mundo",
|
||||
"select_existing_world": "Seleccionar mundo existente",
|
||||
"generate_new_world": "Generar nuevo mundo",
|
||||
"customization_settings": "Configuración de personalización",
|
||||
"footer_text": "© {year} Arnis v{version} por louis-e",
|
||||
"new_version_available": "¡Hay una nueva versión disponible! Haga clic aquí para descargarla.",
|
||||
"minecraft_directory_not_found": "Directorio de Minecraft no encontrado",
|
||||
"world_in_use": "El mundo seleccionado está en uso",
|
||||
"failed_to_create_world": "No se pudo crear un nuevo mundo",
|
||||
"no_world_selected_error": "Ningún mundo seleccionado",
|
||||
"select_minecraft_world_first": "¡Seleccione un mundo de Minecraft primero!",
|
||||
"select_location_first": "¡Seleccione una ubicación primero!",
|
||||
"area_too_large": "Esta área es muy grande y podría exceder los límites típicos de computación.",
|
||||
"area_extensive": "El área es bastante extensa y puede requerir mucho tiempo y recursos.",
|
||||
"selection_confirmed": "¡Selección confirmada!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level",
|
||||
"language": "Idioma",
|
||||
"map_theme": "Tema del mapa",
|
||||
"terrain": "Terreno",
|
||||
"interior": "Generación de interiores",
|
||||
"roof": "Generación de techos",
|
||||
"fillground": "Rellenar suelo"
|
||||
}
|
||||
44
gui-src/locales/fi.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "Valitse paikka",
|
||||
"zoom_in_and_choose": "Zoomaa ja valitse paikka käyttämällä suorakulmatyökalua.",
|
||||
"select_world": "Valitse maailma",
|
||||
"choose_world": "Valitse maailma",
|
||||
"no_world_selected": "Maailmaa ei valittu",
|
||||
"start_generation": "Aloita generointi",
|
||||
"progress": "Edistys",
|
||||
"custom_selection_confirmed": "Mukautettu valinta vahvistettu!",
|
||||
"error_coordinates_out_of_range": "Virhe: Koordinaatit ovat kantaman ulkopuolella tai vääriin aseteltu (Lat ennen Lng vaadittu).",
|
||||
"invalid_format": "Väärä formaatti. Käytä 'lat,lng,lat,lng' tai 'lat lng lat lng'.",
|
||||
"generation_process_started": "Luontiprosessi aloitettu.",
|
||||
"winter_mode": "Talvitila",
|
||||
"world_scale": "Maailmanskaalaus",
|
||||
"custom_bounding_box": "Mukautettu rajoituslaatikko",
|
||||
"floodfill_timeout": "Täytön aikakatkaisu (sec)",
|
||||
"ground_level": "Maataso",
|
||||
"choose_world_modal_title": "Valitse maailma",
|
||||
"select_existing_world": "Valitse olemassa oleva maailma",
|
||||
"generate_new_world": "Luo uusi maailma",
|
||||
"customization_settings": "Kustomisaatio-asetukset",
|
||||
"footer_text": "© {year} Arnis v{version} tekijänä louis-e",
|
||||
"new_version_available": "Uusi versio on saatavilla! Paina tästä ladataksesi sen.",
|
||||
"minecraft_directory_not_found": "Minecraft-hakemistoa ei löytynyt",
|
||||
"world_in_use": "Valittu maailma käytössä.",
|
||||
"failed_to_create_world": "Uuden maailman luonti epäonnistui",
|
||||
"no_world_selected_error": "Maailmaa ei valittu",
|
||||
"select_minecraft_world_first": "Valitse Minecraft-maailma ensin!",
|
||||
"select_location_first": "Valitse paikka ensin!",
|
||||
"area_too_large": "Tämä alue on todella iso ja voi ylittää tyypilliset laskentarajat.",
|
||||
"area_extensive": "Alue on aika laaja ja voi viedä pitkän ajan ja resursseja.",
|
||||
"selection_confirmed": "Valinta vahvistettu!",
|
||||
"unknown_error": "Tuntematon virhe",
|
||||
"license_and_credits": "Lisenssi ja krediitit",
|
||||
"placeholder_bbox": "Formaatti: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Sekuntia",
|
||||
"placeholder_ground": "Maataso",
|
||||
"language": "Kieli",
|
||||
"map_theme": "Karttateema",
|
||||
"terrain": "Maasto",
|
||||
"interior": "Sisätilan luonti",
|
||||
"roof": "Katon luonti",
|
||||
"fillground": "Täytä maa"
|
||||
}
|
||||
44
gui-src/locales/fr-FR.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "Sélectionner une localisation",
|
||||
"zoom_in_and_choose": "Zoomez et choisissez votre zone avec l'outil rectangle",
|
||||
"select_world": "Sélectionner un monde",
|
||||
"choose_world": "Choisir un monde",
|
||||
"no_world_selected": "Aucun monde sélectionné",
|
||||
"start_generation": "Commencer la génération",
|
||||
"progress": "Progrès",
|
||||
"custom_selection_confirmed": "Sélection personnalisée confirmée !",
|
||||
"error_coordinates_out_of_range": "Erreur: Coordonnées hors de portée ou dans un ordre incorrect (besoin de la latitude avant la longitude).",
|
||||
"invalid_format": "Format invalide. Utilisez 'lat,lng,lat,lng' ou 'lat lng lat lng'.",
|
||||
"generation_process_started": "Processus de génération commencé.",
|
||||
"winter_mode": "Mode hiver",
|
||||
"world_scale": "Échelle du monde",
|
||||
"custom_bounding_box": "Cadre de délimitation personnalisé",
|
||||
"floodfill_timeout": "Expiration du délai de remplissage (en secondes)",
|
||||
"ground_level": "Niveau du sol",
|
||||
"choose_world_modal_title": "Choisir un monde",
|
||||
"select_existing_world": "Sélectionner un monde existant",
|
||||
"generate_new_world": "Générer un nouveau monde",
|
||||
"customization_settings": "Paramètres de personnalisation",
|
||||
"footer_text": "© {year} Arnis v{version} par louis-e",
|
||||
"new_version_available": "Une nouvelle version est disponible ! Cliquez ici pour la télécharger.",
|
||||
"minecraft_directory_not_found": "Répertoire Minecraft introuvable",
|
||||
"world_in_use": "Le monde sélectionné est en cours d'utilisation",
|
||||
"failed_to_create_world": "Échec de la création du nouveau monde",
|
||||
"no_world_selected_error": "Aucun monde sélectionné",
|
||||
"select_minecraft_world_first": "Sélectionnez d'abord un monde Minecraft !",
|
||||
"select_location_first": "Sélectionnez d'abord une localisation !",
|
||||
"area_too_large": "Cette zone est très grande et pourrait dépasser les limites de calcul courantes.",
|
||||
"area_extensive": "Cette zone est très étendue et pourrait nécessiter beaucoup de ressources et de temps.",
|
||||
"selection_confirmed": "Sélection confirmée !",
|
||||
"unknown_error": "Erreur inconnue",
|
||||
"license_and_credits": "Licence et crédits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Secondes",
|
||||
"placeholder_ground": "Niveau du sol",
|
||||
"language": "Langue",
|
||||
"map_theme": "Thème de carte",
|
||||
"terrain": "Terrain",
|
||||
"interior": "Génération d'intérieur",
|
||||
"roof": "Génération de toit",
|
||||
"fillground": "Remplir le sol"
|
||||
}
|
||||
44
gui-src/locales/hu.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "Hely kiválasztása",
|
||||
"zoom_in_and_choose": "Nagyíts és jelöld ki a területet a kijelölő eszközzel",
|
||||
"select_world": "Világ kijelölése",
|
||||
"choose_world": "Világ kiválasztása",
|
||||
"no_world_selected": "Nincs világ kiválasztva",
|
||||
"start_generation": "Generálás indítása",
|
||||
"progress": "Haladás",
|
||||
"custom_selection_confirmed": "Egyéni kiválasztás megerősítve",
|
||||
"error_coordinates_out_of_range": "Hiba: A koordináták tartományon kívül vannak vagy hibásan rendezettek (a szélességi foknak a hosszúsági fok előtt kell lennie)",
|
||||
"invalid_format": "Érvénytelen formátum. Kérjük, használja a 'lat,lng,lat,lng' vagy a 'lat lng lat lng' formátumot.'.",
|
||||
"generation_process_started": "Generálási folyamat elkezdődött",
|
||||
"winter_mode": "Téli mód",
|
||||
"world_scale": "Világ nagysága",
|
||||
"custom_bounding_box": "Egyéni határoló keret",
|
||||
"floodfill_timeout": "Floodfill Timeout (sec)",
|
||||
"ground_level": "Földszint",
|
||||
"choose_world_modal_title": "Világ kiválasztása",
|
||||
"select_existing_world": "Már létező világ kiválasztása",
|
||||
"generate_new_world": "Új világ generálása",
|
||||
"customization_settings": "Testreszabási lehetőségek",
|
||||
"footer_text": "© {year} Arnis v{version} by louis-e",
|
||||
"new_version_available": "Egy új verzió elérhető kattints ide hogy letöltsd",
|
||||
"minecraft_directory_not_found": "Minecraft mappa nem található",
|
||||
"world_in_use": "A kiválasztott világ már használatban van",
|
||||
"failed_to_create_world": "Nem sikerült új világot létrehozni",
|
||||
"no_world_selected_error": "Nincs kiválasztott világ",
|
||||
"select_minecraft_world_first": "Válassz ki egy Minecraft világot először!",
|
||||
"select_location_first": "Válassz egy helyet először!",
|
||||
"area_too_large": "Ez a terület nagyon nagy, és meghaladhatja a szokásos számítási korlátokat.",
|
||||
"area_extensive": "A terület meglehetősen kiterjedt, és jelentős időt és erőforrásokat igényelhet.",
|
||||
"selection_confirmed": "Kiválasztás megerősítve",
|
||||
"unknown_error": "Ismeretlen hiba",
|
||||
"license_and_credits": "Licenc és elismerés.",
|
||||
"placeholder_bbox": "Formátum: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Másodpercek",
|
||||
"placeholder_ground": "Földszint",
|
||||
"language": "Nyelv",
|
||||
"map_theme": "Térkép téma",
|
||||
"terrain": "Terep",
|
||||
"interior": "Belső generálás",
|
||||
"roof": "Tető generálás",
|
||||
"fillground": "Talaj feltöltése"
|
||||
}
|
||||
44
gui-src/locales/ko.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "장소 선택",
|
||||
"zoom_in_and_choose": "줌 인하고 직사각형 도구를 사용하여 영역을 선택하세요.",
|
||||
"select_world": "세계 선택",
|
||||
"choose_world": "세계 선택",
|
||||
"no_world_selected": "선택된 세계 없음",
|
||||
"start_generation": "생성 시작",
|
||||
"progress": "진행",
|
||||
"custom_selection_confirmed": "사용자 지정 선택이 확인되었습니다!",
|
||||
"error_coordinates_out_of_range": "오류: 좌표가 범위를 벗어나거나 잘못된 순서입니다 (Lat이 Lng보다 먼저 필요합니다).",
|
||||
"invalid_format": "잘못된 형식입니다. 'lat,lng,lat,lng' 또는 'lat lng lat lng' 형식을 사용하세요.",
|
||||
"generation_process_started": "생성 프로세스가 시작되었습니다.",
|
||||
"winter_mode": "겨울 모드",
|
||||
"world_scale": "세계 규모",
|
||||
"custom_bounding_box": "사용자 지정 경계 상자",
|
||||
"floodfill_timeout": "채우기 시간 초과 (초)",
|
||||
"ground_level": "지면 레벨",
|
||||
"choose_world_modal_title": "세계 선택",
|
||||
"select_existing_world": "이미 존재하는 세계 선택",
|
||||
"generate_new_world": "새 세계 생성",
|
||||
"customization_settings": "사용자 지정 설정",
|
||||
"footer_text": "© {year} Arnis v{version} by louis-e",
|
||||
"new_version_available": "새로운 버전이 있습니다! 여기를 클릭하여 다운로드하세요.",
|
||||
"minecraft_directory_not_found": "마인크래프트 디렉토리가 발견되지 않았습니다",
|
||||
"world_in_use": "선택한 세계가 현재 사용 중입니다",
|
||||
"failed_to_create_world": "새 세계 생성에 실패했습니다",
|
||||
"no_world_selected_error": "선택된 세계 없음 오류",
|
||||
"select_minecraft_world_first": "먼저 마인크래프트 세계를 선택하세요!",
|
||||
"select_location_first": "먼저 위치를 선택하세요!",
|
||||
"area_too_large": "이 지역은 매우 크고, 일반적인 계산 한계를 초과할 수 있습니다.",
|
||||
"area_extensive": "이 지역은 꽤 광범위하여 значитель한 시간과 자원이 필요할 수 있습니다.",
|
||||
"selection_confirmed": "선택이 확인되었습니다!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level",
|
||||
"language": "언어",
|
||||
"map_theme": "지도 테마",
|
||||
"terrain": "지형",
|
||||
"interior": "내부 생성",
|
||||
"roof": "지붕 생성",
|
||||
"fillground": "지면 채우기"
|
||||
}
|
||||
44
gui-src/locales/lt.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "Vietos pasirinkimas",
|
||||
"zoom_in_and_choose": "Pasididinkite žemėlapį ir pasirinkite plotą su kvadrato įrankiu",
|
||||
"select_world": "Pasaulio pasirinkimas",
|
||||
"choose_world": "Pasirinkti pasaulį",
|
||||
"no_world_selected": "Pasaulis nepasirinktas",
|
||||
"start_generation": "Pradėti generaciją",
|
||||
"progress": "Progresas",
|
||||
"custom_selection_confirmed": "Rėmo pasirinkimas patvirtintas!",
|
||||
"error_coordinates_out_of_range": "Klaida: Koordinatės yra už ribų arba neteisingai išdėstytos (plat turi būti prieš ilg).",
|
||||
"invalid_format": "Neteisingas formatas. Prašome naudoti 'plat,ilg,plat,ilg' arba 'plat ilg plat ilg'.",
|
||||
"generation_process_started": "Generacijos procesas pradėtas.",
|
||||
"winter_mode": "Žiemos režimas",
|
||||
"world_scale": "Pasaulio mastelis",
|
||||
"custom_bounding_box": "Pasirinktinis ribos rėmas",
|
||||
"floodfill_timeout": "Užpildymo laiko limitas (sek.)",
|
||||
"ground_level": "Žemės lygis",
|
||||
"choose_world_modal_title": "Pasaulio pasirinkimas",
|
||||
"select_existing_world": "Pasirinkti esamą pasaulį",
|
||||
"generate_new_world": "Sugeneruoti naują pasaulį",
|
||||
"customization_settings": "Generacijos nustatymai",
|
||||
"footer_text": "© {year} „Arnis“ v{version} sukurta louis-e",
|
||||
"new_version_available": "Surasta nauja versija! Spauskite čia kad ją atsisiųstumėte.",
|
||||
"minecraft_directory_not_found": "Nerastas „Minecraft“ aplankas",
|
||||
"world_in_use": "Pasirinktas pasaulis dabar užimtas",
|
||||
"failed_to_create_world": "Klaida sukuriant naują pasaulį",
|
||||
"no_world_selected_error": "Nėra pasirinktas pasaulis",
|
||||
"select_minecraft_world_first": "Pirma pasirinkite „Minecraft“ pasaulį!",
|
||||
"select_location_first": "Pirma pasirinkite vietą!",
|
||||
"area_too_large": "Šis plotas yra labai didelis ir gali viršyti tipinius resursų limitus.",
|
||||
"area_extensive": "Šis plotas yra pakankamai didelis kuriam reikėtų daug laiko ir resursų.",
|
||||
"selection_confirmed": "Pasirinkimas patvirtintas!",
|
||||
"unknown_error": "Nežinoma klaida",
|
||||
"license_and_credits": "Licencija ir padėkos",
|
||||
"placeholder_bbox": "Formatas: plat,lyg,plat,lyg",
|
||||
"placeholder_floodfill": "Sekundės",
|
||||
"placeholder_ground": "Žemės lygis",
|
||||
"language": "Kalba",
|
||||
"map_theme": "Žemėlapio tema",
|
||||
"terrain": "Reljefas",
|
||||
"interior": "Vidaus generavimas",
|
||||
"roof": "Stogo generavimas",
|
||||
"fillground": "Užpildyti pagrindą"
|
||||
}
|
||||
44
gui-src/locales/pl.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "Wybierz lokalizację",
|
||||
"zoom_in_and_choose": "Przybliż i zaznacz obszar za pomocą prostokąta",
|
||||
"select_world": "Wybierz świat",
|
||||
"choose_world": "Wybierz świat",
|
||||
"no_world_selected": "Nie wybrano świata",
|
||||
"start_generation": "Rozpocznij generowanie",
|
||||
"progress": "Postęp",
|
||||
"custom_selection_confirmed": "Niestandardowy wybór potwierdzony!",
|
||||
"error_coordinates_out_of_range": "Błąd: Współrzędne są poza zakresem lub w złej kolejności (wymagana szerokość przed długością).",
|
||||
"invalid_format": "Nieprawidłowy format. Użyj 'szer.,dł.,szer.,dł.' lub 'szer. dł. szer. dł.'.",
|
||||
"generation_process_started": "Proces generowania rozpoczęty.",
|
||||
"winter_mode": "Tryb Zimowy",
|
||||
"world_scale": "Skala świata",
|
||||
"custom_bounding_box": "Niestandardowy obszar",
|
||||
"floodfill_timeout": "Limit czasu wypełniania (sek)",
|
||||
"ground_level": "Wysokość obszaru",
|
||||
"choose_world_modal_title": "Wybierz świat",
|
||||
"select_existing_world": "Wybierz istniejący świat",
|
||||
"generate_new_world": "Generuj nowy świat",
|
||||
"customization_settings": "Ustawienia personalizacji",
|
||||
"footer_text": "© {year} Arnis v{version} autorstwa louis-e",
|
||||
"new_version_available": "Dostępna jest nowa wersja! Kliknij tutaj, aby ją pobrać.",
|
||||
"minecraft_directory_not_found": "Nie znaleziono katalogu Minecrafta",
|
||||
"world_in_use": "Wybrany świat jest obecnie używany",
|
||||
"failed_to_create_world": "Nie udało się utworzyć świata",
|
||||
"no_world_selected_error": "Nie wybrano świata",
|
||||
"select_minecraft_world_first": "Najpierw wybierz świat Minecrafta!",
|
||||
"select_location_first": "Najpierw wybierz lokalizację!",
|
||||
"area_too_large": "Ten obszar jest bardzo duży i może przekroczyć limity obliczeniowe.",
|
||||
"area_extensive": "Ten obszar jest rozległy i może pochłonąć dużo czasu oraz zasobów.",
|
||||
"selection_confirmed": "Wybór potwierdzony!",
|
||||
"unknown_error": "Nieznany błąd",
|
||||
"license_and_credits": "Licencja i autorzy",
|
||||
"placeholder_bbox": "Format: szer,dł,szer,dł",
|
||||
"placeholder_floodfill": "Sekundy",
|
||||
"placeholder_ground": "Wysokość",
|
||||
"language": "Język",
|
||||
"map_theme": "Motyw mapy",
|
||||
"terrain": "Teren",
|
||||
"interior": "Generowanie wnętrz",
|
||||
"roof": "Generowanie dachów",
|
||||
"fillground": "Wypełnij podłoże"
|
||||
}
|
||||
44
gui-src/locales/ru.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "Выбрать местоположение",
|
||||
"zoom_in_and_choose": "Приблизьте и выберите область",
|
||||
"select_world": "Выбрать мир",
|
||||
"choose_world": "Выбрать мир",
|
||||
"no_world_selected": "Мир не выбран",
|
||||
"start_generation": "Начать генерацию",
|
||||
"progress": "Прогресс",
|
||||
"custom_selection_confirmed": "Пользовательский выбор подтвержден!",
|
||||
"error_coordinates_out_of_range": "Ошибка: Координаты находятся вне зоны действия или указаны в неправильном порядке (сначала широта, затем долгота)",
|
||||
"invalid_format": "Неверный формат. Используйте 'широта,долгота,широта,долгота' или 'широта долгота широта долгота'",
|
||||
"generation_process_started": "Процесс генерации начат",
|
||||
"winter_mode": "Зимний режим",
|
||||
"world_scale": "Масштаб мира",
|
||||
"custom_bounding_box": "Пользовательская ограничивающая рамка",
|
||||
"floodfill_timeout": "Тайм-аут заливки (сек)",
|
||||
"ground_level": "Уровень земли",
|
||||
"choose_world_modal_title": "Выбрать мир",
|
||||
"select_existing_world": "Выбрать существующий мир",
|
||||
"generate_new_world": "Создать новый мир",
|
||||
"customization_settings": "Настройки персонализации",
|
||||
"footer_text": "© {year} Arnis v{version} от louis-e",
|
||||
"new_version_available": "Доступна новая версия! Нажмите здесь, чтобы скачать",
|
||||
"minecraft_directory_not_found": "Каталог Minecraft не найден",
|
||||
"world_in_use": "Выбранный мир уже используется",
|
||||
"failed_to_create_world": "Не удалось создать новый мир",
|
||||
"no_world_selected_error": "Мир не выбран",
|
||||
"select_minecraft_world_first": "Сначала выберите мир Minecraft!",
|
||||
"select_location_first": "Сначала выберите местоположение!",
|
||||
"area_too_large": "Эта область слишком велика и может превысить типичные вычислительные ограничения",
|
||||
"area_extensive": "Область довольно обширна и может потребовать значительного времени и ресурсов",
|
||||
"selection_confirmed": "Выбор подтвержден!",
|
||||
"unknown_error": "Неизвестная ошибка",
|
||||
"license_and_credits": "Лицензия и авторы",
|
||||
"placeholder_bbox": "Формат: широта,долгота,широта,долгота",
|
||||
"placeholder_floodfill": "Секунды",
|
||||
"placeholder_ground": "Уровень земли",
|
||||
"language": "Язык",
|
||||
"map_theme": "Тема карты",
|
||||
"terrain": "Рельеф",
|
||||
"interior": "Генерация интерьера",
|
||||
"roof": "Генерация крыш",
|
||||
"fillground": "Заполнить землю"
|
||||
}
|
||||
44
gui-src/locales/sv.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "Välj plats",
|
||||
"zoom_in_and_choose": "Zooma in och välj ditt område med rektangulärt verktyg",
|
||||
"select_world": "Välj värld",
|
||||
"choose_world": "Välj värld",
|
||||
"no_world_selected": "Ingen värld vald",
|
||||
"start_generation": "Starta generering",
|
||||
"progress": "Framsteg",
|
||||
"custom_selection_confirmed": "Anpassad markering bekräftad!",
|
||||
"error_coordinates_out_of_range": "Fel: Koordinater är utanför området eller felaktigt ordnade (Lat före Lng krävs).",
|
||||
"invalid_format": "Ogiltigt format. Använd 'lat,lng,lat,lng' eller 'lat lng lat lng'.",
|
||||
"generation_process_started": "Genereringsprocessen startad.",
|
||||
"winter_mode": "Vinterläge",
|
||||
"world_scale": "Världsskala",
|
||||
"custom_bounding_box": "Anpassad begränsningsram",
|
||||
"floodfill_timeout": "Floodfill-tidsgräns (sek)",
|
||||
"ground_level": "Marknivå",
|
||||
"choose_world_modal_title": "Välj värld",
|
||||
"select_existing_world": "Välj existerande värld",
|
||||
"generate_new_world": "Generera ny värld",
|
||||
"customization_settings": "Anpassningsinställningar",
|
||||
"footer_text": "© {year} Arnis v{version} by louis-e",
|
||||
"new_version_available": "Det finns en ny version tillgänglig! Klicka här för att ladda ner den.",
|
||||
"minecraft_directory_not_found": "Minecraft-katalogen hittades inte",
|
||||
"world_in_use": "Den valda världen används just nu",
|
||||
"failed_to_create_world": "Misslyckades att skapa ny värld",
|
||||
"no_world_selected_error": "Ingen värld vald fel",
|
||||
"select_minecraft_world_first": "Välj Minecraft-värld först!",
|
||||
"select_location_first": "Välj plats först!",
|
||||
"area_too_large": "Detta område är mycket stort och kan överskrida vanliga beräkningsgränser.",
|
||||
"area_extensive": "Området är ganska extensivt och kan ta betydande tid och resurser.",
|
||||
"selection_confirmed": "Val bekräftat!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level",
|
||||
"language": "Språk",
|
||||
"map_theme": "Karttema",
|
||||
"terrain": "Terräng",
|
||||
"interior": "Interiörgenerering",
|
||||
"roof": "Takgenerering",
|
||||
"fillground": "Fyll mark"
|
||||
}
|
||||
44
gui-src/locales/ua.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "Обрати локацію",
|
||||
"zoom_in_and_choose": "Збільште і оберіть область за допомогою прямокутника",
|
||||
"select_world": "Обрати світ",
|
||||
"choose_world": "Обрати світ",
|
||||
"no_world_selected": "Світ не обрано",
|
||||
"start_generation": "Почати генерацію",
|
||||
"progress": "Прогрес",
|
||||
"custom_selection_confirmed": "Користувацький вибір підтверджено!",
|
||||
"error_coordinates_out_of_range": "Помилка: Координати поза діапазоном або неправильно впорядковані (потрібно широта перед довгота)",
|
||||
"invalid_format": "Неправильний формат. Будь ласка, використовуйте 'широта,довгота,широта,довгота' або 'широта довгота широта довгота'",
|
||||
"generation_process_started": "Процес генерації розпочато",
|
||||
"winter_mode": "Зимовий режим",
|
||||
"world_scale": "Масштаб світу",
|
||||
"custom_bounding_box": "Користувацька обмежувальна рамка",
|
||||
"floodfill_timeout": "Тайм-аут заливки (сек)",
|
||||
"ground_level": "Рівень землі",
|
||||
"choose_world_modal_title": "Обрати світ",
|
||||
"select_existing_world": "Обрати наявний світ",
|
||||
"generate_new_world": "Створити новий світ",
|
||||
"customization_settings": "Налаштування параметрів",
|
||||
"footer_text": "© {year} Arnis v{version} від louis-e",
|
||||
"new_version_available": "Доступна нова версія! Натисніть тут, щоб завантажити її",
|
||||
"minecraft_directory_not_found": "Каталог Minecraft не знайдено",
|
||||
"world_in_use": "Вибраний світ зараз використовується",
|
||||
"failed_to_create_world": "Не вдалося створити новий світ",
|
||||
"no_world_selected_error": "Світ не обрано",
|
||||
"select_minecraft_world_first": "Спочатку виберіть світ Minecraft!",
|
||||
"select_location_first": "Спочатку виберіть місцезнаходження!",
|
||||
"area_too_large": "Ця область дуже велика і може перевищити типові обчислювальні межі",
|
||||
"area_extensive": "Область досить велика і може вимагати значного часу та ресурсів",
|
||||
"selection_confirmed": "Вибір підтверджено!",
|
||||
"unknown_error": "Unknown error",
|
||||
"license_and_credits": "License and Credits",
|
||||
"placeholder_bbox": "Format: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "Seconds",
|
||||
"placeholder_ground": "Ground Level",
|
||||
"language": "Мова",
|
||||
"map_theme": "Тема карти",
|
||||
"terrain": "Рельєф",
|
||||
"interior": "Генерація інтер'єру",
|
||||
"roof": "Генерація даху",
|
||||
"fillground": "Заповнити землю"
|
||||
}
|
||||
44
gui-src/locales/zh-CN.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"select_location": "选择位置",
|
||||
"zoom_in_and_choose": "放大并使用矩形工具选择您的区域",
|
||||
"select_world": "选择世界",
|
||||
"choose_world": "选择世界",
|
||||
"no_world_selected": "未选择世界",
|
||||
"start_generation": "开始生成",
|
||||
"progress": "进度",
|
||||
"custom_selection_confirmed": "自定义选择已确认!",
|
||||
"error_coordinates_out_of_range": "错误:坐标超出范围或顺序不正确(需要先纬度后经度)。",
|
||||
"invalid_format": "格式无效。请使用 'lat,lng,lat,lng' 或 'lat lng lat lng'。",
|
||||
"generation_process_started": "生成过程已开始。",
|
||||
"winter_mode": "冬季模式",
|
||||
"world_scale": "世界比例",
|
||||
"custom_bounding_box": "自定义边界框",
|
||||
"floodfill_timeout": "填充超时(秒)",
|
||||
"ground_level": "地面高度",
|
||||
"choose_world_modal_title": "选择世界",
|
||||
"select_existing_world": "选择现有世界",
|
||||
"generate_new_world": "生成新世界",
|
||||
"customization_settings": "自定义设置",
|
||||
"footer_text": "© {year} Arnis v{version} 由 louis-e 提供",
|
||||
"new_version_available": "有新版本可用!点击这里下载。",
|
||||
"minecraft_directory_not_found": "未找到 Minecraft 目录",
|
||||
"world_in_use": "所选世界正在使用中",
|
||||
"failed_to_create_world": "无法创建新世界",
|
||||
"no_world_selected_error": "未选择世界",
|
||||
"select_minecraft_world_first": "请先选择一个 Minecraft 世界!",
|
||||
"select_location_first": "请先选择一个位置!",
|
||||
"area_too_large": "该区域非常大,可能会超出典型的计算限制。",
|
||||
"area_extensive": "该区域相当广泛,可能需要大量时间和资源。",
|
||||
"selection_confirmed": "选择已确认!",
|
||||
"unknown_error": "未知错误",
|
||||
"license_and_credits": "许可证和致谢",
|
||||
"placeholder_bbox": "格式: lat,lng,lat,lng",
|
||||
"placeholder_floodfill": "秒",
|
||||
"placeholder_ground": "地面高度",
|
||||
"language": "语言",
|
||||
"map_theme": "地图主题",
|
||||
"terrain": "地形",
|
||||
"interior": "内部生成",
|
||||
"roof": "屋顶生成",
|
||||
"fillground": "填充地面"
|
||||
}
|
||||
14
gui-src/maps.html
vendored
@@ -3,26 +3,34 @@
|
||||
<title>Map View</title>
|
||||
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||
|
||||
<link rel="stylesheet" href="css/maps/leaflet.css" />
|
||||
<link rel="stylesheet" href="css/maps/leaflet.draw.css" />
|
||||
<link rel="stylesheet" href="css/maps/leaflet.sidebar.css" />
|
||||
<link rel="stylesheet" href="css/maps/mapbox.v3.2.0.css" />
|
||||
<link rel="stylesheet" href="css/bbox.css" />
|
||||
<link rel="stylesheet" href="css/search.css" />
|
||||
|
||||
<script src="js/libs/jquery-1.9.1.min.js"></script>
|
||||
<script src="js/libs/jquery-ui-1.10.3.custom.js"></script>
|
||||
<script src="js/maps/leaflet.js"></script>
|
||||
<script src="js/maps/mapbox.v3.2.0.js"></script>
|
||||
<script src="js/maps/leaflet.draw.js"></script>
|
||||
<script src="js/maps/leaflet.sidebar.js"></script>
|
||||
<script src="js/maps/wkt.parser.js"></script>
|
||||
<script src="js/maps/proj4-src.js"></script>
|
||||
<script src="js/maps/proj4leaflet.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script src="js/bbox.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<!-- City Search Box -->
|
||||
<div id="search-container">
|
||||
<div id="search-box">
|
||||
<input type="text" id="city-search" placeholder="Search for a city..." autocomplete="off" />
|
||||
<button id="search-btn">🔍</button>
|
||||
</div>
|
||||
<div id="search-results"></div>
|
||||
</div>
|
||||
|
||||
<div id="map"></div>
|
||||
<div id="rsidebar" >
|
||||
<button id="add">Add</button>
|
||||
|
||||
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 68 KiB |
BIN
icons/32x32.png
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.7 KiB |
BIN
icons/icon.icns
BIN
icons/icon.ico
|
Before Width: | Height: | Size: 221 KiB After Width: | Height: | Size: 86 KiB |
BIN
icons/icon.png
|
Before Width: | Height: | Size: 232 KiB After Width: | Height: | Size: 258 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 3.2 KiB |
158
src/args.rs
@@ -1,28 +1,26 @@
|
||||
use clap::{ArgGroup, Parser};
|
||||
use colored::Colorize;
|
||||
use crate::coordinate_system::geographic::LLBBox;
|
||||
use clap::Parser;
|
||||
use std::path::Path;
|
||||
use std::process::exit;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Command-line arguments parser
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about)]
|
||||
#[command(group(
|
||||
ArgGroup::new("location")
|
||||
.required(true)
|
||||
.args(&["bbox", "file"])
|
||||
))]
|
||||
pub struct Args {
|
||||
/// Bounding box of the area (min_lng,min_lat,max_lng,max_lat) (required)
|
||||
#[arg(long, allow_hyphen_values = true)]
|
||||
pub bbox: Option<String>,
|
||||
/// Bounding box of the area (min_lat,min_lng,max_lat,max_lng) (required)
|
||||
#[arg(long, allow_hyphen_values = true, value_parser = LLBBox::from_str)]
|
||||
pub bbox: LLBBox,
|
||||
|
||||
/// JSON file containing OSM data (optional)
|
||||
#[arg(long)]
|
||||
#[arg(long, group = "location")]
|
||||
pub file: Option<String>,
|
||||
|
||||
/// JSON file to save OSM data to (optional)
|
||||
#[arg(long, group = "location")]
|
||||
pub save_json_file: Option<String>,
|
||||
|
||||
/// Path to the Minecraft world (required)
|
||||
#[arg(long, required = true)]
|
||||
#[arg(long, value_parser = validate_minecraft_world_path)]
|
||||
pub path: String,
|
||||
|
||||
/// Downloader method (requests/curl/wget) (optional)
|
||||
@@ -30,74 +28,114 @@ pub struct Args {
|
||||
pub downloader: String,
|
||||
|
||||
/// World scale to use, in blocks per meter
|
||||
#[arg(long, default_value = "1.0")]
|
||||
#[arg(long, default_value_t = 1.0)]
|
||||
pub scale: f64,
|
||||
|
||||
/// Ground level to use in the Minecraft world
|
||||
#[arg(long, default_value_t = -62)]
|
||||
pub ground_level: i32,
|
||||
|
||||
/// Enable winter mode (default: false)
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub winter: bool,
|
||||
/// Enable terrain (optional)
|
||||
#[arg(long)]
|
||||
pub terrain: bool,
|
||||
|
||||
/// Enable interior generation (optional)
|
||||
#[arg(long, default_value_t = true, action = clap::ArgAction::SetTrue)]
|
||||
pub interior: bool,
|
||||
|
||||
/// Enable roof generation (optional)
|
||||
#[arg(long, default_value_t = true, action = clap::ArgAction::SetTrue)]
|
||||
pub roof: bool,
|
||||
|
||||
/// Enable filling ground (optional)
|
||||
#[arg(long, default_value_t = false, action = clap::ArgAction::SetFalse)]
|
||||
pub fillground: bool,
|
||||
|
||||
/// Enable debug mode (optional)
|
||||
#[arg(long, default_value_t = false, action = clap::ArgAction::SetTrue)]
|
||||
#[arg(long)]
|
||||
pub debug: bool,
|
||||
|
||||
/// Set floodfill timeout (seconds) (optional)
|
||||
#[arg(long, value_parser = parse_duration)]
|
||||
pub timeout: Option<Duration>,
|
||||
|
||||
/// Spawn point coordinates (lat, lng)
|
||||
#[arg(skip)]
|
||||
pub spawn_point: Option<(f64, f64)>,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
pub fn run(&self) {
|
||||
// Validating the world path
|
||||
let mc_world_path: &Path = Path::new(&self.path);
|
||||
if !mc_world_path.join("region").exists() {
|
||||
eprintln!(
|
||||
"{}",
|
||||
"Error! No Minecraft world found at the given path"
|
||||
.red()
|
||||
.bold()
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Validating bbox if provided
|
||||
if let Some(bbox) = &self.bbox {
|
||||
if !validate_bounding_box(bbox) {
|
||||
eprintln!("{}", "Error! Invalid bbox input".red().bold());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
fn validate_minecraft_world_path(path: &str) -> Result<String, String> {
|
||||
let mc_world_path = Path::new(path);
|
||||
if !mc_world_path.exists() {
|
||||
return Err(format!("Path does not exist: {path}"));
|
||||
}
|
||||
}
|
||||
|
||||
/// Validates the bounding box string
|
||||
fn validate_bounding_box(bbox: &str) -> bool {
|
||||
let parts: Vec<&str> = bbox.split(',').collect();
|
||||
if parts.len() != 4 {
|
||||
return false;
|
||||
if !mc_world_path.is_dir() {
|
||||
return Err(format!("Path is not a directory: {path}"));
|
||||
}
|
||||
|
||||
let min_lng: f64 = parts[0].parse().ok().unwrap_or(0.0);
|
||||
let min_lat: f64 = parts[1].parse().ok().unwrap_or(0.0);
|
||||
let max_lng: f64 = parts[2].parse().ok().unwrap_or(0.0);
|
||||
let max_lat: f64 = parts[3].parse().ok().unwrap_or(0.0);
|
||||
|
||||
if !(-180.0..=180.0).contains(&min_lng) || !(-180.0..=180.0).contains(&max_lng) {
|
||||
return false;
|
||||
let region = mc_world_path.join("region");
|
||||
if !region.is_dir() {
|
||||
return Err(format!("No Minecraft world found at {region:?}"));
|
||||
}
|
||||
|
||||
if !(-90.0..=90.0).contains(&min_lat) || !(-90.0..=90.0).contains(&max_lat) {
|
||||
return false;
|
||||
}
|
||||
|
||||
min_lng < max_lng && min_lat < max_lat
|
||||
Ok(path.to_string())
|
||||
}
|
||||
|
||||
fn parse_duration(arg: &str) -> Result<std::time::Duration, std::num::ParseIntError> {
|
||||
let seconds = arg.parse()?;
|
||||
Ok(std::time::Duration::from_secs(seconds))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn minecraft_tmpdir() -> tempfile::TempDir {
|
||||
let tmpdir = tempfile::tempdir().unwrap();
|
||||
// create a `region` directory in the tempdir
|
||||
let region_path = tmpdir.path().join("region");
|
||||
std::fs::create_dir(®ion_path).unwrap();
|
||||
tmpdir
|
||||
}
|
||||
#[test]
|
||||
fn test_flags() {
|
||||
let tmpdir = minecraft_tmpdir();
|
||||
let tmp_path = tmpdir.path().to_str().unwrap();
|
||||
|
||||
// Test that terrain/debug are SetTrue
|
||||
let cmd = [
|
||||
"arnis",
|
||||
"--path",
|
||||
tmp_path,
|
||||
"--bbox",
|
||||
"1,2,3,4",
|
||||
"--terrain",
|
||||
"--debug",
|
||||
];
|
||||
let args = Args::parse_from(cmd.iter());
|
||||
assert!(args.debug);
|
||||
assert!(args.terrain);
|
||||
|
||||
let cmd = ["arnis", "--path", tmp_path, "--bbox", "1,2,3,4"];
|
||||
let args = Args::parse_from(cmd.iter());
|
||||
assert!(!args.debug);
|
||||
assert!(!args.terrain);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_required_options() {
|
||||
let tmpdir = minecraft_tmpdir();
|
||||
let tmp_path = tmpdir.path().to_str().unwrap();
|
||||
|
||||
let cmd = ["arnis"];
|
||||
assert!(Args::try_parse_from(cmd.iter()).is_err());
|
||||
|
||||
let cmd = ["arnis", "--path", tmp_path, "--bbox", "1,2,3,4"];
|
||||
assert!(Args::try_parse_from(cmd.iter()).is_ok());
|
||||
|
||||
let cmd = ["arnis", "--path", tmp_path, "--file", ""];
|
||||
assert!(Args::try_parse_from(cmd.iter()).is_err());
|
||||
|
||||
// The --gui flag isn't used here, ugh. TODO clean up main.rs and its argparse usage.
|
||||
// let cmd = ["arnis", "--gui"];
|
||||
// assert!(Args::try_parse_from(cmd.iter()).is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,22 +7,93 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::colors::RGBTuple;
|
||||
|
||||
// Enums for stair properties
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum StairFacing {
|
||||
North,
|
||||
East,
|
||||
South,
|
||||
West,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum StairShape {
|
||||
Straight,
|
||||
InnerLeft,
|
||||
InnerRight,
|
||||
OuterLeft,
|
||||
OuterRight,
|
||||
}
|
||||
|
||||
impl StairFacing {
|
||||
#[inline(always)]
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
StairFacing::North => "north",
|
||||
StairFacing::East => "east",
|
||||
StairFacing::South => "south",
|
||||
StairFacing::West => "west",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl StairShape {
|
||||
#[inline(always)]
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
StairShape::Straight => "straight",
|
||||
StairShape::InnerLeft => "inner_left",
|
||||
StairShape::InnerRight => "inner_right",
|
||||
StairShape::OuterLeft => "outer_left",
|
||||
StairShape::OuterRight => "outer_right",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Type definitions for better readability
|
||||
type ColorTuple = (u8, u8, u8);
|
||||
type BlockOptions = &'static [Block];
|
||||
type ColorBlockMapping = (ColorTuple, BlockOptions);
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Hash, Debug)]
|
||||
pub struct Block {
|
||||
id: u8,
|
||||
}
|
||||
|
||||
// Extended block with dynamic properties
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct BlockWithProperties {
|
||||
pub block: Block,
|
||||
pub properties: Option<Value>,
|
||||
}
|
||||
|
||||
impl BlockWithProperties {
|
||||
pub fn new(block: Block, properties: Option<Value>) -> Self {
|
||||
Self { block, properties }
|
||||
}
|
||||
|
||||
pub fn simple(block: Block) -> Self {
|
||||
Self {
|
||||
block,
|
||||
properties: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Block {
|
||||
#[inline(always)]
|
||||
const fn new(id: u8) -> Self {
|
||||
Self { id }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn id(&self) -> u8 {
|
||||
self.id
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn namespace(&self) -> &str {
|
||||
"mincraft"
|
||||
"minecraft"
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &str {
|
||||
@@ -41,7 +112,7 @@ impl Block {
|
||||
11 => "chiseled_stone_bricks",
|
||||
12 => "cobblestone_wall",
|
||||
13 => "cobblestone",
|
||||
14 => "cracked_polished_blackstone_bricks",
|
||||
14 => "polished_blackstone_bricks",
|
||||
15 => "cracked_stone_bricks",
|
||||
16 => "crimson_planks",
|
||||
17 => "cut_sandstone",
|
||||
@@ -52,11 +123,11 @@ impl Block {
|
||||
22 => "dirt",
|
||||
23 => "end_stone_bricks",
|
||||
24 => "farmland",
|
||||
25 => "glass_pane",
|
||||
25 => "glass",
|
||||
26 => "glowstone",
|
||||
27 => "granite",
|
||||
28 => "grass_block",
|
||||
29 => "tall_grass",
|
||||
29 => "short_grass",
|
||||
30 => "gravel",
|
||||
31 => "gray_concrete",
|
||||
32 => "gray_terracotta",
|
||||
@@ -74,7 +145,7 @@ impl Block {
|
||||
44 => "mossy_cobblestone",
|
||||
45 => "mud_bricks",
|
||||
46 => "nether_bricks",
|
||||
47 => "nether_bricks",
|
||||
47 => "netherite_block",
|
||||
48 => "oak_fence",
|
||||
49 => "oak_leaves",
|
||||
50 => "oak_log",
|
||||
@@ -84,7 +155,7 @@ impl Block {
|
||||
54 => "podzol",
|
||||
55 => "polished_andesite",
|
||||
56 => "polished_basalt",
|
||||
57 => "polished_blackstone_bricks",
|
||||
57 => "quartz_block",
|
||||
58 => "polished_blackstone",
|
||||
59 => "polished_deepslate",
|
||||
60 => "polished_diorite",
|
||||
@@ -141,12 +212,78 @@ impl Block {
|
||||
111 => "snow_block",
|
||||
112 => "snow",
|
||||
113 => "oak_sign",
|
||||
114 => "andesite_wall",
|
||||
115 => "stone_brick_wall",
|
||||
116..=125 => "rail",
|
||||
126 => "coarse_dirt",
|
||||
127 => "iron_ore",
|
||||
128 => "coal_ore",
|
||||
129 => "gold_ore",
|
||||
130 => "copper_ore",
|
||||
131 => "clay",
|
||||
132 => "dirt_path",
|
||||
133 => "ice",
|
||||
134 => "packed_ice",
|
||||
135 => "mud",
|
||||
136 => "dead_bush",
|
||||
137..=138 => "tall_grass",
|
||||
139 => "crafting_table",
|
||||
140 => "furnace",
|
||||
141 => "white_carpet",
|
||||
142 => "bookshelf",
|
||||
143 => "oak_pressure_plate",
|
||||
144 => "oak_stairs",
|
||||
155 => "chest",
|
||||
156 => "red_carpet",
|
||||
157 => "anvil",
|
||||
158 => "jukebox",
|
||||
159 => "oak_door",
|
||||
160 => "brewing_stand",
|
||||
161 => "red_bed", // North head
|
||||
162 => "red_bed", // North foot
|
||||
163 => "red_bed", // East head
|
||||
164 => "red_bed", // East foot
|
||||
165 => "red_bed", // South head
|
||||
166 => "red_bed", // South foot
|
||||
167 => "red_bed", // West head
|
||||
168 => "red_bed", // West foot
|
||||
169 => "gray_stained_glass",
|
||||
170 => "light_gray_stained_glass",
|
||||
171 => "brown_stained_glass",
|
||||
172 => "tinted_glass",
|
||||
173 => "oak_trapdoor",
|
||||
174 => "brown_concrete",
|
||||
175 => "black_terracotta",
|
||||
176 => "brown_terracotta",
|
||||
177 => "stone_brick_stairs",
|
||||
178 => "mud_brick_stairs",
|
||||
179 => "polished_blackstone_brick_stairs",
|
||||
180 => "brick_stairs",
|
||||
181 => "polished_granite_stairs",
|
||||
182 => "end_stone_brick_stairs",
|
||||
183 => "polished_diorite_stairs",
|
||||
184 => "smooth_sandstone_stairs",
|
||||
185 => "quartz_stairs",
|
||||
186 => "polished_andesite_stairs",
|
||||
187 => "nether_brick_stairs",
|
||||
_ => panic!("Invalid id"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn properties(&self) -> Option<Value> {
|
||||
match self.id {
|
||||
3 => Some(Value::Compound({
|
||||
let mut map: HashMap<String, Value> = HashMap::new();
|
||||
map.insert("persistent".to_string(), Value::String("true".to_string()));
|
||||
map
|
||||
})),
|
||||
|
||||
49 => Some(Value::Compound({
|
||||
let mut map: HashMap<String, Value> = HashMap::new();
|
||||
map.insert("persistent".to_string(), Value::String("true".to_string()));
|
||||
map
|
||||
})),
|
||||
|
||||
105 => Some(Value::Compound({
|
||||
let mut map: HashMap<String, Value> = HashMap::new();
|
||||
map.insert("age".to_string(), Value::String("7".to_string()));
|
||||
@@ -187,11 +324,200 @@ impl Block {
|
||||
map
|
||||
})),
|
||||
|
||||
116 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert(
|
||||
"shape".to_string(),
|
||||
Value::String("north_south".to_string()),
|
||||
);
|
||||
map
|
||||
})),
|
||||
|
||||
117 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("shape".to_string(), Value::String("east_west".to_string()));
|
||||
map
|
||||
})),
|
||||
|
||||
118 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert(
|
||||
"shape".to_string(),
|
||||
Value::String("ascending_east".to_string()),
|
||||
);
|
||||
map
|
||||
})),
|
||||
|
||||
119 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert(
|
||||
"shape".to_string(),
|
||||
Value::String("ascending_west".to_string()),
|
||||
);
|
||||
map
|
||||
})),
|
||||
|
||||
120 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert(
|
||||
"shape".to_string(),
|
||||
Value::String("ascending_north".to_string()),
|
||||
);
|
||||
map
|
||||
})),
|
||||
|
||||
121 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert(
|
||||
"shape".to_string(),
|
||||
Value::String("ascending_south".to_string()),
|
||||
);
|
||||
map
|
||||
})),
|
||||
|
||||
122 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("shape".to_string(), Value::String("north_east".to_string()));
|
||||
map
|
||||
})),
|
||||
|
||||
123 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("shape".to_string(), Value::String("north_west".to_string()));
|
||||
map
|
||||
})),
|
||||
|
||||
124 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("shape".to_string(), Value::String("south_east".to_string()));
|
||||
map
|
||||
})),
|
||||
|
||||
125 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("shape".to_string(), Value::String("south_west".to_string()));
|
||||
map
|
||||
})),
|
||||
137 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("half".to_string(), Value::String("lower".to_string()));
|
||||
map
|
||||
})),
|
||||
138 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("half".to_string(), Value::String("upper".to_string()));
|
||||
map
|
||||
})),
|
||||
|
||||
// Red bed variations by direction and part
|
||||
161 => Some(Value::Compound({
|
||||
let mut map: HashMap<String, Value> = HashMap::new();
|
||||
map.insert("facing".to_string(), Value::String("north".to_string()));
|
||||
map.insert("part".to_string(), Value::String("head".to_string()));
|
||||
map
|
||||
})),
|
||||
162 => Some(Value::Compound({
|
||||
let mut map: HashMap<String, Value> = HashMap::new();
|
||||
map.insert("facing".to_string(), Value::String("north".to_string()));
|
||||
map.insert("part".to_string(), Value::String("foot".to_string()));
|
||||
map
|
||||
})),
|
||||
163 => Some(Value::Compound({
|
||||
let mut map: HashMap<String, Value> = HashMap::new();
|
||||
map.insert("facing".to_string(), Value::String("east".to_string()));
|
||||
map.insert("part".to_string(), Value::String("head".to_string()));
|
||||
map
|
||||
})),
|
||||
164 => Some(Value::Compound({
|
||||
let mut map: HashMap<String, Value> = HashMap::new();
|
||||
map.insert("facing".to_string(), Value::String("east".to_string()));
|
||||
map.insert("part".to_string(), Value::String("foot".to_string()));
|
||||
map
|
||||
})),
|
||||
165 => Some(Value::Compound({
|
||||
let mut map: HashMap<String, Value> = HashMap::new();
|
||||
map.insert("facing".to_string(), Value::String("south".to_string()));
|
||||
map.insert("part".to_string(), Value::String("head".to_string()));
|
||||
map
|
||||
})),
|
||||
166 => Some(Value::Compound({
|
||||
let mut map: HashMap<String, Value> = HashMap::new();
|
||||
map.insert("facing".to_string(), Value::String("south".to_string()));
|
||||
map.insert("part".to_string(), Value::String("foot".to_string()));
|
||||
map
|
||||
})),
|
||||
167 => Some(Value::Compound({
|
||||
let mut map: HashMap<String, Value> = HashMap::new();
|
||||
map.insert("facing".to_string(), Value::String("west".to_string()));
|
||||
map.insert("part".to_string(), Value::String("head".to_string()));
|
||||
map
|
||||
})),
|
||||
168 => Some(Value::Compound({
|
||||
let mut map: HashMap<String, Value> = HashMap::new();
|
||||
map.insert("facing".to_string(), Value::String("west".to_string()));
|
||||
map.insert("part".to_string(), Value::String("foot".to_string()));
|
||||
map
|
||||
})),
|
||||
173 => Some(Value::Compound({
|
||||
let mut map = HashMap::new();
|
||||
map.insert("half".to_string(), Value::String("top".to_string()));
|
||||
map
|
||||
})),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cache for stair blocks with properties
|
||||
use std::sync::Mutex;
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
static STAIR_CACHE: Lazy<Mutex<HashMap<(u8, StairFacing, StairShape), BlockWithProperties>>> =
|
||||
Lazy::new(|| Mutex::new(HashMap::new()));
|
||||
|
||||
// General function to create any stair block with facing and shape properties
|
||||
pub fn create_stair_with_properties(
|
||||
base_stair_block: Block,
|
||||
facing: StairFacing,
|
||||
shape: StairShape,
|
||||
) -> BlockWithProperties {
|
||||
let cache_key = (base_stair_block.id(), facing, shape);
|
||||
|
||||
// Check cache first
|
||||
{
|
||||
let cache = STAIR_CACHE.lock().unwrap();
|
||||
if let Some(cached_block) = cache.get(&cache_key) {
|
||||
return cached_block.clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Create properties
|
||||
let mut map = HashMap::new();
|
||||
map.insert(
|
||||
"facing".to_string(),
|
||||
Value::String(facing.as_str().to_string()),
|
||||
);
|
||||
|
||||
// Only add shape if it's not straight (default)
|
||||
if !matches!(shape, StairShape::Straight) {
|
||||
map.insert(
|
||||
"shape".to_string(),
|
||||
Value::String(shape.as_str().to_string()),
|
||||
);
|
||||
}
|
||||
|
||||
let properties = Value::Compound(map);
|
||||
let block_with_props = BlockWithProperties::new(base_stair_block, Some(properties));
|
||||
|
||||
// Cache the result
|
||||
{
|
||||
let mut cache = STAIR_CACHE.lock().unwrap();
|
||||
cache.insert(cache_key, block_with_props.clone());
|
||||
}
|
||||
|
||||
block_with_props
|
||||
}
|
||||
|
||||
// Lazy static blocks
|
||||
pub const ACACIA_PLANKS: Block = Block::new(0);
|
||||
pub const AIR: Block = Block::new(1);
|
||||
@@ -207,7 +533,7 @@ pub const CAULDRON: Block = Block::new(10);
|
||||
pub const CHISELED_STONE_BRICKS: Block = Block::new(11);
|
||||
pub const COBBLESTONE_WALL: Block = Block::new(12);
|
||||
pub const COBBLESTONE: Block = Block::new(13);
|
||||
pub const CRACKED_POLISHED_BLACKSTONE_BRICKS: Block = Block::new(14);
|
||||
pub const POLISHED_BLACKSTONE_BRICKS: Block = Block::new(14);
|
||||
pub const CRACKED_STONE_BRICKS: Block = Block::new(15);
|
||||
pub const CRIMSON_PLANKS: Block = Block::new(16);
|
||||
pub const CUT_SANDSTONE: Block = Block::new(17);
|
||||
@@ -240,7 +566,7 @@ pub const MOSS_BLOCK: Block = Block::new(43);
|
||||
pub const MOSSY_COBBLESTONE: Block = Block::new(44);
|
||||
pub const MUD_BRICKS: Block = Block::new(45);
|
||||
pub const NETHER_BRICK: Block = Block::new(46);
|
||||
pub const NETHER_BRICKS: Block = Block::new(47);
|
||||
pub const NETHERITE_BLOCK: Block = Block::new(47);
|
||||
pub const OAK_FENCE: Block = Block::new(48);
|
||||
pub const OAK_LEAVES: Block = Block::new(49);
|
||||
pub const OAK_LOG: Block = Block::new(50);
|
||||
@@ -250,7 +576,7 @@ pub const ORANGE_TERRACOTTA: Block = Block::new(53);
|
||||
pub const PODZOL: Block = Block::new(54);
|
||||
pub const POLISHED_ANDESITE: Block = Block::new(55);
|
||||
pub const POLISHED_BASALT: Block = Block::new(56);
|
||||
pub const POLISHED_BLACKSTONE_BRICKS: Block = Block::new(57);
|
||||
pub const QUARTZ_BLOCK: Block = Block::new(57);
|
||||
pub const POLISHED_BLACKSTONE: Block = Block::new(58);
|
||||
pub const POLISHED_DEEPSLATE: Block = Block::new(59);
|
||||
pub const POLISHED_DIORITE: Block = Block::new(60);
|
||||
@@ -261,7 +587,7 @@ pub const PURPUR_PILLAR: Block = Block::new(64);
|
||||
pub const QUARTZ_BRICKS: Block = Block::new(65);
|
||||
pub const RAIL: Block = Block::new(66);
|
||||
pub const RED_FLOWER: Block = Block::new(67);
|
||||
pub const RED_NETHER_BRICKS: Block = Block::new(68);
|
||||
pub const RED_NETHER_BRICK: Block = Block::new(68);
|
||||
pub const RED_TERRACOTTA: Block = Block::new(69);
|
||||
pub const RED_WOOL: Block = Block::new(70);
|
||||
pub const SAND: Block = Block::new(71);
|
||||
@@ -301,105 +627,381 @@ pub const YELLOW_TERRACOTTA: Block = Block::new(104);
|
||||
pub const SNOW_BLOCK: Block = Block::new(111);
|
||||
pub const SNOW_LAYER: Block = Block::new(112);
|
||||
pub const SIGN: Block = Block::new(113);
|
||||
|
||||
pub const ANDESITE_WALL: Block = Block::new(114);
|
||||
pub const STONE_BRICK_WALL: Block = Block::new(115);
|
||||
pub const CARROTS: Block = Block::new(105);
|
||||
pub const DARK_OAK_DOOR_LOWER: Block = Block::new(106);
|
||||
pub const DARK_OAK_DOOR_UPPER: Block = Block::new(107);
|
||||
pub const POTATOES: Block = Block::new(108);
|
||||
pub const WHEAT: Block = Block::new(109);
|
||||
|
||||
pub const BEDROCK: Block = Block::new(110);
|
||||
pub const RAIL_NORTH_SOUTH: Block = Block::new(116);
|
||||
pub const RAIL_EAST_WEST: Block = Block::new(117);
|
||||
pub const RAIL_ASCENDING_EAST: Block = Block::new(118);
|
||||
pub const RAIL_ASCENDING_WEST: Block = Block::new(119);
|
||||
pub const RAIL_ASCENDING_NORTH: Block = Block::new(120);
|
||||
pub const RAIL_ASCENDING_SOUTH: Block = Block::new(121);
|
||||
pub const RAIL_NORTH_EAST: Block = Block::new(122);
|
||||
pub const RAIL_NORTH_WEST: Block = Block::new(123);
|
||||
pub const RAIL_SOUTH_EAST: Block = Block::new(124);
|
||||
pub const RAIL_SOUTH_WEST: Block = Block::new(125);
|
||||
pub const COARSE_DIRT: Block = Block::new(126);
|
||||
pub const IRON_ORE: Block = Block::new(127);
|
||||
pub const COAL_ORE: Block = Block::new(128);
|
||||
pub const GOLD_ORE: Block = Block::new(129);
|
||||
pub const COPPER_ORE: Block = Block::new(130);
|
||||
pub const CLAY: Block = Block::new(131);
|
||||
pub const DIRT_PATH: Block = Block::new(132);
|
||||
pub const ICE: Block = Block::new(133);
|
||||
pub const PACKED_ICE: Block = Block::new(134);
|
||||
pub const MUD: Block = Block::new(135);
|
||||
pub const DEAD_BUSH: Block = Block::new(136);
|
||||
pub const TALL_GRASS_BOTTOM: Block = Block::new(137);
|
||||
pub const TALL_GRASS_TOP: Block = Block::new(138);
|
||||
pub const CRAFTING_TABLE: Block = Block::new(139);
|
||||
pub const FURNACE: Block = Block::new(140);
|
||||
pub const WHITE_CARPET: Block = Block::new(141);
|
||||
pub const BOOKSHELF: Block = Block::new(142);
|
||||
pub const OAK_PRESSURE_PLATE: Block = Block::new(143);
|
||||
pub const OAK_STAIRS: Block = Block::new(144);
|
||||
pub const CHEST: Block = Block::new(155);
|
||||
pub const RED_CARPET: Block = Block::new(156);
|
||||
pub const ANVIL: Block = Block::new(157);
|
||||
pub const JUKEBOX: Block = Block::new(158);
|
||||
pub const OAK_DOOR: Block = Block::new(159);
|
||||
pub const BREWING_STAND: Block = Block::new(160);
|
||||
pub const RED_BED_NORTH_HEAD: Block = Block::new(161);
|
||||
pub const RED_BED_NORTH_FOOT: Block = Block::new(162);
|
||||
pub const RED_BED_EAST_HEAD: Block = Block::new(163);
|
||||
pub const RED_BED_EAST_FOOT: Block = Block::new(164);
|
||||
pub const RED_BED_SOUTH_HEAD: Block = Block::new(165);
|
||||
pub const RED_BED_SOUTH_FOOT: Block = Block::new(166);
|
||||
pub const RED_BED_WEST_HEAD: Block = Block::new(167);
|
||||
pub const RED_BED_WEST_FOOT: Block = Block::new(168);
|
||||
pub const GRAY_STAINED_GLASS: Block = Block::new(169);
|
||||
pub const LIGHT_GRAY_STAINED_GLASS: Block = Block::new(170);
|
||||
pub const BROWN_STAINED_GLASS: Block = Block::new(171);
|
||||
pub const TINTED_GLASS: Block = Block::new(172);
|
||||
pub const OAK_TRAPDOOR: Block = Block::new(173);
|
||||
pub const BROWN_CONCRETE: Block = Block::new(174);
|
||||
pub const BLACK_TERRACOTTA: Block = Block::new(175);
|
||||
pub const BROWN_TERRACOTTA: Block = Block::new(176);
|
||||
pub const STONE_BRICK_STAIRS: Block = Block::new(177);
|
||||
pub const MUD_BRICK_STAIRS: Block = Block::new(178);
|
||||
pub const POLISHED_BLACKSTONE_BRICK_STAIRS: Block = Block::new(179);
|
||||
pub const BRICK_STAIRS: Block = Block::new(180);
|
||||
pub const POLISHED_GRANITE_STAIRS: Block = Block::new(181);
|
||||
pub const END_STONE_BRICK_STAIRS: Block = Block::new(182);
|
||||
pub const POLISHED_DIORITE_STAIRS: Block = Block::new(183);
|
||||
pub const SMOOTH_SANDSTONE_STAIRS: Block = Block::new(184);
|
||||
pub const QUARTZ_STAIRS: Block = Block::new(185);
|
||||
pub const POLISHED_ANDESITE_STAIRS: Block = Block::new(186);
|
||||
pub const NETHER_BRICK_STAIRS: Block = Block::new(187);
|
||||
|
||||
// Variations for building corners
|
||||
pub fn building_corner_variations() -> Vec<Block> {
|
||||
vec![
|
||||
/// Maps a block to its corresponding stair variant
|
||||
#[inline]
|
||||
pub fn get_stair_block_for_material(material: Block) -> Block {
|
||||
match material {
|
||||
STONE_BRICKS => STONE_BRICK_STAIRS,
|
||||
MUD_BRICKS => MUD_BRICK_STAIRS,
|
||||
OAK_PLANKS => OAK_STAIRS,
|
||||
POLISHED_ANDESITE => STONE_BRICK_STAIRS,
|
||||
SMOOTH_STONE => POLISHED_ANDESITE_STAIRS,
|
||||
OAK_PLANKS => OAK_STAIRS,
|
||||
ANDESITE => STONE_BRICK_STAIRS,
|
||||
CHISELED_STONE_BRICKS => STONE_BRICK_STAIRS,
|
||||
BLACK_TERRACOTTA => POLISHED_BLACKSTONE_BRICK_STAIRS,
|
||||
BLACKSTONE => POLISHED_BLACKSTONE_BRICK_STAIRS,
|
||||
BLUE_TERRACOTTA => MUD_BRICK_STAIRS,
|
||||
BRICK => BRICK_STAIRS,
|
||||
BROWN_CONCRETE => MUD_BRICK_STAIRS,
|
||||
BROWN_TERRACOTTA => MUD_BRICK_STAIRS,
|
||||
DEEPSLATE_BRICKS => STONE_BRICK_STAIRS,
|
||||
END_STONE_BRICKS => END_STONE_BRICK_STAIRS,
|
||||
GRAY_CONCRETE => POLISHED_BLACKSTONE_BRICK_STAIRS,
|
||||
GRAY_TERRACOTTA => MUD_BRICK_STAIRS,
|
||||
LIGHT_BLUE_TERRACOTTA => STONE_BRICK_STAIRS,
|
||||
LIGHT_GRAY_CONCRETE => STONE_BRICK_STAIRS,
|
||||
NETHER_BRICK => NETHER_BRICK_STAIRS,
|
||||
POLISHED_BLACKSTONE => POLISHED_BLACKSTONE_BRICK_STAIRS,
|
||||
POLISHED_BLACKSTONE_BRICKS => POLISHED_BLACKSTONE_BRICK_STAIRS,
|
||||
POLISHED_DEEPSLATE => STONE_BRICK_STAIRS,
|
||||
POLISHED_GRANITE => POLISHED_GRANITE_STAIRS,
|
||||
QUARTZ_BLOCK => POLISHED_DIORITE_STAIRS,
|
||||
QUARTZ_BRICKS => POLISHED_DIORITE_STAIRS,
|
||||
SANDSTONE => SMOOTH_SANDSTONE_STAIRS,
|
||||
SMOOTH_SANDSTONE => SMOOTH_SANDSTONE_STAIRS,
|
||||
WHITE_CONCRETE => QUARTZ_STAIRS,
|
||||
WHITE_TERRACOTTA => MUD_BRICK_STAIRS,
|
||||
_ => STONE_BRICK_STAIRS,
|
||||
}
|
||||
}
|
||||
|
||||
// Window variations for different building types
|
||||
pub static WINDOW_VARIATIONS: [Block; 7] = [
|
||||
GLASS,
|
||||
GRAY_STAINED_GLASS,
|
||||
LIGHT_GRAY_STAINED_GLASS,
|
||||
GRAY_STAINED_GLASS,
|
||||
BROWN_STAINED_GLASS,
|
||||
WHITE_STAINED_GLASS,
|
||||
TINTED_GLASS,
|
||||
];
|
||||
|
||||
// Window types for different building styles
|
||||
pub fn get_window_block_for_building_type(building_type: &str) -> Block {
|
||||
use rand::Rng;
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
match building_type {
|
||||
"residential" | "house" | "apartment" => {
|
||||
let residential_windows = [
|
||||
GLASS,
|
||||
WHITE_STAINED_GLASS,
|
||||
LIGHT_GRAY_STAINED_GLASS,
|
||||
BROWN_STAINED_GLASS,
|
||||
];
|
||||
residential_windows[rng.gen_range(0..residential_windows.len())]
|
||||
}
|
||||
"hospital" | "school" | "university" => {
|
||||
let institutional_windows = [GLASS, WHITE_STAINED_GLASS, LIGHT_GRAY_STAINED_GLASS];
|
||||
institutional_windows[rng.gen_range(0..institutional_windows.len())]
|
||||
}
|
||||
"hotel" | "restaurant" => {
|
||||
let hospitality_windows = [GLASS, WHITE_STAINED_GLASS];
|
||||
hospitality_windows[rng.gen_range(0..hospitality_windows.len())]
|
||||
}
|
||||
"industrial" | "warehouse" => {
|
||||
let industrial_windows = [
|
||||
GLASS,
|
||||
GRAY_STAINED_GLASS,
|
||||
LIGHT_GRAY_STAINED_GLASS,
|
||||
BROWN_STAINED_GLASS,
|
||||
];
|
||||
industrial_windows[rng.gen_range(0..industrial_windows.len())]
|
||||
}
|
||||
_ => WINDOW_VARIATIONS[rng.gen_range(0..WINDOW_VARIATIONS.len())],
|
||||
}
|
||||
}
|
||||
|
||||
// Random floor block selection
|
||||
pub fn get_random_floor_block() -> Block {
|
||||
use rand::Rng;
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let floor_options = [
|
||||
WHITE_CONCRETE,
|
||||
GRAY_CONCRETE,
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
POLISHED_ANDESITE,
|
||||
SMOOTH_STONE,
|
||||
STONE_BRICKS,
|
||||
COBBLESTONE,
|
||||
BRICK,
|
||||
MOSSY_COBBLESTONE,
|
||||
SANDSTONE,
|
||||
RED_NETHER_BRICKS,
|
||||
MUD_BRICKS,
|
||||
OAK_PLANKS,
|
||||
];
|
||||
floor_options[rng.gen_range(0..floor_options.len())]
|
||||
}
|
||||
|
||||
// Define all predefined colors with their blocks
|
||||
static DEFINED_COLORS: &[ColorBlockMapping] = &[
|
||||
((233, 107, 57), &[BRICK, NETHER_BRICK]),
|
||||
(
|
||||
(18, 12, 13),
|
||||
&[POLISHED_BLACKSTONE_BRICKS, BLACKSTONE, DEEPSLATE_BRICKS],
|
||||
),
|
||||
((76, 127, 153), &[LIGHT_BLUE_TERRACOTTA]),
|
||||
(
|
||||
(0, 0, 0),
|
||||
&[DEEPSLATE_BRICKS, BLACKSTONE, POLISHED_BLACKSTONE],
|
||||
),
|
||||
(
|
||||
(186, 195, 142),
|
||||
&[
|
||||
END_STONE_BRICKS,
|
||||
SANDSTONE,
|
||||
SMOOTH_SANDSTONE,
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
],
|
||||
),
|
||||
(
|
||||
(57, 41, 35),
|
||||
&[BROWN_TERRACOTTA, BROWN_CONCRETE, MUD_BRICKS, BRICK],
|
||||
),
|
||||
(
|
||||
(112, 108, 138),
|
||||
&[LIGHT_BLUE_TERRACOTTA, GRAY_TERRACOTTA, GRAY_CONCRETE],
|
||||
),
|
||||
(
|
||||
(122, 92, 66),
|
||||
&[MUD_BRICKS, BROWN_TERRACOTTA, SANDSTONE, BRICK],
|
||||
),
|
||||
((24, 13, 14), &[NETHER_BRICK, BLACKSTONE, DEEPSLATE_BRICKS]),
|
||||
(
|
||||
(159, 82, 36),
|
||||
&[
|
||||
BROWN_TERRACOTTA,
|
||||
BRICK,
|
||||
POLISHED_GRANITE,
|
||||
BROWN_CONCRETE,
|
||||
NETHERITE_BLOCK,
|
||||
POLISHED_DEEPSLATE,
|
||||
],
|
||||
),
|
||||
(
|
||||
(128, 128, 128),
|
||||
&[
|
||||
POLISHED_ANDESITE,
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
SMOOTH_STONE,
|
||||
STONE_BRICKS,
|
||||
],
|
||||
),
|
||||
(
|
||||
(174, 173, 174),
|
||||
&[
|
||||
POLISHED_ANDESITE,
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
SMOOTH_STONE,
|
||||
STONE_BRICKS,
|
||||
],
|
||||
),
|
||||
((141, 101, 142), &[STONE_BRICKS, BRICK, MUD_BRICKS]),
|
||||
(
|
||||
(142, 60, 46),
|
||||
&[
|
||||
BLACK_TERRACOTTA,
|
||||
NETHERITE_BLOCK,
|
||||
NETHER_BRICK,
|
||||
POLISHED_GRANITE,
|
||||
POLISHED_DEEPSLATE,
|
||||
BROWN_TERRACOTTA,
|
||||
],
|
||||
),
|
||||
(
|
||||
(153, 83, 28),
|
||||
&[
|
||||
BLACK_TERRACOTTA,
|
||||
POLISHED_GRANITE,
|
||||
BROWN_CONCRETE,
|
||||
BROWN_TERRACOTTA,
|
||||
STONE_BRICKS,
|
||||
],
|
||||
),
|
||||
(
|
||||
(224, 216, 175),
|
||||
&[
|
||||
SMOOTH_SANDSTONE,
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
POLISHED_ANDESITE,
|
||||
SMOOTH_STONE,
|
||||
],
|
||||
),
|
||||
(
|
||||
(188, 182, 179),
|
||||
&[
|
||||
SMOOTH_SANDSTONE,
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
QUARTZ_BRICKS,
|
||||
POLISHED_ANDESITE,
|
||||
SMOOTH_STONE,
|
||||
],
|
||||
),
|
||||
(
|
||||
(35, 86, 85),
|
||||
&[
|
||||
POLISHED_BLACKSTONE_BRICKS,
|
||||
BLUE_TERRACOTTA,
|
||||
LIGHT_BLUE_TERRACOTTA,
|
||||
],
|
||||
),
|
||||
(
|
||||
(255, 255, 255),
|
||||
&[WHITE_CONCRETE, QUARTZ_BRICKS, QUARTZ_BLOCK],
|
||||
),
|
||||
(
|
||||
(209, 177, 161),
|
||||
&[
|
||||
WHITE_TERRACOTTA,
|
||||
SMOOTH_SANDSTONE,
|
||||
SMOOTH_STONE,
|
||||
SANDSTONE,
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
],
|
||||
),
|
||||
((191, 147, 42), &[SMOOTH_SANDSTONE, SANDSTONE, SMOOTH_STONE]),
|
||||
];
|
||||
|
||||
// Function to randomly select building wall block with alternatives
|
||||
pub fn get_building_wall_block_for_color(color: RGBTuple) -> Block {
|
||||
use rand::Rng;
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// Find the closest color match
|
||||
let closest_color = DEFINED_COLORS
|
||||
.iter()
|
||||
.min_by_key(|(defined_color, _)| crate::colors::rgb_distance(&color, defined_color));
|
||||
|
||||
if let Some((_, options)) = closest_color {
|
||||
options[rng.gen_range(0..options.len())]
|
||||
} else {
|
||||
// This should never happen, but fallback just in case
|
||||
get_fallback_building_block()
|
||||
}
|
||||
}
|
||||
|
||||
// Function to get a random fallback building block when no color attribute is specified
|
||||
pub fn get_fallback_building_block() -> Block {
|
||||
use rand::Rng;
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let fallback_options = [
|
||||
BLACKSTONE,
|
||||
SMOOTH_QUARTZ,
|
||||
CHISELED_STONE_BRICKS,
|
||||
POLISHED_BASALT,
|
||||
CUT_SANDSTONE,
|
||||
POLISHED_BLACKSTONE_BRICKS,
|
||||
ANDESITE,
|
||||
GRANITE,
|
||||
DIORITE,
|
||||
CRACKED_STONE_BRICKS,
|
||||
PRISMARINE,
|
||||
BLUE_TERRACOTTA,
|
||||
BLACK_TERRACOTTA,
|
||||
BRICK,
|
||||
BROWN_CONCRETE,
|
||||
BROWN_TERRACOTTA,
|
||||
DEEPSLATE_BRICKS,
|
||||
END_STONE_BRICKS,
|
||||
GRAY_CONCRETE,
|
||||
GRAY_TERRACOTTA,
|
||||
LIGHT_BLUE_TERRACOTTA,
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
MUD_BRICKS,
|
||||
NETHER_BRICK,
|
||||
POLISHED_ANDESITE,
|
||||
POLISHED_BLACKSTONE,
|
||||
POLISHED_BLACKSTONE_BRICKS,
|
||||
POLISHED_DEEPSLATE,
|
||||
POLISHED_GRANITE,
|
||||
QUARTZ_BLOCK,
|
||||
QUARTZ_BRICKS,
|
||||
]
|
||||
SANDSTONE,
|
||||
SMOOTH_SANDSTONE,
|
||||
SMOOTH_STONE,
|
||||
STONE_BRICKS,
|
||||
WHITE_CONCRETE,
|
||||
WHITE_TERRACOTTA,
|
||||
OAK_PLANKS,
|
||||
];
|
||||
fallback_options[rng.gen_range(0..fallback_options.len())]
|
||||
}
|
||||
|
||||
// Variations for building walls
|
||||
pub fn building_wall_variations() -> Vec<Block> {
|
||||
building_wall_color_map()
|
||||
.into_iter()
|
||||
.map(|(_, block)| block)
|
||||
.collect()
|
||||
}
|
||||
// Function to get a random castle wall block
|
||||
pub fn get_castle_wall_block() -> Block {
|
||||
use rand::Rng;
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// https://wiki.openstreetmap.org/wiki/Key:building:colour
|
||||
pub fn building_wall_color_map() -> Vec<(RGBTuple, Block)> {
|
||||
vec![
|
||||
((233, 107, 57), BRICK),
|
||||
((18, 12, 13), CRACKED_POLISHED_BLACKSTONE_BRICKS),
|
||||
((76, 127, 153), CYAN_CONCRETE),
|
||||
((0, 0, 0), DEEPSLATE_BRICKS),
|
||||
((186, 195, 142), END_STONE_BRICKS),
|
||||
((57, 41, 35), GRAY_TERRACOTTA),
|
||||
((112, 108, 138), LIGHT_BLUE_TERRACOTTA),
|
||||
((122, 92, 66), MUD_BRICKS),
|
||||
((24, 13, 14), NETHER_BRICKS),
|
||||
((159, 82, 36), ORANGE_TERRACOTTA),
|
||||
((128, 128, 128), POLISHED_ANDESITE),
|
||||
((174, 173, 174), POLISHED_DIORITE),
|
||||
((141, 101, 142), PURPUR_PILLAR),
|
||||
((142, 60, 46), RED_TERRACOTTA),
|
||||
((153, 83, 28), SMOOTH_RED_SANDSTONE),
|
||||
((224, 216, 175), SMOOTH_SANDSTONE),
|
||||
((188, 182, 179), SMOOTH_STONE),
|
||||
((35, 86, 85), WARPED_PLANKS),
|
||||
((255, 255, 255), WHITE_CONCRETE),
|
||||
((209, 177, 161), WHITE_TERRACOTTA),
|
||||
((191, 147, 42), YELLOW_TERRACOTTA),
|
||||
]
|
||||
}
|
||||
|
||||
// Variations for building floors
|
||||
pub fn building_floor_variations() -> Vec<Block> {
|
||||
building_wall_color_map()
|
||||
.into_iter()
|
||||
.map(|(_, block)| block)
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn building_floor_color_map() -> Vec<(RGBTuple, Block)> {
|
||||
vec![
|
||||
((181, 101, 59), ACACIA_PLANKS),
|
||||
((22, 15, 16), BLACKSTONE),
|
||||
((104, 51, 74), CRIMSON_PLANKS),
|
||||
((82, 55, 26), DARK_OAK_PLANKS),
|
||||
((182, 133, 99), JUNGLE_PLANKS),
|
||||
((33, 128, 185), LIGHT_BLUE_CONCRETE),
|
||||
((78, 103, 43), MOSS_BLOCK),
|
||||
((171, 138, 88), OAK_PLANKS),
|
||||
((0, 128, 0), OXIDIZED_COPPER),
|
||||
((18, 12, 13), POLISHED_BLACKSTONE),
|
||||
((64, 64, 64), POLISHED_DEEPSLATE),
|
||||
((255, 255, 255), POLISHED_DIORITE),
|
||||
((143, 96, 79), POLISHED_GRANITE),
|
||||
((141, 101, 142), PURPUR_BLOCK),
|
||||
((128, 0, 0), RED_NETHER_BRICKS),
|
||||
((153, 83, 28), SMOOTH_RED_SANDSTONE),
|
||||
((128, 96, 57), SPRUCE_PLANKS),
|
||||
((128, 128, 128), STONE_BRICKS),
|
||||
((150, 93, 68), TERRACOTTA),
|
||||
((35, 86, 85), WARPED_PLANKS),
|
||||
]
|
||||
let castle_wall_options = [
|
||||
STONE_BRICKS,
|
||||
CHISELED_STONE_BRICKS,
|
||||
CRACKED_STONE_BRICKS,
|
||||
COBBLESTONE,
|
||||
MOSSY_COBBLESTONE,
|
||||
DEEPSLATE_BRICKS,
|
||||
POLISHED_ANDESITE,
|
||||
ANDESITE,
|
||||
SMOOTH_STONE,
|
||||
BRICK,
|
||||
];
|
||||
castle_wall_options[rng.gen_range(0..castle_wall_options.len())]
|
||||
}
|
||||
|
||||
@@ -8,26 +8,32 @@ pub fn bresenham_line(
|
||||
y2: i32,
|
||||
z2: i32,
|
||||
) -> Vec<(i32, i32, i32)> {
|
||||
let mut points: Vec<(i32, i32, i32)> = Vec::new();
|
||||
// Calculate max possible points needed
|
||||
let dx = if x2 > x1 { x2 - x1 } else { x1 - x2 };
|
||||
let dy = if y2 > y1 { y2 - y1 } else { y1 - y2 };
|
||||
let dz = if z2 > z1 { z2 - z1 } else { z1 - z2 };
|
||||
|
||||
let dx: i32 = (x2 - x1).abs();
|
||||
let dy: i32 = (y2 - y1).abs();
|
||||
let dz: i32 = (z2 - z1).abs();
|
||||
// Pre-allocate vector with exact size needed
|
||||
let capacity = dx.max(dy).max(dz) + 1;
|
||||
let mut points = Vec::with_capacity(capacity as usize);
|
||||
points.reserve_exact(capacity as usize);
|
||||
|
||||
let xs: i32 = if x1 < x2 { 1 } else { -1 };
|
||||
let ys: i32 = if y1 < y2 { 1 } else { -1 };
|
||||
let zs: i32 = if z1 < z2 { 1 } else { -1 };
|
||||
let xs = if x1 < x2 { 1 } else { -1 };
|
||||
let ys = if y1 < y2 { 1 } else { -1 };
|
||||
let zs = if z1 < z2 { 1 } else { -1 };
|
||||
|
||||
let mut x: i32 = x1;
|
||||
let mut y: i32 = y1;
|
||||
let mut z: i32 = z1;
|
||||
let mut x = x1;
|
||||
let mut y = y1;
|
||||
let mut z = z1;
|
||||
|
||||
// Determine dominant axis once, outside the loop
|
||||
if dx >= dy && dx >= dz {
|
||||
let mut p1: i32 = 2 * dy - dx;
|
||||
let mut p2: i32 = 2 * dz - dx;
|
||||
let mut p1 = 2 * dy - dx;
|
||||
let mut p2 = 2 * dz - dx;
|
||||
|
||||
while x != x2 {
|
||||
points.push((x, y, z));
|
||||
|
||||
if p1 >= 0 {
|
||||
y += ys;
|
||||
p1 -= 2 * dx;
|
||||
@@ -41,11 +47,12 @@ pub fn bresenham_line(
|
||||
x += xs;
|
||||
}
|
||||
} else if dy >= dx && dy >= dz {
|
||||
let mut p1: i32 = 2 * dx - dy;
|
||||
let mut p2: i32 = 2 * dz - dy;
|
||||
let mut p1 = 2 * dx - dy;
|
||||
let mut p2 = 2 * dz - dy;
|
||||
|
||||
while y != y2 {
|
||||
points.push((x, y, z));
|
||||
|
||||
if p1 >= 0 {
|
||||
x += xs;
|
||||
p1 -= 2 * dy;
|
||||
@@ -59,11 +66,12 @@ pub fn bresenham_line(
|
||||
y += ys;
|
||||
}
|
||||
} else {
|
||||
let mut p1: i32 = 2 * dy - dz;
|
||||
let mut p2: i32 = 2 * dx - dz;
|
||||
let mut p1 = 2 * dy - dz;
|
||||
let mut p2 = 2 * dx - dz;
|
||||
|
||||
while z != z2 {
|
||||
points.push((x, y, z));
|
||||
|
||||
if p1 >= 0 {
|
||||
y += ys;
|
||||
p1 -= 2 * dz;
|
||||
|
||||
@@ -32,16 +32,16 @@ fn full_hex_color_to_rgb_tuple(text: &str) -> Option<RGBTuple> {
|
||||
fn short_hex_color_to_rgb_tuple(text: &str) -> Option<RGBTuple> {
|
||||
if text.len() != 4
|
||||
|| !text.starts_with("#")
|
||||
|| text.chars().skip(1).all(|c: char| c.is_ascii_hexdigit())
|
||||
|| !text.chars().skip(1).all(|c: char| c.is_ascii_hexdigit())
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let r: u8 = u8::from_str_radix(&text[1..2], 16).unwrap();
|
||||
let r: u8 = r | r << 4;
|
||||
let r: u8 = r | (r << 4);
|
||||
let g: u8 = u8::from_str_radix(&text[2..3], 16).unwrap();
|
||||
let g: u8 = g | g << 4;
|
||||
let g: u8 = g | (g << 4);
|
||||
let b: u8 = u8::from_str_radix(&text[3..4], 16).unwrap();
|
||||
let b: u8 = b | b << 4;
|
||||
let b: u8 = b | (b << 4);
|
||||
Some((r, g, b))
|
||||
}
|
||||
|
||||
|
||||
7
src/coordinate_system/cartesian/mod.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
mod xzbbox;
|
||||
mod xzpoint;
|
||||
mod xzvector;
|
||||
|
||||
pub use xzbbox::XZBBox;
|
||||
pub use xzpoint::XZPoint;
|
||||
pub use xzvector::XZVector;
|
||||
4
src/coordinate_system/cartesian/xzbbox/mod.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
mod rectangle;
|
||||
mod xzbbox_enum;
|
||||
|
||||
pub use xzbbox_enum::XZBBox;
|
||||
112
src/coordinate_system/cartesian/xzbbox/rectangle.rs
Normal file
@@ -0,0 +1,112 @@
|
||||
use crate::coordinate_system::cartesian::{XZPoint, XZVector};
|
||||
use std::fmt;
|
||||
use std::ops::{Add, AddAssign, Sub, SubAssign};
|
||||
|
||||
/// An underlying shape of XZBBox enum.
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub struct XZBBoxRect {
|
||||
/// The "bottom-left" vertex of the rectangle
|
||||
min: XZPoint,
|
||||
|
||||
/// The "top-right" vertex of the rectangle
|
||||
max: XZPoint,
|
||||
}
|
||||
|
||||
impl XZBBoxRect {
|
||||
pub fn new(min: XZPoint, max: XZPoint) -> Result<Self, String> {
|
||||
let blockx_ge_1 = max.x - min.x >= 0;
|
||||
let blockz_ge_1 = max.z - min.z >= 0;
|
||||
|
||||
if !blockx_ge_1 {
|
||||
return Err(format!(
|
||||
"Invalid XZBBox::Rect: max.x should >= min.x, but encountered {} -> {}",
|
||||
min.x, max.x
|
||||
));
|
||||
}
|
||||
|
||||
if !blockz_ge_1 {
|
||||
return Err(format!(
|
||||
"Invalid XZBBox::Rect: max.z should >= min.z, but encountered {} -> {}",
|
||||
min.z, max.z
|
||||
));
|
||||
}
|
||||
|
||||
Ok(Self { min, max })
|
||||
}
|
||||
|
||||
pub fn min(&self) -> XZPoint {
|
||||
self.min
|
||||
}
|
||||
|
||||
pub fn max(&self) -> XZPoint {
|
||||
self.max
|
||||
}
|
||||
|
||||
/// Total number of blocks covered in this 2D bbox
|
||||
pub fn total_blocks(&self) -> u64 {
|
||||
(self.total_blocks_x() as u64) * (self.total_blocks_z() as u64)
|
||||
}
|
||||
|
||||
/// Total number of blocks covered in x direction
|
||||
pub fn total_blocks_x(&self) -> u32 {
|
||||
let nx = self.max.x - self.min.x + 1;
|
||||
nx as u32
|
||||
}
|
||||
|
||||
/// Total number of blocks covered in z direction
|
||||
pub fn total_blocks_z(&self) -> u32 {
|
||||
let nz = self.max.z - self.min.z + 1;
|
||||
nz as u32
|
||||
}
|
||||
|
||||
/// Check whether an XZPoint is covered
|
||||
pub fn contains(&self, xzpoint: &XZPoint) -> bool {
|
||||
xzpoint.x >= self.min.x
|
||||
&& xzpoint.x <= self.max.x
|
||||
&& xzpoint.z >= self.min.z
|
||||
&& xzpoint.z <= self.max.z
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for XZBBoxRect {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "Rect({} -> {})", self.min, self.max)
|
||||
}
|
||||
}
|
||||
|
||||
// below are associated +- operators
|
||||
impl Add<XZVector> for XZBBoxRect {
|
||||
type Output = XZBBoxRect;
|
||||
|
||||
fn add(self, other: XZVector) -> Self {
|
||||
Self {
|
||||
min: self.min + other,
|
||||
max: self.max + other,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign<XZVector> for XZBBoxRect {
|
||||
fn add_assign(&mut self, other: XZVector) {
|
||||
self.min += other;
|
||||
self.max += other;
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<XZVector> for XZBBoxRect {
|
||||
type Output = XZBBoxRect;
|
||||
|
||||
fn sub(self, other: XZVector) -> Self {
|
||||
Self {
|
||||
min: self.min - other,
|
||||
max: self.max - other,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign<XZVector> for XZBBoxRect {
|
||||
fn sub_assign(&mut self, other: XZVector) {
|
||||
self.min -= other;
|
||||
self.max -= other;
|
||||
}
|
||||
}
|
||||
202
src/coordinate_system/cartesian/xzbbox/xzbbox_enum.rs
Normal file
@@ -0,0 +1,202 @@
|
||||
use super::rectangle::XZBBoxRect;
|
||||
use crate::coordinate_system::cartesian::{XZPoint, XZVector};
|
||||
use std::fmt;
|
||||
use std::ops::{Add, AddAssign, Sub, SubAssign};
|
||||
|
||||
/// Bounding Box in minecraft XZ space with varied shapes.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum XZBBox {
|
||||
Rect(XZBBoxRect),
|
||||
}
|
||||
|
||||
impl XZBBox {
|
||||
/// Construct rectangle shape bbox from the x and z lengths of the world, originated at (0, 0)
|
||||
pub fn rect_from_xz_lengths(length_x: f64, length_z: f64) -> Result<Self, String> {
|
||||
let lenx_ge_0 = length_x >= 0.0;
|
||||
let lenz_ge_0 = length_z >= 0.0;
|
||||
let lenx_overflow = length_x > i32::MAX as f64;
|
||||
let lenz_overflow = length_z > i32::MAX as f64;
|
||||
|
||||
if !lenx_ge_0 {
|
||||
return Err(format!(
|
||||
"Invalid XZBBox::Rect from xz lengths: length x should >=0 , but encountered {length_x}"
|
||||
));
|
||||
}
|
||||
|
||||
if !lenz_ge_0 {
|
||||
return Err(format!(
|
||||
"Invalid XZBBox::Rect from xz lengths: length z should >=0 , but encountered {length_x}"
|
||||
));
|
||||
}
|
||||
|
||||
if lenx_overflow {
|
||||
return Err(format!(
|
||||
"Invalid XZBBox::Rect from xz lengths: length x too large for i32: {length_x}"
|
||||
));
|
||||
}
|
||||
|
||||
if lenz_overflow {
|
||||
return Err(format!(
|
||||
"Invalid XZBBox::Rect from xz lengths: length z too large for i32: {length_z}"
|
||||
));
|
||||
}
|
||||
|
||||
Ok(Self::Rect(XZBBoxRect::new(
|
||||
XZPoint { x: 0, z: 0 },
|
||||
XZPoint {
|
||||
x: length_x as i32,
|
||||
z: length_z as i32,
|
||||
},
|
||||
)?))
|
||||
}
|
||||
|
||||
/// Check whether an XZPoint is covered
|
||||
pub fn contains(&self, xzpoint: &XZPoint) -> bool {
|
||||
match self {
|
||||
Self::Rect(r) => r.contains(xzpoint),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the circumscribed rectangle of the current XZBBox shape
|
||||
pub fn bounding_rect(&self) -> XZBBoxRect {
|
||||
match self {
|
||||
Self::Rect(r) => *r,
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the min x in all covered blocks
|
||||
pub fn min_x(&self) -> i32 {
|
||||
self.bounding_rect().min().x
|
||||
}
|
||||
|
||||
/// Return the max x in all covered blocks
|
||||
pub fn max_x(&self) -> i32 {
|
||||
self.bounding_rect().max().x
|
||||
}
|
||||
|
||||
/// Return the min z in all covered blocks
|
||||
pub fn min_z(&self) -> i32 {
|
||||
self.bounding_rect().min().z
|
||||
}
|
||||
|
||||
/// Return the max z in all covered blocks
|
||||
pub fn max_z(&self) -> i32 {
|
||||
self.bounding_rect().max().z
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for XZBBox {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Rect(r) => write!(f, "XZBBox::{r}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// below are associated +- operators
|
||||
impl Add<XZVector> for XZBBox {
|
||||
type Output = XZBBox;
|
||||
|
||||
fn add(self, other: XZVector) -> XZBBox {
|
||||
match self {
|
||||
Self::Rect(r) => Self::Rect(r + other),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign<XZVector> for XZBBox {
|
||||
fn add_assign(&mut self, other: XZVector) {
|
||||
match self {
|
||||
Self::Rect(r) => *r += other,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<XZVector> for XZBBox {
|
||||
type Output = XZBBox;
|
||||
|
||||
fn sub(self, other: XZVector) -> XZBBox {
|
||||
match self {
|
||||
Self::Rect(r) => Self::Rect(r - other),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign<XZVector> for XZBBox {
|
||||
fn sub_assign(&mut self, other: XZVector) {
|
||||
match self {
|
||||
Self::Rect(r) => *r -= other,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_valid_inputs() {
|
||||
// 2 * 2
|
||||
let obj = XZBBox::rect_from_xz_lengths(1.0, 1.0);
|
||||
assert!(obj.is_ok());
|
||||
let obj = obj.unwrap();
|
||||
assert_eq!(obj.bounding_rect().total_blocks_x(), 2);
|
||||
assert_eq!(obj.bounding_rect().total_blocks_z(), 2);
|
||||
assert_eq!(obj.bounding_rect().total_blocks(), 4);
|
||||
assert_eq!(obj.min_x(), 0);
|
||||
assert_eq!(obj.max_x(), 1);
|
||||
assert_eq!(obj.min_z(), 0);
|
||||
assert_eq!(obj.max_z(), 1);
|
||||
|
||||
// edge cases
|
||||
// 1 * 2
|
||||
let obj = XZBBox::rect_from_xz_lengths(0.0, 1.0);
|
||||
assert!(obj.is_ok());
|
||||
let obj = obj.unwrap();
|
||||
assert_eq!(obj.bounding_rect().total_blocks_x(), 1);
|
||||
assert_eq!(obj.bounding_rect().total_blocks_z(), 2);
|
||||
assert_eq!(obj.bounding_rect().total_blocks(), 2);
|
||||
assert_eq!(obj.min_x(), 0);
|
||||
assert_eq!(obj.max_x(), 0);
|
||||
assert_eq!(obj.min_z(), 0);
|
||||
assert_eq!(obj.max_z(), 1);
|
||||
|
||||
// 2 * 1
|
||||
let obj = XZBBox::rect_from_xz_lengths(1.0, 0.0);
|
||||
assert!(obj.is_ok());
|
||||
let obj = obj.unwrap();
|
||||
assert_eq!(obj.bounding_rect().total_blocks_x(), 2);
|
||||
assert_eq!(obj.bounding_rect().total_blocks_z(), 1);
|
||||
assert_eq!(obj.bounding_rect().total_blocks(), 2);
|
||||
assert_eq!(obj.min_x(), 0);
|
||||
assert_eq!(obj.max_x(), 1);
|
||||
assert_eq!(obj.min_z(), 0);
|
||||
assert_eq!(obj.max_z(), 0);
|
||||
|
||||
// normal case
|
||||
let obj = XZBBox::rect_from_xz_lengths(123.4, 322.5);
|
||||
assert!(obj.is_ok());
|
||||
let obj = obj.unwrap();
|
||||
assert_eq!(obj.bounding_rect().total_blocks_x(), 124);
|
||||
assert_eq!(obj.bounding_rect().total_blocks_z(), 323);
|
||||
assert_eq!(obj.bounding_rect().total_blocks(), 124 * 323);
|
||||
assert_eq!(obj.min_x(), 0);
|
||||
assert_eq!(obj.max_x(), 123);
|
||||
assert_eq!(obj.min_z(), 0);
|
||||
assert_eq!(obj.max_z(), 322);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::excessive_precision)]
|
||||
fn test_invalid_inputs() {
|
||||
assert!(XZBBox::rect_from_xz_lengths(-1.0, 1.5).is_err());
|
||||
assert!(XZBBox::rect_from_xz_lengths(1323.5, -3287238791.395).is_err());
|
||||
assert!(XZBBox::rect_from_xz_lengths(-239928341323.29389498, -3287238791.938395).is_err());
|
||||
assert!(XZBBox::rect_from_xz_lengths(-0.1, 1.5).is_err());
|
||||
assert!(XZBBox::rect_from_xz_lengths(-0.5, 1.5).is_err());
|
||||
assert!(XZBBox::rect_from_xz_lengths(123948761293874123.2398, -0.5).is_err());
|
||||
|
||||
assert!(XZBBox::rect_from_xz_lengths(i32::MAX as f64 + 10.0, -0.5).is_err());
|
||||
assert!(XZBBox::rect_from_xz_lengths(0.2, i32::MAX as f64 + 10.0).is_err());
|
||||
}
|
||||
}
|
||||
70
src/coordinate_system/cartesian/xzpoint.rs
Normal file
@@ -0,0 +1,70 @@
|
||||
use super::xzvector::XZVector;
|
||||
use serde::Deserialize;
|
||||
use std::fmt;
|
||||
use std::ops::{Add, AddAssign, Sub, SubAssign};
|
||||
|
||||
#[derive(Debug, Deserialize, Copy, Clone, PartialEq)]
|
||||
pub struct XZPoint {
|
||||
pub x: i32,
|
||||
pub z: i32,
|
||||
}
|
||||
|
||||
impl XZPoint {
|
||||
pub fn new(x: i32, z: i32) -> Self {
|
||||
Self { x, z }
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for XZPoint {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "XZPoint({}, {})", self.x, self.z)
|
||||
}
|
||||
}
|
||||
|
||||
// below are associated +- operators
|
||||
impl Add<XZVector> for XZPoint {
|
||||
type Output = XZPoint;
|
||||
|
||||
fn add(self, other: XZVector) -> XZPoint {
|
||||
XZPoint {
|
||||
x: self.x + other.dx,
|
||||
z: self.z + other.dz,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign<XZVector> for XZPoint {
|
||||
fn add_assign(&mut self, other: XZVector) {
|
||||
self.x += other.dx;
|
||||
self.z += other.dz;
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub for XZPoint {
|
||||
type Output = XZVector;
|
||||
|
||||
fn sub(self, other: XZPoint) -> XZVector {
|
||||
XZVector {
|
||||
dx: self.x - other.x,
|
||||
dz: self.z - other.z,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<XZVector> for XZPoint {
|
||||
type Output = XZPoint;
|
||||
|
||||
fn sub(self, other: XZVector) -> XZPoint {
|
||||
XZPoint {
|
||||
x: self.x - other.dx,
|
||||
z: self.z - other.dz,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign<XZVector> for XZPoint {
|
||||
fn sub_assign(&mut self, other: XZVector) {
|
||||
self.x -= other.dx;
|
||||
self.z -= other.dz;
|
||||
}
|
||||
}
|
||||
56
src/coordinate_system/cartesian/xzvector.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
use serde::Deserialize;
|
||||
use std::fmt;
|
||||
use std::ops::{Add, AddAssign, Sub, SubAssign};
|
||||
|
||||
/// Vector between two points in minecraft xz space.
|
||||
#[derive(Debug, Deserialize, Copy, Clone, PartialEq)]
|
||||
pub struct XZVector {
|
||||
/// Increment in x direction
|
||||
pub dx: i32,
|
||||
|
||||
/// Increment in z direction
|
||||
pub dz: i32,
|
||||
}
|
||||
|
||||
impl fmt::Display for XZVector {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "XZVector({}, {})", self.dx, self.dz)
|
||||
}
|
||||
}
|
||||
|
||||
// below are associated +- operators
|
||||
impl Add for XZVector {
|
||||
type Output = XZVector;
|
||||
|
||||
fn add(self, other: XZVector) -> XZVector {
|
||||
XZVector {
|
||||
dx: self.dx + other.dx,
|
||||
dz: self.dz + other.dz,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign for XZVector {
|
||||
fn add_assign(&mut self, other: XZVector) {
|
||||
self.dx += other.dx;
|
||||
self.dz += other.dz;
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub for XZVector {
|
||||
type Output = XZVector;
|
||||
|
||||
fn sub(self, other: XZVector) -> XZVector {
|
||||
XZVector {
|
||||
dx: self.dx - other.dx,
|
||||
dz: self.dz - other.dz,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign for XZVector {
|
||||
fn sub_assign(&mut self, other: XZVector) {
|
||||
self.dx -= other.dx;
|
||||
self.dz -= other.dz;
|
||||
}
|
||||
}
|
||||
125
src/coordinate_system/geographic/llbbox.rs
Normal file
@@ -0,0 +1,125 @@
|
||||
use super::llpoint::LLPoint;
|
||||
|
||||
/// A checked Bounding Box.
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub struct LLBBox {
|
||||
/// The "bottom-left" vertex of the rectangle
|
||||
min: LLPoint,
|
||||
|
||||
/// The "top-right" vertex of the rectangle
|
||||
max: LLPoint,
|
||||
}
|
||||
|
||||
impl LLBBox {
|
||||
pub fn new(min_lat: f64, min_lng: f64, max_lat: f64, max_lng: f64) -> Result<Self, String> {
|
||||
if min_lng >= max_lng {
|
||||
return Err(format!(
|
||||
"Invalid LLBBox: min_lng {min_lng} >= max_lng {max_lng}"
|
||||
));
|
||||
}
|
||||
if min_lat >= max_lat {
|
||||
return Err(format!(
|
||||
"Invalid LLBBox: min_lat {min_lat} >= max_lat {max_lat}"
|
||||
));
|
||||
}
|
||||
|
||||
let min = LLPoint::new(min_lat, min_lng)?;
|
||||
let max = LLPoint::new(max_lat, max_lng)?;
|
||||
|
||||
Ok(Self { min, max })
|
||||
}
|
||||
|
||||
pub fn from_str(s: &str) -> Result<Self, String> {
|
||||
let [min_lat, min_lng, max_lat, max_lng]: [f64; 4] = s
|
||||
.split([',', ' '])
|
||||
.map(|e| e.parse().unwrap())
|
||||
.collect::<Vec<_>>()
|
||||
.try_into()
|
||||
.unwrap();
|
||||
|
||||
// So, the GUI does Lat/Lng and no GDAL (comma-sep values), which is the exact opposite of
|
||||
// what bboxfinder.com does. :facepalm: (bboxfinder is wrong here: Lat comes first!)
|
||||
// DO NOT MODIFY THIS! It's correct. The CLI/GUI is passing you the numbers incorrectly.
|
||||
Self::new(min_lat, min_lng, max_lat, max_lng)
|
||||
}
|
||||
|
||||
pub fn min(&self) -> LLPoint {
|
||||
self.min
|
||||
}
|
||||
|
||||
pub fn max(&self) -> LLPoint {
|
||||
self.max
|
||||
}
|
||||
|
||||
pub fn contains(&self, llpoint: &LLPoint) -> bool {
|
||||
llpoint.lat() >= self.min().lat()
|
||||
&& llpoint.lat() <= self.max().lat()
|
||||
&& llpoint.lng() >= self.min().lng()
|
||||
&& llpoint.lng() <= self.max().lng()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_valid_input() {
|
||||
assert!(LLBBox::new(0., 0., 1., 1.).is_ok());
|
||||
|
||||
assert!(LLBBox::new(1., 2., 3., 4.).is_ok());
|
||||
|
||||
// Arnis, Germany
|
||||
assert!(LLBBox::new(54.627053, 9.927928, 54.634902, 9.937563).is_ok());
|
||||
|
||||
// Royal Observatory Greenwich, London, UK
|
||||
assert!(LLBBox::new(51.470000, -0.015000, 51.480000, 0.015000).is_ok());
|
||||
|
||||
// The Bund, Shanghai, China
|
||||
assert!(LLBBox::new(31.23256, 121.46768, 31.24993, 121.50394).is_ok());
|
||||
|
||||
// Santa Monica, Los Angeles, US
|
||||
assert!(LLBBox::new(34.00348, -118.51226, 34.02033, -118.47600).is_ok());
|
||||
|
||||
// Sydney Opera House, Sydney, Australia
|
||||
assert!(LLBBox::new(-33.861035, 151.204137, -33.852597, 151.222268).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_str_commas() {
|
||||
const ARNIS_STR: &str = "9.927928,54.627053,9.937563,54.634902";
|
||||
|
||||
let bbox_result = LLBBox::from_str(ARNIS_STR);
|
||||
assert!(bbox_result.is_ok());
|
||||
|
||||
let arnis_correct: LLBBox = LLBBox {
|
||||
min: LLPoint::new(9.927928, 54.627053).unwrap(),
|
||||
max: LLPoint::new(9.937563, 54.634902).unwrap(),
|
||||
};
|
||||
|
||||
assert_eq!(bbox_result.unwrap(), arnis_correct);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_str_spaces() {
|
||||
const ARNIS_SPACE_STR: &str = "9.927928 54.627053 9.937563 54.634902";
|
||||
|
||||
let bbox_result = LLBBox::from_str(ARNIS_SPACE_STR);
|
||||
assert!(bbox_result.is_ok());
|
||||
|
||||
let arnis_correct: LLBBox = LLBBox {
|
||||
min: LLPoint::new(9.927928, 54.627053).unwrap(),
|
||||
max: LLPoint::new(9.937563, 54.634902).unwrap(),
|
||||
};
|
||||
|
||||
assert_eq!(bbox_result.unwrap(), arnis_correct);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_out_of_order() {
|
||||
// Violates values in vals_in_order
|
||||
assert!(LLBBox::new(0., 0., 0., 0.).is_err());
|
||||
assert!(LLBBox::new(1., 0., 0., 1.).is_err());
|
||||
assert!(LLBBox::new(0., 1., 1., 0.).is_err());
|
||||
}
|
||||
}
|
||||
60
src/coordinate_system/geographic/llpoint.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
/// Bounds-checked longitude and latitude.
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub struct LLPoint {
|
||||
lat: f64,
|
||||
lng: f64,
|
||||
}
|
||||
|
||||
impl LLPoint {
|
||||
pub fn new(lat: f64, lng: f64) -> Result<Self, String> {
|
||||
let lat_in_range = (-90.0..=90.0).contains(&lat);
|
||||
let lng_in_range = (-180.0..=180.0).contains(&lng);
|
||||
|
||||
if !lat_in_range {
|
||||
return Err(format!("Latitude {lat} not in range -90.0..=90.0"));
|
||||
}
|
||||
|
||||
if !lng_in_range {
|
||||
return Err(format!("Longitude {lng} not in range -180.0..=180.0"));
|
||||
}
|
||||
|
||||
Ok(Self { lat, lng })
|
||||
}
|
||||
|
||||
pub fn lat(&self) -> f64 {
|
||||
self.lat
|
||||
}
|
||||
|
||||
pub fn lng(&self) -> f64 {
|
||||
self.lng
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_valid_input() {
|
||||
assert!(LLPoint::new(0., 0.).is_ok());
|
||||
|
||||
// latitude extremes
|
||||
assert!(LLPoint::new(-90.0, 0.).is_ok());
|
||||
assert!(LLPoint::new(90.0, 0.).is_ok());
|
||||
|
||||
// longitude extremes
|
||||
assert!(LLPoint::new(0., -180.0).is_ok());
|
||||
assert!(LLPoint::new(0., 180.0).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_out_of_bounds() {
|
||||
// latitude out-of-bounds
|
||||
assert!(LLPoint::new(-91., 0.).is_err());
|
||||
assert!(LLPoint::new(91., 0.).is_err());
|
||||
|
||||
// longitude out-of-bounds
|
||||
assert!(LLPoint::new(0., -181.).is_err());
|
||||
assert!(LLPoint::new(0., 181.).is_err());
|
||||
}
|
||||
}
|
||||
5
src/coordinate_system/geographic/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
mod llbbox;
|
||||
mod llpoint;
|
||||
|
||||
pub use llbbox::LLBBox;
|
||||
pub use llpoint::LLPoint;
|
||||
3
src/coordinate_system/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub mod cartesian;
|
||||
pub mod geographic;
|
||||
pub mod transformation;
|
||||
185
src/coordinate_system/transformation.rs
Normal file
@@ -0,0 +1,185 @@
|
||||
use super::cartesian::{XZBBox, XZPoint};
|
||||
use super::geographic::{LLBBox, LLPoint};
|
||||
|
||||
/// Transform geographic space (within llbbox) to a local tangential cartesian space (within xzbbox)
|
||||
pub struct CoordTransformer {
|
||||
len_lat: f64,
|
||||
len_lng: f64,
|
||||
scale_factor_x: f64,
|
||||
scale_factor_z: f64,
|
||||
min_lat: f64,
|
||||
min_lng: f64,
|
||||
}
|
||||
|
||||
impl CoordTransformer {
|
||||
pub fn scale_factor_x(&self) -> f64 {
|
||||
self.scale_factor_x
|
||||
}
|
||||
|
||||
pub fn scale_factor_z(&self) -> f64 {
|
||||
self.scale_factor_z
|
||||
}
|
||||
|
||||
pub fn llbbox_to_xzbbox(
|
||||
llbbox: &LLBBox,
|
||||
scale: f64,
|
||||
) -> Result<(CoordTransformer, XZBBox), String> {
|
||||
let err_header = "Construct LLBBox to XZBBox transformation failed".to_string();
|
||||
|
||||
if scale <= 0.0 {
|
||||
return Err(format!("{}: scale <= 0.0", &err_header));
|
||||
}
|
||||
|
||||
let (scale_factor_z, scale_factor_x) = geo_distance(llbbox.min(), llbbox.max());
|
||||
let scale_factor_z: f64 = scale_factor_z.floor() * scale;
|
||||
let scale_factor_x: f64 = scale_factor_x.floor() * scale;
|
||||
|
||||
let xzbbox = XZBBox::rect_from_xz_lengths(scale_factor_x, scale_factor_z)
|
||||
.map_err(|e| format!("{}:\n{}", &err_header, e))?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
len_lat: llbbox.max().lat() - llbbox.min().lat(),
|
||||
len_lng: llbbox.max().lng() - llbbox.min().lng(),
|
||||
scale_factor_x,
|
||||
scale_factor_z,
|
||||
min_lat: llbbox.min().lat(),
|
||||
min_lng: llbbox.min().lng(),
|
||||
},
|
||||
xzbbox,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn transform_point(&self, llpoint: LLPoint) -> XZPoint {
|
||||
// Calculate the relative position within the bounding box
|
||||
let rel_x: f64 = (llpoint.lng() - self.min_lng) / self.len_lng;
|
||||
let rel_z: f64 = 1.0 - (llpoint.lat() - self.min_lat) / self.len_lat;
|
||||
|
||||
// Apply scaling factors for each dimension and convert to Minecraft coordinates
|
||||
let x: i32 = (rel_x * self.scale_factor_x) as i32;
|
||||
let z: i32 = (rel_z * self.scale_factor_z) as i32;
|
||||
|
||||
XZPoint::new(x, z)
|
||||
}
|
||||
}
|
||||
|
||||
// (lat meters, lon meters)
|
||||
#[inline]
|
||||
pub fn geo_distance(a: LLPoint, b: LLPoint) -> (f64, f64) {
|
||||
let z: f64 = lat_distance(a.lat(), b.lat());
|
||||
|
||||
// distance between two lons depends on their latitude. In this case we'll just average them
|
||||
let x: f64 = lon_distance((a.lat() + b.lat()) / 2.0, a.lng(), b.lng());
|
||||
|
||||
(z, x)
|
||||
}
|
||||
|
||||
// Haversine but optimized for a latitude delta of 0
|
||||
// returns meters
|
||||
fn lon_distance(lat: f64, lon1: f64, lon2: f64) -> f64 {
|
||||
const R: f64 = 6_371_000.0;
|
||||
let d_lon: f64 = (lon2 - lon1).to_radians();
|
||||
let a: f64 =
|
||||
lat.to_radians().cos() * lat.to_radians().cos() * (d_lon / 2.0).sin() * (d_lon / 2.0).sin();
|
||||
let c: f64 = 2.0 * a.sqrt().atan2((1.0 - a).sqrt());
|
||||
|
||||
R * c
|
||||
}
|
||||
|
||||
// Haversine but optimized for a longitude delta of 0
|
||||
// returns meters
|
||||
fn lat_distance(lat1: f64, lat2: f64) -> f64 {
|
||||
const R: f64 = 6_371_000.0;
|
||||
let d_lat: f64 = (lat2 - lat1).to_radians();
|
||||
let a: f64 = (d_lat / 2.0).sin() * (d_lat / 2.0).sin();
|
||||
let c: f64 = 2.0 * a.sqrt().atan2((1.0 - a).sqrt());
|
||||
|
||||
R * c
|
||||
}
|
||||
|
||||
// copied legacy code
|
||||
// Function to convert latitude and longitude to Minecraft coordinates.
|
||||
// Function to convert latitude and longitude to Minecraft coordinates.
|
||||
#[cfg(test)]
|
||||
pub fn lat_lon_to_minecraft_coords(
|
||||
lat: f64,
|
||||
lon: f64,
|
||||
bbox: LLBBox, // (min_lon, min_lat, max_lon, max_lat)
|
||||
scale_factor_z: f64,
|
||||
scale_factor_x: f64,
|
||||
) -> (i32, i32) {
|
||||
// Calculate the relative position within the bounding box
|
||||
let rel_x: f64 = (lon - bbox.min().lng()) / (bbox.max().lng() - bbox.min().lng());
|
||||
let rel_z: f64 = 1.0 - (lat - bbox.min().lat()) / (bbox.max().lat() - bbox.min().lat());
|
||||
|
||||
// Apply scaling factors for each dimension and convert to Minecraft coordinates
|
||||
let x: i32 = (rel_x * scale_factor_x) as i32;
|
||||
let z: i32 = (rel_z * scale_factor_z) as i32;
|
||||
|
||||
(x, z)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::test_utilities::get_llbbox_arnis;
|
||||
|
||||
fn test_llxztransform_one_scale_one_factor(
|
||||
scale: f64,
|
||||
test_latfactor: f64,
|
||||
test_lngfactor: f64,
|
||||
) {
|
||||
let llbbox = get_llbbox_arnis();
|
||||
let llpoint = LLPoint::new(
|
||||
llbbox.min().lat() + (llbbox.max().lat() - llbbox.min().lat()) * test_latfactor,
|
||||
llbbox.min().lng() + (llbbox.max().lng() - llbbox.min().lng()) * test_lngfactor,
|
||||
)
|
||||
.unwrap();
|
||||
let (transformer, xzbbox_new) = CoordTransformer::llbbox_to_xzbbox(&llbbox, scale).unwrap();
|
||||
|
||||
// legacy xzbbox creation
|
||||
let (scale_factor_z, scale_factor_x) = geo_distance(llbbox.min(), llbbox.max());
|
||||
let scale_factor_z: f64 = scale_factor_z.floor() * scale;
|
||||
let scale_factor_x: f64 = scale_factor_x.floor() * scale;
|
||||
let xzbbox_old = XZBBox::rect_from_xz_lengths(scale_factor_x, scale_factor_z).unwrap();
|
||||
|
||||
// legacy coord transform
|
||||
let (x, z) = lat_lon_to_minecraft_coords(
|
||||
llpoint.lat(),
|
||||
llpoint.lng(),
|
||||
llbbox,
|
||||
scale_factor_z,
|
||||
scale_factor_x,
|
||||
);
|
||||
// new coord transform
|
||||
let xzpoint = transformer.transform_point(llpoint);
|
||||
|
||||
assert_eq!(x, xzpoint.x);
|
||||
assert_eq!(z, xzpoint.z);
|
||||
assert_eq!(xzbbox_new.min_x(), xzbbox_old.min_x());
|
||||
assert_eq!(xzbbox_new.max_x(), xzbbox_old.max_x());
|
||||
assert_eq!(xzbbox_new.min_z(), xzbbox_old.min_z());
|
||||
assert_eq!(xzbbox_new.max_z(), xzbbox_old.max_z());
|
||||
}
|
||||
|
||||
// this ensures that transformer.transform_point == legacy lat_lon_to_minecraft_coords
|
||||
#[test]
|
||||
pub fn test_llxztransform() {
|
||||
test_llxztransform_one_scale_one_factor(1.0, 0.5, 0.5);
|
||||
test_llxztransform_one_scale_one_factor(3.0, 0.1, 0.2);
|
||||
test_llxztransform_one_scale_one_factor(10.0, -1.2, 2.0);
|
||||
test_llxztransform_one_scale_one_factor(0.4, 0.3, -0.2);
|
||||
test_llxztransform_one_scale_one_factor(0.1, 0.2, 0.7);
|
||||
}
|
||||
|
||||
// this ensures that invalid inputs can be handled correctly
|
||||
#[test]
|
||||
pub fn test_invalid_construct() {
|
||||
let llbbox = get_llbbox_arnis();
|
||||
let obj = CoordTransformer::llbbox_to_xzbbox(&llbbox, 0.0);
|
||||
assert!(obj.is_err());
|
||||
|
||||
let obj = CoordTransformer::llbbox_to_xzbbox(&llbbox, -1.2);
|
||||
assert!(obj.is_err());
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,32 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::{DIRT, GRASS_BLOCK, SNOW_BLOCK};
|
||||
use crate::block_definitions::{BEDROCK, DIRT, GRASS_BLOCK, STONE};
|
||||
use crate::coordinate_system::cartesian::XZBBox;
|
||||
use crate::element_processing::*;
|
||||
use crate::ground::Ground;
|
||||
use crate::osm_parser::ProcessedElement;
|
||||
use crate::progress::emit_gui_progress_update;
|
||||
use crate::world_editor::WorldEditor;
|
||||
use colored::Colorize;
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
|
||||
pub const MIN_Y: i32 = -64;
|
||||
|
||||
pub fn generate_world(
|
||||
elements: Vec<ProcessedElement>,
|
||||
xzbbox: XZBBox,
|
||||
ground: Ground,
|
||||
args: &Args,
|
||||
scale_factor_x: f64,
|
||||
scale_factor_z: f64,
|
||||
) -> Result<(), String> {
|
||||
println!("{} Processing data...", "[3/5]".bold());
|
||||
emit_gui_progress_update(10.0, "Processing data...");
|
||||
|
||||
let ground_level: i32 = args.ground_level;
|
||||
let region_dir: String = format!("{}/region", args.path);
|
||||
let mut editor: WorldEditor =
|
||||
WorldEditor::new(®ion_dir, scale_factor_x, scale_factor_z, args);
|
||||
let mut editor: WorldEditor = WorldEditor::new(®ion_dir, &xzbbox);
|
||||
|
||||
editor.set_sign(
|
||||
"↑".to_string(),
|
||||
"Generated World".to_string(),
|
||||
"This direction".to_string(),
|
||||
"".to_string(),
|
||||
9,
|
||||
-61,
|
||||
9,
|
||||
6,
|
||||
);
|
||||
println!("{} Processing data...", "[4/7]".bold());
|
||||
|
||||
// Set ground reference in the editor to enable elevation-aware block placement
|
||||
editor.set_ground(&ground);
|
||||
|
||||
println!("{} Processing terrain...", "[5/7]".bold());
|
||||
emit_gui_progress_update(25.0, "Processing terrain...");
|
||||
|
||||
// Process data
|
||||
let elements_count: usize = elements.len();
|
||||
@@ -40,9 +36,10 @@ pub fn generate_world(
|
||||
.unwrap()
|
||||
.progress_chars("█▓░"));
|
||||
|
||||
let progress_increment_prcs: f64 = 50.0 / elements_count as f64;
|
||||
let mut current_progress_prcs: f64 = 10.0;
|
||||
let progress_increment_prcs: f64 = 45.0 / elements_count as f64;
|
||||
let mut current_progress_prcs: f64 = 25.0;
|
||||
let mut last_emitted_progress: f64 = current_progress_prcs;
|
||||
|
||||
for element in &elements {
|
||||
process_pb.inc(1);
|
||||
current_progress_prcs += progress_increment_prcs;
|
||||
@@ -64,56 +61,72 @@ pub fn generate_world(
|
||||
match element {
|
||||
ProcessedElement::Way(way) => {
|
||||
if way.tags.contains_key("building") || way.tags.contains_key("building:part") {
|
||||
buildings::generate_buildings(&mut editor, way, ground_level, args);
|
||||
buildings::generate_buildings(&mut editor, way, args, None);
|
||||
} else if way.tags.contains_key("highway") {
|
||||
highways::generate_highways(&mut editor, element, ground_level, args);
|
||||
highways::generate_highways(&mut editor, element, args);
|
||||
} else if way.tags.contains_key("landuse") {
|
||||
landuse::generate_landuse(&mut editor, way, ground_level, args);
|
||||
landuse::generate_landuse(&mut editor, way, args);
|
||||
} else if way.tags.contains_key("natural") {
|
||||
natural::generate_natural(&mut editor, element, ground_level, args);
|
||||
natural::generate_natural(&mut editor, element, args);
|
||||
} else if way.tags.contains_key("amenity") {
|
||||
amenities::generate_amenities(&mut editor, element, ground_level, args);
|
||||
amenities::generate_amenities(&mut editor, element, args);
|
||||
} else if way.tags.contains_key("leisure") {
|
||||
leisure::generate_leisure(&mut editor, way, ground_level, args);
|
||||
leisure::generate_leisure(&mut editor, way, args);
|
||||
} else if way.tags.contains_key("barrier") {
|
||||
barriers::generate_barriers(&mut editor, element, ground_level);
|
||||
barriers::generate_barriers(&mut editor, element);
|
||||
} else if way.tags.contains_key("waterway") {
|
||||
waterways::generate_waterways(&mut editor, way, ground_level);
|
||||
waterways::generate_waterways(&mut editor, way);
|
||||
} else if way.tags.contains_key("bridge") {
|
||||
bridges::generate_bridges(&mut editor, way, ground_level);
|
||||
//bridges::generate_bridges(&mut editor, way, ground_level); // TODO FIX
|
||||
} else if way.tags.contains_key("railway") {
|
||||
railways::generate_railways(&mut editor, way, ground_level);
|
||||
railways::generate_railways(&mut editor, way);
|
||||
} else if way.tags.contains_key("aeroway") || way.tags.contains_key("area:aeroway")
|
||||
{
|
||||
highways::generate_aeroway(&mut editor, way, args);
|
||||
} else if way.tags.get("service") == Some(&"siding".to_string()) {
|
||||
highways::generate_siding(&mut editor, way, ground_level);
|
||||
highways::generate_siding(&mut editor, way);
|
||||
} else if way.tags.contains_key("man_made") {
|
||||
man_made::generate_man_made(&mut editor, element, args);
|
||||
}
|
||||
}
|
||||
ProcessedElement::Node(node) => {
|
||||
if node.tags.contains_key("door") || node.tags.contains_key("entrance") {
|
||||
doors::generate_doors(&mut editor, node, ground_level);
|
||||
doors::generate_doors(&mut editor, node);
|
||||
} else if node.tags.contains_key("natural")
|
||||
&& node.tags.get("natural") == Some(&"tree".to_string())
|
||||
{
|
||||
natural::generate_natural(&mut editor, element, ground_level, args);
|
||||
natural::generate_natural(&mut editor, element, args);
|
||||
} else if node.tags.contains_key("amenity") {
|
||||
amenities::generate_amenities(&mut editor, element, ground_level, args);
|
||||
amenities::generate_amenities(&mut editor, element, args);
|
||||
} else if node.tags.contains_key("barrier") {
|
||||
barriers::generate_barriers(&mut editor, element, ground_level);
|
||||
barriers::generate_barrier_nodes(&mut editor, node);
|
||||
} else if node.tags.contains_key("highway") {
|
||||
highways::generate_highways(&mut editor, element, ground_level, args);
|
||||
highways::generate_highways(&mut editor, element, args);
|
||||
} else if node.tags.contains_key("tourism") {
|
||||
tourisms::generate_tourisms(&mut editor, node, ground_level);
|
||||
tourisms::generate_tourisms(&mut editor, node);
|
||||
} else if node.tags.contains_key("man_made") {
|
||||
man_made::generate_man_made_nodes(&mut editor, node);
|
||||
}
|
||||
}
|
||||
ProcessedElement::Relation(rel) => {
|
||||
if rel.tags.contains_key("building") || rel.tags.contains_key("building:part") {
|
||||
buildings::generate_building_from_relation(
|
||||
buildings::generate_building_from_relation(&mut editor, rel, args);
|
||||
} else if rel.tags.contains_key("water")
|
||||
|| rel.tags.get("natural") == Some(&"water".to_string())
|
||||
{
|
||||
water_areas::generate_water_areas(&mut editor, rel);
|
||||
} else if rel.tags.contains_key("natural") {
|
||||
natural::generate_natural_from_relation(&mut editor, rel, args);
|
||||
} else if rel.tags.contains_key("landuse") {
|
||||
landuse::generate_landuse_from_relation(&mut editor, rel, args);
|
||||
} else if rel.tags.get("leisure") == Some(&"park".to_string()) {
|
||||
leisure::generate_leisure_from_relation(&mut editor, rel, args);
|
||||
} else if rel.tags.contains_key("man_made") {
|
||||
man_made::generate_man_made(
|
||||
&mut editor,
|
||||
rel,
|
||||
ground_level,
|
||||
&ProcessedElement::Relation(rel.clone()),
|
||||
args,
|
||||
);
|
||||
} else if rel.tags.contains_key("water") {
|
||||
water_areas::generate_water_areas(&mut editor, rel, ground_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,14 +135,14 @@ pub fn generate_world(
|
||||
process_pb.finish();
|
||||
|
||||
// Generate ground layer
|
||||
let total_blocks: u64 = (scale_factor_x as i32 + 1) as u64 * (scale_factor_z as i32 + 1) as u64;
|
||||
let total_blocks: u64 = xzbbox.bounding_rect().total_blocks();
|
||||
let desired_updates: u64 = 1500;
|
||||
let batch_size: u64 = (total_blocks / desired_updates).max(1);
|
||||
|
||||
let mut block_counter: u64 = 0;
|
||||
|
||||
println!("{} Generating ground layer...", "[4/5]".bold());
|
||||
emit_gui_progress_update(60.0, "Generating ground layer...");
|
||||
println!("{} Generating ground...", "[6/7]".bold());
|
||||
emit_gui_progress_update(70.0, "Generating ground...");
|
||||
|
||||
let ground_pb: ProgressBar = ProgressBar::new(total_blocks);
|
||||
ground_pb.set_style(
|
||||
@@ -139,17 +152,39 @@ pub fn generate_world(
|
||||
.progress_chars("█▓░"),
|
||||
);
|
||||
|
||||
let mut gui_progress_grnd: f64 = 60.0;
|
||||
let mut gui_progress_grnd: f64 = 70.0;
|
||||
let mut last_emitted_progress: f64 = gui_progress_grnd;
|
||||
let total_iterations_grnd: f64 = (scale_factor_x + 1.0) * (scale_factor_z + 1.0);
|
||||
let progress_increment_grnd: f64 = 30.0 / total_iterations_grnd;
|
||||
let total_iterations_grnd: f64 = total_blocks as f64;
|
||||
let progress_increment_grnd: f64 = 20.0 / total_iterations_grnd;
|
||||
|
||||
let groundlayer_block = if args.winter { SNOW_BLOCK } else { GRASS_BLOCK };
|
||||
let groundlayer_block = GRASS_BLOCK;
|
||||
|
||||
for x in 0..=(scale_factor_x as i32) {
|
||||
for z in 0..=(scale_factor_z as i32) {
|
||||
editor.set_block(groundlayer_block, x, ground_level, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level - 1, z, None, None);
|
||||
for x in xzbbox.min_x()..=xzbbox.max_x() {
|
||||
for z in xzbbox.min_z()..=xzbbox.max_z() {
|
||||
// Add default dirt and grass layer if there isn't a stone layer already
|
||||
if !editor.check_for_block(x, 0, z, Some(&[STONE])) {
|
||||
editor.set_block(groundlayer_block, x, 0, z, None, None);
|
||||
editor.set_block(DIRT, x, -1, z, None, None);
|
||||
editor.set_block(DIRT, x, -2, z, None, None);
|
||||
}
|
||||
|
||||
// Fill underground with stone
|
||||
if args.fillground {
|
||||
// Fill from bedrock+1 to 3 blocks below ground with stone
|
||||
editor.fill_blocks_absolute(
|
||||
STONE,
|
||||
x,
|
||||
MIN_Y + 1,
|
||||
z,
|
||||
x,
|
||||
editor.get_absolute_y(x, -3, z),
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
// Generate a bedrock level at MIN_Y
|
||||
editor.set_block_absolute(BEDROCK, x, MIN_Y, z, None, Some(&[BEDROCK]));
|
||||
|
||||
block_counter += 1;
|
||||
if block_counter % batch_size == 0 {
|
||||
@@ -164,12 +199,47 @@ pub fn generate_world(
|
||||
}
|
||||
}
|
||||
|
||||
// Set sign for player orientation
|
||||
/*editor.set_sign(
|
||||
"↑".to_string(),
|
||||
"Generated World".to_string(),
|
||||
"This direction".to_string(),
|
||||
"".to_string(),
|
||||
9,
|
||||
-61,
|
||||
9,
|
||||
6,
|
||||
);*/
|
||||
|
||||
ground_pb.inc(block_counter % batch_size);
|
||||
ground_pb.finish();
|
||||
|
||||
// Save world
|
||||
editor.save();
|
||||
|
||||
// Update player spawn Y coordinate based on terrain height after generation
|
||||
#[cfg(feature = "gui")]
|
||||
if let Some(spawn_coords) = &args.spawn_point {
|
||||
use crate::gui::update_player_spawn_y_after_generation;
|
||||
let bbox_string = format!(
|
||||
"{},{},{},{}",
|
||||
args.bbox.min().lng(),
|
||||
args.bbox.min().lat(),
|
||||
args.bbox.max().lng(),
|
||||
args.bbox.max().lat()
|
||||
);
|
||||
|
||||
if let Err(e) = update_player_spawn_y_after_generation(
|
||||
&args.path,
|
||||
Some(*spawn_coords),
|
||||
bbox_string,
|
||||
args.scale,
|
||||
&ground,
|
||||
) {
|
||||
eprintln!("Warning: Failed to update spawn point Y coordinate: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
emit_gui_progress_update(100.0, "Done! World generation completed.");
|
||||
println!("{}", "Done! World generation completed.".green().bold());
|
||||
Ok(())
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::coordinate_system::cartesian::XZPoint;
|
||||
use crate::floodfill::flood_fill_area;
|
||||
use crate::osm_parser::ProcessedElement;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_amenities(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedElement,
|
||||
ground_level: i32,
|
||||
args: &Args,
|
||||
) {
|
||||
pub fn generate_amenities(editor: &mut WorldEditor, element: &ProcessedElement, args: &Args) {
|
||||
// Skip if 'layer' or 'level' is negative in the tags
|
||||
if let Some(layer) = element.tags().get("layer") {
|
||||
if layer.parse::<i32>().unwrap_or(0) < 0 {
|
||||
@@ -25,21 +21,21 @@ pub fn generate_amenities(
|
||||
}
|
||||
|
||||
if let Some(amenity_type) = element.tags().get("amenity") {
|
||||
let first_node: Option<(i32, i32)> = element
|
||||
let first_node: Option<XZPoint> = element
|
||||
.nodes()
|
||||
.map(|n: &crate::osm_parser::ProcessedNode| (n.x, n.z))
|
||||
.map(|n: &crate::osm_parser::ProcessedNode| XZPoint::new(n.x, n.z))
|
||||
.next();
|
||||
match amenity_type.as_str() {
|
||||
"waste_disposal" | "waste_basket" => {
|
||||
// Place a cauldron for waste disposal or waste basket
|
||||
if let Some((x, z)) = first_node {
|
||||
editor.set_block(CAULDRON, x, ground_level + 1, z, None, None);
|
||||
if let Some(pt) = first_node {
|
||||
editor.set_block(CAULDRON, pt.x, 1, pt.z, None, None);
|
||||
}
|
||||
}
|
||||
"vending_machine" | "atm" => {
|
||||
if let Some((x, z)) = first_node {
|
||||
editor.set_block(IRON_BLOCK, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(IRON_BLOCK, x, ground_level + 2, z, None, None);
|
||||
if let Some(pt) = first_node {
|
||||
editor.set_block(IRON_BLOCK, pt.x, 1, pt.z, None, None);
|
||||
editor.set_block(IRON_BLOCK, pt.x, 2, pt.z, None, None);
|
||||
}
|
||||
}
|
||||
"bicycle_parking" => {
|
||||
@@ -50,50 +46,88 @@ pub fn generate_amenities(
|
||||
.nodes()
|
||||
.map(|n: &crate::osm_parser::ProcessedNode| (n.x, n.z))
|
||||
.collect();
|
||||
|
||||
if polygon_coords.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
let floor_area: Vec<(i32, i32)> =
|
||||
flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
// Fill the floor area
|
||||
for (x, z) in floor_area.iter() {
|
||||
editor.set_block(ground_block, *x, ground_level, *z, None, None);
|
||||
editor.set_block(ground_block, *x, 0, *z, None, None);
|
||||
}
|
||||
|
||||
// Place fences and roof slabs at each corner node
|
||||
for node in element.nodes() {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
|
||||
// Set ground block and fences
|
||||
editor.set_block(ground_block, x, 0, z, None, None);
|
||||
for y in 1..=4 {
|
||||
editor.set_block(OAK_FENCE, x, y, z, None, None);
|
||||
}
|
||||
editor.set_block(roof_block, x, 5, z, None, None);
|
||||
}
|
||||
|
||||
// Flood fill the roof area
|
||||
for (x, z) in floor_area.iter() {
|
||||
editor.set_block(roof_block, *x, 5, *z, None, None);
|
||||
}
|
||||
}
|
||||
"bench" => {
|
||||
// Place a bench
|
||||
if let Some(pt) = first_node {
|
||||
// 50% chance to 90 degrees rotate the bench using if
|
||||
if rand::random::<bool>() {
|
||||
editor.set_block(SMOOTH_STONE, pt.x, 1, pt.z, None, None);
|
||||
editor.set_block(OAK_LOG, pt.x + 1, 1, pt.z, None, None);
|
||||
editor.set_block(OAK_LOG, pt.x - 1, 1, pt.z, None, None);
|
||||
} else {
|
||||
editor.set_block(SMOOTH_STONE, pt.x, 1, pt.z, None, None);
|
||||
editor.set_block(OAK_LOG, pt.x, 1, pt.z + 1, None, None);
|
||||
editor.set_block(OAK_LOG, pt.x, 1, pt.z - 1, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
"vending" => {
|
||||
// Place vending machine blocks
|
||||
if let Some(pt) = first_node {
|
||||
editor.set_block(IRON_BLOCK, pt.x, 1, pt.z, None, None);
|
||||
editor.set_block(IRON_BLOCK, pt.x, 2, pt.z, None, None);
|
||||
}
|
||||
}
|
||||
"shelter" => {
|
||||
let roof_block: Block = STONE_BRICK_SLAB;
|
||||
|
||||
let polygon_coords: Vec<(i32, i32)> = element
|
||||
.nodes()
|
||||
.map(|n: &crate::osm_parser::ProcessedNode| (n.x, n.z))
|
||||
.collect();
|
||||
let roof_area: Vec<(i32, i32)> =
|
||||
flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
// Place fences and roof slabs at each corner node directly
|
||||
for node in element.nodes() {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
|
||||
for y in 1..=4 {
|
||||
editor.set_block(ground_block, x, ground_level, z, None, None);
|
||||
editor.set_block(OAK_FENCE, x, ground_level + y, z, None, None);
|
||||
for fence_height in 1..=4 {
|
||||
editor.set_block(OAK_FENCE, x, fence_height, z, None, None);
|
||||
}
|
||||
editor.set_block(roof_block, x, ground_level + 5, z, None, None);
|
||||
editor.set_block(roof_block, x, 5, z, None, None);
|
||||
}
|
||||
|
||||
// Flood fill the roof area
|
||||
let roof_height: i32 = ground_level + 5;
|
||||
for (x, z) in floor_area.iter() {
|
||||
editor.set_block(roof_block, *x, roof_height, *z, None, None);
|
||||
}
|
||||
}
|
||||
"bench" => {
|
||||
// Place a bench
|
||||
if let Some((x, z)) = first_node {
|
||||
editor.set_block(SMOOTH_STONE, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(OAK_LOG, x + 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(OAK_LOG, x - 1, ground_level + 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"vending" => {
|
||||
// Place vending machine blocks
|
||||
if let Some((x, z)) = first_node {
|
||||
editor.set_block(IRON_BLOCK, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(IRON_BLOCK, x, ground_level + 2, z, None, None);
|
||||
for (x, z) in roof_area.iter() {
|
||||
editor.set_block(roof_block, *x, 5, *z, None, None);
|
||||
}
|
||||
}
|
||||
"parking" | "fountain" => {
|
||||
// Process parking or fountain areas
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
let mut previous_node: Option<XZPoint> = None;
|
||||
let mut corner_addup: (i32, i32, i32) = (0, 0, 0);
|
||||
let mut current_amenity: Vec<(i32, i32)> = vec![];
|
||||
|
||||
@@ -102,23 +136,16 @@ pub fn generate_amenities(
|
||||
"parking" => GRAY_CONCRETE,
|
||||
_ => GRAY_CONCRETE,
|
||||
};
|
||||
|
||||
for node in element.nodes() {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
let pt: XZPoint = node.xz();
|
||||
|
||||
if let Some(prev) = previous_node {
|
||||
// Create borders for fountain or parking area
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level, prev.1, x, ground_level, z);
|
||||
bresenham_line(prev.x, 0, prev.z, pt.x, 0, pt.z);
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
editor.set_block(
|
||||
block_type,
|
||||
bx,
|
||||
ground_level,
|
||||
bz,
|
||||
Some(&[BLACK_CONCRETE]),
|
||||
None,
|
||||
);
|
||||
editor.set_block(block_type, bx, 0, bz, Some(&[BLACK_CONCRETE]), None);
|
||||
|
||||
// Decorative border around fountains
|
||||
if amenity_type == "fountain" {
|
||||
@@ -128,7 +155,7 @@ pub fn generate_amenities(
|
||||
editor.set_block(
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
bx + dx,
|
||||
ground_level,
|
||||
0,
|
||||
bz + dz,
|
||||
None,
|
||||
None,
|
||||
@@ -144,7 +171,7 @@ pub fn generate_amenities(
|
||||
corner_addup.2 += 1;
|
||||
}
|
||||
}
|
||||
previous_node = Some((x, z));
|
||||
previous_node = Some(pt);
|
||||
}
|
||||
|
||||
// Flood-fill the interior area for parking or fountains
|
||||
@@ -157,22 +184,81 @@ pub fn generate_amenities(
|
||||
editor.set_block(
|
||||
block_type,
|
||||
x,
|
||||
ground_level,
|
||||
0,
|
||||
z,
|
||||
Some(&[BLACK_CONCRETE, GRAY_CONCRETE]),
|
||||
None,
|
||||
);
|
||||
|
||||
// Add parking spot markings
|
||||
if amenity_type == "parking" && (x + z) % 8 == 0 && (x * z) % 32 != 0 {
|
||||
editor.set_block(
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
x,
|
||||
ground_level,
|
||||
z,
|
||||
Some(&[BLACK_CONCRETE, GRAY_CONCRETE]),
|
||||
None,
|
||||
);
|
||||
// Enhanced parking space markings
|
||||
if amenity_type == "parking" {
|
||||
// Create defined parking spaces with realistic layout
|
||||
let space_width = 4; // Width of each parking space
|
||||
let space_length = 6; // Length of each parking space
|
||||
let lane_width = 5; // Width of driving lanes
|
||||
|
||||
// Calculate which "zone" this coordinate falls into
|
||||
let zone_x = x / space_width;
|
||||
let zone_z = z / (space_length + lane_width);
|
||||
let local_x = x % space_width;
|
||||
let local_z = z % (space_length + lane_width);
|
||||
|
||||
// Create parking space boundaries (only within parking areas, not in driving lanes)
|
||||
if local_z < space_length {
|
||||
// We're in a parking space area, not in the driving lane
|
||||
if local_x == 0 {
|
||||
// Vertical parking space lines (only on the left edge)
|
||||
editor.set_block(
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
x,
|
||||
0,
|
||||
z,
|
||||
Some(&[BLACK_CONCRETE, GRAY_CONCRETE]),
|
||||
None,
|
||||
);
|
||||
} else if local_z == 0 {
|
||||
// Horizontal parking space lines (only on the top edge)
|
||||
editor.set_block(
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
x,
|
||||
0,
|
||||
z,
|
||||
Some(&[BLACK_CONCRETE, GRAY_CONCRETE]),
|
||||
None,
|
||||
);
|
||||
}
|
||||
} else if local_z == space_length {
|
||||
// Bottom edge of parking spaces (border with driving lane)
|
||||
editor.set_block(
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
x,
|
||||
0,
|
||||
z,
|
||||
Some(&[BLACK_CONCRETE, GRAY_CONCRETE]),
|
||||
None,
|
||||
);
|
||||
} else if local_z > space_length && local_z < space_length + lane_width
|
||||
{
|
||||
// Driving lane - use darker concrete
|
||||
editor.set_block(
|
||||
BLACK_CONCRETE,
|
||||
x,
|
||||
0,
|
||||
z,
|
||||
Some(&[GRAY_CONCRETE]),
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
// Add light posts at parking space outline corners
|
||||
if local_x == 0 && local_z == 0 && zone_x % 3 == 0 && zone_z % 2 == 0 {
|
||||
// Light posts at regular intervals on parking space corners
|
||||
editor.set_block(COBBLESTONE_WALL, x, 1, z, None, None);
|
||||
for dy in 2..=4 {
|
||||
editor.set_block(OAK_FENCE, x, dy, z, None, None);
|
||||
}
|
||||
editor.set_block(GLOWSTONE, x, 5, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,65 +1,171 @@
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::osm_parser::ProcessedElement;
|
||||
use crate::osm_parser::{ProcessedElement, ProcessedNode};
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_barriers(editor: &mut WorldEditor, element: &ProcessedElement, ground_level: i32) {
|
||||
if let Some(barrier_type) = element.tags().get("barrier") {
|
||||
if barrier_type == "bollard" {
|
||||
if let ProcessedElement::Node(node) = element {
|
||||
editor.set_block(
|
||||
COBBLESTONE_WALL,
|
||||
node.x,
|
||||
ground_level + 1,
|
||||
node.z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
// Place bollard
|
||||
pub fn generate_barriers(editor: &mut WorldEditor, element: &ProcessedElement) {
|
||||
// Default values
|
||||
let mut barrier_material: Block = COBBLESTONE_WALL;
|
||||
let mut barrier_height: i32 = 2;
|
||||
|
||||
match element.tags().get("barrier").map(|s| s.as_str()) {
|
||||
Some("bollard") => {
|
||||
barrier_material = COBBLESTONE_WALL;
|
||||
barrier_height = 1;
|
||||
}
|
||||
Some("kerb") => {
|
||||
// Ignore kerbs
|
||||
return;
|
||||
}
|
||||
Some("hedge") => {
|
||||
barrier_material = OAK_LEAVES;
|
||||
barrier_height = 2;
|
||||
}
|
||||
Some("fence") => {
|
||||
// Handle fence sub-types
|
||||
match element.tags().get("fence_type").map(|s| s.as_str()) {
|
||||
Some("railing" | "bars" | "krest") => {
|
||||
barrier_material = STONE_BRICK_WALL;
|
||||
barrier_height = 1;
|
||||
}
|
||||
Some(
|
||||
"chain_link" | "metal" | "wire" | "barbed_wire" | "corrugated_metal"
|
||||
| "electric" | "metal_bars",
|
||||
) => {
|
||||
barrier_material = STONE_BRICK_WALL; // IRON_BARS
|
||||
barrier_height = 2;
|
||||
}
|
||||
Some("slatted" | "paling") => {
|
||||
barrier_material = OAK_FENCE;
|
||||
barrier_height = 1;
|
||||
}
|
||||
Some("wood" | "split_rail" | "panel" | "pole") => {
|
||||
barrier_material = OAK_FENCE;
|
||||
barrier_height = 2;
|
||||
}
|
||||
Some("concrete" | "stone") => {
|
||||
barrier_material = STONE_BRICK_WALL;
|
||||
barrier_height = 2;
|
||||
}
|
||||
Some("glass") => {
|
||||
barrier_material = GLASS;
|
||||
barrier_height = 1;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else if let ProcessedElement::Way(way) = element {
|
||||
// Determine wall height
|
||||
let wall_height: i32 = element
|
||||
.tags()
|
||||
.get("height")
|
||||
.and_then(|height: &String| height.parse::<f32>().ok())
|
||||
.map(|height: f32| f32::min(3.0, height).round() as i32)
|
||||
.unwrap_or(2); // Default height is 2 if not specified or invalid
|
||||
}
|
||||
Some("wall") => {
|
||||
barrier_material = STONE_BRICK_WALL;
|
||||
barrier_height = 3;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
// Tagged material takes priority over inferred
|
||||
if let Some(barrier_mat) = element.tags().get("material") {
|
||||
if barrier_mat == "brick" {
|
||||
barrier_material = BRICK;
|
||||
}
|
||||
if barrier_mat == "concrete" {
|
||||
barrier_material = LIGHT_GRAY_CONCRETE;
|
||||
}
|
||||
if barrier_mat == "metal" {
|
||||
barrier_material = STONE_BRICK_WALL; // IRON_BARS
|
||||
}
|
||||
}
|
||||
|
||||
// Process nodes to create the barrier wall
|
||||
for i in 1..way.nodes.len() {
|
||||
let prev: &crate::osm_parser::ProcessedNode = &way.nodes[i - 1];
|
||||
let x1: i32 = prev.x;
|
||||
let z1: i32 = prev.z;
|
||||
if let ProcessedElement::Way(way) = element {
|
||||
// Determine wall height
|
||||
let wall_height: i32 = element
|
||||
.tags()
|
||||
.get("height")
|
||||
.and_then(|height: &String| height.parse::<f32>().ok())
|
||||
.map(|height: f32| height.round() as i32)
|
||||
.unwrap_or(barrier_height);
|
||||
|
||||
let cur: &crate::osm_parser::ProcessedNode = &way.nodes[i];
|
||||
let x2: i32 = cur.x;
|
||||
let z2: i32 = cur.z;
|
||||
// Process nodes to create the barrier wall
|
||||
for i in 1..way.nodes.len() {
|
||||
let prev: &crate::osm_parser::ProcessedNode = &way.nodes[i - 1];
|
||||
let x1: i32 = prev.x;
|
||||
let z1: i32 = prev.z;
|
||||
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(x1, ground_level, z1, x2, ground_level, z2);
|
||||
let cur: &crate::osm_parser::ProcessedNode = &way.nodes[i];
|
||||
let x2: i32 = cur.x;
|
||||
let z2: i32 = cur.z;
|
||||
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
// Build the barrier wall to the specified height
|
||||
for y in (ground_level + 1)..=(ground_level + wall_height) {
|
||||
editor.set_block(COBBLESTONE_WALL, bx, y, bz, None, None);
|
||||
// Barrier wall
|
||||
}
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> = bresenham_line(x1, 0, z1, x2, 0, z2);
|
||||
|
||||
// Add an optional top to the barrier if the height is more than 1
|
||||
if wall_height > 1 {
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
bx,
|
||||
ground_level + wall_height + 1,
|
||||
bz,
|
||||
None,
|
||||
None,
|
||||
); // Top of the barrier
|
||||
}
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
// Build the barrier wall to the specified height
|
||||
for y in 1..=wall_height {
|
||||
editor.set_block(barrier_material, bx, y, bz, None, None);
|
||||
}
|
||||
|
||||
// Add an optional top to the barrier if the height is more than 1
|
||||
if wall_height > 1 {
|
||||
editor.set_block(STONE_BRICK_SLAB, bx, wall_height + 1, bz, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_barrier_nodes(editor: &mut WorldEditor<'_>, node: &ProcessedNode) {
|
||||
match node.tags.get("barrier").map(|s| s.as_str()) {
|
||||
Some("bollard") => {
|
||||
editor.set_block(COBBLESTONE_WALL, node.x, 1, node.z, None, None);
|
||||
}
|
||||
Some("stile" | "gate" | "swing_gate" | "lift_gate") => {
|
||||
/*editor.set_block(
|
||||
OAK_TRAPDOOR,
|
||||
node.x,
|
||||
1,
|
||||
node.z,
|
||||
Some(&[
|
||||
COBBLESTONE_WALL,
|
||||
OAK_FENCE,
|
||||
STONE_BRICK_WALL,
|
||||
OAK_LEAVES,
|
||||
STONE_BRICK_SLAB,
|
||||
]),
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
AIR,
|
||||
node.x,
|
||||
2,
|
||||
node.z,
|
||||
Some(&[
|
||||
COBBLESTONE_WALL,
|
||||
OAK_FENCE,
|
||||
STONE_BRICK_WALL,
|
||||
OAK_LEAVES,
|
||||
STONE_BRICK_SLAB,
|
||||
]),
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
AIR,
|
||||
node.x,
|
||||
3,
|
||||
node.z,
|
||||
Some(&[
|
||||
COBBLESTONE_WALL,
|
||||
OAK_FENCE,
|
||||
STONE_BRICK_WALL,
|
||||
OAK_LEAVES,
|
||||
STONE_BRICK_SLAB,
|
||||
]),
|
||||
None,
|
||||
);*/
|
||||
}
|
||||
Some("block") => {
|
||||
editor.set_block(STONE, node.x, 1, node.z, None, None);
|
||||
}
|
||||
Some("entrance") => {
|
||||
editor.set_block(AIR, node.x, 1, node.z, None, None);
|
||||
}
|
||||
None => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,67 +3,36 @@ use crate::bresenham::bresenham_line;
|
||||
use crate::osm_parser::ProcessedWay;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_bridges(editor: &mut WorldEditor, element: &ProcessedWay, ground_level: i32) {
|
||||
// TODO FIX
|
||||
#[allow(dead_code)]
|
||||
pub fn generate_bridges(editor: &mut WorldEditor, element: &ProcessedWay) {
|
||||
if let Some(_bridge_type) = element.tags.get("bridge") {
|
||||
let bridge_height: i32 = element
|
||||
.tags
|
||||
.get("layer")
|
||||
.and_then(|layer: &String| layer.parse::<i32>().ok())
|
||||
.unwrap_or(1); // Default height if not specified
|
||||
|
||||
// Calculate the total length of the bridge
|
||||
let total_steps: usize = element
|
||||
.nodes
|
||||
.windows(2)
|
||||
.map(|nodes: &[crate::osm_parser::ProcessedNode]| {
|
||||
let x1: i32 = nodes[0].x;
|
||||
let z1: i32 = nodes[0].z;
|
||||
let x2: i32 = nodes[1].x;
|
||||
let z2: i32 = nodes[1].z;
|
||||
|
||||
bresenham_line(x1, ground_level, z1, x2, ground_level, z2).len()
|
||||
})
|
||||
.sum();
|
||||
|
||||
let half_steps: usize = total_steps / 2; // Calculate midpoint for descending after rising
|
||||
let mut current_step: usize = 0;
|
||||
let bridge_height = 3; // Fixed height
|
||||
|
||||
for i in 1..element.nodes.len() {
|
||||
let prev: &crate::osm_parser::ProcessedNode = &element.nodes[i - 1];
|
||||
let x1: i32 = prev.x;
|
||||
let z1: i32 = prev.z;
|
||||
let prev = &element.nodes[i - 1];
|
||||
let cur = &element.nodes[i];
|
||||
let points = bresenham_line(prev.x, 0, prev.z, cur.x, 0, cur.z);
|
||||
|
||||
let cur: &crate::osm_parser::ProcessedNode = &element.nodes[i];
|
||||
let x2: i32 = cur.x;
|
||||
let z2: i32 = cur.z;
|
||||
let total_length = points.len();
|
||||
let ramp_length = 6; // Length of ramp at each end
|
||||
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(x1, ground_level, z1, x2, ground_level, z2);
|
||||
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
// Calculate the current height of the bridge
|
||||
let current_height: i32 = if current_step <= half_steps {
|
||||
ground_level + bridge_height + current_step as i32 / 5 // Rise for the first half
|
||||
for (idx, (x, _, z)) in points.iter().enumerate() {
|
||||
let height = if idx < ramp_length {
|
||||
// Start ramp (rising)
|
||||
(idx * bridge_height) / ramp_length
|
||||
} else if idx >= total_length - ramp_length {
|
||||
// End ramp (descending)
|
||||
((total_length - idx) * bridge_height) / ramp_length
|
||||
} else {
|
||||
ground_level + bridge_height + (half_steps as i32 / 5)
|
||||
- ((current_step - half_steps) as i32 / 5) // Descend for the second half
|
||||
// Middle section (constant height)
|
||||
bridge_height
|
||||
};
|
||||
|
||||
// Set bridge blocks
|
||||
editor.set_block(LIGHT_GRAY_CONCRETE, bx, current_height, bz, None, None);
|
||||
for (offset_x, offset_z) in &[(-1, -1), (1, -1), (1, 1), (-1, 1)] {
|
||||
editor.set_block(
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
bx + offset_x,
|
||||
current_height,
|
||||
bz + offset_z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
// Place bridge blocks
|
||||
for dx in -2..=2 {
|
||||
editor.set_block(LIGHT_GRAY_CONCRETE, *x + dx, height as i32, *z, None, None);
|
||||
}
|
||||
|
||||
current_step += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::block_definitions::*;
|
||||
use crate::osm_parser::ProcessedNode;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_doors(editor: &mut WorldEditor, element: &ProcessedNode, ground_level: i32) {
|
||||
pub fn generate_doors(editor: &mut WorldEditor, element: &ProcessedNode) {
|
||||
// Check if the element is a door or entrance
|
||||
if element.tags.contains_key("door") || element.tags.contains_key("entrance") {
|
||||
// Check for the "level" tag and skip doors that are not at ground level
|
||||
@@ -18,8 +18,8 @@ pub fn generate_doors(editor: &mut WorldEditor, element: &ProcessedNode, ground_
|
||||
let z: i32 = element.z;
|
||||
|
||||
// Set the ground block and the door blocks
|
||||
editor.set_block(GRAY_CONCRETE, x, ground_level, z, None, None);
|
||||
editor.set_block(DARK_OAK_DOOR_LOWER, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(DARK_OAK_DOOR_UPPER, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(GRAY_CONCRETE, x, 0, z, None, None);
|
||||
editor.set_block(DARK_OAK_DOOR_LOWER, x, 1, z, None, None);
|
||||
editor.set_block(DARK_OAK_DOOR_UPPER, x, 2, z, None, None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::coordinate_system::cartesian::XZPoint;
|
||||
use crate::floodfill::flood_fill_area;
|
||||
use crate::osm_parser::{ProcessedElement, ProcessedWay};
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_highways(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedElement,
|
||||
ground_level: i32,
|
||||
args: &Args,
|
||||
) {
|
||||
pub fn generate_highways(editor: &mut WorldEditor, element: &ProcessedElement, args: &Args) {
|
||||
if let Some(highway_type) = element.tags().get("highway") {
|
||||
if highway_type == "street_lamp" {
|
||||
// Handle street lamps
|
||||
if let ProcessedElement::Node(first_node) = element {
|
||||
let x: i32 = first_node.x;
|
||||
let z: i32 = first_node.z;
|
||||
for y in 1..=4 {
|
||||
editor.set_block(OAK_FENCE, x, ground_level + y, z, None, None);
|
||||
editor.set_block(COBBLESTONE_WALL, x, 1, z, None, None);
|
||||
for dy in 2..=4 {
|
||||
editor.set_block(OAK_FENCE, x, dy, z, None, None);
|
||||
}
|
||||
editor.set_block(GLOWSTONE, x, ground_level + 5, z, None, None);
|
||||
editor.set_block(GLOWSTONE, x, 5, z, None, None);
|
||||
}
|
||||
} else if highway_type == "crossing" {
|
||||
// Handle traffic signals for crossings
|
||||
@@ -29,36 +26,33 @@ pub fn generate_highways(
|
||||
if let ProcessedElement::Node(node) = element {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
for y in 1..=3 {
|
||||
editor.set_block(COBBLESTONE_WALL, x, ground_level + y, z, None, None);
|
||||
|
||||
for dy in 1..=3 {
|
||||
editor.set_block(COBBLESTONE_WALL, x, dy, z, None, None);
|
||||
}
|
||||
|
||||
editor.set_block(GREEN_WOOL, x, ground_level + 4, z, None, None);
|
||||
editor.set_block(YELLOW_WOOL, x, ground_level + 5, z, None, None);
|
||||
editor.set_block(RED_WOOL, x, ground_level + 6, z, None, None);
|
||||
|
||||
if args.winter {
|
||||
editor.set_block(SNOW_LAYER, x, ground_level + 7, z, None, None);
|
||||
}
|
||||
editor.set_block(GREEN_WOOL, x, 4, z, None, None);
|
||||
editor.set_block(YELLOW_WOOL, x, 5, z, None, None);
|
||||
editor.set_block(RED_WOOL, x, 6, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if highway_type == "bus_stop" {
|
||||
// Handle bus stops
|
||||
if let ProcessedElement::Node(node) = element {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
for y in 1..=3 {
|
||||
editor.set_block(COBBLESTONE_WALL, x, ground_level + y, z, None, None);
|
||||
let x = node.x;
|
||||
let z = node.z;
|
||||
for dy in 1..=3 {
|
||||
editor.set_block(COBBLESTONE_WALL, x, dy, z, None, None);
|
||||
}
|
||||
|
||||
editor.set_block(WHITE_WOOL, x, ground_level + 4, z, None, None);
|
||||
editor.set_block(WHITE_WOOL, x + 1, ground_level + 4, z, None, None);
|
||||
editor.set_block(WHITE_WOOL, x, 4, z, None, None);
|
||||
editor.set_block(WHITE_WOOL, x + 1, 4, z, None, None);
|
||||
}
|
||||
} else if element
|
||||
.tags()
|
||||
.get("area")
|
||||
.map_or(false, |v: &String| v == "yes")
|
||||
.is_some_and(|v: &String| v == "yes")
|
||||
{
|
||||
let ProcessedElement::Way(way) = element else {
|
||||
return;
|
||||
@@ -75,14 +69,8 @@ pub fn generate_highways(
|
||||
"wood" => OAK_PLANKS,
|
||||
"asphalt" => BLACK_CONCRETE,
|
||||
"gravel" | "fine_gravel" => GRAVEL,
|
||||
"grass" => {
|
||||
if args.winter {
|
||||
SNOW_BLOCK
|
||||
} else {
|
||||
GRASS_BLOCK
|
||||
}
|
||||
}
|
||||
"dirt" => DIRT,
|
||||
"grass" => GRASS_BLOCK,
|
||||
"dirt" | "ground" | "earth" => DIRT,
|
||||
"sand" => SAND,
|
||||
"concrete" => LIGHT_GRAY_CONCRETE,
|
||||
_ => STONE, // Default to stone for unknown surfaces
|
||||
@@ -99,13 +87,15 @@ pub fn generate_highways(
|
||||
flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
for (x, z) in filled_area {
|
||||
editor.set_block(surface_block, x, ground_level, z, None, None);
|
||||
editor.set_block(surface_block, x, 0, z, None, None);
|
||||
}
|
||||
} else {
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
let mut block_type = BLACK_CONCRETE;
|
||||
let mut block_range: i32 = 2;
|
||||
let mut add_stripe = false;
|
||||
let mut add_outline = false;
|
||||
let scale_factor = args.scale;
|
||||
|
||||
// Skip if 'layer' or 'level' is negative in the tags
|
||||
if let Some(layer) = element.tags().get("layer") {
|
||||
@@ -127,12 +117,15 @@ pub fn generate_highways(
|
||||
block_range = 1;
|
||||
}
|
||||
"path" => {
|
||||
block_type = LIGHT_GRAY_CONCRETE;
|
||||
block_type = DIRT_PATH;
|
||||
block_range = 1;
|
||||
}
|
||||
"motorway" | "primary" => {
|
||||
block_range = 5;
|
||||
add_stripe = true; // Add stripes for motorways and primary roads
|
||||
add_stripe = true;
|
||||
}
|
||||
"tertiary" => {
|
||||
add_stripe = true;
|
||||
}
|
||||
"track" => {
|
||||
block_range = 1;
|
||||
@@ -141,14 +134,32 @@ pub fn generate_highways(
|
||||
block_type = GRAY_CONCRETE;
|
||||
block_range = 2;
|
||||
}
|
||||
"secondary_link" | "tertiary_link" => {
|
||||
//Exit ramps, sliproads
|
||||
block_type = BLACK_CONCRETE;
|
||||
block_range = 1;
|
||||
}
|
||||
"escape" => {
|
||||
// Sand trap for vehicles on mountainous roads
|
||||
block_type = SAND;
|
||||
block_range = 1;
|
||||
}
|
||||
"steps" => {
|
||||
//TODO: Add correct stairs respecting height, step_count, etc.
|
||||
block_type = GRAY_CONCRETE;
|
||||
block_range = 1;
|
||||
}
|
||||
|
||||
_ => {
|
||||
if let Some(lanes) = element.tags().get("lanes") {
|
||||
if lanes == "2" {
|
||||
block_range = 3;
|
||||
add_stripe = true;
|
||||
add_outline = true;
|
||||
} else if lanes != "1" {
|
||||
block_range = 4;
|
||||
add_stripe = true;
|
||||
add_outline = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,6 +169,10 @@ pub fn generate_highways(
|
||||
return;
|
||||
};
|
||||
|
||||
if scale_factor < 1.0 {
|
||||
block_range = ((block_range as f64) * scale_factor).floor() as i32;
|
||||
}
|
||||
|
||||
// Iterate over nodes to create the highway
|
||||
for node in &way.nodes {
|
||||
if let Some(prev) = previous_node {
|
||||
@@ -166,13 +181,15 @@ pub fn generate_highways(
|
||||
let z2: i32 = node.z;
|
||||
|
||||
// Generate the line of coordinates between the two nodes
|
||||
// we don't care about the y because it's going to get overwritten
|
||||
// I'm not sure if we'll keep it this way
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(x1, ground_level, z1, x2, ground_level, z2);
|
||||
bresenham_line(x1, 0, z1, x2, 0, z2);
|
||||
|
||||
// Variables to manage dashed line pattern
|
||||
let mut stripe_length: i32 = 0;
|
||||
let dash_length: i32 = 5; // Length of the solid part of the stripe
|
||||
let gap_length: i32 = 5; // Length of the gap part of the stripe
|
||||
let dash_length: i32 = (5.0 * scale_factor).ceil() as i32; // Length of the solid part of the stripe
|
||||
let gap_length: i32 = (5.0 * scale_factor).ceil() as i32; // Length of the gap part of the stripe
|
||||
|
||||
for (x, _, z) in bresenham_points {
|
||||
// Draw the road surface for the entire width
|
||||
@@ -192,7 +209,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
WHITE_CONCRETE,
|
||||
set_x,
|
||||
ground_level,
|
||||
0,
|
||||
set_z,
|
||||
Some(&[BLACK_CONCRETE]),
|
||||
None,
|
||||
@@ -201,7 +218,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
BLACK_CONCRETE,
|
||||
set_x,
|
||||
ground_level,
|
||||
0,
|
||||
set_z,
|
||||
None,
|
||||
None,
|
||||
@@ -211,7 +228,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
WHITE_CONCRETE,
|
||||
set_x,
|
||||
ground_level,
|
||||
0,
|
||||
set_z,
|
||||
Some(&[BLACK_CONCRETE]),
|
||||
None,
|
||||
@@ -220,7 +237,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
BLACK_CONCRETE,
|
||||
set_x,
|
||||
ground_level,
|
||||
0,
|
||||
set_z,
|
||||
None,
|
||||
None,
|
||||
@@ -230,7 +247,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
block_type,
|
||||
set_x,
|
||||
ground_level,
|
||||
0,
|
||||
set_z,
|
||||
None,
|
||||
Some(&[BLACK_CONCRETE, WHITE_CONCRETE]),
|
||||
@@ -239,6 +256,36 @@ pub fn generate_highways(
|
||||
}
|
||||
}
|
||||
|
||||
// Add light gray concrete outline for multi-lane roads
|
||||
if add_outline {
|
||||
// Left outline
|
||||
for dz in -block_range..=block_range {
|
||||
let outline_x = x - block_range - 1;
|
||||
let outline_z = z + dz;
|
||||
editor.set_block(
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
outline_x,
|
||||
0,
|
||||
outline_z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
// Right outline
|
||||
for dz in -block_range..=block_range {
|
||||
let outline_x = x + block_range + 1;
|
||||
let outline_z = z + dz;
|
||||
editor.set_block(
|
||||
LIGHT_GRAY_CONCRETE,
|
||||
outline_x,
|
||||
0,
|
||||
outline_z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Add a dashed white line in the middle for larger roads
|
||||
if add_stripe {
|
||||
if stripe_length < dash_length {
|
||||
@@ -247,7 +294,7 @@ pub fn generate_highways(
|
||||
editor.set_block(
|
||||
WHITE_CONCRETE,
|
||||
stripe_x,
|
||||
ground_level,
|
||||
0,
|
||||
stripe_z,
|
||||
Some(&[BLACK_CONCRETE]),
|
||||
None,
|
||||
@@ -269,31 +316,58 @@ pub fn generate_highways(
|
||||
}
|
||||
|
||||
/// Generates a siding using stone brick slabs
|
||||
pub fn generate_siding(editor: &mut WorldEditor, element: &ProcessedWay, ground_level: i32) {
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
pub fn generate_siding(editor: &mut WorldEditor, element: &ProcessedWay) {
|
||||
let mut previous_node: Option<XZPoint> = None;
|
||||
let siding_block: Block = STONE_BRICK_SLAB;
|
||||
|
||||
for node in &element.nodes {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
let current_node = node.xz();
|
||||
|
||||
// Draw the siding using Bresenham's line algorithm between nodes
|
||||
if let Some(prev) = previous_node {
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level + 1, prev.1, x, ground_level + 1, z);
|
||||
for (bx, by, bz) in bresenham_points {
|
||||
if !editor.check_for_block(
|
||||
bx,
|
||||
by - 1,
|
||||
bz,
|
||||
None,
|
||||
Some(&[BLACK_CONCRETE, WHITE_CONCRETE]),
|
||||
) {
|
||||
editor.set_block(siding_block, bx, by, bz, None, None);
|
||||
if let Some(prev_node) = previous_node {
|
||||
let bresenham_points: Vec<(i32, i32, i32)> = bresenham_line(
|
||||
prev_node.x,
|
||||
0,
|
||||
prev_node.z,
|
||||
current_node.x,
|
||||
0,
|
||||
current_node.z,
|
||||
);
|
||||
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
if !editor.check_for_block(bx, 0, bz, Some(&[BLACK_CONCRETE, WHITE_CONCRETE])) {
|
||||
editor.set_block(siding_block, bx, 1, bz, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
previous_node = Some((x, z));
|
||||
previous_node = Some(current_node);
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates an aeroway
|
||||
pub fn generate_aeroway(editor: &mut WorldEditor, way: &ProcessedWay, args: &Args) {
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
let surface_block = LIGHT_GRAY_CONCRETE;
|
||||
|
||||
for node in &way.nodes {
|
||||
if let Some(prev) = previous_node {
|
||||
let (x1, z1) = prev;
|
||||
let x2 = node.x;
|
||||
let z2 = node.z;
|
||||
let points = bresenham_line(x1, 0, z1, x2, 0, z2);
|
||||
let way_width: i32 = (12.0 * args.scale).ceil() as i32;
|
||||
|
||||
for (x, _, z) in points {
|
||||
for dx in -way_width..=way_width {
|
||||
for dz in -way_width..=way_width {
|
||||
let set_x = x + dx;
|
||||
let set_z = z + dz;
|
||||
editor.set_block(surface_block, set_x, 0, set_z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
previous_node = Some((node.x, node.z));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,373 +1,308 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::element_processing::tree::create_tree;
|
||||
use crate::element_processing::tree::Tree;
|
||||
use crate::floodfill::flood_fill_area;
|
||||
use crate::osm_parser::ProcessedWay;
|
||||
use crate::osm_parser::{ProcessedMemberRole, ProcessedRelation, ProcessedWay};
|
||||
use crate::world_editor::WorldEditor;
|
||||
use rand::Rng;
|
||||
|
||||
pub fn generate_landuse(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedWay,
|
||||
ground_level: i32,
|
||||
args: &Args,
|
||||
) {
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
let mut corner_addup: (i32, i32, i32) = (0, 0, 0);
|
||||
let mut current_landuse: Vec<(i32, i32)> = vec![];
|
||||
|
||||
pub fn generate_landuse(editor: &mut WorldEditor, element: &ProcessedWay, args: &Args) {
|
||||
// Determine block type based on landuse tag
|
||||
let binding: String = "".to_string();
|
||||
let landuse_tag: &String = element.tags.get("landuse").unwrap_or(&binding);
|
||||
|
||||
let block_type = match landuse_tag.as_str() {
|
||||
"greenfield" | "meadow" | "grass" => {
|
||||
if args.winter {
|
||||
SNOW_BLOCK
|
||||
} else {
|
||||
GRASS_BLOCK
|
||||
}
|
||||
}
|
||||
"greenfield" | "meadow" | "grass" | "orchard" | "forest" => GRASS_BLOCK,
|
||||
"farmland" => FARMLAND,
|
||||
"forest" => {
|
||||
if args.winter {
|
||||
SNOW_BLOCK
|
||||
} else {
|
||||
"cemetery" => PODZOL,
|
||||
"construction" => COARSE_DIRT,
|
||||
"traffic_island" => STONE_BLOCK_SLAB,
|
||||
"residential" => {
|
||||
let residential_tag = element.tags.get("residential").unwrap_or(&binding);
|
||||
if residential_tag == "rural" {
|
||||
GRASS_BLOCK
|
||||
} else {
|
||||
STONE_BRICKS
|
||||
}
|
||||
}
|
||||
"cemetery" => PODZOL,
|
||||
"beach" => SAND,
|
||||
"construction" => DIRT,
|
||||
"traffic_island" => STONE_BLOCK_SLAB,
|
||||
"residential" => STONE_BRICKS,
|
||||
"commercial" => SMOOTH_STONE,
|
||||
"education" => LIGHT_GRAY_CONCRETE,
|
||||
"education" => POLISHED_ANDESITE,
|
||||
"religious" => POLISHED_ANDESITE,
|
||||
"industrial" => COBBLESTONE,
|
||||
"military" => GRAY_CONCRETE,
|
||||
"railway" => GRAVEL,
|
||||
_ => {
|
||||
if args.winter {
|
||||
SNOW_BLOCK
|
||||
"landfill" => {
|
||||
// Gravel if man_made = spoil_heap or heap, coarse dirt else
|
||||
let manmade_tag = element.tags.get("man_made").unwrap_or(&binding);
|
||||
if manmade_tag == "spoil_heap" || manmade_tag == "heap" {
|
||||
GRAVEL
|
||||
} else {
|
||||
GRASS_BLOCK
|
||||
COARSE_DIRT
|
||||
}
|
||||
}
|
||||
"quarry" => STONE,
|
||||
_ => GRASS_BLOCK,
|
||||
};
|
||||
|
||||
let bresenham_block: Block = if args.winter { SNOW_BLOCK } else { GRASS_BLOCK };
|
||||
// Get the area of the landuse element
|
||||
let polygon_coords: Vec<(i32, i32)> = element.nodes.iter().map(|n| (n.x, n.z)).collect();
|
||||
let floor_area: Vec<(i32, i32)> = flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
// Process landuse nodes to fill the area
|
||||
for node in &element.nodes {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
|
||||
|
||||
if let Some(prev) = previous_node {
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level, prev.1, x, ground_level, z);
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
editor.set_block(bresenham_block, bx, ground_level, bz, None, None);
|
||||
}
|
||||
|
||||
current_landuse.push((x, z));
|
||||
corner_addup = (corner_addup.0 + x, corner_addup.1 + z, corner_addup.2 + 1);
|
||||
for (x, z) in floor_area {
|
||||
if landuse_tag == "traffic_island" {
|
||||
editor.set_block(block_type, x, 1, z, None, None);
|
||||
} else if landuse_tag == "construction" || landuse_tag == "railway" {
|
||||
editor.set_block(block_type, x, 0, z, None, Some(&[SPONGE]));
|
||||
} else {
|
||||
editor.set_block(block_type, x, 0, z, None, None);
|
||||
}
|
||||
|
||||
previous_node = Some((x, z));
|
||||
}
|
||||
|
||||
// If there are landuse nodes, flood-fill the area
|
||||
if !current_landuse.is_empty() {
|
||||
let polygon_coords: Vec<(i32, i32)> = element.nodes.iter().map(|n| (n.x, n.z)).collect();
|
||||
let floor_area: Vec<(i32, i32)> = flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
|
||||
|
||||
for (x, z) in floor_area {
|
||||
if landuse_tag == "traffic_island" {
|
||||
editor.set_block(block_type, x, ground_level + 1, z, None, None);
|
||||
} else if landuse_tag == "construction" || landuse_tag == "railway" {
|
||||
editor.set_block(block_type, x, ground_level, z, None, Some(&[SPONGE]));
|
||||
} else {
|
||||
editor.set_block(block_type, x, ground_level, z, None, None);
|
||||
}
|
||||
|
||||
// Add specific features for different landuse types
|
||||
match landuse_tag.as_str() {
|
||||
"cemetery" => {
|
||||
if (x % 3 == 0) && (z % 3 == 0) {
|
||||
let random_choice: i32 = rng.gen_range(0..100);
|
||||
if random_choice < 15 {
|
||||
// Place graves
|
||||
if editor.check_for_block(x, ground_level, z, Some(&[PODZOL]), None) {
|
||||
if rng.gen_bool(0.5) {
|
||||
editor.set_block(
|
||||
COBBLESTONE,
|
||||
x - 1,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x - 1,
|
||||
ground_level + 2,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x + 1,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
} else {
|
||||
editor.set_block(
|
||||
COBBLESTONE,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z - 1,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 2,
|
||||
z - 1,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
editor.set_block(
|
||||
STONE_BRICK_SLAB,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z + 1,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if random_choice < 30 {
|
||||
if editor.check_for_block(x, ground_level, z, Some(&[PODZOL]), None) {
|
||||
editor.set_block(RED_FLOWER, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
} else if random_choice < 33 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
"forest" => {
|
||||
if !editor.check_for_block(x, ground_level, z, None, Some(&[WATER])) {
|
||||
let random_choice: i32 = rng.gen_range(0..21);
|
||||
if random_choice == 20 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
} else if random_choice == 2 {
|
||||
let flower_block: Block = match rng.gen_range(1..=4) {
|
||||
1 => RED_FLOWER,
|
||||
2 => BLUE_FLOWER,
|
||||
3 => YELLOW_FLOWER,
|
||||
_ => WHITE_FLOWER,
|
||||
};
|
||||
editor.set_block(flower_block, x, ground_level + 1, z, None, None);
|
||||
} else if random_choice <= 1 {
|
||||
editor.set_block(GRASS, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
"farmland" => {
|
||||
// Check if the current block is not water or another undesired block
|
||||
if !editor.check_for_block(x, ground_level, z, None, Some(&[WATER])) {
|
||||
if x % 15 == 0 || z % 15 == 0 {
|
||||
// Place water on the edges
|
||||
editor.set_block(WATER, x, ground_level, z, Some(&[FARMLAND]), None);
|
||||
editor.set_block(
|
||||
AIR,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
Some(&[GRASS, WHEAT, CARROTS, POTATOES]),
|
||||
None,
|
||||
);
|
||||
} else {
|
||||
// Set the block below as farmland
|
||||
editor.set_block(FARMLAND, x, ground_level, z, None, None);
|
||||
|
||||
// If a random condition is met, place a special object
|
||||
if rng.gen_range(0..76) == 0 {
|
||||
let special_choice: i32 = rng.gen_range(1..=10);
|
||||
if special_choice <= 2 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
} else if special_choice <= 6 {
|
||||
editor.set_block(HAY_BALE, x, ground_level + 1, z, None, None);
|
||||
} else {
|
||||
editor.set_block(
|
||||
OAK_LEAVES,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
// Add specific features for different landuse types
|
||||
match landuse_tag.as_str() {
|
||||
"cemetery" => {
|
||||
if (x % 3 == 0) && (z % 3 == 0) {
|
||||
let random_choice: i32 = rng.gen_range(0..100);
|
||||
if random_choice < 15 {
|
||||
// Place graves
|
||||
if editor.check_for_block(x, 0, z, Some(&[PODZOL])) {
|
||||
if rng.gen_bool(0.5) {
|
||||
editor.set_block(COBBLESTONE, x - 1, 1, z, None, None);
|
||||
editor.set_block(STONE_BRICK_SLAB, x - 1, 2, z, None, None);
|
||||
editor.set_block(STONE_BRICK_SLAB, x, 1, z, None, None);
|
||||
editor.set_block(STONE_BRICK_SLAB, x + 1, 1, z, None, None);
|
||||
} else {
|
||||
// Set crops only if the block below is farmland
|
||||
if editor.check_for_block(
|
||||
x,
|
||||
ground_level,
|
||||
z,
|
||||
Some(&[FARMLAND]),
|
||||
None,
|
||||
) {
|
||||
let crop_choice =
|
||||
[WHEAT, CARROTS, POTATOES][rng.gen_range(0..3)];
|
||||
editor.set_block(
|
||||
crop_choice,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
editor.set_block(COBBLESTONE, x, 1, z - 1, None, None);
|
||||
editor.set_block(STONE_BRICK_SLAB, x, 2, z - 1, None, None);
|
||||
editor.set_block(STONE_BRICK_SLAB, x, 1, z, None, None);
|
||||
editor.set_block(STONE_BRICK_SLAB, x, 1, z + 1, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"construction" => {
|
||||
let random_choice: i32 = rng.gen_range(0..1501);
|
||||
if random_choice < 6 {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 1, z, None, None);
|
||||
if random_choice < 2 {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 3, z, None, None);
|
||||
} else if random_choice < 4 {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 3, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 4, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 1, z + 1, None, None);
|
||||
} else {
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 3, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 4, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, ground_level + 5, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x - 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(
|
||||
SCAFFOLDING,
|
||||
x + 1,
|
||||
ground_level + 1,
|
||||
z - 1,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
} else if random_choice < 30 {
|
||||
let construction_items: [Block; 11] = [
|
||||
OAK_LOG,
|
||||
COBBLESTONE,
|
||||
GRAVEL,
|
||||
GLOWSTONE,
|
||||
STONE,
|
||||
COBBLESTONE_WALL,
|
||||
BLACK_CONCRETE,
|
||||
SAND,
|
||||
OAK_PLANKS,
|
||||
DIRT,
|
||||
BRICK,
|
||||
];
|
||||
editor.set_block(
|
||||
construction_items[rng.gen_range(0..construction_items.len())],
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
if editor.check_for_block(x, 0, z, Some(&[PODZOL])) {
|
||||
editor.set_block(RED_FLOWER, x, 1, z, None, None);
|
||||
}
|
||||
} else if random_choice < 33 {
|
||||
Tree::create(editor, (x, 1, z));
|
||||
} else if random_choice < 35 {
|
||||
if random_choice < 30 {
|
||||
editor.set_block(DIRT, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(DIRT, x + 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 1, z + 1, None, None);
|
||||
} else {
|
||||
editor.set_block(DIRT, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(DIRT, x - 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(DIRT, x, ground_level + 1, z - 1, None, None);
|
||||
}
|
||||
} else if random_choice < 150 {
|
||||
editor.set_block(AIR, x, ground_level, z, None, Some(&[SPONGE]));
|
||||
editor.set_block(OAK_LEAVES, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"grass" => {
|
||||
if rng.gen_range(1..=7) != 1
|
||||
&& !editor.check_for_block(x, ground_level, z, None, Some(&[WATER]))
|
||||
{
|
||||
editor.set_block(GRASS, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"meadow" => {
|
||||
if !editor.check_for_block(x, ground_level, z, None, Some(&[WATER])) {
|
||||
let random_choice: i32 = rng.gen_range(0..1001);
|
||||
if random_choice < 5 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
} else if random_choice < 800 {
|
||||
editor.set_block(GRASS, x, ground_level + 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
"forest" => {
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
let random_choice: i32 = rng.gen_range(0..30);
|
||||
if random_choice == 20 {
|
||||
Tree::create(editor, (x, 1, z));
|
||||
} else if random_choice == 2 {
|
||||
let flower_block: Block = match rng.gen_range(1..=5) {
|
||||
1 => OAK_LEAVES,
|
||||
2 => RED_FLOWER,
|
||||
3 => BLUE_FLOWER,
|
||||
4 => YELLOW_FLOWER,
|
||||
_ => WHITE_FLOWER,
|
||||
};
|
||||
editor.set_block(flower_block, x, 1, z, None, None);
|
||||
} else if random_choice <= 12 {
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
"farmland" => {
|
||||
// Check if the current block is not water or another undesired block
|
||||
if !editor.check_for_block(x, 0, z, Some(&[WATER])) {
|
||||
if x % 9 == 0 && z % 9 == 0 {
|
||||
// Place water in dot pattern
|
||||
editor.set_block(WATER, x, 0, z, Some(&[FARMLAND]), None);
|
||||
} else if rng.gen_range(0..76) == 0 {
|
||||
let special_choice: i32 = rng.gen_range(1..=10);
|
||||
if special_choice <= 4 {
|
||||
editor.set_block(HAY_BALE, x, 1, z, None, Some(&[SPONGE]));
|
||||
} else {
|
||||
editor.set_block(OAK_LEAVES, x, 1, z, None, Some(&[SPONGE]));
|
||||
}
|
||||
} else {
|
||||
// Set crops only if the block below is farmland
|
||||
if editor.check_for_block(x, 0, z, Some(&[FARMLAND])) {
|
||||
let crop_choice = [WHEAT, CARROTS, POTATOES][rng.gen_range(0..3)];
|
||||
editor.set_block(crop_choice, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"construction" => {
|
||||
let random_choice: i32 = rng.gen_range(0..1501);
|
||||
if random_choice < 15 {
|
||||
editor.set_block(SCAFFOLDING, x, 1, z, None, None);
|
||||
if random_choice < 2 {
|
||||
editor.set_block(SCAFFOLDING, x, 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, 3, z, None, None);
|
||||
} else if random_choice < 4 {
|
||||
editor.set_block(SCAFFOLDING, x, 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, 3, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, 4, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, 1, z + 1, None, None);
|
||||
} else {
|
||||
editor.set_block(SCAFFOLDING, x, 2, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, 3, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, 4, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x, 5, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x - 1, 1, z, None, None);
|
||||
editor.set_block(SCAFFOLDING, x + 1, 1, z - 1, None, None);
|
||||
}
|
||||
} else if random_choice < 55 {
|
||||
let construction_items: [Block; 13] = [
|
||||
OAK_LOG,
|
||||
COBBLESTONE,
|
||||
GRAVEL,
|
||||
GLOWSTONE,
|
||||
STONE,
|
||||
COBBLESTONE_WALL,
|
||||
BLACK_CONCRETE,
|
||||
SAND,
|
||||
OAK_PLANKS,
|
||||
DIRT,
|
||||
BRICK,
|
||||
CRAFTING_TABLE,
|
||||
FURNACE,
|
||||
];
|
||||
editor.set_block(
|
||||
construction_items[rng.gen_range(0..construction_items.len())],
|
||||
x,
|
||||
1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
} else if random_choice < 65 {
|
||||
if random_choice < 60 {
|
||||
editor.set_block(DIRT, x, 1, z, None, None);
|
||||
editor.set_block(DIRT, x, 2, z, None, None);
|
||||
editor.set_block(DIRT, x + 1, 1, z, None, None);
|
||||
editor.set_block(DIRT, x, 1, z + 1, None, None);
|
||||
} else {
|
||||
editor.set_block(DIRT, x, 1, z, None, None);
|
||||
editor.set_block(DIRT, x, 2, z, None, None);
|
||||
editor.set_block(DIRT, x - 1, 1, z, None, None);
|
||||
editor.set_block(DIRT, x, 1, z - 1, None, None);
|
||||
}
|
||||
} else if random_choice < 100 {
|
||||
editor.set_block(GRAVEL, x, 0, z, None, Some(&[SPONGE]));
|
||||
} else if random_choice < 115 {
|
||||
editor.set_block(SAND, x, 0, z, None, Some(&[SPONGE]));
|
||||
} else if random_choice < 125 {
|
||||
editor.set_block(DIORITE, x, 0, z, None, Some(&[SPONGE]));
|
||||
} else if random_choice < 145 {
|
||||
editor.set_block(BRICK, x, 0, z, None, Some(&[SPONGE]));
|
||||
} else if random_choice < 155 {
|
||||
editor.set_block(GRANITE, x, 0, z, None, Some(&[SPONGE]));
|
||||
} else if random_choice < 180 {
|
||||
editor.set_block(ANDESITE, x, 0, z, None, Some(&[SPONGE]));
|
||||
} else if random_choice < 565 {
|
||||
editor.set_block(COBBLESTONE, x, 0, z, None, Some(&[SPONGE]));
|
||||
}
|
||||
}
|
||||
"grass" => {
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
match rng.gen_range(0..200) {
|
||||
0 => editor.set_block(OAK_LEAVES, x, 1, z, None, None),
|
||||
1..=170 => editor.set_block(GRASS, x, 1, z, None, None),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
"greenfield" => {
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
match rng.gen_range(0..200) {
|
||||
0 => editor.set_block(OAK_LEAVES, x, 1, z, None, None),
|
||||
1..=17 => editor.set_block(GRASS, x, 1, z, None, None),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
"meadow" => {
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
let random_choice: i32 = rng.gen_range(0..1001);
|
||||
if random_choice < 5 {
|
||||
Tree::create(editor, (x, 1, z));
|
||||
} else if random_choice < 6 {
|
||||
editor.set_block(RED_FLOWER, x, 1, z, None, None);
|
||||
} else if random_choice < 9 {
|
||||
editor.set_block(OAK_LEAVES, x, 1, z, None, None);
|
||||
} else if random_choice < 800 {
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
"orchard" => {
|
||||
if x % 18 == 0 && z % 10 == 0 {
|
||||
Tree::create(editor, (x, 1, z));
|
||||
} else if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
match rng.gen_range(0..100) {
|
||||
0 => editor.set_block(OAK_LEAVES, x, 1, z, None, None),
|
||||
1..=20 => editor.set_block(GRASS, x, 1, z, None, None),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
"quarry" => {
|
||||
// Add stone layer under it
|
||||
editor.set_block(STONE, x, -1, z, Some(&[STONE]), None);
|
||||
editor.set_block(STONE, x, -2, z, Some(&[STONE]), None);
|
||||
// Generate ore blocks
|
||||
if let Some(resource) = element.tags.get("resource") {
|
||||
let ore_block = match resource.as_str() {
|
||||
"iron_ore" => IRON_ORE,
|
||||
"coal" => COAL_ORE,
|
||||
"copper" => COPPER_ORE,
|
||||
"gold" => GOLD_ORE,
|
||||
"clay" | "kaolinite" => CLAY,
|
||||
_ => STONE,
|
||||
};
|
||||
let random_choice: i32 = rng.gen_range(0..100 + editor.get_absolute_y(x, 0, z)); // The deeper it is the more resources are there
|
||||
if random_choice < 5 {
|
||||
editor.set_block(ore_block, x, 0, z, Some(&[STONE]), None);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_landuse_from_relation(
|
||||
editor: &mut WorldEditor,
|
||||
rel: &ProcessedRelation,
|
||||
args: &Args,
|
||||
) {
|
||||
if rel.tags.contains_key("landuse") {
|
||||
// Generate individual ways with their original tags
|
||||
for member in &rel.members {
|
||||
if member.role == ProcessedMemberRole::Outer {
|
||||
generate_landuse(editor, &member.way.clone(), args);
|
||||
}
|
||||
}
|
||||
|
||||
// Combine all outer ways into one with relation tags
|
||||
let mut combined_nodes = Vec::new();
|
||||
for member in &rel.members {
|
||||
if member.role == ProcessedMemberRole::Outer {
|
||||
combined_nodes.extend(member.way.nodes.clone());
|
||||
}
|
||||
}
|
||||
|
||||
// Only process if we have nodes
|
||||
if !combined_nodes.is_empty() {
|
||||
// Create combined way with relation tags
|
||||
let combined_way = ProcessedWay {
|
||||
id: rel.id,
|
||||
nodes: combined_nodes,
|
||||
tags: rel.tags.clone(),
|
||||
};
|
||||
|
||||
// Generate landuse area from combined way
|
||||
generate_landuse(editor, &combined_way, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::element_processing::tree::create_tree;
|
||||
use crate::element_processing::tree::Tree;
|
||||
use crate::floodfill::flood_fill_area;
|
||||
use crate::osm_parser::ProcessedWay;
|
||||
use crate::osm_parser::{ProcessedMemberRole, ProcessedRelation, ProcessedWay};
|
||||
use crate::world_editor::WorldEditor;
|
||||
use rand::Rng;
|
||||
|
||||
pub fn generate_leisure(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedWay,
|
||||
ground_level: i32,
|
||||
args: &Args,
|
||||
) {
|
||||
pub fn generate_leisure(editor: &mut WorldEditor, element: &ProcessedWay, args: &Args) {
|
||||
if let Some(leisure_type) = element.tags.get("leisure") {
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
let mut corner_addup: (i32, i32, i32) = (0, 0, 0);
|
||||
@@ -20,40 +15,30 @@ pub fn generate_leisure(
|
||||
|
||||
// Determine block type based on leisure type
|
||||
let block_type: Block = match leisure_type.as_str() {
|
||||
"park" => {
|
||||
if args.winter {
|
||||
SNOW_BLOCK
|
||||
} else {
|
||||
GRASS_BLOCK
|
||||
}
|
||||
"park" | "nature_reserve" | "garden" | "disc_golf_course" | "golf_course" => {
|
||||
GRASS_BLOCK
|
||||
}
|
||||
"playground" | "recreation_ground" | "pitch" => {
|
||||
"playground" | "recreation_ground" | "pitch" | "beach_resort" | "dog_park" => {
|
||||
if let Some(surface) = element.tags.get("surface") {
|
||||
match surface.as_str() {
|
||||
"clay" => TERRACOTTA,
|
||||
"sand" => SAND,
|
||||
"tartan" => RED_TERRACOTTA,
|
||||
"grass" => GRASS_BLOCK,
|
||||
"dirt" => DIRT,
|
||||
"pebblestone" | "cobblestone" | "unhewn_cobblestone" => COBBLESTONE,
|
||||
_ => GREEN_STAINED_HARDENED_CLAY,
|
||||
}
|
||||
} else {
|
||||
GREEN_STAINED_HARDENED_CLAY
|
||||
}
|
||||
}
|
||||
"garden" => {
|
||||
if args.winter {
|
||||
SNOW_BLOCK
|
||||
} else {
|
||||
GRASS_BLOCK
|
||||
}
|
||||
}
|
||||
"swimming_pool" => WATER,
|
||||
_ => {
|
||||
if args.winter {
|
||||
SNOW_BLOCK
|
||||
} else {
|
||||
GRASS_BLOCK
|
||||
}
|
||||
}
|
||||
"swimming_pool" | "swimming_area" => WATER, //Swimming area: Area in a larger body of water for swimming
|
||||
"bathing_place" => SMOOTH_SANDSTONE, // Could be sand or concrete
|
||||
"outdoor_seating" => SMOOTH_STONE, //Usually stone or stone bricks
|
||||
"water_park" | "slipway" => LIGHT_GRAY_CONCRETE, // Water park area, not the pool. Usually is concrete
|
||||
"ice_rink" => PACKED_ICE, // TODO: Ice for Ice Rink, needs building defined
|
||||
_ => GRASS_BLOCK,
|
||||
};
|
||||
|
||||
// Process leisure area nodes
|
||||
@@ -61,12 +46,12 @@ pub fn generate_leisure(
|
||||
if let Some(prev) = previous_node {
|
||||
// Draw a line between the current and previous node
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level, prev.1, node.x, ground_level, node.z);
|
||||
bresenham_line(prev.0, 0, prev.1, node.x, 0, node.z);
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
editor.set_block(
|
||||
block_type,
|
||||
bx,
|
||||
ground_level,
|
||||
0,
|
||||
bz,
|
||||
Some(&[
|
||||
GRASS_BLOCK,
|
||||
@@ -99,46 +84,37 @@ pub fn generate_leisure(
|
||||
flood_fill_area(&polygon_coords, args.timeout.as_ref());
|
||||
|
||||
for (x, z) in filled_area {
|
||||
editor.set_block(block_type, x, ground_level, z, Some(&[GRASS_BLOCK]), None);
|
||||
editor.set_block(block_type, x, 0, z, Some(&[GRASS_BLOCK]), None);
|
||||
|
||||
// Add decorative elements for parks and gardens
|
||||
if matches!(leisure_type.as_str(), "park" | "garden")
|
||||
&& editor.check_for_block(x, ground_level, z, Some(&[GRASS_BLOCK]), None)
|
||||
if matches!(leisure_type.as_str(), "park" | "garden" | "nature_reserve")
|
||||
&& editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK]))
|
||||
{
|
||||
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
|
||||
let random_choice: i32 = rng.gen_range(0..1000);
|
||||
|
||||
match random_choice {
|
||||
0 => {
|
||||
// Benches
|
||||
editor.set_block(OAK_LOG, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(OAK_LOG, x + 1, ground_level + 1, z, None, None);
|
||||
editor.set_block(OAK_LOG, x - 1, ground_level + 1, z, None, None);
|
||||
}
|
||||
1..=30 => {
|
||||
0..30 => {
|
||||
// Flowers
|
||||
let flower_choice = match rng.gen_range(0..4) {
|
||||
0 => RED_FLOWER,
|
||||
1 => YELLOW_FLOWER,
|
||||
2 => BLUE_FLOWER,
|
||||
let flower_choice = match random_choice {
|
||||
0..10 => RED_FLOWER,
|
||||
10..20 => YELLOW_FLOWER,
|
||||
20..30 => BLUE_FLOWER,
|
||||
_ => WHITE_FLOWER,
|
||||
};
|
||||
editor.set_block(flower_choice, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(flower_choice, x, 1, z, None, None);
|
||||
}
|
||||
31..=70 => {
|
||||
30..90 => {
|
||||
// Grass
|
||||
editor.set_block(GRASS, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
71..=80 => {
|
||||
90..105 => {
|
||||
// Oak leaves
|
||||
editor.set_block(OAK_LEAVES, x, 1, z, None, None);
|
||||
}
|
||||
105..120 => {
|
||||
// Tree
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
Tree::create(editor, (x, 1, z));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -150,36 +126,38 @@ pub fn generate_leisure(
|
||||
let random_choice: i32 = rng.gen_range(0..5000);
|
||||
|
||||
match random_choice {
|
||||
0..=10 => {
|
||||
0..10 => {
|
||||
// Swing set
|
||||
for y in 1..=4 {
|
||||
editor.set_block(OAK_FENCE, x - 1, ground_level + y, z, None, None);
|
||||
editor.set_block(OAK_FENCE, x + 1, ground_level + y, z, None, None);
|
||||
for y in 1..=3 {
|
||||
editor.set_block(OAK_FENCE, x - 1, y, z, None, None);
|
||||
editor.set_block(OAK_FENCE, x + 1, y, z, None, None);
|
||||
}
|
||||
editor.set_block(OAK_FENCE, x, ground_level + 4, z, None, None);
|
||||
editor.set_block(STONE_BLOCK_SLAB, x, ground_level + 2, z, None, None);
|
||||
editor.set_block(OAK_PLANKS, x - 1, 4, z, None, None);
|
||||
editor.set_block(OAK_SLAB, x, 4, z, None, None);
|
||||
editor.set_block(OAK_PLANKS, x + 1, 4, z, None, None);
|
||||
editor.set_block(STONE_BLOCK_SLAB, x, 2, z, None, None);
|
||||
}
|
||||
11..=20 => {
|
||||
10..20 => {
|
||||
// Slide
|
||||
editor.set_block(OAK_SLAB, x, ground_level + 1, z, None, None);
|
||||
editor.set_block(OAK_SLAB, x + 1, ground_level + 2, z, None, None);
|
||||
editor.set_block(OAK_SLAB, x + 2, ground_level + 3, z, None, None);
|
||||
editor.set_block(OAK_SLAB, x, 1, z, None, None);
|
||||
editor.set_block(OAK_SLAB, x + 1, 2, z, None, None);
|
||||
editor.set_block(OAK_SLAB, x + 2, 3, z, None, None);
|
||||
|
||||
editor.set_block(OAK_PLANKS, x + 2, ground_level + 2, z, None, None);
|
||||
editor.set_block(OAK_PLANKS, x + 2, ground_level + 1, z, None, None);
|
||||
editor.set_block(OAK_PLANKS, x + 2, 2, z, None, None);
|
||||
editor.set_block(OAK_PLANKS, x + 2, 1, z, None, None);
|
||||
|
||||
editor.set_block(LADDER, x + 2, ground_level + 2, z - 1, None, None);
|
||||
editor.set_block(LADDER, x + 2, ground_level + 1, z - 1, None, None);
|
||||
editor.set_block(LADDER, x + 2, 2, z - 1, None, None);
|
||||
editor.set_block(LADDER, x + 2, 1, z - 1, None, None);
|
||||
}
|
||||
21..=30 => {
|
||||
20..30 => {
|
||||
// Sandpit
|
||||
editor.fill_blocks(
|
||||
SAND,
|
||||
x - 3,
|
||||
ground_level,
|
||||
0,
|
||||
z - 3,
|
||||
x + 3,
|
||||
ground_level,
|
||||
0,
|
||||
z + 3,
|
||||
Some(&[GREEN_STAINED_HARDENED_CLAY]),
|
||||
None,
|
||||
@@ -192,3 +170,36 @@ pub fn generate_leisure(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_leisure_from_relation(
|
||||
editor: &mut WorldEditor,
|
||||
rel: &ProcessedRelation,
|
||||
args: &Args,
|
||||
) {
|
||||
if rel.tags.get("leisure") == Some(&"park".to_string()) {
|
||||
// First generate individual ways with their original tags
|
||||
for member in &rel.members {
|
||||
if member.role == ProcessedMemberRole::Outer {
|
||||
generate_leisure(editor, &member.way, args);
|
||||
}
|
||||
}
|
||||
|
||||
// Then combine all outer ways into one
|
||||
let mut combined_nodes = Vec::new();
|
||||
for member in &rel.members {
|
||||
if member.role == ProcessedMemberRole::Outer {
|
||||
combined_nodes.extend(member.way.nodes.clone());
|
||||
}
|
||||
}
|
||||
|
||||
// Create combined way with relation tags
|
||||
let combined_way = ProcessedWay {
|
||||
id: rel.id,
|
||||
nodes: combined_nodes,
|
||||
tags: rel.tags.clone(),
|
||||
};
|
||||
|
||||
// Generate leisure area from combined way
|
||||
generate_leisure(editor, &combined_way, args);
|
||||
}
|
||||
}
|
||||
|
||||
255
src/element_processing/man_made.rs
Normal file
@@ -0,0 +1,255 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::osm_parser::{ProcessedElement, ProcessedNode};
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_man_made(editor: &mut WorldEditor, element: &ProcessedElement, _args: &Args) {
|
||||
// Skip if 'layer' or 'level' is negative in the tags
|
||||
if let Some(layer) = element.tags().get("layer") {
|
||||
if layer.parse::<i32>().unwrap_or(0) < 0 {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(level) = element.tags().get("level") {
|
||||
if level.parse::<i32>().unwrap_or(0) < 0 {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(man_made_type) = element.tags().get("man_made") {
|
||||
match man_made_type.as_str() {
|
||||
"pier" => generate_pier(editor, element),
|
||||
"antenna" => generate_antenna(editor, element),
|
||||
"chimney" => generate_chimney(editor, element),
|
||||
"water_well" => generate_water_well(editor, element),
|
||||
"water_tower" => generate_water_tower(editor, element),
|
||||
_ => {} // Unknown man_made type, ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a pier structure with OAK_SLAB planks and OAK_LOG support pillars
|
||||
fn generate_pier(editor: &mut WorldEditor, element: &ProcessedElement) {
|
||||
if let ProcessedElement::Way(way) = element {
|
||||
let nodes = &way.nodes;
|
||||
if nodes.len() < 2 {
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract pier dimensions from tags
|
||||
let pier_width = element
|
||||
.tags()
|
||||
.get("width")
|
||||
.and_then(|w| w.parse::<i32>().ok())
|
||||
.unwrap_or(3); // Default 3 blocks wide
|
||||
|
||||
let pier_height = 1; // Pier deck height above ground
|
||||
let support_spacing = 4; // Support pillars every 4 blocks
|
||||
|
||||
// Generate the pier walkway using bresenham line algorithm
|
||||
for i in 0..nodes.len() - 1 {
|
||||
let start_node = &nodes[i];
|
||||
let end_node = &nodes[i + 1];
|
||||
|
||||
let line_points =
|
||||
bresenham_line(start_node.x, 0, start_node.z, end_node.x, 0, end_node.z);
|
||||
|
||||
for (index, (center_x, _y, center_z)) in line_points.iter().enumerate() {
|
||||
// Create pier deck (3 blocks wide)
|
||||
let half_width = pier_width / 2;
|
||||
for x in (center_x - half_width)..=(center_x + half_width) {
|
||||
for z in (center_z - half_width)..=(center_z + half_width) {
|
||||
editor.set_block(OAK_SLAB, x, pier_height, z, None, None);
|
||||
}
|
||||
}
|
||||
|
||||
// Add support pillars every few blocks
|
||||
if index % support_spacing == 0 {
|
||||
let half_width = pier_width / 2;
|
||||
|
||||
// Place support pillars at the edges of the pier
|
||||
let support_positions = [
|
||||
(center_x - half_width, center_z), // Left side
|
||||
(center_x + half_width, center_z), // Right side
|
||||
];
|
||||
|
||||
for (pillar_x, pillar_z) in support_positions {
|
||||
// Support pillars going down from pier level
|
||||
editor.set_block(OAK_LOG, pillar_x, 0, *pillar_z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate an antenna/radio tower
|
||||
fn generate_antenna(editor: &mut WorldEditor, element: &ProcessedElement) {
|
||||
if let Some(first_node) = element.nodes().next() {
|
||||
let x = first_node.x;
|
||||
let z = first_node.z;
|
||||
|
||||
// Extract antenna configuration from tags
|
||||
let height = match element.tags().get("height") {
|
||||
Some(h) => h.parse::<i32>().unwrap_or(20).min(40), // Max 40 blocks
|
||||
None => match element.tags().get("tower:type").map(|s| s.as_str()) {
|
||||
Some("communication") => 20,
|
||||
Some("transmission") => 25,
|
||||
Some("cellular") => 15,
|
||||
_ => 20,
|
||||
},
|
||||
};
|
||||
|
||||
// Build the main tower pole
|
||||
editor.set_block(IRON_BLOCK, x, 3, z, None, None);
|
||||
for y in 4..height {
|
||||
editor.set_block(IRON_BARS, x, y, z, None, None);
|
||||
}
|
||||
|
||||
// Add structural supports every 7 blocks
|
||||
for y in (7..height).step_by(7) {
|
||||
editor.set_block(IRON_BLOCK, x, y, z, Some(&[IRON_BARS]), None);
|
||||
let support_positions = [(1, 0), (-1, 0), (0, 1), (0, -1)];
|
||||
for (dx, dz) in support_positions {
|
||||
editor.set_block(IRON_BLOCK, x + dx, y, z + dz, None, None);
|
||||
}
|
||||
}
|
||||
|
||||
// Equipment housing at base
|
||||
editor.fill_blocks(
|
||||
GRAY_CONCRETE,
|
||||
x - 1,
|
||||
1,
|
||||
z - 1,
|
||||
x + 1,
|
||||
2,
|
||||
z + 1,
|
||||
Some(&[GRAY_CONCRETE]),
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a chimney structure
|
||||
fn generate_chimney(editor: &mut WorldEditor, element: &ProcessedElement) {
|
||||
if let Some(first_node) = element.nodes().next() {
|
||||
let x = first_node.x;
|
||||
let z = first_node.z;
|
||||
let height = 25;
|
||||
|
||||
// Build 3x3 brick chimney with hole in the middle
|
||||
for y in 0..height {
|
||||
for dx in -1..=1 {
|
||||
for dz in -1..=1 {
|
||||
// Skip center block to create hole
|
||||
if dx == 0 && dz == 0 {
|
||||
continue;
|
||||
}
|
||||
editor.set_block(BRICK, x + dx, y, z + dz, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a water well structure
|
||||
fn generate_water_well(editor: &mut WorldEditor, element: &ProcessedElement) {
|
||||
if let Some(first_node) = element.nodes().next() {
|
||||
let x = first_node.x;
|
||||
let z = first_node.z;
|
||||
|
||||
// Build stone well structure (3x3 base with water in center)
|
||||
for dx in -1..=1 {
|
||||
for dz in -1..=1 {
|
||||
if dx == 0 && dz == 0 {
|
||||
// Water in the center
|
||||
editor.set_block(WATER, x, -1, z, None, None);
|
||||
editor.set_block(WATER, x, 0, z, None, None);
|
||||
} else {
|
||||
// Stone well walls
|
||||
editor.set_block(STONE_BRICKS, x + dx, 0, z + dz, None, None);
|
||||
editor.set_block(STONE_BRICKS, x + dx, 1, z + dz, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add wooden well frame structure
|
||||
editor.fill_blocks(OAK_LOG, x - 2, 1, z, x - 2, 4, z, None, None);
|
||||
editor.fill_blocks(OAK_LOG, x + 2, 1, z, x + 2, 4, z, None, None);
|
||||
|
||||
// Crossbeam with pulley system
|
||||
editor.set_block(OAK_SLAB, x - 1, 5, z, None, None);
|
||||
editor.set_block(OAK_FENCE, x, 4, z, None, None);
|
||||
editor.set_block(OAK_SLAB, x, 5, z, None, None);
|
||||
editor.set_block(OAK_SLAB, x + 1, 5, z, None, None);
|
||||
|
||||
// Bucket hanging from center
|
||||
editor.set_block(IRON_BLOCK, x, 3, z, None, None);
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a water tower structure
|
||||
fn generate_water_tower(editor: &mut WorldEditor, element: &ProcessedElement) {
|
||||
if let Some(first_node) = element.nodes().next() {
|
||||
let x = first_node.x;
|
||||
let z = first_node.z;
|
||||
let tower_height = 20;
|
||||
let tank_height = 6;
|
||||
|
||||
// Build support legs (4 corner pillars)
|
||||
let leg_positions = [(-2, -2), (2, -2), (-2, 2), (2, 2)];
|
||||
for (dx, dz) in leg_positions {
|
||||
for y in 0..tower_height {
|
||||
editor.set_block(IRON_BLOCK, x + dx, y, z + dz, None, None);
|
||||
}
|
||||
}
|
||||
|
||||
// Add cross-bracing every 5 blocks for stability
|
||||
for y in (5..tower_height).step_by(5) {
|
||||
// Horizontal bracing
|
||||
for dx in -1..=1 {
|
||||
editor.set_block(SMOOTH_STONE, x + dx, y, z - 2, None, None);
|
||||
editor.set_block(SMOOTH_STONE, x + dx, y, z + 2, None, None);
|
||||
}
|
||||
for dz in -1..=1 {
|
||||
editor.set_block(SMOOTH_STONE, x - 2, y, z + dz, None, None);
|
||||
editor.set_block(SMOOTH_STONE, x + 2, y, z + dz, None, None);
|
||||
}
|
||||
}
|
||||
|
||||
// Build water tank at the top - simple rectangular tank
|
||||
editor.fill_blocks(
|
||||
POLISHED_ANDESITE,
|
||||
x - 3,
|
||||
tower_height,
|
||||
z - 3,
|
||||
x + 3,
|
||||
tower_height + tank_height,
|
||||
z + 3,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
// Add polished andesite pipe going down from the tank
|
||||
for y in 0..tower_height {
|
||||
editor.set_block(POLISHED_ANDESITE, x, y, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate man_made structures for node elements
|
||||
pub fn generate_man_made_nodes(editor: &mut WorldEditor, node: &ProcessedNode) {
|
||||
if let Some(man_made_type) = node.tags.get("man_made") {
|
||||
let element = ProcessedElement::Node(node.clone());
|
||||
|
||||
match man_made_type.as_str() {
|
||||
"antenna" => generate_antenna(editor, &element),
|
||||
"chimney" => generate_chimney(editor, &element),
|
||||
"water_well" => generate_water_well(editor, &element),
|
||||
"water_tower" => generate_water_tower(editor, &element),
|
||||
_ => {} // Unknown man_made type, ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,10 @@ pub mod doors;
|
||||
pub mod highways;
|
||||
pub mod landuse;
|
||||
pub mod leisure;
|
||||
pub mod man_made;
|
||||
pub mod natural;
|
||||
pub mod railways;
|
||||
pub mod subprocessor;
|
||||
pub mod tourisms;
|
||||
pub mod tree;
|
||||
pub mod water_areas;
|
||||
|
||||
@@ -1,64 +1,48 @@
|
||||
use crate::args::Args;
|
||||
use crate::block_definitions::*;
|
||||
use crate::bresenham::bresenham_line;
|
||||
use crate::element_processing::tree::create_tree;
|
||||
use crate::element_processing::tree::Tree;
|
||||
use crate::floodfill::flood_fill_area;
|
||||
use crate::osm_parser::ProcessedElement;
|
||||
use crate::osm_parser::{ProcessedElement, ProcessedMemberRole, ProcessedRelation, ProcessedWay};
|
||||
use crate::world_editor::WorldEditor;
|
||||
use rand::Rng;
|
||||
|
||||
pub fn generate_natural(
|
||||
editor: &mut WorldEditor,
|
||||
element: &ProcessedElement,
|
||||
ground_level: i32,
|
||||
args: &Args,
|
||||
) {
|
||||
pub fn generate_natural(editor: &mut WorldEditor, element: &ProcessedElement, args: &Args) {
|
||||
if let Some(natural_type) = element.tags().get("natural") {
|
||||
if natural_type == "tree" {
|
||||
if let ProcessedElement::Node(node) = element {
|
||||
let x: i32 = node.x;
|
||||
let z: i32 = node.z;
|
||||
|
||||
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
Tree::create(editor, (x, 1, z));
|
||||
}
|
||||
} else {
|
||||
let mut previous_node: Option<(i32, i32)> = None;
|
||||
let mut corner_addup: (i32, i32, i32) = (0, 0, 0);
|
||||
let mut current_natural: Vec<(i32, i32)> = vec![];
|
||||
let binding: String = "".to_string();
|
||||
|
||||
// Determine block type based on natural tag
|
||||
let block_type: Block = match natural_type.as_str() {
|
||||
"scrub" | "grassland" | "wood" => {
|
||||
if args.winter {
|
||||
SNOW_BLOCK
|
||||
} else {
|
||||
GRASS_BLOCK
|
||||
}
|
||||
}
|
||||
"beach" | "sand" => SAND,
|
||||
"tree_row" => {
|
||||
if args.winter {
|
||||
SNOW_BLOCK
|
||||
} else {
|
||||
GRASS_BLOCK
|
||||
}
|
||||
}
|
||||
"wetland" | "water" => WATER,
|
||||
_ => {
|
||||
if args.winter {
|
||||
SNOW_BLOCK
|
||||
} else {
|
||||
GRASS_BLOCK
|
||||
"scrub" | "grassland" | "wood" | "heath" | "tree_row" => GRASS_BLOCK,
|
||||
"sand" | "dune" => SAND,
|
||||
"beach" | "shoal" => {
|
||||
let surface = element.tags().get("natural").unwrap_or(&binding);
|
||||
match surface.as_str() {
|
||||
"gravel" => GRAVEL,
|
||||
_ => SAND,
|
||||
}
|
||||
}
|
||||
"water" | "reef" => WATER,
|
||||
"bare_rock" => STONE,
|
||||
"blockfield" => COBBLESTONE,
|
||||
"glacier" => PACKED_ICE,
|
||||
"mud" | "wetland" => MUD,
|
||||
"mountain_range" => COBBLESTONE,
|
||||
"saddle" | "ridge" => STONE,
|
||||
"shrubbery" | "tundra" | "hill" => GRASS_BLOCK,
|
||||
"cliff" => STONE,
|
||||
_ => GRASS_BLOCK,
|
||||
};
|
||||
|
||||
let ProcessedElement::Way(way) = element else {
|
||||
@@ -73,9 +57,9 @@ pub fn generate_natural(
|
||||
if let Some(prev) = previous_node {
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(prev.0, ground_level, prev.1, x, ground_level, z);
|
||||
bresenham_line(prev.0, 0, prev.1, x, 0, z);
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
editor.set_block(block_type, bx, ground_level, bz, None, None);
|
||||
editor.set_block(block_type, bx, 0, bz, None, None);
|
||||
}
|
||||
|
||||
current_natural.push((x, z));
|
||||
@@ -98,38 +82,400 @@ pub fn generate_natural(
|
||||
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
|
||||
|
||||
for (x, z) in filled_area {
|
||||
editor.set_block(block_type, x, ground_level, z, None, None);
|
||||
|
||||
// Generate elements for "wood" and "tree_row"
|
||||
if natural_type == "wood" || natural_type == "tree_row" {
|
||||
if editor.check_for_block(x, ground_level, z, None, Some(&[WATER])) {
|
||||
continue;
|
||||
editor.set_block(block_type, x, 0, z, None, None);
|
||||
// Generate custom layer instead of dirt, must be stone on the lowest level
|
||||
match natural_type.as_str() {
|
||||
"beach" | "sand" | "dune" | "shoal" => {
|
||||
editor.set_block(SAND, x, 0, z, None, None);
|
||||
}
|
||||
|
||||
let random_choice: i32 = rng.gen_range(0..26);
|
||||
if random_choice == 25 {
|
||||
create_tree(
|
||||
editor,
|
||||
x,
|
||||
ground_level + 1,
|
||||
z,
|
||||
rng.gen_range(1..=3),
|
||||
args.winter,
|
||||
);
|
||||
} else if random_choice == 2 {
|
||||
let flower_block = match rng.gen_range(1..=4) {
|
||||
1 => RED_FLOWER,
|
||||
2 => BLUE_FLOWER,
|
||||
3 => YELLOW_FLOWER,
|
||||
_ => WHITE_FLOWER,
|
||||
};
|
||||
editor.set_block(flower_block, x, ground_level + 1, z, None, None);
|
||||
} else if random_choice <= 1 {
|
||||
editor.set_block(GRASS, x, ground_level + 1, z, None, None);
|
||||
"glacier" => {
|
||||
editor.set_block(PACKED_ICE, x, 0, z, None, None);
|
||||
editor.set_block(STONE, x, -1, z, None, None);
|
||||
}
|
||||
"bare_rock" => {
|
||||
editor.set_block(STONE, x, 0, z, None, None);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// Generate surface elements
|
||||
if editor.check_for_block(x, 0, z, Some(&[WATER])) {
|
||||
continue;
|
||||
}
|
||||
match natural_type.as_str() {
|
||||
"grassland" => {
|
||||
if !editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
continue;
|
||||
}
|
||||
if rng.gen_bool(0.6) {
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"heath" => {
|
||||
if !editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
continue;
|
||||
}
|
||||
let random_choice = rng.gen_range(0..500);
|
||||
if random_choice < 33 {
|
||||
if random_choice <= 2 {
|
||||
editor.set_block(COBBLESTONE, x, 0, z, None, None);
|
||||
} else if random_choice < 6 {
|
||||
editor.set_block(OAK_LEAVES, x, 1, z, None, None);
|
||||
} else {
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
"scrub" => {
|
||||
if !editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
continue;
|
||||
}
|
||||
let random_choice = rng.gen_range(0..500);
|
||||
if random_choice == 0 {
|
||||
Tree::create(editor, (x, 1, z));
|
||||
} else if random_choice == 1 {
|
||||
let flower_block = match rng.gen_range(1..=4) {
|
||||
1 => RED_FLOWER,
|
||||
2 => BLUE_FLOWER,
|
||||
3 => YELLOW_FLOWER,
|
||||
_ => WHITE_FLOWER,
|
||||
};
|
||||
editor.set_block(flower_block, x, 1, z, None, None);
|
||||
} else if random_choice < 40 {
|
||||
editor.set_block(OAK_LEAVES, x, 1, z, None, None);
|
||||
if random_choice < 15 {
|
||||
editor.set_block(OAK_LEAVES, x, 2, z, None, None);
|
||||
}
|
||||
} else if random_choice < 300 {
|
||||
if random_choice < 250 {
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
} else {
|
||||
editor.set_block(TALL_GRASS_BOTTOM, x, 1, z, None, None);
|
||||
editor.set_block(TALL_GRASS_TOP, x, 2, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
"tree_row" | "wood" => {
|
||||
if !editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
continue;
|
||||
}
|
||||
let random_choice: i32 = rng.gen_range(0..30);
|
||||
if random_choice == 0 {
|
||||
Tree::create(editor, (x, 1, z));
|
||||
} else if random_choice == 1 {
|
||||
let flower_block = match rng.gen_range(1..=4) {
|
||||
1 => RED_FLOWER,
|
||||
2 => BLUE_FLOWER,
|
||||
3 => YELLOW_FLOWER,
|
||||
_ => WHITE_FLOWER,
|
||||
};
|
||||
editor.set_block(flower_block, x, 1, z, None, None);
|
||||
} else if random_choice <= 12 {
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"sand" => {
|
||||
if editor.check_for_block(x, 0, z, Some(&[SAND]))
|
||||
&& rng.gen_range(0..100) == 1
|
||||
{
|
||||
editor.set_block(DEAD_BUSH, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"shoal" => {
|
||||
if rng.gen_bool(0.05) {
|
||||
editor.set_block(WATER, x, 0, z, Some(&[SAND, GRAVEL]), None);
|
||||
}
|
||||
}
|
||||
"wetland" => {
|
||||
if let Some(wetland_type) = element.tags().get("wetland") {
|
||||
// Wetland without water blocks
|
||||
if matches!(wetland_type.as_str(), "wet_meadow" | "fen") {
|
||||
if rng.gen_bool(0.3) {
|
||||
editor.set_block(GRASS_BLOCK, x, 0, z, Some(&[MUD]), None);
|
||||
}
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
continue;
|
||||
}
|
||||
// All the other types of wetland
|
||||
if rng.gen_bool(0.3) {
|
||||
editor.set_block(
|
||||
WATER,
|
||||
x,
|
||||
0,
|
||||
z,
|
||||
Some(&[MUD, GRASS_BLOCK]),
|
||||
None,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if !editor.check_for_block(x, 0, z, Some(&[MUD, MOSS_BLOCK])) {
|
||||
continue;
|
||||
}
|
||||
match wetland_type.as_str() {
|
||||
"reedbed" => {
|
||||
editor.set_block(TALL_GRASS_BOTTOM, x, 1, z, None, None);
|
||||
editor.set_block(TALL_GRASS_TOP, x, 2, z, None, None);
|
||||
}
|
||||
"swamp" | "mangrove" => {
|
||||
// TODO implement mangrove
|
||||
let random_choice: i32 = rng.gen_range(0..40);
|
||||
if random_choice == 0 {
|
||||
Tree::create(editor, (x, 1, z));
|
||||
} else if random_choice < 35 {
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"bog" => {
|
||||
if rng.gen_bool(0.2) {
|
||||
editor.set_block(
|
||||
MOSS_BLOCK,
|
||||
x,
|
||||
0,
|
||||
z,
|
||||
Some(&[MUD]),
|
||||
None,
|
||||
);
|
||||
}
|
||||
if rng.gen_bool(0.15) {
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"tidalflat" => {
|
||||
continue; // No vegetation here
|
||||
}
|
||||
_ => {
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Generic natural=wetland without wetland=... tag
|
||||
if rng.gen_bool(0.3) {
|
||||
editor.set_block(WATER, x, 0, z, Some(&[MUD]), None);
|
||||
continue;
|
||||
}
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"mountain_range" => {
|
||||
// Create block clusters instead of random placement
|
||||
let cluster_chance = rng.gen_range(0..1000);
|
||||
|
||||
if cluster_chance < 50 {
|
||||
// 5% chance to start a new cluster
|
||||
let cluster_block = match rng.gen_range(0..7) {
|
||||
0 => DIRT,
|
||||
1 => STONE,
|
||||
2 => GRAVEL,
|
||||
3 => GRANITE,
|
||||
4 => DIORITE,
|
||||
5 => ANDESITE,
|
||||
_ => GRASS_BLOCK,
|
||||
};
|
||||
|
||||
// Generate cluster size (5-10 blocks radius)
|
||||
let cluster_size = rng.gen_range(5..=10);
|
||||
|
||||
// Create cluster around current position
|
||||
for dx in -(cluster_size as i32)..=(cluster_size as i32) {
|
||||
for dz in -(cluster_size as i32)..=(cluster_size as i32) {
|
||||
let cluster_x = x + dx;
|
||||
let cluster_z = z + dz;
|
||||
|
||||
// Use distance to create more natural cluster shape
|
||||
let distance = ((dx * dx + dz * dz) as f32).sqrt();
|
||||
if distance <= cluster_size as f32 {
|
||||
// Probability decreases with distance from center
|
||||
let place_prob = 1.0 - (distance / cluster_size as f32);
|
||||
if rng.gen::<f32>() < place_prob {
|
||||
editor.set_block(
|
||||
cluster_block,
|
||||
cluster_x,
|
||||
0,
|
||||
cluster_z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
// Add vegetation on grass blocks
|
||||
if cluster_block == GRASS_BLOCK {
|
||||
let vegetation_chance = rng.gen_range(0..100);
|
||||
if vegetation_chance == 0 {
|
||||
// 1% chance for rare trees
|
||||
Tree::create(
|
||||
editor,
|
||||
(cluster_x, 1, cluster_z),
|
||||
);
|
||||
} else if vegetation_chance < 15 {
|
||||
// 15% chance for grass
|
||||
editor.set_block(
|
||||
GRASS, cluster_x, 1, cluster_z, None,
|
||||
None,
|
||||
);
|
||||
} else if vegetation_chance < 25 {
|
||||
// 10% chance for oak leaves
|
||||
editor.set_block(
|
||||
OAK_LEAVES, cluster_x, 1, cluster_z,
|
||||
None, None,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"saddle" => {
|
||||
// Saddle areas - lowest point between peaks, mix of stone and grass
|
||||
let terrain_chance = rng.gen_range(0..100);
|
||||
if terrain_chance < 30 {
|
||||
// 30% chance for exposed stone
|
||||
editor.set_block(STONE, x, 0, z, None, None);
|
||||
} else if terrain_chance < 50 {
|
||||
// 20% chance for gravel/rocky terrain
|
||||
editor.set_block(GRAVEL, x, 0, z, None, None);
|
||||
} else {
|
||||
// 50% chance for grass
|
||||
editor.set_block(GRASS_BLOCK, x, 0, z, None, None);
|
||||
if rng.gen_bool(0.4) {
|
||||
// 40% chance for grass on top
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
"ridge" => {
|
||||
// Ridge areas - elevated crest, mostly rocky with some vegetation
|
||||
let ridge_chance = rng.gen_range(0..100);
|
||||
if ridge_chance < 60 {
|
||||
// 60% chance for stone/rocky terrain
|
||||
let rock_type = match rng.gen_range(0..4) {
|
||||
0 => STONE,
|
||||
1 => COBBLESTONE,
|
||||
2 => GRANITE,
|
||||
_ => ANDESITE,
|
||||
};
|
||||
editor.set_block(rock_type, x, 0, z, None, None);
|
||||
} else {
|
||||
// 40% chance for grass with sparse vegetation
|
||||
editor.set_block(GRASS_BLOCK, x, 0, z, None, None);
|
||||
let vegetation_chance = rng.gen_range(0..100);
|
||||
if vegetation_chance < 20 {
|
||||
// 20% chance for grass
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
} else if vegetation_chance < 25 {
|
||||
// 5% chance for small shrubs
|
||||
editor.set_block(OAK_LEAVES, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
"shrubbery" => {
|
||||
// Manicured shrubs and decorative vegetation
|
||||
editor.set_block(OAK_LEAVES, x, 1, z, None, None);
|
||||
editor.set_block(OAK_LEAVES, x, 2, z, None, None);
|
||||
}
|
||||
"tundra" => {
|
||||
// Treeless habitat with low vegetation, mosses, lichens
|
||||
if !editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
continue;
|
||||
}
|
||||
let tundra_chance = rng.gen_range(0..100);
|
||||
if tundra_chance < 40 {
|
||||
// 40% chance for grass (sedges, grasses)
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
} else if tundra_chance < 60 {
|
||||
// 20% chance for moss
|
||||
editor.set_block(MOSS_BLOCK, x, 0, z, Some(&[GRASS_BLOCK]), None);
|
||||
} else if tundra_chance < 70 {
|
||||
// 10% chance for dead bush (lichens)
|
||||
editor.set_block(DEAD_BUSH, x, 1, z, None, None);
|
||||
}
|
||||
// 30% chance for bare ground (no surface block)
|
||||
}
|
||||
"cliff" => {
|
||||
// Cliff areas - predominantly stone with minimal vegetation
|
||||
let cliff_chance = rng.gen_range(0..100);
|
||||
if cliff_chance < 90 {
|
||||
// 90% chance for stone variants
|
||||
let stone_type = match rng.gen_range(0..4) {
|
||||
0 => STONE,
|
||||
1 => COBBLESTONE,
|
||||
2 => ANDESITE,
|
||||
_ => DIORITE,
|
||||
};
|
||||
editor.set_block(stone_type, x, 0, z, None, None);
|
||||
} else {
|
||||
// 10% chance for gravel/loose rock
|
||||
editor.set_block(GRAVEL, x, 0, z, None, None);
|
||||
}
|
||||
}
|
||||
"hill" => {
|
||||
// Hill areas - elevated terrain with sparse trees and mostly grass
|
||||
if !editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
continue;
|
||||
}
|
||||
let hill_chance = rng.gen_range(0..1000);
|
||||
if hill_chance == 0 {
|
||||
// 0.1% chance for rare trees
|
||||
Tree::create(editor, (x, 1, z));
|
||||
} else if hill_chance < 50 {
|
||||
// 5% chance for flowers
|
||||
let flower_block = match rng.gen_range(1..=4) {
|
||||
1 => RED_FLOWER,
|
||||
2 => BLUE_FLOWER,
|
||||
3 => YELLOW_FLOWER,
|
||||
_ => WHITE_FLOWER,
|
||||
};
|
||||
editor.set_block(flower_block, x, 1, z, None, None);
|
||||
} else if hill_chance < 600 {
|
||||
// 55% chance for grass
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
} else if hill_chance < 650 {
|
||||
// 5% chance for tall grass
|
||||
editor.set_block(TALL_GRASS_BOTTOM, x, 1, z, None, None);
|
||||
editor.set_block(TALL_GRASS_TOP, x, 2, z, None, None);
|
||||
}
|
||||
// 35% chance for bare grass block
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_natural_from_relation(
|
||||
editor: &mut WorldEditor,
|
||||
rel: &ProcessedRelation,
|
||||
args: &Args,
|
||||
) {
|
||||
if rel.tags.contains_key("natural") {
|
||||
// Generate individual ways with their original tags
|
||||
for member in &rel.members {
|
||||
if member.role == ProcessedMemberRole::Outer {
|
||||
generate_natural(editor, &ProcessedElement::Way(member.way.clone()), args);
|
||||
}
|
||||
}
|
||||
|
||||
// Combine all outer ways into one with relation tags
|
||||
let mut combined_nodes = Vec::new();
|
||||
for member in &rel.members {
|
||||
if member.role == ProcessedMemberRole::Outer {
|
||||
combined_nodes.extend(member.way.nodes.clone());
|
||||
}
|
||||
}
|
||||
|
||||
// Only process if we have nodes
|
||||
if !combined_nodes.is_empty() {
|
||||
// Create combined way with relation tags
|
||||
let combined_way = ProcessedWay {
|
||||
id: rel.id,
|
||||
nodes: combined_nodes,
|
||||
tags: rel.tags.clone(),
|
||||
};
|
||||
|
||||
// Generate natural area from combined way
|
||||
generate_natural(editor, &ProcessedElement::Way(combined_way), args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,18 @@ use crate::bresenham::bresenham_line;
|
||||
use crate::osm_parser::ProcessedWay;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_railways(editor: &mut WorldEditor, element: &ProcessedWay, ground_level: i32) {
|
||||
pub fn generate_railways(editor: &mut WorldEditor, element: &ProcessedWay) {
|
||||
if let Some(railway_type) = element.tags.get("railway") {
|
||||
if ["proposed", "abandoned", "subway", "construction"].contains(&railway_type.as_str()) {
|
||||
if [
|
||||
"proposed",
|
||||
"abandoned",
|
||||
"subway",
|
||||
"construction",
|
||||
"razed",
|
||||
"turntable",
|
||||
]
|
||||
.contains(&railway_type.as_str())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,27 +31,146 @@ pub fn generate_railways(editor: &mut WorldEditor, element: &ProcessedWay, groun
|
||||
}
|
||||
|
||||
for i in 1..element.nodes.len() {
|
||||
let prev: &crate::osm_parser::ProcessedNode = &element.nodes[i - 1];
|
||||
let x1: i32 = prev.x;
|
||||
let z1: i32 = prev.z;
|
||||
let prev_node = element.nodes[i - 1].xz();
|
||||
let cur_node = element.nodes[i].xz();
|
||||
|
||||
let cur: &crate::osm_parser::ProcessedNode = &element.nodes[i];
|
||||
let x2: i32 = cur.x;
|
||||
let z2: i32 = cur.z;
|
||||
let points = bresenham_line(prev_node.x, 0, prev_node.z, cur_node.x, 0, cur_node.z);
|
||||
let smoothed_points = smooth_diagonal_rails(&points);
|
||||
|
||||
// Generate the line of coordinates between the two nodes
|
||||
let bresenham_points: Vec<(i32, i32, i32)> =
|
||||
bresenham_line(x1, ground_level, z1, x2, ground_level, z2);
|
||||
for j in 0..smoothed_points.len() {
|
||||
let (bx, _, bz) = smoothed_points[j];
|
||||
|
||||
for (bx, _, bz) in bresenham_points {
|
||||
// TODO: Set direction of rail
|
||||
editor.set_block(IRON_BLOCK, bx, ground_level, bz, None, None);
|
||||
editor.set_block(RAIL, bx, ground_level + 1, bz, None, None);
|
||||
editor.set_block(GRAVEL, bx, 0, bz, None, None);
|
||||
|
||||
let prev = if j > 0 {
|
||||
Some(smoothed_points[j - 1])
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let next = if j < smoothed_points.len() - 1 {
|
||||
Some(smoothed_points[j + 1])
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let rail_block = determine_rail_direction(
|
||||
(bx, bz),
|
||||
prev.map(|(x, _, z)| (x, z)),
|
||||
next.map(|(x, _, z)| (x, z)),
|
||||
);
|
||||
|
||||
editor.set_block(rail_block, bx, 1, bz, None, None);
|
||||
|
||||
if bx % 4 == 0 {
|
||||
editor.set_block(OAK_LOG, bx, ground_level, bz, None, None);
|
||||
editor.set_block(OAK_LOG, bx, 0, bz, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn smooth_diagonal_rails(points: &[(i32, i32, i32)]) -> Vec<(i32, i32, i32)> {
|
||||
let mut smoothed = Vec::new();
|
||||
|
||||
for i in 0..points.len() {
|
||||
let current = points[i];
|
||||
smoothed.push(current);
|
||||
|
||||
if i + 1 >= points.len() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let next = points[i + 1];
|
||||
let (x1, y1, z1) = current;
|
||||
let (x2, _, z2) = next;
|
||||
|
||||
// If points are diagonally adjacent
|
||||
if (x2 - x1).abs() == 1 && (z2 - z1).abs() == 1 {
|
||||
// Look ahead to determine best intermediate point
|
||||
let look_ahead = if i + 2 < points.len() {
|
||||
Some(points[i + 2])
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// Look behind
|
||||
let look_behind = if i > 0 { Some(points[i - 1]) } else { None };
|
||||
|
||||
// Choose intermediate point based on the overall curve direction
|
||||
let intermediate = if let Some((prev_x, _, _prev_z)) = look_behind {
|
||||
if prev_x == x1 {
|
||||
// Coming from vertical, keep x constant
|
||||
(x1, y1, z2)
|
||||
} else {
|
||||
// Coming from horizontal, keep z constant
|
||||
(x2, y1, z1)
|
||||
}
|
||||
} else if let Some((next_x, _, _next_z)) = look_ahead {
|
||||
if next_x == x2 {
|
||||
// Going to vertical, keep x constant
|
||||
(x2, y1, z1)
|
||||
} else {
|
||||
// Going to horizontal, keep z constant
|
||||
(x1, y1, z2)
|
||||
}
|
||||
} else {
|
||||
// Default to horizontal first if no context
|
||||
(x2, y1, z1)
|
||||
};
|
||||
|
||||
smoothed.push(intermediate);
|
||||
}
|
||||
}
|
||||
|
||||
smoothed
|
||||
}
|
||||
|
||||
fn determine_rail_direction(
|
||||
current: (i32, i32),
|
||||
prev: Option<(i32, i32)>,
|
||||
next: Option<(i32, i32)>,
|
||||
) -> Block {
|
||||
let (x, z) = current;
|
||||
|
||||
match (prev, next) {
|
||||
(Some((px, pz)), Some((nx, nz))) => {
|
||||
if px == nx {
|
||||
RAIL_NORTH_SOUTH
|
||||
} else if pz == nz {
|
||||
RAIL_EAST_WEST
|
||||
} else {
|
||||
// Calculate relative movements
|
||||
let from_prev = (px - x, pz - z);
|
||||
let to_next = (nx - x, nz - z);
|
||||
|
||||
match (from_prev, to_next) {
|
||||
// East to North or North to East
|
||||
((-1, 0), (0, -1)) | ((0, -1), (-1, 0)) => RAIL_NORTH_WEST,
|
||||
// West to North or North to West
|
||||
((1, 0), (0, -1)) | ((0, -1), (1, 0)) => RAIL_NORTH_EAST,
|
||||
// East to South or South to East
|
||||
((-1, 0), (0, 1)) | ((0, 1), (-1, 0)) => RAIL_SOUTH_WEST,
|
||||
// West to South or South to West
|
||||
((1, 0), (0, 1)) | ((0, 1), (1, 0)) => RAIL_SOUTH_EAST,
|
||||
_ => {
|
||||
if (px - x).abs() > (pz - z).abs() {
|
||||
RAIL_EAST_WEST
|
||||
} else {
|
||||
RAIL_NORTH_SOUTH
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(Some((px, pz)), None) | (None, Some((px, pz))) => {
|
||||
if px == x {
|
||||
RAIL_NORTH_SOUTH
|
||||
} else if pz == z {
|
||||
RAIL_EAST_WEST
|
||||
} else {
|
||||
RAIL_NORTH_SOUTH
|
||||
}
|
||||
}
|
||||
(None, None) => RAIL_NORTH_SOUTH,
|
||||
}
|
||||
}
|
||||
|
||||
303
src/element_processing/subprocessor/buildings_interior.rs
Normal file
@@ -0,0 +1,303 @@
|
||||
use crate::block_definitions::*;
|
||||
use crate::world_editor::WorldEditor;
|
||||
use std::collections::HashSet;
|
||||
|
||||
/// Interior layout for building ground floors (1st layer above floor)
|
||||
#[rustfmt::skip]
|
||||
const INTERIOR1_LAYER1: [[char; 23]; 23] = [
|
||||
['1', 'U', ' ', 'W', 'C', ' ', ' ', ' ', 'S', 'S', 'W', 'B', 'T', 'T', 'B', 'W', '7', '8', ' ', ' ', ' ', ' ', 'W',],
|
||||
['2', ' ', ' ', 'W', 'F', ' ', ' ', ' ', 'U', 'U', 'W', 'B', 'T', 'T', 'B', 'W', '7', '8', ' ', ' ', ' ', 'B', 'W',],
|
||||
[' ', ' ', ' ', 'W', 'F', ' ', ' ', ' ', ' ', ' ', 'W', 'B', 'T', 'T', 'B', 'W', 'W', 'W', 'D', 'W', 'W', 'W', 'W',],
|
||||
['W', 'W', 'D', 'W', 'L', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'A', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'W', 'W', 'W', 'D', 'W', 'W', 'W', 'W', 'D', 'W', 'W', ' ', ' ', 'D',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'B', 'B', 'B', ' ', ' ', 'J', 'W', ' ', ' ', ' ', 'B', 'W', 'W', 'W',],
|
||||
['W', 'W', 'W', 'W', 'D', 'W', ' ', ' ', 'W', 'T', 'S', 'S', 'T', ' ', ' ', 'W', 'S', 'S', ' ', 'B', 'W', 'W', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W', 'T', 'T', 'T', 'T', ' ', ' ', 'W', 'U', 'U', ' ', 'B', 'W', ' ', ' ',],
|
||||
[' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'D', 'T', 'T', 'T', 'T', ' ', 'B', 'W', ' ', ' ', ' ', 'B', 'W', ' ', ' ',],
|
||||
['L', ' ', 'A', 'L', 'W', 'W', ' ', ' ', 'W', 'J', 'U', 'U', ' ', ' ', 'B', 'W', 'W', 'D', 'W', 'W', 'W', ' ', ' ',],
|
||||
['W', 'W', 'W', 'W', 'W', 'W', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'D', 'W', 'W', ' ', ' ', 'W', 'C', 'C', 'W', 'W',],
|
||||
['B', 'B', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'D', ' ', ' ', 'W', ' ', ' ', 'W', 'W',],
|
||||
[' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', ' ', ' ', 'D',],
|
||||
[' ', '6', ' ', 'W', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'D', 'W', 'W', 'D', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
['U', '5', ' ', 'W', ' ', ' ', 'W', 'C', 'F', 'F', ' ', ' ', 'W', ' ', ' ', 'W', 'W', 'D', 'W', 'W', ' ', ' ', 'W',],
|
||||
['W', 'W', 'W', 'W', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', 'W', 'L', ' ', 'W', 'A', ' ', 'B', 'W', ' ', ' ', 'W',],
|
||||
['B', ' ', ' ', ' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W', ' ', ' ', 'B', 'W', 'J', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', 'W', 'U', ' ', ' ', 'W', 'B', ' ', 'D',],
|
||||
['J', ' ', ' ', 'C', 'B', 'B', 'W', 'L', 'F', ' ', 'W', 'F', ' ', 'W', 'L', 'W', '7', '8', ' ', 'W', 'B', ' ', 'W',],
|
||||
['B', ' ', ' ', 'B', 'W', 'W', 'W', 'W', 'W', ' ', 'W', 'A', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'C', ' ', 'W',],
|
||||
['B', ' ', ' ', 'B', 'W', ' ', ' ', ' ', 'D', ' ', 'W', 'C', ' ', ' ', 'W', 'W', 'B', 'B', 'B', 'B', 'W', 'D', 'W',],
|
||||
['W', 'W', 'D', 'W', 'C', ' ', ' ', ' ', 'W', 'W', 'W', 'B', 'T', 'T', 'B', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
];
|
||||
|
||||
/// Interior layout for building ground floors (2nd layer above floor)
|
||||
#[rustfmt::skip]
|
||||
const INTERIOR1_LAYER2: [[char; 23]; 23] = [
|
||||
[' ', 'P', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'B', ' ', ' ', 'B', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'P', 'P', 'W', 'B', ' ', ' ', 'B', 'W', ' ', ' ', ' ', ' ', ' ', 'B', 'W',],
|
||||
[' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'B', ' ', ' ', 'B', 'W', 'W', 'W', 'D', 'W', 'W', 'W', 'W',],
|
||||
['W', 'W', 'D', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'W', 'W', 'W', 'D', 'W', 'W', 'W', 'W', 'D', 'W', 'W', ' ', ' ', 'D',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'B', 'B', 'B', ' ', ' ', ' ', 'W', ' ', ' ', ' ', 'B', 'W', 'W', 'W',],
|
||||
['W', 'W', 'W', 'W', 'D', 'W', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', 'B', 'W', 'W', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'P', 'P', ' ', 'B', 'W', ' ', ' ',],
|
||||
[' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'D', ' ', ' ', ' ', ' ', ' ', 'B', 'W', ' ', ' ', ' ', 'B', 'W', ' ', ' ',],
|
||||
[' ', ' ', ' ', ' ', 'W', 'W', ' ', ' ', 'W', ' ', 'P', 'P', ' ', ' ', 'B', 'W', 'W', 'D', 'W', 'W', 'W', ' ', ' ',],
|
||||
['W', 'W', 'W', 'W', 'W', 'W', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'D', 'W', 'W', ' ', ' ', 'W', 'C', 'C', 'W', 'W',],
|
||||
['B', 'B', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'D', ' ', ' ', 'W', ' ', ' ', 'W', 'W',],
|
||||
[' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', ' ', ' ', 'D',],
|
||||
[' ', ' ', ' ', 'W', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'D', 'W', 'W', 'D', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
['P', ' ', ' ', 'W', ' ', ' ', 'W', 'N', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W', 'W', 'D', 'W', 'W', ' ', ' ', 'W',],
|
||||
['W', 'W', 'W', 'W', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W', ' ', ' ', 'B', 'W', ' ', ' ', 'W',],
|
||||
['B', ' ', ' ', ' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W', ' ', ' ', 'C', 'W', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', 'W', 'P', ' ', ' ', 'W', 'B', ' ', 'D',],
|
||||
[' ', ' ', ' ', ' ', 'B', 'B', 'W', ' ', ' ', ' ', 'W', ' ', ' ', 'W', 'P', 'W', ' ', ' ', ' ', 'W', 'B', ' ', 'W',],
|
||||
['B', ' ', ' ', 'B', 'W', 'W', 'W', 'W', 'W', ' ', 'W', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', ' ', ' ', 'W',],
|
||||
['B', ' ', ' ', 'B', 'W', ' ', ' ', ' ', 'D', ' ', 'W', 'N', ' ', ' ', 'W', 'W', 'B', 'B', 'B', 'B', 'W', 'D', 'W',],
|
||||
['W', 'W', 'D', 'W', ' ', ' ', ' ', ' ', 'W', 'W', 'W', 'B', ' ', ' ', 'B', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
];
|
||||
|
||||
/// Interior layout for building level floors (1nd layer above floor)
|
||||
#[rustfmt::skip]
|
||||
const INTERIOR2_LAYER1: [[char; 23]; 23] = [
|
||||
['W', 'W', 'W', 'D', 'W', 'W', 'W', 'W', 'W', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'D', 'W', 'W', 'W',],
|
||||
['U', ' ', ' ', ' ', ' ', ' ', 'C', 'W', 'L', ' ', ' ', 'L', 'W', 'A', 'A', 'W', ' ', ' ', ' ', ' ', ' ', 'L', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
[' ', ' ', 'W', 'W', 'W', ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', 'S', 'S', 'S', ' ', 'W',],
|
||||
[' ', ' ', 'W', 'F', ' ', ' ', ' ', 'W', 'C', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'J', ' ', 'U', 'U', 'U', ' ', 'D',],
|
||||
['U', ' ', 'W', 'F', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W',],
|
||||
['U', ' ', 'W', 'F', ' ', ' ', ' ', 'D', ' ', ' ', 'T', 'T', 'W', ' ', ' ', ' ', ' ', ' ', 'U', 'W', ' ', 'L', 'W',],
|
||||
[' ', ' ', 'W', 'W', 'W', ' ', ' ', 'W', ' ', ' ', 'T', 'J', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'D', 'W', 'W', 'W', ' ', ' ', 'W', 'L', ' ', 'W',],
|
||||
['J', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'C', ' ', ' ', ' ', 'B', 'W', ' ', ' ', 'W', ' ', ' ', 'W',],
|
||||
['W', 'W', 'W', 'W', 'W', 'L', ' ', ' ', ' ', ' ', 'W', 'C', ' ', ' ', ' ', 'B', 'W', ' ', ' ', 'W', 'W', 'D', 'W',],
|
||||
[' ', 'A', 'B', 'B', 'W', 'W', 'W', 'W', ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'B', 'W', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', 'B', 'W', 'L', ' ', ' ', ' ', ' ', 'W', 'L', ' ', ' ', 'B', 'W', 'W', 'B', 'B', 'W', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', 'B', 'W', ' ', ' ', ' ', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', ' ', ' ', 'D',],
|
||||
[' ', ' ', ' ', ' ', 'D', ' ', ' ', 'U', ' ', ' ', ' ', 'D', ' ', ' ', 'F', 'F', 'W', 'A', 'A', 'W', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', 'W', ' ', ' ', 'U', ' ', ' ', 'W', 'W', ' ', ' ', ' ', ' ', 'C', ' ', ' ', 'W', ' ', ' ', 'W',],
|
||||
['C', ' ', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', ' ', ' ', ' ', ' ', 'L', ' ', ' ', 'W', 'W', 'D', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
['L', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'L', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
['W', 'W', 'W', 'W', 'W', 'W', ' ', ' ', 'U', 'U', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'U', 'U', ' ', 'W', 'B', ' ', 'U', 'U', 'B', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
['S', 'S', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', 'W',],
|
||||
['U', 'U', ' ', ' ', ' ', 'L', 'B', 'B', 'B', ' ', ' ', 'W', 'B', 'B', 'B', 'B', 'B', 'B', 'B', ' ', 'B', 'D', 'W',],
|
||||
];
|
||||
|
||||
/// Interior layout for building level floors (2nd layer above floor)
|
||||
#[rustfmt::skip]
|
||||
const INTERIOR2_LAYER2: [[char; 23]; 23] = [
|
||||
['W', 'W', 'W', 'D', 'W', 'W', 'W', 'W', 'W', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'D', 'W', 'W', 'W',],
|
||||
['P', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'E', ' ', ' ', 'E', 'W', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', 'E', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
[' ', ' ', 'W', 'W', 'W', ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
[' ', ' ', 'W', 'F', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'P', 'P', 'P', ' ', 'D',],
|
||||
['P', ' ', 'W', 'F', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W',],
|
||||
['P', ' ', 'W', 'F', ' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', 'P', 'W', ' ', 'P', 'W',],
|
||||
[' ', ' ', 'W', 'W', 'W', ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'D', 'W', 'W', 'W', ' ', ' ', 'W', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'P', ' ', ' ', ' ', 'B', 'W', ' ', ' ', 'W', ' ', ' ', 'W',],
|
||||
['W', 'W', 'W', 'W', 'W', 'E', ' ', ' ', ' ', ' ', 'W', 'P', ' ', ' ', ' ', 'B', 'W', ' ', ' ', 'W', 'W', 'D', 'W',],
|
||||
[' ', ' ', 'B', 'B', 'W', 'W', 'W', 'W', ' ', ' ', 'W', ' ', ' ', ' ', ' ', 'B', 'W', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', 'B', 'W', 'E', ' ', ' ', ' ', ' ', 'W', 'E', ' ', ' ', 'B', 'W', 'W', 'B', 'B', 'W', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', 'B', 'W', ' ', ' ', ' ', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', ' ', ' ', 'D',],
|
||||
[' ', ' ', ' ', ' ', 'D', ' ', ' ', 'P', ' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', 'W', ' ', ' ', 'P', ' ', ' ', 'W', 'W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', ' ', ' ', ' ', ' ', 'E', ' ', ' ', 'W', 'W', 'D', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'D', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
['E', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'E', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
['W', 'W', 'W', 'W', 'W', 'W', ' ', ' ', 'P', 'P', ' ', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'P', 'P', ' ', 'W', 'B', ' ', 'P', 'P', 'B', ' ', ' ', ' ', ' ', ' ', 'W',],
|
||||
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', 'W',],
|
||||
['P', 'P', ' ', ' ', ' ', 'E', 'B', 'B', 'B', ' ', ' ', 'W', 'B', 'B', 'B', 'B', 'B', 'B', 'B', ' ', 'B', ' ', 'D',],
|
||||
];
|
||||
|
||||
/// Maps interior layout characters to actual block types for different floor layers
|
||||
#[inline(always)]
|
||||
pub fn get_interior_block(c: char, is_layer2: bool, wall_block: Block) -> Option<Block> {
|
||||
match c {
|
||||
' ' => None, // Nothing
|
||||
'W' => Some(wall_block), // Use the building's wall block for interior walls
|
||||
'U' => Some(OAK_FENCE), // Oak Fence
|
||||
'S' => Some(OAK_STAIRS), // Oak Stairs
|
||||
'B' => Some(BOOKSHELF), // Bookshelf
|
||||
'C' => Some(CRAFTING_TABLE), // Crafting Table
|
||||
'F' => Some(FURNACE), // Furnace
|
||||
'1' => Some(RED_BED_NORTH_HEAD), // Bed North Head
|
||||
'2' => Some(RED_BED_NORTH_FOOT), // Bed North Foot
|
||||
'3' => Some(RED_BED_EAST_HEAD), // Bed East Head
|
||||
'4' => Some(RED_BED_EAST_FOOT), // Bed East Foot
|
||||
'5' => Some(RED_BED_SOUTH_HEAD), // Bed South Head
|
||||
'6' => Some(RED_BED_SOUTH_FOOT), // Bed South Foot
|
||||
'7' => Some(RED_BED_WEST_HEAD), // Bed West Head
|
||||
'8' => Some(RED_BED_WEST_FOOT), // Bed West Foot
|
||||
'H' => Some(CHEST), // Chest
|
||||
'L' => Some(CAULDRON), // Cauldron
|
||||
'A' => Some(ANVIL), // Anvil
|
||||
'P' => Some(OAK_PRESSURE_PLATE), // Pressure Plate
|
||||
'D' => {
|
||||
// Use different door types for different layers
|
||||
if is_layer2 {
|
||||
Some(DARK_OAK_DOOR_UPPER)
|
||||
} else {
|
||||
Some(DARK_OAK_DOOR_LOWER)
|
||||
}
|
||||
}
|
||||
'J' => Some(JUKEBOX), // Jukebox
|
||||
'G' => Some(GLOWSTONE), // Glowstone
|
||||
'N' => Some(BREWING_STAND), // Brewing Stand
|
||||
'T' => Some(WHITE_CARPET), // White Carpet
|
||||
'E' => Some(OAK_LEAVES), // Oak Leaves
|
||||
_ => None, // Default case for unknown characters
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates interior layouts inside buildings at each floor level
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn generate_building_interior(
|
||||
editor: &mut WorldEditor,
|
||||
floor_area: &[(i32, i32)],
|
||||
min_x: i32,
|
||||
min_z: i32,
|
||||
max_x: i32,
|
||||
max_z: i32,
|
||||
start_y_offset: i32,
|
||||
building_height: i32,
|
||||
wall_block: Block,
|
||||
floor_levels: &[i32],
|
||||
args: &crate::args::Args,
|
||||
element: &crate::osm_parser::ProcessedWay,
|
||||
abs_terrain_offset: i32,
|
||||
) {
|
||||
// Skip interior generation for very small buildings
|
||||
let width = max_x - min_x + 1;
|
||||
let depth = max_z - min_z + 1;
|
||||
|
||||
if width < 8 || depth < 8 {
|
||||
return; // Building too small for interior
|
||||
}
|
||||
|
||||
// For efficiency, create a HashSet of floor area coordinates
|
||||
let floor_area_set: HashSet<(i32, i32)> = floor_area.iter().cloned().collect();
|
||||
|
||||
// Add buffer around edges to avoid placing furniture too close to walls
|
||||
let buffer = 2;
|
||||
let interior_min_x = min_x + buffer;
|
||||
let interior_min_z = min_z + buffer;
|
||||
let interior_max_x = max_x - buffer;
|
||||
let interior_max_z = max_z - buffer;
|
||||
|
||||
// Generate interiors for each floor
|
||||
for (floor_index, &floor_y) in floor_levels.iter().enumerate() {
|
||||
// Store wall and door positions for this floor to extend them to the ceiling
|
||||
let mut wall_positions = Vec::new();
|
||||
let mut door_positions = Vec::new();
|
||||
|
||||
// Determine the floor extension height (ceiling) - either next floor or roof
|
||||
let current_floor_ceiling = if floor_index < floor_levels.len() - 1 {
|
||||
// For intermediate floors, extend walls up to just below the next floor
|
||||
floor_levels[floor_index + 1] - 1
|
||||
} else {
|
||||
// Last floor ceiling depends on roof generation
|
||||
if args.roof
|
||||
&& element.tags.contains_key("roof:shape")
|
||||
&& element.tags.get("roof:shape").unwrap() != "flat"
|
||||
{
|
||||
// When roof generation is enabled with non-flat roofs, stop at building height (no extra ceiling)
|
||||
start_y_offset + building_height
|
||||
} else {
|
||||
// When roof generation is disabled or flat roof, extend to building top + 1 (includes ceiling)
|
||||
start_y_offset + building_height + 1
|
||||
}
|
||||
};
|
||||
|
||||
// Choose the appropriate interior pattern based on floor number
|
||||
let (layer1, layer2) = if floor_index == 0 {
|
||||
// Ground floor uses INTERIOR1 patterns
|
||||
(&INTERIOR1_LAYER1, &INTERIOR1_LAYER2)
|
||||
} else {
|
||||
// Upper floors use INTERIOR2 patterns
|
||||
(&INTERIOR2_LAYER1, &INTERIOR2_LAYER2)
|
||||
};
|
||||
|
||||
// Get dimensions for the selected pattern
|
||||
let pattern_height = layer1.len() as i32;
|
||||
let pattern_width = layer1[0].len() as i32;
|
||||
|
||||
// Calculate Y offset - place interior 1 block above floor level consistently
|
||||
let y_offset = 1;
|
||||
|
||||
// Create a seamless repeating pattern across the interior of this floor
|
||||
for z in interior_min_z..=interior_max_z {
|
||||
for x in interior_min_x..=interior_max_x {
|
||||
// Skip if outside the building's floor area
|
||||
if !floor_area_set.contains(&(x, z)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Map the world coordinates to pattern coordinates using modulo
|
||||
// This creates a seamless tiling effect across the entire building
|
||||
// Add floor_index offset to create variation between floors
|
||||
let pattern_x = ((x - interior_min_x + floor_index as i32) % pattern_width
|
||||
+ pattern_width)
|
||||
% pattern_width;
|
||||
let pattern_z = ((z - interior_min_z + floor_index as i32) % pattern_height
|
||||
+ pattern_height)
|
||||
% pattern_height;
|
||||
|
||||
// Access the pattern arrays safely
|
||||
let cell1 = layer1[pattern_z as usize][pattern_x as usize];
|
||||
let cell2 = layer2[pattern_z as usize][pattern_x as usize];
|
||||
|
||||
// Place first layer blocks
|
||||
if let Some(block) = get_interior_block(cell1, false, wall_block) {
|
||||
editor.set_block_absolute(
|
||||
block,
|
||||
x,
|
||||
floor_y + y_offset + abs_terrain_offset,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
// If this is a wall in layer 1, add to wall positions to extend later
|
||||
if cell1 == 'W' {
|
||||
wall_positions.push((x, z));
|
||||
}
|
||||
// If this is a door in layer 1, add to door positions to add wall above later
|
||||
else if cell1 == 'D' {
|
||||
door_positions.push((x, z));
|
||||
}
|
||||
}
|
||||
|
||||
// Place second layer blocks
|
||||
if let Some(block) = get_interior_block(cell2, true, wall_block) {
|
||||
editor.set_block_absolute(
|
||||
block,
|
||||
x,
|
||||
floor_y + y_offset + abs_terrain_offset + 1,
|
||||
z,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extend walls all the way to the next floor ceiling or roof
|
||||
for (x, z) in &wall_positions {
|
||||
for y in (floor_y + y_offset + 2)..=current_floor_ceiling {
|
||||
editor.set_block_absolute(wall_block, *x, y + abs_terrain_offset, *z, None, None);
|
||||
}
|
||||
}
|
||||
|
||||
// Add wall blocks above doors all the way to the ceiling/next floor
|
||||
for (x, z) in &door_positions {
|
||||
for y in (floor_y + y_offset + 2)..=current_floor_ceiling {
|
||||
editor.set_block_absolute(wall_block, *x, y + abs_terrain_offset, *z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
src/element_processing/subprocessor/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod buildings_interior;
|
||||
@@ -2,7 +2,7 @@ use crate::block_definitions::*;
|
||||
use crate::osm_parser::ProcessedNode;
|
||||
use crate::world_editor::WorldEditor;
|
||||
|
||||
pub fn generate_tourisms(editor: &mut WorldEditor, element: &ProcessedNode, ground_level: i32) {
|
||||
pub fn generate_tourisms(editor: &mut WorldEditor, element: &ProcessedNode) {
|
||||
// Skip if 'layer' or 'level' is negative in the tags
|
||||
if let Some(layer) = element.tags.get("layer") {
|
||||
if layer.parse::<i32>().unwrap_or(0) < 0 {
|
||||
@@ -21,9 +21,13 @@ pub fn generate_tourisms(editor: &mut WorldEditor, element: &ProcessedNode, grou
|
||||
let z: i32 = element.z;
|
||||
|
||||
if tourism_type == "information" {
|
||||
if let Some("board") = element.tags.get("information").map(|x: &String| x.as_str()) {
|
||||
// TODO draw a sign
|
||||
editor.set_block(OAK_PLANKS, x, ground_level + 1, z, None, None);
|
||||
if let Some(info_type) = element.tags.get("information").map(|x: &String| x.as_str()) {
|
||||
if info_type != "office" && info_type != "visitor_centre" {
|
||||
// Draw an information board
|
||||
// TODO draw a sign with text if provided
|
||||
editor.set_block(COBBLESTONE_WALL, x, 1, z, None, None);
|
||||
editor.set_block(OAK_PLANKS, x, 2, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||