mirror of
https://github.com/AndorsTrailRelease/andors-trail.git
synced 2025-12-27 14:59:00 +01:00
Compare commits
1741 Commits
test
...
import_exp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b660f482e | ||
|
|
639b17c582 | ||
|
|
a6c39a578d | ||
|
|
79e6fe7b65 | ||
|
|
329acad741 | ||
|
|
41ad345a89 | ||
|
|
f79633fb85 | ||
|
|
8071ebe28f | ||
|
|
09ff14bd14 | ||
|
|
fee94d4262 | ||
|
|
ec14dbe917 | ||
|
|
cc1d20aba6 | ||
|
|
4feebd058b | ||
|
|
265469f88e | ||
|
|
2dd9f8fcab | ||
|
|
50c522c20a | ||
|
|
08dea48010 | ||
|
|
781ddcf7a7 | ||
|
|
76127d9d85 | ||
|
|
e826232611 | ||
|
|
d879629e4a | ||
|
|
2e7eb84f88 | ||
|
|
10ebaf925f | ||
|
|
4c8302b11e | ||
|
|
235f1c912d | ||
|
|
a5721a4a25 | ||
|
|
5adbbd61b9 | ||
|
|
196223bf73 | ||
|
|
d89a615990 | ||
|
|
863cc1a0bb | ||
|
|
1cec98249b | ||
|
|
15ba005062 | ||
|
|
86c1b7496d | ||
|
|
0a194f1e25 | ||
|
|
6ada4c9649 | ||
|
|
2705e1c208 | ||
|
|
3ec7a76ce2 | ||
|
|
5ec9a76c65 | ||
|
|
146f62b283 | ||
|
|
b9d4e52101 | ||
|
|
934f578083 | ||
|
|
0d604f6346 | ||
|
|
5a555d554c | ||
|
|
8ccaabfb0d | ||
|
|
fb887cc869 | ||
|
|
368359af08 | ||
|
|
dc15a9ecde | ||
|
|
1f6db65a45 | ||
|
|
0a70cdd852 | ||
|
|
493f3675dd | ||
|
|
7b3b950982 | ||
|
|
58cb83ee0c | ||
|
|
97d03a76c5 | ||
|
|
d42046dc30 | ||
|
|
fc6d11b096 | ||
|
|
716d0076cd | ||
|
|
e19e73c6a1 | ||
|
|
779a2e81fd | ||
|
|
cd1e764f92 | ||
|
|
71bd56fff4 | ||
|
|
0e48faa5b2 | ||
|
|
9d0f17d2a2 | ||
|
|
67720592f4 | ||
|
|
ba97e71957 | ||
|
|
ee5f525591 | ||
|
|
bed80e48b0 | ||
|
|
90c8293fd2 | ||
|
|
6c390c6b39 | ||
|
|
9785a8ece9 | ||
|
|
362c3f8b74 | ||
|
|
bb707047a0 | ||
|
|
efe0691f74 | ||
|
|
30906135e1 | ||
|
|
0a8b598f04 | ||
|
|
b7ea7ccaab | ||
|
|
6a959f88d4 | ||
|
|
311c1cb1ae | ||
|
|
7023401f1f | ||
|
|
f4e7995b8e | ||
|
|
0712dac81b | ||
|
|
40693d99b9 | ||
|
|
8aeb391239 | ||
|
|
fc6821ea94 | ||
|
|
92a77518ae | ||
|
|
a345b22116 | ||
|
|
3d4869bf29 | ||
|
|
fa19e69494 | ||
|
|
721123fbca | ||
|
|
c0aae189c9 | ||
|
|
c9619ea6a6 | ||
|
|
7a72521cd2 | ||
|
|
e5d43460db | ||
|
|
7743cd803e | ||
|
|
96df9670b3 | ||
|
|
5319a611bc | ||
|
|
e179d0cdf6 | ||
|
|
f330a48f51 | ||
|
|
e6268fbd14 | ||
|
|
ef0ee63d6f | ||
|
|
ab0487a900 | ||
|
|
4eb9db2532 | ||
|
|
c81ee4768c | ||
|
|
a034f3aced | ||
|
|
d446548863 | ||
|
|
37e66e6bf4 | ||
|
|
a6a456882d | ||
|
|
590cb7ed42 | ||
|
|
378d8b3185 | ||
|
|
69bb657b76 | ||
|
|
e012c6473e | ||
|
|
1b10ce2796 | ||
|
|
98a97ba9d4 | ||
|
|
85e6f1d6ba | ||
|
|
c9d28f2023 | ||
|
|
2b216ec152 | ||
|
|
0d203f5962 | ||
|
|
2a3400baa9 | ||
|
|
fadf1a91a0 | ||
|
|
2c4280bb9c | ||
|
|
7a3d9ee354 | ||
|
|
223180f822 | ||
|
|
27ae0979a0 | ||
|
|
c8aab8d383 | ||
|
|
dab311041c | ||
|
|
2bbb56d2ca | ||
|
|
4ed9a78b82 | ||
|
|
b2f6e46959 | ||
|
|
921c792135 | ||
|
|
08aba800ca | ||
|
|
c62c71e64e | ||
|
|
a7ce535569 | ||
|
|
55237a6d1b | ||
|
|
edd475d765 | ||
|
|
23d476c51d | ||
|
|
a825707748 | ||
|
|
072e75e0fb | ||
|
|
68c88c424e | ||
|
|
6ef7703cc9 | ||
|
|
2047d2230f | ||
|
|
0c938b1505 | ||
|
|
559e01e6e9 | ||
|
|
fa851fd05d | ||
|
|
b812e7f3c2 | ||
|
|
bd56757e7e | ||
|
|
ec8d851211 | ||
|
|
81700155e6 | ||
|
|
6e12754d47 | ||
|
|
0459c66b3d | ||
|
|
daf4da54c4 | ||
|
|
e809006eba | ||
|
|
1775fa3ae1 | ||
|
|
bf49318d9b | ||
|
|
927fafd708 | ||
|
|
2afd109e4a | ||
|
|
765617ea52 | ||
|
|
35cf007569 | ||
|
|
54f358858b | ||
|
|
6cd22e3f63 | ||
|
|
a2cef1376d | ||
|
|
8d8ae8227b | ||
|
|
cdefb95056 | ||
|
|
1f3a7e147f | ||
|
|
062f2157c0 | ||
|
|
1a2087b2d3 | ||
|
|
f725349590 | ||
|
|
fc3c070a96 | ||
|
|
e06f10ca41 | ||
|
|
062469c955 | ||
|
|
c780518fc1 | ||
|
|
a88d346325 | ||
|
|
fb7af524e8 | ||
|
|
e6dfa8db68 | ||
|
|
e491ab4abf | ||
|
|
a61038c74b | ||
|
|
bfc843f496 | ||
|
|
696d1f086e | ||
|
|
7f0a9a1588 | ||
|
|
07568b15d0 | ||
|
|
17461da8f3 | ||
|
|
964ec8a276 | ||
|
|
7d65ddf25d | ||
|
|
2661badb73 | ||
|
|
9a3fbdf7d9 | ||
|
|
7c4ba2b2c7 | ||
|
|
0368c112ad | ||
|
|
1cd759d12a | ||
|
|
0d73255de0 | ||
|
|
7f0499c701 | ||
|
|
09656bc4bf | ||
|
|
5ab945b739 | ||
|
|
f47d395b94 | ||
|
|
dba2900213 | ||
|
|
cb8ef5e790 | ||
|
|
426f4078a9 | ||
|
|
4fdbd3d330 | ||
|
|
384c1b9c0d | ||
|
|
075a99f657 | ||
|
|
b9f426cc9b | ||
|
|
49a613ce0b | ||
|
|
a3cb939253 | ||
|
|
824c0579c9 | ||
|
|
44902f35ea | ||
|
|
ca25d413ad | ||
|
|
9d33993d61 | ||
|
|
be48ef66f1 | ||
|
|
2062be506f | ||
|
|
0eecde9ee4 | ||
|
|
d4cbed9d35 | ||
|
|
e33e75846c | ||
|
|
5378279d46 | ||
|
|
cc6a573ef0 | ||
|
|
2821c2b8fc | ||
|
|
0b72a1a603 | ||
|
|
f19314713f | ||
|
|
370a4fedd7 | ||
|
|
57acd95706 | ||
|
|
f5a93e170c | ||
|
|
53cb4853e3 | ||
|
|
8e27d57868 | ||
|
|
05107b2f55 | ||
|
|
3a4d5ae9c5 | ||
|
|
0875850589 | ||
|
|
d2b86b502a | ||
|
|
7447df12cf | ||
|
|
ba34e16290 | ||
|
|
1998d1ec90 | ||
|
|
3c2a70fdeb | ||
|
|
d94f7a5907 | ||
|
|
97ad665ac0 | ||
|
|
2f758b6e4a | ||
|
|
b4e446e8d0 | ||
|
|
63dfff7f7a | ||
|
|
3369b135d7 | ||
|
|
70a9b45591 | ||
|
|
71b9ac54b1 | ||
|
|
74ac5289dd | ||
|
|
01bd80db53 | ||
|
|
a1bcbf7c7a | ||
|
|
2b6e4606b2 | ||
|
|
c65811b89f | ||
|
|
15450b8b8b | ||
|
|
f2d4fb6b88 | ||
|
|
5735df8a6b | ||
|
|
19b1f19535 | ||
|
|
28c3f5228d | ||
|
|
b5c4d77ad8 | ||
|
|
60fae8adde | ||
|
|
97810e12f0 | ||
|
|
13f01c5f77 | ||
|
|
36424f1888 | ||
|
|
003aea1aeb | ||
|
|
2d61fcd3ef | ||
|
|
ccd012b085 | ||
|
|
933dcb94af | ||
|
|
15899693eb | ||
|
|
663c9d68d2 | ||
|
|
f058351e78 | ||
|
|
2b591c4d3d | ||
|
|
dd92baa08a | ||
|
|
0a4656054d | ||
|
|
804ae432e3 | ||
|
|
bba9d927e2 | ||
|
|
e9419f09f1 | ||
|
|
f0a4f06db4 | ||
|
|
2f02728612 | ||
|
|
f4c366cb03 | ||
|
|
e6d6892904 | ||
|
|
df13484872 | ||
|
|
86f4bd2e7e | ||
|
|
d04e8eebb7 | ||
|
|
13ae770c1b | ||
|
|
5b38d848e0 | ||
|
|
73838a501b | ||
|
|
e7365bc325 | ||
|
|
181abaaad2 | ||
|
|
c6ca78f86b | ||
|
|
65dc7ea0e9 | ||
|
|
2386afe711 | ||
|
|
4b10abe018 | ||
|
|
c83e36fe2d | ||
|
|
e6200487d0 | ||
|
|
aa1ae1622a | ||
|
|
8231b6db06 | ||
|
|
37c7575279 | ||
|
|
6985cecafb | ||
|
|
e86d053b6a | ||
|
|
2e65700f81 | ||
|
|
a2514cc58f | ||
|
|
b3e8ef7927 | ||
|
|
37d204b93d | ||
|
|
9d76227d70 | ||
|
|
f7039a855a | ||
|
|
d53c91b19a | ||
|
|
b48e1aa254 | ||
|
|
fc773b5721 | ||
|
|
b956f4ca93 | ||
|
|
99c4c3a6f4 | ||
|
|
2dfadcaa8f | ||
|
|
d52622b4fd | ||
|
|
2334a91a5a | ||
|
|
4bb9baa662 | ||
|
|
d89bce96d5 | ||
|
|
aaac6ae3b5 | ||
|
|
ade84de6e9 | ||
|
|
7538593036 | ||
|
|
8daa49916b | ||
|
|
0e41a885e3 | ||
|
|
93a00755da | ||
|
|
fe89818bb7 | ||
|
|
e9bbe0a2d2 | ||
|
|
564f809591 | ||
|
|
ee2d6258d3 | ||
|
|
e85b6c447a | ||
|
|
2315b6821a | ||
|
|
7112d447ac | ||
|
|
d12dc80986 | ||
|
|
ec0fd22292 | ||
|
|
b01615f23b | ||
|
|
bcc1e0fa34 | ||
|
|
a08df47db9 | ||
|
|
ce0318f450 | ||
|
|
cebde22296 | ||
|
|
7e98398501 | ||
|
|
287324a0d7 | ||
|
|
c4c0cde086 | ||
|
|
a57b935fc8 | ||
|
|
2f532e2ff4 | ||
|
|
ea6b7f3dd0 | ||
|
|
213158c8d5 | ||
|
|
223c3dcfe9 | ||
|
|
9e9025bb6b | ||
|
|
a6e2453b1c | ||
|
|
5c1c08850e | ||
|
|
c1e815714d | ||
|
|
3f0ac4b217 | ||
|
|
7b5d0fc607 | ||
|
|
095ae727c1 | ||
|
|
fa3cf821aa | ||
|
|
20acd6cffe | ||
|
|
57932e7ace | ||
|
|
0785d33bf8 | ||
|
|
86480f0863 | ||
|
|
b2ce4c5448 | ||
|
|
71b4d173f5 | ||
|
|
c1776e1c19 | ||
|
|
7675cfd69f | ||
|
|
7e9ff1e06b | ||
|
|
40254a88b7 | ||
|
|
a001fd5378 | ||
|
|
19cfe30d94 | ||
|
|
f775d36181 | ||
|
|
3f407a6472 | ||
|
|
36801fea3a | ||
|
|
3ac91ac56b | ||
|
|
ac3e6c1a8e | ||
|
|
4a0ba2c86b | ||
|
|
c6152ad11c | ||
|
|
f8defcff9a | ||
|
|
b8fc51c59e | ||
|
|
606379d161 | ||
|
|
cf40a2514e | ||
|
|
ef4d43bc0f | ||
|
|
26c327320b | ||
|
|
abb113c308 | ||
|
|
76df1b281a | ||
|
|
682356f1c1 | ||
|
|
2466f09bd1 | ||
|
|
5933f0047a | ||
|
|
9519336a46 | ||
|
|
d34d038e41 | ||
|
|
279446c117 | ||
|
|
13f8ab103b | ||
|
|
d96422b731 | ||
|
|
cde3074fa7 | ||
|
|
6750292ec7 | ||
|
|
6054adede7 | ||
|
|
a40a6a1a37 | ||
|
|
1471dd2adf | ||
|
|
ca84e9d0e0 | ||
|
|
ba6c426a15 | ||
|
|
625845aa46 | ||
|
|
fdb144fed7 | ||
|
|
9c3d6dabc0 | ||
|
|
82b61b892b | ||
|
|
9f5ac80141 | ||
|
|
3655c3a864 | ||
|
|
def18995f7 | ||
|
|
96da21fb6b | ||
|
|
2b03b1e08e | ||
|
|
ee62ec432f | ||
|
|
6b7cc3e584 | ||
|
|
a64f6161c6 | ||
|
|
e7b0471e19 | ||
|
|
861791bdba | ||
|
|
6135e5a014 | ||
|
|
196a12a0aa | ||
|
|
1881e0e0c5 | ||
|
|
d9bddcc3bf | ||
|
|
c12bdd60b5 | ||
|
|
b24ecb93aa | ||
|
|
ad1fb9d6fe | ||
|
|
d2ec4afa87 | ||
|
|
f84b6d172c | ||
|
|
a1893f3135 | ||
|
|
18f7acb1d3 | ||
|
|
8a17bd7e84 | ||
|
|
381b7d17eb | ||
|
|
0d93899544 | ||
|
|
0263d60261 | ||
|
|
cd0d63aeac | ||
|
|
b1275f1143 | ||
|
|
698c344595 | ||
|
|
a553b0e927 | ||
|
|
988cf048a8 | ||
|
|
1ef94fe505 | ||
|
|
751c4850a9 | ||
|
|
f9fc4b13b9 | ||
|
|
947494b82c | ||
|
|
e6dc6c9535 | ||
|
|
3f5ff64103 | ||
|
|
dc2b953dec | ||
|
|
74d3179157 | ||
|
|
a002183f49 | ||
|
|
57919347d1 | ||
|
|
cfb7f8a0a7 | ||
|
|
8cb6c8355a | ||
|
|
a84cc8e9cc | ||
|
|
06c25297a4 | ||
|
|
ac8668e6f0 | ||
|
|
315d38d9b8 | ||
|
|
dbb106ba4e | ||
|
|
784401247d | ||
|
|
48a2e6391b | ||
|
|
65ba89f74c | ||
|
|
2f922b93d7 | ||
|
|
6e72388e8e | ||
|
|
729060b367 | ||
|
|
a5da21d889 | ||
|
|
51894a2c46 | ||
|
|
49940c1803 | ||
|
|
109461c22e | ||
|
|
613855a1fe | ||
|
|
53382be705 | ||
|
|
6f0336d23d | ||
|
|
06ba965f41 | ||
|
|
0e0e0b5f67 | ||
|
|
4d58ca4cbf | ||
|
|
537617eeb5 | ||
|
|
2daad62d08 | ||
|
|
6d9779cca4 | ||
|
|
30c27fadd9 | ||
|
|
21e381b916 | ||
|
|
3ab543214e | ||
|
|
565fb51370 | ||
|
|
a01bb1f861 | ||
|
|
b3fc8b3be2 | ||
|
|
019022de80 | ||
|
|
4fca247ad2 | ||
|
|
ed8dc46f3c | ||
|
|
41f711b30c | ||
|
|
08027de85d | ||
|
|
d49f9f3320 | ||
|
|
9e04008f9c | ||
|
|
f38d9f7197 | ||
|
|
1728b5fa20 | ||
|
|
2a85292274 | ||
|
|
3e534a7a47 | ||
|
|
4ff444511e | ||
|
|
337aba70d9 | ||
|
|
04fbbac774 | ||
|
|
e96815f655 | ||
|
|
46c8a203d9 | ||
|
|
3cf9ae4901 | ||
|
|
f5f653e7ba | ||
|
|
f8e6d06d15 | ||
|
|
92ef9dfc03 | ||
|
|
d2193a9778 | ||
|
|
71e8afa949 | ||
|
|
1289c24cf3 | ||
|
|
dabefad73d | ||
|
|
a108eba3ed | ||
|
|
f1f495bbe3 | ||
|
|
86986f8747 | ||
|
|
e185b69b50 | ||
|
|
7c5000a0a9 | ||
|
|
edd12cce52 | ||
|
|
1711bc87bd | ||
|
|
ea36be8461 | ||
|
|
11ac7da4b5 | ||
|
|
e731bbbd29 | ||
|
|
48566e0c32 | ||
|
|
2bd17ad956 | ||
|
|
0dd71e65b6 | ||
|
|
1cfd00bab3 | ||
|
|
af36019345 | ||
|
|
d5a7fe353e | ||
|
|
83975caa82 | ||
|
|
01305e554a | ||
|
|
0809baf6e5 | ||
|
|
2c306a686e | ||
|
|
6c2727d555 | ||
|
|
05e50b3e74 | ||
|
|
16f648ebfa | ||
|
|
f9006294e0 | ||
|
|
0619ca591d | ||
|
|
560eda1d42 | ||
|
|
535e6895ba | ||
|
|
827ca98b20 | ||
|
|
47337edb53 | ||
|
|
8b5f2213c1 | ||
|
|
f2bd35db76 | ||
|
|
338531c420 | ||
|
|
62e635d29e | ||
|
|
75534f2b6a | ||
|
|
80625cecdf | ||
|
|
c67a1d2863 | ||
|
|
b04e3061d6 | ||
|
|
467937263b | ||
|
|
555ae7b7d0 | ||
|
|
9d62081e8e | ||
|
|
8d3ea3f86a | ||
|
|
2f452f51b7 | ||
|
|
2416b12809 | ||
|
|
8385687ea6 | ||
|
|
abb133ddce | ||
|
|
7645e35e08 | ||
|
|
e620081a57 | ||
|
|
d00b208d05 | ||
|
|
ffa0b2375c | ||
|
|
b318ee7d9c | ||
|
|
31806c0153 | ||
|
|
509830dc78 | ||
|
|
f10f5e4a3a | ||
|
|
0e7289c314 | ||
|
|
3f1f87b195 | ||
|
|
06ab0ad121 | ||
|
|
d32b19b6cb | ||
|
|
594145d623 | ||
|
|
6ebca0b3a1 | ||
|
|
5bcfd5e1e7 | ||
|
|
d3bfd737ce | ||
|
|
19d4e8180f | ||
|
|
e205c1af94 | ||
|
|
76e6b02c05 | ||
|
|
9f37a5fb40 | ||
|
|
08ada52e75 | ||
|
|
d22f079d3c | ||
|
|
59d898b4ad | ||
|
|
b57e6fffa1 | ||
|
|
bb1e7558e2 | ||
|
|
96a64b0fe4 | ||
|
|
e022de9e42 | ||
|
|
8353231407 | ||
|
|
d45d1373de | ||
|
|
fda0becbf1 | ||
|
|
78ecc95382 | ||
|
|
62fae625a4 | ||
|
|
ae48aa8bb8 | ||
|
|
e2ce4a97bf | ||
|
|
f713f9ac3d | ||
|
|
4cc25fcd84 | ||
|
|
b71206232c | ||
|
|
5db871a8d4 | ||
|
|
78c9acc0ef | ||
|
|
bc80d88c26 | ||
|
|
98efee7e46 | ||
|
|
d9adf1239f | ||
|
|
f76ff77f65 | ||
|
|
1e1dd0bb41 | ||
|
|
6b824f6fb7 | ||
|
|
0cbb43fce0 | ||
|
|
ac486c896a | ||
|
|
9419b823aa | ||
|
|
969a4dd9b8 | ||
|
|
6f3a37d45c | ||
|
|
32e41dab18 | ||
|
|
c2b58d3fbd | ||
|
|
19343cf27f | ||
|
|
52af9a5ded | ||
|
|
9bc407c4a4 | ||
|
|
e0365a7e5a | ||
|
|
8917a43ac8 | ||
|
|
1fe7e11fe7 | ||
|
|
badce708d1 | ||
|
|
acf202b10c | ||
|
|
100a93d28a | ||
|
|
acd376652d | ||
|
|
15c78eb82f | ||
|
|
8e29e58595 | ||
|
|
6b2ad2af18 | ||
|
|
734e3b7590 | ||
|
|
7d74e3a9b2 | ||
|
|
62987af1dc | ||
|
|
76f12287cc | ||
|
|
17b2160eee | ||
|
|
c018137910 | ||
|
|
0a53c932b2 | ||
|
|
55def3f378 | ||
|
|
9b58a2858b | ||
|
|
e98f1e000a | ||
|
|
8159c77645 | ||
|
|
cf59c59202 | ||
|
|
b1144aefab | ||
|
|
13d31dcb1c | ||
|
|
8de9790705 | ||
|
|
c25089d368 | ||
|
|
be9133a21a | ||
|
|
2bcacffe6e | ||
|
|
636f8ee9ed | ||
|
|
184c60f468 | ||
|
|
dbf2ded1b6 | ||
|
|
ce5592eb7d | ||
|
|
64a7e935a8 | ||
|
|
2539c16022 | ||
|
|
0c91207203 | ||
|
|
d64ed028dd | ||
|
|
bd68be2355 | ||
|
|
a5ffa4e5f3 | ||
|
|
4593b9f91a | ||
|
|
bc26eba677 | ||
|
|
78ce00a9f6 | ||
|
|
a2c556ca12 | ||
|
|
f1034a7a24 | ||
|
|
df0bc95bf1 | ||
|
|
b16d75c43b | ||
|
|
61efc7eea9 | ||
|
|
6e26ce4014 | ||
|
|
4531b1328c | ||
|
|
230f945750 | ||
|
|
e265e45882 | ||
|
|
97d08bde8f | ||
|
|
0f1e1e76b9 | ||
|
|
d6d7e3abd0 | ||
|
|
79ae97bbae | ||
|
|
5664334236 | ||
|
|
a60412c9c6 | ||
|
|
e58cfd14d9 | ||
|
|
c6b882fac1 | ||
|
|
99c4928c77 | ||
|
|
06b5083ee2 | ||
|
|
e3c10d2c82 | ||
|
|
3fb0c263f0 | ||
|
|
20fb1b8f84 | ||
|
|
73f61c04a5 | ||
|
|
7ac99f8067 | ||
|
|
298d099beb | ||
|
|
c4ed3a697c | ||
|
|
ea910554ce | ||
|
|
c4d7a6d156 | ||
|
|
fbc07c5979 | ||
|
|
5423f759a4 | ||
|
|
09d757dcfc | ||
|
|
b1e2042530 | ||
|
|
4e142ad8ba | ||
|
|
3a0ca47908 | ||
|
|
c80e2d37e2 | ||
|
|
c070f96772 | ||
|
|
f3daab8ee1 | ||
|
|
c95b0d3882 | ||
|
|
8d914bab11 | ||
|
|
a06420c884 | ||
|
|
9cc2a97a61 | ||
|
|
d54924909e | ||
|
|
57fe205c72 | ||
|
|
6d97bb797a | ||
|
|
43a1dec280 | ||
|
|
e6250dea76 | ||
|
|
1d85e94075 | ||
|
|
003827ada7 | ||
|
|
5de208d084 | ||
|
|
7447a87d92 | ||
|
|
3cf02ac84b | ||
|
|
fc37e19904 | ||
|
|
398a8938e8 | ||
|
|
abd79475a8 | ||
|
|
40ebfacdac | ||
|
|
42a75ddffa | ||
|
|
bdb9a8451e | ||
|
|
678c083291 | ||
|
|
c309943953 | ||
|
|
20e2f6ddc6 | ||
|
|
59ee40d092 | ||
|
|
26af3fe12d | ||
|
|
bb14652b29 | ||
|
|
af804223a8 | ||
|
|
47547552a6 | ||
|
|
2f6a6aab4a | ||
|
|
5f8683d959 | ||
|
|
644f191c90 | ||
|
|
cab263b88b | ||
|
|
6122198731 | ||
|
|
6e3ae6f3bc | ||
|
|
ccc95e46cc | ||
|
|
260f46c4c3 | ||
|
|
0f9a43bc2b | ||
|
|
df38715c0a | ||
|
|
43c8595d8d | ||
|
|
424d0504cd | ||
|
|
dbf278fa07 | ||
|
|
01491c4042 | ||
|
|
ffb2694039 | ||
|
|
c1b5089ba9 | ||
|
|
de2f32fab9 | ||
|
|
eb146a1c08 | ||
|
|
3176cb27fc | ||
|
|
8dab4b9f60 | ||
|
|
1467e7d61f | ||
|
|
fc2bfb6b65 | ||
|
|
b2754bd782 | ||
|
|
84e71e024b | ||
|
|
b7ed340de2 | ||
|
|
dcede566c7 | ||
|
|
20db8af71d | ||
|
|
d1a7eefbe9 | ||
|
|
39fdaadedf | ||
|
|
ff8ab4bcd6 | ||
|
|
29eaeca327 | ||
|
|
91895bec82 | ||
|
|
45a9caf583 | ||
|
|
7f816df024 | ||
|
|
aa265b7878 | ||
|
|
96a5f53298 | ||
|
|
dc8b5ddb7e | ||
|
|
0c4381b3d0 | ||
|
|
5e56c018a0 | ||
|
|
65e3c1bb65 | ||
|
|
a1ff055f28 | ||
|
|
527ad87f7b | ||
|
|
42bae77141 | ||
|
|
4ecfacdb11 | ||
|
|
f83c53cf3b | ||
|
|
1316f8d42f | ||
|
|
a978f7ab28 | ||
|
|
4cdbe80259 | ||
|
|
67aaf73a7a | ||
|
|
d0455831e0 | ||
|
|
7f60cec354 | ||
|
|
c524ca5fdc | ||
|
|
404ee1a92e | ||
|
|
805c64b607 | ||
|
|
bf5dc8ffd8 | ||
|
|
d08a57d491 | ||
|
|
0479070610 | ||
|
|
6332f62030 | ||
|
|
8cf47452bd | ||
|
|
d48b64a0df | ||
|
|
7c0c60ca7f | ||
|
|
061c608f65 | ||
|
|
0e35995bbb | ||
|
|
d434dd1ae7 | ||
|
|
cbcbdc022b | ||
|
|
2d1252aef8 | ||
|
|
2380895b07 | ||
|
|
6e10a8f27b | ||
|
|
881501ed86 | ||
|
|
57de174802 | ||
|
|
7e69025f15 | ||
|
|
f0112d8f8b | ||
|
|
c93c56a536 | ||
|
|
0e4e60ee16 | ||
|
|
75abdf8fc5 | ||
|
|
0d0080db65 | ||
|
|
7c2778a7b6 | ||
|
|
f18492c1cb | ||
|
|
9a75f4c4ab | ||
|
|
1cf3f810a4 | ||
|
|
01d422537d | ||
|
|
414c05d9c8 | ||
|
|
f9f55f965b | ||
|
|
b6c3ede860 | ||
|
|
5b05a66980 | ||
|
|
ac3c041ced | ||
|
|
3affd6f4c0 | ||
|
|
68840f1687 | ||
|
|
9985e4035e | ||
|
|
243279bdb4 | ||
|
|
ccda7ca9f0 | ||
|
|
c34fc6e0d6 | ||
|
|
14530b6bce | ||
|
|
38f1a62a57 | ||
|
|
c3b146ffa3 | ||
|
|
aaac4f77bc | ||
|
|
b341a96a5d | ||
|
|
88632f91b5 | ||
|
|
a71e8d1019 | ||
|
|
505409938f | ||
|
|
89ded3e72a | ||
|
|
60ffadda86 | ||
|
|
b3b9c62e2c | ||
|
|
0899241c49 | ||
|
|
147452be42 | ||
|
|
4923235658 | ||
|
|
90575990d8 | ||
|
|
008f6d71ea | ||
|
|
bc0ecdc07b | ||
|
|
b6a2ceb6e0 | ||
|
|
632e6a0b09 | ||
|
|
e8c81a6646 | ||
|
|
af2bab7412 | ||
|
|
7e8ee15eb6 | ||
|
|
a397de3991 | ||
|
|
5e64264b34 | ||
|
|
19667aa839 | ||
|
|
a4e9220357 | ||
|
|
f3200baadd | ||
|
|
65b71d15f7 | ||
|
|
58f04af511 | ||
|
|
dec1a548cd | ||
|
|
87a45a7d4f | ||
|
|
5d572187df | ||
|
|
beef9904c3 | ||
|
|
d3891144ce | ||
|
|
b0f356afcc | ||
|
|
219bc77251 | ||
|
|
24e6a842d7 | ||
|
|
23c2486c27 | ||
|
|
803648d557 | ||
|
|
a39a8e13d0 | ||
|
|
b9baaa4772 | ||
|
|
830ea8c6b6 | ||
|
|
abcb7dec53 | ||
|
|
ae47a5e0e7 | ||
|
|
bd00ab68fb | ||
|
|
86fa2cdf0b | ||
|
|
6a16983830 | ||
|
|
8676c6aff7 | ||
|
|
b4f6969b9a | ||
|
|
e3eb9d4e05 | ||
|
|
fa79428dba | ||
|
|
c257f35ba2 | ||
|
|
14c64aa3de | ||
|
|
fe60a9fa9f | ||
|
|
850d66cc97 | ||
|
|
9bfc439351 | ||
|
|
463582e904 | ||
|
|
67ded45bec | ||
|
|
bf804d3e4e | ||
|
|
f175385342 | ||
|
|
cf1cbb6fdc | ||
|
|
f3373b3d5e | ||
|
|
3ac4f7b30e | ||
|
|
1e9b7a58a4 | ||
|
|
334465467b | ||
|
|
b60874b870 | ||
|
|
3c8f913ce8 | ||
|
|
37bc895db0 | ||
|
|
4a8a69a12d | ||
|
|
65f29a2c1a | ||
|
|
c6c4b1b7cb | ||
|
|
c7a6e51d68 | ||
|
|
3d30e3b08f | ||
|
|
5a61227213 | ||
|
|
fca1104f44 | ||
|
|
7aa4d0937a | ||
|
|
b4eeafa8e9 | ||
|
|
26e5e1c8d7 | ||
|
|
27388f83c0 | ||
|
|
3d2fcc8cc7 | ||
|
|
5fe5cbb185 | ||
|
|
eeba3287e6 | ||
|
|
3439c5f859 | ||
|
|
7fadea910d | ||
|
|
a05351a821 | ||
|
|
e69c9a59c6 | ||
|
|
c1c5071c33 | ||
|
|
5dc457dbdd | ||
|
|
d181122072 | ||
|
|
d0f346dae6 | ||
|
|
d00fc4a93d | ||
|
|
d68f43eac3 | ||
|
|
8edbfd1804 | ||
|
|
db466a6f1d | ||
|
|
7e6ac79f09 | ||
|
|
311d41e3d7 | ||
|
|
385dd5c3e4 | ||
|
|
a3a58d71e1 | ||
|
|
9d0ebcddcb | ||
|
|
5a75b2233a | ||
|
|
0ce02f181b | ||
|
|
e301e815e1 | ||
|
|
28a9080163 | ||
|
|
a48f0b016e | ||
|
|
b99597fbe9 | ||
|
|
ab0ff7c864 | ||
|
|
7b021c4450 | ||
|
|
d84232de0c | ||
|
|
eec6cc7e9d | ||
|
|
7a71c2bdbe | ||
|
|
3061324d91 | ||
|
|
428efb1afd | ||
|
|
447723c2c7 | ||
|
|
71eb8a9266 | ||
|
|
95e4185508 | ||
|
|
f5bc0b4343 | ||
|
|
5811b7465c | ||
|
|
2c146568cd | ||
|
|
40ea70b29f | ||
|
|
ec7945df33 | ||
|
|
04e2b64587 | ||
|
|
013863a0e7 | ||
|
|
58d2d41232 | ||
|
|
828598e0ff | ||
|
|
ffa3762a0f | ||
|
|
b5a9ff65ff | ||
|
|
639885087e | ||
|
|
efeb6773bc | ||
|
|
d21dd8921c | ||
|
|
a3ce447047 | ||
|
|
16e89036cb | ||
|
|
73b22d51af | ||
|
|
62b1a34288 | ||
|
|
2f4664adfd | ||
|
|
d0a7babc33 | ||
|
|
2a02ad9afa | ||
|
|
aff0cf1e0d | ||
|
|
bee47f3715 | ||
|
|
79b65e12ed | ||
|
|
47d905d7d6 | ||
|
|
2f1cde5eab | ||
|
|
3d4e147a2a | ||
|
|
a847704a43 | ||
|
|
b6ecd7ac71 | ||
|
|
aca4da79b3 | ||
|
|
a6aafb4ad3 | ||
|
|
11b2d998eb | ||
|
|
23ccc9ac56 | ||
|
|
59ef64d595 | ||
|
|
9531c5f876 | ||
|
|
5c28bed0ac | ||
|
|
ef98fb3232 | ||
|
|
039bd15cf9 | ||
|
|
b0e6e17c3e | ||
|
|
def46b6765 | ||
|
|
8403d18588 | ||
|
|
d4afb6585c | ||
|
|
5b66c1b6fd | ||
|
|
03a3413710 | ||
|
|
ca6fd5042c | ||
|
|
7197a1031f | ||
|
|
2701617548 | ||
|
|
03be71ffff | ||
|
|
859de4efec | ||
|
|
5225c55783 | ||
|
|
a3920f6b8a | ||
|
|
0f6b97a09d | ||
|
|
c384325962 | ||
|
|
ec5f8211ae | ||
|
|
f9e30b4092 | ||
|
|
1762803d92 | ||
|
|
75857dae42 | ||
|
|
1d71c2b9d3 | ||
|
|
abcf44469f | ||
|
|
bd20d0eab6 | ||
|
|
f26926d58e | ||
|
|
baece11a5c | ||
|
|
a3c243f129 | ||
|
|
e31a89aa6e | ||
|
|
aa3d4f077c | ||
|
|
c94d8494ce | ||
|
|
40f09d7d22 | ||
|
|
cdb9a99516 | ||
|
|
958b84413b | ||
|
|
d7255b8e5b | ||
|
|
6b8dbbb2ab | ||
|
|
61c033e0c9 | ||
|
|
e5183a8512 | ||
|
|
8c3533b3a3 | ||
|
|
db90ba7de1 | ||
|
|
c2c4af429c | ||
|
|
a97f254870 | ||
|
|
4daeb6262e | ||
|
|
8941f1d106 | ||
|
|
1c85b6035a | ||
|
|
28200b7940 | ||
|
|
8f9e12c65b | ||
|
|
c325207615 | ||
|
|
c5e67fb05a | ||
|
|
732956dc8d | ||
|
|
9e739b7b13 | ||
|
|
2d197f4b95 | ||
|
|
3dc92b5c42 | ||
|
|
36f1131911 | ||
|
|
9adad50c37 | ||
|
|
5293e9896e | ||
|
|
261e8c5948 | ||
|
|
f92719e40f | ||
|
|
96ac82fd03 | ||
|
|
92bdab0d1b | ||
|
|
b48a317cd7 | ||
|
|
c75c58f61e | ||
|
|
de6d7d28e3 | ||
|
|
6aa78e435e | ||
|
|
98b9234815 | ||
|
|
bb8554a5ae | ||
|
|
7f95b60260 | ||
|
|
7537df9024 | ||
|
|
270ca76237 | ||
|
|
11fbb4e187 | ||
|
|
08da93cf92 | ||
|
|
d09bfffbe5 | ||
|
|
7e34b910f2 | ||
|
|
b2ab99495d | ||
|
|
645c24b5f5 | ||
|
|
bae8c85ea9 | ||
|
|
c0cd1671f9 | ||
|
|
4e348ad617 | ||
|
|
b4e22bd1e9 | ||
|
|
75b35102b5 | ||
|
|
83096ce1cb | ||
|
|
68d5f56f8c | ||
|
|
5ee3ea5347 | ||
|
|
58026ab202 | ||
|
|
2f8127e521 | ||
|
|
197e79f0a2 | ||
|
|
7b6e1b080c | ||
|
|
c739734685 | ||
|
|
2172c4c40f | ||
|
|
23a92f51fd | ||
|
|
0b4db8ba58 | ||
|
|
85966a7249 | ||
|
|
dca75063e3 | ||
|
|
6d18e00535 | ||
|
|
127cba55f5 | ||
|
|
1b19d899cd | ||
|
|
dc6275356a | ||
|
|
68f0abc124 | ||
|
|
30675d8ed2 | ||
|
|
9e06b0d1c2 | ||
|
|
8cbd09126a | ||
|
|
4b952c3613 | ||
|
|
a4e95b1c98 | ||
|
|
174d34ad71 | ||
|
|
1b5e88fc94 | ||
|
|
2649471c5f | ||
|
|
1b3dbd59a8 | ||
|
|
60d055d660 | ||
|
|
bcad893b86 | ||
|
|
bd17ea8cee | ||
|
|
1eee4fc4de | ||
|
|
5a470ccceb | ||
|
|
c24c8d1444 | ||
|
|
a3c632947b | ||
|
|
edd147e970 | ||
|
|
a299fa1619 | ||
|
|
80ba78a81b | ||
|
|
4851ca93f8 | ||
|
|
21faa9a504 | ||
|
|
6fd7e22dca | ||
|
|
93cd18c14d | ||
|
|
4f1dd93ba6 | ||
|
|
737736dca2 | ||
|
|
0f32f09b0d | ||
|
|
324be2768c | ||
|
|
4e9845294c | ||
|
|
479a6351ae | ||
|
|
952e8a8f58 | ||
|
|
642bebd66a | ||
|
|
27f4d6a39b | ||
|
|
8c0caf5856 | ||
|
|
907feba02e | ||
|
|
71b47eb979 | ||
|
|
7aa33ce46b | ||
|
|
d06f51ac33 | ||
|
|
c216f38d49 | ||
|
|
41b0473bbb | ||
|
|
e0b42690ad | ||
|
|
39f6609a46 | ||
|
|
2e0b72808f | ||
|
|
420af508d9 | ||
|
|
e248cae13d | ||
|
|
2996ca79d7 | ||
|
|
51e40b9976 | ||
|
|
83cfed4e87 | ||
|
|
7afc3e422c | ||
|
|
0983de54ef | ||
|
|
fef2d5bc48 | ||
|
|
88d1f4ad20 | ||
|
|
e1f9e1b777 | ||
|
|
e6e649d45d | ||
|
|
32676730a3 | ||
|
|
096d3b692e | ||
|
|
61a20aeefa | ||
|
|
6067136a88 | ||
|
|
0aeba2d5e0 | ||
|
|
2273bcfb3a | ||
|
|
266553473c | ||
|
|
5b253d3b2a | ||
|
|
010cf462ec | ||
|
|
f78f76b36b | ||
|
|
b6f51c9d78 | ||
|
|
24c507d963 | ||
|
|
a466aa0080 | ||
|
|
72e7be4dd5 | ||
|
|
4c2ea8e34d | ||
|
|
087f5b5b2b | ||
|
|
c388de1331 | ||
|
|
ff2493297f | ||
|
|
80f55d6d14 | ||
|
|
97769fd1de | ||
|
|
5823e98887 | ||
|
|
3f6ae96410 | ||
|
|
09cde7def0 | ||
|
|
a86c88559e | ||
|
|
9d8a3c2bd9 | ||
|
|
ff139c74aa | ||
|
|
c25955b707 | ||
|
|
cf9018b20e | ||
|
|
9fded3a8fe | ||
|
|
d71197c5c1 | ||
|
|
fd0ed17112 | ||
|
|
cb07e4e0ef | ||
|
|
e18bd12614 | ||
|
|
531544c89b | ||
|
|
83b3619eda | ||
|
|
c937cc91d0 | ||
|
|
d301b6097a | ||
|
|
f6f826d8df | ||
|
|
e2fd52ded3 | ||
|
|
613293f342 | ||
|
|
811745d8d9 | ||
|
|
23c9e9a2d1 | ||
|
|
2c595d6b31 | ||
|
|
993eac6e3e | ||
|
|
d675b5d5ed | ||
|
|
efc6d22fda | ||
|
|
8b9b133e03 | ||
|
|
09b295bce6 | ||
|
|
6cb0e4bd11 | ||
|
|
0901e683f1 | ||
|
|
9679a75e28 | ||
|
|
17f903efc2 | ||
|
|
e4056a7e25 | ||
|
|
f0fe4284f8 | ||
|
|
0ba28dc6d3 | ||
|
|
29d12d35dd | ||
|
|
757f1faf01 | ||
|
|
fbe4cdd3b4 | ||
|
|
fb91696894 | ||
|
|
6eb7e9926e | ||
|
|
4a61f1d99f | ||
|
|
f19805b88b | ||
|
|
8cfff5d4c3 | ||
|
|
546b505234 | ||
|
|
31d4771551 | ||
|
|
d9385b6cff | ||
|
|
35ce473d31 | ||
|
|
c91911387b | ||
|
|
9306a163cf | ||
|
|
a810355aef | ||
|
|
505525dff1 | ||
|
|
71a36c6a5d | ||
|
|
8b15777b8a | ||
|
|
79a3d74265 | ||
|
|
947e4511e6 | ||
|
|
90abda95b5 | ||
|
|
e04dd0e5cd | ||
|
|
f29124a2a4 | ||
|
|
be30144f4c | ||
|
|
a1290aca48 | ||
|
|
f4ffc26641 | ||
|
|
0289c2e1f7 | ||
|
|
ccc85c3d12 | ||
|
|
21e1cc9f8f | ||
|
|
4e1be033df | ||
|
|
6f51e89067 | ||
|
|
38d474c505 | ||
|
|
b1046ee3db | ||
|
|
6a035c0767 | ||
|
|
c6a7b2df03 | ||
|
|
e763bbdd2b | ||
|
|
7fb49b9027 | ||
|
|
028380f73d | ||
|
|
499daca20e | ||
|
|
7b09b02032 | ||
|
|
983316b493 | ||
|
|
a11dcaf84d | ||
|
|
0131699a0d | ||
|
|
64d00d2d3f | ||
|
|
c4221c3ab6 | ||
|
|
872fce1b86 | ||
|
|
66f31ef6dd | ||
|
|
f84061a8de | ||
|
|
9f505d5dd6 | ||
|
|
d6d8cca90e | ||
|
|
122f680d33 | ||
|
|
20342456c2 | ||
|
|
9efdf37b4c | ||
|
|
1b49947be8 | ||
|
|
ba571d45f6 | ||
|
|
45762f557b | ||
|
|
fcf6fe4dd3 | ||
|
|
91c23658ee | ||
|
|
f48ccc24b2 | ||
|
|
3febf3f5e3 | ||
|
|
d7c9853054 | ||
|
|
1bf16545f5 | ||
|
|
50a678d646 | ||
|
|
49ccbb1cb4 | ||
|
|
a46350a516 | ||
|
|
b1903afe4a | ||
|
|
5ba562d4eb | ||
|
|
1e30f6179f | ||
|
|
2d98e601c9 | ||
|
|
960d0f0e79 | ||
|
|
d4df52a78e | ||
|
|
cbcdabe281 | ||
|
|
18efe50088 | ||
|
|
b52946de24 | ||
|
|
24b1559e5b | ||
|
|
6a33968937 | ||
|
|
6197edcb2a | ||
|
|
72aa8e306d | ||
|
|
dbc5a5470d | ||
|
|
d01b0c3b27 | ||
|
|
028b732059 | ||
|
|
bfb41a381c | ||
|
|
ed3dc867a7 | ||
|
|
5c350c9406 | ||
|
|
06f168124f | ||
|
|
9724fb01c9 | ||
|
|
e182ca85e6 | ||
|
|
147071c92a | ||
|
|
ff6552f764 | ||
|
|
10c18f1792 | ||
|
|
431d30b82d | ||
|
|
b86693a611 | ||
|
|
f342c34295 | ||
|
|
64031d7195 | ||
|
|
8d8d5945f5 | ||
|
|
08ac09a95b | ||
|
|
f44dace8b1 | ||
|
|
cf3d6a21bf | ||
|
|
4d16b90201 | ||
|
|
f3d33854f0 | ||
|
|
a71876d60e | ||
|
|
2826f5a39c | ||
|
|
6cca9ed061 | ||
|
|
3af2859335 | ||
|
|
9b56acc310 | ||
|
|
1865f4f8d5 | ||
|
|
52943da6a5 | ||
|
|
f18524e8e2 | ||
|
|
7bc24ac371 | ||
|
|
8e542c5665 | ||
|
|
b8d9ec36e5 | ||
|
|
e3ef1952eb | ||
|
|
758c5f7f3f | ||
|
|
98f0a0322e | ||
|
|
6941ce6543 | ||
|
|
6727f6c163 | ||
|
|
e60758fa0c | ||
|
|
c2e46d4de8 | ||
|
|
dda5a9d17a | ||
|
|
24107abbef | ||
|
|
805cbf4733 | ||
|
|
9d341c4e0b | ||
|
|
a9641b4970 | ||
|
|
0278c45d34 | ||
|
|
143262b6fc | ||
|
|
c0a798e3e3 | ||
|
|
0855873117 | ||
|
|
e35a1df79a | ||
|
|
516ff7389a | ||
|
|
22d28666ea | ||
|
|
ed6831595f | ||
|
|
894a4275af | ||
|
|
65d56f3135 | ||
|
|
6be899fe1c | ||
|
|
d0f300890c | ||
|
|
860dc466aa | ||
|
|
f9bce7be7b | ||
|
|
ccf4f11095 | ||
|
|
6c68bb0f73 | ||
|
|
3434e5d738 | ||
|
|
575c7236cd | ||
|
|
d4c7146850 | ||
|
|
08d8d04c8c | ||
|
|
fae9cdf292 | ||
|
|
7c62376d7e | ||
|
|
410bf9cc63 | ||
|
|
79f47d8830 | ||
|
|
0ed844ef0d | ||
|
|
017012cd05 | ||
|
|
e0f960dd28 | ||
|
|
20e377dca3 | ||
|
|
b373785ec3 | ||
|
|
d8f7d27511 | ||
|
|
7eff687b4c | ||
|
|
e056bc3209 | ||
|
|
be520fc104 | ||
|
|
f80536944d | ||
|
|
81f54aca1d | ||
|
|
13004de111 | ||
|
|
82e8b57e89 | ||
|
|
9b32cf08d8 | ||
|
|
098fe77a54 | ||
|
|
64e037ad90 | ||
|
|
7894ed7e0f | ||
|
|
3523bc669b | ||
|
|
dd919eb029 | ||
|
|
1c15204198 | ||
|
|
d5f0d2bbb2 | ||
|
|
5ae9cf18c9 | ||
|
|
a06d55a00a | ||
|
|
486774c8f7 | ||
|
|
583c728245 | ||
|
|
988067eedc | ||
|
|
b044b17d8a | ||
|
|
329b38b5d3 | ||
|
|
cec353a96c | ||
|
|
a93545f7af | ||
|
|
826efc6074 | ||
|
|
97d84936aa | ||
|
|
7070cd6853 | ||
|
|
87e2202c51 | ||
|
|
e776c86aff | ||
|
|
0e85c9d05f | ||
|
|
84899b4410 | ||
|
|
9e2a21c80a | ||
|
|
2e9f7ced10 | ||
|
|
4e2c0cf349 | ||
|
|
83d1241ec9 | ||
|
|
aa946bb047 | ||
|
|
65c8a0e499 | ||
|
|
f8f625e5a1 | ||
|
|
c1d8ce51d5 | ||
|
|
34603c287f | ||
|
|
cddd7b5ee3 | ||
|
|
c6f4c64a67 | ||
|
|
bd33ec7edd | ||
|
|
2b533f9617 | ||
|
|
85d26e9c8e | ||
|
|
3442d0da70 | ||
|
|
fb7317a667 | ||
|
|
bab395f982 | ||
|
|
d092879a74 | ||
|
|
005f22a349 | ||
|
|
96bbd2e038 | ||
|
|
a6f75d030d | ||
|
|
c054de0c67 | ||
|
|
fcfd656c4b | ||
|
|
79f7ea4277 | ||
|
|
1c45d841d2 | ||
|
|
8a6ab625cc | ||
|
|
59f0015cc0 | ||
|
|
dfadbfffd5 | ||
|
|
099acfcdb6 | ||
|
|
162127c2a1 | ||
|
|
b9dbda107a | ||
|
|
5352998818 | ||
|
|
fc0984f082 | ||
|
|
0c717ea672 | ||
|
|
4493d902b2 | ||
|
|
85975857f0 | ||
|
|
ac9f25abf3 | ||
|
|
953d458a37 | ||
|
|
c343f30af6 | ||
|
|
2e07586089 | ||
|
|
8702577308 | ||
|
|
fe7302df80 | ||
|
|
d04ff2a22e | ||
|
|
5a505f76e5 | ||
|
|
f9a08dcf16 | ||
|
|
d5f00b25d6 | ||
|
|
4d73eaa341 | ||
|
|
66bb28661e | ||
|
|
fe79d134fd | ||
|
|
83bd59c595 | ||
|
|
6f209951e4 | ||
|
|
daddd02fcf | ||
|
|
fdc64682af | ||
|
|
748f0bf36f | ||
|
|
3e06a573e7 | ||
|
|
8b8beb3f0c | ||
|
|
9346df94f5 | ||
|
|
2e7b7c10f7 | ||
|
|
1268dbeba6 | ||
|
|
1e1be4bd86 | ||
|
|
0dfbaba2e3 | ||
|
|
e709e45880 | ||
|
|
f59cd035c8 | ||
|
|
aeadfaa27e | ||
|
|
7746d97019 | ||
|
|
44251a73c0 | ||
|
|
605748b35b | ||
|
|
a659a2f176 | ||
|
|
b6d7231248 | ||
|
|
7760efac74 | ||
|
|
d263c6e4cc | ||
|
|
693b8eb490 | ||
|
|
9197e97d9e | ||
|
|
a4b83b576e | ||
|
|
18fd76bdbd | ||
|
|
444bbfb5aa | ||
|
|
139e19e747 | ||
|
|
a77cfd091c | ||
|
|
66b4df7a65 | ||
|
|
4831b43114 | ||
|
|
c4ed6341fe | ||
|
|
b837053eee | ||
|
|
cf415d45d3 | ||
|
|
2c7fedc90c | ||
|
|
674b608a8f | ||
|
|
917956c6b4 | ||
|
|
7f839cd2f9 | ||
|
|
0a36d2741a | ||
|
|
213314e324 | ||
|
|
eab055c906 | ||
|
|
d1622d5bfa | ||
|
|
2dbe7a9cc2 | ||
|
|
d84198743c | ||
|
|
a89dd87c35 | ||
|
|
4a914bae43 | ||
|
|
3236eb239c | ||
|
|
7b439696b9 | ||
|
|
6bc5e9ed13 | ||
|
|
9651ac3ece | ||
|
|
7c8f737b43 | ||
|
|
0198a3e8a9 | ||
|
|
c17ad66af6 | ||
|
|
9943bf336e | ||
|
|
95f048daf0 | ||
|
|
4899361c7a | ||
|
|
98b82110b8 | ||
|
|
3bb09ad2d9 | ||
|
|
8c66daed6d | ||
|
|
b92c2d428a | ||
|
|
c54a1d0b0b | ||
|
|
8094acebdf | ||
|
|
e0f4112f49 | ||
|
|
2979561044 | ||
|
|
5aeeefa0f0 | ||
|
|
2e8fea9bcd | ||
|
|
4dd3ab85b4 | ||
|
|
e0d6c7b354 | ||
|
|
18f4df9949 | ||
|
|
1c0058a0a4 | ||
|
|
7a9bd42b15 | ||
|
|
53d691666c | ||
|
|
ca453cb066 | ||
|
|
4dbd4197df | ||
|
|
e2cd220b5c | ||
|
|
2edf1cf3f1 | ||
|
|
be3d751164 | ||
|
|
4f8a035c22 | ||
|
|
c0e047672e | ||
|
|
9345865ee0 | ||
|
|
3d30d4e3bb | ||
|
|
c948927ba5 | ||
|
|
05e47e7d50 | ||
|
|
7a7b79074a | ||
|
|
f90372c9df | ||
|
|
758ee87ab8 | ||
|
|
6a4957e4bc | ||
|
|
f22f7f606c | ||
|
|
484c786f61 | ||
|
|
8e3e6b89ef | ||
|
|
f44c695a04 | ||
|
|
3468880077 | ||
|
|
21f2dd62f5 | ||
|
|
608c253e8e | ||
|
|
30edb77b30 | ||
|
|
a6f76bf1ff | ||
|
|
592c676e98 | ||
|
|
6c3b357a5e | ||
|
|
9661560698 | ||
|
|
f33c3dc44a | ||
|
|
2db9fe181e | ||
|
|
63f6ff48cf | ||
|
|
dc366f6ed4 | ||
|
|
5ce3d00570 | ||
|
|
72db7b3f19 | ||
|
|
4e5dfecccc | ||
|
|
8da40e60cf | ||
|
|
2aaf902d83 | ||
|
|
2b5d1bec94 | ||
|
|
0f79254c8c | ||
|
|
825538d653 | ||
|
|
c487a52cbd | ||
|
|
b987272a4a | ||
|
|
519e082a85 | ||
|
|
85d91f0b89 | ||
|
|
b895b660b6 | ||
|
|
ce50baedb5 | ||
|
|
8a7c628095 | ||
|
|
79629f4d10 | ||
|
|
45e44e513b | ||
|
|
5529382a05 | ||
|
|
e6475fe58e | ||
|
|
a46483f080 | ||
|
|
f846b5d50b | ||
|
|
7c95793fc0 | ||
|
|
c8eb41f7f5 | ||
|
|
494b124599 | ||
|
|
b8ce971fc8 | ||
|
|
3ef96948c8 | ||
|
|
84b2e470ee | ||
|
|
f4aa4dee53 | ||
|
|
ebc3d93774 | ||
|
|
61febe0299 | ||
|
|
ce45d0b5bd | ||
|
|
5e21375181 | ||
|
|
49697c20d4 | ||
|
|
19e0d6d3c4 | ||
|
|
9934a1312a | ||
|
|
a8ebe2dcf3 | ||
|
|
3cf92843fb | ||
|
|
6dc33bcac2 | ||
|
|
d5df5ae95d | ||
|
|
7e47e5862e | ||
|
|
264937dded | ||
|
|
d5595c1fcc | ||
|
|
24da584d20 | ||
|
|
c852d47373 | ||
|
|
b4a542a0e7 | ||
|
|
1f2269395f | ||
|
|
d90e60f171 | ||
|
|
b5b089043d | ||
|
|
c5caec66c1 | ||
|
|
f5e43fe0c5 | ||
|
|
4803d838ab | ||
|
|
0c3f32344e | ||
|
|
dbacb524c9 | ||
|
|
e5d7fa8bf6 | ||
|
|
f7301f9217 | ||
|
|
3ca676c57b | ||
|
|
eaca079fe2 | ||
|
|
53cdf18299 | ||
|
|
9180a125e6 | ||
|
|
32f0b01cd8 | ||
|
|
c9cb420377 | ||
|
|
eff1e3272f | ||
|
|
cda3a327d9 | ||
|
|
be78b4d868 | ||
|
|
bb12b85dfd | ||
|
|
9599e4e3ee | ||
|
|
b88b807a2b | ||
|
|
f2907f6b0c | ||
|
|
bdff300787 | ||
|
|
c0bd9c836a | ||
|
|
1b105083d4 | ||
|
|
ea03067b2b | ||
|
|
dc2f606bf9 | ||
|
|
a09fb92936 | ||
|
|
bfd0b3d206 | ||
|
|
3d73f58744 | ||
|
|
609851d4d1 | ||
|
|
74a80b34b7 | ||
|
|
737bf305b0 | ||
|
|
e892f22a4c | ||
|
|
3b2b4856f6 | ||
|
|
e282f97202 | ||
|
|
680dc57a8d | ||
|
|
d4a060520c | ||
|
|
a14f21b024 | ||
|
|
61c3a2756e | ||
|
|
626e64a58e | ||
|
|
fb56c7073d | ||
|
|
1daea8e21c | ||
|
|
66990846cc | ||
|
|
e51937e322 | ||
|
|
501516ed1d | ||
|
|
535a5737ba | ||
|
|
2c73df1a97 | ||
|
|
d215046cf4 | ||
|
|
948fa47fac | ||
|
|
7a59d2fcc1 | ||
|
|
c2651b9beb | ||
|
|
4dfce1430f | ||
|
|
e767b54526 | ||
|
|
300a8aa5fb | ||
|
|
27d159a698 | ||
|
|
3d5c6276c0 | ||
|
|
92e12f0f36 | ||
|
|
608d416506 | ||
|
|
ed28db35fb | ||
|
|
d9b857abf6 | ||
|
|
edcb0984e8 | ||
|
|
9e54b70fdd | ||
|
|
658930e425 | ||
|
|
6ee0ca0485 | ||
|
|
0da87913c6 | ||
|
|
daa480276f | ||
|
|
c99c90d574 | ||
|
|
9b83e6b41e | ||
|
|
03a24b0155 | ||
|
|
1f60fe227f | ||
|
|
62cc2d1b7e | ||
|
|
61377dd5f6 | ||
|
|
2c0d112f11 | ||
|
|
460c92617d | ||
|
|
9f6648a0c7 | ||
|
|
d1a2ef7edf | ||
|
|
8a124b8195 | ||
|
|
6f075fc768 | ||
|
|
3fdf3ea21d | ||
|
|
ca552f7748 | ||
|
|
70ac3e95e2 | ||
|
|
e79d357014 | ||
|
|
9facf68532 | ||
|
|
56b0f62499 | ||
|
|
6201e1ccaa | ||
|
|
fc0a42bf71 | ||
|
|
55d57ef95a | ||
|
|
588d045b47 | ||
|
|
67e0b92fc3 | ||
|
|
5bea8fa817 | ||
|
|
0212a8f53d | ||
|
|
96afcf86f0 | ||
|
|
c389ed837e | ||
|
|
b8c898e883 | ||
|
|
12159ce377 | ||
|
|
6e8646f619 | ||
|
|
e3280656a6 | ||
|
|
f934bc5c5d | ||
|
|
55e1eb5f06 | ||
|
|
41f0839961 | ||
|
|
161a9e0bf2 | ||
|
|
969e7c0a14 | ||
|
|
b9c6df5503 | ||
|
|
1a50f3da22 | ||
|
|
97feb1117d | ||
|
|
5d3278dac8 | ||
|
|
3423abc6b0 | ||
|
|
a695647175 | ||
|
|
0d1941a320 | ||
|
|
c46dac5499 | ||
|
|
4a13fd0d40 | ||
|
|
88eb13fbe8 | ||
|
|
31c8a05d13 | ||
|
|
0c8eac7321 | ||
|
|
a79cbd937e | ||
|
|
957142db99 | ||
|
|
ca01b72f9e | ||
|
|
9fd769cf65 | ||
|
|
d329895cdb | ||
|
|
0e1f8d8f1f | ||
|
|
fa9e186062 | ||
|
|
12b8026ade | ||
|
|
2308895a68 | ||
|
|
a6f14cfa9e | ||
|
|
0d8eb9669a | ||
|
|
f6798ddf82 | ||
|
|
94f5296067 | ||
|
|
42fcbecf7c | ||
|
|
a8e6d27983 | ||
|
|
584c8885f3 | ||
|
|
36d9e34087 | ||
|
|
c11dcb514b | ||
|
|
a9a29914ef | ||
|
|
8f983029dc | ||
|
|
fb46f5afcc | ||
|
|
0f788365a8 | ||
|
|
8551592990 | ||
|
|
d12765bb92 | ||
|
|
74d01d879c | ||
|
|
a193eb55ed | ||
|
|
41c56d896c | ||
|
|
13c77213df | ||
|
|
f470cbd462 | ||
|
|
22999d5632 | ||
|
|
ff7c38bc35 | ||
|
|
a54258ffb2 | ||
|
|
cf0c30c622 | ||
|
|
6fb6d326a7 | ||
|
|
41c6cb13df | ||
|
|
1ad07ae491 | ||
|
|
bcdf4bb8e6 | ||
|
|
ba0cf8467b | ||
|
|
1fbb25391f | ||
|
|
ee809b7cc4 | ||
|
|
2f39f077f7 | ||
|
|
9ab74c881d | ||
|
|
ba0a2562b2 | ||
|
|
b3f62f72ad | ||
|
|
e24cfea200 | ||
|
|
ca842f451c | ||
|
|
e20d962b32 | ||
|
|
0238118a36 | ||
|
|
2899af86d6 | ||
|
|
3e6cf167ad | ||
|
|
a7890366bb | ||
|
|
23ce865aa4 | ||
|
|
97776ad4f6 | ||
|
|
7f496b7f75 | ||
|
|
3650aa8505 | ||
|
|
f0f9f94a1e | ||
|
|
1f077ef95a | ||
|
|
465c4f418c | ||
|
|
cd028ecb45 | ||
|
|
13bb9ab322 | ||
|
|
5a34e1f816 | ||
|
|
0d7835338b | ||
|
|
a3ba57dc7f | ||
|
|
0a810549b3 | ||
|
|
cdacc346ed | ||
|
|
d4da74d82d | ||
|
|
b5e2f3157c | ||
|
|
486feeb4f8 | ||
|
|
a63150406a | ||
|
|
61966ab7e2 | ||
|
|
5fa1f68f93 | ||
|
|
a0a47e443d | ||
|
|
9761f3d9c8 | ||
|
|
8dc9a123cd | ||
|
|
f67eb9ce67 | ||
|
|
8ca858794f | ||
|
|
11830ce814 | ||
|
|
75654f52bd | ||
|
|
f504bf4f84 | ||
|
|
84d03a2945 | ||
|
|
003b72d7ad | ||
|
|
bb55276ca9 | ||
|
|
90946e69ee | ||
|
|
03fc984cc6 | ||
|
|
c5df5c5c09 | ||
|
|
daccd36cc5 | ||
|
|
798c4cafa8 | ||
|
|
135c279e1d | ||
|
|
fb9092e59a | ||
|
|
2a357d1678 | ||
|
|
6e3f30db21 | ||
|
|
0c74308945 | ||
|
|
daf3d810d1 | ||
|
|
84be701870 | ||
|
|
54750f9287 | ||
|
|
9b635d9ee7 | ||
|
|
30753bff63 | ||
|
|
8654cd39cc | ||
|
|
e5ba35372b | ||
|
|
5719e5be47 | ||
|
|
51fac93c54 | ||
|
|
fbcbe4d581 | ||
|
|
1390223637 | ||
|
|
2864b747a3 | ||
|
|
45032b7294 | ||
|
|
d1d604abbf | ||
|
|
691a8318f4 | ||
|
|
05a35a6413 | ||
|
|
c8f6e3c3f5 | ||
|
|
25e10558ee |
14
.travis.yml
Normal file
14
.travis.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
dist: bionic
|
||||
sudo: required
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/pbuilder-bases
|
||||
matrix:
|
||||
include:
|
||||
- env: TARGET_OS=stretch
|
||||
before_install:
|
||||
- "$TRAVIS_BUILD_DIR/travis/$TRAVIS_OS_NAME.$TARGET_OS.before_install"
|
||||
install:
|
||||
- "$TRAVIS_BUILD_DIR/travis/$TRAVIS_OS_NAME.$TARGET_OS.install"
|
||||
script:
|
||||
- "$TRAVIS_BUILD_DIR/travis/$TRAVIS_OS_NAME.$TARGET_OS.script"
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
39
AndorsTrail/.gitignore
vendored
39
AndorsTrail/.gitignore
vendored
@@ -1,8 +1,15 @@
|
||||
# Android ignores
|
||||
app/src/main/res
|
||||
app/src/main/assets
|
||||
gen/
|
||||
bin/
|
||||
target/
|
||||
local.properties
|
||||
app/build/intermediates/
|
||||
build/
|
||||
debug/
|
||||
release/
|
||||
.gradle/
|
||||
|
||||
#IntelliJ
|
||||
.idea/
|
||||
@@ -14,3 +21,35 @@ out/test/
|
||||
# Other
|
||||
.metadata
|
||||
.svn/
|
||||
|
||||
|
||||
#copied from https://github.com/github/gitignore/blob/main/Gradle.gitignore
|
||||
.gradle
|
||||
**/build/
|
||||
!src/**/build/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
# Avoid ignore Gradle wrappper properties
|
||||
!gradle-wrapper.properties
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
# Eclipse Gradle plugin generated files
|
||||
# Eclipse Core
|
||||
.project
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
#copied from https://github.com/github/gitignore/blob/main/Gradle.gitignore
|
||||
|
||||
|
||||
/AndorsTrail/.gradle
|
||||
/AndorsTrail/gradle/wrapper
|
||||
/AndorsTrail/app/build/
|
||||
/AndorsTrail/app/debug/
|
||||
/AndorsTrail/app/release/
|
||||
|
||||
Binary file not shown.
BIN
AndorsTrail/.gradle/7.3.3/fileChanges/last-build.bin
Normal file
BIN
AndorsTrail/.gradle/7.3.3/fileChanges/last-build.bin
Normal file
Binary file not shown.
0
AndorsTrail/.gradle/7.3.3/gc.properties
Normal file
0
AndorsTrail/.gradle/7.3.3/gc.properties
Normal file
0
AndorsTrail/.gradle/vcs-1/gc.properties
Normal file
0
AndorsTrail/.gradle/vcs-1/gc.properties
Normal file
6
AndorsTrail/.idea/compiler.xml
generated
Normal file
6
AndorsTrail/.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
||||
20
AndorsTrail/.idea/gradle.xml
generated
Normal file
20
AndorsTrail/.idea/gradle.xml
generated
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="1.8" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
25
AndorsTrail/.idea/jarRepositories.xml
generated
Normal file
25
AndorsTrail/.idea/jarRepositories.xml
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="BintrayJCenter" />
|
||||
<option name="name" value="BintrayJCenter" />
|
||||
<option name="url" value="https://jcenter.bintray.com/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="Google" />
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
10
AndorsTrail/.idea/misc.xml
generated
Normal file
10
AndorsTrail/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
6
AndorsTrail/.idea/vcs.xml
generated
Normal file
6
AndorsTrail/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
166
AndorsTrail/.idea/workspace.xml
generated
Normal file
166
AndorsTrail/.idea/workspace.xml
generated
Normal file
@@ -0,0 +1,166 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="NONE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="fb7bf33b-30cf-40b9-a238-3e2f6f604a8f" name="Changes" comment="" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="ExecutionTargetManager" SELECTED_TARGET="device_and_snapshot_combo_box_target[C:\Users\chris\.android\avd\Nexus_5_API_30.avd]" />
|
||||
<component name="ExternalProjectsData">
|
||||
<projectState path="$PROJECT_DIR$">
|
||||
<ProjectState />
|
||||
</projectState>
|
||||
</component>
|
||||
<component name="ExternalProjectsManager">
|
||||
<system id="GRADLE">
|
||||
<state>
|
||||
<projects_view>
|
||||
<tree_state>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="AndorsTrail" type="f1a62948:ProjectNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</tree_state>
|
||||
</projects_view>
|
||||
</state>
|
||||
</system>
|
||||
</component>
|
||||
<component name="GenerateSignedApkSettings">
|
||||
<option name="KEY_STORE_PATH" value="C:\AT\sec\AndorsTrail.keystore" />
|
||||
<option name="KEY_ALIAS" value="andorstrail" />
|
||||
<option name="REMEMBER_PASSWORDS" value="true" />
|
||||
<option name="BUILD_TARGET_KEY" value="apk" />
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
|
||||
</component>
|
||||
<component name="ProjectId" id="2FG0LqADbxm6Q1t3yQ9BlX5APzJ" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="ApkExportedModule" value="AndorsTrail.app" />
|
||||
<property name="ExportApk.ApkPath" value="C:\AT\AndorsTrailRelease\andors-trail\AndorsTrail\app" />
|
||||
<property name="ExportApk.BuildVariants" value="release" />
|
||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||
<property name="RunOnceActivity.cidr.known.project.marker" value="true" />
|
||||
<property name="android.sdk.path" value="$USER_HOME$/AppData/Local/Android/Sdk" />
|
||||
<property name="cidr.known.project.marker" value="true" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../../sec/AndorsTrail.keystore" />
|
||||
<property name="settings.editor.selected.configurable" value="device.file.explorer" />
|
||||
<property name="show.inlinked.gradle.project.popup" value="false" />
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="<template>" type="Applet" default="true" selected="false">
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="HTML_FILE_NAME" />
|
||||
<option name="HTML_USED" value="false" />
|
||||
<option name="WIDTH" value="400" />
|
||||
<option name="HEIGHT" value="300" />
|
||||
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
</configuration>
|
||||
<configuration name="<template>" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" default="true" selected="false">
|
||||
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
|
||||
</configuration>
|
||||
<configuration name="app" type="AndroidRunConfigurationType" factoryName="Android App">
|
||||
<module name="AndorsTrail.app" />
|
||||
<option name="DEPLOY" value="true" />
|
||||
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
|
||||
<option name="DEPLOY_AS_INSTANT" value="false" />
|
||||
<option name="ARTIFACT_NAME" value="" />
|
||||
<option name="PM_INSTALL_OPTIONS" value="" />
|
||||
<option name="ALL_USERS" value="false" />
|
||||
<option name="ALWAYS_INSTALL_WITH_PM" value="false" />
|
||||
<option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
|
||||
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
|
||||
<option name="MODE" value="default_activity" />
|
||||
<option name="CLEAR_LOGCAT" value="false" />
|
||||
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
|
||||
<option name="INSPECTION_WITHOUT_ACTIVITY_RESTART" value="false" />
|
||||
<option name="TARGET_SELECTION_MODE" value="DEVICE_AND_SNAPSHOT_COMBO_BOX" />
|
||||
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
|
||||
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
|
||||
<option name="DEBUGGER_TYPE" value="Auto" />
|
||||
<Auto>
|
||||
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||
<option name="SHOW_STATIC_VARS" value="true" />
|
||||
<option name="WORKING_DIR" value="" />
|
||||
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||
</Auto>
|
||||
<Hybrid>
|
||||
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||
<option name="SHOW_STATIC_VARS" value="true" />
|
||||
<option name="WORKING_DIR" value="" />
|
||||
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||
</Hybrid>
|
||||
<Java />
|
||||
<Native>
|
||||
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||
<option name="SHOW_STATIC_VARS" value="true" />
|
||||
<option name="WORKING_DIR" value="" />
|
||||
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||
</Native>
|
||||
<Profilers>
|
||||
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
|
||||
<option name="STARTUP_PROFILING_ENABLED" value="false" />
|
||||
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
|
||||
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Java/Kotlin Method Sample (legacy)" />
|
||||
<option name="STARTUP_NATIVE_MEMORY_PROFILING_ENABLED" value="false" />
|
||||
<option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
|
||||
</Profilers>
|
||||
<option name="DEEP_LINK" value="" />
|
||||
<option name="ACTIVITY_CLASS" value="" />
|
||||
<option name="SEARCH_ACTIVITY_IN_GLOBAL_SCOPE" value="false" />
|
||||
<option name="SKIP_ACTIVITY_VALIDATION" value="false" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration default="true" type="Application" factoryName="Application">
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration default="true" type="JUnit" factoryName="JUnit">
|
||||
<option name="TEST_OBJECT" value="class" />
|
||||
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration default="true" type="TestNG">
|
||||
<option name="TEST_OBJECT" value="CLASS" />
|
||||
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
|
||||
<properties />
|
||||
<listeners />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="fb7bf33b-30cf-40b9-a238-3e2f6f604a8f" name="Changes" comment="" />
|
||||
<created>1664103080085</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1664103080085</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>AndorsTrail</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="EclipseModuleManager" forced_jdk="true">
|
||||
<conelement value="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK" />
|
||||
<conelement value="com.android.ide.eclipse.adt.LIBRARIES" />
|
||||
<src_description expected_position="1">
|
||||
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
|
||||
<src_folder value="file://$MODULE_DIR$/gen" expected_position="1" />
|
||||
</src_description>
|
||||
</component>
|
||||
<component name="FacetManager">
|
||||
<facet type="android" name="Android">
|
||||
<configuration />
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/bin/classes" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/libs/android-support-v4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
|
||||
23
AndorsTrail/app/build.gradle
Normal file
23
AndorsTrail/app/build.gradle
Normal file
@@ -0,0 +1,23 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.gpl.rpg.AndorsTrail"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 30
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.android.support:support-v4:28.0.0'
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<lint>
|
||||
<issue id="MissingTranslation" severity="ignore" />
|
||||
<issue id="TypographyDashes" severity="ignore" />
|
||||
@@ -1,66 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.gpl.rpg.AndorsTrail"
|
||||
android:versionCode="54"
|
||||
android:versionName="0.7.11"
|
||||
android:installLocation="auto"
|
||||
>
|
||||
<uses-sdk
|
||||
android:minSdkVersion="4"
|
||||
android:targetSdkVersion="28"
|
||||
/>
|
||||
|
||||
<supports-screens
|
||||
android:smallScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:largeScreens="true"
|
||||
android:xlargeScreens="true"
|
||||
android:anyDensity="true"
|
||||
/>
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
|
||||
<application
|
||||
android:name=".AndorsTrailApplication"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@drawable/icon"
|
||||
android:description="@string/app_description"
|
||||
android:allowBackup="true"
|
||||
android:theme="@style/AndorsTrailTheme_Blue"
|
||||
>
|
||||
<activity
|
||||
android:name=".activity.StartScreenActivity"
|
||||
android:clearTaskOnLaunch="true"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AndorsTrailTheme_Blue.NoBackground"
|
||||
/>
|
||||
<activity android:name=".activity.HeroinfoActivity" />
|
||||
<activity android:name=".activity.MonsterInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ItemInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.LevelUpActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.MonsterEncounterActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ConversationActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ShopActivity" />
|
||||
<activity android:name=".activity.AboutActivity" />
|
||||
<activity android:name=".activity.LoadingActivity" />
|
||||
<activity android:name=".activity.Preferences" />
|
||||
<activity android:name=".activity.LoadSaveActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ActorConditionInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.BulkSelectionInterface" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.SkillInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.DisplayWorldMapActivity" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.gpl.rpg.AndorsTrail"
|
||||
android:versionCode="66"
|
||||
android:versionName="0.8.2"
|
||||
android:installLocation="auto"
|
||||
>
|
||||
<uses-sdk
|
||||
android:minSdkVersion="4"
|
||||
android:targetSdkVersion="30"
|
||||
/>
|
||||
|
||||
<supports-screens
|
||||
android:smallScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:largeScreens="true"
|
||||
android:xlargeScreens="true"
|
||||
android:anyDensity="true"
|
||||
/>
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
|
||||
<application
|
||||
android:name=".AndorsTrailApplication"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@drawable/icon"
|
||||
android:description="@string/app_description"
|
||||
android:allowBackup="true"
|
||||
android:theme="@style/AndorsTrailTheme_Blue"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:hasFragileUserData="true"
|
||||
android:preserveLegacyExternalStorage="true"
|
||||
>
|
||||
<activity
|
||||
android:name=".activity.StartScreenActivity"
|
||||
android:clearTaskOnLaunch="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AndorsTrailTheme_Blue.NoBackground"
|
||||
/>
|
||||
<activity android:name=".activity.HeroinfoActivity" />
|
||||
<activity android:name=".activity.MonsterInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ItemInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.LevelUpActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.MonsterEncounterActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ConversationActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ShopActivity" />
|
||||
<activity android:name=".activity.AboutActivity" />
|
||||
<activity android:name=".activity.LoadingActivity" />
|
||||
<activity android:name=".activity.Preferences" />
|
||||
<activity android:name=".activity.LoadSaveActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ActorConditionInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.BulkSelectionInterface" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.SkillInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.DisplayWorldMapActivity" />
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="com.gpl.rpg.AndorsTrail.fileprovider"
|
||||
android:grantUriPermissions="true"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/fileprovider" />
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,171 +1,169 @@
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.util.Pair;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Environment;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
public final class AndorsTrailApplication extends Application {
|
||||
|
||||
public static final boolean DEVELOPMENT_DEBUGRESOURCES = false;
|
||||
public static final boolean DEVELOPMENT_FORCE_STARTNEWGAME = false;
|
||||
public static final boolean DEVELOPMENT_FORCE_CONTINUEGAME = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGBUTTONS = false;
|
||||
public static final boolean DEVELOPMENT_FASTSPEED = false;
|
||||
public static final boolean DEVELOPMENT_VALIDATEDATA = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGMESSAGES = false;
|
||||
public static final boolean DEVELOPMENT_INCOMPATIBLE_SAVEGAMES = DEVELOPMENT_DEBUGRESOURCES || DEVELOPMENT_DEBUGBUTTONS || DEVELOPMENT_FASTSPEED;
|
||||
public static final int DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION = 999;
|
||||
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION : 54;
|
||||
public static final String CURRENT_VERSION_DISPLAY = "0.7.11";
|
||||
public static final boolean IS_RELEASE_VERSION = !CURRENT_VERSION_DISPLAY.matches(".*[a-d].*");
|
||||
|
||||
private final AndorsTrailPreferences preferences = new AndorsTrailPreferences();
|
||||
private WorldContext world = new WorldContext();
|
||||
private ControllerContext controllers = new ControllerContext(this, world);
|
||||
private WorldSetup setup = new WorldSetup(world, controllers, this);
|
||||
public WorldContext getWorld() { return world; }
|
||||
public WorldSetup getWorldSetup() { return setup; }
|
||||
public AndorsTrailPreferences getPreferences() { return preferences; }
|
||||
public ControllerContext getControllerContext() { return controllers; }
|
||||
|
||||
public static AndorsTrailApplication getApplicationFromActivity(Activity activity) {
|
||||
return ((AndorsTrailApplication) activity.getApplication());
|
||||
}
|
||||
public static AndorsTrailApplication getApplicationFromActivityContext(Context context) {
|
||||
return getApplicationFromActivity(getActivityFromActivityContext(context));
|
||||
}
|
||||
private static Activity getActivityFromActivityContext(Context context) {
|
||||
return (Activity) context;
|
||||
}
|
||||
|
||||
public boolean isInitialized() { return world.model != null; }
|
||||
|
||||
public void setWindowParameters(Activity activity) {
|
||||
activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
if (preferences.fullscreen) {
|
||||
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
activity.getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
//Get default locale at startup, as somehow it seems that changing the app's
|
||||
//configured locale impacts the value returned by Locale.getDefault() nowadays.
|
||||
private final Locale defaultLocale = Locale.getDefault();
|
||||
|
||||
private Pair<String, Locale> lastLocale = null;
|
||||
|
||||
public boolean setLocale(Activity context) {
|
||||
Resources res = context.getResources();
|
||||
Configuration conf = res.getConfiguration();
|
||||
|
||||
Locale targetLocale;
|
||||
|
||||
if (lastLocale != null && lastLocale.first == preferences.language) {
|
||||
targetLocale = lastLocale.second;
|
||||
} else {
|
||||
targetLocale = localeForLanguageTag(preferences.language);
|
||||
lastLocale = new Pair<String, Locale>(preferences.language, targetLocale);
|
||||
}
|
||||
|
||||
if (targetLocale.equals(conf.locale)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
conf.locale = targetLocale;
|
||||
res.updateConfiguration(conf, res.getDisplayMetrics());
|
||||
this.getResources().updateConfiguration(conf, res.getDisplayMetrics());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Supports language or language_COUNTRY in short form e.g. "en" or "en_US"
|
||||
private Locale localeForLanguageTag(String languageTag) {
|
||||
Locale locale = null;
|
||||
if (languageTag != null && !languageTag.equalsIgnoreCase("default")) {
|
||||
final int pos = languageTag.indexOf('-');
|
||||
if (pos == -1) {
|
||||
locale = new Locale(languageTag);
|
||||
}
|
||||
else locale = new Locale(languageTag.substring(0, pos), languageTag.substring(pos+1));
|
||||
}
|
||||
if (locale == null) {
|
||||
locale = defaultLocale;
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging to text file system as found on https://stackoverflow.com/questions/19565685/saving-logcat-to-a-text-file-in-android-device
|
||||
*/
|
||||
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
if ( DEVELOPMENT_DEBUGMESSAGES && isExternalStorageWritable() ) {
|
||||
|
||||
File root = Environment.getExternalStorageDirectory();
|
||||
File appDirectory = new File(root, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
File logDirectory = new File( appDirectory, "log" );
|
||||
File logFile = new File( logDirectory, "logcat" + System.currentTimeMillis() + ".txt" );
|
||||
|
||||
// create app folder
|
||||
if ( !appDirectory.exists() ) {
|
||||
appDirectory.mkdir();
|
||||
}
|
||||
|
||||
// create log folder
|
||||
if ( !logDirectory.exists() ) {
|
||||
logDirectory.mkdir();
|
||||
}
|
||||
|
||||
// clear the previous logcat and then write the new one to the file
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec("logcat -c");
|
||||
process = Runtime.getRuntime().exec("logcat -f " + logFile+" *:W");
|
||||
} catch ( IOException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Checks if external storage is available for read and write */
|
||||
public boolean isExternalStorageWritable() {
|
||||
String state = Environment.getExternalStorageState();
|
||||
if ( Environment.MEDIA_MOUNTED.equals( state ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Checks if external storage is available to at least read */
|
||||
public boolean isExternalStorageReadable() {
|
||||
String state = Environment.getExternalStorageState();
|
||||
if ( Environment.MEDIA_MOUNTED.equals( state ) ||
|
||||
Environment.MEDIA_MOUNTED_READ_ONLY.equals( state ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void discardWorld() {
|
||||
world = new WorldContext();
|
||||
controllers = new ControllerContext(this, world);
|
||||
setup = new WorldSetup(world, controllers, getApplicationContext());
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.Pair;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Environment;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
public final class AndorsTrailApplication extends Application {
|
||||
|
||||
public static final boolean DEVELOPMENT_DEBUGRESOURCES = false;
|
||||
public static final boolean DEVELOPMENT_FORCE_STARTNEWGAME = false;
|
||||
public static final boolean DEVELOPMENT_FORCE_CONTINUEGAME = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGBUTTONS = false;
|
||||
public static final boolean DEVELOPMENT_FASTSPEED = false;
|
||||
public static final boolean DEVELOPMENT_VALIDATEDATA = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGMESSAGES = false;
|
||||
public static final String CURRENT_VERSION_DISPLAY = "0.8.2";
|
||||
public static final boolean IS_RELEASE_VERSION = !CURRENT_VERSION_DISPLAY.matches(".*[a-d].*");
|
||||
public static final boolean DEVELOPMENT_INCOMPATIBLE_SAVEGAMES = DEVELOPMENT_DEBUGRESOURCES || DEVELOPMENT_DEBUGBUTTONS || DEVELOPMENT_FASTSPEED || !IS_RELEASE_VERSION;
|
||||
public static final int DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION = 999;
|
||||
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION : 66;
|
||||
|
||||
private final AndorsTrailPreferences preferences = new AndorsTrailPreferences();
|
||||
private WorldContext world = new WorldContext();
|
||||
private ControllerContext controllers = new ControllerContext(this, world);
|
||||
private WorldSetup setup = new WorldSetup(world, controllers, this);
|
||||
public WorldContext getWorld() { return world; }
|
||||
public WorldSetup getWorldSetup() { return setup; }
|
||||
public AndorsTrailPreferences getPreferences() { return preferences; }
|
||||
public ControllerContext getControllerContext() { return controllers; }
|
||||
|
||||
public static AndorsTrailApplication getApplicationFromActivity(Activity activity) {
|
||||
return ((AndorsTrailApplication) activity.getApplication());
|
||||
}
|
||||
public static AndorsTrailApplication getApplicationFromActivityContext(Context context) {
|
||||
return getApplicationFromActivity(getActivityFromActivityContext(context));
|
||||
}
|
||||
private static Activity getActivityFromActivityContext(Context context) {
|
||||
return (Activity) context;
|
||||
}
|
||||
|
||||
public boolean isInitialized() { return world.model != null; }
|
||||
|
||||
public void setWindowParameters(Activity activity) {
|
||||
activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
if (preferences.fullscreen) {
|
||||
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
activity.getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
//Get default locale at startup, as somehow it seems that changing the app's
|
||||
//configured locale impacts the value returned by Locale.getDefault() nowadays.
|
||||
private final Locale defaultLocale = Locale.getDefault();
|
||||
|
||||
private Pair<String, Locale> lastLocale = null;
|
||||
|
||||
public boolean setLocale(Activity context) {
|
||||
Resources res = context.getResources();
|
||||
Configuration conf = res.getConfiguration();
|
||||
|
||||
Locale targetLocale;
|
||||
|
||||
if (lastLocale != null && lastLocale.first == preferences.language) {
|
||||
targetLocale = lastLocale.second;
|
||||
} else {
|
||||
targetLocale = localeForLanguageTag(preferences.language);
|
||||
lastLocale = new Pair<String, Locale>(preferences.language, targetLocale);
|
||||
}
|
||||
|
||||
if (targetLocale.equals(conf.locale)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
conf.locale = targetLocale;
|
||||
res.updateConfiguration(conf, res.getDisplayMetrics());
|
||||
this.getResources().updateConfiguration(conf, res.getDisplayMetrics());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Supports language or language_COUNTRY in short form e.g. "en" or "en_US"
|
||||
private Locale localeForLanguageTag(String languageTag) {
|
||||
Locale locale = null;
|
||||
if (languageTag != null && !languageTag.equalsIgnoreCase("default")) {
|
||||
final int pos = languageTag.indexOf('-');
|
||||
if (pos == -1) {
|
||||
locale = new Locale(languageTag);
|
||||
}
|
||||
else locale = new Locale(languageTag.substring(0, pos), languageTag.substring(pos+1));
|
||||
}
|
||||
if (locale == null) {
|
||||
locale = defaultLocale;
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging to text file system as found on https://stackoverflow.com/questions/19565685/saving-logcat-to-a-text-file-in-android-device
|
||||
*/
|
||||
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
if ( DEVELOPMENT_DEBUGMESSAGES && isExternalStorageWritable() ) {
|
||||
File appDirectory = AndroidStorage.getStorageDirectory(getApplicationContext(), Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
File logDirectory = new File( appDirectory, "log" );
|
||||
File logFile = new File( logDirectory, "logcat" + System.currentTimeMillis() + ".txt" );
|
||||
|
||||
// create app folder
|
||||
if ( !appDirectory.exists() ) {
|
||||
appDirectory.mkdir();
|
||||
}
|
||||
|
||||
// create log folder
|
||||
if ( !logDirectory.exists() ) {
|
||||
logDirectory.mkdir();
|
||||
}
|
||||
|
||||
// clear the previous logcat and then write the new one to the file
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec("logcat -c");
|
||||
process = Runtime.getRuntime().exec("logcat -f " + logFile+" *:W");
|
||||
} catch ( IOException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Checks if external storage is available for read and write */
|
||||
public boolean isExternalStorageWritable() {
|
||||
String state = Environment.getExternalStorageState();
|
||||
if ( Environment.MEDIA_MOUNTED.equals( state ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Checks if external storage is available to at least read */
|
||||
public boolean isExternalStorageReadable() {
|
||||
String state = Environment.getExternalStorageState();
|
||||
if ( Environment.MEDIA_MOUNTED.equals( state ) ||
|
||||
Environment.MEDIA_MOUNTED_READ_ONLY.equals( state ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void discardWorld() {
|
||||
world = new WorldContext();
|
||||
controllers = new ControllerContext(this, world);
|
||||
setup = new WorldSetup(world, controllers, getApplicationContext());
|
||||
}
|
||||
}
|
||||
@@ -1,106 +1,115 @@
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public final class AndorsTrailPreferences {
|
||||
public static final int DISPLAYLOOT_DIALOG_ALWAYS = 0;
|
||||
public static final int DISPLAYLOOT_DIALOG_FOR_ITEMS = 3;
|
||||
public static final int DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST = 4;
|
||||
public static final int DISPLAYLOOT_TOAST = 1;
|
||||
public static final int DISPLAYLOOT_TOAST_FOR_ITEMS = 5;
|
||||
public static final int DISPLAYLOOT_NONE = 2;
|
||||
public static final int MOVEMENTMETHOD_STRAIGHT = 0;
|
||||
public static final int MOVEMENTMETHOD_DIRECTIONAL = 1;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_NORMAL = 0;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_AGGRESSIVE = 1;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_DEFENSIVE = 2;
|
||||
public static final int DPAD_POSITION_DISABLED = 0;
|
||||
public static final int DPAD_POSITION_LOWER_RIGHT = 1;
|
||||
public static final int DPAD_POSITION_LOWER_LEFT = 2;
|
||||
public static final int DPAD_POSITION_LOWER_CENTER = 3;
|
||||
public static final int DPAD_POSITION_CENTER_LEFT = 4;
|
||||
public static final int DPAD_POSITION_CENTER_RIGHT = 5;
|
||||
public static final int DPAD_POSITION_UPPER_LEFT = 6;
|
||||
public static final int DPAD_POSITION_UPPER_RIGHT = 7;
|
||||
public static final int DPAD_POSITION_UPPER_CENTER = 8;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_ALWAYS = 0;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_WHEN_PLAYERNAME_DIFFERS = 1;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_NEVER = 2;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM = 0;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_CENTER_LEFT = 1;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_CENTER_RIGHT = 2;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_BOTTOM_LEFT = 3;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_BOTTOM_LEFT = 4;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_BOTTOM_RIGHT = 5;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_BOTTOM_RIGHT = 6;
|
||||
public static final int ATTACKSPEED_DEFAULT_MILLISECONDS = 1000;
|
||||
|
||||
public boolean confirmRest = true;
|
||||
public boolean confirmAttack = true;
|
||||
public int displayLoot = DISPLAYLOOT_DIALOG_ALWAYS;
|
||||
public boolean fullscreen = true;
|
||||
public int attackspeed_milliseconds = 1000;
|
||||
public int movementMethod = MOVEMENTMETHOD_STRAIGHT;
|
||||
public int movementAggressiveness = MOVEMENTAGGRESSIVENESS_NORMAL;
|
||||
public float scalingFactor = 1.0f;
|
||||
public int dpadPosition;
|
||||
public boolean dpadMinimizeable = true;
|
||||
public boolean optimizedDrawing = false;
|
||||
public boolean highQualityFilters = true;
|
||||
public boolean enableUiAnimations = true;
|
||||
public int displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS;
|
||||
public int quickslotsPosition = QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM;
|
||||
public boolean showQuickslotsWhenToolboxIsVisible = false;
|
||||
public String language = "default";
|
||||
|
||||
public int selectedTheme = 0;
|
||||
|
||||
public void read(final Context androidContext) {
|
||||
AndorsTrailPreferences dest = this;
|
||||
try {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(androidContext);
|
||||
dest.confirmRest = prefs.getBoolean("confirm_rest", true);
|
||||
dest.confirmAttack = prefs.getBoolean("confirm_attack", true);
|
||||
dest.displayLoot = Integer.parseInt(prefs.getString("display_lootdialog", Integer.toString(DISPLAYLOOT_DIALOG_ALWAYS)));
|
||||
dest.fullscreen = prefs.getBoolean("fullscreen", true);
|
||||
dest.attackspeed_milliseconds = Integer.parseInt(prefs.getString("attackspeed", "1000"));
|
||||
dest.movementMethod = Integer.parseInt(prefs.getString("movementmethod", Integer.toString(MOVEMENTMETHOD_STRAIGHT)));
|
||||
dest.scalingFactor = Float.parseFloat(prefs.getString("scaling_factor", "1.0f"));
|
||||
dest.dpadPosition = Integer.parseInt(prefs.getString("dpadposition", Integer.toString(DPAD_POSITION_DISABLED)));
|
||||
dest.dpadMinimizeable = prefs.getBoolean("dpadMinimizeable", true);
|
||||
dest.optimizedDrawing = prefs.getBoolean("optimized_drawing", false);
|
||||
dest.highQualityFilters = prefs.getBoolean("high_quality_filters", true);
|
||||
dest.enableUiAnimations = prefs.getBoolean("enableUiAnimations", true);
|
||||
dest.displayOverwriteSavegame = Integer.parseInt(prefs.getString("display_overwrite_savegame", Integer.toString(CONFIRM_OVERWRITE_SAVEGAME_ALWAYS)));
|
||||
dest.quickslotsPosition = Integer.parseInt(prefs.getString("quickslots_placement", Integer.toString(QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM)));
|
||||
dest.showQuickslotsWhenToolboxIsVisible = prefs.getBoolean("showQuickslotsWhenToolboxIsVisible", false);
|
||||
dest.language = prefs.getString("language", "default");
|
||||
dest.selectedTheme = Integer.parseInt(prefs.getString("selectedTheme", Integer.toString(0)));
|
||||
// This might be implemented as a skill in the future.
|
||||
//dest.movementAggressiveness = Integer.parseInt(prefs.getString("movementaggressiveness", Integer.toString(MOVEMENTAGGRESSIVENESS_NORMAL)));
|
||||
} catch (Exception e) {
|
||||
dest.confirmRest = true;
|
||||
dest.confirmAttack = true;
|
||||
dest.displayLoot = DISPLAYLOOT_DIALOG_ALWAYS;
|
||||
dest.fullscreen = true;
|
||||
dest.attackspeed_milliseconds = 1000;
|
||||
dest.movementMethod = MOVEMENTMETHOD_STRAIGHT;
|
||||
dest.movementAggressiveness = MOVEMENTAGGRESSIVENESS_NORMAL;
|
||||
dest.scalingFactor = 1.0f;
|
||||
dest.dpadPosition = DPAD_POSITION_DISABLED;
|
||||
dest.dpadMinimizeable = true;
|
||||
dest.optimizedDrawing = false;
|
||||
dest.highQualityFilters = true;
|
||||
dest.enableUiAnimations = true;
|
||||
dest.displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS;
|
||||
dest.quickslotsPosition = QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM;
|
||||
dest.showQuickslotsWhenToolboxIsVisible = false;
|
||||
dest.language = "default";
|
||||
dest.selectedTheme = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public final class AndorsTrailPreferences {
|
||||
public static final int DISPLAYLOOT_DIALOG_ALWAYS = 0;
|
||||
public static final int DISPLAYLOOT_DIALOG_FOR_ITEMS = 3;
|
||||
public static final int DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST = 4;
|
||||
public static final int DISPLAYLOOT_TOAST = 1;
|
||||
public static final int DISPLAYLOOT_TOAST_FOR_ITEMS = 5;
|
||||
public static final int DISPLAYLOOT_NONE = 2;
|
||||
public static final int MOVEMENTMETHOD_STRAIGHT = 0;
|
||||
public static final int MOVEMENTMETHOD_DIRECTIONAL = 1;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_NORMAL = 0;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_AGGRESSIVE = 1;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_DEFENSIVE = 2;
|
||||
public static final int DPAD_POSITION_DISABLED = 0;
|
||||
public static final int DPAD_POSITION_LOWER_RIGHT = 1;
|
||||
public static final int DPAD_POSITION_LOWER_LEFT = 2;
|
||||
public static final int DPAD_POSITION_LOWER_CENTER = 3;
|
||||
public static final int DPAD_POSITION_CENTER_LEFT = 4;
|
||||
public static final int DPAD_POSITION_CENTER_RIGHT = 5;
|
||||
public static final int DPAD_POSITION_UPPER_LEFT = 6;
|
||||
public static final int DPAD_POSITION_UPPER_RIGHT = 7;
|
||||
public static final int DPAD_POSITION_UPPER_CENTER = 8;
|
||||
public static final int DPAD_TRANSPARENCY_30_PERCENT = 0;
|
||||
public static final int DPAD_TRANSPARENCY_40_PERCENT = 1;
|
||||
public static final int DPAD_TRANSPARENCY_50_PERCENT = 2;
|
||||
public static final int DPAD_TRANSPARENCY_60_PERCENT = 3;
|
||||
public static final int DPAD_TRANSPARENCY_70_PERCENT = 4;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_ALWAYS = 0;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_WHEN_PLAYERNAME_DIFFERS = 1;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_NEVER = 2;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM = 0;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_CENTER_LEFT = 1;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_CENTER_RIGHT = 2;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_BOTTOM_LEFT = 3;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_BOTTOM_LEFT = 4;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_BOTTOM_RIGHT = 5;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_BOTTOM_RIGHT = 6;
|
||||
public static final int ATTACKSPEED_DEFAULT_MILLISECONDS = 1000;
|
||||
|
||||
public boolean confirmRest = true;
|
||||
public boolean confirmAttack = true;
|
||||
public int displayLoot = DISPLAYLOOT_DIALOG_ALWAYS;
|
||||
public boolean fullscreen = true;
|
||||
public int attackspeed_milliseconds = 1000;
|
||||
public int movementMethod = MOVEMENTMETHOD_STRAIGHT;
|
||||
public int movementAggressiveness = MOVEMENTAGGRESSIVENESS_NORMAL;
|
||||
public float scalingFactor = 1.0f;
|
||||
public int dpadPosition;
|
||||
public int dpadTransparency;
|
||||
public boolean dpadMinimizeable = true;
|
||||
public boolean optimizedDrawing = false;
|
||||
public boolean highQualityFilters = true;
|
||||
public boolean enableUiAnimations = true;
|
||||
public int displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS;
|
||||
public int quickslotsPosition = QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM;
|
||||
public boolean showQuickslotsWhenToolboxIsVisible = false;
|
||||
public String language = "default";
|
||||
|
||||
public Uri exportImportFolderPath;
|
||||
|
||||
public int selectedTheme = 0;
|
||||
|
||||
public void read(final Context androidContext) {
|
||||
AndorsTrailPreferences dest = this;
|
||||
try {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(androidContext);
|
||||
dest.confirmRest = prefs.getBoolean("confirm_rest", true);
|
||||
dest.confirmAttack = prefs.getBoolean("confirm_attack", true);
|
||||
dest.displayLoot = Integer.parseInt(prefs.getString("display_lootdialog", Integer.toString(DISPLAYLOOT_DIALOG_ALWAYS)));
|
||||
dest.fullscreen = prefs.getBoolean("fullscreen", true);
|
||||
dest.attackspeed_milliseconds = Integer.parseInt(prefs.getString("attackspeed", "1000"));
|
||||
dest.movementMethod = Integer.parseInt(prefs.getString("movementmethod", Integer.toString(MOVEMENTMETHOD_STRAIGHT)));
|
||||
dest.scalingFactor = Float.parseFloat(prefs.getString("scaling_factor", "1.0f"));
|
||||
dest.dpadPosition = Integer.parseInt(prefs.getString("dpadposition", Integer.toString(DPAD_POSITION_DISABLED)));
|
||||
dest.dpadTransparency = Integer.parseInt(prefs.getString("dpadtransparency", Integer.toString(DPAD_TRANSPARENCY_50_PERCENT)));
|
||||
dest.dpadMinimizeable = prefs.getBoolean("dpadMinimizeable", true);
|
||||
dest.optimizedDrawing = prefs.getBoolean("optimized_drawing", false);
|
||||
dest.highQualityFilters = prefs.getBoolean("high_quality_filters", true);
|
||||
dest.enableUiAnimations = prefs.getBoolean("enableUiAnimations", true);
|
||||
dest.displayOverwriteSavegame = Integer.parseInt(prefs.getString("display_overwrite_savegame", Integer.toString(CONFIRM_OVERWRITE_SAVEGAME_ALWAYS)));
|
||||
dest.quickslotsPosition = Integer.parseInt(prefs.getString("quickslots_placement", Integer.toString(QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM)));
|
||||
dest.showQuickslotsWhenToolboxIsVisible = prefs.getBoolean("showQuickslotsWhenToolboxIsVisible", false);
|
||||
dest.language = prefs.getString("language", "default");
|
||||
dest.selectedTheme = Integer.parseInt(prefs.getString("selectedTheme", Integer.toString(0)));
|
||||
// This might be implemented as a skill in the future.
|
||||
//dest.movementAggressiveness = Integer.parseInt(prefs.getString("movementaggressiveness", Integer.toString(MOVEMENTAGGRESSIVENESS_NORMAL)));
|
||||
} catch (Exception e) {
|
||||
dest.confirmRest = true;
|
||||
dest.confirmAttack = true;
|
||||
dest.displayLoot = DISPLAYLOOT_DIALOG_ALWAYS;
|
||||
dest.fullscreen = true;
|
||||
dest.attackspeed_milliseconds = 1000;
|
||||
dest.movementMethod = MOVEMENTMETHOD_STRAIGHT;
|
||||
dest.movementAggressiveness = MOVEMENTAGGRESSIVENESS_NORMAL;
|
||||
dest.scalingFactor = 1.0f;
|
||||
dest.dpadPosition = DPAD_POSITION_DISABLED;
|
||||
dest.dpadTransparency = DPAD_TRANSPARENCY_50_PERCENT;
|
||||
dest.dpadMinimizeable = true;
|
||||
dest.optimizedDrawing = false;
|
||||
dest.highQualityFilters = true;
|
||||
dest.enableUiAnimations = true;
|
||||
dest.displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS;
|
||||
dest.quickslotsPosition = QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM;
|
||||
dest.showQuickslotsWhenToolboxIsVisible = false;
|
||||
dest.language = "default";
|
||||
dest.selectedTheme = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,475 +1,475 @@
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import android.*;
|
||||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.activity.ActorConditionInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.BulkSelectionInterface;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ConversationActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ItemInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LevelUpActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LoadSaveActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MainActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MonsterEncounterActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MonsterInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.SkillInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorConditionType;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
||||
|
||||
public final class Dialogs {
|
||||
|
||||
private static void showDialogAndPause(Dialog d, final ControllerContext context) {
|
||||
showDialogAndPause(d, context, null);
|
||||
}
|
||||
private static void showDialogAndPause(Dialog d, final ControllerContext context, final OnDismissListener onDismiss) {
|
||||
context.gameRoundController.pause();
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
if (onDismiss != null) onDismiss.onDismiss(arg0);
|
||||
context.gameRoundController.resume();
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
public static void showKeyArea(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null);
|
||||
}
|
||||
|
||||
public static void showMapSign(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null);
|
||||
}
|
||||
|
||||
public static void showMapScriptMessage(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null, false);
|
||||
}
|
||||
|
||||
public static void showConversation(final MainActivity currentActivity, final ControllerContext context, final String phraseID, final Monster npc) {
|
||||
showConversation(currentActivity, context, phraseID, npc, true);
|
||||
}
|
||||
|
||||
private static void showConversation(final MainActivity currentActivity, final ControllerContext context, final String phraseID, final Monster npc, boolean applyScriptEffectsForFirstPhrase) {
|
||||
context.gameRoundController.pause();
|
||||
Intent intent = new Intent(currentActivity, ConversationActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/conversation/" + phraseID));
|
||||
intent.putExtra("applyScriptEffectsForFirstPhrase", applyScriptEffectsForFirstPhrase);
|
||||
addMonsterIdentifiers(intent, npc);
|
||||
currentActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_CONVERSATION);
|
||||
}
|
||||
|
||||
public static void addMonsterIdentifiers(Intent intent, Monster monster) {
|
||||
if (monster == null) return;
|
||||
intent.putExtra("x", monster.position.x);
|
||||
intent.putExtra("y", monster.position.y);
|
||||
}
|
||||
public static void addMonsterIdentifiers(Bundle bundle, Monster monster) {
|
||||
if (monster == null) return;
|
||||
bundle.putInt("x", monster.position.x);
|
||||
bundle.putInt("y", monster.position.y);
|
||||
}
|
||||
|
||||
public static Monster getMonsterFromIntent(Intent intent, final WorldContext world) {
|
||||
return getMonsterFromBundle(intent.getExtras(), world);
|
||||
}
|
||||
public static Monster getMonsterFromBundle(Bundle params, final WorldContext world) {
|
||||
if (params == null) return null;
|
||||
if (!params.containsKey("x")) return null;
|
||||
int x = params.getInt("x");
|
||||
int y = params.getInt("y");
|
||||
return world.model.currentMaps.map.getMonsterAt(x, y);
|
||||
}
|
||||
|
||||
public static void showMonsterEncounter(final MainActivity currentActivity, final ControllerContext context, final Monster monster) {
|
||||
context.gameRoundController.pause();
|
||||
Intent intent = new Intent(currentActivity, MonsterEncounterActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/monsterencounter"));
|
||||
addMonsterIdentifiers(intent, monster);
|
||||
currentActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_MONSTERENCOUNTER);
|
||||
}
|
||||
|
||||
public static void showMonsterInfo(final Context context, final Monster monster) {
|
||||
Intent intent = new Intent(context, MonsterInfoActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/monsterinfo"));
|
||||
addMonsterIdentifiers(intent, monster);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static String getGroundLootFoundMessage(final Context ctx, final Loot loot) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
if (!loot.items.isEmpty()) {
|
||||
sb.append(ctx.getString(R.string.dialog_groundloot_message));
|
||||
}
|
||||
appendGoldPickedUpMessage(ctx, loot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getGroundLootPickedUpMessage(final Context ctx, final Loot loot) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendLootPickedUpMessage(ctx, loot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getMonsterLootFoundMessage(final Context ctx, final Loot combinedLoot, final int exp) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendMonsterEncounterSurvivedMessage(ctx, sb, exp);
|
||||
appendGoldPickedUpMessage(ctx, combinedLoot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getMonsterLootPickedUpMessage(final Context ctx, final Loot combinedLoot, final int exp) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendMonsterEncounterSurvivedMessage(ctx, sb, exp);
|
||||
appendLootPickedUpMessage(ctx, combinedLoot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
private static void appendMonsterEncounterSurvivedMessage(final Context ctx, final StringBuilder sb, final int exp) {
|
||||
sb.append(ctx.getString(R.string.dialog_monsterloot_message));
|
||||
if (exp > 0) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_monsterloot_gainedexp, exp));
|
||||
}
|
||||
}
|
||||
private static void appendGoldPickedUpMessage(final Context ctx, final Loot loot, final StringBuilder sb) {
|
||||
if (loot.gold > 0) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_foundgold, loot.gold));
|
||||
}
|
||||
}
|
||||
private static void appendLootPickedUpMessage(final Context ctx, final Loot loot, final StringBuilder sb) {
|
||||
appendGoldPickedUpMessage(ctx, loot, sb);
|
||||
int numItems = loot.items.countItems();
|
||||
if (numItems == 1) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_pickedupitem));
|
||||
} else if (numItems > 1){
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_pickedupitems, numItems));
|
||||
}
|
||||
}
|
||||
|
||||
public static void showMonsterLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Collection<Loot> lootBags, final Loot combinedLoot, final String msg) {
|
||||
// CombatController will do killedMonsterBags.clear() after this method has been called,
|
||||
// so we need to keep the list of objects. Therefore, we create a shallow copy of the list of bags.
|
||||
ArrayList<Loot> bags = new ArrayList<Loot>(lootBags);
|
||||
showLoot(mainActivity, controllers, world, combinedLoot, bags, R.string.dialog_monsterloot_title, msg);
|
||||
}
|
||||
|
||||
public static void showGroundLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Loot loot, final String msg) {
|
||||
showLoot(mainActivity, controllers, world, loot, Collections.singletonList(loot), R.string.dialog_groundloot_title, msg);
|
||||
}
|
||||
|
||||
private static void showLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Loot combinedLoot, final Iterable<Loot> lootBags, final int title, final String msg) {
|
||||
final ListView itemList = new ListView(mainActivity);
|
||||
itemList.setBackgroundResource(android.R.color.transparent);
|
||||
itemList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
// itemList.setPadding(20, 0, 20, 20);
|
||||
itemList.setAdapter(new ItemContainerAdapter(mainActivity, world.tileManager, combinedLoot.items, world.model.player));
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(title),
|
||||
mainActivity.getResources().getDrawable(R.drawable.ui_icon_equipment),
|
||||
msg,
|
||||
combinedLoot.items.isEmpty() ? null : itemList,
|
||||
true);
|
||||
|
||||
itemList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
|
||||
final String itemTypeID = ((ItemContainerAdapter) parent.getAdapter()).getItem(position).itemType.id;
|
||||
boolean removeFromCombinedLoot = true;
|
||||
for (Loot l : lootBags) {
|
||||
if (l == combinedLoot) removeFromCombinedLoot = false;
|
||||
if (l.items.removeItem(itemTypeID)) {
|
||||
controllers.itemController.removeLootBagIfEmpty(l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (removeFromCombinedLoot) {
|
||||
combinedLoot.items.removeItem(itemTypeID);
|
||||
}
|
||||
if (((ItemContainerAdapter) parent.getAdapter()).isEmpty()) {
|
||||
ViewGroup vg = (ViewGroup) d.findViewById(R.id.dialog_content_container);
|
||||
vg.setVisibility(View.GONE);
|
||||
}
|
||||
ItemType type = world.itemTypes.getItemType(itemTypeID);
|
||||
world.model.player.inventory.addItem(type);
|
||||
((ItemContainerAdapter) itemList.getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
if (!itemList.getAdapter().isEmpty()) {
|
||||
CustomDialogFactory.addButton(d, R.string.dialog_loot_pickall, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllers.itemController.pickupAll(lootBags);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, R.string.dialog_close);
|
||||
|
||||
showDialogAndPause(d, controllers, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
controllers.itemController.removeLootBagIfEmpty(lootBags);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void showHeroDied(final MainActivity mainActivity, final ControllerContext controllers) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(R.string.dialog_game_over_title),
|
||||
mainActivity.getResources().getDrawable(R.drawable.ui_icon_combat),
|
||||
mainActivity.getResources().getString(R.string.dialog_game_over_text),
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
|
||||
showDialogAndPause(d, controllers, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
mainActivity.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static Intent getIntentForItemInfo(final Context ctx, String itemTypeID, ItemInfoActivity.ItemInfoAction actionType, String buttonText, boolean buttonEnabled, Inventory.WearSlot inventorySlot) {
|
||||
Intent intent = new Intent(ctx, ItemInfoActivity.class);
|
||||
intent.putExtra("buttonText", buttonText);
|
||||
intent.putExtra("buttonEnabled", buttonEnabled);
|
||||
intent.putExtra("moreActions", (actionType == ItemInfoActivity.ItemInfoAction.equip || actionType == ItemInfoActivity.ItemInfoAction.use || actionType == ItemInfoActivity.ItemInfoAction.none));
|
||||
intent.putExtra("itemTypeID", itemTypeID);
|
||||
intent.putExtra("actionType", actionType.name());
|
||||
if (inventorySlot != null) intent.putExtra("inventorySlot", inventorySlot.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/iteminfo/" + itemTypeID));
|
||||
return intent;
|
||||
}
|
||||
public static Intent getIntentForLevelUp(final Context ctx) {
|
||||
Intent intent = new Intent(ctx, LevelUpActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/levelup"));
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void showConfirmRest(final Activity currentActivity, final ControllerContext controllerContext, final MapObject area) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
||||
null,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_confirm_message),
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllerContext.mapController.rest(area);
|
||||
}
|
||||
});
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
public static void showRested(final Activity currentActivity, final ControllerContext controllerContext) {
|
||||
// Dialog d = new AlertDialog.Builder(new ContextThemeWrapper(currentActivity, R.style.AndorsTrailStyle))
|
||||
// .setTitle(R.string.dialog_rest_title)
|
||||
// .setMessage(R.string.dialog_rest_message)
|
||||
// .setNeutralButton(android.R.string.ok, null)
|
||||
// .create();
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
||||
null,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_message),
|
||||
null,
|
||||
true);
|
||||
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
|
||||
public static void showNewVersion(final Activity currentActivity, final OnDismissListener onDismiss) {
|
||||
// new AlertDialog.Builder(new ContextThemeWrapper(currentActivity, R.style.AndorsTrailStyle))
|
||||
// .setTitle(R.string.dialog_newversion_title)
|
||||
// .setMessage(R.string.dialog_newversion_message)
|
||||
// .setNeutralButton(android.R.string.ok, null)
|
||||
// .show();
|
||||
|
||||
String text = currentActivity.getResources().getString(R.string.dialog_newversion_message);
|
||||
|
||||
if (!hasPermissions(currentActivity)) {
|
||||
text += currentActivity.getResources().getString(R.string.dialog_newversion_permission_information);
|
||||
}
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_newversion_title),
|
||||
null,
|
||||
text,
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
if (onDismiss != null) onDismiss.onDismiss(arg0);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
private static boolean hasPermissions(final Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (activity.getApplicationContext().checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|
||||
|| activity.getApplicationContext().checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean showSave(final Activity mainActivity, final ControllerContext controllerContext, final WorldContext world) {
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
Toast.makeText(mainActivity, R.string.menu_save_saving_not_allowed_in_combat, Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world.model.statistics.hasUnlimitedSaves()) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(R.string.menu_save_switch_character_title),
|
||||
null,
|
||||
mainActivity.getResources().getString(R.string.menu_save_switch_character),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllerContext.gameRoundController.pause();
|
||||
Intent intent = new Intent(mainActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/save"));
|
||||
mainActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_SAVEGAME);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
||||
CustomDialogFactory.show(d);
|
||||
return false;
|
||||
} else {
|
||||
controllerContext.gameRoundController.pause();
|
||||
Intent intent = new Intent(mainActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/save"));
|
||||
mainActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_SAVEGAME);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void showLoad(final Activity currentActivity) {
|
||||
Intent intent = new Intent(currentActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/load"));
|
||||
currentActivity.startActivityForResult(intent, StartScreenActivity_MainMenu.INTENTREQUEST_LOADGAME);
|
||||
}
|
||||
|
||||
public static void showLoad(final Fragment currentFragment) {
|
||||
Intent intent = new Intent(currentFragment.getActivity(), LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/load"));
|
||||
currentFragment.startActivityForResult(intent, StartScreenActivity_MainMenu.INTENTREQUEST_LOADGAME);
|
||||
}
|
||||
|
||||
public static void showActorConditionInfo(final Context context, ActorConditionType conditionType) {
|
||||
Intent intent = new Intent(context, ActorConditionInfoActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/actorconditioninfo/" + conditionType.conditionTypeID));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkBuyingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.buy);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkSellingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.sell);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkDroppingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.drop);
|
||||
}
|
||||
|
||||
private static Intent getIntentForBulkSelectionInterface(final Context ctx, String itemTypeID, int totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType interfaceType) {
|
||||
Intent intent = new Intent(ctx, BulkSelectionInterface.class);
|
||||
intent.putExtra("itemTypeID", itemTypeID);
|
||||
intent.putExtra("totalAvailableAmount", totalAvailableAmount);
|
||||
intent.putExtra("interfaceType", interfaceType.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/bulkselection/" + itemTypeID));
|
||||
return intent;
|
||||
}
|
||||
public static Intent getIntentForSkillInfo(final Context ctx, SkillCollection.SkillID skillID) {
|
||||
Intent intent = new Intent(ctx, SkillInfoActivity.class);
|
||||
intent.putExtra("skillID", skillID.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/showskillinfo/" + skillID));
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void showCombatLog(final Context context, final ControllerContext controllerContext, final WorldContext world) {
|
||||
String[] combatLogMessages = world.model.combatLog.getAllMessages();
|
||||
|
||||
View view = null;
|
||||
ListView itemList = null;
|
||||
itemList = new ListView(context);
|
||||
itemList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
itemList.setStackFromBottom(true);
|
||||
itemList.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
|
||||
itemList.setChoiceMode(ListView.CHOICE_MODE_NONE);
|
||||
itemList.setBackgroundColor(ThemeHelper.getThemeColor(context, R.attr.ui_theme_stdframe_bg_color));
|
||||
if (combatLogMessages.length <= 0) {
|
||||
combatLogMessages = new String[] {context.getResources().getString(R.string.combat_log_noentries)};
|
||||
}
|
||||
itemList.setAdapter(new ArrayAdapter<String>(context, R.layout.combatlog_row, android.R.id.text1, combatLogMessages));
|
||||
view = itemList;
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(context,
|
||||
context.getResources().getString(R.string.combat_log_title),
|
||||
context.getResources().getDrawable(R.drawable.ui_icon_combat),
|
||||
null,
|
||||
view,
|
||||
true);
|
||||
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, R.string.dialog_close);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.activity.ActorConditionInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.BulkSelectionInterface;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ConversationActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ItemInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LevelUpActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LoadSaveActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MainActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MonsterEncounterActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MonsterInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.SkillInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorConditionType;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
||||
|
||||
public final class Dialogs {
|
||||
|
||||
private static void showDialogAndPause(Dialog d, final ControllerContext context) {
|
||||
showDialogAndPause(d, context, null);
|
||||
}
|
||||
private static void showDialogAndPause(Dialog d, final ControllerContext context, final OnDismissListener onDismiss) {
|
||||
context.gameRoundController.pause();
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
if (onDismiss != null) onDismiss.onDismiss(arg0);
|
||||
context.gameRoundController.resume();
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
public static void showKeyArea(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null);
|
||||
}
|
||||
|
||||
public static void showMapSign(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null);
|
||||
}
|
||||
|
||||
public static void showMapScriptMessage(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null, false);
|
||||
}
|
||||
|
||||
public static void showConversation(final MainActivity currentActivity, final ControllerContext context, final String phraseID, final Monster npc) {
|
||||
showConversation(currentActivity, context, phraseID, npc, true);
|
||||
}
|
||||
|
||||
private static void showConversation(final MainActivity currentActivity, final ControllerContext context, final String phraseID, final Monster npc, boolean applyScriptEffectsForFirstPhrase) {
|
||||
context.gameRoundController.pause();
|
||||
Intent intent = new Intent(currentActivity, ConversationActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/conversation/" + phraseID));
|
||||
intent.putExtra("applyScriptEffectsForFirstPhrase", applyScriptEffectsForFirstPhrase);
|
||||
addMonsterIdentifiers(intent, npc);
|
||||
currentActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_CONVERSATION);
|
||||
}
|
||||
|
||||
public static void addMonsterIdentifiers(Intent intent, Monster monster) {
|
||||
if (monster == null) return;
|
||||
intent.putExtra("x", monster.position.x);
|
||||
intent.putExtra("y", monster.position.y);
|
||||
}
|
||||
public static void addMonsterIdentifiers(Bundle bundle, Monster monster) {
|
||||
if (monster == null) return;
|
||||
bundle.putInt("x", monster.position.x);
|
||||
bundle.putInt("y", monster.position.y);
|
||||
}
|
||||
|
||||
public static Monster getMonsterFromIntent(Intent intent, final WorldContext world) {
|
||||
return getMonsterFromBundle(intent.getExtras(), world);
|
||||
}
|
||||
public static Monster getMonsterFromBundle(Bundle params, final WorldContext world) {
|
||||
if (params == null) return null;
|
||||
if (!params.containsKey("x")) return null;
|
||||
int x = params.getInt("x");
|
||||
int y = params.getInt("y");
|
||||
return world.model.currentMaps.map.getMonsterAt(x, y);
|
||||
}
|
||||
|
||||
public static void showMonsterEncounter(final MainActivity currentActivity, final ControllerContext context, final Monster monster) {
|
||||
context.gameRoundController.pause();
|
||||
Intent intent = new Intent(currentActivity, MonsterEncounterActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/monsterencounter"));
|
||||
addMonsterIdentifiers(intent, monster);
|
||||
currentActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_MONSTERENCOUNTER);
|
||||
}
|
||||
|
||||
public static void showMonsterInfo(final Context context, final Monster monster) {
|
||||
Intent intent = new Intent(context, MonsterInfoActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/monsterinfo"));
|
||||
addMonsterIdentifiers(intent, monster);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static String getGroundLootFoundMessage(final Context ctx, final Loot loot) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
if (!loot.items.isEmpty()) {
|
||||
sb.append(ctx.getString(R.string.dialog_groundloot_message));
|
||||
}
|
||||
appendGoldPickedUpMessage(ctx, loot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getGroundLootPickedUpMessage(final Context ctx, final Loot loot) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendLootPickedUpMessage(ctx, loot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getMonsterLootFoundMessage(final Context ctx, final Loot combinedLoot, final int exp) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendMonsterEncounterSurvivedMessage(ctx, sb, exp);
|
||||
appendGoldPickedUpMessage(ctx, combinedLoot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getMonsterLootPickedUpMessage(final Context ctx, final Loot combinedLoot, final int exp) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendMonsterEncounterSurvivedMessage(ctx, sb, exp);
|
||||
appendLootPickedUpMessage(ctx, combinedLoot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
private static void appendMonsterEncounterSurvivedMessage(final Context ctx, final StringBuilder sb, final int exp) {
|
||||
sb.append(ctx.getString(R.string.dialog_monsterloot_message));
|
||||
if (exp > 0) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_monsterloot_gainedexp, exp));
|
||||
}
|
||||
}
|
||||
private static void appendGoldPickedUpMessage(final Context ctx, final Loot loot, final StringBuilder sb) {
|
||||
if (loot.gold > 0) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_foundgold, loot.gold));
|
||||
}
|
||||
}
|
||||
private static void appendLootPickedUpMessage(final Context ctx, final Loot loot, final StringBuilder sb) {
|
||||
appendGoldPickedUpMessage(ctx, loot, sb);
|
||||
int numItems = loot.items.countItems();
|
||||
if (numItems == 1) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_pickedupitem));
|
||||
} else if (numItems > 1){
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_pickedupitems, numItems));
|
||||
}
|
||||
}
|
||||
|
||||
public static void showMonsterLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Collection<Loot> lootBags, final Loot combinedLoot, final String msg) {
|
||||
// CombatController will do killedMonsterBags.clear() after this method has been called,
|
||||
// so we need to keep the list of objects. Therefore, we create a shallow copy of the list of bags.
|
||||
ArrayList<Loot> bags = new ArrayList<Loot>(lootBags);
|
||||
showLoot(mainActivity, controllers, world, combinedLoot, bags, R.string.dialog_monsterloot_title, msg);
|
||||
}
|
||||
|
||||
public static void showGroundLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Loot loot, final String msg) {
|
||||
showLoot(mainActivity, controllers, world, loot, Collections.singletonList(loot), R.string.dialog_groundloot_title, msg);
|
||||
}
|
||||
|
||||
private static void showLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Loot combinedLoot, final Iterable<Loot> lootBags, final int title, final String msg) {
|
||||
final ListView itemList = new ListView(mainActivity);
|
||||
itemList.setBackgroundResource(android.R.color.transparent);
|
||||
itemList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
// itemList.setPadding(20, 0, 20, 20);
|
||||
itemList.setAdapter(new ItemContainerAdapter(mainActivity, world.tileManager, combinedLoot.items, world.model.player));
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(title),
|
||||
mainActivity.getResources().getDrawable(R.drawable.ui_icon_equipment),
|
||||
msg,
|
||||
combinedLoot.items.isEmpty() ? null : itemList,
|
||||
true,
|
||||
false);
|
||||
|
||||
itemList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
|
||||
final String itemTypeID = ((ItemContainerAdapter) parent.getAdapter()).getItem(position).itemType.id;
|
||||
boolean removeFromCombinedLoot = true;
|
||||
for (Loot l : lootBags) {
|
||||
if (l == combinedLoot) removeFromCombinedLoot = false;
|
||||
if (l.items.removeItem(itemTypeID)) {
|
||||
controllers.itemController.removeLootBagIfEmpty(l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (removeFromCombinedLoot) {
|
||||
combinedLoot.items.removeItem(itemTypeID);
|
||||
}
|
||||
if (((ItemContainerAdapter) parent.getAdapter()).isEmpty()) {
|
||||
ViewGroup vg = (ViewGroup) d.findViewById(R.id.dialog_content_container);
|
||||
vg.setVisibility(View.GONE);
|
||||
}
|
||||
ItemType type = world.itemTypes.getItemType(itemTypeID);
|
||||
world.model.player.inventory.addItem(type);
|
||||
((ItemContainerAdapter) itemList.getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
if (!itemList.getAdapter().isEmpty()) {
|
||||
CustomDialogFactory.addButton(d, R.string.dialog_loot_pickall, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllers.itemController.pickupAll(lootBags);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, R.string.dialog_close);
|
||||
|
||||
showDialogAndPause(d, controllers, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
controllers.itemController.removeLootBagIfEmpty(lootBags);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void showHeroDied(final MainActivity mainActivity, final ControllerContext controllers) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(R.string.dialog_game_over_title),
|
||||
mainActivity.getResources().getDrawable(R.drawable.ui_icon_combat),
|
||||
mainActivity.getResources().getString(R.string.dialog_game_over_text),
|
||||
null,
|
||||
true,
|
||||
false);
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
|
||||
showDialogAndPause(d, controllers, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
mainActivity.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static Intent getIntentForItemInfo(final Context ctx, String itemTypeID, ItemInfoActivity.ItemInfoAction actionType, String buttonText, boolean buttonEnabled, Inventory.WearSlot inventorySlot) {
|
||||
Intent intent = new Intent(ctx, ItemInfoActivity.class);
|
||||
intent.putExtra("buttonText", buttonText);
|
||||
intent.putExtra("buttonEnabled", buttonEnabled);
|
||||
intent.putExtra("moreActions", (actionType == ItemInfoActivity.ItemInfoAction.equip || actionType == ItemInfoActivity.ItemInfoAction.use || actionType == ItemInfoActivity.ItemInfoAction.none));
|
||||
intent.putExtra("itemTypeID", itemTypeID);
|
||||
intent.putExtra("actionType", actionType.name());
|
||||
if (inventorySlot != null) intent.putExtra("inventorySlot", inventorySlot.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/iteminfo/" + itemTypeID));
|
||||
return intent;
|
||||
}
|
||||
public static Intent getIntentForLevelUp(final Context ctx) {
|
||||
Intent intent = new Intent(ctx, LevelUpActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/levelup"));
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void showConfirmRest(final Activity currentActivity, final ControllerContext controllerContext, final MapObject area) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
||||
null,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_confirm_message),
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllerContext.mapController.rest(area);
|
||||
}
|
||||
});
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
public static void showRested(final Activity currentActivity, final ControllerContext controllerContext) {
|
||||
// Dialog d = new AlertDialog.Builder(new ContextThemeWrapper(currentActivity, R.style.AndorsTrailStyle))
|
||||
// .setTitle(R.string.dialog_rest_title)
|
||||
// .setMessage(R.string.dialog_rest_message)
|
||||
// .setNeutralButton(android.R.string.ok, null)
|
||||
// .create();
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
||||
null,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_message),
|
||||
null,
|
||||
true);
|
||||
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
|
||||
public static void showNewVersion(final Activity currentActivity, final OnDismissListener onDismiss) {
|
||||
// new AlertDialog.Builder(new ContextThemeWrapper(currentActivity, R.style.AndorsTrailStyle))
|
||||
// .setTitle(R.string.dialog_newversion_title)
|
||||
// .setMessage(R.string.dialog_newversion_message)
|
||||
// .setNeutralButton(android.R.string.ok, null)
|
||||
// .show();
|
||||
|
||||
String text = currentActivity.getResources().getString(R.string.dialog_newversion_message);
|
||||
|
||||
if (!hasPermissions(currentActivity) && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
text += currentActivity.getResources().getString(R.string.dialog_newversion_permission_information);
|
||||
}
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_newversion_title),
|
||||
null,
|
||||
text,
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
if (onDismiss != null) onDismiss.onDismiss(arg0);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
private static boolean hasPermissions(final Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (activity.getApplicationContext().checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|
||||
|| activity.getApplicationContext().checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean showSave(final Activity mainActivity, final ControllerContext controllerContext, final WorldContext world) {
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
Toast.makeText(mainActivity, R.string.menu_save_saving_not_allowed_in_combat, Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world.model.statistics.hasUnlimitedSaves()) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(R.string.menu_save_switch_character_title),
|
||||
null,
|
||||
mainActivity.getResources().getString(R.string.menu_save_switch_character),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllerContext.gameRoundController.pause();
|
||||
Intent intent = new Intent(mainActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/save"));
|
||||
mainActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_SAVEGAME);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
||||
CustomDialogFactory.show(d);
|
||||
return false;
|
||||
} else {
|
||||
controllerContext.gameRoundController.pause();
|
||||
Intent intent = new Intent(mainActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/save"));
|
||||
mainActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_SAVEGAME);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void showLoad(final Activity currentActivity) {
|
||||
Intent intent = new Intent(currentActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/load"));
|
||||
currentActivity.startActivityForResult(intent, StartScreenActivity_MainMenu.INTENTREQUEST_LOADGAME);
|
||||
}
|
||||
|
||||
public static void showLoad(final Fragment currentFragment) {
|
||||
Intent intent = new Intent(currentFragment.getActivity(), LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/load"));
|
||||
currentFragment.startActivityForResult(intent, StartScreenActivity_MainMenu.INTENTREQUEST_LOADGAME);
|
||||
}
|
||||
|
||||
public static void showActorConditionInfo(final Context context, ActorConditionType conditionType) {
|
||||
Intent intent = new Intent(context, ActorConditionInfoActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/actorconditioninfo/" + conditionType.conditionTypeID));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkBuyingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.buy);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkSellingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.sell);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkDroppingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.drop);
|
||||
}
|
||||
|
||||
private static Intent getIntentForBulkSelectionInterface(final Context ctx, String itemTypeID, int totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType interfaceType) {
|
||||
Intent intent = new Intent(ctx, BulkSelectionInterface.class);
|
||||
intent.putExtra("itemTypeID", itemTypeID);
|
||||
intent.putExtra("totalAvailableAmount", totalAvailableAmount);
|
||||
intent.putExtra("interfaceType", interfaceType.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/bulkselection/" + itemTypeID));
|
||||
return intent;
|
||||
}
|
||||
public static Intent getIntentForSkillInfo(final Context ctx, SkillCollection.SkillID skillID) {
|
||||
Intent intent = new Intent(ctx, SkillInfoActivity.class);
|
||||
intent.putExtra("skillID", skillID.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/showskillinfo/" + skillID));
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void showCombatLog(final Context context, final ControllerContext controllerContext, final WorldContext world) {
|
||||
String[] combatLogMessages = world.model.combatLog.getAllMessages();
|
||||
|
||||
View view = null;
|
||||
ListView itemList = null;
|
||||
itemList = new ListView(context);
|
||||
itemList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
itemList.setStackFromBottom(true);
|
||||
itemList.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
|
||||
itemList.setChoiceMode(ListView.CHOICE_MODE_NONE);
|
||||
itemList.setBackgroundColor(ThemeHelper.getThemeColor(context, R.attr.ui_theme_stdframe_bg_color));
|
||||
if (combatLogMessages.length <= 0) {
|
||||
combatLogMessages = new String[] {context.getResources().getString(R.string.combat_log_noentries)};
|
||||
}
|
||||
itemList.setAdapter(new ArrayAdapter<String>(context, R.layout.combatlog_row, android.R.id.text1, combatLogMessages));
|
||||
view = itemList;
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(context,
|
||||
context.getResources().getString(R.string.combat_log_title),
|
||||
context.getResources().getDrawable(R.drawable.ui_icon_combat),
|
||||
null,
|
||||
view,
|
||||
true);
|
||||
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, R.string.dialog_close);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@@ -1,12 +1,9 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
public abstract class AndorsTrailBaseFragmentActivity extends FragmentActivity {
|
||||
@Override
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
@@ -2,7 +2,6 @@ package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
@@ -0,0 +1,341 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.view.MainView;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
public final class DebugInterface {
|
||||
private final ControllerContext controllerContext;
|
||||
private final MainActivity mainActivity;
|
||||
private final Resources res;
|
||||
private final WorldContext world;
|
||||
|
||||
private DebugButton[] buttons;
|
||||
private List<DebugButton> tpButtons = new ArrayList<DebugButton>();
|
||||
private List<DebugButton> tpButtons2 = new ArrayList<DebugButton>();
|
||||
|
||||
public DebugInterface(ControllerContext controllers, WorldContext world, MainActivity mainActivity) {
|
||||
this.controllerContext = controllers;
|
||||
this.world = world;
|
||||
this.res = mainActivity.getResources();
|
||||
this.mainActivity = mainActivity;
|
||||
}
|
||||
|
||||
public void addDebugButtons() {
|
||||
if (!AndorsTrailApplication.DEVELOPMENT_DEBUGBUTTONS) return;
|
||||
|
||||
List<DebugButton> buttonList = new ArrayList<DebugButton>();
|
||||
buttonList.addAll(Arrays.asList(new DebugButton[] {
|
||||
new DebugButton("dbg", new OnClickListener() {
|
||||
boolean hidden = false;
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
hidden = !hidden;
|
||||
for (int i = 1; i < buttons.length; i++) {
|
||||
buttons[i].b.setVisibility(hidden ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
for (DebugButton b : tpButtons) {
|
||||
b.b.setVisibility(View.GONE);
|
||||
}
|
||||
for (DebugButton b : tpButtons2) {
|
||||
b.b.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
})
|
||||
,new DebugButton("teleport", new OnClickListener() {
|
||||
public void onClick(View arg0) {
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
buttons[i].b.setVisibility(View.GONE);
|
||||
}
|
||||
for (DebugButton tpButton : tpButtons) {
|
||||
tpButton.b.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
})
|
||||
,new DebugButton("dmg", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
world.model.player.damagePotential.set(500, 500);
|
||||
world.model.player.attackChance = 500;
|
||||
world.model.player.attackCost = 1;
|
||||
showToast(mainActivity, "DEBUG: damagePotential=500, chance=500%, cost=1", Toast.LENGTH_SHORT);
|
||||
}
|
||||
})
|
||||
/*,new DebugButton("dmg=1", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
world.model.player.damagePotential.set(1, 1);
|
||||
showToast(mainActivity, "DEBUG: damagePotential=1", Toast.LENGTH_SHORT);
|
||||
}
|
||||
})*/
|
||||
,new DebugButton("itm", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
for (ItemType item : world.itemTypes.UNITTEST_getAllItemTypes().values()) {
|
||||
world.model.player.inventory.addItem(item, 10);
|
||||
}
|
||||
world.model.player.inventory.gold += 50000;
|
||||
showToast(mainActivity, "DEBUG: added items", Toast.LENGTH_SHORT);
|
||||
}
|
||||
})
|
||||
,new DebugButton("xp", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.actorStatsController.addExperience(10000);
|
||||
showToast(mainActivity, "DEBUG: given 10000 exp", Toast.LENGTH_SHORT);
|
||||
}
|
||||
})
|
||||
,new DebugButton("rst", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
for(PredefinedMap map : world.maps.getAllMaps()) {
|
||||
map.resetTemporaryData();
|
||||
}
|
||||
showToast(mainActivity, "DEBUG: maps respawned", Toast.LENGTH_SHORT);
|
||||
}
|
||||
})
|
||||
,new DebugButton("hp", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
world.model.player.baseTraits.maxHP = 500;
|
||||
world.model.player.health.max = world.model.player.baseTraits.maxHP;
|
||||
controllerContext.actorStatsController.setActorMaxHealth(world.model.player);
|
||||
world.model.player.conditions.clear();
|
||||
showToast(mainActivity, "DEBUG: hp set to max", Toast.LENGTH_SHORT);
|
||||
}
|
||||
})
|
||||
,new DebugButton("skl", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
world.model.player.availableSkillIncreases += 10;
|
||||
showToast(mainActivity, "DEBUG: 10 skill points", Toast.LENGTH_SHORT);
|
||||
}
|
||||
})
|
||||
,new DebugButton("spd", new OnClickListener() {
|
||||
boolean fast = Constants.MINIMUM_INPUT_INTERVAL == Constants.MINIMUM_INPUT_INTERVAL_FAST;
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
fast = !fast;
|
||||
if (fast) {
|
||||
Constants.MINIMUM_INPUT_INTERVAL = Constants.MINIMUM_INPUT_INTERVAL_FAST;
|
||||
} else {
|
||||
Constants.MINIMUM_INPUT_INTERVAL = Constants.MINIMUM_INPUT_INTERVAL_STD;
|
||||
}
|
||||
MainView.SCROLL_DURATION = Constants.MINIMUM_INPUT_INTERVAL;
|
||||
AndorsTrailApplication.getApplicationFromActivity(mainActivity).getControllerContext().movementController.resetMovementHandler();
|
||||
}
|
||||
})
|
||||
,new DebugButton("map", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
showToast(mainActivity, "DEBUG: map=" + world.model.currentMaps.map.name , Toast.LENGTH_SHORT);
|
||||
}
|
||||
})
|
||||
}));
|
||||
|
||||
tpButtons.addAll(Arrays.asList(new DebugButton[] {
|
||||
new DebugButton("teleport", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
for (DebugButton tpButton : tpButtons2) {
|
||||
tpButton.b.setVisibility(View.VISIBLE);
|
||||
}
|
||||
for (DebugButton tpButton : tpButtons) {
|
||||
tpButton.b.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
})
|
||||
,new DebugButton("cg", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "crossglen", "hall", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("vg", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "vilegard_s", "tavern", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("cr", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "houseatcrossroads4", "down", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("lf", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "loneford9", "south", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("fh", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "fallhaven_ne", "clothes", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("prm", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "blackwater_mountain29", "south", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("bwm", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "blackwater_mountain43", "south", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("rmg", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "remgard0", "east", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("chr", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "waytolostmine2", "minerhouse4", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("ldr", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "lodarhouse0", "lodarhouse", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("sf", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "wild20", "south2", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("gm", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "guynmart_wood_1", "farmhouse", 0, 0);
|
||||
}
|
||||
})
|
||||
}));
|
||||
buttonList.addAll(tpButtons);
|
||||
|
||||
tpButtons2.addAll(Arrays.asList(new DebugButton[] {
|
||||
new DebugButton("teleport", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
buttons[i].b.setVisibility(View.VISIBLE);
|
||||
}
|
||||
for (DebugButton tpButton : tpButtons) {
|
||||
tpButton.b.setVisibility(View.GONE);
|
||||
}
|
||||
for (DebugButton tpButton : tpButtons2) {
|
||||
tpButton.b.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
})
|
||||
,new DebugButton("brv", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "brimhaven4", "south2", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("aru", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "mountainlake5", "north", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("ws", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "woodsettlement0", "east", 0, 0);
|
||||
}
|
||||
})
|
||||
,new DebugButton("sul", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "sullengard2", "south", 0, 0);
|
||||
}
|
||||
})
|
||||
}));
|
||||
buttonList.addAll(tpButtons2);
|
||||
|
||||
buttons = buttonList.toArray(new DebugButton[buttonList.size()]);
|
||||
addDebugButtons(buttons);
|
||||
|
||||
for (DebugButton b : tpButtons) {
|
||||
b.b.setVisibility(View.GONE);
|
||||
}
|
||||
for (DebugButton b : tpButtons2) {
|
||||
b.b.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void showToast(Context context, String msg, int duration) {
|
||||
Toast.makeText(context, msg, duration).show();
|
||||
}
|
||||
|
||||
private static class DebugButton {
|
||||
public final String text;
|
||||
public final OnClickListener listener;
|
||||
public Button b = null;
|
||||
public DebugButton(String text, OnClickListener listener) {
|
||||
this.text = text;
|
||||
this.listener = listener;
|
||||
}
|
||||
public void makeButton(Context c, int id) {
|
||||
b = new Button(c);
|
||||
b.setText(text);
|
||||
b.setTextSize(10);//res.getDimension(R.dimen.actionbar_text));
|
||||
b.setId(id);
|
||||
b.setOnClickListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
private void addDebugButton(DebugButton button, int id, RelativeLayout layout) {
|
||||
if (!AndorsTrailApplication.DEVELOPMENT_DEBUGBUTTONS) return;
|
||||
|
||||
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, res.getDimensionPixelSize(R.dimen.smalltext_buttonheight));
|
||||
if (id == 1)
|
||||
lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
|
||||
else
|
||||
lp.addRule(RelativeLayout.RIGHT_OF, id - 1);
|
||||
lp.addRule(RelativeLayout.ABOVE, R.id.main_statusview);
|
||||
button.makeButton(mainActivity, id);
|
||||
button.b.setLayoutParams(lp);
|
||||
layout.addView(button.b);
|
||||
}
|
||||
|
||||
private void addDebugButtons(DebugButton[] buttons) {
|
||||
if (!AndorsTrailApplication.DEVELOPMENT_DEBUGBUTTONS) return;
|
||||
|
||||
if (buttons == null || buttons.length <= 0) return;
|
||||
RelativeLayout layout = (RelativeLayout) mainActivity.findViewById(R.id.main_container);
|
||||
|
||||
int id = 1;
|
||||
for (DebugButton b : buttons) {
|
||||
addDebugButton(b, id, layout);
|
||||
++id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,168 +1,168 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.WorldMapController;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.WorldMapSegmentMap;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
public final class DisplayWorldMapActivity extends AndorsTrailBaseActivity {
|
||||
private WorldContext world;
|
||||
|
||||
private WebView displayworldmap_webview;
|
||||
private String worldMapSegmentName;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
this.world = app.getWorld();
|
||||
|
||||
app.setWindowParameters(this);
|
||||
|
||||
setContentView(R.layout.displayworldmap);
|
||||
|
||||
displayworldmap_webview = (WebView) findViewById(R.id.displayworldmap_webview);
|
||||
displayworldmap_webview.setBackgroundColor(ThemeHelper.getThemeColor(this, R.attr.ui_theme_displayworldmap_bg_color));
|
||||
displayworldmap_webview.getSettings().setBuiltInZoomControls(true);
|
||||
displayworldmap_webview.getSettings().setUseWideViewPort(true);
|
||||
displayworldmap_webview.setVerticalScrollBarEnabled(true);
|
||||
displayworldmap_webview.setHorizontalScrollBarEnabled(true);
|
||||
enableJavascript();
|
||||
|
||||
Button b = (Button) findViewById(R.id.displayworldmap_close);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DisplayWorldMapActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
b = (Button) findViewById(R.id.displayworldmap_recenter);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
recenter();
|
||||
}
|
||||
});
|
||||
|
||||
worldMapSegmentName = getIntent().getStringExtra("worldMapSegmentName");
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public void enableJavascript() {
|
||||
displayworldmap_webview.getSettings().setJavaScriptEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
update();
|
||||
}
|
||||
|
||||
WorldMapSegmentMap map;
|
||||
Coord offsetWorldmapTo;
|
||||
@SuppressLint("NewApi")
|
||||
private void update() {
|
||||
File worldmap = WorldMapController.getCombinedWorldMapFile(worldMapSegmentName);
|
||||
|
||||
if (!worldmap.exists()) {
|
||||
Toast.makeText(this, getResources().getString(R.string.menu_button_worldmap_failed), Toast.LENGTH_LONG).show();
|
||||
this.finish();
|
||||
}
|
||||
|
||||
WorldMapSegment segment = world.maps.worldMapSegments.get(worldMapSegmentName);
|
||||
map = segment.maps.get(world.model.currentMaps.map.name);
|
||||
if (map == null) {
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
offsetWorldmapTo = new Coord(999999, 999999);
|
||||
for (WorldMapSegmentMap map : segment.maps.values()) {
|
||||
PredefinedMap predefinedMap = world.maps.findPredefinedMap(map.mapName);
|
||||
if (predefinedMap == null) continue;
|
||||
if (!predefinedMap.visited) continue;
|
||||
if (!WorldMapController.fileForMapExists(predefinedMap)) continue;
|
||||
|
||||
offsetWorldmapTo.x = Math.min(offsetWorldmapTo.x, map.worldPosition.x);
|
||||
offsetWorldmapTo.y = Math.min(offsetWorldmapTo.y, map.worldPosition.y);
|
||||
}
|
||||
|
||||
|
||||
String url = "file://" + worldmap.getAbsolutePath() + '?'
|
||||
+ (world.model.player.position.x + map.worldPosition.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
+ ','
|
||||
+ (world.model.player.position.y + map.worldPosition.y-1) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
L.log("Showing " + url);
|
||||
displayworldmap_webview.loadUrl(url);
|
||||
displayworldmap_webview.setBackgroundColor(ThemeHelper.getThemeColor(this, R.attr.ui_theme_displayworldmap_bg_color));
|
||||
displayworldmap_webview.setWebViewClient(new WebViewClient() {
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url)
|
||||
{
|
||||
recenter();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void recenter() {
|
||||
displayworldmap_webview.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (map != null) {
|
||||
//Local map to global worldmap
|
||||
int x = world.model.player.position.x + map.worldPosition.x - offsetWorldmapTo.x;
|
||||
//Tile coord to pixel coord
|
||||
x *= WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
x += WorldMapController.WORLDMAP_DISPLAY_TILESIZE/2;
|
||||
//Zoom level
|
||||
x = (int)(x * displayworldmap_webview.getScale());
|
||||
//Center
|
||||
x -= displayworldmap_webview.getWidth() / 2;
|
||||
|
||||
//Local map to global worldmap
|
||||
int y = world.model.player.position.y + map.worldPosition.y - offsetWorldmapTo.y;
|
||||
//Tile coord to pixel coord
|
||||
y *= WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
y += WorldMapController.WORLDMAP_DISPLAY_TILESIZE/2;
|
||||
//Zoom level
|
||||
y = (int)(y * displayworldmap_webview.getScale());
|
||||
//Center
|
||||
y -= displayworldmap_webview.getHeight() / 2;
|
||||
|
||||
displayworldmap_webview.scrollTo(x, y);
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
ViewGroup view = (ViewGroup) getWindow().getDecorView();
|
||||
view.removeAllViews();
|
||||
super.finish();
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.WorldMapController;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.WorldMapSegmentMap;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
public final class DisplayWorldMapActivity extends AndorsTrailBaseActivity {
|
||||
private WorldContext world;
|
||||
|
||||
private WebView displayworldmap_webview;
|
||||
private String worldMapSegmentName;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
this.world = app.getWorld();
|
||||
|
||||
app.setWindowParameters(this);
|
||||
|
||||
setContentView(R.layout.displayworldmap);
|
||||
|
||||
displayworldmap_webview = (WebView) findViewById(R.id.displayworldmap_webview);
|
||||
displayworldmap_webview.setBackgroundColor(ThemeHelper.getThemeColor(this, R.attr.ui_theme_displayworldmap_bg_color));
|
||||
displayworldmap_webview.getSettings().setBuiltInZoomControls(true);
|
||||
displayworldmap_webview.getSettings().setUseWideViewPort(true);
|
||||
displayworldmap_webview.setVerticalScrollBarEnabled(true);
|
||||
displayworldmap_webview.setHorizontalScrollBarEnabled(true);
|
||||
displayworldmap_webview.getSettings().setAllowFileAccess(true);
|
||||
enableJavascript();
|
||||
|
||||
Button b = (Button) findViewById(R.id.displayworldmap_close);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DisplayWorldMapActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
b = (Button) findViewById(R.id.displayworldmap_recenter);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
recenter();
|
||||
}
|
||||
});
|
||||
|
||||
worldMapSegmentName = getIntent().getStringExtra("worldMapSegmentName");
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public void enableJavascript() {
|
||||
displayworldmap_webview.getSettings().setJavaScriptEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
update();
|
||||
}
|
||||
|
||||
WorldMapSegmentMap map;
|
||||
Coord offsetWorldmapTo;
|
||||
@SuppressLint("NewApi")
|
||||
private void update() {
|
||||
File worldmap = WorldMapController.getCombinedWorldMapFile(this, worldMapSegmentName);
|
||||
|
||||
if (!worldmap.exists()) {
|
||||
Toast.makeText(this, getResources().getString(R.string.menu_button_worldmap_failed), Toast.LENGTH_LONG).show();
|
||||
this.finish();
|
||||
}
|
||||
|
||||
WorldMapSegment segment = world.maps.worldMapSegments.get(worldMapSegmentName);
|
||||
map = segment.maps.get(world.model.currentMaps.map.name);
|
||||
if (map == null) {
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
offsetWorldmapTo = new Coord(999999, 999999);
|
||||
for (WorldMapSegmentMap map : segment.maps.values()) {
|
||||
PredefinedMap predefinedMap = world.maps.findPredefinedMap(map.mapName);
|
||||
if (predefinedMap == null) continue;
|
||||
if (!predefinedMap.visited) continue;
|
||||
if (!WorldMapController.fileForMapExists(this, predefinedMap)) continue;
|
||||
|
||||
offsetWorldmapTo.x = Math.min(offsetWorldmapTo.x, map.worldPosition.x);
|
||||
offsetWorldmapTo.y = Math.min(offsetWorldmapTo.y, map.worldPosition.y);
|
||||
}
|
||||
|
||||
String url = AndroidStorage.getUrlForFile(this, worldmap) + '?'
|
||||
+ (world.model.player.position.x + map.worldPosition.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
+ ','
|
||||
+ (world.model.player.position.y + map.worldPosition.y-1) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
L.log("Showing " + url);
|
||||
displayworldmap_webview.loadUrl(url);
|
||||
displayworldmap_webview.setBackgroundColor(ThemeHelper.getThemeColor(this, R.attr.ui_theme_displayworldmap_bg_color));
|
||||
displayworldmap_webview.setWebViewClient(new WebViewClient() {
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url)
|
||||
{
|
||||
recenter();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void recenter() {
|
||||
displayworldmap_webview.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (map != null) {
|
||||
//Local map to global worldmap
|
||||
int x = world.model.player.position.x + map.worldPosition.x - offsetWorldmapTo.x;
|
||||
//Tile coord to pixel coord
|
||||
x *= WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
x += WorldMapController.WORLDMAP_DISPLAY_TILESIZE/2;
|
||||
//Zoom level
|
||||
x = (int)(x * displayworldmap_webview.getScale());
|
||||
//Center
|
||||
x -= displayworldmap_webview.getWidth() / 2;
|
||||
|
||||
//Local map to global worldmap
|
||||
int y = world.model.player.position.y + map.worldPosition.y - offsetWorldmapTo.y;
|
||||
//Tile coord to pixel coord
|
||||
y *= WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
y += WorldMapController.WORLDMAP_DISPLAY_TILESIZE/2;
|
||||
//Zoom level
|
||||
y = (int)(y * displayworldmap_webview.getScale());
|
||||
//Center
|
||||
y -= displayworldmap_webview.getHeight() / 2;
|
||||
|
||||
displayworldmap_webview.scrollTo(x, y);
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
ViewGroup view = (ViewGroup) getWindow().getDecorView();
|
||||
view.removeAllViews();
|
||||
super.finish();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentTabHost;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
@@ -1,139 +1,139 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemEffectsView;
|
||||
|
||||
public final class ItemInfoActivity extends AndorsTrailBaseActivity {
|
||||
|
||||
public static enum ItemInfoAction {
|
||||
none, use, equip, unequip, buy, sell
|
||||
}
|
||||
|
||||
public static final int RESULT_MORE_ACTIONS = Activity.RESULT_FIRST_USER;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getDialogTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
final WorldContext world = app.getWorld();
|
||||
|
||||
app.setWindowParameters(this);
|
||||
|
||||
final Intent intent = getIntent();
|
||||
Bundle params = intent.getExtras();
|
||||
String itemTypeID = params.getString("itemTypeID");
|
||||
final ItemType itemType = world.itemTypes.getItemType(itemTypeID);
|
||||
|
||||
final String buttonText = params.getString("buttonText");
|
||||
boolean buttonEnabled = params.getBoolean("buttonEnabled");
|
||||
boolean moreButtonEnabled = params.getBoolean("moreActions");
|
||||
|
||||
setContentView(R.layout.iteminfo);
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.iteminfo_title);
|
||||
tv.setText(itemType.getName(world.model.player));
|
||||
world.tileManager.setImageViewTileForSingleItemType(getResources(), tv, itemType);
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_description);
|
||||
String description = itemType.getDescription();
|
||||
if (description != null) {
|
||||
tv.setText(description);
|
||||
tv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_category);
|
||||
tv.setText(itemType.category.displayName);
|
||||
|
||||
((ItemEffectsView) findViewById(R.id.iteminfo_effects)).update(
|
||||
itemType.effects_equip,
|
||||
itemType.effects_use == null ? null : Collections.singletonList(itemType.effects_use),
|
||||
itemType.effects_hit == null ? null : Collections.singletonList(itemType.effects_hit),
|
||||
itemType.effects_kill == null ? null : Collections.singletonList(itemType.effects_kill),
|
||||
itemType.effects_hitReceived == null ? null : Collections.singletonList(itemType.effects_hitReceived),
|
||||
null,
|
||||
itemType.isWeapon()
|
||||
);
|
||||
|
||||
Button b = (Button) findViewById(R.id.iteminfo_close);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
setResult(RESULT_CANCELED);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
b = (Button) findViewById(R.id.iteminfo_more);
|
||||
if (!moreButtonEnabled) {
|
||||
b.setVisibility(View.GONE);
|
||||
} else {
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent result = new Intent();
|
||||
result.putExtras(intent);
|
||||
setResult(RESULT_MORE_ACTIONS, intent);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
b = (Button) findViewById(R.id.iteminfo_action);
|
||||
if (buttonText != null && buttonText.length() > 0) {
|
||||
b.setVisibility(View.VISIBLE);
|
||||
b.setEnabled(buttonEnabled);
|
||||
b.setText(buttonText);
|
||||
} else {
|
||||
b.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent result = new Intent();
|
||||
result.putExtras(intent);
|
||||
setResult(RESULT_OK, result);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_displaytype);
|
||||
if (itemType.isOrdinaryItem()) {
|
||||
tv.setVisibility(View.GONE);
|
||||
} else {
|
||||
tv.setVisibility(View.VISIBLE);
|
||||
final String diplayType = getDisplayTypeString(getResources(), itemType);
|
||||
tv.setText(diplayType);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDisplayTypeString(Resources res, ItemType itemType) {
|
||||
switch (itemType.displayType) {
|
||||
case rare: return res.getString(R.string.iteminfo_displaytypes_rare);
|
||||
case extraordinary: return res.getString(R.string.iteminfo_displaytypes_extraordinary);
|
||||
case legendary: return res.getString(R.string.iteminfo_displaytypes_legendary);
|
||||
case ordinary: return res.getString(R.string.iteminfo_displaytypes_ordinary);
|
||||
case quest: return res.getString(R.string.iteminfo_displaytypes_quest);
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemEffectsView;
|
||||
|
||||
public final class ItemInfoActivity extends AndorsTrailBaseActivity {
|
||||
|
||||
public static enum ItemInfoAction {
|
||||
none, use, equip, unequip, buy, sell
|
||||
}
|
||||
|
||||
public static final int RESULT_MORE_ACTIONS = Activity.RESULT_FIRST_USER;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getDialogTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
final WorldContext world = app.getWorld();
|
||||
|
||||
app.setWindowParameters(this);
|
||||
|
||||
final Intent intent = getIntent();
|
||||
Bundle params = intent.getExtras();
|
||||
String itemTypeID = params.getString("itemTypeID");
|
||||
final ItemType itemType = world.itemTypes.getItemType(itemTypeID);
|
||||
|
||||
final String buttonText = params.getString("buttonText");
|
||||
boolean buttonEnabled = params.getBoolean("buttonEnabled");
|
||||
boolean moreButtonEnabled = params.getBoolean("moreActions");
|
||||
|
||||
setContentView(R.layout.iteminfo);
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.iteminfo_title);
|
||||
tv.setText(itemType.getName(world.model.player));
|
||||
world.tileManager.setImageViewTileForSingleItemType(getResources(), tv, itemType);
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_description);
|
||||
String description = itemType.getDescription();
|
||||
if (description != null) {
|
||||
tv.setText(description);
|
||||
tv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_category);
|
||||
tv.setText(itemType.category.displayName);
|
||||
|
||||
((ItemEffectsView) findViewById(R.id.iteminfo_effects)).update(
|
||||
itemType.effects_equip,
|
||||
itemType.effects_use == null ? null : Collections.singletonList(itemType.effects_use),
|
||||
itemType.effects_hit == null ? null : Collections.singletonList(itemType.effects_hit),
|
||||
itemType.effects_kill == null ? null : Collections.singletonList(itemType.effects_kill),
|
||||
itemType.effects_hitReceived == null ? null : Collections.singletonList(itemType.effects_hitReceived),
|
||||
null,
|
||||
itemType.isWeapon()
|
||||
);
|
||||
|
||||
Button b = (Button) findViewById(R.id.iteminfo_close);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
setResult(RESULT_CANCELED);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
b = (Button) findViewById(R.id.iteminfo_more);
|
||||
if (!moreButtonEnabled) {
|
||||
b.setVisibility(View.GONE);
|
||||
} else {
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent result = new Intent();
|
||||
result.putExtras(intent);
|
||||
setResult(RESULT_MORE_ACTIONS, intent);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
b = (Button) findViewById(R.id.iteminfo_action);
|
||||
if (buttonText != null && buttonText.length() > 0) {
|
||||
b.setVisibility(View.VISIBLE);
|
||||
b.setEnabled(buttonEnabled);
|
||||
b.setText(buttonText);
|
||||
} else {
|
||||
b.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent result = new Intent();
|
||||
result.putExtras(intent);
|
||||
setResult(RESULT_OK, result);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_displaytype);
|
||||
if (itemType.isOrdinaryItem()) {
|
||||
tv.setVisibility(View.GONE);
|
||||
} else {
|
||||
tv.setVisibility(View.VISIBLE);
|
||||
final String diplayType = getDisplayTypeString(getResources(), itemType);
|
||||
tv.setText(diplayType);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDisplayTypeString(Resources res, ItemType itemType) {
|
||||
switch (itemType.displayType) {
|
||||
case rare: return res.getString(R.string.iteminfo_displaytypes_rare);
|
||||
case extraordinary: return res.getString(R.string.iteminfo_displaytypes_extraordinary);
|
||||
case legendary: return res.getString(R.string.iteminfo_displaytypes_legendary);
|
||||
case ordinary: return res.getString(R.string.iteminfo_displaytypes_ordinary);
|
||||
case quest: return res.getString(R.string.iteminfo_displaytypes_quest);
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@@ -0,0 +1,684 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v4.provider.DocumentFile;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames.FileHeader;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
public final class LoadSaveActivity extends AndorsTrailBaseActivity implements OnClickListener {
|
||||
private boolean isLoading = true;
|
||||
//region special slot numbers
|
||||
private static final int SLOT_NUMBER_CREATE_NEW_SLOT = -1;
|
||||
public static final int SLOT_NUMBER_EXPORT_SAVEGAMES = -2;
|
||||
public static final int SLOT_NUMBER_IMPORT_SAVEGAMES = -3;
|
||||
public static final int SLOT_NUMBER_IMPORT_WORLDMAP = -4;
|
||||
private static final int SLOT_NUMBER_FIRST_SLOT = 1;
|
||||
//endregion
|
||||
private ModelContainer model;
|
||||
private TileManager tileManager;
|
||||
private AndorsTrailPreferences preferences;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getDialogTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
app.setWindowParameters(this);
|
||||
this.model = app.getWorld().model;
|
||||
this.preferences = app.getPreferences();
|
||||
this.tileManager = app.getWorld().tileManager;
|
||||
|
||||
String loadsave = getIntent().getData().getLastPathSegment();
|
||||
isLoading = (loadsave.equalsIgnoreCase("load"));
|
||||
|
||||
setContentView(R.layout.loadsave);
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.loadsave_title);
|
||||
if (isLoading) {
|
||||
tv.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_menu_search, 0, 0, 0);
|
||||
tv.setText(R.string.loadsave_title_load);
|
||||
} else {
|
||||
tv.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_menu_save, 0, 0, 0);
|
||||
tv.setText(R.string.loadsave_title_save);
|
||||
}
|
||||
|
||||
ViewGroup slotList = (ViewGroup) findViewById(R.id.loadsave_slot_list);
|
||||
Button slotTemplateButton = (Button) findViewById(R.id.loadsave_slot_n);
|
||||
LayoutParams params = slotTemplateButton.getLayoutParams();
|
||||
slotList.removeView(slotTemplateButton);
|
||||
|
||||
ViewGroup newSlotContainer = (ViewGroup) findViewById(R.id.loadsave_save_to_new_slot_container);
|
||||
Button createNewSlot = (Button) findViewById(R.id.loadsave_save_to_new_slot);
|
||||
|
||||
Button exportSaves = (Button) findViewById(R.id.loadsave_export_save);
|
||||
Button importSaves = (Button) findViewById(R.id.loadsave_import_save);
|
||||
Button importWorldmap = (Button) findViewById(R.id.loadsave_import_worldmap);
|
||||
|
||||
exportSaves.setTag(SLOT_NUMBER_EXPORT_SAVEGAMES);
|
||||
importSaves.setTag(SLOT_NUMBER_IMPORT_SAVEGAMES);
|
||||
importWorldmap.setTag(SLOT_NUMBER_IMPORT_WORLDMAP);
|
||||
|
||||
ViewGroup exportContainer = (ViewGroup) findViewById(R.id.loadsave_export_save_container);
|
||||
ViewGroup importContainer = (ViewGroup) findViewById(R.id.loadsave_import_save_container);
|
||||
ViewGroup importWorldmapContainer = (ViewGroup) findViewById(R.id.loadsave_import_worldmap_container);
|
||||
|
||||
|
||||
addSavegameSlotButtons(slotList, params, Savegames.getUsedSavegameSlots(this));
|
||||
|
||||
checkAndRequestPermissions();
|
||||
|
||||
if (!isLoading) {
|
||||
createNewSlot.setTag(SLOT_NUMBER_CREATE_NEW_SLOT);
|
||||
createNewSlot.setOnClickListener(this);
|
||||
newSlotContainer.setVisibility(View.VISIBLE);
|
||||
exportContainer.setVisibility(View.GONE);
|
||||
importContainer.setVisibility(View.GONE);
|
||||
importWorldmapContainer.setVisibility(View.GONE);
|
||||
} else {
|
||||
newSlotContainer.setVisibility(View.GONE);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
exportSaves.setOnClickListener(this);
|
||||
importSaves.setOnClickListener(this);
|
||||
importWorldmap.setOnClickListener(this);
|
||||
exportContainer.setVisibility(View.VISIBLE);
|
||||
importContainer.setVisibility(View.VISIBLE);
|
||||
importWorldmapContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final int READ_EXTERNAL_STORAGE_REQUEST = 1;
|
||||
private static final int WRITE_EXTERNAL_STORAGE_REQUEST = 2;
|
||||
|
||||
@TargetApi(23)
|
||||
private void checkAndRequestPermissions() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||
if (getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
this.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, READ_EXTERNAL_STORAGE_REQUEST);
|
||||
}
|
||||
if (getApplicationContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
this.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_REQUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
if (grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
|
||||
Toast.makeText(this, R.string.storage_permissions_mandatory, Toast.LENGTH_LONG).show();
|
||||
((AndorsTrailApplication) getApplication()).discardWorld();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void addSavegameSlotButtons(ViewGroup parent, LayoutParams params, List<Integer> usedSavegameSlots) {
|
||||
int unused = 1;
|
||||
for (int slot : usedSavegameSlots) {
|
||||
final FileHeader header = Savegames.quickload(this, slot);
|
||||
if (header == null) continue;
|
||||
|
||||
while (unused < slot) {
|
||||
Button b = new Button(this);
|
||||
b.setLayoutParams(params);
|
||||
b.setTag(unused);
|
||||
b.setOnClickListener(this);
|
||||
b.setText(getString(R.string.loadsave_empty_slot, unused));
|
||||
tileManager.setImageViewTileForPlayer(getResources(), b, header.iconID);
|
||||
parent.addView(b, params);
|
||||
unused++;
|
||||
}
|
||||
unused++;
|
||||
|
||||
Button b = new Button(this);
|
||||
b.setLayoutParams(params);
|
||||
b.setTag(slot);
|
||||
b.setOnClickListener(this);
|
||||
b.setText(slot + ". " + header.describe());
|
||||
tileManager.setImageViewTileForPlayer(getResources(), b, header.iconID);
|
||||
parent.addView(b, params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void completeLoadSaveActivity(int slot) {
|
||||
Intent i = new Intent();
|
||||
if (slot == SLOT_NUMBER_CREATE_NEW_SLOT) {
|
||||
List<Integer> usedSlots = Savegames.getUsedSavegameSlots(this);
|
||||
if (usedSlots.isEmpty())
|
||||
slot = SLOT_NUMBER_FIRST_SLOT;
|
||||
else slot = Collections.max(usedSlots) + 1;
|
||||
} else if (slot == SLOT_NUMBER_EXPORT_SAVEGAMES
|
||||
|| slot == SLOT_NUMBER_IMPORT_SAVEGAMES
|
||||
|| slot == SLOT_NUMBER_IMPORT_WORLDMAP) {
|
||||
i.putExtra("import_export", true);
|
||||
} else if (slot < SLOT_NUMBER_FIRST_SLOT)
|
||||
slot = SLOT_NUMBER_FIRST_SLOT;
|
||||
|
||||
i.putExtra("slot", slot);
|
||||
setResult(Activity.RESULT_OK, i);
|
||||
LoadSaveActivity.this.finish();
|
||||
}
|
||||
|
||||
private String getConfirmOverwriteQuestion(int slot) {
|
||||
if (isLoading)
|
||||
return null;
|
||||
|
||||
return getConfirmOverwriteQuestionIgnoringLoading(slot);
|
||||
}
|
||||
|
||||
private String getConfirmOverwriteQuestionIgnoringLoading(int slot) {
|
||||
if (slot == SLOT_NUMBER_CREATE_NEW_SLOT)
|
||||
return null;//creating a new savegame
|
||||
|
||||
if (!Savegames.getSlotFile(slot, this).exists())
|
||||
return null;//nothing in slot to overwrite
|
||||
|
||||
if (preferences.displayOverwriteSavegame == AndorsTrailPreferences.CONFIRM_OVERWRITE_SAVEGAME_ALWAYS) {
|
||||
return getString(R.string.loadsave_save_overwrite_confirmation_all);
|
||||
}
|
||||
if (preferences.displayOverwriteSavegame == AndorsTrailPreferences.CONFIRM_OVERWRITE_SAVEGAME_NEVER) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String currentPlayerName = model.player.getName();
|
||||
final FileHeader header = Savegames.quickload(this, slot);
|
||||
if (header == null) return null;
|
||||
|
||||
final String savedPlayerName = header.playerName;
|
||||
if (currentPlayerName.equals(savedPlayerName)) return null; //if the names match
|
||||
|
||||
return getString(R.string.loadsave_save_overwrite_confirmation, savedPlayerName, currentPlayerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
final int slot = (Integer) view.getTag();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
switch (slot) {
|
||||
case SLOT_NUMBER_IMPORT_WORLDMAP:
|
||||
clickImportWorldmap();
|
||||
return;
|
||||
case SLOT_NUMBER_IMPORT_SAVEGAMES:
|
||||
clickImportSaveGames();
|
||||
return;
|
||||
case SLOT_NUMBER_EXPORT_SAVEGAMES:
|
||||
clickExportSaveGames();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!isLoading
|
||||
&& slot != SLOT_NUMBER_CREATE_NEW_SLOT
|
||||
&& AndorsTrailApplication.CURRENT_VERSION == AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION) {
|
||||
if (!isOverwriteTargetInIncompatibleVersion(slot)) {
|
||||
saveOrOverwriteSavegame(slot);
|
||||
}
|
||||
} else if (isLoading) {
|
||||
loadSaveGame(slot);
|
||||
} else {
|
||||
saveOrOverwriteSavegame(slot);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveOrOverwriteSavegame(int slot) {
|
||||
final String message = getConfirmOverwriteQuestion(slot);
|
||||
if (message != null) {
|
||||
showConfirmoverwriteQuestion(slot, message);
|
||||
} else {
|
||||
completeLoadSaveActivity(slot);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOverwriteTargetInIncompatibleVersion(int slot) {
|
||||
final FileHeader header = Savegames.quickload(this, slot);
|
||||
if (header != null && header.fileversion != AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION) {
|
||||
final Dialog d = CustomDialogFactory.createErrorDialog(this, "Overwriting not allowed", "You are currently using a development version of Andor's trail. Overwriting a regular savegame is not allowed in development mode.");
|
||||
CustomDialogFactory.show(d);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//region Imports/Exports
|
||||
|
||||
private void exportSaveGames(Intent data) {
|
||||
Uri uri = data.getData();
|
||||
|
||||
Context context = getApplicationContext();
|
||||
ContentResolver resolver = AndorsTrailApplication.getApplicationFromActivity(this).getContentResolver();
|
||||
|
||||
File storageDir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
DocumentFile source = DocumentFile.fromFile(storageDir);
|
||||
DocumentFile target = DocumentFile.fromTreeUri(context, uri);
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DocumentFile[] files = source.listFiles();
|
||||
|
||||
boolean hasExistingFiles = false;
|
||||
for (DocumentFile file :
|
||||
files) {
|
||||
String fileName = file.getName();
|
||||
if (fileName == null)
|
||||
continue;
|
||||
|
||||
DocumentFile existingFile = target.findFile(fileName);
|
||||
if (existingFile != null) {
|
||||
hasExistingFiles = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasExistingFiles) {
|
||||
showConfirmOverwriteByExportQuestion(resolver, target, files);
|
||||
} else {
|
||||
exportSaveGamesFolderContentToFolder(resolver, target, files);
|
||||
}
|
||||
}
|
||||
|
||||
private void exportSaveGamesFolderContentToFolder(ContentResolver resolver, DocumentFile target, DocumentFile[] files) {
|
||||
for (DocumentFile file : files) {
|
||||
String fileName = file.getName();
|
||||
DocumentFile existingFile = target.findFile(fileName);
|
||||
boolean hasExistingFile = existingFile != null && existingFile.exists();
|
||||
|
||||
if (file.isFile()) {
|
||||
try {
|
||||
if (hasExistingFile)
|
||||
existingFile.delete();
|
||||
|
||||
|
||||
AndroidStorage.copyDocumentFileToNewOrExistingFile(file, resolver, target);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (file.isDirectory()) {
|
||||
DocumentFile targetWorlmap = existingFile;
|
||||
//if the folder exists already, put the files in the existing folder. (should not happen because of check earlier)
|
||||
if (!hasExistingFile)
|
||||
//create a new folder for the worldmap-files
|
||||
targetWorlmap = target.createDirectory(Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
|
||||
if (targetWorlmap == null)//Unable to create worldmap folder for some reason
|
||||
continue;
|
||||
|
||||
DocumentFile[] worldmapFiles = file.listFiles();
|
||||
for (DocumentFile f : worldmapFiles) {
|
||||
try {
|
||||
AndroidStorage.copyDocumentFileToNewOrExistingFile(f, resolver, targetWorlmap);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
completeLoadSaveActivity(SLOT_NUMBER_EXPORT_SAVEGAMES);
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
|
||||
private void importSaveGames(Intent data) {
|
||||
Uri uri = data.getData();
|
||||
ClipData uris = data.getClipData();
|
||||
|
||||
if (uri == null && uris == null) {
|
||||
//no file was selected
|
||||
return;
|
||||
}
|
||||
|
||||
Context context = getApplicationContext();
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
|
||||
File storageDir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
DocumentFile appSavegameFolder = DocumentFile.fromFile(storageDir);
|
||||
|
||||
List<Uri> uriList = new ArrayList<>();
|
||||
if (uri != null) {
|
||||
uriList.add(uri);
|
||||
} else {
|
||||
for (int i = 0; i < uris.getItemCount(); i++)
|
||||
uriList.add(uris.getItemAt(i).getUri());
|
||||
}
|
||||
importSaveGamesFromUris(context, resolver, appSavegameFolder, uriList);
|
||||
}
|
||||
|
||||
private void importSaveGamesFromUris(Context context, ContentResolver resolver, DocumentFile appSavegameFolder, List<Uri> uriList) {
|
||||
int count = uriList.size();
|
||||
|
||||
ArrayList<DocumentFile> alreadyExistingFiles = new ArrayList<>();
|
||||
ArrayList<DocumentFile> newFiles = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
Uri item = uriList.get(i);
|
||||
DocumentFile itemFile = DocumentFile.fromSingleUri(context, item);
|
||||
boolean fileAlreadyExists = getExistsSavegameInOwnFiles(itemFile, appSavegameFolder);
|
||||
if (fileAlreadyExists)
|
||||
alreadyExistingFiles.add(itemFile);
|
||||
else
|
||||
newFiles.add(itemFile);
|
||||
}
|
||||
|
||||
if (alreadyExistingFiles.size() > 0) {
|
||||
showConfirmOverwriteByImportQuestion(resolver, appSavegameFolder, alreadyExistingFiles, newFiles);
|
||||
} else {
|
||||
importSaveGames(resolver, appSavegameFolder, newFiles);
|
||||
}
|
||||
}
|
||||
|
||||
private void importSaveGames(ContentResolver resolver, DocumentFile appSavegameFolder, List<DocumentFile> saveFiles) {
|
||||
for (DocumentFile file : saveFiles) {
|
||||
int slot = getSlotFromSavegameFileName(file.getName());
|
||||
importSaveGameFile(resolver, appSavegameFolder, file, slot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void completeSavegameImportAndCheckIfDone(List<Integer> importsNeedingConfirmation, int slot) {
|
||||
importsNeedingConfirmation.remove((Object) slot);
|
||||
if (importsNeedingConfirmation.isEmpty()) {
|
||||
completeLoadSaveActivity(SLOT_NUMBER_IMPORT_SAVEGAMES);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getExistsSavegameInOwnFiles(DocumentFile savegameFile, DocumentFile appSavegameFolder) {
|
||||
if (savegameFile == null)
|
||||
return false;
|
||||
|
||||
DocumentFile foundFile = appSavegameFolder.findFile(Objects.requireNonNull(savegameFile.getName()));
|
||||
return foundFile != null && foundFile.exists();
|
||||
}
|
||||
|
||||
private int getSlotFromSavegameFileName(String fileName) {
|
||||
if (fileName == null || !fileName.startsWith(Constants.FILENAME_SAVEGAME_FILENAME_PREFIX)) {
|
||||
//TODO: Maybe output a message that the file didn't have the right name?
|
||||
return -1;
|
||||
}
|
||||
String slotStr = fileName.substring(Constants.FILENAME_SAVEGAME_FILENAME_PREFIX.length());
|
||||
|
||||
int slot;
|
||||
try {
|
||||
slot = Integer.parseInt(slotStr);
|
||||
return slot;
|
||||
} catch (NumberFormatException e) {
|
||||
//TODO: Maybe output a message that the file didn't have the right name?
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private void importSaveGameFile(ContentResolver resolver, DocumentFile appSavegameFolder, DocumentFile itemFile, int slot) {
|
||||
String targetName = Savegames.getSlotFileName(slot);
|
||||
DocumentFile targetFile = getOrCreateDocumentFile(appSavegameFolder, targetName);
|
||||
|
||||
if (targetFile == null || !targetName.equals(targetFile.getName())) {
|
||||
showErrorImportingSaveGameUnknown();//TODO: maybe replace with a more specific error message
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
AndroidStorage.copyDocumentFile(itemFile, resolver, targetFile);
|
||||
} catch (IOException e) {
|
||||
showErrorImportingSaveGameUnknown();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private DocumentFile getOrCreateDocumentFile(DocumentFile folder, String targetName) {
|
||||
DocumentFile targetFile = folder.findFile(targetName);//try finding the file
|
||||
if (targetFile == null)//no file found, creating new one
|
||||
targetFile = folder.createFile(Constants.NO_FILE_EXTENSION_MIME_TYPE, targetName);
|
||||
return targetFile;
|
||||
}
|
||||
|
||||
private void importWorldmap(Intent data) {
|
||||
Uri uri = data.getData();
|
||||
|
||||
Context context = getApplicationContext();
|
||||
ContentResolver resolver = AndorsTrailApplication.getApplicationFromActivity(this).getContentResolver();
|
||||
|
||||
File storageDir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
DocumentFile storageFolder = DocumentFile.fromFile(storageDir);
|
||||
DocumentFile ownWorldmapFolder = storageFolder.findFile(Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
if (ownWorldmapFolder == null) {
|
||||
ownWorldmapFolder = storageFolder.createDirectory(Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
}
|
||||
|
||||
DocumentFile chosenFolder = DocumentFile.fromTreeUri(context, uri);
|
||||
if (chosenFolder == null || !chosenFolder.isDirectory()) {
|
||||
showErrorImportingWorldmapWrongDirectory();
|
||||
return;
|
||||
}
|
||||
if (!Constants.FILENAME_WORLDMAP_DIRECTORY.equals(chosenFolder.getName())) {
|
||||
//user did not select the worldmap folder directly
|
||||
DocumentFile file = chosenFolder.findFile(Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
if (file == null || !file.isDirectory() || !Constants.FILENAME_WORLDMAP_DIRECTORY.equals(file.getName())) {
|
||||
//could not find a worldmap folder in the users selection
|
||||
showErrorImportingWorldmapWrongDirectory();
|
||||
return;
|
||||
}
|
||||
|
||||
chosenFolder = file;
|
||||
}
|
||||
|
||||
DocumentFile[] files = chosenFolder.listFiles();
|
||||
for (DocumentFile file : files) {
|
||||
if (file.isFile()) {
|
||||
try {
|
||||
AndroidStorage.copyDocumentFileToNewOrExistingFile(file, resolver, ownWorldmapFolder);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
completeLoadSaveActivity(SLOT_NUMBER_IMPORT_WORLDMAP);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void clickExportSaveGames() {
|
||||
startActivityForResult(AndroidStorage.getNewOpenDirectoryIntent(), -SLOT_NUMBER_EXPORT_SAVEGAMES);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void clickImportSaveGames() {
|
||||
startActivityForResult(AndroidStorage.getNewSelectMultipleSavegameFilesIntent(), -SLOT_NUMBER_IMPORT_SAVEGAMES);
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void clickImportWorldmap() {
|
||||
startActivityForResult(AndroidStorage.getNewOpenDirectoryIntent(), -SLOT_NUMBER_IMPORT_WORLDMAP);
|
||||
|
||||
}
|
||||
|
||||
private void showConfirmOverwriteByExportQuestion(ContentResolver resolver, DocumentFile targetFolder, DocumentFile[] files) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(this,
|
||||
getString(R.string.loadsave_export_overwrite_confirmation_title),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.loadsave_export_overwrite_confirmation),
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, v -> exportSaveGamesFolderContentToFolder(resolver, targetFolder, files));
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
private void showConfirmOverwriteByImportQuestion(ContentResolver resolver,
|
||||
DocumentFile appSavegameFolder,
|
||||
List<DocumentFile> alreadyExistingFiles,
|
||||
List<DocumentFile> newFiles) {
|
||||
final String title = getString(R.string.loadsave_import_overwrite_confirmation_title);
|
||||
String message = getString(R.string.loadsave_import_overwrite_confirmation);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('\n');
|
||||
int amount = alreadyExistingFiles.size();
|
||||
|
||||
Context context = AndorsTrailApplication.getApplicationFromActivity(this).getApplicationContext();
|
||||
|
||||
for (int i = 0; i < amount && i < 3; i++) {
|
||||
DocumentFile alreadyExistingFile = alreadyExistingFiles.get(i);
|
||||
String alreadyExistingFileName = alreadyExistingFile.getName();
|
||||
FileHeader fileHeader = Savegames.quickload(context, getSlotFromSavegameFileName(alreadyExistingFileName));
|
||||
sb.append('\n');
|
||||
String fileHeaderDesription = "";
|
||||
if (fileHeader != null)
|
||||
fileHeaderDesription = fileHeader.describe();
|
||||
|
||||
sb.append(getString(R.string.loadsave_import_overwrite_confirmation_file_pattern, alreadyExistingFileName, fileHeaderDesription));
|
||||
// sb.append(alreadyExistingFile.getName());
|
||||
}
|
||||
if (amount > 3) {
|
||||
sb.append("\n...");
|
||||
}
|
||||
message = message + sb;
|
||||
final Dialog d = CustomDialogFactory.createDialog(this,
|
||||
title,
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
message,
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, v -> newFiles.addAll(alreadyExistingFiles));
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
CustomDialogFactory.setDismissListener(d, dialog -> {
|
||||
importSaveGames(resolver, appSavegameFolder, newFiles);
|
||||
completeLoadSaveActivity(SLOT_NUMBER_IMPORT_SAVEGAMES);
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (resultCode != Activity.RESULT_OK)
|
||||
return;
|
||||
|
||||
// Uri uri = data.getData();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
switch (-requestCode) {
|
||||
case SLOT_NUMBER_EXPORT_SAVEGAMES:
|
||||
exportSaveGames(data);
|
||||
return;
|
||||
case SLOT_NUMBER_IMPORT_SAVEGAMES:
|
||||
importSaveGames(data);
|
||||
return;
|
||||
case SLOT_NUMBER_IMPORT_WORLDMAP:
|
||||
importWorldmap(data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
private void loadSaveGame(int slot) {
|
||||
if (!Savegames.getSlotFile(slot, this).exists()) {
|
||||
showErrorLoadingEmptySlot();
|
||||
} else {
|
||||
final FileHeader header = Savegames.quickload(this, slot);
|
||||
if (header != null && !header.hasUnlimitedSaves) {
|
||||
showSlotGetsDeletedOnLoadWarning(slot);
|
||||
} else {
|
||||
completeLoadSaveActivity(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//region show Dialogs
|
||||
|
||||
private void showErrorImportingWorldmapWrongDirectory() {
|
||||
final Dialog d = CustomDialogFactory.createErrorDialog(this,
|
||||
getString(R.string.loadsave_import_worldmap_unsuccessfull),
|
||||
getString(R.string.loadsave_import_worldmap_unsuccessfull_wrong_directory));
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
private void showErrorImportingSaveGameUnknown() {
|
||||
final Dialog d = CustomDialogFactory.createErrorDialog(this,
|
||||
getString(R.string.loadsave_import_save_unsuccessfull),
|
||||
getString(R.string.loadsave_import_save_unsuccessfull_unknown));
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
private void showErrorLoadingEmptySlot() {
|
||||
final Dialog d = CustomDialogFactory.createErrorDialog(this,
|
||||
getString(R.string.startscreen_error_loading_game),
|
||||
getString(R.string.startscreen_error_loading_empty_slot));
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
private void showSlotGetsDeletedOnLoadWarning(final int slot) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(this,
|
||||
getString(R.string.startscreen_attention_slot_gets_delete_on_load),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.startscreen_attention_message_slot_gets_delete_on_load),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, v -> completeLoadSaveActivity(slot));
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
private void showConfirmoverwriteQuestion(final int slot, String message) {
|
||||
final String title =
|
||||
getString(R.string.loadsave_save_overwrite_confirmation_title) + ' '
|
||||
+ getString(R.string.loadsave_save_overwrite_confirmation_slot, slot);
|
||||
final Dialog d = CustomDialogFactory.createDialog(this,
|
||||
title,
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
message,
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, v -> completeLoadSaveActivity(slot));
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
}
|
||||
@@ -1,180 +1,179 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup.OnResourcesLoadedListener;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup.OnSceneLoadedListener;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
public final class LoadingActivity extends AndorsTrailBaseActivity implements OnResourcesLoadedListener, OnSceneLoadedListener {
|
||||
|
||||
private WorldSetup setup;
|
||||
private Dialog progressDialog;
|
||||
private CloudsAnimatorView clouds_back, clouds_mid, clouds_front;
|
||||
boolean loaded = false;
|
||||
|
||||
private Object semaphore = new Object();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
app.setWindowParameters(this);
|
||||
setContentView(R.layout.startscreen);
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.startscreen_version);
|
||||
tv.setVisibility(View.GONE);
|
||||
|
||||
clouds_back = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_back);
|
||||
if (clouds_back != null) clouds_back.setCloudsCountAndLayer(40, CloudsAnimatorView.Layer.below);
|
||||
clouds_mid = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_mid);
|
||||
if (clouds_mid != null) clouds_mid.setCloudsCountAndLayer(15, CloudsAnimatorView.Layer.center);
|
||||
clouds_front = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_front);
|
||||
if (clouds_front != null) clouds_front.setCloudsCountAndLayer(8, CloudsAnimatorView.Layer.above);
|
||||
|
||||
this.setup = app.getWorldSetup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
((AnimationDrawable)((ImageView)findViewById(R.id.title_logo)).getDrawable()).start();
|
||||
ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
int ivWidth = iv.getWidth();
|
||||
int drawableWidth = iv.getDrawable().getIntrinsicWidth();
|
||||
float ratio = ((float)ivWidth) / ((float)drawableWidth);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setScalingRatio(ratio);
|
||||
}
|
||||
|
||||
if (progressDialog == null) {
|
||||
progressDialog = CustomDialogFactory.createDialog(this, getResources().getString(R.string.dialog_loading_message),
|
||||
getResources().getDrawable(R.drawable.loading_anim), null, null, false, false);
|
||||
synchronized (semaphore) {
|
||||
if (!loaded) {
|
||||
progressDialog.setOwnerActivity(this);
|
||||
CustomDialogFactory.show(progressDialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
setup.setOnResourcesLoadedListener(this);
|
||||
|
||||
|
||||
final ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
iv.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
float[] point = new float[]{0f,0.25f * iv.getDrawable().getIntrinsicHeight()};
|
||||
iv.getImageMatrix().mapPoints(point);
|
||||
int imgY = (int) (iv.getTop() + point[1]);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setYMax(imgY);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setYMax(imgY);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setYMax(imgY);
|
||||
}
|
||||
iv.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (clouds_back != null)clouds_back.resumeAnimation();
|
||||
if (clouds_mid != null)clouds_mid.resumeAnimation();
|
||||
if (clouds_front != null)clouds_front.resumeAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
setup.setOnResourcesLoadedListener(null);
|
||||
setup.removeOnSceneLoadedListener(this);
|
||||
if (clouds_back != null)clouds_back.pauseAnimation();
|
||||
if (clouds_mid != null)clouds_mid.pauseAnimation();
|
||||
if (clouds_front != null)clouds_front.pauseAnimation();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResourcesLoaded() {
|
||||
loaded = false;
|
||||
setup.startCharacterSetup(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onSceneLoaded() {
|
||||
synchronized (semaphore) {
|
||||
if (progressDialog != null) progressDialog.dismiss();
|
||||
loaded =true;
|
||||
}
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
this.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSceneLoadFailed(Savegames.LoadSavegameResult loadResult) {
|
||||
synchronized (semaphore) {
|
||||
if (progressDialog != null) progressDialog.dismiss();
|
||||
loaded =true;
|
||||
}
|
||||
if (loadResult == Savegames.LoadSavegameResult.savegameIsFromAFutureVersion) {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_incorrectversion);
|
||||
} else if (loadResult == Savegames.LoadSavegameResult.cheatingDetected) {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_cheat);
|
||||
} else {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_message);
|
||||
}
|
||||
}
|
||||
|
||||
private void showLoadingFailedDialog(int messageResourceID) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(this, getResources().getString(R.string.dialog_loading_failed_title), null, getResources().getString(messageResourceID), null, true);
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
LoadingActivity.this.finish();
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup.OnResourcesLoadedListener;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup.OnSceneLoadedListener;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
public final class LoadingActivity extends AndorsTrailBaseActivity implements OnResourcesLoadedListener, OnSceneLoadedListener {
|
||||
|
||||
private WorldSetup setup;
|
||||
private Dialog progressDialog;
|
||||
private CloudsAnimatorView clouds_back, clouds_mid, clouds_front;
|
||||
boolean loaded = false;
|
||||
|
||||
private Object semaphore = new Object();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
app.setWindowParameters(this);
|
||||
setContentView(R.layout.startscreen);
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.startscreen_version);
|
||||
tv.setVisibility(View.GONE);
|
||||
|
||||
clouds_back = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_back);
|
||||
if (clouds_back != null) clouds_back.setCloudsCountAndLayer(40, CloudsAnimatorView.Layer.below);
|
||||
clouds_mid = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_mid);
|
||||
if (clouds_mid != null) clouds_mid.setCloudsCountAndLayer(15, CloudsAnimatorView.Layer.center);
|
||||
clouds_front = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_front);
|
||||
if (clouds_front != null) clouds_front.setCloudsCountAndLayer(8, CloudsAnimatorView.Layer.above);
|
||||
|
||||
this.setup = app.getWorldSetup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
((AnimationDrawable)((ImageView)findViewById(R.id.title_logo)).getDrawable()).start();
|
||||
ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
int ivWidth = iv.getWidth();
|
||||
int drawableWidth = iv.getDrawable().getIntrinsicWidth();
|
||||
float ratio = ((float)ivWidth) / ((float)drawableWidth);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setScalingRatio(ratio);
|
||||
}
|
||||
|
||||
if (progressDialog == null) {
|
||||
progressDialog = CustomDialogFactory.createDialog(this, getResources().getString(R.string.dialog_loading_message),
|
||||
getResources().getDrawable(R.drawable.loading_anim), null, null, false, false);
|
||||
synchronized (semaphore) {
|
||||
if (!loaded) {
|
||||
progressDialog.setOwnerActivity(this);
|
||||
CustomDialogFactory.show(progressDialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
setup.setOnResourcesLoadedListener(this);
|
||||
|
||||
|
||||
final ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
iv.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
float[] point = new float[]{0f,0.25f * iv.getDrawable().getIntrinsicHeight()};
|
||||
iv.getImageMatrix().mapPoints(point);
|
||||
int imgY = (int) (iv.getTop() + point[1]);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setYMax(imgY);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setYMax(imgY);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setYMax(imgY);
|
||||
}
|
||||
iv.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (clouds_back != null)clouds_back.resumeAnimation();
|
||||
if (clouds_mid != null)clouds_mid.resumeAnimation();
|
||||
if (clouds_front != null)clouds_front.resumeAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
setup.setOnResourcesLoadedListener(null);
|
||||
setup.removeOnSceneLoadedListener(this);
|
||||
if (clouds_back != null)clouds_back.pauseAnimation();
|
||||
if (clouds_mid != null)clouds_mid.pauseAnimation();
|
||||
if (clouds_front != null)clouds_front.pauseAnimation();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResourcesLoaded() {
|
||||
loaded = false;
|
||||
setup.startCharacterSetup(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onSceneLoaded() {
|
||||
synchronized (semaphore) {
|
||||
if (progressDialog != null) progressDialog.dismiss();
|
||||
loaded =true;
|
||||
}
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
this.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSceneLoadFailed(Savegames.LoadSavegameResult loadResult) {
|
||||
synchronized (semaphore) {
|
||||
if (progressDialog != null) progressDialog.dismiss();
|
||||
loaded =true;
|
||||
}
|
||||
if (loadResult == Savegames.LoadSavegameResult.savegameIsFromAFutureVersion) {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_incorrectversion);
|
||||
} else if (loadResult == Savegames.LoadSavegameResult.cheatingDetected) {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_cheat);
|
||||
} else {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_message);
|
||||
}
|
||||
}
|
||||
|
||||
private void showLoadingFailedDialog(int messageResourceID) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(this, getResources().getString(R.string.dialog_loading_failed_title), null, getResources().getString(messageResourceID), null, true);
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
LoadingActivity.this.finish();
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,6 @@ import com.gpl.rpg.AndorsTrail.controller.listeners.WorldEventListener;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorCondition;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorConditionEffect;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
@@ -305,7 +304,8 @@ public final class MainActivity
|
||||
t = Toast.makeText(this, msg, duration);
|
||||
lastToast = new WeakReference<Toast>(t);
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && t.getView().isShown()) {
|
||||
if (Build.VERSION.SDK_INT >= 30 ||
|
||||
Build.VERSION.SDK_INT >= 26 && t.getView().isShown()) {
|
||||
t.cancel();
|
||||
}
|
||||
t.setText(msg);
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -31,6 +30,7 @@ public final class MonsterInfoActivity extends AndorsTrailBaseActivity {
|
||||
private RangeBar hp;
|
||||
private ViewGroup monsterinfo_container;
|
||||
private TextView monsterinfo_max_ap;
|
||||
private TextView monsterinfo_killcount;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -48,6 +48,7 @@ public final class MonsterInfoActivity extends AndorsTrailBaseActivity {
|
||||
monsterinfo_title = (TextView) findViewById(R.id.monsterinfo_title);
|
||||
monsterinfo_difficulty = (TextView) findViewById(R.id.monsterinfo_difficulty);
|
||||
monsterinfo_max_ap = (TextView) findViewById(R.id.monsterinfo_max_ap);
|
||||
monsterinfo_killcount = (TextView) findViewById(R.id.monsterinfo_killcount);
|
||||
|
||||
Button b = (Button) findViewById(R.id.monsterinfo_close);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@@ -95,6 +96,7 @@ public final class MonsterInfoActivity extends AndorsTrailBaseActivity {
|
||||
false);
|
||||
hp.update(monster.getMaxHP(), monster.getCurrentHP());
|
||||
monsterinfo_max_ap.setText(Integer.toString(monster.getMaxAP()));
|
||||
monsterinfo_killcount.setText(Integer.toString(world.model.statistics.getNumberOfKillsForMonsterName(monster.getName()) ));
|
||||
}
|
||||
|
||||
public static int getMonsterDifficultyResource(ControllerContext controllerContext, Monster monster) {
|
||||
@@ -1,36 +1,45 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
public final class Preferences extends PreferenceActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (app.getPreferences().fullscreen) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
app.setLocale(this);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
app.setLocale(this);
|
||||
}
|
||||
}
|
||||
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
public final class Preferences extends PreferenceActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (app.getPreferences().fullscreen) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
app.setLocale(this);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
app.setLocale(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@ package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentTabHost;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
@@ -153,6 +152,7 @@ public final class SkillInfoActivity extends AndorsTrailBaseActivity {
|
||||
case specialization2hand: return R.string.skill_title_specialization_2hand;
|
||||
case specializationWeaponShield: return R.string.skill_title_specialization_weapon_shield;
|
||||
case weaponProficiencyPole: return R.string.skill_title_weapon_prof_pole;
|
||||
case sporeImmunity: return R.string.skill_title_spore_immunity;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@@ -181,6 +181,7 @@ public final class SkillInfoActivity extends AndorsTrailBaseActivity {
|
||||
case resistancePhysical: return res.getString(R.string.skill_longdescription_resistance_physical_capacity, SkillCollection.PER_SKILLPOINT_INCREASE_RESISTANCE_CHANCE_PERCENT, SkillCollection.PER_SKILLPOINT_INCREASE_RESISTANCE_CHANCE_PERCENT * SkillCollection.MAX_LEVEL_RESISTANCE);
|
||||
case resistanceBlood: return res.getString(R.string.skill_longdescription_resistance_blood_disorder, SkillCollection.PER_SKILLPOINT_INCREASE_RESISTANCE_CHANCE_PERCENT, SkillCollection.PER_SKILLPOINT_INCREASE_RESISTANCE_CHANCE_PERCENT * SkillCollection.MAX_LEVEL_RESISTANCE);
|
||||
case shadowBless: return res.getString(R.string.skill_longdescription_shadow_bless, SkillCollection.PER_SKILLPOINT_INCREASE_RESISTANCE_SHADOW_BLESS);
|
||||
case sporeImmunity: return res.getString(R.string.skill_longdescription_spore_immunity);
|
||||
case crit1: return res.getString(R.string.skill_longdescription_crit1, SkillCollection.PER_SKILLPOINT_INCREASE_CRIT1_CHANCE);
|
||||
case crit2: return res.getString(R.string.skill_longdescription_crit2, SkillCollection.PER_SKILLPOINT_INCREASE_CRIT2_CHANCE);
|
||||
case rejuvenation: return res.getString(R.string.skill_longdescription_rejuvenation, SkillCollection.PER_SKILLPOINT_INCREASE_REJUVENATION_CHANCE);
|
||||
@@ -1,292 +1,287 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu.OnNewGameRequestedListener;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame.GameCreationOverListener;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public final class StartScreenActivity extends AndorsTrailBaseFragmentActivity implements OnNewGameRequestedListener, GameCreationOverListener, OnBackStackChangedListener {
|
||||
|
||||
private TextView tv;
|
||||
private TextView development_version;
|
||||
private CloudsAnimatorView clouds_back, clouds_mid, clouds_front;
|
||||
private Fragment currentFragment;
|
||||
|
||||
//Means false by default, as a toggle is initiated in onCreate.
|
||||
boolean ui_visible = true;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
initPreferences();
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
final Resources res = getResources();
|
||||
TileManager tileManager = app.getWorld().tileManager;
|
||||
tileManager.setDensity(res);
|
||||
app.setWindowParameters(this);
|
||||
|
||||
setContentView(R.layout.startscreen);
|
||||
|
||||
if (findViewById(R.id.startscreen_fragment_container) != null) {
|
||||
StartScreenActivity_MainMenu mainMenu = new StartScreenActivity_MainMenu();
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.startscreen_fragment_container, mainMenu)
|
||||
.commit();
|
||||
currentFragment = mainMenu;
|
||||
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
tv = (TextView) findViewById(R.id.startscreen_version);
|
||||
tv.setText('v' + AndorsTrailApplication.CURRENT_VERSION_DISPLAY);
|
||||
|
||||
development_version = (TextView) findViewById(R.id.startscreen_dev_version);
|
||||
if (AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAMES) {
|
||||
development_version.setText(R.string.startscreen_incompatible_savegames);
|
||||
development_version.setVisibility(View.VISIBLE);
|
||||
} else if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
development_version.setText(R.string.startscreen_non_release_version);
|
||||
development_version.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
clouds_back = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_back);
|
||||
if (clouds_back != null) clouds_back.setCloudsCountAndLayer(40, CloudsAnimatorView.Layer.below);
|
||||
clouds_mid = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_mid);
|
||||
if (clouds_mid != null) clouds_mid.setCloudsCountAndLayer(15, CloudsAnimatorView.Layer.center);
|
||||
clouds_front = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_front);
|
||||
if (clouds_front != null) clouds_front.setCloudsCountAndLayer(8, CloudsAnimatorView.Layer.above);
|
||||
|
||||
View background = findViewById(R.id.title_bg);
|
||||
if (background != null) {
|
||||
background.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toggleUiVisibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (development_version.getVisibility() == View.VISIBLE) {
|
||||
development_version.setText(development_version.getText()
|
||||
// +
|
||||
// "\nMax Heap: " + Runtime.getRuntime().maxMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nUsed Heap: " + Runtime.getRuntime().totalMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nTile size: " + (int) (32 * res.getDisplayMetrics().density)
|
||||
);
|
||||
}
|
||||
|
||||
toggleUiVisibility();
|
||||
|
||||
app.getWorldSetup().startResourceLoader(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
if (grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(this,
|
||||
getResources().getString(R.string.dialog_permission_information_title),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||
getResources().getString(R.string.dialog_permission_information),
|
||||
null,
|
||||
true);
|
||||
final Activity activity = this;
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
StartScreenActivity_MainMenu.checkAndRequestPermissions(activity);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleUiVisibility() {
|
||||
ui_visible = !ui_visible;
|
||||
int visibility = ui_visible ? View.VISIBLE : View.GONE;
|
||||
if (tv != null) tv.setVisibility(visibility);
|
||||
if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
if (development_version != null) development_version.setVisibility(visibility);
|
||||
}
|
||||
if (currentFragment != null) {
|
||||
if (ui_visible) {
|
||||
|
||||
if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
development_version.setText(
|
||||
development_version.getText()
|
||||
// +
|
||||
// "\nMax Heap: " + Runtime.getRuntime().maxMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nUsed Heap: " + Runtime.getRuntime().totalMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nTile size: " + (int) (32 * getResources().getDisplayMetrics().density)
|
||||
);
|
||||
}
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.show(currentFragment)
|
||||
.commit();
|
||||
} else {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.hide(currentFragment)
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initPreferences() {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
AndorsTrailPreferences preferences = app.getPreferences();
|
||||
preferences.read(this);
|
||||
ThemeHelper.changeTheme(preferences.selectedTheme);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
((AnimationDrawable)((ImageView)findViewById(R.id.title_logo)).getDrawable()).start();
|
||||
ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
int ivWidth = iv.getWidth();
|
||||
int drawableWidth = iv.getDrawable().getIntrinsicWidth();
|
||||
float ratio = ((float)ivWidth) / ((float)drawableWidth);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setScalingRatio(ratio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
final ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
iv.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
float[] point = new float[]{0f,0.25f * iv.getDrawable().getIntrinsicHeight()};
|
||||
iv.getImageMatrix().mapPoints(point);
|
||||
int imgY = (int) (iv.getTop() + point[1]);
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setYMax(imgY);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setYMax(imgY);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setYMax(imgY);
|
||||
}
|
||||
iv.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (clouds_back != null)clouds_back.resumeAnimation();
|
||||
if (clouds_mid != null)clouds_mid.resumeAnimation();
|
||||
if (clouds_front != null)clouds_front.resumeAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (clouds_back != null)clouds_back.pauseAnimation();
|
||||
if (clouds_mid != null)clouds_mid.pauseAnimation();
|
||||
if (clouds_front != null)clouds_front.pauseAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
|
||||
backPressed();
|
||||
return true;
|
||||
} else {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
private void backPressed() {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
|
||||
getSupportFragmentManager().popBackStack();
|
||||
currentFragment = getSupportFragmentManager().findFragmentById(R.id.startscreen_fragment_container);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void onNewGameRequested() {
|
||||
if (findViewById(R.id.startscreen_fragment_container) != null) {
|
||||
StartScreenActivity_NewGame newGameFragment = new StartScreenActivity_NewGame();
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.startscreen_fragment_container, newGameFragment)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
|
||||
currentFragment = newGameFragment;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameCreationCancelled() {
|
||||
backPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackStackChanged() {
|
||||
currentFragment = getSupportFragmentManager().findFragmentById(R.id.startscreen_fragment_container);
|
||||
}
|
||||
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu.OnNewGameRequestedListener;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame.GameCreationOverListener;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public final class StartScreenActivity extends AndorsTrailBaseFragmentActivity implements OnNewGameRequestedListener, GameCreationOverListener, OnBackStackChangedListener {
|
||||
|
||||
private TextView tv;
|
||||
private TextView development_version;
|
||||
private CloudsAnimatorView clouds_back, clouds_mid, clouds_front;
|
||||
private Fragment currentFragment;
|
||||
|
||||
//Means false by default, as a toggle is initiated in onCreate.
|
||||
boolean ui_visible = true;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
initPreferences();
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
final Resources res = getResources();
|
||||
TileManager tileManager = app.getWorld().tileManager;
|
||||
tileManager.setDensity(res);
|
||||
app.setWindowParameters(this);
|
||||
|
||||
setContentView(R.layout.startscreen);
|
||||
|
||||
if (findViewById(R.id.startscreen_fragment_container) != null) {
|
||||
StartScreenActivity_MainMenu mainMenu = new StartScreenActivity_MainMenu();
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.startscreen_fragment_container, mainMenu)
|
||||
.commit();
|
||||
currentFragment = mainMenu;
|
||||
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
tv = (TextView) findViewById(R.id.startscreen_version);
|
||||
tv.setText('v' + AndorsTrailApplication.CURRENT_VERSION_DISPLAY);
|
||||
|
||||
development_version = (TextView) findViewById(R.id.startscreen_dev_version);
|
||||
if (AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAMES) {
|
||||
development_version.setText(R.string.startscreen_incompatible_savegames);
|
||||
development_version.setVisibility(View.VISIBLE);
|
||||
} else if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
development_version.setText(R.string.startscreen_non_release_version);
|
||||
development_version.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
clouds_back = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_back);
|
||||
if (clouds_back != null) clouds_back.setCloudsCountAndLayer(40, CloudsAnimatorView.Layer.below);
|
||||
clouds_mid = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_mid);
|
||||
if (clouds_mid != null) clouds_mid.setCloudsCountAndLayer(15, CloudsAnimatorView.Layer.center);
|
||||
clouds_front = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_front);
|
||||
if (clouds_front != null) clouds_front.setCloudsCountAndLayer(8, CloudsAnimatorView.Layer.above);
|
||||
|
||||
View background = findViewById(R.id.title_bg);
|
||||
if (background != null) {
|
||||
background.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toggleUiVisibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (development_version.getVisibility() == View.VISIBLE) {
|
||||
development_version.setText(development_version.getText()
|
||||
// +
|
||||
// "\nMax Heap: " + Runtime.getRuntime().maxMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nUsed Heap: " + Runtime.getRuntime().totalMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nTile size: " + (int) (32 * res.getDisplayMetrics().density)
|
||||
);
|
||||
}
|
||||
|
||||
toggleUiVisibility();
|
||||
|
||||
app.getWorldSetup().startResourceLoader(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
if (grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(this,
|
||||
getResources().getString(R.string.dialog_permission_information_title),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||
getResources().getString(R.string.dialog_permission_information),
|
||||
null,
|
||||
true);
|
||||
final Activity activity = this;
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
StartScreenActivity_MainMenu.checkAndRequestPermissions(activity);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleUiVisibility() {
|
||||
ui_visible = !ui_visible;
|
||||
int visibility = ui_visible ? View.VISIBLE : View.GONE;
|
||||
if (tv != null) tv.setVisibility(visibility);
|
||||
if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
if (development_version != null) development_version.setVisibility(visibility);
|
||||
}
|
||||
if (currentFragment != null) {
|
||||
if (ui_visible) {
|
||||
|
||||
if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
development_version.setText(
|
||||
development_version.getText()
|
||||
// +
|
||||
// "\nMax Heap: " + Runtime.getRuntime().maxMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nUsed Heap: " + Runtime.getRuntime().totalMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nTile size: " + (int) (32 * getResources().getDisplayMetrics().density)
|
||||
);
|
||||
}
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.show(currentFragment)
|
||||
.commit();
|
||||
} else {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.hide(currentFragment)
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initPreferences() {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
AndorsTrailPreferences preferences = app.getPreferences();
|
||||
preferences.read(this);
|
||||
ThemeHelper.changeTheme(preferences.selectedTheme);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
((AnimationDrawable)((ImageView)findViewById(R.id.title_logo)).getDrawable()).start();
|
||||
ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
int ivWidth = iv.getWidth();
|
||||
int drawableWidth = iv.getDrawable().getIntrinsicWidth();
|
||||
float ratio = ((float)ivWidth) / ((float)drawableWidth);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setScalingRatio(ratio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
final ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
iv.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
float[] point = new float[]{0f,0.25f * iv.getDrawable().getIntrinsicHeight()};
|
||||
iv.getImageMatrix().mapPoints(point);
|
||||
int imgY = (int) (iv.getTop() + point[1]);
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setYMax(imgY);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setYMax(imgY);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setYMax(imgY);
|
||||
}
|
||||
iv.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (clouds_back != null)clouds_back.resumeAnimation();
|
||||
if (clouds_mid != null)clouds_mid.resumeAnimation();
|
||||
if (clouds_front != null)clouds_front.resumeAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (clouds_back != null)clouds_back.pauseAnimation();
|
||||
if (clouds_mid != null)clouds_mid.pauseAnimation();
|
||||
if (clouds_front != null)clouds_front.pauseAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
|
||||
backPressed();
|
||||
return true;
|
||||
} else {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
private void backPressed() {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
|
||||
getSupportFragmentManager().popBackStack();
|
||||
currentFragment = getSupportFragmentManager().findFragmentById(R.id.startscreen_fragment_container);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void onNewGameRequested() {
|
||||
if (findViewById(R.id.startscreen_fragment_container) != null) {
|
||||
StartScreenActivity_NewGame newGameFragment = new StartScreenActivity_NewGame();
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.startscreen_fragment_container, newGameFragment)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
|
||||
currentFragment = newGameFragment;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameCreationCancelled() {
|
||||
backPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackStackChanged() {
|
||||
currentFragment = getSupportFragmentManager().findFragmentById(R.id.startscreen_fragment_container);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,476 +1,490 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.AdapterView.OnItemLongClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ItemInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.ItemController;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.HeroCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomMenuInflater;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
||||
import com.gpl.rpg.AndorsTrail.view.SpinnerEmulator;
|
||||
|
||||
public final class HeroinfoActivity_Inventory extends Fragment implements CustomMenuInflater.MenuItemSelectedListener {
|
||||
|
||||
private static final int INTENTREQUEST_ITEMINFO = 3;
|
||||
private static final int INTENTREQUEST_BULKSELECT_DROP = 11;
|
||||
|
||||
private WorldContext world;
|
||||
private ControllerContext controllers;
|
||||
private TileCollection wornTiles;
|
||||
|
||||
private Player player;
|
||||
private ListView inventoryList;
|
||||
private ItemContainerAdapter inventoryListAdapter;
|
||||
private ItemContainerAdapter inventoryWeaponsListAdapter;
|
||||
private ItemContainerAdapter inventoryArmorListAdapter;
|
||||
private ItemContainerAdapter inventoryUsableListAdapter;
|
||||
private ItemContainerAdapter inventoryQuestListAdapter;
|
||||
private ItemContainerAdapter inventoryOtherListAdapter;
|
||||
|
||||
private TextView heroinfo_stats_gold;
|
||||
private TextView heroinfo_stats_attack;
|
||||
private TextView heroinfo_stats_defense;
|
||||
|
||||
private ItemType lastSelectedItem; // Workaround android bug #7139
|
||||
|
||||
private final ImageView[] wornItemImage = new ImageView[Inventory.WearSlot.values().length];
|
||||
private final int[] defaultWornItemImageResourceIDs = new int[Inventory.WearSlot.values().length];
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity());
|
||||
if (!app.isInitialized()) return;
|
||||
this.world = app.getWorld();
|
||||
this.controllers = app.getControllerContext();
|
||||
this.player = world.model.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final View v = inflater.inflate(R.layout.heroinfo_inventory, container, false);
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity());
|
||||
if (!app.isInitialized()) return v;
|
||||
|
||||
inventoryList = (ListView) v.findViewById(R.id.inventorylist_root);
|
||||
ImageView heroicon = (ImageView) v.findViewById(R.id.heroinfo_inventory_heroicon);
|
||||
heroinfo_stats_gold = (TextView) v.findViewById(R.id.heroinfo_stats_gold);
|
||||
heroinfo_stats_attack = (TextView) v.findViewById(R.id.heroinfo_stats_attack);
|
||||
heroinfo_stats_defense = (TextView) v.findViewById(R.id.heroinfo_stats_defense);
|
||||
|
||||
registerForContextMenu(inventoryList);
|
||||
inventoryList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
// Move this code to separate function? -- Done
|
||||
ItemType itemType = getSelectedItemType(position);
|
||||
showInventoryItemInfo(itemType.id);
|
||||
}
|
||||
});
|
||||
inventoryList.setOnItemLongClickListener(new OnItemLongClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
showContextMenuForItem(getSelectedItemType(position));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
new SpinnerEmulator(v, R.id.inventorylist_category_filters_button, R.array.inventorylist_category_filters, R.string.heroinfo_inventory_categories) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedInventoryCategory = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownCategory(value);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return world.model.uiSelections.selectedInventoryCategory;
|
||||
}
|
||||
};
|
||||
new SpinnerEmulator(v, R.id.inventorylist_sort_filters_button, R.array.inventorylist_sort_filters, R.string.heroinfo_inventory_sort) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedInventorySort = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownSort(player.inventory);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return world.model.uiSelections.selectedInventorySort;
|
||||
}
|
||||
};
|
||||
|
||||
ItemContainer inv = player.inventory;
|
||||
wornTiles = world.tileManager.loadTilesFor(player.inventory, getResources());
|
||||
inventoryListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, inv, player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryListAdapter);
|
||||
|
||||
|
||||
heroicon.setImageResource(HeroCollection.getHeroLargeSprite(player.iconID));
|
||||
|
||||
setWearSlot(v, Inventory.WearSlot.weapon, R.id.heroinfo_worn_weapon, R.drawable.equip_weapon);
|
||||
setWearSlot(v, Inventory.WearSlot.shield, R.id.heroinfo_worn_shield, R.drawable.equip_shield);
|
||||
setWearSlot(v, Inventory.WearSlot.head, R.id.heroinfo_worn_head, R.drawable.equip_head);
|
||||
setWearSlot(v, Inventory.WearSlot.body, R.id.heroinfo_worn_body, R.drawable.equip_body);
|
||||
setWearSlot(v, Inventory.WearSlot.feet, R.id.heroinfo_worn_feet, R.drawable.equip_feet);
|
||||
setWearSlot(v, Inventory.WearSlot.neck, R.id.heroinfo_worn_neck, R.drawable.equip_neck);
|
||||
setWearSlot(v, Inventory.WearSlot.hand, R.id.heroinfo_worn_hand, R.drawable.equip_hand);
|
||||
setWearSlot(v, Inventory.WearSlot.leftring, R.id.heroinfo_worn_ringleft, R.drawable.equip_ring);
|
||||
setWearSlot(v, Inventory.WearSlot.rightring, R.id.heroinfo_worn_ringright, R.drawable.equip_ring);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
update();
|
||||
}
|
||||
|
||||
private void setWearSlot(final View v, final Inventory.WearSlot inventorySlot, int viewId, int resourceId) {
|
||||
final ImageView imageView = (ImageView) v.findViewById(viewId);
|
||||
wornItemImage[inventorySlot.ordinal()] = imageView;
|
||||
defaultWornItemImageResourceIDs[inventorySlot.ordinal()] = resourceId;
|
||||
imageView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (player.inventory.isEmptySlot(inventorySlot)) return;
|
||||
imageView.setClickable(false); // Will be enabled again on update()
|
||||
showEquippedItemInfo(player.inventory.getItemTypeInWearSlot(inventorySlot), inventorySlot);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case INTENTREQUEST_ITEMINFO:
|
||||
if (resultCode == ItemInfoActivity.RESULT_MORE_ACTIONS) {
|
||||
showContextMenuForItem( world.itemTypes.getItemType(data.getExtras().getString("itemTypeID")));
|
||||
break;
|
||||
}
|
||||
if (resultCode != Activity.RESULT_OK) break;
|
||||
|
||||
ItemType itemType = world.itemTypes.getItemType(data.getExtras().getString("itemTypeID"));
|
||||
ItemInfoActivity.ItemInfoAction actionType = ItemInfoActivity.ItemInfoAction.valueOf(data.getExtras().getString("actionType"));
|
||||
if (actionType == ItemInfoActivity.ItemInfoAction.unequip) {
|
||||
Inventory.WearSlot slot = Inventory.WearSlot.valueOf(data.getExtras().getString("inventorySlot"));
|
||||
controllers.itemController.unequipSlot(itemType, slot);
|
||||
} else if (actionType == ItemInfoActivity.ItemInfoAction.equip) {
|
||||
Inventory.WearSlot slot = suggestInventorySlot(itemType);
|
||||
controllers.itemController.equipItem(itemType, slot);
|
||||
} else if (actionType == ItemInfoActivity.ItemInfoAction.use) {
|
||||
controllers.itemController.useItem(itemType);
|
||||
}
|
||||
break;
|
||||
case INTENTREQUEST_BULKSELECT_DROP:
|
||||
if (resultCode != Activity.RESULT_OK) break;
|
||||
|
||||
int quantity = data.getExtras().getInt("selectedAmount");
|
||||
String itemTypeID = data.getExtras().getString("itemTypeID");
|
||||
dropItem(itemTypeID, quantity);
|
||||
break;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
private Inventory.WearSlot suggestInventorySlot(ItemType itemType) {
|
||||
Inventory.WearSlot slot = itemType.category.inventorySlot;
|
||||
if (player.inventory.isEmptySlot(slot)) return slot;
|
||||
|
||||
if (slot == Inventory.WearSlot.leftring) return Inventory.WearSlot.rightring;
|
||||
if (itemType.isOffhandCapableWeapon()) {
|
||||
ItemType mainWeapon = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (mainWeapon != null && mainWeapon.isTwohandWeapon()) return slot;
|
||||
else if (player.inventory.isEmptySlot(Inventory.WearSlot.shield)) return Inventory.WearSlot.shield;
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
|
||||
private void dropItem(String itemTypeID, int quantity) {
|
||||
ItemType itemType = world.itemTypes.getItemType(itemTypeID);
|
||||
controllers.itemController.dropItem(itemType, quantity);
|
||||
}
|
||||
|
||||
private void update() {
|
||||
updateTraits();
|
||||
updateWorn();
|
||||
updateItemList();
|
||||
}
|
||||
|
||||
private void updateTraits() {
|
||||
heroinfo_stats_gold.setText(getResources().getString(R.string.heroinfo_gold, player.inventory.gold));
|
||||
|
||||
StringBuilder sb = new StringBuilder(10);
|
||||
ItemController.describeAttackEffect(
|
||||
player.getAttackChance(),
|
||||
player.getDamagePotential().current,
|
||||
player.getDamagePotential().max,
|
||||
player.getCriticalSkill(),
|
||||
player.getCriticalMultiplier(),
|
||||
sb);
|
||||
heroinfo_stats_attack.setText(sb.toString());
|
||||
|
||||
sb = new StringBuilder(10);
|
||||
ItemController.describeBlockEffect(player.getBlockChance(), player.getDamageResistance(), sb);
|
||||
heroinfo_stats_defense.setText(sb.toString());
|
||||
}
|
||||
|
||||
private void updateWorn() {
|
||||
for(Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
updateWornImage(wornItemImage[slot.ordinal()], defaultWornItemImageResourceIDs[slot.ordinal()], player.inventory.getItemTypeInWearSlot(slot));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWornImage(ImageView imageView, int resourceIDEmptyImage, ItemType type) {
|
||||
if (type != null) {
|
||||
world.tileManager.setImageViewTile(getResources(), imageView, type, wornTiles);
|
||||
} else {
|
||||
imageView.setImageResource(resourceIDEmptyImage);
|
||||
}
|
||||
imageView.setClickable(true);
|
||||
}
|
||||
|
||||
private void updateItemList() {
|
||||
int currentScreen = world.model.uiSelections.selectedInventoryCategory;
|
||||
if (currentScreen == 0)
|
||||
inventoryListAdapter.notifyDataSetChanged();
|
||||
else
|
||||
reloadShownCategory(world.model.uiSelections.selectedInventoryCategory);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {}
|
||||
// ItemType type = getSelectedItemType((AdapterContextMenuInfo) menuInfo);
|
||||
|
||||
|
||||
public void showContextMenuForItem(ItemType type) {
|
||||
MenuInflater inflater = getActivity().getMenuInflater();
|
||||
Menu menu = CustomMenuInflater.newMenuInstance(getActivity());
|
||||
inflater.inflate(R.menu.inventoryitem, menu);
|
||||
if (type.isUsable()){
|
||||
menu.findItem(R.id.inv_menu_use).setVisible(true);
|
||||
menu.findItem(R.id.inv_menu_assign).setVisible(true);
|
||||
}
|
||||
if (type.isEquippable()) {
|
||||
menu.findItem(R.id.inv_menu_equip).setVisible(true);
|
||||
if (type.isOffhandCapableWeapon()) menu.findItem(R.id.inv_menu_equip_offhand).setVisible(true);
|
||||
else if (type.category.inventorySlot == Inventory.WearSlot.leftring) menu.findItem(R.id.inv_menu_equip_offhand).setVisible(true);
|
||||
}
|
||||
lastSelectedItem = null;
|
||||
CustomMenuInflater.showMenuInDialog(getActivity(), menu, world.tileManager.getDrawableForItem(getResources(), type.iconID, world.tileManager.loadTilesFor(Arrays.asList(new Integer[] { type.iconID}), getResources())), type.getName(player), type, this);
|
||||
}
|
||||
|
||||
private ItemType getSelectedItemType(int position) {
|
||||
int v = world.model.uiSelections.selectedInventoryCategory;
|
||||
|
||||
if (v == 0) { //All items
|
||||
return inventoryListAdapter.getItem(position).itemType;
|
||||
}else if (v == 1) { //Weapon items
|
||||
return inventoryWeaponsListAdapter.getItem(position).itemType;
|
||||
} else if (v == 2) { //Armor items
|
||||
return inventoryArmorListAdapter.getItem(position).itemType;
|
||||
} else if (v == 3) { //Usable items
|
||||
return inventoryUsableListAdapter.getItem(position).itemType;
|
||||
} else if (v == 4) { //Quest items
|
||||
return inventoryQuestListAdapter.getItem(position).itemType;
|
||||
} else if (v == 5) { //Other items
|
||||
return inventoryOtherListAdapter.getItem(position).itemType;
|
||||
}
|
||||
|
||||
// Better than crashing...
|
||||
return inventoryListAdapter.getItem(position).itemType;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private ItemType getSelectedItemType(AdapterContextMenuInfo info) {
|
||||
return getSelectedItemType(info.position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMenuItemSelected(MenuItem item, Object data) {
|
||||
ItemType itemType = (ItemType) data;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.inv_menu_info:
|
||||
showInventoryItemInfo(itemType);
|
||||
//context.mapController.itemInfo(this, getSelectedItemType(info));
|
||||
break;
|
||||
case R.id.inv_menu_drop:
|
||||
String itemTypeID = itemType.id;
|
||||
int quantity = player.inventory.getItemQuantity(itemTypeID);
|
||||
if (quantity > 1) {
|
||||
Intent intent = Dialogs.getIntentForBulkDroppingInterface(getActivity(), itemTypeID, quantity);
|
||||
startActivityForResult(intent, INTENTREQUEST_BULKSELECT_DROP);
|
||||
} else {
|
||||
dropItem(itemTypeID, quantity);
|
||||
}
|
||||
break;
|
||||
case R.id.inv_menu_equip:
|
||||
controllers.itemController.equipItem(itemType, itemType.category.inventorySlot);
|
||||
break;
|
||||
case R.id.inv_menu_equip_offhand:
|
||||
if (itemType.category.inventorySlot == Inventory.WearSlot.weapon) {
|
||||
controllers.itemController.equipItem(itemType, Inventory.WearSlot.shield);
|
||||
} else if (itemType.category.inventorySlot == Inventory.WearSlot.leftring) {
|
||||
controllers.itemController.equipItem(itemType, Inventory.WearSlot.rightring);
|
||||
}
|
||||
break;
|
||||
/*case R.id.inv_menu_unequip:
|
||||
context.mapController.unequipItem(this, getSelectedItemType(info));
|
||||
break;*/
|
||||
case R.id.inv_menu_use:
|
||||
controllers.itemController.useItem(itemType);
|
||||
break;
|
||||
case R.id.inv_menu_assign:
|
||||
//lastSelectedItem = itemType;
|
||||
break;
|
||||
case R.id.inv_assign_slot1:
|
||||
controllers.itemController.setQuickItem(itemType, 0);
|
||||
break;
|
||||
case R.id.inv_assign_slot2:
|
||||
controllers.itemController.setQuickItem(itemType, 1);
|
||||
break;
|
||||
case R.id.inv_assign_slot3:
|
||||
controllers.itemController.setQuickItem(itemType, 2);
|
||||
break;
|
||||
case R.id.inv_menu_movetop:
|
||||
player.inventory.sortToTop(itemType.id);
|
||||
break;
|
||||
case R.id.inv_menu_movebottom:
|
||||
player.inventory.sortToBottom(itemType.id);
|
||||
break;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
private void showEquippedItemInfo(ItemType itemType, Inventory.WearSlot inventorySlot) {
|
||||
String text;
|
||||
boolean enabled = true;
|
||||
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
int ap = world.model.player.getReequipCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_unequip_ap, ap);
|
||||
if (ap > 0) {
|
||||
enabled = world.model.player.hasAPs(ap);
|
||||
}
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_unequip);
|
||||
}
|
||||
Intent intent = Dialogs.getIntentForItemInfo(getActivity(), itemType.id, ItemInfoActivity.ItemInfoAction.unequip, text, enabled, inventorySlot);
|
||||
startActivityForResult(intent, INTENTREQUEST_ITEMINFO);
|
||||
}
|
||||
private void showInventoryItemInfo(String itemTypeID) {
|
||||
showInventoryItemInfo(world.itemTypes.getItemType(itemTypeID));
|
||||
}
|
||||
private void showInventoryItemInfo(ItemType itemType) {
|
||||
String text = "";
|
||||
int ap = 0;
|
||||
boolean enabled = true;
|
||||
ItemInfoActivity.ItemInfoAction action = ItemInfoActivity.ItemInfoAction.none;
|
||||
final boolean isInCombat = world.model.uiSelections.isInCombat;
|
||||
if (itemType.isEquippable()) {
|
||||
if (isInCombat) {
|
||||
ap = world.model.player.getReequipCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_equip_ap, ap);
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_equip);
|
||||
}
|
||||
action = ItemInfoActivity.ItemInfoAction.equip;
|
||||
} else if (itemType.isUsable()) {
|
||||
if (isInCombat) {
|
||||
ap = world.model.player.getUseItemCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_use_ap, ap);
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_use);
|
||||
}
|
||||
action = ItemInfoActivity.ItemInfoAction.use;
|
||||
}
|
||||
if (isInCombat && ap > 0) {
|
||||
enabled = world.model.player.hasAPs(ap);
|
||||
}
|
||||
|
||||
Intent intent = Dialogs.getIntentForItemInfo(getActivity(), itemType.id, action, text, enabled, null);
|
||||
startActivityForResult(intent, INTENTREQUEST_ITEMINFO);
|
||||
}
|
||||
|
||||
private void reloadShownCategory(int v) { // Apologies about the code duplication,
|
||||
// just didn't seem to make sense as an array, although I did create a nice array for skill category adapters.
|
||||
|
||||
// Decide which category to show
|
||||
if (v == 0) { //All items
|
||||
inventoryList.setAdapter(inventoryListAdapter);
|
||||
inventoryListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 1) { //Weapon items
|
||||
inventoryWeaponsListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildWeaponItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryWeaponsListAdapter);
|
||||
inventoryWeaponsListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 2) { //Armor items
|
||||
inventoryArmorListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildArmorItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryArmorListAdapter);
|
||||
inventoryArmorListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 3) { //Usable items
|
||||
inventoryUsableListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildUsableItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryUsableListAdapter);
|
||||
inventoryUsableListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 4) { //Quest items
|
||||
inventoryQuestListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildQuestItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryQuestListAdapter);
|
||||
inventoryQuestListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 5) { //Other items
|
||||
inventoryOtherListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildOtherItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryOtherListAdapter);
|
||||
inventoryOtherListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
//updateItemList();
|
||||
}
|
||||
|
||||
private void reloadShownSort(Inventory inv) {
|
||||
int selected = world.model.uiSelections.selectedInventorySort;
|
||||
|
||||
inventoryListAdapter.reloadShownSort(selected, world.model.uiSelections.oldSortSelection, player.inventory, player);
|
||||
|
||||
// Currently not functional, perhaps because selection only updates when changed.
|
||||
if (world.model.uiSelections.oldSortSelection == selected)
|
||||
world.model.uiSelections.oldSortSelection = 0;
|
||||
else world.model.uiSelections.oldSortSelection = selected;
|
||||
updateItemList();
|
||||
}
|
||||
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.AdapterView.OnItemLongClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ItemInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.ItemController;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.HeroCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomMenuInflater;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
||||
import com.gpl.rpg.AndorsTrail.view.SpinnerEmulator;
|
||||
|
||||
public final class HeroinfoActivity_Inventory extends Fragment implements CustomMenuInflater.MenuItemSelectedListener {
|
||||
|
||||
private static final int INTENTREQUEST_ITEMINFO = 3;
|
||||
private static final int INTENTREQUEST_BULKSELECT_DROP = 11;
|
||||
|
||||
private WorldContext world;
|
||||
private ControllerContext controllers;
|
||||
private TileCollection wornTiles;
|
||||
|
||||
private Player player;
|
||||
private ListView inventoryList;
|
||||
private ItemContainerAdapter inventoryListAdapter;
|
||||
private ItemContainerAdapter inventoryWeaponsListAdapter;
|
||||
private ItemContainerAdapter inventoryArmorListAdapter;
|
||||
private ItemContainerAdapter inventoryJewelryListAdapter;
|
||||
private ItemContainerAdapter inventoryPotionListAdapter;
|
||||
private ItemContainerAdapter inventoryFoodListAdapter;
|
||||
private ItemContainerAdapter inventoryQuestListAdapter;
|
||||
private ItemContainerAdapter inventoryOtherListAdapter;
|
||||
|
||||
private TextView heroinfo_stats_gold;
|
||||
private TextView heroinfo_stats_attack;
|
||||
private TextView heroinfo_stats_defense;
|
||||
|
||||
private ItemType lastSelectedItem; // Workaround android bug #7139
|
||||
|
||||
private final ImageView[] wornItemImage = new ImageView[Inventory.WearSlot.values().length];
|
||||
private final int[] defaultWornItemImageResourceIDs = new int[Inventory.WearSlot.values().length];
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity());
|
||||
if (!app.isInitialized()) return;
|
||||
this.world = app.getWorld();
|
||||
this.controllers = app.getControllerContext();
|
||||
this.player = world.model.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final View v = inflater.inflate(R.layout.heroinfo_inventory, container, false);
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity());
|
||||
if (!app.isInitialized()) return v;
|
||||
|
||||
inventoryList = (ListView) v.findViewById(R.id.inventorylist_root);
|
||||
ImageView heroicon = (ImageView) v.findViewById(R.id.heroinfo_inventory_heroicon);
|
||||
heroinfo_stats_gold = (TextView) v.findViewById(R.id.heroinfo_stats_gold);
|
||||
heroinfo_stats_attack = (TextView) v.findViewById(R.id.heroinfo_stats_attack);
|
||||
heroinfo_stats_defense = (TextView) v.findViewById(R.id.heroinfo_stats_defense);
|
||||
|
||||
registerForContextMenu(inventoryList);
|
||||
inventoryList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
// Move this code to separate function? -- Done
|
||||
ItemType itemType = getSelectedItemType(position);
|
||||
showInventoryItemInfo(itemType.id);
|
||||
}
|
||||
});
|
||||
inventoryList.setOnItemLongClickListener(new OnItemLongClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
showContextMenuForItem(getSelectedItemType(position));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
new SpinnerEmulator(v, R.id.inventorylist_category_filters_button, R.array.inventorylist_category_filters, R.string.heroinfo_inventory_categories) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedInventoryCategory = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownCategory(value);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return world.model.uiSelections.selectedInventoryCategory;
|
||||
}
|
||||
};
|
||||
new SpinnerEmulator(v, R.id.inventorylist_sort_filters_button, R.array.inventorylist_sort_filters, R.string.heroinfo_inventory_sort) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedInventorySort = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownSort(player.inventory);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return world.model.uiSelections.selectedInventorySort;
|
||||
}
|
||||
};
|
||||
|
||||
ItemContainer inv = player.inventory;
|
||||
wornTiles = world.tileManager.loadTilesFor(player.inventory, getResources());
|
||||
inventoryListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, inv, player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryListAdapter);
|
||||
|
||||
|
||||
heroicon.setImageResource(HeroCollection.getHeroLargeSprite(player.iconID));
|
||||
|
||||
setWearSlot(v, Inventory.WearSlot.weapon, R.id.heroinfo_worn_weapon, R.drawable.equip_weapon);
|
||||
setWearSlot(v, Inventory.WearSlot.shield, R.id.heroinfo_worn_shield, R.drawable.equip_shield);
|
||||
setWearSlot(v, Inventory.WearSlot.head, R.id.heroinfo_worn_head, R.drawable.equip_head);
|
||||
setWearSlot(v, Inventory.WearSlot.body, R.id.heroinfo_worn_body, R.drawable.equip_body);
|
||||
setWearSlot(v, Inventory.WearSlot.feet, R.id.heroinfo_worn_feet, R.drawable.equip_feet);
|
||||
setWearSlot(v, Inventory.WearSlot.neck, R.id.heroinfo_worn_neck, R.drawable.equip_neck);
|
||||
setWearSlot(v, Inventory.WearSlot.hand, R.id.heroinfo_worn_hand, R.drawable.equip_hand);
|
||||
setWearSlot(v, Inventory.WearSlot.leftring, R.id.heroinfo_worn_ringleft, R.drawable.equip_ring);
|
||||
setWearSlot(v, Inventory.WearSlot.rightring, R.id.heroinfo_worn_ringright, R.drawable.equip_ring);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
update();
|
||||
}
|
||||
|
||||
private void setWearSlot(final View v, final Inventory.WearSlot inventorySlot, int viewId, int resourceId) {
|
||||
final ImageView imageView = (ImageView) v.findViewById(viewId);
|
||||
wornItemImage[inventorySlot.ordinal()] = imageView;
|
||||
defaultWornItemImageResourceIDs[inventorySlot.ordinal()] = resourceId;
|
||||
imageView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (player.inventory.isEmptySlot(inventorySlot)) return;
|
||||
imageView.setClickable(false); // Will be enabled again on update()
|
||||
showEquippedItemInfo(player.inventory.getItemTypeInWearSlot(inventorySlot), inventorySlot);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case INTENTREQUEST_ITEMINFO:
|
||||
if (resultCode == ItemInfoActivity.RESULT_MORE_ACTIONS) {
|
||||
showContextMenuForItem( world.itemTypes.getItemType(data.getExtras().getString("itemTypeID")));
|
||||
break;
|
||||
}
|
||||
if (resultCode != Activity.RESULT_OK) break;
|
||||
|
||||
ItemType itemType = world.itemTypes.getItemType(data.getExtras().getString("itemTypeID"));
|
||||
ItemInfoActivity.ItemInfoAction actionType = ItemInfoActivity.ItemInfoAction.valueOf(data.getExtras().getString("actionType"));
|
||||
if (actionType == ItemInfoActivity.ItemInfoAction.unequip) {
|
||||
Inventory.WearSlot slot = Inventory.WearSlot.valueOf(data.getExtras().getString("inventorySlot"));
|
||||
controllers.itemController.unequipSlot(itemType, slot);
|
||||
} else if (actionType == ItemInfoActivity.ItemInfoAction.equip) {
|
||||
Inventory.WearSlot slot = suggestInventorySlot(itemType);
|
||||
controllers.itemController.equipItem(itemType, slot);
|
||||
} else if (actionType == ItemInfoActivity.ItemInfoAction.use) {
|
||||
controllers.itemController.useItem(itemType);
|
||||
}
|
||||
break;
|
||||
case INTENTREQUEST_BULKSELECT_DROP:
|
||||
if (resultCode != Activity.RESULT_OK) break;
|
||||
|
||||
int quantity = data.getExtras().getInt("selectedAmount");
|
||||
String itemTypeID = data.getExtras().getString("itemTypeID");
|
||||
dropItem(itemTypeID, quantity);
|
||||
break;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
private Inventory.WearSlot suggestInventorySlot(ItemType itemType) {
|
||||
Inventory.WearSlot slot = itemType.category.inventorySlot;
|
||||
if (player.inventory.isEmptySlot(slot)) return slot;
|
||||
|
||||
if (slot == Inventory.WearSlot.leftring) return Inventory.WearSlot.rightring;
|
||||
if (itemType.isOffhandCapableWeapon()) {
|
||||
ItemType mainWeapon = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (mainWeapon != null && mainWeapon.isTwohandWeapon()) return slot;
|
||||
else if (player.inventory.isEmptySlot(Inventory.WearSlot.shield)) return Inventory.WearSlot.shield;
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
|
||||
private void dropItem(String itemTypeID, int quantity) {
|
||||
ItemType itemType = world.itemTypes.getItemType(itemTypeID);
|
||||
controllers.itemController.dropItem(itemType, quantity);
|
||||
}
|
||||
|
||||
private void update() {
|
||||
updateTraits();
|
||||
updateWorn();
|
||||
updateItemList();
|
||||
}
|
||||
|
||||
private void updateTraits() {
|
||||
heroinfo_stats_gold.setText(getResources().getString(R.string.heroinfo_gold, player.inventory.gold));
|
||||
|
||||
StringBuilder sb = new StringBuilder(10);
|
||||
ItemController.describeAttackEffect(
|
||||
player.getAttackChance(),
|
||||
player.getDamagePotential().current,
|
||||
player.getDamagePotential().max,
|
||||
player.getCriticalSkill(),
|
||||
player.getCriticalMultiplier(),
|
||||
sb);
|
||||
heroinfo_stats_attack.setText(sb.toString());
|
||||
|
||||
sb = new StringBuilder(10);
|
||||
ItemController.describeBlockEffect(player.getBlockChance(), player.getDamageResistance(), sb);
|
||||
heroinfo_stats_defense.setText(sb.toString());
|
||||
}
|
||||
|
||||
private void updateWorn() {
|
||||
for(Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
updateWornImage(wornItemImage[slot.ordinal()], defaultWornItemImageResourceIDs[slot.ordinal()], player.inventory.getItemTypeInWearSlot(slot));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWornImage(ImageView imageView, int resourceIDEmptyImage, ItemType type) {
|
||||
if (type != null) {
|
||||
world.tileManager.setImageViewTile(getResources(), imageView, type, wornTiles);
|
||||
} else {
|
||||
imageView.setImageResource(resourceIDEmptyImage);
|
||||
}
|
||||
imageView.setClickable(true);
|
||||
}
|
||||
|
||||
private void updateItemList() {
|
||||
int currentScreen = world.model.uiSelections.selectedInventoryCategory;
|
||||
if (currentScreen == 0)
|
||||
inventoryListAdapter.notifyDataSetChanged();
|
||||
else
|
||||
reloadShownCategory(world.model.uiSelections.selectedInventoryCategory);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {}
|
||||
// ItemType type = getSelectedItemType((AdapterContextMenuInfo) menuInfo);
|
||||
|
||||
|
||||
public void showContextMenuForItem(ItemType type) {
|
||||
MenuInflater inflater = getActivity().getMenuInflater();
|
||||
Menu menu = CustomMenuInflater.newMenuInstance(getActivity());
|
||||
inflater.inflate(R.menu.inventoryitem, menu);
|
||||
if (type.isUsable()){
|
||||
menu.findItem(R.id.inv_menu_use).setVisible(true);
|
||||
menu.findItem(R.id.inv_menu_assign).setVisible(true);
|
||||
}
|
||||
if (type.isEquippable()) {
|
||||
menu.findItem(R.id.inv_menu_equip).setVisible(true);
|
||||
if (type.isOffhandCapableWeapon()) menu.findItem(R.id.inv_menu_equip_offhand).setVisible(true);
|
||||
else if (type.category.inventorySlot == Inventory.WearSlot.leftring) menu.findItem(R.id.inv_menu_equip_offhand).setVisible(true);
|
||||
}
|
||||
lastSelectedItem = null;
|
||||
CustomMenuInflater.showMenuInDialog(getActivity(), menu, world.tileManager.getDrawableForItem(getResources(), type.iconID, world.tileManager.loadTilesFor(Arrays.asList(new Integer[] { type.iconID}), getResources())), type.getName(player), type, this);
|
||||
}
|
||||
|
||||
private ItemType getSelectedItemType(int position) {
|
||||
int v = world.model.uiSelections.selectedInventoryCategory;
|
||||
|
||||
if (v == 0) { //All items
|
||||
return inventoryListAdapter.getItem(position).itemType;
|
||||
}else if (v == 1) { //Weapon items
|
||||
return inventoryWeaponsListAdapter.getItem(position).itemType;
|
||||
} else if (v == 2) { //Armor items
|
||||
return inventoryArmorListAdapter.getItem(position).itemType;
|
||||
} else if (v == 3) { //Jewelry items
|
||||
return inventoryJewelryListAdapter.getItem(position).itemType;
|
||||
} else if (v == 4) { //Potion items
|
||||
return inventoryPotionListAdapter.getItem(position).itemType;
|
||||
} else if (v == 5) { //Food items
|
||||
return inventoryFoodListAdapter.getItem(position).itemType;
|
||||
} else if (v == 6) { //Quest items
|
||||
return inventoryQuestListAdapter.getItem(position).itemType;
|
||||
} else if (v == 7) { //Other items
|
||||
return inventoryOtherListAdapter.getItem(position).itemType;
|
||||
}
|
||||
|
||||
// Better than crashing...
|
||||
return inventoryListAdapter.getItem(position).itemType;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private ItemType getSelectedItemType(AdapterContextMenuInfo info) {
|
||||
return getSelectedItemType(info.position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMenuItemSelected(MenuItem item, Object data) {
|
||||
ItemType itemType = (ItemType) data;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.inv_menu_info:
|
||||
showInventoryItemInfo(itemType);
|
||||
//context.mapController.itemInfo(this, getSelectedItemType(info));
|
||||
break;
|
||||
case R.id.inv_menu_drop:
|
||||
String itemTypeID = itemType.id;
|
||||
int quantity = player.inventory.getItemQuantity(itemTypeID);
|
||||
if (quantity > 1) {
|
||||
Intent intent = Dialogs.getIntentForBulkDroppingInterface(getActivity(), itemTypeID, quantity);
|
||||
startActivityForResult(intent, INTENTREQUEST_BULKSELECT_DROP);
|
||||
} else {
|
||||
dropItem(itemTypeID, quantity);
|
||||
}
|
||||
break;
|
||||
case R.id.inv_menu_equip:
|
||||
controllers.itemController.equipItem(itemType, itemType.category.inventorySlot);
|
||||
break;
|
||||
case R.id.inv_menu_equip_offhand:
|
||||
if (itemType.category.inventorySlot == Inventory.WearSlot.weapon) {
|
||||
controllers.itemController.equipItem(itemType, Inventory.WearSlot.shield);
|
||||
} else if (itemType.category.inventorySlot == Inventory.WearSlot.leftring) {
|
||||
controllers.itemController.equipItem(itemType, Inventory.WearSlot.rightring);
|
||||
}
|
||||
break;
|
||||
/*case R.id.inv_menu_unequip:
|
||||
context.mapController.unequipItem(this, getSelectedItemType(info));
|
||||
break;*/
|
||||
case R.id.inv_menu_use:
|
||||
controllers.itemController.useItem(itemType);
|
||||
break;
|
||||
case R.id.inv_menu_assign:
|
||||
//lastSelectedItem = itemType;
|
||||
break;
|
||||
case R.id.inv_assign_slot1:
|
||||
controllers.itemController.setQuickItem(itemType, 0);
|
||||
break;
|
||||
case R.id.inv_assign_slot2:
|
||||
controllers.itemController.setQuickItem(itemType, 1);
|
||||
break;
|
||||
case R.id.inv_assign_slot3:
|
||||
controllers.itemController.setQuickItem(itemType, 2);
|
||||
break;
|
||||
case R.id.inv_menu_movetop:
|
||||
player.inventory.sortToTop(itemType.id);
|
||||
break;
|
||||
case R.id.inv_menu_movebottom:
|
||||
player.inventory.sortToBottom(itemType.id);
|
||||
break;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
private void showEquippedItemInfo(ItemType itemType, Inventory.WearSlot inventorySlot) {
|
||||
String text;
|
||||
boolean enabled = true;
|
||||
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
int ap = world.model.player.getReequipCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_unequip_ap, ap);
|
||||
if (ap > 0) {
|
||||
enabled = world.model.player.hasAPs(ap);
|
||||
}
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_unequip);
|
||||
}
|
||||
Intent intent = Dialogs.getIntentForItemInfo(getActivity(), itemType.id, ItemInfoActivity.ItemInfoAction.unequip, text, enabled, inventorySlot);
|
||||
startActivityForResult(intent, INTENTREQUEST_ITEMINFO);
|
||||
}
|
||||
private void showInventoryItemInfo(String itemTypeID) {
|
||||
showInventoryItemInfo(world.itemTypes.getItemType(itemTypeID));
|
||||
}
|
||||
private void showInventoryItemInfo(ItemType itemType) {
|
||||
String text = "";
|
||||
int ap = 0;
|
||||
boolean enabled = true;
|
||||
ItemInfoActivity.ItemInfoAction action = ItemInfoActivity.ItemInfoAction.none;
|
||||
final boolean isInCombat = world.model.uiSelections.isInCombat;
|
||||
if (itemType.isEquippable()) {
|
||||
if (isInCombat) {
|
||||
ap = world.model.player.getReequipCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_equip_ap, ap);
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_equip);
|
||||
}
|
||||
action = ItemInfoActivity.ItemInfoAction.equip;
|
||||
} else if (itemType.isUsable()) {
|
||||
if (isInCombat) {
|
||||
ap = world.model.player.getUseItemCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_use_ap, ap);
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_use);
|
||||
}
|
||||
action = ItemInfoActivity.ItemInfoAction.use;
|
||||
}
|
||||
if (isInCombat && ap > 0) {
|
||||
enabled = world.model.player.hasAPs(ap);
|
||||
}
|
||||
|
||||
Intent intent = Dialogs.getIntentForItemInfo(getActivity(), itemType.id, action, text, enabled, null);
|
||||
startActivityForResult(intent, INTENTREQUEST_ITEMINFO);
|
||||
}
|
||||
|
||||
private void reloadShownCategory(int v) { // Apologies about the code duplication,
|
||||
// just didn't seem to make sense as an array, although I did create a nice array for skill category adapters.
|
||||
|
||||
// Decide which category to show
|
||||
if (v == 0) { //All items
|
||||
inventoryList.setAdapter(inventoryListAdapter);
|
||||
inventoryListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 1) { //Weapon items
|
||||
inventoryWeaponsListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildWeaponItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryWeaponsListAdapter);
|
||||
inventoryWeaponsListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 2) { //Armor items
|
||||
inventoryArmorListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildArmorItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryArmorListAdapter);
|
||||
inventoryArmorListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 3) { //Jewelry items
|
||||
inventoryJewelryListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildJewelryItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryJewelryListAdapter);
|
||||
inventoryJewelryListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 4) { //Potion items
|
||||
inventoryPotionListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildPotionItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryPotionListAdapter);
|
||||
inventoryPotionListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 5) { //Food items
|
||||
inventoryFoodListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildFoodItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryFoodListAdapter);
|
||||
inventoryFoodListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 6) { //Quest items
|
||||
inventoryQuestListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildQuestItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryQuestListAdapter);
|
||||
inventoryQuestListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 7) { //Other items
|
||||
inventoryOtherListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildOtherItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryOtherListAdapter);
|
||||
inventoryOtherListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
//updateItemList();
|
||||
}
|
||||
|
||||
private void reloadShownSort(Inventory inv) {
|
||||
int selected = world.model.uiSelections.selectedInventorySort;
|
||||
|
||||
inventoryListAdapter.reloadShownSort(selected, world.model.uiSelections.oldSortSelection, player.inventory, player);
|
||||
|
||||
// Currently not functional, perhaps because selection only updates when changed.
|
||||
if (world.model.uiSelections.oldSortSelection == selected)
|
||||
world.model.uiSelections.oldSortSelection = 0;
|
||||
else world.model.uiSelections.oldSortSelection = selected;
|
||||
updateItemList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -144,12 +144,16 @@ public final class HeroinfoActivity_Quests extends Fragment {
|
||||
groupList.add(item);
|
||||
|
||||
List<Map<String, ?>> logItemList = new ArrayList<Map<String, ?>>();
|
||||
for (QuestLogEntry e : q.stages) {
|
||||
if (e.logtext.length() <= 0) continue; // Do not show if displaytext is empty.
|
||||
if (player.hasExactQuestProgress(q.questID, e.progress)) {
|
||||
item = new HashMap<String, Object>();
|
||||
item.put(mn_logText, e.logtext);
|
||||
logItemList.add(item);
|
||||
for(Integer progress : player.getQuestProgress(q.questID)) {
|
||||
for(QuestLogEntry e : q.stages) {
|
||||
if (e.progress == progress.intValue()) {
|
||||
if (e.logtext.length() > 0) {
|
||||
item = new HashMap<String, Object>();
|
||||
item.put(mn_logText, e.logtext);
|
||||
logItemList.add(item);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
childList.add(logItemList);
|
||||
@@ -6,10 +6,6 @@ import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -1,131 +1,128 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter;
|
||||
import com.gpl.rpg.AndorsTrail.view.SpinnerEmulator;
|
||||
import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter.OnContainerItemClickedListener;
|
||||
|
||||
public abstract class ShopActivityFragment extends Fragment implements OnContainerItemClickedListener {
|
||||
|
||||
protected static final int INTENTREQUEST_ITEMINFO = 3;
|
||||
protected static final int INTENTREQUEST_BULKSELECT = 9;
|
||||
|
||||
protected WorldContext world;
|
||||
protected Player player;
|
||||
|
||||
protected ItemContainer shopInventory;
|
||||
private TextView shop_gc;
|
||||
private ShopItemContainerAdapter listAdapter;
|
||||
private Button shoplist_sort;
|
||||
|
||||
protected abstract boolean isSellingInterface();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||
if (!app.isInitialized()) return;
|
||||
this.world = app.getWorld();
|
||||
this.player = world.model.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.shoplist, container, false);
|
||||
|
||||
final Monster npc = Dialogs.getMonsterFromIntent(getActivity().getIntent(), world);
|
||||
|
||||
final Resources res = getResources();
|
||||
|
||||
shop_gc = (TextView) v.findViewById(R.id.shop_gc);
|
||||
|
||||
ListView shoplist = (ListView) v.findViewById(R.id.shop_list);
|
||||
|
||||
shopInventory = npc.getShopItems(player);
|
||||
|
||||
HashSet<Integer> iconIDs = world.tileManager.getTileIDsFor(shopInventory);
|
||||
iconIDs.addAll(world.tileManager.getTileIDsFor(player.inventory));
|
||||
TileCollection tiles = world.tileManager.loadTilesFor(iconIDs, res);
|
||||
final boolean isSelling = isSellingInterface();
|
||||
listAdapter = new ShopItemContainerAdapter(getActivity(), tiles, world.tileManager, player, isSelling ? player.inventory : shopInventory, this, isSelling);
|
||||
shoplist.setAdapter(listAdapter);
|
||||
|
||||
//Initiating drop-down list for category filters
|
||||
shoplist_sort = (Button) v.findViewById(R.id.shoplist_sort_filters);
|
||||
new SpinnerEmulator(v, R.id.shoplist_sort_filters, R.array.shoplist_sort_filters, R.string.shop_item_sort) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedShopSort = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownSort(isSelling ? player.inventory : shopInventory);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return world.model.uiSelections.selectedShopSort;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
private void reloadShownSort(ItemContainer itemContainer) {
|
||||
listAdapter.reloadShownSort(world.model.uiSelections.selectedShopSort, itemContainer, player);
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
update();
|
||||
}
|
||||
|
||||
private Toast lastToast = null;
|
||||
protected void displayStoreAction(final String msg) {
|
||||
if (lastToast != null) {
|
||||
lastToast.setText(msg);
|
||||
} else {
|
||||
lastToast = Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT);
|
||||
}
|
||||
lastToast.show();
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
lastToast = null;
|
||||
}
|
||||
|
||||
protected void update() {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
String gc = getResources().getString(R.string.shop_yourgold, player.getGold());
|
||||
shop_gc.setText(gc);
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter;
|
||||
import com.gpl.rpg.AndorsTrail.view.SpinnerEmulator;
|
||||
import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter.OnContainerItemClickedListener;
|
||||
|
||||
public abstract class ShopActivityFragment extends Fragment implements OnContainerItemClickedListener {
|
||||
|
||||
protected static final int INTENTREQUEST_ITEMINFO = 3;
|
||||
protected static final int INTENTREQUEST_BULKSELECT = 9;
|
||||
|
||||
protected WorldContext world;
|
||||
protected Player player;
|
||||
|
||||
protected ItemContainer shopInventory;
|
||||
private TextView shop_gc;
|
||||
private ShopItemContainerAdapter listAdapter;
|
||||
private Button shoplist_sort;
|
||||
|
||||
protected abstract boolean isSellingInterface();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||
if (!app.isInitialized()) return;
|
||||
this.world = app.getWorld();
|
||||
this.player = world.model.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.shoplist, container, false);
|
||||
|
||||
final Monster npc = Dialogs.getMonsterFromIntent(getActivity().getIntent(), world);
|
||||
|
||||
final Resources res = getResources();
|
||||
|
||||
shop_gc = (TextView) v.findViewById(R.id.shop_gc);
|
||||
|
||||
ListView shoplist = (ListView) v.findViewById(R.id.shop_list);
|
||||
|
||||
shopInventory = npc.getShopItems(player);
|
||||
|
||||
HashSet<Integer> iconIDs = world.tileManager.getTileIDsFor(shopInventory);
|
||||
iconIDs.addAll(world.tileManager.getTileIDsFor(player.inventory));
|
||||
TileCollection tiles = world.tileManager.loadTilesFor(iconIDs, res);
|
||||
final boolean isSelling = isSellingInterface();
|
||||
listAdapter = new ShopItemContainerAdapter(getActivity(), tiles, world.tileManager, player, isSelling ? player.inventory : shopInventory, this, isSelling);
|
||||
shoplist.setAdapter(listAdapter);
|
||||
|
||||
//Initiating drop-down list for category filters
|
||||
shoplist_sort = (Button) v.findViewById(R.id.shoplist_sort_filters);
|
||||
new SpinnerEmulator(v, R.id.shoplist_sort_filters, R.array.shoplist_sort_filters, R.string.shop_item_sort) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedShopSort = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownSort(isSelling ? player.inventory : shopInventory);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return world.model.uiSelections.selectedShopSort;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
private void reloadShownSort(ItemContainer itemContainer) {
|
||||
listAdapter.reloadShownSort(world.model.uiSelections.selectedShopSort, itemContainer, player);
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
update();
|
||||
}
|
||||
|
||||
private Toast lastToast = null;
|
||||
protected void displayStoreAction(final String msg) {
|
||||
if (lastToast != null) {
|
||||
lastToast.setText(msg);
|
||||
} else {
|
||||
lastToast = Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT);
|
||||
}
|
||||
lastToast.show();
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
lastToast = null;
|
||||
}
|
||||
|
||||
protected void update() {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
String gc = getResources().getString(R.string.shop_yourgold, player.getGold());
|
||||
shop_gc.setText(gc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,414 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup;
|
||||
import com.gpl.rpg.AndorsTrail.activity.AboutActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LoadSaveActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LoadingActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.Preferences;
|
||||
import com.gpl.rpg.AndorsTrail.activity.StartScreenActivity;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames.FileHeader;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
public class StartScreenActivity_MainMenu extends Fragment {
|
||||
|
||||
private static final int INTENTREQUEST_PREFERENCES = 7;
|
||||
public static final int INTENTREQUEST_LOADGAME = 9;
|
||||
public static final int INTENTREQUEST_EXPORT_SAVE = 11;
|
||||
public static final int INTENTREQUEST_IMPORT_SAVE = 13;
|
||||
|
||||
private boolean hasExistingGame = false;
|
||||
private Button startscreen_continue;
|
||||
private Button startscreen_newgame;
|
||||
private Button startscreen_load;
|
||||
private Button startscreen_import;
|
||||
private Button startscreen_export;
|
||||
private ViewGroup save_preview_holder;
|
||||
private ImageView save_preview_hero_icon;
|
||||
private TextView save_preview_hero_desc;
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
updatePreferences(false);
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
|
||||
if (container != null) {
|
||||
container.removeAllViews();
|
||||
}
|
||||
|
||||
View root = inflater.inflate(R.layout.startscreen_mainmenu, container, false);
|
||||
|
||||
save_preview_holder = (ViewGroup) root.findViewById(R.id.save_preview_holder);
|
||||
save_preview_hero_icon = (ImageView) root.findViewById(R.id.save_preview_hero_icon);
|
||||
save_preview_hero_desc = (TextView) root.findViewById(R.id.save_preview_hero_desc);
|
||||
|
||||
|
||||
startscreen_continue = (Button) root.findViewById(R.id.startscreen_continue);
|
||||
startscreen_continue.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
continueGame(false, Savegames.SLOT_QUICKSAVE, null);
|
||||
}
|
||||
});
|
||||
|
||||
startscreen_newgame = (Button) root.findViewById(R.id.startscreen_newgame);
|
||||
startscreen_newgame.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
if (hasExistingGame) {
|
||||
comfirmNewGame();
|
||||
} else {
|
||||
createNewGame();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Button b = (Button) root.findViewById(R.id.startscreen_about);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
startActivity(new Intent(getActivity(), AboutActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
b = (Button) root.findViewById(R.id.startscreen_preferences);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent intent = new Intent(getActivity(), Preferences.class);
|
||||
StartScreenActivity_MainMenu.this.startActivityForResult(intent, INTENTREQUEST_PREFERENCES);
|
||||
}
|
||||
});
|
||||
|
||||
startscreen_load = (Button) root.findViewById(R.id.startscreen_load);
|
||||
startscreen_load.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||
if (hasExistingGame && app != null && app.getWorld() != null && app.getWorld().model != null
|
||||
&& app.getWorld().model.statistics != null && !app.getWorld().model.statistics.hasUnlimitedSaves()) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(getActivity(),
|
||||
getString(R.string.startscreen_load_game),
|
||||
getResources().getDrawable(android.R.drawable.ic_delete),
|
||||
getString(R.string.startscreen_load_game_confirm),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Dialogs.showLoad(StartScreenActivity_MainMenu.this);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
||||
CustomDialogFactory.show(d);
|
||||
|
||||
} else {
|
||||
Dialogs.showLoad(StartScreenActivity_MainMenu.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (AndorsTrailApplication.DEVELOPMENT_FORCE_STARTNEWGAME) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGRESOURCES) {
|
||||
continueGame(true, 0, "Debug player");
|
||||
} else {
|
||||
continueGame(true, 0, "Player");
|
||||
}
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_FORCE_CONTINUEGAME) {
|
||||
continueGame(false, Savegames.SLOT_QUICKSAVE, null);
|
||||
}
|
||||
|
||||
// if it is a new version we first fire a welcome screen in onResume
|
||||
// and afterwards check the permissions
|
||||
if (!isNewVersion()) {
|
||||
checkAndRequestPermissions(getActivity());
|
||||
migrateDataOnDemand(getActivity());
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
String playerName;
|
||||
String displayInfo = null;
|
||||
int iconID = TileManager.CHAR_HERO;
|
||||
boolean isDead = false;
|
||||
|
||||
FileHeader header = Savegames.quickload(getActivity(), Savegames.SLOT_QUICKSAVE);
|
||||
if (header != null && header.playerName != null) {
|
||||
playerName = header.playerName;
|
||||
displayInfo = header.displayInfo;
|
||||
iconID = header.iconID;
|
||||
isDead = header.isDead;
|
||||
} else {
|
||||
// Before fileversion 14 (v0.6.7), quicksave was stored in Shared preferences
|
||||
SharedPreferences p = getActivity().getSharedPreferences("quicksave", Activity.MODE_PRIVATE);
|
||||
playerName = p.getString("playername", null);
|
||||
if (playerName != null) {
|
||||
displayInfo = "level " + p.getInt("level", -1);
|
||||
}
|
||||
}
|
||||
hasExistingGame = (playerName != null);
|
||||
setButtonState(playerName, displayInfo, iconID, isDead);
|
||||
|
||||
if (isNewVersion()) {
|
||||
Dialogs.showNewVersion(getActivity(), new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
setCurrentVersionForVersionCheck();
|
||||
checkAndRequestPermissions(getActivity());
|
||||
migrateDataOnDemand(getActivity());
|
||||
startscreen_load.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
startscreen_load.setEnabled(true);
|
||||
}
|
||||
|
||||
@TargetApi(29)
|
||||
public void migrateDataOnDemand(final Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
if (activity.getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
if (AndroidStorage.shouldMigrateToInternalStorage(activity.getApplicationContext())) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(activity,
|
||||
getString(R.string.startscreen_migration_title),
|
||||
activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.startscreen_migration_text),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
d.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
startscreen_load.setEnabled(true);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
if (!AndroidStorage.migrateToInternalStorage(activity.getApplicationContext())) {
|
||||
final Dialog errorDlg = CustomDialogFactory.createDialog(activity,
|
||||
getString(R.string.startscreen_migration_title),
|
||||
activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.startscreen_migration_failure),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addDismissButton(errorDlg, android.R.string.ok);
|
||||
d.cancel();
|
||||
CustomDialogFactory.show(errorDlg);
|
||||
}
|
||||
} else {
|
||||
L.log("INFO: No external files or destination folder ist not empty. No data migration.");
|
||||
}
|
||||
} else {
|
||||
L.log("INFO: No read permission on external folder. No data migration.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final int READ_EXTERNAL_STORAGE_REQUEST = 1;
|
||||
private static final int WRITE_EXTERNAL_STORAGE_REQUEST = 2;
|
||||
|
||||
@TargetApi(23)
|
||||
public static void checkAndRequestPermissions(final Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||
if (activity.getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
activity.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, READ_EXTERNAL_STORAGE_REQUEST);
|
||||
}
|
||||
if (activity.getApplicationContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
activity.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_REQUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
listener = (OnNewGameRequestedListener) activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
listener = null;
|
||||
}
|
||||
|
||||
private void setButtonState(final String playerName, final String displayInfo, int iconID, boolean isDead) {
|
||||
startscreen_continue.setEnabled(hasExistingGame && !isDead);
|
||||
startscreen_newgame.setEnabled(true);
|
||||
if (hasExistingGame) {
|
||||
TileManager tm = AndorsTrailApplication.getApplicationFromActivity(getActivity()).getWorld().tileManager;
|
||||
tm.setImageViewTileForPlayer(getResources(), save_preview_hero_icon, iconID);
|
||||
save_preview_hero_desc.setText((isDead ? getString(R.string.rip_startscreen) : "") + playerName + ", " + displayInfo);
|
||||
save_preview_holder.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
save_preview_holder.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void continueGame(boolean createNewCharacter, int loadFromSlot, String name) {
|
||||
final WorldSetup setup = AndorsTrailApplication.getApplicationFromActivity(getActivity()).getWorldSetup();
|
||||
setup.createNewCharacter = createNewCharacter;
|
||||
setup.loadFromSlot = loadFromSlot;
|
||||
setup.newHeroName = name;
|
||||
startActivity(new Intent(getActivity(), LoadingActivity.class));
|
||||
}
|
||||
|
||||
private void comfirmNewGame() {
|
||||
// new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.AndorsTrailStyle_Dialog))
|
||||
// .setTitle(R.string.startscreen_newgame)
|
||||
// .setMessage(R.string.startscreen_newgame_confirm)
|
||||
// .setIcon(android.R.drawable.ic_delete)
|
||||
// .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// //continueGame(true);
|
||||
//// hasExistingGame = false;
|
||||
//// setButtonState(null, null, 0);
|
||||
// createNewGame();
|
||||
// }
|
||||
// })
|
||||
// .setNegativeButton(android.R.string.cancel, null)
|
||||
// .create().show();
|
||||
//
|
||||
//
|
||||
final Dialog d = CustomDialogFactory.createDialog(getActivity(),
|
||||
getString(R.string.startscreen_newgame),
|
||||
getResources().getDrawable(android.R.drawable.ic_delete),
|
||||
getResources().getString(R.string.startscreen_newgame_confirm),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
createNewGame();
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
||||
|
||||
CustomDialogFactory.show(d);
|
||||
|
||||
}
|
||||
|
||||
private static final String versionCheck = "lastversion";
|
||||
|
||||
private boolean isNewVersion() {
|
||||
SharedPreferences s = getActivity().getSharedPreferences(Constants.PREFERENCE_MODEL_LASTRUNVERSION, Activity.MODE_PRIVATE);
|
||||
int lastversion = s.getInt(versionCheck, 0);
|
||||
if (lastversion >= AndorsTrailApplication.CURRENT_VERSION) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setCurrentVersionForVersionCheck() {
|
||||
SharedPreferences s = getActivity().getSharedPreferences(Constants.PREFERENCE_MODEL_LASTRUNVERSION, Activity.MODE_PRIVATE);
|
||||
Editor e = s.edit();
|
||||
e.putInt(versionCheck, AndorsTrailApplication.CURRENT_VERSION);
|
||||
e.commit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case INTENTREQUEST_LOADGAME:
|
||||
if (resultCode != Activity.RESULT_OK) break;
|
||||
final boolean wasImportOrExport = data.getBooleanExtra("import_export", false);
|
||||
final int slot = data.getIntExtra("slot", 1);
|
||||
if (wasImportOrExport) {
|
||||
if(slot == LoadSaveActivity.SLOT_NUMBER_EXPORT_SAVEGAMES)
|
||||
Toast.makeText(getActivity(),R.string.loadsave_export_save_successfull, Toast.LENGTH_LONG).show();
|
||||
else if(slot == LoadSaveActivity.SLOT_NUMBER_IMPORT_SAVEGAMES)
|
||||
Toast.makeText(getActivity(),R.string.loadsave_import_save_successfull, Toast.LENGTH_LONG).show();
|
||||
else if(slot == LoadSaveActivity.SLOT_NUMBER_IMPORT_WORLDMAP)
|
||||
Toast.makeText(getActivity(),R.string.loadsave_import_worldmap_successfull, Toast.LENGTH_LONG).show();
|
||||
|
||||
break;
|
||||
}
|
||||
continueGame(false, slot, null);
|
||||
break;
|
||||
case INTENTREQUEST_PREFERENCES:
|
||||
updatePreferences(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePreferences(boolean alreadyStartedLoadingResources) {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||
AndorsTrailPreferences preferences = app.getPreferences();
|
||||
preferences.read(getActivity());
|
||||
if (app.setLocale(getActivity())) {
|
||||
if (alreadyStartedLoadingResources) {
|
||||
// Changing the locale after having loaded the game requires resources to
|
||||
// be re-loaded. Therefore, we just exit here.
|
||||
Toast.makeText(getActivity(), R.string.change_locale_requires_restart, Toast.LENGTH_LONG).show();
|
||||
doFinish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ThemeHelper.changeTheme(preferences.selectedTheme)) {
|
||||
// Changing the theme requires a restart to re-create all activities.
|
||||
Toast.makeText(getActivity(), R.string.change_theme_requires_restart, Toast.LENGTH_LONG).show();
|
||||
doFinish();
|
||||
return;
|
||||
}
|
||||
app.getWorld().tileManager.updatePreferences(preferences);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void doFinish() {
|
||||
//For Lollipop and above
|
||||
((AndorsTrailApplication) getActivity().getApplication()).discardWorld();
|
||||
getActivity().finish();
|
||||
}
|
||||
|
||||
|
||||
public interface OnNewGameRequestedListener {
|
||||
public void onNewGameRequested();
|
||||
}
|
||||
|
||||
private OnNewGameRequestedListener listener = null;
|
||||
|
||||
private void createNewGame() {
|
||||
if (listener != null) {
|
||||
listener.onNewGameRequested();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.gpl.rpg.AndorsTrail.context;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
@@ -58,4 +59,5 @@ public final class ControllerContext {
|
||||
public Resources getResources() {
|
||||
return app.get().getResources();
|
||||
}
|
||||
public Context getContext() {return app.get().getApplicationContext(); }
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import com.gpl.rpg.AndorsTrail.model.actor.Actor;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.MonsterType;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnHitReceived;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnUse;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
@@ -58,6 +59,9 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
public void exitCombat(boolean pickupLootBags) {
|
||||
setCombatSelection(null, null);
|
||||
world.model.uiSelections.isInCombat = false;
|
||||
if (pickupLootBags) {
|
||||
recordLootInCombatLog();
|
||||
}
|
||||
combatTurnListeners.onCombatEnded();
|
||||
controllers.actorStatsController.setActorMaxAP(world.model.player);
|
||||
world.model.uiSelections.selectedPosition = null;
|
||||
@@ -75,6 +79,31 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
resetCombatState();
|
||||
}
|
||||
|
||||
private void recordLootInCombatLog() {
|
||||
Loot combinedLoot = Loot.combine(killedMonsterBags);
|
||||
if (combinedLoot.gold > 0) {
|
||||
world.model.combatLog.append(controllers.getResources().getString(R.string.dialog_loot_foundgold, combinedLoot.gold));
|
||||
}
|
||||
int itemCount = combinedLoot.items.countItems();
|
||||
if (itemCount > 0) {
|
||||
StringBuilder itemMessage = new StringBuilder();
|
||||
if (itemCount == 1) {
|
||||
itemMessage.append(controllers.getResources().getString(R.string.combat_log_item_single));
|
||||
} else {
|
||||
itemMessage.append(controllers.getResources().getString(R.string.combat_log_item_plural, itemCount));
|
||||
}
|
||||
boolean firstItem = true;
|
||||
for (ItemContainer.ItemEntry entry : combinedLoot.items.items) {
|
||||
if (!firstItem) {
|
||||
itemMessage.append(";");
|
||||
}
|
||||
itemMessage.append(" " + entry.itemType.getName(world.model.player) + " (" + entry.quantity + ")");
|
||||
firstItem = false;
|
||||
}
|
||||
world.model.combatLog.append(itemMessage.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void resetCombatState() {
|
||||
killedMonsterBags.clear();
|
||||
totalExpThisFight = 0;
|
||||
@@ -209,8 +238,9 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
controllers.actorStatsController.addActorAP(player, player.getSkillLevel(SkillCollection.SkillID.cleave) * SkillCollection.PER_SKILLPOINT_INCREASE_CLEAVE_AP);
|
||||
controllers.actorStatsController.addActorHealth(player, player.getSkillLevel(SkillCollection.SkillID.eater) * SkillCollection.PER_SKILLPOINT_INCREASE_EATER_HEALTH);
|
||||
|
||||
world.model.statistics.addMonsterKill(killedMonster.getMonsterTypeID());
|
||||
world.model.statistics.addMonsterKill(killedMonster.monsterType);
|
||||
controllers.actorStatsController.addExperience(loot.exp);
|
||||
world.model.combatLog.append(controllers.getResources().getString(R.string.dialog_monsterloot_gainedexp, loot.exp));
|
||||
|
||||
totalExpThisFight += loot.exp;
|
||||
loot.exp = 0;
|
||||
@@ -240,7 +270,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean playerHasApLeft() {
|
||||
public boolean playerHasApLeft() {
|
||||
final Player player = world.model.player;
|
||||
if (player.hasAPs(player.getUseItemCost())) return true;
|
||||
if (player.hasAPs(player.getAttackCost())) return true;
|
||||
@@ -23,10 +23,11 @@ public final class Constants {
|
||||
public static final long MINIMUM_INPUT_INTERVAL_STD = 200;
|
||||
//TODO restore final modifier before release
|
||||
public static long MINIMUM_INPUT_INTERVAL = AndorsTrailApplication.DEVELOPMENT_FASTSPEED ? MINIMUM_INPUT_INTERVAL_FAST : MINIMUM_INPUT_INTERVAL_STD;
|
||||
public static final int MAX_MAP_WIDTH = 33;
|
||||
public static final int MAX_MAP_HEIGHT = 33;
|
||||
public static final int MAX_MAP_WIDTH = 46;
|
||||
public static final int MAX_MAP_HEIGHT = 46;
|
||||
|
||||
public static final int MONSTER_MOVEMENT_TURN_DURATION_MS = 1200;
|
||||
public static final int MONSTER_IMMOBILE_MOVE_COST = 999;
|
||||
|
||||
public static final int TICK_DELAY = 500;
|
||||
private static final int ROUND_DURATION = 6000;
|
||||
@@ -48,10 +49,15 @@ public final class Constants {
|
||||
public static final String FILENAME_SAVEGAME_FILENAME_PREFIX = "savegame";
|
||||
public static final String PLACEHOLDER_PLAYERNAME = "$playername";
|
||||
public static final String CHEAT_DETECTION_FOLDER = "dEAGyGE3YojqXjI3x4x7";
|
||||
public static final String PASSIVE_ACHIEVEMENT_CHECK_PHRASE = "passive_achievement_check";
|
||||
|
||||
public static final String SAVEGAME_FILE_MIME_TYPE = "application/octet-stream";
|
||||
public static final String WORLDMAP_FILE_MIME_TYPE = "image/png";
|
||||
public static final String NO_FILE_EXTENSION_MIME_TYPE = "application/no_file_extension_mime_type";
|
||||
|
||||
public static final Random rnd = new Random();
|
||||
public static int rollValue(final ConstRange r) { return rollValue(r.max, r.current); }
|
||||
public static int rollValue(final ConstRange r, int bias) { return rollValue(r.max, r.current + bias); }
|
||||
public static int rollValue(final ConstRange r, int bias) { return rollValue((r.max + 1) * 100 -1, r.current * 100 + bias)/100; }
|
||||
public static int rollValue(final Range r) { return rollValue(r.max, r.current); }
|
||||
private static int rollValue(final int max, final int min) {
|
||||
if (max <= min) return max;
|
||||
@@ -59,7 +65,7 @@ public final class Constants {
|
||||
}
|
||||
public static boolean roll100(final int chance) { return rollResult(100, chance); }
|
||||
public static boolean rollResult(final ConstRange r) { return rollResult(r.max, r.current); }
|
||||
public static boolean rollResult(final ConstRange r, int bias) { return rollResult(r.max, r.current + bias); }
|
||||
public static boolean rollResult(final ConstRange r, int bias) { return rollResult(r.max * 100, r.current * 100 + bias); }
|
||||
public static boolean rollResult(final Range r) { return rollResult(r.max, r.current); }
|
||||
private static boolean rollResult(final int probabilityMax, final int probabilityValue) { return rnd.nextInt(probabilityMax) < probabilityValue; }
|
||||
}
|
||||
@@ -393,18 +393,24 @@ public final class ConversationController {
|
||||
}
|
||||
|
||||
public void proceedToPhrase(final Resources res, String phraseID, boolean applyScriptEffects, boolean displayPhraseMessage) {
|
||||
while (phraseID != null) {
|
||||
phraseID = proceedToPhraseInternal(res, phraseID, applyScriptEffects, displayPhraseMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private String proceedToPhraseInternal(final Resources res, String phraseID, boolean applyScriptEffects, boolean displayPhraseMessage) {
|
||||
if (phraseID.equalsIgnoreCase(ConversationCollection.PHRASE_CLOSE)) {
|
||||
listener.onConversationEnded();
|
||||
return;
|
||||
return null;
|
||||
} else if (phraseID.equalsIgnoreCase(ConversationCollection.PHRASE_SHOP)) {
|
||||
listener.onConversationEndedWithShop(npc);
|
||||
return;
|
||||
return null;
|
||||
} else if (phraseID.equalsIgnoreCase(ConversationCollection.PHRASE_ATTACK)) {
|
||||
endConversationWithCombat();
|
||||
return;
|
||||
return null;
|
||||
} else if (phraseID.equalsIgnoreCase(ConversationCollection.PHRASE_REMOVE)) {
|
||||
endConversationWithRemovingNPC();
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
setCurrentPhrase(res, phraseID);
|
||||
@@ -420,8 +426,7 @@ public final class ConversationController {
|
||||
for (Reply r : currentPhrase.replies) {
|
||||
if (!canSelectReply(world, r)) continue;
|
||||
applyReplyEffect(world, r, controllers);
|
||||
proceedToPhrase(res, r.nextPhrase, applyScriptEffects, displayPhraseMessage);
|
||||
return;
|
||||
return r.nextPhrase;
|
||||
}
|
||||
} else if (displayPhraseMessage) {
|
||||
String message = getDisplayMessage(currentPhrase, player);
|
||||
@@ -430,13 +435,14 @@ public final class ConversationController {
|
||||
|
||||
if (hasOnlyOneNextReply()) {
|
||||
listener.onConversationCanProceedWithNext();
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Reply r : currentPhrase.replies) {
|
||||
if (!canSelectReply(world, r)) continue;
|
||||
listener.onConversationHasReply(r, getDisplayMessage(r, player));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void endConversationWithRemovingNPC() {
|
||||
@@ -0,0 +1,333 @@
|
||||
package com.gpl.rpg.AndorsTrail.controller;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnLongClickListener;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.activity.HeroinfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
public final class InputController implements OnClickListener, OnLongClickListener{
|
||||
private final ControllerContext controllers;
|
||||
private final WorldContext world;
|
||||
|
||||
private final Coord lastTouchPosition_tileCoords = new Coord();
|
||||
private int lastTouchPosition_dx = 0;
|
||||
private int lastTouchPosition_dy = 0;
|
||||
private long lastTouchEventTime = 0;
|
||||
private boolean isDpadActive = false;
|
||||
|
||||
private int keyState_dx = 0;
|
||||
private int keyState_dy = 0;
|
||||
private boolean keyState_attack = false;
|
||||
private boolean keyState_flee = false;
|
||||
private boolean keyState_endturn = false;
|
||||
|
||||
final private int KEY_UNHANDLED = 0; // Default, for unhandled keycodes
|
||||
final private int KEY_MOVE_UP = 1;
|
||||
final private int KEY_MOVE_DOWN = 2;
|
||||
final private int KEY_MOVE_LEFT = 3;
|
||||
final private int KEY_MOVE_RIGHT = 4;
|
||||
final private int KEY_MOVE_UP_LEFT = 5;
|
||||
final private int KEY_MOVE_UP_RIGHT = 6;
|
||||
final private int KEY_MOVE_DOWN_LEFT = 7;
|
||||
final private int KEY_MOVE_DOWN_RIGHT = 8;
|
||||
final private int KEY_ATTACK = 9;
|
||||
final private int KEY_FLEE = 10;
|
||||
final private int KEY_END_TURN = 11;
|
||||
final private int KEY_HERO_INFO = 12;
|
||||
final private int KEY_TOOLBOX = 13;
|
||||
|
||||
private SparseIntArray keyMap = new SparseIntArray(); // Android keycode to internal key event mapping. TODO: Configure via preferences
|
||||
|
||||
public InputController(ControllerContext controllers, WorldContext world) {
|
||||
this.controllers = controllers;
|
||||
this.world = world;
|
||||
initializeKeyMap();
|
||||
|
||||
}
|
||||
|
||||
/* New keyboard handler. Both Key Down and Key Up events handled here to allow conditional behaviours.
|
||||
On 4-way dpad controllers, cursor keys, and WASD, diagonals are generated by chording two keys.
|
||||
Single-key diagonals are supported on numeric keypad and 8-way dpads (not seen/tested in the wild).
|
||||
|
||||
Because two-key combos initially generate a ordinal movement (one key comes in first), which can
|
||||
be dangerous in tight spaces, modifiers are provided to "lock" the input until both keys are down.
|
||||
TODO: Use delay timer to enable chorded diagonals on first move without locking kludge?
|
||||
*/
|
||||
|
||||
// Map key codes to spectic internal actions
|
||||
// TODO: Move mapping out of code to JSON/XML file, or maybe player prefs
|
||||
private void initializeKeyMap() {
|
||||
int key;
|
||||
|
||||
// Keys mapping to UP
|
||||
key = KEY_MOVE_UP;
|
||||
keyMap.put(KeyEvent.KEYCODE_DPAD_UP, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_8, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_8, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_W, key);
|
||||
|
||||
// Keys mapping to DOWN
|
||||
key = KEY_MOVE_DOWN;
|
||||
keyMap.put(KeyEvent.KEYCODE_DPAD_DOWN, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_2, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_2, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_S, key);
|
||||
|
||||
// Keys mapping to LEFT
|
||||
key = KEY_MOVE_LEFT;
|
||||
keyMap.put(KeyEvent.KEYCODE_DPAD_LEFT, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_4, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_4, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_A, key);
|
||||
|
||||
// Keys mapping to RIGHT
|
||||
key = KEY_MOVE_RIGHT;
|
||||
keyMap.put(KeyEvent.KEYCODE_DPAD_RIGHT, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_6, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_6, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_D, key);
|
||||
|
||||
// Keys mapping to UP_LEFT
|
||||
key = KEY_MOVE_UP_LEFT;
|
||||
keyMap.put(KeyEvent.KEYCODE_DPAD_UP_LEFT, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_7, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_7, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_MOVE_HOME, key);
|
||||
|
||||
// Keys mapping to UP_RIGHT
|
||||
key = KEY_MOVE_UP_RIGHT;
|
||||
keyMap.put(KeyEvent.KEYCODE_DPAD_UP_RIGHT, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_9, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_9, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_PAGE_UP, key);
|
||||
|
||||
// Keys mapping to DOWN_LEFT
|
||||
key = KEY_MOVE_DOWN_LEFT;
|
||||
keyMap.put(KeyEvent.KEYCODE_DPAD_DOWN_LEFT, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_1, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_1, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_MOVE_END, key);
|
||||
|
||||
// Keys mapping to DOWN_RIGHT
|
||||
key = KEY_MOVE_DOWN_RIGHT;
|
||||
keyMap.put(KeyEvent.KEYCODE_DPAD_DOWN_RIGHT, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_3, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_3, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_PAGE_DOWN, key);
|
||||
|
||||
// Keys mapping to ATTACK
|
||||
key = KEY_ATTACK;
|
||||
keyMap.put(KeyEvent.KEYCODE_DPAD_CENTER, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_BUTTON_A, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_SPACE, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_5, key);
|
||||
|
||||
// Keys mapping to FLEE
|
||||
key = KEY_FLEE;
|
||||
keyMap.put(KeyEvent.KEYCODE_BUTTON_X, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_F, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_ENTER, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_ENTER, key);
|
||||
|
||||
// Keys mapping to END_TURN
|
||||
key = KEY_END_TURN;
|
||||
keyMap.put(KeyEvent.KEYCODE_BUTTON_Y, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_E, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_FORWARD_DEL, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_DOT, key);
|
||||
|
||||
// Keys mapping to HERO_INFO
|
||||
key = KEY_HERO_INFO;
|
||||
//keyMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_BUTTON_L1, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUM_LOCK, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_C, key);
|
||||
|
||||
// Keys mapping to TOOLBOX
|
||||
key = KEY_TOOLBOX;
|
||||
keyMap.put(KeyEvent.KEYCODE_BUTTON_R1, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_DIVIDE, key);
|
||||
keyMap.put(KeyEvent.KEYCODE_B, key);
|
||||
}
|
||||
|
||||
// Generate game actions based on mapped keys
|
||||
public boolean onKeyboardAction(Context context, KeyEvent event, boolean acceptInput) {
|
||||
//L.log("onKeyboardAction(): Processing action " + event.getAction() + " for keyCode " + event.getKeyCode());
|
||||
|
||||
if (event.getAction() != KeyEvent.ACTION_DOWN && event.getAction() != KeyEvent.ACTION_UP) return false; // don't handle other actions
|
||||
boolean keydown = (event.getAction() == KeyEvent.ACTION_DOWN);
|
||||
boolean inihbit = (keyState_attack || keyState_flee); // used to inhibit movement if an action key is held down
|
||||
|
||||
switch (keyMap.get(event.getKeyCode())) {
|
||||
|
||||
// Ordinal directional keys - only modify one direction register; registers are combined when
|
||||
// keys used simultaneously to create synthetic diagonals
|
||||
case KEY_MOVE_UP:
|
||||
keyState_dy = keydown ? -1 : 0;
|
||||
if (acceptInput && !inihbit) onRelativeMovement(keyState_dx, keyState_dy);
|
||||
break;
|
||||
case KEY_MOVE_DOWN:
|
||||
keyState_dy = keydown ? 1 : 0;
|
||||
if (acceptInput && !inihbit) onRelativeMovement(keyState_dx, keyState_dy);
|
||||
break;
|
||||
case KEY_MOVE_LEFT:
|
||||
keyState_dx = keydown ? -1 : 0;
|
||||
if (acceptInput && !inihbit) onRelativeMovement(keyState_dx, keyState_dy);
|
||||
break;
|
||||
case KEY_MOVE_RIGHT:
|
||||
keyState_dx = keydown ? 1 : 0;
|
||||
if (acceptInput && !inihbit) onRelativeMovement(keyState_dx, keyState_dy);
|
||||
break;
|
||||
|
||||
// Diagonal directional keys. Modify both direction registers, can't be combined
|
||||
// TODO: store individual key position to allow combinations. May not be worth the trouble.
|
||||
case KEY_MOVE_UP_LEFT:
|
||||
keyState_dx = keydown ? -1 : 0;
|
||||
keyState_dy = keydown ? -1 : 0;
|
||||
if (acceptInput && !inihbit) onRelativeMovement(keyState_dx, keyState_dy);
|
||||
break;
|
||||
case KEY_MOVE_UP_RIGHT:
|
||||
keyState_dx = keydown ? 1 : 0;
|
||||
keyState_dy = keydown ? -1 : 0;
|
||||
if (acceptInput && !inihbit) onRelativeMovement(keyState_dx, keyState_dy);
|
||||
break;
|
||||
case KEY_MOVE_DOWN_LEFT:
|
||||
keyState_dx = keydown ? -1 : 0;
|
||||
keyState_dy = keydown ? 1 : 0;
|
||||
if (acceptInput && !inihbit) onRelativeMovement(keyState_dx, keyState_dy);
|
||||
break;
|
||||
case KEY_MOVE_DOWN_RIGHT:
|
||||
keyState_dx = keydown ? 1 : 0;
|
||||
keyState_dy = keydown ? 1 : 0;
|
||||
if (acceptInput && !inihbit) onRelativeMovement(keyState_dx, keyState_dy);
|
||||
break;
|
||||
|
||||
// Special key handling below - some combat/movement stuff done here because it's too
|
||||
// specific for logic in onRelativeMovement
|
||||
|
||||
// "Attack" shortcut - freeze movement to allow chorded direction when key is released.
|
||||
// if in combat, executes an attack on key release
|
||||
case KEY_ATTACK:
|
||||
if (keydown && !keyState_attack) { // key pressed - pause any movement
|
||||
if(!world.model.uiSelections.isInCombat) controllers.movementController.stopMovement();
|
||||
} else if (!keydown && keyState_attack) { // key released - execute attack / move in direction
|
||||
if (acceptInput) onRelativeMovement(keyState_dx, keyState_dy);
|
||||
}
|
||||
keyState_attack = keydown;
|
||||
break;
|
||||
|
||||
// "Flee" shortcut. Intitiates flee when pressed. If a direction is held, moves in chosen direction when released
|
||||
case KEY_FLEE:
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
if (keydown && !keyState_flee) { // button pressed - set flee; movement locked while pressed
|
||||
if(acceptInput) controllers.combatController.startFlee();
|
||||
} else if (!keydown && keyState_flee) { // button released - move flee direction, if held
|
||||
// We need to do a special call because the movement key may already be down, and if the device
|
||||
// doesn't generate repeat keystrokes, this handler won't get another event
|
||||
if ((keyState_dx != 0 || keyState_dy != 0) && allowInputInterval()) {
|
||||
if(acceptInput) controllers.combatController.executeMoveAttack(keyState_dx, keyState_dy);
|
||||
}
|
||||
}
|
||||
}
|
||||
keyState_flee = keydown;
|
||||
break;
|
||||
|
||||
// "End Turn" shortcut. Flag prevents repeated end turn if key is held down.
|
||||
case KEY_END_TURN:
|
||||
if (acceptInput && keydown && !keyState_endturn) {
|
||||
if (world.model.uiSelections.isInCombat) controllers.combatController.endPlayerTurn();
|
||||
}
|
||||
keyState_endturn = keydown;
|
||||
break;
|
||||
|
||||
// "Hero Info" screen shortcut. New activity takes focus, so we don't need to worry about repeats.
|
||||
case KEY_HERO_INFO:
|
||||
if (acceptInput && keydown) context.startActivity(new Intent(context, HeroinfoActivity.class));
|
||||
break;
|
||||
|
||||
case KEY_TOOLBOX:
|
||||
// ??? ToolboxView toolboxview = context.getApplicationContext(). findViewById(R.id.main_toolboxview);
|
||||
|
||||
break;
|
||||
|
||||
case KEY_UNHANDLED: // Unhandled keycode
|
||||
return false;
|
||||
|
||||
default: // unhandled keymap code entry (should not happen)
|
||||
L.log("onKeyboardAction(): Unhandled keyMap code constant " + keyMap.get(event.getKeyCode()) + " for keyCode " + event.getKeyCode());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onRelativeMovement(int dx, int dy) {
|
||||
//L.log("onRelativeMovement(): dx=" + dx + " dy=" + dy + " combat: " + world.model.uiSelections.isInCombat);
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
if (allowInputInterval()) controllers.combatController.executeMoveAttack(dx, dy);
|
||||
} else if (dx == 0 && dy == 0) {
|
||||
controllers.movementController.stopMovement();
|
||||
} else {
|
||||
controllers.movementController.startMovement(dx, dy, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void onKeyboardCancel() {
|
||||
controllers.movementController.stopMovement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
if (!world.model.uiSelections.isInCombat) return;
|
||||
onRelativeMovement(lastTouchPosition_dx, lastTouchPosition_dy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View arg0) {
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
//TODO: Should be able to mark positions far away (mapwalk / ranged combat)
|
||||
if (lastTouchPosition_dx == 0 && lastTouchPosition_dy == 0) return false;
|
||||
if (Math.abs(lastTouchPosition_dx) > 1) return false;
|
||||
if (Math.abs(lastTouchPosition_dy) > 1) return false;
|
||||
|
||||
controllers.combatController.setCombatSelection(lastTouchPosition_tileCoords);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean allowInputInterval() {
|
||||
final long now = System.currentTimeMillis();
|
||||
if ((now - lastTouchEventTime) < Constants.MINIMUM_INPUT_INTERVAL) return false;
|
||||
lastTouchEventTime = now;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setDpadActive(boolean isDpadActive) {
|
||||
this.isDpadActive = isDpadActive;
|
||||
}
|
||||
|
||||
public void onTouchCancel() {
|
||||
controllers.movementController.stopMovement();
|
||||
}
|
||||
|
||||
public boolean onTouchedTile(int tile_x, int tile_y) {
|
||||
lastTouchPosition_tileCoords.set(tile_x, tile_y);
|
||||
lastTouchPosition_dx = tile_x - world.model.player.position.x;
|
||||
lastTouchPosition_dy = tile_y - world.model.player.position.y;
|
||||
|
||||
if (world.model.uiSelections.isInCombat || isDpadActive) return false;
|
||||
|
||||
controllers.movementController.startMovement(lastTouchPosition_dx, lastTouchPosition_dy, lastTouchPosition_tileCoords);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,429 +1,446 @@
|
||||
package com.gpl.rpg.AndorsTrail.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.QuickSlotListeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.traits.AbilityModifierTraits;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer.ItemEntry;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnHitReceived;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnUse;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
|
||||
import static java.lang.Math.min;
|
||||
|
||||
public final class ItemController {
|
||||
|
||||
private final ControllerContext controllers;
|
||||
private final WorldContext world;
|
||||
public final QuickSlotListeners quickSlotListeners = new QuickSlotListeners();
|
||||
|
||||
public ItemController(ControllerContext controllers, WorldContext world) {
|
||||
this.controllers = controllers;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public void dropItem(ItemType type, int quantity) {
|
||||
if (world.model.player.inventory.getItemQuantity(type.id) < quantity) return;
|
||||
world.model.player.inventory.removeItem(type.id, quantity);
|
||||
world.model.currentMaps.map.itemDropped(type, quantity, world.model.player.position);
|
||||
}
|
||||
|
||||
public void equipItem(ItemType type, Inventory.WearSlot slot) {
|
||||
if (!type.isEquippable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getReequipCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
if (!player.inventory.removeItem(type.id, 1)) return;
|
||||
|
||||
unequipSlot(player, slot);
|
||||
if (type.isTwohandWeapon()) unequipSlot(player, Inventory.WearSlot.shield);
|
||||
else if (slot == Inventory.WearSlot.shield) {
|
||||
ItemType currentWeapon = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (currentWeapon != null && currentWeapon.isTwohandWeapon()) unequipSlot(player, Inventory.WearSlot.weapon);
|
||||
}
|
||||
|
||||
player.inventory.setItemTypeInWearSlot(slot, type);
|
||||
controllers.actorStatsController.addConditionsFromEquippedItem(player, type);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
}
|
||||
|
||||
public void unequipSlot(ItemType type, Inventory.WearSlot slot) {
|
||||
if (!type.isEquippable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (player.inventory.isEmptySlot(slot)) return;
|
||||
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getReequipCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
unequipSlot(player, slot);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
}
|
||||
|
||||
private void unequipSlot(Player player, Inventory.WearSlot slot) {
|
||||
ItemType removedItemType = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (removedItemType == null) return;
|
||||
player.inventory.addItem(removedItemType);
|
||||
player.inventory.setItemTypeInWearSlot(slot, null);
|
||||
controllers.actorStatsController.removeConditionsFromUnequippedItem(player, removedItemType);
|
||||
}
|
||||
|
||||
public void useItem(ItemType type) {
|
||||
if (!type.isUsable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getUseItemCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
if (!player.inventory.removeItem(type.id, 1)) return;
|
||||
|
||||
controllers.actorStatsController.applyUseEffect(player, null, type.effects_use);
|
||||
world.model.statistics.addItemUsage(type);
|
||||
|
||||
//TODO: provide feedback that the item has been used.
|
||||
//context.mainActivity.message(androidContext.getResources().getString(R.string.inventory_item_used, type.name));
|
||||
}
|
||||
|
||||
public void playerSteppedOnLootBag(Loot loot) {
|
||||
if (pickupLootBagWithoutConfirmation(loot)) {
|
||||
controllers.mapController.worldEventListeners.onPlayerPickedUpGroundLoot(loot);
|
||||
pickupAll(loot);
|
||||
removeLootBagIfEmpty(loot);
|
||||
} else {
|
||||
controllers.mapController.worldEventListeners.onPlayerSteppedOnGroundLoot(loot);
|
||||
consumeNonItemLoot(loot);
|
||||
}
|
||||
}
|
||||
|
||||
public void lootMonsterBags(Collection<Loot> killedMonsterBags, int totalExpThisFight) {
|
||||
if (pickupLootBagsWithoutConfirmation(killedMonsterBags)) {
|
||||
controllers.mapController.worldEventListeners.onPlayerPickedUpMonsterLoot(killedMonsterBags, totalExpThisFight);
|
||||
pickupAll(killedMonsterBags);
|
||||
removeLootBagIfEmpty(killedMonsterBags);
|
||||
controllers.gameRoundController.resume();
|
||||
} else {
|
||||
controllers.mapController.worldEventListeners.onPlayerFoundMonsterLoot(killedMonsterBags, totalExpThisFight);
|
||||
consumeNonItemLoot(killedMonsterBags);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean pickupLootBagWithoutConfirmation(Loot bag) {
|
||||
if (bag.isContainer()) return false;
|
||||
switch (controllers.preferences.displayLoot) {
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS:
|
||||
return false;
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS:
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST:
|
||||
if (bag.hasItems()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean pickupLootBagsWithoutConfirmation(Collection<Loot> bags) {
|
||||
if (controllers.preferences.displayLoot == AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS) return false;
|
||||
for (Loot bag : bags) {
|
||||
if (!pickupLootBagWithoutConfirmation(bag)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void applyInventoryEffects(Player player) {
|
||||
ItemType weapon = getMainWeapon(player);
|
||||
if (weapon != null) {
|
||||
player.attackCost = 0;
|
||||
player.criticalMultiplier = weapon.effects_equip.stats.setCriticalMultiplier;
|
||||
}
|
||||
|
||||
applyInventoryEffects(player, Inventory.WearSlot.weapon);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.shield);
|
||||
SkillController.applySkillEffectsFromFightingStyles(player);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.head);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.body);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.hand);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.feet);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.neck);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.leftring);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.rightring);
|
||||
SkillController.applySkillEffectsFromItemProficiencies(player);
|
||||
}
|
||||
public static ItemType getMainWeapon(Player player) {
|
||||
ItemType itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (itemType != null) return itemType;
|
||||
itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.shield);
|
||||
if (itemType != null && itemType.isWeapon()) return itemType;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void applyInventoryEffects(Player player, Inventory.WearSlot slot) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type == null) return;
|
||||
if (slot == Inventory.WearSlot.shield) {
|
||||
ItemType mainHandItem = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
// The stats for off-hand weapons will be added later in SkillController.applySkillEffectsFromFightingStyles
|
||||
if (SkillController.isDualWielding(mainHandItem, type)) return;
|
||||
}
|
||||
if (type.effects_equip != null && type.effects_equip.stats != null) {
|
||||
controllers.actorStatsController.applyAbilityEffects(player, type.effects_equip.stats, 1);
|
||||
if (type.isWeapon()) {
|
||||
controllers.actorStatsController.addPlayerWeaponDamage(player, type.effects_equip.stats.increaseMinDamage, type.effects_equip.stats.increaseMaxDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void recalculateHitEffectsFromWornItems(Player player) {
|
||||
ArrayList<ItemTraits_OnUse> effects_onHit = null;
|
||||
ArrayList<ItemTraits_OnHitReceived> effects_onHitReceived = null;
|
||||
for (Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type == null) continue;
|
||||
ItemTraits_OnUse eh = type.effects_hit;
|
||||
ItemTraits_OnHitReceived ehr = type.effects_hitReceived;
|
||||
if (eh == null && ehr == null) continue;
|
||||
|
||||
if (effects_onHit == null) effects_onHit = new ArrayList<ItemTraits_OnUse>();
|
||||
if (eh != null) effects_onHit.add(eh);
|
||||
|
||||
if (effects_onHitReceived == null) effects_onHitReceived = new ArrayList<ItemTraits_OnHitReceived>();
|
||||
if (ehr != null) effects_onHitReceived.add(ehr);
|
||||
}
|
||||
|
||||
if (effects_onHit != null) {
|
||||
ItemTraits_OnUse[] effects_ = new ItemTraits_OnUse[effects_onHit.size()];
|
||||
effects_ = effects_onHit.toArray(effects_);
|
||||
player.onHitEffects = effects_;
|
||||
} else {
|
||||
player.onHitEffects = null;
|
||||
}
|
||||
|
||||
if (effects_onHitReceived != null) {
|
||||
ItemTraits_OnHitReceived[] effects_ = new ItemTraits_OnHitReceived[effects_onHitReceived.size()];
|
||||
effects_ = effects_onHitReceived.toArray(effects_);
|
||||
player.onHitReceivedEffects = effects_;
|
||||
} else {
|
||||
player.onHitReceivedEffects = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void consumeNonItemLoot(Loot loot) {
|
||||
// Experience will be given as soon as the monster is killed.
|
||||
world.model.player.inventory.gold += loot.gold;
|
||||
loot.gold = 0;
|
||||
removeLootBagIfEmpty(loot);
|
||||
}
|
||||
public void consumeNonItemLoot(Iterable<Loot> lootBags) {
|
||||
for(Loot l : lootBags) {
|
||||
consumeNonItemLoot(l);
|
||||
}
|
||||
}
|
||||
|
||||
public void pickupAll(Loot loot) {
|
||||
world.model.player.inventory.add(loot.items);
|
||||
consumeNonItemLoot(loot);
|
||||
checkQuickslotItemLooted(loot.items);
|
||||
loot.clear();
|
||||
}
|
||||
public void pickupAll(Iterable<Loot> lootBags) {
|
||||
for(Loot l : lootBags) {
|
||||
pickupAll(l);
|
||||
}
|
||||
}
|
||||
public boolean removeLootBagIfEmpty(final Loot loot) {
|
||||
if (loot.hasItemsOrGold()) return false;
|
||||
|
||||
world.model.currentMaps.map.removeGroundLoot(loot);
|
||||
controllers.mapController.mapLayoutListeners.onLootBagRemoved(world.model.currentMaps.map, loot.position);
|
||||
return true; // The bag was removed.
|
||||
}
|
||||
|
||||
public boolean removeLootBagIfEmpty(final Iterable<Loot> lootBags) {
|
||||
boolean isEmpty = true;
|
||||
for (Loot l : lootBags) {
|
||||
if (!removeLootBagIfEmpty(l)) isEmpty = false;
|
||||
}
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
private static int getMarketPriceFactor(Player player) {
|
||||
return Constants.MARKET_PRICEFACTOR_PERCENT
|
||||
- player.getSkillLevel(SkillCollection.SkillID.barter) * SkillCollection.PER_SKILLPOINT_INCREASE_BARTER_PRICEFACTOR_PERCENTAGE;
|
||||
}
|
||||
public static int getBuyingPrice(Player player, ItemType itemType) {
|
||||
return itemType.baseMarketCost + itemType.baseMarketCost * getMarketPriceFactor(player) / 100;
|
||||
}
|
||||
public static int getSellingPrice(Player player, ItemType itemType) {
|
||||
return itemType.baseMarketCost - itemType.baseMarketCost * getMarketPriceFactor(player) / 100;
|
||||
}
|
||||
|
||||
public static boolean canAfford(Player player, ItemType itemType) {
|
||||
return player.inventory.gold >= getBuyingPrice(player, itemType);
|
||||
}
|
||||
public static boolean canAfford(Player player, int price) {
|
||||
return player.inventory.gold >= price;
|
||||
}
|
||||
public static boolean maySellItem(Player player, ItemType itemType) {
|
||||
if (!itemType.isSellable()) return false;
|
||||
return true;
|
||||
}
|
||||
public static boolean sell(Player player, ItemType itemType, ItemContainer merchant, int quantity) {
|
||||
int price = getSellingPrice(player, itemType) * quantity;
|
||||
if (!maySellItem(player, itemType)) return false;
|
||||
if (!player.inventory.removeItem(itemType.id, quantity)) return false;
|
||||
player.inventory.gold += price;
|
||||
merchant.addItem(itemType, quantity);
|
||||
return true;
|
||||
}
|
||||
public static boolean buy(ModelContainer model, Player player, ItemType itemType, ItemContainer merchant, int quantity) {
|
||||
int price = getBuyingPrice(player, itemType) * quantity;
|
||||
if (!canAfford(player, price)) return false;
|
||||
if (!merchant.removeItem(itemType.id, quantity)) return false;
|
||||
player.inventory.gold -= price;
|
||||
player.inventory.addItem(itemType, quantity);
|
||||
model.statistics.addGoldSpent(price);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static String describeItemForListView(ItemEntry item, Player player) {
|
||||
StringBuilder sb = new StringBuilder(item.itemType.getName(player));
|
||||
if (item.quantity > 1) {
|
||||
sb.append(" (");
|
||||
sb.append(item.quantity);
|
||||
sb.append(')');
|
||||
}
|
||||
if (item.itemType.effects_equip != null) {
|
||||
AbilityModifierTraits t = item.itemType.effects_equip.stats;
|
||||
if (t != null) {
|
||||
if (t.increaseAttackChance != 0
|
||||
|| t.increaseMinDamage != 0
|
||||
|| t.increaseMaxDamage != 0
|
||||
|| t.increaseCriticalSkill != 0
|
||||
|| t.setCriticalMultiplier != 0) {
|
||||
sb.append(" [");
|
||||
describeAttackEffect(t.increaseAttackChance, t.increaseMinDamage, t.increaseMaxDamage, t.increaseCriticalSkill, t.setCriticalMultiplier, sb);
|
||||
sb.append(']');
|
||||
}
|
||||
if (t.increaseBlockChance != 0
|
||||
|| t.increaseDamageResistance != 0) {
|
||||
sb.append(" [");
|
||||
describeBlockEffect(t.increaseBlockChance, t.increaseDamageResistance, sb);
|
||||
sb.append(']');
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void describeAttackEffect(int attackChance, int minDamage, int maxDamage, int criticalSkill, float criticalMultiplier, StringBuilder sb) {
|
||||
boolean addSpace = false;
|
||||
if (attackChance != 0) {
|
||||
sb.append(attackChance);
|
||||
addSpace = true;
|
||||
}
|
||||
if (minDamage != 0 || maxDamage != 0) {
|
||||
if (addSpace) sb.append(' ');
|
||||
sb.append(minDamage);
|
||||
if (minDamage != maxDamage) {
|
||||
sb.append('-');
|
||||
sb.append(maxDamage);
|
||||
}
|
||||
addSpace = true;
|
||||
}
|
||||
if (criticalSkill != 0) {
|
||||
if (addSpace) sb.append(' ');
|
||||
if (criticalSkill >= 0) {
|
||||
sb.append('+');
|
||||
}
|
||||
sb.append(criticalSkill);
|
||||
}
|
||||
if (criticalMultiplier != 0 && criticalMultiplier != 1) {
|
||||
sb.append('x');
|
||||
sb.append(criticalMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
public static void describeBlockEffect(int blockChance, int damageResistance, StringBuilder sb) {
|
||||
if (blockChance != 0) {
|
||||
sb.append(blockChance);
|
||||
}
|
||||
if (damageResistance != 0) {
|
||||
sb.append('/');
|
||||
sb.append(damageResistance);
|
||||
}
|
||||
}
|
||||
|
||||
public void quickitemUse(int quickSlotId) {
|
||||
useItem(world.model.player.inventory.quickitem[quickSlotId]);
|
||||
quickSlotListeners.onQuickSlotUsed(quickSlotId);
|
||||
}
|
||||
|
||||
public void setQuickItem(ItemType itemType, int quickSlotId) {
|
||||
world.model.player.inventory.quickitem[quickSlotId] = itemType;
|
||||
quickSlotListeners.onQuickSlotChanged(quickSlotId);
|
||||
}
|
||||
|
||||
private void checkQuickslotItemLooted(ItemContainer items) {
|
||||
for (ItemEntry item : items.items) {
|
||||
if (item.itemType.isUsable()) {
|
||||
for (int i = 0; i < world.model.player.inventory.quickitem.length; i++) {
|
||||
if (item.itemType == world.model.player.inventory.quickitem[i]) {
|
||||
quickSlotListeners.onQuickSlotChanged(i);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int removeEquippedItem(String itemTypeID, int count) {
|
||||
int removed = 0;
|
||||
final Player player = world.model.player;
|
||||
for (Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type != null && type.id.equals(itemTypeID)) {
|
||||
player.inventory.setItemTypeInWearSlot(slot, null);
|
||||
controllers.actorStatsController.removeConditionsFromUnequippedItem(player, type);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
removed++;
|
||||
if (removed >= count) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
public static void applyDamageModifier(Player player) {
|
||||
ItemType itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
int modifier1 = -1;
|
||||
int modifier2 = -1;
|
||||
if (itemType != null) modifier1 = itemType.effects_equip.stats.setNonWeaponDamageModifier;
|
||||
itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.shield);
|
||||
if (itemType != null && itemType.isWeapon()) modifier2 = itemType.effects_equip.stats.setNonWeaponDamageModifier;
|
||||
|
||||
int modifier = 100;
|
||||
if (modifier1 >= 0 && modifier2 >= 0) modifier = Math.min(modifier1, modifier2);
|
||||
else if (modifier1 <= 0 && modifier2 >= 0) modifier = modifier2;
|
||||
else if (modifier2 <= 0 && modifier1 >= 0) modifier = modifier1;
|
||||
|
||||
if (modifier != 100) {
|
||||
final int minBaseDamage = player.damagePotential.current - player.weaponDamage.current;
|
||||
final int maxBaseDamage = player.damagePotential.max - player.weaponDamage.max;
|
||||
player.damagePotential.add(Math.round(minBaseDamage * ((modifier - 100)/100f)), true);
|
||||
player.damagePotential.addToMax(Math.round(maxBaseDamage * ((modifier - 100)/100f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.QuickSlotListeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.traits.AbilityModifierTraits;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer.ItemEntry;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnHitReceived;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnUse;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
|
||||
import static java.lang.Math.min;
|
||||
|
||||
public final class ItemController {
|
||||
|
||||
private final ControllerContext controllers;
|
||||
private final WorldContext world;
|
||||
public final QuickSlotListeners quickSlotListeners = new QuickSlotListeners();
|
||||
|
||||
public ItemController(ControllerContext controllers, WorldContext world) {
|
||||
this.controllers = controllers;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public void dropItem(ItemType type, int quantity) {
|
||||
if (world.model.player.inventory.getItemQuantity(type.id) < quantity) return;
|
||||
world.model.player.inventory.removeItem(type.id, quantity);
|
||||
world.model.currentMaps.map.itemDropped(type, quantity, world.model.player.position);
|
||||
}
|
||||
|
||||
public void equipItem(ItemType type, Inventory.WearSlot slot) {
|
||||
if (!type.isEquippable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getReequipCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
if (!player.inventory.removeItem(type.id, 1)) return;
|
||||
|
||||
unequipSlot(player, slot);
|
||||
if (type.isTwohandWeapon()) unequipSlot(player, Inventory.WearSlot.shield);
|
||||
else if (slot == Inventory.WearSlot.shield) {
|
||||
ItemType currentWeapon = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (currentWeapon != null && currentWeapon.isTwohandWeapon()) unequipSlot(player, Inventory.WearSlot.weapon);
|
||||
}
|
||||
|
||||
player.inventory.setItemTypeInWearSlot(slot, type);
|
||||
controllers.actorStatsController.addConditionsFromEquippedItem(player, type);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
if (world.model.uiSelections.isInCombat && !controllers.combatController.playerHasApLeft()) {
|
||||
controllers.combatController.endPlayerTurn();
|
||||
}
|
||||
}
|
||||
|
||||
public void unequipSlot(ItemType type, Inventory.WearSlot slot) {
|
||||
if (!type.isEquippable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (player.inventory.isEmptySlot(slot)) return;
|
||||
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getReequipCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
unequipSlot(player, slot);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
if (world.model.uiSelections.isInCombat && !controllers.combatController.playerHasApLeft()) {
|
||||
controllers.combatController.endPlayerTurn();
|
||||
}
|
||||
}
|
||||
|
||||
private void unequipSlot(Player player, Inventory.WearSlot slot) {
|
||||
ItemType removedItemType = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (removedItemType == null) return;
|
||||
player.inventory.addItem(removedItemType);
|
||||
player.inventory.setItemTypeInWearSlot(slot, null);
|
||||
controllers.actorStatsController.removeConditionsFromUnequippedItem(player, removedItemType);
|
||||
}
|
||||
|
||||
public void useItem(ItemType type) {
|
||||
if (!type.isUsable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getUseItemCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
if (!player.inventory.removeItem(type.id, 1)) return;
|
||||
|
||||
world.model.combatLog.append(controllers.getResources().getString(R.string.inventory_item_used, type.getName(player)));
|
||||
controllers.actorStatsController.applyUseEffect(player, null, type.effects_use);
|
||||
world.model.statistics.addItemUsage(type);
|
||||
if (world.model.uiSelections.isInCombat && !controllers.combatController.playerHasApLeft()) {
|
||||
controllers.combatController.endPlayerTurn();
|
||||
}
|
||||
}
|
||||
|
||||
public void playerSteppedOnLootBag(Loot loot) {
|
||||
if (pickupLootBagWithoutConfirmation(loot)) {
|
||||
controllers.mapController.worldEventListeners.onPlayerPickedUpGroundLoot(loot);
|
||||
pickupAll(loot);
|
||||
removeLootBagIfEmpty(loot);
|
||||
} else {
|
||||
controllers.mapController.worldEventListeners.onPlayerSteppedOnGroundLoot(loot);
|
||||
consumeNonItemLoot(loot);
|
||||
}
|
||||
}
|
||||
|
||||
public void lootMonsterBags(Collection<Loot> killedMonsterBags, int totalExpThisFight) {
|
||||
if (pickupLootBagsWithoutConfirmation(killedMonsterBags)) {
|
||||
controllers.mapController.worldEventListeners.onPlayerPickedUpMonsterLoot(killedMonsterBags, totalExpThisFight);
|
||||
pickupAll(killedMonsterBags);
|
||||
removeLootBagIfEmpty(killedMonsterBags);
|
||||
controllers.gameRoundController.resume();
|
||||
} else {
|
||||
controllers.mapController.worldEventListeners.onPlayerFoundMonsterLoot(killedMonsterBags, totalExpThisFight);
|
||||
consumeNonItemLoot(killedMonsterBags);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean pickupLootBagWithoutConfirmation(Loot bag) {
|
||||
if (bag.isContainer()) return false;
|
||||
switch (controllers.preferences.displayLoot) {
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS:
|
||||
return false;
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS:
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST:
|
||||
if (bag.hasItems()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean pickupLootBagsWithoutConfirmation(Collection<Loot> bags) {
|
||||
if (controllers.preferences.displayLoot == AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS) return false;
|
||||
for (Loot bag : bags) {
|
||||
if (!pickupLootBagWithoutConfirmation(bag)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void applyInventoryEffects(Player player) {
|
||||
ItemType weapon = getMainWeapon(player);
|
||||
if (weapon != null) {
|
||||
player.attackCost = 0;
|
||||
player.criticalMultiplier = weapon.effects_equip.stats.setCriticalMultiplier;
|
||||
}
|
||||
|
||||
applyInventoryEffects(player, Inventory.WearSlot.weapon);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.shield);
|
||||
SkillController.applySkillEffectsFromFightingStyles(player);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.head);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.body);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.hand);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.feet);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.neck);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.leftring);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.rightring);
|
||||
SkillController.applySkillEffectsFromItemProficiencies(player);
|
||||
}
|
||||
public static ItemType getMainWeapon(Player player) {
|
||||
ItemType itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (itemType != null) return itemType;
|
||||
itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.shield);
|
||||
if (itemType != null && itemType.isWeapon()) return itemType;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void applyInventoryEffects(Player player, Inventory.WearSlot slot) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type == null) return;
|
||||
if (slot == Inventory.WearSlot.shield) {
|
||||
ItemType mainHandItem = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
// The stats for off-hand weapons will be added later in SkillController.applySkillEffectsFromFightingStyles
|
||||
if (SkillController.isDualWielding(mainHandItem, type)) return;
|
||||
}
|
||||
if (type.effects_equip != null && type.effects_equip.stats != null) {
|
||||
controllers.actorStatsController.applyAbilityEffects(player, type.effects_equip.stats, 1);
|
||||
if (type.isWeapon()) {
|
||||
controllers.actorStatsController.addPlayerWeaponDamage(player, type.effects_equip.stats.increaseMinDamage, type.effects_equip.stats.increaseMaxDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void recalculateHitEffectsFromWornItems(Player player) {
|
||||
ArrayList<ItemTraits_OnUse> effects_onHit = null;
|
||||
ArrayList<ItemTraits_OnHitReceived> effects_onHitReceived = null;
|
||||
for (Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type == null) continue;
|
||||
ItemTraits_OnUse eh = type.effects_hit;
|
||||
ItemTraits_OnHitReceived ehr = type.effects_hitReceived;
|
||||
if (eh == null && ehr == null) continue;
|
||||
|
||||
if (effects_onHit == null) effects_onHit = new ArrayList<ItemTraits_OnUse>();
|
||||
if (eh != null) effects_onHit.add(eh);
|
||||
|
||||
if (effects_onHitReceived == null) effects_onHitReceived = new ArrayList<ItemTraits_OnHitReceived>();
|
||||
if (ehr != null) effects_onHitReceived.add(ehr);
|
||||
}
|
||||
|
||||
if (effects_onHit != null) {
|
||||
ItemTraits_OnUse[] effects_ = new ItemTraits_OnUse[effects_onHit.size()];
|
||||
effects_ = effects_onHit.toArray(effects_);
|
||||
player.onHitEffects = effects_;
|
||||
} else {
|
||||
player.onHitEffects = null;
|
||||
}
|
||||
|
||||
if (effects_onHitReceived != null) {
|
||||
ItemTraits_OnHitReceived[] effects_ = new ItemTraits_OnHitReceived[effects_onHitReceived.size()];
|
||||
effects_ = effects_onHitReceived.toArray(effects_);
|
||||
player.onHitReceivedEffects = effects_;
|
||||
} else {
|
||||
player.onHitReceivedEffects = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void consumeNonItemLoot(Loot loot) {
|
||||
// Experience will be given as soon as the monster is killed.
|
||||
world.model.player.inventory.gold += loot.gold;
|
||||
loot.gold = 0;
|
||||
removeLootBagIfEmpty(loot);
|
||||
}
|
||||
public void consumeNonItemLoot(Iterable<Loot> lootBags) {
|
||||
for(Loot l : lootBags) {
|
||||
consumeNonItemLoot(l);
|
||||
}
|
||||
}
|
||||
|
||||
public void pickupAll(Loot loot) {
|
||||
world.model.player.inventory.add(loot.items);
|
||||
consumeNonItemLoot(loot);
|
||||
checkQuickslotItemLooted(loot.items);
|
||||
loot.clear();
|
||||
}
|
||||
public void pickupAll(Iterable<Loot> lootBags) {
|
||||
for(Loot l : lootBags) {
|
||||
pickupAll(l);
|
||||
}
|
||||
}
|
||||
public boolean removeLootBagIfEmpty(final Loot loot) {
|
||||
if (loot.hasItemsOrGold()) return false;
|
||||
|
||||
world.model.currentMaps.map.removeGroundLoot(loot);
|
||||
controllers.mapController.mapLayoutListeners.onLootBagRemoved(world.model.currentMaps.map, loot.position);
|
||||
return true; // The bag was removed.
|
||||
}
|
||||
|
||||
public boolean removeLootBagIfEmpty(final Iterable<Loot> lootBags) {
|
||||
boolean isEmpty = true;
|
||||
for (Loot l : lootBags) {
|
||||
if (!removeLootBagIfEmpty(l)) isEmpty = false;
|
||||
}
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
private static int getMarketPriceFactor(Player player) {
|
||||
return Constants.MARKET_PRICEFACTOR_PERCENT
|
||||
- player.getSkillLevel(SkillCollection.SkillID.barter) * SkillCollection.PER_SKILLPOINT_INCREASE_BARTER_PRICEFACTOR_PERCENTAGE;
|
||||
}
|
||||
public static int getBuyingPrice(Player player, ItemType itemType) {
|
||||
return itemType.baseMarketCost + itemType.baseMarketCost * getMarketPriceFactor(player) / 100;
|
||||
}
|
||||
public static int getSellingPrice(Player player, ItemType itemType) {
|
||||
return itemType.baseMarketCost - itemType.baseMarketCost * getMarketPriceFactor(player) / 100;
|
||||
}
|
||||
|
||||
public static boolean canAfford(Player player, ItemType itemType) {
|
||||
return player.inventory.gold >= getBuyingPrice(player, itemType);
|
||||
}
|
||||
public static boolean canAfford(Player player, int price) {
|
||||
return player.inventory.gold >= price;
|
||||
}
|
||||
public static boolean maySellItem(Player player, ItemType itemType) {
|
||||
if (!itemType.isSellable()) return false;
|
||||
return true;
|
||||
}
|
||||
public static boolean sell(Player player, ItemType itemType, ItemContainer merchant, int quantity) {
|
||||
int price = getSellingPrice(player, itemType) * quantity;
|
||||
if (!maySellItem(player, itemType)) return false;
|
||||
if (!player.inventory.removeItem(itemType.id, quantity)) return false;
|
||||
player.inventory.gold += price;
|
||||
merchant.addItem(itemType, quantity);
|
||||
return true;
|
||||
}
|
||||
public static boolean buy(ModelContainer model, Player player, ItemType itemType, ItemContainer merchant, int quantity) {
|
||||
int price = getBuyingPrice(player, itemType) * quantity;
|
||||
if (!canAfford(player, price)) return false;
|
||||
if (!merchant.removeItem(itemType.id, quantity)) return false;
|
||||
player.inventory.gold -= price;
|
||||
player.inventory.addItem(itemType, quantity);
|
||||
model.statistics.addGoldSpent(price);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static String describeItemForListView(ItemEntry item, Player player) {
|
||||
StringBuilder sb = new StringBuilder(item.itemType.getName(player));
|
||||
if (item.quantity > 1) {
|
||||
sb.append(" (");
|
||||
sb.append(item.quantity);
|
||||
sb.append(')');
|
||||
}
|
||||
if (item.itemType.effects_equip != null) {
|
||||
AbilityModifierTraits t = item.itemType.effects_equip.stats;
|
||||
if (t != null) {
|
||||
if (t.increaseAttackChance != 0
|
||||
|| t.increaseMinDamage != 0
|
||||
|| t.increaseMaxDamage != 0
|
||||
|| t.increaseCriticalSkill != 0
|
||||
|| t.setCriticalMultiplier != 0) {
|
||||
sb.append(" [");
|
||||
describeAttackEffect(t.increaseAttackChance, t.increaseMinDamage, t.increaseMaxDamage, t.increaseCriticalSkill, t.setCriticalMultiplier, sb);
|
||||
sb.append(']');
|
||||
}
|
||||
if (t.increaseBlockChance != 0
|
||||
|| t.increaseDamageResistance != 0) {
|
||||
sb.append(" [");
|
||||
describeBlockEffect(t.increaseBlockChance, t.increaseDamageResistance, sb);
|
||||
sb.append(']');
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void describeAttackEffect(int attackChance, int minDamage, int maxDamage, int criticalSkill, float criticalMultiplier, StringBuilder sb) {
|
||||
boolean addSpace = false;
|
||||
if (attackChance != 0) {
|
||||
sb.append(attackChance);
|
||||
addSpace = true;
|
||||
}
|
||||
if (minDamage != 0 || maxDamage != 0) {
|
||||
if (addSpace) sb.append(' ');
|
||||
sb.append(minDamage);
|
||||
if (minDamage != maxDamage) {
|
||||
sb.append('-');
|
||||
sb.append(maxDamage);
|
||||
}
|
||||
addSpace = true;
|
||||
}
|
||||
if (criticalSkill != 0) {
|
||||
if (addSpace) sb.append(' ');
|
||||
if (criticalSkill >= 0) {
|
||||
sb.append('+');
|
||||
}
|
||||
sb.append(criticalSkill);
|
||||
}
|
||||
if (criticalMultiplier != 0 && criticalMultiplier != 1) {
|
||||
sb.append('x');
|
||||
sb.append(criticalMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
public static void describeBlockEffect(int blockChance, int damageResistance, StringBuilder sb) {
|
||||
if (blockChance != 0) {
|
||||
sb.append(blockChance);
|
||||
}
|
||||
if (damageResistance != 0) {
|
||||
sb.append('/');
|
||||
sb.append(damageResistance);
|
||||
}
|
||||
}
|
||||
|
||||
public void quickitemUse(int quickSlotId) {
|
||||
useItem(world.model.player.inventory.quickitem[quickSlotId]);
|
||||
quickSlotListeners.onQuickSlotUsed(quickSlotId);
|
||||
}
|
||||
|
||||
public void setQuickItem(ItemType itemType, int quickSlotId) {
|
||||
world.model.player.inventory.quickitem[quickSlotId] = itemType;
|
||||
quickSlotListeners.onQuickSlotChanged(quickSlotId);
|
||||
}
|
||||
|
||||
private void checkQuickslotItemLooted(ItemContainer items) {
|
||||
for (ItemEntry item : items.items) {
|
||||
if (item.itemType.isUsable()) {
|
||||
for (int i = 0; i < world.model.player.inventory.quickitem.length; i++) {
|
||||
if (item.itemType == world.model.player.inventory.quickitem[i]) {
|
||||
quickSlotListeners.onQuickSlotChanged(i);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int removeEquippedItem(String itemTypeID, int count) {
|
||||
int removed = 0;
|
||||
final Player player = world.model.player;
|
||||
for (Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type != null && type.id.equals(itemTypeID)) {
|
||||
player.inventory.setItemTypeInWearSlot(slot, null);
|
||||
controllers.actorStatsController.removeConditionsFromUnequippedItem(player, type);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
removed++;
|
||||
if (removed >= count) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
public static void applyDamageModifier(Player player) {
|
||||
ItemType itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
int modifier1 = -1;
|
||||
int modifier2 = -1;
|
||||
if (itemType != null) modifier1 = itemType.effects_equip.stats.setNonWeaponDamageModifier;
|
||||
itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.shield);
|
||||
if (itemType != null && itemType.isWeapon()) modifier2 = itemType.effects_equip.stats.setNonWeaponDamageModifier;
|
||||
|
||||
int modifier = 100;
|
||||
if (modifier1 >= 0 && modifier2 >= 0) {
|
||||
int skillLevelFightStyle = player.getSkillLevel(SkillCollection.SkillID.fightstyleDualWield);
|
||||
if (skillLevelFightStyle == 2) {
|
||||
modifier = Math.max(modifier1, modifier2);
|
||||
} else if (skillLevelFightStyle == 1) {
|
||||
modifier = (modifier1 + modifier2) / 2;
|
||||
} else {
|
||||
modifier = Math.min(modifier1, modifier2);
|
||||
}
|
||||
}
|
||||
else if (modifier1 <= 0 && modifier2 >= 0) modifier = modifier2;
|
||||
else if (modifier2 <= 0 && modifier1 >= 0) modifier = modifier1;
|
||||
|
||||
if (modifier != 100) {
|
||||
final int minBaseDamage = player.damagePotential.current - player.weaponDamage.current;
|
||||
final int maxBaseDamage = player.damagePotential.max - player.weaponDamage.max;
|
||||
player.damagePotential.add(Math.round(minBaseDamage * ((modifier - 100)/100f)), true);
|
||||
player.damagePotential.addToMax(Math.round(maxBaseDamage * ((modifier - 100)/100f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,6 +149,7 @@ public final class MapController {
|
||||
controllers.monsterSpawnController.spawnAll(world.model.currentMaps.map, world.model.currentMaps.tileMap);
|
||||
world.model.worldData.tickWorldTime(20);
|
||||
controllers.gameRoundController.resetRoundTimers();
|
||||
mapScriptExecutor.proceedToPhrase(controllers.getResources(), Constants.PASSIVE_ACHIEVEMENT_CHECK_PHRASE, true, true);
|
||||
}
|
||||
|
||||
public void rest(MapObject area) {
|
||||
@@ -180,7 +181,7 @@ public final class MapController {
|
||||
world.maps.worldMapRequiresUpdate = true;
|
||||
|
||||
if (!updateWorldmap) return;
|
||||
WorldMapController.updateWorldMap(world, res);
|
||||
WorldMapController.updateWorldMap(controllers.getContext(), world, res);
|
||||
mapLayoutListeners.onMapTilesChanged(world.model.currentMaps.map, world.model.currentMaps.tileMap);
|
||||
}
|
||||
|
||||
@@ -75,6 +75,9 @@ public final class MonsterMovementController implements EvaluateWalkable {
|
||||
}
|
||||
|
||||
private void moveMonster(final Monster m, final MonsterSpawnArea area) {
|
||||
if (m.getMoveCost() == Constants.MONSTER_IMMOBILE_MOVE_COST) {
|
||||
return;
|
||||
}
|
||||
PredefinedMap map = world.model.currentMaps.map;
|
||||
LayeredTileMap tileMap = world.model.currentMaps.tileMap;
|
||||
m.nextActionTime = System.currentTimeMillis() + getMillisecondsPerMove(m);
|
||||
@@ -128,7 +128,7 @@ public final class MovementController implements TimedMessageTask.Callback {
|
||||
moveBlockedActors(newMap, model.currentMaps.tileMap);
|
||||
refreshMonsterAggressiveness(newMap, model.player);
|
||||
controllers.effectController.updateSplatters(newMap);
|
||||
WorldMapController.updateWorldMap(world, res);
|
||||
WorldMapController.updateWorldMap(controllers.getContext(), world, res);
|
||||
}
|
||||
|
||||
private boolean mayMovePlayer() {
|
||||
@@ -72,7 +72,7 @@ public final class SkillController {
|
||||
if (player == null) return 0;
|
||||
if (!ItemTypeCollection.isGoldItemType(item.itemType.id)) return 0;
|
||||
|
||||
return getRollBias(item, player, SkillID.coinfinder, SkillCollection.PER_SKILLPOINT_INCREASE_COINFINDER_QUANTITY_PERCENT);
|
||||
return getRollBias(item.quantity, player, SkillID.coinfinder, SkillCollection.PER_SKILLPOINT_INCREASE_COINFINDER_QUANTITY_PERCENT);
|
||||
}
|
||||
|
||||
private static int getRollBias(DropItem item, Player player, SkillID skill, int perSkillpointIncrease) {
|
||||
@@ -82,7 +82,7 @@ public final class SkillController {
|
||||
private static int getRollBias(ConstRange chance, Player player, SkillID skill, int perSkillpointIncrease) {
|
||||
int skillLevel = player.getSkillLevel(skill);
|
||||
if (skillLevel <= 0) return 0;
|
||||
return chance.current * skillLevel * perSkillpointIncrease / 100;
|
||||
return chance.current * skillLevel * perSkillpointIncrease;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,9 @@ public final class SkillController {
|
||||
int result = 0;
|
||||
result += getActorConditionEffectChanceRollBiasFromResistanceSkills(effect, player);
|
||||
result += getActorConditionEffectChanceRollBias(effect, player, SkillID.shadowBless, SkillCollection.PER_SKILLPOINT_INCREASE_RESISTANCE_SHADOW_BLESS);
|
||||
if ("spore_poison".equals(effect.conditionType.conditionTypeID)) {
|
||||
result += getActorConditionEffectChanceRollBias(effect, player, SkillID.sporeImmunity, 100);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,318 +1,317 @@
|
||||
package com.gpl.rpg.AndorsTrail.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Environment;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.DisplayWorldMapActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.LayeredTileMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapLayer;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.NamedWorldMapArea;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.WorldMapSegmentMap;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class WorldMapController {
|
||||
|
||||
private static final int WORLDMAP_SCREENSHOT_TILESIZE = 8;
|
||||
public static final int WORLDMAP_DISPLAY_TILESIZE = WORLDMAP_SCREENSHOT_TILESIZE;
|
||||
|
||||
public static void updateWorldMap(final WorldContext world, final Resources res) {
|
||||
updateWorldMap(world, world.model.currentMaps.map, world.model.currentMaps.tileMap, world.model.currentMaps.tiles, res);
|
||||
}
|
||||
|
||||
private static void updateWorldMap(
|
||||
final WorldContext world,
|
||||
final PredefinedMap map,
|
||||
final LayeredTileMap mapTiles,
|
||||
final TileCollection cachedTiles,
|
||||
final Resources res) {
|
||||
final String worldMapSegmentName = world.maps.getWorldMapSegmentNameForMap(map.name);
|
||||
if (worldMapSegmentName == null) return;
|
||||
|
||||
if (!shouldUpdateWorldMap(map, worldMapSegmentName, world.maps.worldMapRequiresUpdate)) return;
|
||||
|
||||
(new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
final MapRenderer renderer = new MapRenderer(world, map, mapTiles, cachedTiles);
|
||||
try {
|
||||
updateCachedBitmap(map, renderer);
|
||||
updateWorldMapSegment(res, world, worldMapSegmentName);
|
||||
world.maps.worldMapRequiresUpdate = false;
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
|
||||
L.log("WorldMapController: Updated worldmap segment " + worldMapSegmentName + " for map " + map.name);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
L.log("Error creating worldmap file for map " + map.name + " : " + e.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
|
||||
private static boolean shouldUpdateWorldMap(PredefinedMap map, String worldMapSegmentName, boolean forceUpdate) {
|
||||
if (forceUpdate) return true;
|
||||
if (!map.visited) return true;
|
||||
File file = getFileForMap(map, false);
|
||||
if (!file.exists()) return true;
|
||||
|
||||
file = getCombinedWorldMapFile(worldMapSegmentName);
|
||||
if (!file.exists()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void updateCachedBitmap(PredefinedMap map, MapRenderer renderer) throws IOException {
|
||||
ensureWorldmapDirectoryExists();
|
||||
|
||||
File file = getFileForMap(map, false);
|
||||
if (file.exists()) return;
|
||||
|
||||
Bitmap image = renderer.drawMap();
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
image.compress(Bitmap.CompressFormat.PNG, 70, fos);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
image.recycle();
|
||||
L.log("WorldMapController: Wrote " + file.getAbsolutePath());
|
||||
}
|
||||
|
||||
private static final class MapRenderer {
|
||||
private final PredefinedMap map;
|
||||
private final LayeredTileMap mapTiles;
|
||||
private final TileCollection cachedTiles;
|
||||
private final int tileSize;
|
||||
private final float scale;
|
||||
private final Paint mPaint = new Paint();
|
||||
|
||||
public MapRenderer(final WorldContext world, final PredefinedMap map, final LayeredTileMap mapTiles, final TileCollection cachedTiles) {
|
||||
this.map = map;
|
||||
this.mapTiles = mapTiles;
|
||||
this.cachedTiles = cachedTiles;
|
||||
this.tileSize = world.tileManager.tileSize;
|
||||
this.scale = (float) WORLDMAP_SCREENSHOT_TILESIZE / world.tileManager.tileSize;
|
||||
mapTiles.setColorFilter(mPaint, null, true);
|
||||
}
|
||||
|
||||
public Bitmap drawMap() {
|
||||
Bitmap image = Bitmap.createBitmap(map.size.width * WORLDMAP_SCREENSHOT_TILESIZE, map.size.height * WORLDMAP_SCREENSHOT_TILESIZE, Config.RGB_565);
|
||||
image.setDensity(Bitmap.DENSITY_NONE);
|
||||
Canvas canvas = new Canvas(image);
|
||||
canvas.scale(scale, scale);
|
||||
|
||||
synchronized (cachedTiles) {
|
||||
drawMapLayer(canvas, mapTiles.currentLayout.layerGround);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerObjects);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerAbove);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerTop);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private void tryDrawMapLayer(Canvas canvas, final MapLayer layer) {
|
||||
if (layer != null) drawMapLayer(canvas, layer);
|
||||
}
|
||||
|
||||
private void drawMapLayer(Canvas canvas, final MapLayer layer) {
|
||||
int py = 0;
|
||||
for (int y = 0; y < map.size.height; ++y, py += tileSize) {
|
||||
int px = 0;
|
||||
for (int x = 0; x < map.size.width; ++x, px += tileSize) {
|
||||
final int tile = layer.tiles[x][y];
|
||||
if (tile == 0) continue;
|
||||
cachedTiles.drawTile(canvas, tile, px, py, mPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ensureWorldmapDirectoryExists() throws IOException {
|
||||
File root = Environment.getExternalStorageDirectory();
|
||||
File dir = new File(root, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
if (!dir.exists()) dir.mkdir();
|
||||
dir = new File(dir, Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
if (!dir.exists()) dir.mkdir();
|
||||
|
||||
File noMediaFile = new File(dir, ".nomedia");
|
||||
if (!noMediaFile.exists()) noMediaFile.createNewFile();
|
||||
}
|
||||
public static boolean fileForMapExists(PredefinedMap map) {
|
||||
if (map.lastSeenLayoutHash.length() > 0) {
|
||||
return getPngFile(map.name + '.' + map.lastSeenLayoutHash).exists();
|
||||
}
|
||||
return getPngFile(map.name).exists();
|
||||
}
|
||||
private static File getFileForMap(PredefinedMap map, boolean verifyFileExists) {
|
||||
if (map.lastSeenLayoutHash.length() > 0) {
|
||||
File fileWithHash = getPngFile(map.name + '.' + map.lastSeenLayoutHash);
|
||||
if (!verifyFileExists) return fileWithHash;
|
||||
else if (fileWithHash.exists()) return fileWithHash;
|
||||
}
|
||||
return getPngFile(map.name);
|
||||
}
|
||||
private static File getPngFile(String fileName) {
|
||||
return new File(getWorldmapDirectory(), fileName + ".png");
|
||||
}
|
||||
private static File getWorldmapDirectory() {
|
||||
File dir = Environment.getExternalStorageDirectory();
|
||||
dir = new File(dir, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
return new File(dir, Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
}
|
||||
public static File getCombinedWorldMapFile(String segmentName) {
|
||||
return new File(getWorldmapDirectory(), Constants.FILENAME_WORLDMAP_HTMLFILE_PREFIX + segmentName + Constants.FILENAME_WORLDMAP_HTMLFILE_SUFFIX);
|
||||
}
|
||||
|
||||
private static String getWorldMapSegmentAsHtml(Resources res, WorldContext world, String segmentName) {
|
||||
WorldMapSegment segment = world.maps.worldMapSegments.get(segmentName);
|
||||
|
||||
Map<String, File> displayedMapFilenamesPerMapName = new HashMap<String, File>(segment.maps.size());
|
||||
Coord offsetWorldmapTo = new Coord(999999, 999999);
|
||||
for (WorldMapSegmentMap map : segment.maps.values()) {
|
||||
PredefinedMap predefinedMap = world.maps.findPredefinedMap(map.mapName);
|
||||
if (predefinedMap == null) continue;
|
||||
if (!predefinedMap.visited) continue;
|
||||
File f = WorldMapController.getFileForMap(predefinedMap, true);
|
||||
if (!f.exists()) continue;
|
||||
displayedMapFilenamesPerMapName.put(map.mapName, f);
|
||||
|
||||
offsetWorldmapTo.x = Math.min(offsetWorldmapTo.x, map.worldPosition.x);
|
||||
offsetWorldmapTo.y = Math.min(offsetWorldmapTo.y, map.worldPosition.y);
|
||||
}
|
||||
|
||||
Coord bottomRight = new Coord(0, 0);
|
||||
|
||||
StringBuilder mapsAsHtml = new StringBuilder(1000);
|
||||
for (WorldMapSegmentMap segmentMap : segment.maps.values()) {
|
||||
File f = displayedMapFilenamesPerMapName.get(segmentMap.mapName);
|
||||
if (f == null) continue;
|
||||
|
||||
Size size = getMapSize(segmentMap, world);
|
||||
mapsAsHtml
|
||||
.append("<img src=\"")
|
||||
.append(f.getName())
|
||||
.append("\" id=\"")
|
||||
.append(segmentMap.mapName)
|
||||
.append("\" style=\"width:")
|
||||
.append(size.width * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; height:")
|
||||
.append(size.height * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; left:")
|
||||
.append((segmentMap.worldPosition.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; top:")
|
||||
.append((segmentMap.worldPosition.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px;\" />");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) mapsAsHtml.append('\n');
|
||||
|
||||
bottomRight.x = Math.max(bottomRight.x, segmentMap.worldPosition.x + size.width);
|
||||
bottomRight.y = Math.max(bottomRight.y, segmentMap.worldPosition.y + size.height);
|
||||
}
|
||||
Size worldmapSegmentSize = new Size(
|
||||
(bottomRight.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
,(bottomRight.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
);
|
||||
|
||||
StringBuilder namedAreasAsHtml = new StringBuilder(500);
|
||||
for (NamedWorldMapArea area : segment.namedAreas.values()) {
|
||||
CoordRect r = determineNamedAreaBoundary(area, segment, world, displayedMapFilenamesPerMapName.keySet());
|
||||
if (r == null) continue;
|
||||
namedAreasAsHtml
|
||||
.append("<div class=\"namedarea ")
|
||||
.append(area.type)
|
||||
.append("\" style=\"width:")
|
||||
.append(r.size.width * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; line-height:")
|
||||
.append(r.size.height * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; left:")
|
||||
.append((r.topLeft.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; top:")
|
||||
.append((r.topLeft.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px;\"><span>")
|
||||
.append(area.name)
|
||||
.append("</span></div>");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) namedAreasAsHtml.append('\n');
|
||||
}
|
||||
|
||||
return res.getString(R.string.worldmap_template)
|
||||
.replace("{{maps}}", mapsAsHtml.toString())
|
||||
.replace("{{areas}}", namedAreasAsHtml.toString())
|
||||
.replace("{{sizex}}", Integer.toString(worldmapSegmentSize.width))
|
||||
.replace("{{sizey}}", Integer.toString(worldmapSegmentSize.height))
|
||||
.replace("{{offsetx}}", Integer.toString(offsetWorldmapTo.x * WorldMapController.WORLDMAP_DISPLAY_TILESIZE))
|
||||
.replace("{{offsety}}", Integer.toString(offsetWorldmapTo.y * WorldMapController.WORLDMAP_DISPLAY_TILESIZE));
|
||||
}
|
||||
|
||||
private static Size getMapSize(WorldMapSegmentMap map, WorldContext world) {
|
||||
return world.maps.findPredefinedMap(map.mapName).size;
|
||||
}
|
||||
|
||||
private static CoordRect determineNamedAreaBoundary(NamedWorldMapArea area, WorldMapSegment segment, WorldContext world, Set<String> displayedMapNames) {
|
||||
Coord topLeft = null;
|
||||
Coord bottomRight = null;
|
||||
|
||||
for (String mapName : area.mapNames) {
|
||||
if (!displayedMapNames.contains(mapName)) continue;
|
||||
WorldMapSegmentMap map = segment.maps.get(mapName);
|
||||
Size size = getMapSize(map, world);
|
||||
if (topLeft == null) {
|
||||
topLeft = new Coord(map.worldPosition);
|
||||
} else {
|
||||
topLeft.x = Math.min(topLeft.x, map.worldPosition.x);
|
||||
topLeft.y = Math.min(topLeft.y, map.worldPosition.y);
|
||||
}
|
||||
if (bottomRight == null) {
|
||||
bottomRight = new Coord(map.worldPosition.x + size.width, map.worldPosition.y + size.height);
|
||||
} else {
|
||||
bottomRight.x = Math.max(bottomRight.x, map.worldPosition.x + size.width);
|
||||
bottomRight.y = Math.max(bottomRight.y, map.worldPosition.y + size.height);
|
||||
}
|
||||
}
|
||||
if (topLeft == null) return null;
|
||||
return new CoordRect(topLeft, new Size(bottomRight.x - topLeft.x, bottomRight.y - topLeft.y));
|
||||
}
|
||||
|
||||
public static void updateWorldMapSegment(Resources res, WorldContext world, String segmentName) throws IOException {
|
||||
String mapAsHtml = getWorldMapSegmentAsHtml(res, world, segmentName);
|
||||
File outputFile = getCombinedWorldMapFile(segmentName);
|
||||
PrintWriter pw = new PrintWriter(outputFile);
|
||||
pw.write(mapAsHtml);
|
||||
pw.close();
|
||||
}
|
||||
|
||||
public static boolean displayWorldMap(Context context, WorldContext world) {
|
||||
String worldMapSegmentName = world.maps.getWorldMapSegmentNameForMap(world.model.currentMaps.map.name);
|
||||
if (worldMapSegmentName == null) {
|
||||
Toast.makeText(context, context.getResources().getString(R.string.display_worldmap_not_available), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(context, DisplayWorldMapActivity.class);
|
||||
intent.putExtra("worldMapSegmentName", worldMapSegmentName);
|
||||
context.startActivity(intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.DisplayWorldMapActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.LayeredTileMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapLayer;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.NamedWorldMapArea;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.WorldMapSegmentMap;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class WorldMapController {
|
||||
|
||||
private static final int WORLDMAP_SCREENSHOT_TILESIZE = 8;
|
||||
public static final int WORLDMAP_DISPLAY_TILESIZE = WORLDMAP_SCREENSHOT_TILESIZE;
|
||||
|
||||
public static void updateWorldMap(Context context, final WorldContext world, final Resources res) {
|
||||
updateWorldMap(context, world, world.model.currentMaps.map, world.model.currentMaps.tileMap, world.model.currentMaps.tiles, res);
|
||||
}
|
||||
|
||||
private static void updateWorldMap(
|
||||
Context context, final WorldContext world,
|
||||
final PredefinedMap map,
|
||||
final LayeredTileMap mapTiles,
|
||||
final TileCollection cachedTiles,
|
||||
final Resources res) {
|
||||
final String worldMapSegmentName = world.maps.getWorldMapSegmentNameForMap(map.name);
|
||||
if (worldMapSegmentName == null) return;
|
||||
|
||||
if (!shouldUpdateWorldMap(context, map, worldMapSegmentName, world.maps.worldMapRequiresUpdate)) return;
|
||||
|
||||
(new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
final MapRenderer renderer = new MapRenderer(world, map, mapTiles, cachedTiles);
|
||||
try {
|
||||
updateCachedBitmap(context, map, renderer);
|
||||
updateWorldMapSegment(context, res, world, worldMapSegmentName);
|
||||
world.maps.worldMapRequiresUpdate = false;
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
|
||||
L.log("WorldMapController: Updated worldmap segment " + worldMapSegmentName + " for map " + map.name);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
L.log("Error creating worldmap file for map " + map.name + " : " + e.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
|
||||
private static boolean shouldUpdateWorldMap(Context context, PredefinedMap map, String worldMapSegmentName, boolean forceUpdate) {
|
||||
if (forceUpdate) return true;
|
||||
if (!map.visited) return true;
|
||||
File file = getFileForMap(context, map, false);
|
||||
if (!file.exists()) return true;
|
||||
|
||||
file = getCombinedWorldMapFile(context, worldMapSegmentName);
|
||||
if (!file.exists()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void updateCachedBitmap(Context context, PredefinedMap map, MapRenderer renderer) throws IOException {
|
||||
ensureWorldmapDirectoryExists(context);
|
||||
|
||||
File file = getFileForMap(context, map, false);
|
||||
if (file.exists()) return;
|
||||
|
||||
Bitmap image = renderer.drawMap();
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
image.compress(Bitmap.CompressFormat.PNG, 70, fos);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
image.recycle();
|
||||
L.log("WorldMapController: Wrote " + file.getAbsolutePath());
|
||||
}
|
||||
|
||||
private static final class MapRenderer {
|
||||
private final PredefinedMap map;
|
||||
private final LayeredTileMap mapTiles;
|
||||
private final TileCollection cachedTiles;
|
||||
private final int tileSize;
|
||||
private final float scale;
|
||||
private final Paint mPaint = new Paint();
|
||||
|
||||
public MapRenderer(final WorldContext world, final PredefinedMap map, final LayeredTileMap mapTiles, final TileCollection cachedTiles) {
|
||||
this.map = map;
|
||||
this.mapTiles = mapTiles;
|
||||
this.cachedTiles = cachedTiles;
|
||||
this.tileSize = world.tileManager.tileSize;
|
||||
this.scale = (float) WORLDMAP_SCREENSHOT_TILESIZE / world.tileManager.tileSize;
|
||||
mapTiles.setColorFilter(mPaint, null, true);
|
||||
}
|
||||
|
||||
public Bitmap drawMap() {
|
||||
Bitmap image = Bitmap.createBitmap(map.size.width * WORLDMAP_SCREENSHOT_TILESIZE, map.size.height * WORLDMAP_SCREENSHOT_TILESIZE, Config.RGB_565);
|
||||
image.setDensity(Bitmap.DENSITY_NONE);
|
||||
Canvas canvas = new Canvas(image);
|
||||
canvas.scale(scale, scale);
|
||||
|
||||
synchronized (cachedTiles) {
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerBase);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerGround);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerObjects);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerAbove);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerTop);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private void tryDrawMapLayer(Canvas canvas, final MapLayer layer) {
|
||||
if (layer != null) drawMapLayer(canvas, layer);
|
||||
}
|
||||
|
||||
private void drawMapLayer(Canvas canvas, final MapLayer layer) {
|
||||
int py = 0;
|
||||
for (int y = 0; y < map.size.height; ++y, py += tileSize) {
|
||||
int px = 0;
|
||||
for (int x = 0; x < map.size.width; ++x, px += tileSize) {
|
||||
final int tile = layer.tiles[x][y];
|
||||
if (tile == 0) continue;
|
||||
cachedTiles.drawTile(canvas, tile, px, py, mPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ensureWorldmapDirectoryExists(Context context) throws IOException {
|
||||
File dir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
if (!dir.exists()) dir.mkdir();
|
||||
dir = new File(dir, Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
if (!dir.exists()) dir.mkdir();
|
||||
|
||||
File noMediaFile = new File(dir, ".nomedia");
|
||||
if (!noMediaFile.exists()) noMediaFile.createNewFile();
|
||||
}
|
||||
public static boolean fileForMapExists(Context context, PredefinedMap map) {
|
||||
if (map.lastSeenLayoutHash.length() > 0) {
|
||||
return getPngFile(context, map.name + '.' + map.lastSeenLayoutHash).exists();
|
||||
}
|
||||
return getPngFile(context, map.name).exists();
|
||||
}
|
||||
private static File getFileForMap(Context context, PredefinedMap map, boolean verifyFileExists) {
|
||||
if (map.lastSeenLayoutHash.length() > 0) {
|
||||
File fileWithHash = getPngFile(context, map.name + '.' + map.lastSeenLayoutHash);
|
||||
if (!verifyFileExists) return fileWithHash;
|
||||
else if (fileWithHash.exists()) return fileWithHash;
|
||||
}
|
||||
return getPngFile(context, map.name);
|
||||
}
|
||||
private static File getPngFile(Context context, String fileName) {
|
||||
return new File(getWorldmapDirectory(context), fileName + ".png");
|
||||
}
|
||||
private static File getWorldmapDirectory(Context context) {
|
||||
File dir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
return new File(dir, Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
}
|
||||
public static File getCombinedWorldMapFile(Context context, String segmentName) {
|
||||
return new File(getWorldmapDirectory(context), Constants.FILENAME_WORLDMAP_HTMLFILE_PREFIX + segmentName + Constants.FILENAME_WORLDMAP_HTMLFILE_SUFFIX);
|
||||
}
|
||||
|
||||
private static String getWorldMapSegmentAsHtml(Context context, Resources res, WorldContext world, String segmentName) {
|
||||
WorldMapSegment segment = world.maps.worldMapSegments.get(segmentName);
|
||||
|
||||
Map<String, File> displayedMapFilenamesPerMapName = new HashMap<String, File>(segment.maps.size());
|
||||
Coord offsetWorldmapTo = new Coord(999999, 999999);
|
||||
for (WorldMapSegmentMap map : segment.maps.values()) {
|
||||
PredefinedMap predefinedMap = world.maps.findPredefinedMap(map.mapName);
|
||||
if (predefinedMap == null) continue;
|
||||
if (!predefinedMap.visited) continue;
|
||||
File f = WorldMapController.getFileForMap(context, predefinedMap, true);
|
||||
if (!f.exists()) continue;
|
||||
displayedMapFilenamesPerMapName.put(map.mapName, f);
|
||||
|
||||
offsetWorldmapTo.x = Math.min(offsetWorldmapTo.x, map.worldPosition.x);
|
||||
offsetWorldmapTo.y = Math.min(offsetWorldmapTo.y, map.worldPosition.y);
|
||||
}
|
||||
|
||||
Coord bottomRight = new Coord(0, 0);
|
||||
|
||||
StringBuilder mapsAsHtml = new StringBuilder(1000);
|
||||
for (WorldMapSegmentMap segmentMap : segment.maps.values()) {
|
||||
File f = displayedMapFilenamesPerMapName.get(segmentMap.mapName);
|
||||
if (f == null) continue;
|
||||
|
||||
Size size = getMapSize(segmentMap, world);
|
||||
mapsAsHtml
|
||||
.append("<img src=\"")
|
||||
.append(f.getName())
|
||||
.append("\" id=\"")
|
||||
.append(segmentMap.mapName)
|
||||
.append("\" style=\"width:")
|
||||
.append(size.width * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; height:")
|
||||
.append(size.height * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; left:")
|
||||
.append((segmentMap.worldPosition.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; top:")
|
||||
.append((segmentMap.worldPosition.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px;\" />");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) mapsAsHtml.append('\n');
|
||||
|
||||
bottomRight.x = Math.max(bottomRight.x, segmentMap.worldPosition.x + size.width);
|
||||
bottomRight.y = Math.max(bottomRight.y, segmentMap.worldPosition.y + size.height);
|
||||
}
|
||||
Size worldmapSegmentSize = new Size(
|
||||
(bottomRight.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
,(bottomRight.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
);
|
||||
|
||||
StringBuilder namedAreasAsHtml = new StringBuilder(500);
|
||||
for (NamedWorldMapArea area : segment.namedAreas.values()) {
|
||||
CoordRect r = determineNamedAreaBoundary(area, segment, world, displayedMapFilenamesPerMapName.keySet());
|
||||
if (r == null) continue;
|
||||
namedAreasAsHtml
|
||||
.append("<div class=\"namedarea ")
|
||||
.append(area.type)
|
||||
.append("\" style=\"width:")
|
||||
.append(r.size.width * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; line-height:")
|
||||
.append(r.size.height * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; left:")
|
||||
.append((r.topLeft.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; top:")
|
||||
.append((r.topLeft.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px;\"><span>")
|
||||
.append(area.name)
|
||||
.append("</span></div>");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) namedAreasAsHtml.append('\n');
|
||||
}
|
||||
|
||||
return res.getString(R.string.worldmap_template)
|
||||
.replace("{{maps}}", mapsAsHtml.toString())
|
||||
.replace("{{areas}}", namedAreasAsHtml.toString())
|
||||
.replace("{{sizex}}", Integer.toString(worldmapSegmentSize.width))
|
||||
.replace("{{sizey}}", Integer.toString(worldmapSegmentSize.height))
|
||||
.replace("{{offsetx}}", Integer.toString(offsetWorldmapTo.x * WorldMapController.WORLDMAP_DISPLAY_TILESIZE))
|
||||
.replace("{{offsety}}", Integer.toString(offsetWorldmapTo.y * WorldMapController.WORLDMAP_DISPLAY_TILESIZE));
|
||||
}
|
||||
|
||||
private static Size getMapSize(WorldMapSegmentMap map, WorldContext world) {
|
||||
return world.maps.findPredefinedMap(map.mapName).size;
|
||||
}
|
||||
|
||||
private static CoordRect determineNamedAreaBoundary(NamedWorldMapArea area, WorldMapSegment segment, WorldContext world, Set<String> displayedMapNames) {
|
||||
Coord topLeft = null;
|
||||
Coord bottomRight = null;
|
||||
|
||||
for (String mapName : area.mapNames) {
|
||||
if (!displayedMapNames.contains(mapName)) continue;
|
||||
WorldMapSegmentMap map = segment.maps.get(mapName);
|
||||
Size size = getMapSize(map, world);
|
||||
if (topLeft == null) {
|
||||
topLeft = new Coord(map.worldPosition);
|
||||
} else {
|
||||
topLeft.x = Math.min(topLeft.x, map.worldPosition.x);
|
||||
topLeft.y = Math.min(topLeft.y, map.worldPosition.y);
|
||||
}
|
||||
if (bottomRight == null) {
|
||||
bottomRight = new Coord(map.worldPosition.x + size.width, map.worldPosition.y + size.height);
|
||||
} else {
|
||||
bottomRight.x = Math.max(bottomRight.x, map.worldPosition.x + size.width);
|
||||
bottomRight.y = Math.max(bottomRight.y, map.worldPosition.y + size.height);
|
||||
}
|
||||
}
|
||||
if (topLeft == null) return null;
|
||||
return new CoordRect(topLeft, new Size(bottomRight.x - topLeft.x, bottomRight.y - topLeft.y));
|
||||
}
|
||||
|
||||
public static void updateWorldMapSegment(Context context, Resources res, WorldContext world, String segmentName) throws IOException {
|
||||
String mapAsHtml = getWorldMapSegmentAsHtml(context, res, world, segmentName);
|
||||
File outputFile = getCombinedWorldMapFile(context, segmentName);
|
||||
PrintWriter pw = new PrintWriter(outputFile);
|
||||
pw.write(mapAsHtml);
|
||||
pw.close();
|
||||
}
|
||||
|
||||
public static boolean displayWorldMap(Context context, WorldContext world) {
|
||||
String worldMapSegmentName = world.maps.getWorldMapSegmentNameForMap(world.model.currentMaps.map.name);
|
||||
if (worldMapSegmentName == null) {
|
||||
Toast.makeText(context, context.getResources().getString(R.string.display_worldmap_not_available), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(context, DisplayWorldMapActivity.class);
|
||||
intent.putExtra("worldMapSegmentName", worldMapSegmentName);
|
||||
context.startActivity(intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,8 @@ import com.gpl.rpg.AndorsTrail.model.quest.Quest;
|
||||
|
||||
public final class GameStatistics {
|
||||
private int deaths = 0;
|
||||
private final HashMap<String, Integer> killedMonsters = new HashMap<String, Integer>();
|
||||
private final HashMap<String, Integer> killedMonstersByTypeID = new HashMap<String, Integer>();
|
||||
private final HashMap<String, Integer> killedMonstersByName = new HashMap<String, Integer>();
|
||||
private final HashMap<String, Integer> usedItems = new HashMap<String, Integer>();
|
||||
private int spentGold = 0;
|
||||
private boolean unlimitedSaves = true;
|
||||
@@ -33,10 +34,14 @@ public final class GameStatistics {
|
||||
this.startLives = startLives;
|
||||
}
|
||||
|
||||
public void addMonsterKill(String monsterTypeID) {
|
||||
if (!killedMonsters.containsKey(monsterTypeID)) killedMonsters.put(monsterTypeID, 1);
|
||||
else killedMonsters.put(monsterTypeID, killedMonsters.get(monsterTypeID) + 1);
|
||||
public void addMonsterKill(MonsterType monsterType) {
|
||||
// Track monster kills by type ID, for savegame file
|
||||
killedMonstersByTypeID.put(monsterType.id, killedMonstersByTypeID.getOrDefault((monsterType.id), 0) + 1);
|
||||
|
||||
// Also track by name, for statistics display (multiple IDs w/same name don't matter to player)
|
||||
killedMonstersByName.put(monsterType.name, killedMonstersByName.getOrDefault(monsterType.name, 0) + 1);
|
||||
}
|
||||
|
||||
public void addPlayerDeath(int lostExp) {
|
||||
++deaths;
|
||||
}
|
||||
@@ -68,30 +73,34 @@ public final class GameStatistics {
|
||||
public boolean isDead() { return !hasUnlimitedLives() && getLivesLeft() < 1; }
|
||||
|
||||
public int getNumberOfKillsForMonsterType(String monsterTypeID) {
|
||||
Integer v = killedMonsters.get(monsterTypeID);
|
||||
Integer v = killedMonstersByTypeID.get(monsterTypeID);
|
||||
if (v == null) return 0;
|
||||
return v;
|
||||
}
|
||||
|
||||
public int getNumberOfKillsForMonsterName(String monsterName) {
|
||||
Integer v = killedMonstersByName.get(monsterName);
|
||||
if (v == null) return 0;
|
||||
return v;
|
||||
}
|
||||
|
||||
public String getTop5MostCommonlyKilledMonsters(WorldContext world, Resources res) {
|
||||
if (killedMonsters.isEmpty()) return null;
|
||||
List<Entry<String, Integer>> entries = new ArrayList<Entry<String, Integer>>(killedMonsters.entrySet());
|
||||
if (killedMonstersByTypeID.isEmpty()) return null;
|
||||
List<Entry<String, Integer>> entries = new ArrayList<Entry<String, Integer>>(killedMonstersByName.entrySet());
|
||||
Collections.sort(entries, descendingValueComparator);
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
int i = 0;
|
||||
for (Entry<String, Integer> e : entries) {
|
||||
if (i++ >= 5) break;
|
||||
MonsterType t = world.monsterTypes.getMonsterType(e.getKey());
|
||||
if (t == null) continue;
|
||||
sb.append(res.getString(R.string.heroinfo_gamestats_name_and_qty, t.name, e.getValue())).append('\n');
|
||||
sb.append(res.getString(R.string.heroinfo_gamestats_name_and_qty, e.getKey(), e.getValue())).append('\n');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getMostPowerfulKilledMonster(WorldContext world) {
|
||||
if (killedMonsters.isEmpty()) return null;
|
||||
HashMap<String, Integer> expPerMonsterType = new HashMap<String, Integer>(killedMonsters.size());
|
||||
for (String monsterTypeID : killedMonsters.keySet()) {
|
||||
if (killedMonstersByTypeID.isEmpty()) return null;
|
||||
HashMap<String, Integer> expPerMonsterType = new HashMap<String, Integer>(killedMonstersByTypeID.size());
|
||||
for (String monsterTypeID : killedMonstersByTypeID.keySet()) {
|
||||
MonsterType t = world.monsterTypes.getMonsterType(monsterTypeID);
|
||||
expPerMonsterType.put(monsterTypeID, t != null ? t.exp : 0);
|
||||
}
|
||||
@@ -147,7 +156,7 @@ public final class GameStatistics {
|
||||
|
||||
public int getNumberOfKilledMonsters() {
|
||||
int result = 0;
|
||||
for (int v : killedMonsters.values()) result += v;
|
||||
for (int v : killedMonstersByTypeID.values()) result += v;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -172,8 +181,14 @@ public final class GameStatistics {
|
||||
if (type == null) continue;
|
||||
id = type.id;
|
||||
}
|
||||
this.killedMonsters.put(id, value);
|
||||
this.killedMonstersByTypeID.put(id, value);
|
||||
|
||||
// Also track by name, for statistics display (multiple IDs w/same name don't matter to player)
|
||||
MonsterType t = world.monsterTypes.getMonsterType(id);
|
||||
|
||||
if (t != null) killedMonstersByName.put(t.name, killedMonstersByName.getOrDefault(t.name, 0) + value);
|
||||
}
|
||||
|
||||
if (fileversion <= 17) return;
|
||||
|
||||
final int numItems = src.readInt();
|
||||
@@ -192,7 +207,7 @@ public final class GameStatistics {
|
||||
|
||||
public void writeToParcel(DataOutputStream dest) throws IOException {
|
||||
dest.writeInt(deaths);
|
||||
Set<Entry<String, Integer> > set = killedMonsters.entrySet();
|
||||
Set<Entry<String, Integer> > set = killedMonstersByTypeID.entrySet();
|
||||
dest.writeInt(set.size());
|
||||
for (Entry<String, Integer> e : set) {
|
||||
dest.writeUTF(e.getKey());
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user