mirror of
https://github.com/AndorsTrailRelease/andors-trail.git
synced 2026-01-22 03:09:26 +01:00
Compare commits
344 Commits
switch_to_
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
226459ddb8 | ||
|
|
a5d94c03e2 | ||
|
|
9d15d380a3 | ||
|
|
bff780c837 | ||
|
|
0c493952c8 | ||
|
|
82b904d176 | ||
|
|
111aca868c | ||
|
|
2171c16d47 | ||
|
|
acd4d84783 | ||
|
|
cc25cc97f1 | ||
|
|
93ecebc448 | ||
|
|
f5713a3eb2 | ||
|
|
90001bb4d6 | ||
|
|
357cab9b1e | ||
|
|
5ea272f286 | ||
|
|
0c876bd1c5 | ||
|
|
0ac2999694 | ||
|
|
49af3c4b6d | ||
|
|
2a54b31d31 | ||
|
|
64766ce50a | ||
|
|
311accfdd3 | ||
|
|
2b5bf2fa4a | ||
|
|
64342c96d7 | ||
|
|
f8649bb0a5 | ||
|
|
fde6608c26 | ||
|
|
3f339c14a2 | ||
|
|
922db05c4d | ||
|
|
b849de8b66 | ||
|
|
f798b29729 | ||
|
|
e58e7a2588 | ||
|
|
a1ef339831 | ||
|
|
2002d51f6b | ||
|
|
025283b70b | ||
|
|
577b1aa034 | ||
|
|
da637c0cc8 | ||
|
|
d026ff690a | ||
|
|
d14ed56669 | ||
|
|
64cfacb7ff | ||
|
|
98a800e070 | ||
|
|
35219c8e88 | ||
|
|
b636cad347 | ||
|
|
733328cd29 | ||
|
|
36db28f805 | ||
|
|
6d4c1c3c14 | ||
|
|
eadb95f8e8 | ||
|
|
014f67f270 | ||
|
|
cd8657adb4 | ||
|
|
c007fc4d1c | ||
|
|
7e6c864ba3 | ||
|
|
f2da8f767a | ||
|
|
bd856541d6 | ||
|
|
bdde2176d9 | ||
|
|
171893a2c1 | ||
|
|
c6c1d6d03d | ||
|
|
ec8b114782 | ||
|
|
aaecb8ae4a | ||
|
|
4e2e3b370c | ||
|
|
c14f8f84a0 | ||
|
|
13c8012710 | ||
|
|
3806d77b26 | ||
|
|
af94220715 | ||
|
|
af07c47832 | ||
|
|
322007e5ac | ||
|
|
af5cdb9d49 | ||
|
|
3ada8ceaa7 | ||
|
|
68fa0068dc | ||
|
|
7b5fc79375 | ||
|
|
5dfa750227 | ||
|
|
cbe0773310 | ||
|
|
72a19eeb80 | ||
|
|
a993cc5a08 | ||
|
|
83724ba408 | ||
|
|
a4cd8f7460 | ||
|
|
7a52bbb9f3 | ||
|
|
3552ff8a9f | ||
|
|
0e081f3319 | ||
|
|
1d94519e1c | ||
|
|
0bbc6adb4b | ||
|
|
b48ddd4999 | ||
|
|
be8dad981d | ||
|
|
f9708f48a4 | ||
|
|
155b01bdea | ||
|
|
19810b2099 | ||
|
|
c6886f7a3e | ||
|
|
3bea24f9cc | ||
|
|
4b8f5c4908 | ||
|
|
66d9618b1b | ||
|
|
488d6347d0 | ||
|
|
51fd0d0994 | ||
|
|
50833af145 | ||
|
|
ca7c2388aa | ||
|
|
8e7d6adca5 | ||
|
|
17edb96ff8 | ||
|
|
3f3869916c | ||
|
|
1d2fc7ade7 | ||
|
|
aa84e5a73d | ||
|
|
4ecf7d2dda | ||
|
|
dca1cb676c | ||
|
|
9a4f41eac2 | ||
|
|
23012b0d40 | ||
|
|
916134bd9b | ||
|
|
1d6777daae | ||
|
|
4793751ba8 | ||
|
|
185c0eaf7c | ||
|
|
4b50d13149 | ||
|
|
23b58c3e7c | ||
|
|
2d5ebc3b13 | ||
|
|
59e2e3035c | ||
|
|
6d5ddfdbfa | ||
|
|
f8ae18721f | ||
|
|
63bc7c3a4e | ||
|
|
8e72763314 | ||
|
|
9310d53362 | ||
|
|
a71dcc13a3 | ||
|
|
ea95f4ff87 | ||
|
|
f35167d112 | ||
|
|
9f935190f2 | ||
|
|
c11430cf6b | ||
|
|
8f97a27ab7 | ||
|
|
9e36f848dc | ||
|
|
b24d52b1da | ||
|
|
e2a9307560 | ||
|
|
e3ac804f61 | ||
|
|
fd504d2df5 | ||
|
|
0e615d3f11 | ||
|
|
47646457ab | ||
|
|
8e393b93d8 | ||
|
|
3289bd6fb1 | ||
|
|
23a331d655 | ||
|
|
112301c444 | ||
|
|
f50e4f1d38 | ||
|
|
d623c22b38 | ||
|
|
d11bf5b0aa | ||
|
|
e30f67e327 | ||
|
|
6946b1f2b3 | ||
|
|
96a1a5760a | ||
|
|
58b802e911 | ||
|
|
f9b095565b | ||
|
|
19817eb97d | ||
|
|
f46d2aedbf | ||
|
|
913b651953 | ||
|
|
5283eed28e | ||
|
|
deb824d50e | ||
|
|
6841d862e4 | ||
|
|
f94723b0cd | ||
|
|
ab41168736 | ||
|
|
2d73c4687a | ||
|
|
e454deb8b1 | ||
|
|
074891805a | ||
|
|
d2d32bc4ed | ||
|
|
22daeb0c33 | ||
|
|
db30253baf | ||
|
|
312cb7dec7 | ||
|
|
7befd27951 | ||
|
|
c1e3bfa7ed | ||
|
|
ddec991082 | ||
|
|
79e6fe7b65 | ||
|
|
25e36dc535 | ||
|
|
83c579a929 | ||
|
|
0c694115ee | ||
|
|
bf9723b0c1 | ||
|
|
b81bacb1fe | ||
|
|
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 | ||
|
|
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 | ||
|
|
4f1dd93ba6 | ||
|
|
737736dca2 | ||
|
|
0f32f09b0d | ||
|
|
324be2768c |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/AndorsTrail/.idea/workspace.xml
|
||||||
@@ -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
|
# Android ignores
|
||||||
|
app/src/main/res
|
||||||
|
app/src/main/assets
|
||||||
gen/
|
gen/
|
||||||
bin/
|
bin/
|
||||||
target/
|
target/
|
||||||
local.properties
|
local.properties
|
||||||
|
app/build/intermediates/
|
||||||
|
build/
|
||||||
|
debug/
|
||||||
|
release/
|
||||||
|
.gradle/
|
||||||
|
|
||||||
#IntelliJ
|
#IntelliJ
|
||||||
.idea/
|
.idea/
|
||||||
@@ -14,3 +21,35 @@ out/test/
|
|||||||
# Other
|
# Other
|
||||||
.metadata
|
.metadata
|
||||||
.svn/
|
.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/
|
||||||
|
|||||||
@@ -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>
|
|
||||||
|
|
||||||
52
AndorsTrail/app/build.gradle
Normal file
52
AndorsTrail/app/build.gradle
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 31
|
||||||
|
buildToolsVersion "30.0.3"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.gpl.rpg.AndorsTrail"
|
||||||
|
minSdkVersion 14
|
||||||
|
targetSdkVersion 31
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
manifestPlaceholders icon_name: 'icon', fileproviderPath: 'AndorsTrail'
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||||
|
}
|
||||||
|
debug {
|
||||||
|
manifestPlaceholders icon_name: 'icon_beta', fileproviderPath: 'AndorsTrail.beta2'
|
||||||
|
applicationIdSuffix 'beta2'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation 'com.android.support:support-v4:28.0.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
task copyRes(type: Copy) {
|
||||||
|
description "Copies the res folder to the modules res folder (& renames .tmx to .xml)"
|
||||||
|
from "${rootDir}/res"
|
||||||
|
into "${projectDir}/src/main/res"
|
||||||
|
rename "(.*)\\.tmx", "\$1.xml"
|
||||||
|
}
|
||||||
|
|
||||||
|
task copyTranslation(type: Copy) {
|
||||||
|
description("Copies the translation files to the modules translations folder")
|
||||||
|
from "${rootDir}/assets/translation"
|
||||||
|
into "${projectDir}/src/main/assets/translation"
|
||||||
|
}
|
||||||
|
|
||||||
|
task cleanup(type: Delete) {
|
||||||
|
description("Deletes the assets/translation and the res folder from the modules folder")
|
||||||
|
delete "${projectDir}/src/main/res", "${projectDir}/src/main/assets/translation"
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
preBuild.dependsOn project.tasks.copyRes
|
||||||
|
preBuild.dependsOn project.tasks.copyTranslation
|
||||||
|
clean.dependsOn project.tasks.cleanup
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<lint>
|
<lint>
|
||||||
<issue id="MissingTranslation" severity="ignore" />
|
<issue id="MissingTranslation" severity="ignore" />
|
||||||
<issue id="TypographyDashes" severity="ignore" />
|
<issue id="TypographyDashes" severity="ignore" />
|
||||||
@@ -1,79 +1,76 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<manifest
|
<manifest
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.gpl.rpg.AndorsTrail"
|
package="com.gpl.rpg.AndorsTrail"
|
||||||
android:versionCode="64"
|
android:versionCode="68"
|
||||||
android:versionName="0.7.17"
|
android:versionName="0.8.4"
|
||||||
android:installLocation="auto"
|
android:installLocation="auto"
|
||||||
>
|
>
|
||||||
<uses-sdk
|
|
||||||
android:minSdkVersion="4"
|
<supports-screens
|
||||||
android:targetSdkVersion="30"
|
android:smallScreens="true"
|
||||||
/>
|
android:normalScreens="true"
|
||||||
|
android:largeScreens="true"
|
||||||
<supports-screens
|
android:xlargeScreens="true"
|
||||||
android:smallScreens="true"
|
android:anyDensity="true"
|
||||||
android:normalScreens="true"
|
/>
|
||||||
android:largeScreens="true"
|
|
||||||
android:xlargeScreens="true"
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
android:anyDensity="true"
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
/>
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<application
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
android:name="com.gpl.rpg.AndorsTrail.AndorsTrailApplication"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:icon="@drawable/${icon_name}"
|
||||||
<application
|
android:description="@string/app_description"
|
||||||
android:name="com.gpl.rpg.AndorsTrail.AndorsTrailApplication"
|
android:allowBackup="true"
|
||||||
android:label="@string/app_name"
|
android:theme="@style/AndorsTrailTheme_Blue"
|
||||||
android:icon="@drawable/icon"
|
android:requestLegacyExternalStorage="true"
|
||||||
android:description="@string/app_description"
|
android:hasFragileUserData="true"
|
||||||
android:allowBackup="true"
|
android:preserveLegacyExternalStorage="true"
|
||||||
android:theme="@style/AndorsTrailTheme_Blue"
|
>
|
||||||
android:requestLegacyExternalStorage="true"
|
<activity
|
||||||
android:hasFragileUserData="true"
|
android:name="com.gpl.rpg.AndorsTrail.activity.StartScreenActivity"
|
||||||
android:preserveLegacyExternalStorage="true"
|
android:exported="true"
|
||||||
>
|
android:clearTaskOnLaunch="true"
|
||||||
<activity
|
>
|
||||||
android:name="com.gpl.rpg.AndorsTrail.activity.StartScreenActivity"
|
<intent-filter>
|
||||||
android:clearTaskOnLaunch="true"
|
<action android:name="android.intent.action.MAIN" />
|
||||||
>
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
<intent-filter>
|
</intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
</activity>
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<activity
|
||||||
</intent-filter>
|
android:name="com.gpl.rpg.AndorsTrail.activity.MainActivity"
|
||||||
</activity>
|
android:label="@string/app_name"
|
||||||
<activity
|
android:theme="@style/AndorsTrailTheme_Blue.NoBackground"
|
||||||
android:name="com.gpl.rpg.AndorsTrail.activity.MainActivity"
|
/>
|
||||||
android:label="@string/app_name"
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.HeroinfoActivity" />
|
||||||
android:theme="@style/AndorsTrailTheme_Blue.NoBackground"
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.MonsterInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||||
/>
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ItemInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.HeroinfoActivity" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.LevelUpActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.MonsterInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.MonsterEncounterActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ItemInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ConversationActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.LevelUpActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ShopActivity" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.MonsterEncounterActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.AboutActivity" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ConversationActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.LoadingActivity" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ShopActivity" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.Preferences" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.AboutActivity" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.LoadSaveActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.LoadingActivity" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ActorConditionInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.Preferences" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.BulkSelectionInterface" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.LoadSaveActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.SkillInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ActorConditionInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
<activity android:name="com.gpl.rpg.AndorsTrail.activity.DisplayWorldMapActivity" />
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.BulkSelectionInterface" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.SkillInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
<provider
|
||||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.DisplayWorldMapActivity" />
|
android:name="android.support.v4.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}.fileprovider"
|
||||||
<provider
|
android:grantUriPermissions="true"
|
||||||
android:name="android.support.v4.content.FileProvider"
|
android:exported="false">
|
||||||
android:authorities="com.gpl.rpg.AndorsTrail.fileprovider"
|
<meta-data
|
||||||
android:grantUriPermissions="true"
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
android:exported="false">
|
android:resource="@xml/fileprovider" />
|
||||||
<meta-data
|
</provider>
|
||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
</application>
|
||||||
android:resource="@xml/fileprovider" />
|
|
||||||
</provider>
|
</manifest>
|
||||||
</application>
|
|
||||||
|
|
||||||
</manifest>
|
|
||||||
@@ -28,11 +28,11 @@ public final class AndorsTrailApplication extends Application {
|
|||||||
public static final boolean DEVELOPMENT_FASTSPEED = false;
|
public static final boolean DEVELOPMENT_FASTSPEED = false;
|
||||||
public static final boolean DEVELOPMENT_VALIDATEDATA = false;
|
public static final boolean DEVELOPMENT_VALIDATEDATA = false;
|
||||||
public static final boolean DEVELOPMENT_DEBUGMESSAGES = false;
|
public static final boolean DEVELOPMENT_DEBUGMESSAGES = false;
|
||||||
public static final String CURRENT_VERSION_DISPLAY = "0.7.17";
|
public static final String CURRENT_VERSION_DISPLAY = "0.8.4";
|
||||||
public static final boolean IS_RELEASE_VERSION = !CURRENT_VERSION_DISPLAY.matches(".*[a-d].*");
|
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 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 DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION = 999;
|
||||||
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION : 64;
|
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION : 68;
|
||||||
|
|
||||||
private final AndorsTrailPreferences preferences = new AndorsTrailPreferences();
|
private final AndorsTrailPreferences preferences = new AndorsTrailPreferences();
|
||||||
private WorldContext world = new WorldContext();
|
private WorldContext world = new WorldContext();
|
||||||
@@ -46,14 +46,15 @@ import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
|||||||
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
|
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
|
||||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||||
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory.CustomDialog;
|
||||||
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
||||||
|
|
||||||
public final class Dialogs {
|
public final class Dialogs {
|
||||||
|
|
||||||
private static void showDialogAndPause(Dialog d, final ControllerContext context) {
|
private static void showDialogAndPause(CustomDialog d, final ControllerContext context) {
|
||||||
showDialogAndPause(d, context, null);
|
showDialogAndPause(d, context, null);
|
||||||
}
|
}
|
||||||
private static void showDialogAndPause(Dialog d, final ControllerContext context, final OnDismissListener onDismiss) {
|
private static void showDialogAndPause(CustomDialog d, final ControllerContext context, final OnDismissListener onDismiss) {
|
||||||
context.gameRoundController.pause();
|
context.gameRoundController.pause();
|
||||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -195,7 +196,7 @@ public final class Dialogs {
|
|||||||
// itemList.setPadding(20, 0, 20, 20);
|
// itemList.setPadding(20, 0, 20, 20);
|
||||||
itemList.setAdapter(new ItemContainerAdapter(mainActivity, world.tileManager, combinedLoot.items, world.model.player));
|
itemList.setAdapter(new ItemContainerAdapter(mainActivity, world.tileManager, combinedLoot.items, world.model.player));
|
||||||
|
|
||||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
final CustomDialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||||
mainActivity.getResources().getString(title),
|
mainActivity.getResources().getString(title),
|
||||||
mainActivity.getResources().getDrawable(R.drawable.ui_icon_equipment),
|
mainActivity.getResources().getDrawable(R.drawable.ui_icon_equipment),
|
||||||
msg,
|
msg,
|
||||||
@@ -249,7 +250,7 @@ public final class Dialogs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void showHeroDied(final MainActivity mainActivity, final ControllerContext controllers) {
|
public static void showHeroDied(final MainActivity mainActivity, final ControllerContext controllers) {
|
||||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
final CustomDialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||||
mainActivity.getResources().getString(R.string.dialog_game_over_title),
|
mainActivity.getResources().getString(R.string.dialog_game_over_title),
|
||||||
mainActivity.getResources().getDrawable(R.drawable.ui_icon_combat),
|
mainActivity.getResources().getDrawable(R.drawable.ui_icon_combat),
|
||||||
mainActivity.getResources().getString(R.string.dialog_game_over_text),
|
mainActivity.getResources().getString(R.string.dialog_game_over_text),
|
||||||
@@ -286,7 +287,7 @@ public final class Dialogs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void showConfirmRest(final Activity currentActivity, final ControllerContext controllerContext, final MapObject area) {
|
public static void showConfirmRest(final Activity currentActivity, final ControllerContext controllerContext, final MapObject area) {
|
||||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
final CustomDialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||||
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
||||||
null,
|
null,
|
||||||
currentActivity.getResources().getString(R.string.dialog_rest_confirm_message),
|
currentActivity.getResources().getString(R.string.dialog_rest_confirm_message),
|
||||||
@@ -310,7 +311,7 @@ public final class Dialogs {
|
|||||||
// .setMessage(R.string.dialog_rest_message)
|
// .setMessage(R.string.dialog_rest_message)
|
||||||
// .setNeutralButton(android.R.string.ok, null)
|
// .setNeutralButton(android.R.string.ok, null)
|
||||||
// .create();
|
// .create();
|
||||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
final CustomDialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||||
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
||||||
null,
|
null,
|
||||||
currentActivity.getResources().getString(R.string.dialog_rest_message),
|
currentActivity.getResources().getString(R.string.dialog_rest_message),
|
||||||
@@ -336,7 +337,7 @@ public final class Dialogs {
|
|||||||
text += currentActivity.getResources().getString(R.string.dialog_newversion_permission_information);
|
text += currentActivity.getResources().getString(R.string.dialog_newversion_permission_information);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
final CustomDialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||||
currentActivity.getResources().getString(R.string.dialog_newversion_title),
|
currentActivity.getResources().getString(R.string.dialog_newversion_title),
|
||||||
null,
|
null,
|
||||||
text,
|
text,
|
||||||
@@ -371,7 +372,7 @@ public final class Dialogs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!world.model.statistics.hasUnlimitedSaves()) {
|
if (!world.model.statistics.hasUnlimitedSaves()) {
|
||||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
final CustomDialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||||
mainActivity.getResources().getString(R.string.menu_save_switch_character_title),
|
mainActivity.getResources().getString(R.string.menu_save_switch_character_title),
|
||||||
null,
|
null,
|
||||||
mainActivity.getResources().getString(R.string.menu_save_switch_character),
|
mainActivity.getResources().getString(R.string.menu_save_switch_character),
|
||||||
@@ -460,7 +461,7 @@ public final class Dialogs {
|
|||||||
itemList.setAdapter(new ArrayAdapter<String>(context, R.layout.combatlog_row, android.R.id.text1, combatLogMessages));
|
itemList.setAdapter(new ArrayAdapter<String>(context, R.layout.combatlog_row, android.R.id.text1, combatLogMessages));
|
||||||
view = itemList;
|
view = itemList;
|
||||||
|
|
||||||
final Dialog d = CustomDialogFactory.createDialog(context,
|
final CustomDialog d = CustomDialogFactory.createDialog(context,
|
||||||
context.getResources().getString(R.string.combat_log_title),
|
context.getResources().getString(R.string.combat_log_title),
|
||||||
context.getResources().getDrawable(R.drawable.ui_icon_combat),
|
context.getResources().getDrawable(R.drawable.ui_icon_combat),
|
||||||
null,
|
null,
|
||||||
@@ -23,6 +23,7 @@ import com.gpl.rpg.AndorsTrail.controller.ItemController;
|
|||||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||||
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory.CustomDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ejwessel
|
* @author ejwessel
|
||||||
@@ -206,7 +207,7 @@ public final class BulkSelectionInterface extends AndorsTrailBaseActivity implem
|
|||||||
// })
|
// })
|
||||||
// .setNegativeButton(android.R.string.no, null)
|
// .setNegativeButton(android.R.string.no, null)
|
||||||
// .show();
|
// .show();
|
||||||
final Dialog d = CustomDialogFactory.createDialog(v.getContext(),
|
final CustomDialog d = CustomDialogFactory.createDialog(v.getContext(),
|
||||||
v.getContext().getResources().getString(R.string.bulkselection_sell_confirmation_title),
|
v.getContext().getResources().getString(R.string.bulkselection_sell_confirmation_title),
|
||||||
v.getContext().getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
v.getContext().getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||||
message,
|
message,
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,876 @@
|
|||||||
|
package com.gpl.rpg.AndorsTrail.activity;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
|
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;
|
||||||
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory.CustomDialog;
|
||||||
|
|
||||||
|
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 exportImportContainer = (ViewGroup) findViewById(R.id.loadsave_export_import_save_container);
|
||||||
|
|
||||||
|
|
||||||
|
addSavegameSlotButtons(slotList, params, Savegames.getUsedSavegameSlots(this));
|
||||||
|
|
||||||
|
checkAndRequestPermissions();
|
||||||
|
|
||||||
|
if (!isLoading) {
|
||||||
|
createNewSlot.setTag(SLOT_NUMBER_CREATE_NEW_SLOT);
|
||||||
|
createNewSlot.setOnClickListener(this);
|
||||||
|
newSlotContainer.setVisibility(View.VISIBLE);
|
||||||
|
exportImportContainer.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
newSlotContainer.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
exportSaves.setOnClickListener(this);
|
||||||
|
importSaves.setOnClickListener(this);
|
||||||
|
importWorldmap.setOnClickListener(this);
|
||||||
|
exportImportContainer.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
boolean hasSavegames = !Savegames.getUsedSavegameSlots(this).isEmpty();
|
||||||
|
exportSaves.setEnabled(hasSavegames);
|
||||||
|
} else {
|
||||||
|
exportImportContainer.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int READ_EXTERNAL_STORAGE_REQUEST = 1;
|
||||||
|
private static final int WRITE_EXTERNAL_STORAGE_REQUEST = 2;
|
||||||
|
|
||||||
|
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 cancelLoadSaveActivity(int slot) {
|
||||||
|
completeLoadSaveActivity(slot, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void completeLoadSaveActivity(int slot) {
|
||||||
|
completeLoadSaveActivity(slot, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void completeLoadSaveActivity(int slot, boolean success) {
|
||||||
|
Intent i = new Intent();
|
||||||
|
if (slot == SLOT_NUMBER_CREATE_NEW_SLOT) {
|
||||||
|
slot = getFirstFreeSlot();
|
||||||
|
} else if (slot == SLOT_NUMBER_EXPORT_SAVEGAMES
|
||||||
|
|| slot == SLOT_NUMBER_IMPORT_SAVEGAMES
|
||||||
|
|| slot == SLOT_NUMBER_IMPORT_WORLDMAP) {
|
||||||
|
i.putExtra("import_export", true);
|
||||||
|
|
||||||
|
if (slot == SLOT_NUMBER_IMPORT_WORLDMAP) {
|
||||||
|
i.putExtra("import_worldmap", true);
|
||||||
|
}
|
||||||
|
if (slot == SLOT_NUMBER_IMPORT_SAVEGAMES) {
|
||||||
|
i.putExtra("import_savegames", true);
|
||||||
|
}
|
||||||
|
if (slot == SLOT_NUMBER_EXPORT_SAVEGAMES) {
|
||||||
|
i.putExtra("export", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (slot < SLOT_NUMBER_FIRST_SLOT) {
|
||||||
|
slot = SLOT_NUMBER_FIRST_SLOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
i.putExtra("slot", slot);
|
||||||
|
if (success) {
|
||||||
|
setResult(Activity.RESULT_OK, i);
|
||||||
|
} else {
|
||||||
|
setResult(Activity.RESULT_CANCELED, i);
|
||||||
|
}
|
||||||
|
LoadSaveActivity.this.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getFirstFreeSlot() {
|
||||||
|
int slot;
|
||||||
|
List<Integer> usedSlots = Savegames.getUsedSavegameSlots(this);
|
||||||
|
if (usedSlots.isEmpty()) {
|
||||||
|
slot = SLOT_NUMBER_FIRST_SLOT;
|
||||||
|
} else {
|
||||||
|
slot = Collections.max(usedSlots) + 1;
|
||||||
|
}
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.P) {
|
||||||
|
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 CustomDialog 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
|
||||||
|
|
||||||
|
//region Export
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
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 target = DocumentFile.fromTreeUri(context, uri);
|
||||||
|
if (target == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File[] files = storageDir.listFiles();
|
||||||
|
if (files == null) {
|
||||||
|
showErrorExportingSaveGamesUnknown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean hasExistingFiles = false;
|
||||||
|
for (File file : files) {
|
||||||
|
String fileName = file.getName();
|
||||||
|
|
||||||
|
DocumentFile existingFile = target.findFile(fileName);
|
||||||
|
if (existingFile != null) {
|
||||||
|
hasExistingFiles = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasExistingFiles) {
|
||||||
|
showConfirmOverwriteByExportQuestion(resolver, target, files);
|
||||||
|
} else {
|
||||||
|
exportSaveGamesFolderContentToFolder(target, files);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void exportSaveGamesFolderContentToFolder(DocumentFile target, File[] files) {
|
||||||
|
DocumentFile[] sourceFiles = new DocumentFile[files.length];
|
||||||
|
|
||||||
|
File[] worldmapFiles = null;
|
||||||
|
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
File file = files[i];
|
||||||
|
if (file.isFile()) {
|
||||||
|
sourceFiles[i] = DocumentFile.fromFile(file);
|
||||||
|
} else if (file.isDirectory() && Objects.equals(file.getName(),
|
||||||
|
Constants.FILENAME_WORLDMAP_DIRECTORY)) {
|
||||||
|
worldmapFiles = file.listFiles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Context context = this;
|
||||||
|
File[] finalWorldmapFiles = worldmapFiles;
|
||||||
|
CopyFilesToExternalFolder(target, sourceFiles, context, finalWorldmapFiles);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void CopyFilesToExternalFolder(DocumentFile target,
|
||||||
|
DocumentFile[] sourceFiles,
|
||||||
|
Context context,
|
||||||
|
File[] finalWorldmapFiles) {
|
||||||
|
AndroidStorage.copyDocumentFilesToDirAsync(sourceFiles,
|
||||||
|
context,
|
||||||
|
target,
|
||||||
|
getString(R.string.loadsave_exporting_savegames),
|
||||||
|
(success) -> {
|
||||||
|
if (success) {
|
||||||
|
CopyWorldmapFilesAsZip(target,
|
||||||
|
context,
|
||||||
|
finalWorldmapFiles);
|
||||||
|
} else {
|
||||||
|
completeLoadSaveActivity(
|
||||||
|
SLOT_NUMBER_EXPORT_SAVEGAMES,
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void CopyWorldmapFilesAsZip(DocumentFile target,
|
||||||
|
Context context,
|
||||||
|
File[] finalWorldmapFiles) {
|
||||||
|
AndroidStorage.createZipDocumentFileFromFilesAsync(finalWorldmapFiles,
|
||||||
|
context,
|
||||||
|
target,
|
||||||
|
Constants.FILENAME_WORLDMAP_DIRECTORY,
|
||||||
|
getString(R.string.loadsave_exporting_worldmap),
|
||||||
|
(successWorldmap) -> completeLoadSaveActivity(
|
||||||
|
SLOT_NUMBER_EXPORT_SAVEGAMES,
|
||||||
|
successWorldmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
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 = AndorsTrailApplication.getApplicationFromActivity(this)
|
||||||
|
.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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void importSaveGames(ContentResolver resolver,
|
||||||
|
DocumentFile appSavegameFolder,
|
||||||
|
List<DocumentFile> saveFiles) {
|
||||||
|
int size = saveFiles.size();
|
||||||
|
DocumentFile[] sources = new DocumentFile[size];
|
||||||
|
DocumentFile[] targets = new DocumentFile[size];
|
||||||
|
|
||||||
|
boolean saveAsNew = false;
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
DocumentFile file = saveFiles.get(i);
|
||||||
|
if (file == null) {//null is value a marker that the next should be saved as new
|
||||||
|
saveAsNew = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int slot = getSlotFromSavegameFileName(file.getName());
|
||||||
|
if (slot == -1) {
|
||||||
|
//invalid file name
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saveAsNew) {
|
||||||
|
slot = getFirstFreeSlot();
|
||||||
|
saveAsNew = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String targetName = Savegames.getSlotFileName(slot);
|
||||||
|
sources[i] = file;
|
||||||
|
targets[i] = getOrCreateDocumentFile(appSavegameFolder, targetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
AndroidStorage.copyDocumentFilesFromToAsync(sources,
|
||||||
|
this,
|
||||||
|
targets,
|
||||||
|
getString(R.string.loadsave_importing_savegames),
|
||||||
|
(sucess) -> completeLoadSaveActivity(
|
||||||
|
SLOT_NUMBER_IMPORT_SAVEGAMES,
|
||||||
|
sucess));
|
||||||
|
}
|
||||||
|
|
||||||
|
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)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
String slotStr = fileName.substring(Constants.FILENAME_SAVEGAME_FILENAME_PREFIX.length());
|
||||||
|
|
||||||
|
int slot;
|
||||||
|
try {
|
||||||
|
slot = Integer.parseInt(slotStr);
|
||||||
|
return slot;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void importWorldmap(Intent data) {
|
||||||
|
Uri uri = data.getData();
|
||||||
|
|
||||||
|
Context context = AndorsTrailApplication.getApplicationFromActivity(this).getApplicationContext();
|
||||||
|
|
||||||
|
DocumentFile chosenZip = DocumentFile.fromSingleUri(context, uri);
|
||||||
|
if (chosenZip == null || !chosenZip.isFile()) {
|
||||||
|
showErrorImportingWorldmapWrongDirectory();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String chosenZipName = chosenZip.getName();
|
||||||
|
if (!chosenZipName.startsWith(Constants.FILENAME_WORLDMAP_DIRECTORY)) {
|
||||||
|
showErrorImportingWorldmapWrongDirectory();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File ownWorldmapFolder = getOwnWorldmapFolder(context);
|
||||||
|
|
||||||
|
|
||||||
|
AndroidStorage.unzipDocumentFileToDirectoryAsync(chosenZip,
|
||||||
|
this,
|
||||||
|
ownWorldmapFolder,
|
||||||
|
false,
|
||||||
|
getString(R.string.loadsave_importing_worldmap),
|
||||||
|
(success) -> completeLoadSaveActivity(
|
||||||
|
SLOT_NUMBER_IMPORT_WORLDMAP,
|
||||||
|
success));
|
||||||
|
}
|
||||||
|
|
||||||
|
private File getOwnWorldmapFolder(Context context) {
|
||||||
|
File storageDir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||||
|
File ownWorldmapFolder = null;
|
||||||
|
for (File f : storageDir.listFiles()) {
|
||||||
|
if (f.getName().equals(Constants.FILENAME_WORLDMAP_DIRECTORY)) {
|
||||||
|
ownWorldmapFolder = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ownWorldmapFolder == null) {
|
||||||
|
ownWorldmapFolder = new File(storageDir, Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||||
|
ownWorldmapFolder.mkdir();
|
||||||
|
}
|
||||||
|
return ownWorldmapFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void clickExportSaveGames() {
|
||||||
|
showStartExportInfo(view -> startActivityForResult(AndroidStorage.getNewOpenDirectoryIntent(),
|
||||||
|
-SLOT_NUMBER_EXPORT_SAVEGAMES));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void clickImportSaveGames() {
|
||||||
|
showStartImportSavesInfo(view -> startActivityForResult(AndroidStorage.getNewSelectMultipleSavegameFilesIntent(),
|
||||||
|
-SLOT_NUMBER_IMPORT_SAVEGAMES));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void clickImportWorldmap() {
|
||||||
|
showStartImportWorldmapInfo(view -> startActivityForResult(AndroidStorage.getNewSelectZipIntent(),
|
||||||
|
-SLOT_NUMBER_IMPORT_WORLDMAP));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void showConfirmOverwriteByExportQuestion(ContentResolver resolver,
|
||||||
|
DocumentFile targetFolder,
|
||||||
|
File[] files) {
|
||||||
|
final CustomDialog 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(targetFolder, files));
|
||||||
|
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||||
|
|
||||||
|
CustomDialogFactory.show(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
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_file_exists_question);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append('\n');
|
||||||
|
int amount = alreadyExistingFiles.size();
|
||||||
|
|
||||||
|
Context context = AndorsTrailApplication.getApplicationFromActivity(this).getApplicationContext();
|
||||||
|
|
||||||
|
ArrayList<CustomDialog> dialogs = new ArrayList<>(amount);
|
||||||
|
|
||||||
|
for (int i = 0; i < amount; i++) {
|
||||||
|
DocumentFile alreadyExistingFile = alreadyExistingFiles.get(i);
|
||||||
|
int slot = getSlotFromSavegameFileName(alreadyExistingFile.getName());
|
||||||
|
FileHeader existingFileHeader = Savegames.quickload(context, slot);
|
||||||
|
FileHeader importedFileHeader = null;
|
||||||
|
try (InputStream stream = resolver.openInputStream(alreadyExistingFile.getUri());
|
||||||
|
DataInputStream dataStream = new DataInputStream(stream)) {
|
||||||
|
importedFileHeader = new FileHeader(dataStream, true);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
continue;
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder messageSb = new StringBuilder();
|
||||||
|
String existingFileDescription = getString(R.string.loadsave_import_existing_description,
|
||||||
|
Integer.toString(slot),
|
||||||
|
existingFileHeader.describe());
|
||||||
|
String importedFileDescription = getString(R.string.loadsave_import_imported_description,
|
||||||
|
Integer.toString(slot),
|
||||||
|
importedFileHeader.describe());
|
||||||
|
messageSb.append(getString(R.string.loadsave_import_file_exists_question,
|
||||||
|
existingFileDescription,
|
||||||
|
importedFileDescription));
|
||||||
|
|
||||||
|
|
||||||
|
String m = messageSb.toString();
|
||||||
|
CustomDialog dialog = CustomDialogFactory.createDialog(this,
|
||||||
|
title,
|
||||||
|
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||||
|
m,
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true);
|
||||||
|
|
||||||
|
CustomDialogFactory.addButton(dialog, R.string.loadsave_import_option_keep_existing, v -> {
|
||||||
|
//do nothing
|
||||||
|
GoToNextConflictOrFinish(resolver, appSavegameFolder, newFiles, dialogs);
|
||||||
|
});
|
||||||
|
|
||||||
|
CustomDialogFactory.addButton(dialog, R.string.loadsave_import_option_keep_imported, v -> {
|
||||||
|
newFiles.add(alreadyExistingFile);
|
||||||
|
GoToNextConflictOrFinish(resolver, appSavegameFolder, newFiles, dialogs);
|
||||||
|
});
|
||||||
|
|
||||||
|
CustomDialogFactory.addButton(dialog, R.string.loadsave_import_option_add_as_new, v -> {
|
||||||
|
newFiles.add(null);//add a null element as marker to know later if the next file
|
||||||
|
// should be imported as new or overwrite the existing one
|
||||||
|
newFiles.add(alreadyExistingFile);
|
||||||
|
GoToNextConflictOrFinish(resolver, appSavegameFolder, newFiles, dialogs);
|
||||||
|
});
|
||||||
|
|
||||||
|
CustomDialogFactory.addCancelButton(dialog, android.R.string.cancel);
|
||||||
|
CustomDialogFactory.setCancelListener(dialog, v -> {
|
||||||
|
completeLoadSaveActivity(SLOT_NUMBER_IMPORT_SAVEGAMES, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogs.add(dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
GoToNextConflictOrFinish(resolver, appSavegameFolder, newFiles, dialogs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void GoToNextConflictOrFinish(ContentResolver resolver,
|
||||||
|
DocumentFile appSavegameFolder,
|
||||||
|
List<DocumentFile> newFiles,
|
||||||
|
ArrayList<CustomDialog> dialogs) {
|
||||||
|
if (dialogs.stream().count() > 0) {
|
||||||
|
CustomDialog d = dialogs.remove(0);
|
||||||
|
CustomDialogFactory.show(d);
|
||||||
|
} else {
|
||||||
|
importSaveGames(resolver, appSavegameFolder, newFiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
|
if (resultCode != Activity.RESULT_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
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
|
||||||
|
|
||||||
|
//region Import/Export
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void showStartExportInfo(OnClickListener onOk) {
|
||||||
|
final CustomDialog d = CustomDialogFactory.createDialog(this,
|
||||||
|
getString(R.string.loadsave_export),
|
||||||
|
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||||
|
getString(R.string.loadsave_export_info),
|
||||||
|
null,
|
||||||
|
true);
|
||||||
|
CustomDialogFactory.addButton(d, android.R.string.yes, onOk);
|
||||||
|
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||||
|
CustomDialogFactory.show(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void showStartImportSavesInfo(OnClickListener onOk) {
|
||||||
|
final CustomDialog d = CustomDialogFactory.createDialog(this,
|
||||||
|
getString(R.string.loadsave_import_save),
|
||||||
|
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||||
|
getString(R.string.loadsave_import_save_info),
|
||||||
|
null,
|
||||||
|
true);
|
||||||
|
CustomDialogFactory.addButton(d, android.R.string.yes, onOk);
|
||||||
|
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||||
|
CustomDialogFactory.show(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||||
|
private void showStartImportWorldmapInfo(OnClickListener onOk) {
|
||||||
|
final CustomDialog d = CustomDialogFactory.createDialog(this,
|
||||||
|
getString(R.string.loadsave_import_worldmap),
|
||||||
|
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||||
|
getString(R.string.loadsave_import_worldmap_info),
|
||||||
|
null,
|
||||||
|
true);
|
||||||
|
CustomDialogFactory.addButton(d, android.R.string.yes, onOk);
|
||||||
|
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||||
|
CustomDialogFactory.show(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showErrorImportingWorldmapWrongDirectory() {
|
||||||
|
final CustomDialog d = CustomDialogFactory.createErrorDialog(this,
|
||||||
|
getString(R.string.loadsave_import_worldmap_unsuccessfull),
|
||||||
|
getString(R.string.loadsave_import_worldmap_wrong_file));
|
||||||
|
CustomDialogFactory.show(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showErrorExportingSaveGamesUnknown() {
|
||||||
|
final CustomDialog d = CustomDialogFactory.createErrorDialog(this,
|
||||||
|
getString(R.string.loadsave_export_unsuccessfull),
|
||||||
|
getString(R.string.loadsave_export_error_unknown));
|
||||||
|
CustomDialogFactory.show(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
private void showErrorLoadingEmptySlot() {
|
||||||
|
final CustomDialog 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 CustomDialog 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 CustomDialog 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
|
||||||
|
|
||||||
|
}
|
||||||
@@ -20,11 +20,12 @@ import com.gpl.rpg.AndorsTrail.savegames.Savegames;
|
|||||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||||
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
||||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||||
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory.CustomDialog;
|
||||||
|
|
||||||
public final class LoadingActivity extends AndorsTrailBaseActivity implements OnResourcesLoadedListener, OnSceneLoadedListener {
|
public final class LoadingActivity extends AndorsTrailBaseActivity implements OnResourcesLoadedListener, OnSceneLoadedListener {
|
||||||
|
|
||||||
private WorldSetup setup;
|
private WorldSetup setup;
|
||||||
private Dialog progressDialog;
|
private CustomDialog progressDialog;
|
||||||
private CloudsAnimatorView clouds_back, clouds_mid, clouds_front;
|
private CloudsAnimatorView clouds_back, clouds_mid, clouds_front;
|
||||||
boolean loaded = false;
|
boolean loaded = false;
|
||||||
|
|
||||||
@@ -165,7 +166,7 @@ public final class LoadingActivity extends AndorsTrailBaseActivity implements On
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showLoadingFailedDialog(int messageResourceID) {
|
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);
|
final CustomDialog 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.addDismissButton(d, android.R.string.ok);
|
||||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -43,6 +43,7 @@ import com.gpl.rpg.AndorsTrail.util.Coord;
|
|||||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||||
import com.gpl.rpg.AndorsTrail.view.CombatView;
|
import com.gpl.rpg.AndorsTrail.view.CombatView;
|
||||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||||
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory.CustomDialog;
|
||||||
import com.gpl.rpg.AndorsTrail.view.DisplayActiveActorConditionIcons;
|
import com.gpl.rpg.AndorsTrail.view.DisplayActiveActorConditionIcons;
|
||||||
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
||||||
import com.gpl.rpg.AndorsTrail.view.MainView;
|
import com.gpl.rpg.AndorsTrail.view.MainView;
|
||||||
@@ -247,7 +248,7 @@ public final class MainActivity
|
|||||||
final ItemContainerAdapter inventoryListAdapter = new QuickslotsItemContainerAdapter(lv.getContext(), world.tileManager, world.model.player.inventory.usableItems(), world.model.player, wornTiles);
|
final ItemContainerAdapter inventoryListAdapter = new QuickslotsItemContainerAdapter(lv.getContext(), world.tileManager, world.model.player.inventory.usableItems(), world.model.player, wornTiles);
|
||||||
lv.setAdapter(inventoryListAdapter);
|
lv.setAdapter(inventoryListAdapter);
|
||||||
|
|
||||||
final Dialog d = CustomDialogFactory.createDialog(v.getContext(),
|
final CustomDialog d = CustomDialogFactory.createDialog(v.getContext(),
|
||||||
v.getResources().getString(R.string.inventory_assign),
|
v.getResources().getString(R.string.inventory_assign),
|
||||||
v.getResources().getDrawable(R.drawable.ui_icon_equipment),
|
v.getResources().getDrawable(R.drawable.ui_icon_equipment),
|
||||||
v.getResources().getString(R.string.inventory_selectitem), view, false);
|
v.getResources().getString(R.string.inventory_selectitem), view, false);
|
||||||
@@ -30,6 +30,7 @@ public final class MonsterInfoActivity extends AndorsTrailBaseActivity {
|
|||||||
private RangeBar hp;
|
private RangeBar hp;
|
||||||
private ViewGroup monsterinfo_container;
|
private ViewGroup monsterinfo_container;
|
||||||
private TextView monsterinfo_max_ap;
|
private TextView monsterinfo_max_ap;
|
||||||
|
private TextView monsterinfo_killcount;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,6 +48,7 @@ public final class MonsterInfoActivity extends AndorsTrailBaseActivity {
|
|||||||
monsterinfo_title = (TextView) findViewById(R.id.monsterinfo_title);
|
monsterinfo_title = (TextView) findViewById(R.id.monsterinfo_title);
|
||||||
monsterinfo_difficulty = (TextView) findViewById(R.id.monsterinfo_difficulty);
|
monsterinfo_difficulty = (TextView) findViewById(R.id.monsterinfo_difficulty);
|
||||||
monsterinfo_max_ap = (TextView) findViewById(R.id.monsterinfo_max_ap);
|
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);
|
Button b = (Button) findViewById(R.id.monsterinfo_close);
|
||||||
b.setOnClickListener(new OnClickListener() {
|
b.setOnClickListener(new OnClickListener() {
|
||||||
@@ -94,6 +96,7 @@ public final class MonsterInfoActivity extends AndorsTrailBaseActivity {
|
|||||||
false);
|
false);
|
||||||
hp.update(monster.getMaxHP(), monster.getCurrentHP());
|
hp.update(monster.getMaxHP(), monster.getCurrentHP());
|
||||||
monsterinfo_max_ap.setText(Integer.toString(monster.getMaxAP()));
|
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) {
|
public static int getMonsterDifficultyResource(ControllerContext controllerContext, Monster monster) {
|
||||||
@@ -11,6 +11,7 @@ import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
|||||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||||
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
||||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||||
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory.CustomDialog;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@@ -114,7 +115,7 @@ public final class StartScreenActivity extends AndorsTrailBaseFragmentActivity i
|
|||||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||||
if (grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
|
if (grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|
||||||
final Dialog d = CustomDialogFactory.createDialog(this,
|
final CustomDialog d = CustomDialogFactory.createDialog(this,
|
||||||
getResources().getString(R.string.dialog_permission_information_title),
|
getResources().getString(R.string.dialog_permission_information_title),
|
||||||
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||||
getResources().getString(R.string.dialog_permission_information),
|
getResources().getString(R.string.dialog_permission_information),
|
||||||
@@ -38,25 +38,26 @@ import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
|||||||
import com.gpl.rpg.AndorsTrail.util.L;
|
import com.gpl.rpg.AndorsTrail.util.L;
|
||||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||||
|
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory.CustomDialog;
|
||||||
|
|
||||||
public class StartScreenActivity_MainMenu extends Fragment {
|
public class StartScreenActivity_MainMenu extends Fragment {
|
||||||
|
|
||||||
private static final int INTENTREQUEST_PREFERENCES = 7;
|
private static final int INTENTREQUEST_PREFERENCES = 7;
|
||||||
public static final int INTENTREQUEST_LOADGAME = 9;
|
public static final int INTENTREQUEST_LOADGAME = 9;
|
||||||
|
|
||||||
private boolean hasExistingGame = false;
|
private boolean hasExistingGame = false;
|
||||||
private Button startscreen_continue;
|
private Button startscreen_continue;
|
||||||
private Button startscreen_newgame;
|
private Button startscreen_newgame;
|
||||||
private Button startscreen_load;
|
private Button startscreen_load;
|
||||||
private ViewGroup save_preview_holder;
|
private ViewGroup save_preview_holder;
|
||||||
private ImageView save_preview_hero_icon;
|
private ImageView save_preview_hero_icon;
|
||||||
private TextView save_preview_hero_desc;
|
private TextView save_preview_hero_desc;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
updatePreferences(false);
|
updatePreferences(false);
|
||||||
super.onCreateView(inflater, container, savedInstanceState);
|
super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
@@ -64,11 +65,11 @@ public class StartScreenActivity_MainMenu extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
View root = inflater.inflate(R.layout.startscreen_mainmenu, container, false);
|
View root = inflater.inflate(R.layout.startscreen_mainmenu, container, false);
|
||||||
|
|
||||||
save_preview_holder = (ViewGroup) root.findViewById(R.id.save_preview_holder);
|
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_icon = (ImageView) root.findViewById(R.id.save_preview_hero_icon);
|
||||||
save_preview_hero_desc = (TextView) root.findViewById(R.id.save_preview_hero_desc);
|
save_preview_hero_desc = (TextView) root.findViewById(R.id.save_preview_hero_desc);
|
||||||
|
|
||||||
|
|
||||||
startscreen_continue = (Button) root.findViewById(R.id.startscreen_continue);
|
startscreen_continue = (Button) root.findViewById(R.id.startscreen_continue);
|
||||||
startscreen_continue.setOnClickListener(new OnClickListener() {
|
startscreen_continue.setOnClickListener(new OnClickListener() {
|
||||||
@@ -114,7 +115,7 @@ public class StartScreenActivity_MainMenu extends Fragment {
|
|||||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||||
if (hasExistingGame && app != null && app.getWorld() != null && app.getWorld().model != null
|
if (hasExistingGame && app != null && app.getWorld() != null && app.getWorld().model != null
|
||||||
&& app.getWorld().model.statistics != null && !app.getWorld().model.statistics.hasUnlimitedSaves()) {
|
&& app.getWorld().model.statistics != null && !app.getWorld().model.statistics.hasUnlimitedSaves()) {
|
||||||
final Dialog d = CustomDialogFactory.createDialog(getActivity(),
|
final CustomDialog d = CustomDialogFactory.createDialog(getActivity(),
|
||||||
getString(R.string.startscreen_load_game),
|
getString(R.string.startscreen_load_game),
|
||||||
getResources().getDrawable(android.R.drawable.ic_delete),
|
getResources().getDrawable(android.R.drawable.ic_delete),
|
||||||
getString(R.string.startscreen_load_game_confirm),
|
getString(R.string.startscreen_load_game_confirm),
|
||||||
@@ -134,7 +135,7 @@ public class StartScreenActivity_MainMenu extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (AndorsTrailApplication.DEVELOPMENT_FORCE_STARTNEWGAME) {
|
if (AndorsTrailApplication.DEVELOPMENT_FORCE_STARTNEWGAME) {
|
||||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGRESOURCES) {
|
if (AndorsTrailApplication.DEVELOPMENT_DEBUGRESOURCES) {
|
||||||
@@ -152,14 +153,14 @@ public class StartScreenActivity_MainMenu extends Fragment {
|
|||||||
checkAndRequestPermissions(getActivity());
|
checkAndRequestPermissions(getActivity());
|
||||||
migrateDataOnDemand(getActivity());
|
migrateDataOnDemand(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
String playerName;
|
String playerName;
|
||||||
String displayInfo = null;
|
String displayInfo = null;
|
||||||
int iconID = TileManager.CHAR_HERO;
|
int iconID = TileManager.CHAR_HERO;
|
||||||
@@ -189,14 +190,10 @@ public class StartScreenActivity_MainMenu extends Fragment {
|
|||||||
setCurrentVersionForVersionCheck();
|
setCurrentVersionForVersionCheck();
|
||||||
checkAndRequestPermissions(getActivity());
|
checkAndRequestPermissions(getActivity());
|
||||||
migrateDataOnDemand(getActivity());
|
migrateDataOnDemand(getActivity());
|
||||||
boolean hasSavegames = !Savegames.getUsedSavegameSlots(getActivity()).isEmpty();
|
|
||||||
startscreen_load.setEnabled(hasSavegames);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasSavegames = !Savegames.getUsedSavegameSlots(getActivity()).isEmpty();
|
|
||||||
startscreen_load.setEnabled(hasSavegames);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(29)
|
@TargetApi(29)
|
||||||
@@ -204,23 +201,16 @@ public class StartScreenActivity_MainMenu extends Fragment {
|
|||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
if (activity.getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
if (activity.getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||||
if (AndroidStorage.shouldMigrateToInternalStorage(activity.getApplicationContext())) {
|
if (AndroidStorage.shouldMigrateToInternalStorage(activity.getApplicationContext())) {
|
||||||
final Dialog d = CustomDialogFactory.createDialog(activity,
|
final CustomDialog d = CustomDialogFactory.createDialog(activity,
|
||||||
getString(R.string.startscreen_migration_title),
|
getString(R.string.startscreen_migration_title),
|
||||||
activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||||
getString(R.string.startscreen_migration_text),
|
getString(R.string.startscreen_migration_text),
|
||||||
null,
|
null,
|
||||||
true);
|
true);
|
||||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||||
d.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
||||||
@Override
|
|
||||||
public void onDismiss(DialogInterface arg0) {
|
|
||||||
boolean hasSavegames = !Savegames.getUsedSavegameSlots(getActivity()).isEmpty();
|
|
||||||
startscreen_load.setEnabled(hasSavegames);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
CustomDialogFactory.show(d);
|
CustomDialogFactory.show(d);
|
||||||
if (!AndroidStorage.migrateToInternalStorage(activity.getApplicationContext())) {
|
if (!AndroidStorage.migrateToInternalStorage(activity.getApplicationContext())) {
|
||||||
final Dialog errorDlg = CustomDialogFactory.createDialog(activity,
|
final CustomDialog errorDlg = CustomDialogFactory.createDialog(activity,
|
||||||
getString(R.string.startscreen_migration_title),
|
getString(R.string.startscreen_migration_title),
|
||||||
activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||||
getString(R.string.startscreen_migration_failure),
|
getString(R.string.startscreen_migration_failure),
|
||||||
@@ -259,13 +249,13 @@ public class StartScreenActivity_MainMenu extends Fragment {
|
|||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
listener = (OnNewGameRequestedListener) activity;
|
listener = (OnNewGameRequestedListener) activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDetach() {
|
public void onDetach() {
|
||||||
super.onDetach();
|
super.onDetach();
|
||||||
listener = null;
|
listener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setButtonState(final String playerName, final String displayInfo, int iconID, boolean isDead) {
|
private void setButtonState(final String playerName, final String displayInfo, int iconID, boolean isDead) {
|
||||||
startscreen_continue.setEnabled(hasExistingGame && !isDead);
|
startscreen_continue.setEnabled(hasExistingGame && !isDead);
|
||||||
startscreen_newgame.setEnabled(true);
|
startscreen_newgame.setEnabled(true);
|
||||||
@@ -305,9 +295,9 @@ public class StartScreenActivity_MainMenu extends Fragment {
|
|||||||
// .create().show();
|
// .create().show();
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
final Dialog d = CustomDialogFactory.createDialog(getActivity(),
|
final CustomDialog d = CustomDialogFactory.createDialog(getActivity(),
|
||||||
getString(R.string.startscreen_newgame),
|
getString(R.string.startscreen_newgame),
|
||||||
getResources().getDrawable(android.R.drawable.ic_delete),
|
getResources().getDrawable(android.R.drawable.ic_delete),
|
||||||
getResources().getString(R.string.startscreen_newgame_confirm),
|
getResources().getString(R.string.startscreen_newgame_confirm),
|
||||||
null,
|
null,
|
||||||
true);
|
true);
|
||||||
@@ -318,9 +308,9 @@ public class StartScreenActivity_MainMenu extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
||||||
|
|
||||||
CustomDialogFactory.show(d);
|
CustomDialogFactory.show(d);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String versionCheck = "lastversion";
|
private static final String versionCheck = "lastversion";
|
||||||
@@ -337,64 +327,90 @@ public class StartScreenActivity_MainMenu extends Fragment {
|
|||||||
e.putInt(versionCheck, AndorsTrailApplication.CURRENT_VERSION);
|
e.putInt(versionCheck, AndorsTrailApplication.CURRENT_VERSION);
|
||||||
e.commit();
|
e.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
@Override
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
switch (requestCode) {
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
case INTENTREQUEST_LOADGAME:
|
switch (requestCode) {
|
||||||
if (resultCode != Activity.RESULT_OK) break;
|
case INTENTREQUEST_LOADGAME:
|
||||||
final int slot = data.getIntExtra("slot", 1);
|
boolean unsuccessful = resultCode != Activity.RESULT_OK;
|
||||||
continueGame(false, slot, null);
|
if(data == null) break;
|
||||||
break;
|
|
||||||
case INTENTREQUEST_PREFERENCES:
|
final boolean wasImportOrExport = data.getBooleanExtra("import_export", false);
|
||||||
updatePreferences(true);
|
if (wasImportOrExport) {
|
||||||
break;
|
String message = getImportExportMessage(!unsuccessful, data);
|
||||||
|
Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (unsuccessful) break;
|
||||||
|
final int slot = data.getIntExtra("slot", 1);
|
||||||
|
continueGame(false, slot, null);
|
||||||
|
break;
|
||||||
|
case INTENTREQUEST_PREFERENCES:
|
||||||
|
updatePreferences(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getImportExportMessage(boolean successful, Intent data) {
|
||||||
|
String message = "";
|
||||||
|
boolean isImportWorldmap = data.getBooleanExtra("import_worldmap", false);
|
||||||
|
boolean isImportSaves = data.getBooleanExtra("import_savegames", false);
|
||||||
|
boolean isExport = data.getBooleanExtra("export", false);
|
||||||
|
|
||||||
|
if(isImportWorldmap) {
|
||||||
|
message = getString(successful ? R.string.loadsave_import_worldmap_successfull : R.string.loadsave_import_worldmap_unsuccessfull);
|
||||||
|
} else if(isImportSaves) {
|
||||||
|
message = getString(successful ? R.string.loadsave_import_save_successfull : R.string.loadsave_import_save_unsuccessfull);
|
||||||
|
} else if(isExport) {
|
||||||
|
message = getString(successful ? R.string.loadsave_export_successfull : R.string.loadsave_export_unsuccessfull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePreferences(boolean alreadyStartedLoadingResources) {
|
private void updatePreferences(boolean alreadyStartedLoadingResources) {
|
||||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||||
AndorsTrailPreferences preferences = app.getPreferences();
|
AndorsTrailPreferences preferences = app.getPreferences();
|
||||||
preferences.read(getActivity());
|
preferences.read(getActivity());
|
||||||
if (app.setLocale(getActivity())) {
|
if (app.setLocale(getActivity())) {
|
||||||
if (alreadyStartedLoadingResources) {
|
if (alreadyStartedLoadingResources) {
|
||||||
// Changing the locale after having loaded the game requires resources to
|
// Changing the locale after having loaded the game requires resources to
|
||||||
// be re-loaded. Therefore, we just exit here.
|
// be re-loaded. Therefore, we just exit here.
|
||||||
Toast.makeText(getActivity(), R.string.change_locale_requires_restart, Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), R.string.change_locale_requires_restart, Toast.LENGTH_LONG).show();
|
||||||
doFinish();
|
doFinish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ThemeHelper.changeTheme(preferences.selectedTheme)) {
|
if (ThemeHelper.changeTheme(preferences.selectedTheme)) {
|
||||||
// Changing the theme requires a restart to re-create all activities.
|
// Changing the theme requires a restart to re-create all activities.
|
||||||
Toast.makeText(getActivity(), R.string.change_theme_requires_restart, Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), R.string.change_theme_requires_restart, Toast.LENGTH_LONG).show();
|
||||||
doFinish();
|
doFinish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
app.getWorld().tileManager.updatePreferences(preferences);
|
app.getWorld().tileManager.updatePreferences(preferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private void doFinish() {
|
private void doFinish() {
|
||||||
//For Lollipop and above
|
//For Lollipop and above
|
||||||
((AndorsTrailApplication)getActivity().getApplication()).discardWorld();
|
((AndorsTrailApplication) getActivity().getApplication()).discardWorld();
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface OnNewGameRequestedListener {
|
public interface OnNewGameRequestedListener {
|
||||||
public void onNewGameRequested();
|
public void onNewGameRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
private OnNewGameRequestedListener listener = null;
|
private OnNewGameRequestedListener listener = null;
|
||||||
|
|
||||||
private void createNewGame() {
|
private void createNewGame() {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onNewGameRequested();
|
listener.onNewGameRequested();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
|||||||
controllers.actorStatsController.addActorAP(player, player.getSkillLevel(SkillCollection.SkillID.cleave) * SkillCollection.PER_SKILLPOINT_INCREASE_CLEAVE_AP);
|
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);
|
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);
|
controllers.actorStatsController.addExperience(loot.exp);
|
||||||
world.model.combatLog.append(controllers.getResources().getString(R.string.dialog_monsterloot_gainedexp, loot.exp));
|
world.model.combatLog.append(controllers.getResources().getString(R.string.dialog_monsterloot_gainedexp, loot.exp));
|
||||||
|
|
||||||
@@ -23,8 +23,8 @@ public final class Constants {
|
|||||||
public static final long MINIMUM_INPUT_INTERVAL_STD = 200;
|
public static final long MINIMUM_INPUT_INTERVAL_STD = 200;
|
||||||
//TODO restore final modifier before release
|
//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 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_WIDTH = 46;
|
||||||
public static final int MAX_MAP_HEIGHT = 33;
|
public static final int MAX_MAP_HEIGHT = 46;
|
||||||
|
|
||||||
public static final int MONSTER_MOVEMENT_TURN_DURATION_MS = 1200;
|
public static final int MONSTER_MOVEMENT_TURN_DURATION_MS = 1200;
|
||||||
public static final int MONSTER_IMMOBILE_MOVE_COST = 999;
|
public static final int MONSTER_IMMOBILE_MOVE_COST = 999;
|
||||||
@@ -51,6 +51,10 @@ public final class Constants {
|
|||||||
public static final String CHEAT_DETECTION_FOLDER = "dEAGyGE3YojqXjI3x4x7";
|
public static final String CHEAT_DETECTION_FOLDER = "dEAGyGE3YojqXjI3x4x7";
|
||||||
public static final String PASSIVE_ACHIEVEMENT_CHECK_PHRASE = "passive_achievement_check";
|
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 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) { return rollValue(r.max, r.current); }
|
||||||
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 ConstRange r, int bias) { return rollValue((r.max + 1) * 100 -1, r.current * 100 + bias)/100; }
|
||||||
@@ -2,6 +2,7 @@ package com.gpl.rpg.AndorsTrail.controller;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -98,28 +99,36 @@ public final class InputController implements OnClickListener, OnLongClickListen
|
|||||||
|
|
||||||
// Keys mapping to UP_LEFT
|
// Keys mapping to UP_LEFT
|
||||||
key = KEY_MOVE_UP_LEFT;
|
key = KEY_MOVE_UP_LEFT;
|
||||||
keyMap.put(KeyEvent.KEYCODE_DPAD_UP_LEFT, key);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
keyMap.put(KeyEvent.KEYCODE_DPAD_UP_LEFT, key);
|
||||||
|
}
|
||||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_7, key);
|
keyMap.put(KeyEvent.KEYCODE_NUMPAD_7, key);
|
||||||
keyMap.put(KeyEvent.KEYCODE_7, key);
|
keyMap.put(KeyEvent.KEYCODE_7, key);
|
||||||
keyMap.put(KeyEvent.KEYCODE_MOVE_HOME, key);
|
keyMap.put(KeyEvent.KEYCODE_MOVE_HOME, key);
|
||||||
|
|
||||||
// Keys mapping to UP_RIGHT
|
// Keys mapping to UP_RIGHT
|
||||||
key = KEY_MOVE_UP_RIGHT;
|
key = KEY_MOVE_UP_RIGHT;
|
||||||
keyMap.put(KeyEvent.KEYCODE_DPAD_UP_RIGHT, key);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
keyMap.put(KeyEvent.KEYCODE_DPAD_UP_RIGHT, key);
|
||||||
|
}
|
||||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_9, key);
|
keyMap.put(KeyEvent.KEYCODE_NUMPAD_9, key);
|
||||||
keyMap.put(KeyEvent.KEYCODE_9, key);
|
keyMap.put(KeyEvent.KEYCODE_9, key);
|
||||||
keyMap.put(KeyEvent.KEYCODE_PAGE_UP, key);
|
keyMap.put(KeyEvent.KEYCODE_PAGE_UP, key);
|
||||||
|
|
||||||
// Keys mapping to DOWN_LEFT
|
// Keys mapping to DOWN_LEFT
|
||||||
key = KEY_MOVE_DOWN_LEFT;
|
key = KEY_MOVE_DOWN_LEFT;
|
||||||
keyMap.put(KeyEvent.KEYCODE_DPAD_DOWN_LEFT, key);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
keyMap.put(KeyEvent.KEYCODE_DPAD_DOWN_LEFT, key);
|
||||||
|
}
|
||||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_1, key);
|
keyMap.put(KeyEvent.KEYCODE_NUMPAD_1, key);
|
||||||
keyMap.put(KeyEvent.KEYCODE_1, key);
|
keyMap.put(KeyEvent.KEYCODE_1, key);
|
||||||
keyMap.put(KeyEvent.KEYCODE_MOVE_END, key);
|
keyMap.put(KeyEvent.KEYCODE_MOVE_END, key);
|
||||||
|
|
||||||
// Keys mapping to DOWN_RIGHT
|
// Keys mapping to DOWN_RIGHT
|
||||||
key = KEY_MOVE_DOWN_RIGHT;
|
key = KEY_MOVE_DOWN_RIGHT;
|
||||||
keyMap.put(KeyEvent.KEYCODE_DPAD_DOWN_RIGHT, key);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
keyMap.put(KeyEvent.KEYCODE_DPAD_DOWN_RIGHT, key);
|
||||||
|
}
|
||||||
keyMap.put(KeyEvent.KEYCODE_NUMPAD_3, key);
|
keyMap.put(KeyEvent.KEYCODE_NUMPAD_3, key);
|
||||||
keyMap.put(KeyEvent.KEYCODE_3, key);
|
keyMap.put(KeyEvent.KEYCODE_3, key);
|
||||||
keyMap.put(KeyEvent.KEYCODE_PAGE_DOWN, key);
|
keyMap.put(KeyEvent.KEYCODE_PAGE_DOWN, key);
|
||||||
@@ -19,10 +19,12 @@ import com.gpl.rpg.AndorsTrail.model.actor.MonsterType;
|
|||||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||||
import com.gpl.rpg.AndorsTrail.model.quest.Quest;
|
import com.gpl.rpg.AndorsTrail.model.quest.Quest;
|
||||||
|
import com.gpl.rpg.AndorsTrail.util.HashMapHelper;
|
||||||
|
|
||||||
public final class GameStatistics {
|
public final class GameStatistics {
|
||||||
private int deaths = 0;
|
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 final HashMap<String, Integer> usedItems = new HashMap<String, Integer>();
|
||||||
private int spentGold = 0;
|
private int spentGold = 0;
|
||||||
private boolean unlimitedSaves = true;
|
private boolean unlimitedSaves = true;
|
||||||
@@ -33,10 +35,14 @@ public final class GameStatistics {
|
|||||||
this.startLives = startLives;
|
this.startLives = startLives;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMonsterKill(String monsterTypeID) {
|
public void addMonsterKill(MonsterType monsterType) {
|
||||||
if (!killedMonsters.containsKey(monsterTypeID)) killedMonsters.put(monsterTypeID, 1);
|
// Track monster kills by type ID, for savegame file
|
||||||
else killedMonsters.put(monsterTypeID, killedMonsters.get(monsterTypeID) + 1);
|
killedMonstersByTypeID.put(monsterType.id, getNumberOfKillsForMonsterType(monsterType.id) + 1);
|
||||||
|
|
||||||
|
// Also track by name, for statistics display (multiple IDs w/same name don't matter to player)
|
||||||
|
killedMonstersByName.put(monsterType.name, getNumberOfKillsForMonsterName(monsterType.name) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerDeath(int lostExp) {
|
public void addPlayerDeath(int lostExp) {
|
||||||
++deaths;
|
++deaths;
|
||||||
}
|
}
|
||||||
@@ -45,8 +51,7 @@ public final class GameStatistics {
|
|||||||
}
|
}
|
||||||
public void addItemUsage(ItemType type) {
|
public void addItemUsage(ItemType type) {
|
||||||
final String n = type.id;
|
final String n = type.id;
|
||||||
if (!usedItems.containsKey(n)) usedItems.put(n, 1);
|
usedItems.put(n, HashMapHelper.getOrDefault(usedItems, n,0) + 1);
|
||||||
else usedItems.put(n, usedItems.get(n) + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDeaths() {
|
public int getDeaths() {
|
||||||
@@ -68,30 +73,30 @@ public final class GameStatistics {
|
|||||||
public boolean isDead() { return !hasUnlimitedLives() && getLivesLeft() < 1; }
|
public boolean isDead() { return !hasUnlimitedLives() && getLivesLeft() < 1; }
|
||||||
|
|
||||||
public int getNumberOfKillsForMonsterType(String monsterTypeID) {
|
public int getNumberOfKillsForMonsterType(String monsterTypeID) {
|
||||||
Integer v = killedMonsters.get(monsterTypeID);
|
return HashMapHelper.getOrDefault(killedMonstersByTypeID, monsterTypeID, 0);
|
||||||
if (v == null) return 0;
|
}
|
||||||
return v;
|
|
||||||
|
public int getNumberOfKillsForMonsterName(String monsterName) {
|
||||||
|
return HashMapHelper.getOrDefault(killedMonstersByName, monsterName, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTop5MostCommonlyKilledMonsters(WorldContext world, Resources res) {
|
public String getTop5MostCommonlyKilledMonsters(WorldContext world, Resources res) {
|
||||||
if (killedMonsters.isEmpty()) return null;
|
if (killedMonstersByTypeID.isEmpty()) return null;
|
||||||
List<Entry<String, Integer>> entries = new ArrayList<Entry<String, Integer>>(killedMonsters.entrySet());
|
List<Entry<String, Integer>> entries = new ArrayList<Entry<String, Integer>>(killedMonstersByName.entrySet());
|
||||||
Collections.sort(entries, descendingValueComparator);
|
Collections.sort(entries, descendingValueComparator);
|
||||||
StringBuilder sb = new StringBuilder(100);
|
StringBuilder sb = new StringBuilder(100);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Entry<String, Integer> e : entries) {
|
for (Entry<String, Integer> e : entries) {
|
||||||
if (i++ >= 5) break;
|
if (i++ >= 5) break;
|
||||||
MonsterType t = world.monsterTypes.getMonsterType(e.getKey());
|
sb.append(res.getString(R.string.heroinfo_gamestats_name_and_qty, e.getKey(), e.getValue())).append('\n');
|
||||||
if (t == null) continue;
|
|
||||||
sb.append(res.getString(R.string.heroinfo_gamestats_name_and_qty, t.name, e.getValue())).append('\n');
|
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMostPowerfulKilledMonster(WorldContext world) {
|
public String getMostPowerfulKilledMonster(WorldContext world) {
|
||||||
if (killedMonsters.isEmpty()) return null;
|
if (killedMonstersByTypeID.isEmpty()) return null;
|
||||||
HashMap<String, Integer> expPerMonsterType = new HashMap<String, Integer>(killedMonsters.size());
|
HashMap<String, Integer> expPerMonsterType = new HashMap<String, Integer>(killedMonstersByTypeID.size());
|
||||||
for (String monsterTypeID : killedMonsters.keySet()) {
|
for (String monsterTypeID : killedMonstersByTypeID.keySet()) {
|
||||||
MonsterType t = world.monsterTypes.getMonsterType(monsterTypeID);
|
MonsterType t = world.monsterTypes.getMonsterType(monsterTypeID);
|
||||||
expPerMonsterType.put(monsterTypeID, t != null ? t.exp : 0);
|
expPerMonsterType.put(monsterTypeID, t != null ? t.exp : 0);
|
||||||
}
|
}
|
||||||
@@ -135,20 +140,15 @@ public final class GameStatistics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfUsedItems() {
|
public int getNumberOfUsedItems() {
|
||||||
int result = 0;
|
return HashMapHelper.sumIntegerValues(usedItems);
|
||||||
for (int v : usedItems.values()) result += v;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfTimesItemHasBeenUsed(String itemId) {
|
public int getNumberOfTimesItemHasBeenUsed(String itemId) {
|
||||||
if (!usedItems.containsKey(itemId)) return 0;
|
return HashMapHelper.getOrDefault(usedItems, itemId, 0);
|
||||||
return usedItems.get(itemId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfKilledMonsters() {
|
public int getNumberOfKilledMonsters() {
|
||||||
int result = 0;
|
return HashMapHelper.sumIntegerValues(killedMonstersByTypeID);
|
||||||
for (int v : killedMonsters.values()) result += v;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Comparator<Entry<String, Integer>> descendingValueComparator = new Comparator<Entry<String, Integer>>() {
|
private static final Comparator<Entry<String, Integer>> descendingValueComparator = new Comparator<Entry<String, Integer>>() {
|
||||||
@@ -172,8 +172,14 @@ public final class GameStatistics {
|
|||||||
if (type == null) continue;
|
if (type == null) continue;
|
||||||
id = type.id;
|
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, getNumberOfKillsForMonsterName(t.name) + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileversion <= 17) return;
|
if (fileversion <= 17) return;
|
||||||
|
|
||||||
final int numItems = src.readInt();
|
final int numItems = src.readInt();
|
||||||
@@ -192,7 +198,7 @@ public final class GameStatistics {
|
|||||||
|
|
||||||
public void writeToParcel(DataOutputStream dest) throws IOException {
|
public void writeToParcel(DataOutputStream dest) throws IOException {
|
||||||
dest.writeInt(deaths);
|
dest.writeInt(deaths);
|
||||||
Set<Entry<String, Integer> > set = killedMonsters.entrySet();
|
Set<Entry<String, Integer> > set = killedMonstersByTypeID.entrySet();
|
||||||
dest.writeInt(set.size());
|
dest.writeInt(set.size());
|
||||||
for (Entry<String, Integer> e : set) {
|
for (Entry<String, Integer> e : set) {
|
||||||
dest.writeUTF(e.getKey());
|
dest.writeUTF(e.getKey());
|
||||||
@@ -83,7 +83,7 @@ public final class SkillCollection {
|
|||||||
public static final int PER_SKILLPOINT_INCREASE_COINFINDER_CHANCE_PERCENT = 30;
|
public static final int PER_SKILLPOINT_INCREASE_COINFINDER_CHANCE_PERCENT = 30;
|
||||||
public static final int PER_SKILLPOINT_INCREASE_MAGICFINDER_CHANCE_PERCENT = 50;
|
public static final int PER_SKILLPOINT_INCREASE_MAGICFINDER_CHANCE_PERCENT = 50;
|
||||||
public static final int PER_SKILLPOINT_INCREASE_COINFINDER_QUANTITY_PERCENT = 50;
|
public static final int PER_SKILLPOINT_INCREASE_COINFINDER_QUANTITY_PERCENT = 50;
|
||||||
public static final int PER_SKILLPOINT_INCREASE_MORE_EXP_PERCENT = 5;
|
public static final int PER_SKILLPOINT_INCREASE_MORE_EXP_PERCENT = 10;
|
||||||
public static final int PER_SKILLPOINT_INCREASE_CLEAVE_AP = 3;
|
public static final int PER_SKILLPOINT_INCREASE_CLEAVE_AP = 3;
|
||||||
public static final int PER_SKILLPOINT_INCREASE_EATER_HEALTH = 1;
|
public static final int PER_SKILLPOINT_INCREASE_EATER_HEALTH = 1;
|
||||||
public static final int PER_SKILLPOINT_INCREASE_FORTITUDE_HEALTH = 1;
|
public static final int PER_SKILLPOINT_INCREASE_FORTITUDE_HEALTH = 1;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user