Compare commits
340 Commits
v0.6.2
...
performanc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
364bf8ee11 | ||
|
|
e2b0b0e81e | ||
|
|
703b723322 | ||
|
|
297bff84db | ||
|
|
67724f5124 | ||
|
|
09d23c8cdf | ||
|
|
749e64e09e | ||
|
|
998560a6ff | ||
|
|
2bf64c417f | ||
|
|
120ed02a69 | ||
|
|
f308580deb | ||
|
|
fd41013ade | ||
|
|
114e09597e | ||
|
|
3ceee2e9e6 | ||
|
|
83cc57515d | ||
|
|
06d4131582 | ||
|
|
60205d54de | ||
|
|
f6fbb0f5a3 | ||
|
|
af48341439 | ||
|
|
7b7218ad4e | ||
|
|
1ddf1c5051 | ||
|
|
f9a9ab97de | ||
|
|
b37d32b5c2 | ||
|
|
3c5ed1d6f6 | ||
|
|
bc3333bd0e | ||
|
|
e6d9d8fbda | ||
|
|
32ff1b57fa | ||
|
|
090584dbcc | ||
|
|
e858e436c6 | ||
|
|
4b2aa77cb6 | ||
|
|
24e1e526ce | ||
|
|
861c4c3bb1 | ||
|
|
c18fcfc667 | ||
|
|
9b1ac0d3e1 | ||
|
|
782d436681 | ||
|
|
397d1ded8c | ||
|
|
aef6429dbc | ||
|
|
c43b8464a2 | ||
|
|
7929ffe2a7 | ||
|
|
a3ffecfd23 | ||
|
|
1cbcd5b661 | ||
|
|
0eddd25292 | ||
|
|
1c83eedd80 | ||
|
|
6c296868c0 | ||
|
|
8f5452b487 | ||
|
|
f9f1caafc6 | ||
|
|
c0e24b4cf5 | ||
|
|
cd36813050 | ||
|
|
358d855eec | ||
|
|
281e314815 | ||
|
|
3f19ca959b | ||
|
|
6b74ad5cbe | ||
|
|
93e44a2b50 | ||
|
|
652da07cc8 | ||
|
|
2dbe881dd7 | ||
|
|
b7e9bf0582 | ||
|
|
6dcd8599b3 | ||
|
|
62ed795fed | ||
|
|
ec04b810d9 | ||
|
|
18b92a3921 | ||
|
|
127ed76006 | ||
|
|
56242e85f2 | ||
|
|
de2b47821b | ||
|
|
7eb60117c4 | ||
|
|
0c69438a33 | ||
|
|
380bb1de17 | ||
|
|
9ae9914dde | ||
|
|
c78fcde633 | ||
|
|
270c613f66 | ||
|
|
ebafae7503 | ||
|
|
572c658b43 | ||
|
|
5031fa3c72 | ||
|
|
7f0b55a71c | ||
|
|
ab91d330bd | ||
|
|
27a86ee654 | ||
|
|
ad15063dcc | ||
|
|
2ea425dda6 | ||
|
|
f22052525c | ||
|
|
63e381a804 | ||
|
|
488dd92893 | ||
|
|
f04f062723 | ||
|
|
e91f770975 | ||
|
|
7018703ba6 | ||
|
|
93f0a902ba | ||
|
|
1ca2b9068e | ||
|
|
a7f214a1cb | ||
|
|
b2c05037e5 | ||
|
|
517a798b6f | ||
|
|
e9fecee876 | ||
|
|
967bbf918b | ||
|
|
5ce84dc1b1 | ||
|
|
0a18309bfe | ||
|
|
edc4634cbe | ||
|
|
1e25eabb50 | ||
|
|
1c7de2b97f | ||
|
|
e40fe058dd | ||
|
|
919e65187f | ||
|
|
7b780462ea | ||
|
|
00147c2708 | ||
|
|
70cc945010 | ||
|
|
21005f1ba6 | ||
|
|
b5a6aa6706 | ||
|
|
3cc6eb9edb | ||
|
|
d166e49f4d | ||
|
|
d1568cd2ed | ||
|
|
685ce223da | ||
|
|
18cb73385f | ||
|
|
90359bf285 | ||
|
|
bb187621b7 | ||
|
|
a4b431efdd | ||
|
|
cffbf973e1 | ||
|
|
979a7bc43f | ||
|
|
6b049d3b7b | ||
|
|
edd0160c9d | ||
|
|
fdcc4fab55 | ||
|
|
d030e11019 | ||
|
|
333100b19b | ||
|
|
cfb906736d | ||
|
|
cf8c0497bc | ||
|
|
355bb2bc54 | ||
|
|
e1e85d7a90 | ||
|
|
9ed9393b16 | ||
|
|
8c42b498b0 | ||
|
|
8561415574 | ||
|
|
185f168b19 | ||
|
|
70055be6d2 | ||
|
|
286d95d83d | ||
|
|
04b704daf0 | ||
|
|
3f1f988808 | ||
|
|
e232c33339 | ||
|
|
4239beb825 | ||
|
|
eb6377a983 | ||
|
|
2fb16c9213 | ||
|
|
6741100a4f | ||
|
|
dbff7fb571 | ||
|
|
dfb3e31a7a | ||
|
|
022c9ad229 | ||
|
|
38a3d4082b | ||
|
|
cd78ee3ad0 | ||
|
|
7b30cc6355 | ||
|
|
9a6c5ecf6e | ||
|
|
ed81c2382f | ||
|
|
ed2ad56b76 | ||
|
|
becf45f249 | ||
|
|
c950324cd9 | ||
|
|
b58d080f4d | ||
|
|
a2640c2da0 | ||
|
|
4fe7e71a43 | ||
|
|
9a162ac58d | ||
|
|
93718230a5 | ||
|
|
4fbf7de85a | ||
|
|
f0be1a8135 | ||
|
|
104d3db5ad | ||
|
|
f154efcecc | ||
|
|
00e9e3b2a7 | ||
|
|
92436d3ce9 | ||
|
|
b6cfe349c0 | ||
|
|
1e2daa56a4 | ||
|
|
2caaaeb474 | ||
|
|
0e8ed1a25d | ||
|
|
e2fdf08fec | ||
|
|
b5dceb9fd1 | ||
|
|
1555bd63db | ||
|
|
56fff8a730 | ||
|
|
dd7b3d5300 | ||
|
|
68affdde8c | ||
|
|
6cec8b835e | ||
|
|
aa43382296 | ||
|
|
ec346e9c98 | ||
|
|
61d5af822c | ||
|
|
c2d05b2bff | ||
|
|
e60378ab64 | ||
|
|
6578236775 | ||
|
|
4fa2409c24 | ||
|
|
b5aa453fd6 | ||
|
|
42f1c87278 | ||
|
|
9097b97316 | ||
|
|
7965ecb4f1 | ||
|
|
01963517ba | ||
|
|
30bef443d5 | ||
|
|
8d01716d93 | ||
|
|
fce5cd71ff | ||
|
|
0cddbb04e9 | ||
|
|
00ec5fe49f | ||
|
|
5cdb42ae07 | ||
|
|
c98f51744b | ||
|
|
5550b257ca | ||
|
|
619aa1075f | ||
|
|
38a3ad85c8 | ||
|
|
89f764b62b | ||
|
|
d81233d470 | ||
|
|
e1685aa625 | ||
|
|
ae3ca5d50a | ||
|
|
a00b8fbc66 | ||
|
|
4d03c15e08 | ||
|
|
4571bea429 | ||
|
|
ecc9a35c69 | ||
|
|
c4d71df4b1 | ||
|
|
a13dac467a | ||
|
|
e305dfd7bf | ||
|
|
80984a43af | ||
|
|
2bc8b65264 | ||
|
|
b2584a24cc | ||
|
|
1626a8340f | ||
|
|
5fe2dfe148 | ||
|
|
abc1e7c912 | ||
|
|
317d6d4216 | ||
|
|
3628386019 | ||
|
|
ada352a02c | ||
|
|
fc0d97aa2f | ||
|
|
7451f582ce | ||
|
|
7b80bf5768 | ||
|
|
ddd98c5a8f | ||
|
|
0ef703d82e | ||
|
|
2339a9307c | ||
|
|
7dcdb90750 | ||
|
|
b638c31ebe | ||
|
|
862f4b7366 | ||
|
|
693de98212 | ||
|
|
3f4bf58375 | ||
|
|
7ae4d9d3f6 | ||
|
|
0f20f0cd6d | ||
|
|
481956cfa5 | ||
|
|
7c282aae53 | ||
|
|
1fd3e6253e | ||
|
|
70f61f0281 | ||
|
|
2f82fd13a6 | ||
|
|
f7e5785970 | ||
|
|
084b23f641 | ||
|
|
ff4d8a6b6c | ||
|
|
45aff3d25b | ||
|
|
28a1d0b09e | ||
|
|
b96568049f | ||
|
|
e125b0339c | ||
|
|
65456a110b | ||
|
|
a9bd84b9f2 | ||
|
|
1bab8dc42f | ||
|
|
7863b73eda | ||
|
|
32e1b87e09 | ||
|
|
4b6be99d98 | ||
|
|
13847bb8cd | ||
|
|
2d92a97689 | ||
|
|
9c21c7cd02 | ||
|
|
f4fd8ad5bb | ||
|
|
63acc5bf2c | ||
|
|
4c51353e93 | ||
|
|
7bf6bbfcd1 | ||
|
|
7d40d56430 | ||
|
|
d7e83575e3 | ||
|
|
811870184b | ||
|
|
7297f47b67 | ||
|
|
20877f7850 | ||
|
|
b3c8879be1 | ||
|
|
ac68006a69 | ||
|
|
92e07e76d2 | ||
|
|
5a3315da1a | ||
|
|
e12c6bcc25 | ||
|
|
44c4e1f998 | ||
|
|
450b0de02a | ||
|
|
57702a3a4a | ||
|
|
3e5f732f82 | ||
|
|
b497493853 | ||
|
|
00c05e7507 | ||
|
|
1b01ecd37d | ||
|
|
da5b686672 | ||
|
|
0a3da17d47 | ||
|
|
bf42f86408 | ||
|
|
aa543bc111 | ||
|
|
f4041ee2c7 | ||
|
|
3e8d578474 | ||
|
|
67b8acd20b | ||
|
|
d1612269c0 | ||
|
|
f95327bd12 | ||
|
|
e0425e335d | ||
|
|
3800bf8ff0 | ||
|
|
84e46ffd20 | ||
|
|
9f5666ea6d | ||
|
|
ae5822703a | ||
|
|
9b68ef6679 | ||
|
|
75d6f8e98f | ||
|
|
38c206cbaf | ||
|
|
b12ed1802f | ||
|
|
0b8bc8448a | ||
|
|
221a031c2b | ||
|
|
f2e4767eb0 | ||
|
|
78ceacb0ce | ||
|
|
1604373e6c | ||
|
|
6e2ee13da7 | ||
|
|
ea28b7475a | ||
|
|
ffe6a14cd9 | ||
|
|
3ab233761f | ||
|
|
e5bb59b876 | ||
|
|
1fb22ab73f | ||
|
|
6b834e0f0e | ||
|
|
9e6e1d936d | ||
|
|
c3144db751 | ||
|
|
daeb394373 | ||
|
|
e697f93cf5 | ||
|
|
407d50a01e | ||
|
|
a475180bb5 | ||
|
|
259442710b | ||
|
|
3c63ace6c1 | ||
|
|
1786860a3b | ||
|
|
cbc101b3b1 | ||
|
|
33260137d9 | ||
|
|
5a1d8637f9 | ||
|
|
97119b7101 | ||
|
|
104029124b | ||
|
|
2aad37549c | ||
|
|
8dc05bd26a | ||
|
|
de0274a5be | ||
|
|
3d2dbb9f51 | ||
|
|
f53302cb18 | ||
|
|
8d6a40eb13 | ||
|
|
0199bcfb4c | ||
|
|
3fe895a668 | ||
|
|
025a63af28 | ||
|
|
528ac7a7e3 | ||
|
|
506afb95ed | ||
|
|
5d802ed0e3 | ||
|
|
33cbd059ec | ||
|
|
6cb0941ca6 | ||
|
|
cfb38c33d6 | ||
|
|
ec3afaaf36 | ||
|
|
9f978591ff | ||
|
|
7fff58d8f9 | ||
|
|
6192bd8dce | ||
|
|
be43a2a5d4 | ||
|
|
99524bf043 | ||
|
|
f2144ab446 | ||
|
|
ada045a13b | ||
|
|
4c4f7e5b92 | ||
|
|
ef521207de | ||
|
|
3ef0f7e0f1 | ||
|
|
74808cdd3a | ||
|
|
1e8d08ee3a | ||
|
|
8d8a1e122e | ||
|
|
fe62c05b4b | ||
|
|
f93d03dbd3 | ||
|
|
7eb5c7c208 |
@@ -4,6 +4,7 @@
|
|||||||
<classpathentry kind="src" path="res"/>
|
<classpathentry kind="src" path="res"/>
|
||||||
<classpathentry kind="src" path="hacked-libtiled"/>
|
<classpathentry kind="src" path="hacked-libtiled"/>
|
||||||
<classpathentry kind="src" path="siphash-zackehh/src/main/java"/>
|
<classpathentry kind="src" path="siphash-zackehh/src/main/java"/>
|
||||||
|
<classpathentry kind="src" path="minify"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="lib" path="lib/jide-oss.jar"/>
|
<classpathentry kind="lib" path="lib/jide-oss.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/json_simple-1.1.jar"/>
|
<classpathentry kind="lib" path="lib/json_simple-1.1.jar"/>
|
||||||
@@ -13,6 +14,6 @@
|
|||||||
<classpathentry kind="lib" path="lib/ui.jar"/>
|
<classpathentry kind="lib" path="lib/ui.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/bsh-2.0b4.jar"/>
|
<classpathentry kind="lib" path="lib/bsh-2.0b4.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/jsoup-1.10.2.jar" sourcepath="lib/jsoup-1.10.2-sources.jar"/>
|
<classpathentry kind="lib" path="lib/jsoup-1.10.2.jar" sourcepath="lib/jsoup-1.10.2-sources.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/AndorsTrainer_v0.1.4.jar"/>
|
<classpathentry kind="lib" path="lib/AndorsTrainer_v0.1.5.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
6
.gitattributes
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Set default behavior to automatically normalize line endings.
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
# Force bash scripts to always use LF line endings so that if a repo is accessed
|
||||||
|
# in Unix via a file share from Windows, the scripts will work.
|
||||||
|
*.sh text eol=lf
|
||||||
56
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
name: Release Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get Version
|
||||||
|
id: get_version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "Reading version from file:"
|
||||||
|
cat res/ATCS_latest
|
||||||
|
echo ""
|
||||||
|
VERSION=$(tr -d '[:space:]' < "res/ATCS_latest")
|
||||||
|
echo "Processed version: $VERSION"
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
echo "Environment variable set to: $VERSION"
|
||||||
|
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: Build JAR
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd packaging
|
||||||
|
chmod +x package.sh
|
||||||
|
echo "Building JAR and ZIP for version: ${{ env.VERSION }}"
|
||||||
|
./package.sh -windows
|
||||||
|
echo "Created artifacts:"
|
||||||
|
ls -la common/ATCS.jar
|
||||||
|
ls -la ATCS_${{ env.VERSION }}.zip
|
||||||
|
|
||||||
|
- name: Install NSIS
|
||||||
|
uses: joncloud/makensis-action@v4
|
||||||
|
with:
|
||||||
|
script-file: packaging/Windows/ATCS_Installer.nsi
|
||||||
|
arguments: /DVERSION="${{ env.VERSION }}"
|
||||||
|
|
||||||
|
- name: Upload Release Assets
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
./packaging/ATCS_${{ env.VERSION }}.zip
|
||||||
|
./packaging/ATCS_${{ env.VERSION }}_Setup.exe
|
||||||
10
.gitignore
vendored
@@ -1,3 +1,13 @@
|
|||||||
/ATCS_v*.jar
|
/ATCS_v*.jar
|
||||||
/Project
|
/Project
|
||||||
/bin
|
/bin
|
||||||
|
/packaging/tmp/
|
||||||
|
/out
|
||||||
|
packaging/common/lib
|
||||||
|
packaging/common/ATCS.jar
|
||||||
|
packaging/ATCS_*.zip
|
||||||
|
ATCS_v*.tar.gz
|
||||||
|
ATCS.jar
|
||||||
|
/packaging/common/ATCS.env.bat
|
||||||
|
/packaging/common/ATCS.env
|
||||||
|
/packaging/common/ATCS_v*.zip
|
||||||
|
|||||||
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
17
.idea/artifacts/ATContentStudio_jar.xml
generated
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact name="ATContentStudio:jar">
|
||||||
|
<output-path>$PROJECT_DIR$/out/artifacts/ATContentStudio_jar</output-path>
|
||||||
|
<root id="root">
|
||||||
|
<element id="archive" name="ATContentStudio.jar">
|
||||||
|
<element id="module-output" name="ATContentStudio" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/lib/bsh-2.0b4.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/lib/rsyntaxtextarea.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/lib/prefuse.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/lib/jsoup-1.10.2.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/lib/json_simple-1.1.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/lib/ui.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$PROJECT_DIR$/lib/jide-oss.jar" path-in-jar="/" />
|
||||||
|
</element>
|
||||||
|
</root>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
19
.idea/codeStyles/Project.xml
generated
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<JavaCodeStyleSettings>
|
||||||
|
<option name="JD_P_AT_EMPTY_LINES" value="false" />
|
||||||
|
</JavaCodeStyleSettings>
|
||||||
|
<codeStyleSettings language="JAVA">
|
||||||
|
<option name="RIGHT_MARGIN" value="200" />
|
||||||
|
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
|
||||||
|
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
||||||
|
<option name="BINARY_OPERATION_WRAP" value="5" />
|
||||||
|
<option name="SOFT_MARGINS" value="120" />
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="JSON">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="4" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
||||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
4
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK" />
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/ATContentStudio.iml" filepath="$PROJECT_DIR$/ATContentStudio.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<jardesc>
|
<jardesc>
|
||||||
<jar path="ATContentStudio/ATCS_v0.6.2.jar"/>
|
<jar path="ATContentStudio/ATCS_v0.6.20.jar"/>
|
||||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/ATContentStudio/ATCS_JAR.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
<options buildIfNeeded="true" compress="true" descriptionLocation="/ATContentStudio/ATCS_JAR.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||||
<selectedProjects/>
|
<selectedProjects/>
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
</sealing>
|
</sealing>
|
||||||
</manifest>
|
</manifest>
|
||||||
<selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false">
|
<selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false">
|
||||||
<javaElement handleIdentifier="=ATContentStudio/siphash-zackehh\/src\/main\/java"/>
|
|
||||||
<javaElement handleIdentifier="=ATContentStudio/res"/>
|
|
||||||
<javaElement handleIdentifier="=ATContentStudio/src"/>
|
|
||||||
<javaElement handleIdentifier="=ATContentStudio/hacked-libtiled"/>
|
<javaElement handleIdentifier="=ATContentStudio/hacked-libtiled"/>
|
||||||
|
<javaElement handleIdentifier="=ATContentStudio/siphash-zackehh\/src\/main\/java"/>
|
||||||
|
<javaElement handleIdentifier="=ATContentStudio/src"/>
|
||||||
|
<javaElement handleIdentifier="=ATContentStudio/res"/>
|
||||||
</selectedElements>
|
</selectedElements>
|
||||||
</jardesc>
|
</jardesc>
|
||||||
|
|||||||
117
ATContentStudio.iml
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="EclipseModuleManager">
|
||||||
|
<libelement value="jar://$MODULE_DIR$/lib/jide-oss.jar!/" />
|
||||||
|
<libelement value="jar://$MODULE_DIR$/lib/json_simple-1.1.jar!/" />
|
||||||
|
<libelement value="jar://$MODULE_DIR$/lib/junit-4.10.jar!/" />
|
||||||
|
<libelement value="jar://$MODULE_DIR$/lib/prefuse.jar!/" />
|
||||||
|
<libelement value="jar://$MODULE_DIR$/lib/rsyntaxtextarea.jar!/" />
|
||||||
|
<libelement value="jar://$MODULE_DIR$/lib/ui.jar!/" />
|
||||||
|
<libelement value="jar://$MODULE_DIR$/lib/bsh-2.0b4.jar!/" />
|
||||||
|
<libelement value="jar://$MODULE_DIR$/lib/jsoup-1.10.2.jar!/" />
|
||||||
|
<libelement value="jar://$MODULE_DIR$/lib/AndorsTrainer_v0.1.5.jar!/" />
|
||||||
|
<src_description expected_position="0">
|
||||||
|
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
|
||||||
|
<src_folder value="file://$MODULE_DIR$/res" expected_position="1" />
|
||||||
|
<src_folder value="file://$MODULE_DIR$/hacked-libtiled" expected_position="2" />
|
||||||
|
<src_folder value="file://$MODULE_DIR$/siphash-zackehh/src/main/java" expected_position="3" />
|
||||||
|
<src_folder value="file://$MODULE_DIR$/minify" expected_position="4" />
|
||||||
|
</src_description>
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<output url="file://$MODULE_DIR$/bin" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/hacked-libtiled" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/minify" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/res" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/siphash-zackehh/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="jide-oss.jar">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MODULE_DIR$/lib/jide-oss.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="json_simple-1.1.jar">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MODULE_DIR$/lib/json_simple-1.1.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="junit-4.10.jar">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MODULE_DIR$/lib/junit-4.10.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="prefuse.jar">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MODULE_DIR$/lib/prefuse.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="rsyntaxtextarea.jar">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MODULE_DIR$/lib/rsyntaxtextarea.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="ui.jar">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MODULE_DIR$/lib/ui.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="bsh-2.0b4.jar">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MODULE_DIR$/lib/bsh-2.0b4.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="jsoup-1.10.2.jar">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MODULE_DIR$/lib/jsoup-1.10.2.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MODULE_DIR$/lib/jsoup-1.10.2-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="AndorsTrainer_v0.1.5.jar">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MODULE_DIR$/lib/AndorsTrainer_v0.1.5.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
129
createProject.bat
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
@echo off
|
||||||
|
echo.
|
||||||
|
echo ***
|
||||||
|
echo *** createProject v1.0 (2024-08-24)
|
||||||
|
echo ***
|
||||||
|
echo *** This script will help to setup an ATCS project
|
||||||
|
echo *** and connect it to a repo on Github
|
||||||
|
echo ***
|
||||||
|
echo.
|
||||||
|
rem Save this script anywhere on your PC (e.g. C:\AT\createProject.bat)
|
||||||
|
rem Then open a command shell: CMD
|
||||||
|
rem and call the script in the shell.
|
||||||
|
|
||||||
|
if "%1"=="" goto :noParamError
|
||||||
|
|
||||||
|
echo You have entered:
|
||||||
|
echo.
|
||||||
|
echo ATCS-project: %1
|
||||||
|
echo in Directory: %2
|
||||||
|
echo Github user: %3
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
if "%3"=="" goto :help
|
||||||
|
if not "%4"=="" goto :help
|
||||||
|
|
||||||
|
if not exist %2 md %2
|
||||||
|
|
||||||
|
rem --- Create ATCS project (if not already done)
|
||||||
|
:atcs
|
||||||
|
if not exist %2\%1\created\drawable\char_hero.png (
|
||||||
|
echo.
|
||||||
|
echo Do the following steps:
|
||||||
|
echo.
|
||||||
|
echo 1. Start ATCS
|
||||||
|
echo 2. Create your ATCS workspace in %2
|
||||||
|
echo 3. Add the new project %1
|
||||||
|
echo 4. Exit ATCS
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
goto :atcs
|
||||||
|
) else (
|
||||||
|
echo ATCS Project exists
|
||||||
|
)
|
||||||
|
|
||||||
|
rem --- Create git repository
|
||||||
|
rem This is the really important part :)
|
||||||
|
rem -- go into project dir (even if we do not need to create the git repo)
|
||||||
|
echo cd %2\%1
|
||||||
|
cd %2\%1
|
||||||
|
|
||||||
|
if not exist %2\%1\readme.md (
|
||||||
|
echo creating readme
|
||||||
|
|
||||||
|
echo # %1 > readme.md
|
||||||
|
) else (
|
||||||
|
echo readme already exists
|
||||||
|
)
|
||||||
|
|
||||||
|
if not exist %2\%1\.gitignore (
|
||||||
|
echo creating gitignore
|
||||||
|
|
||||||
|
echo .workspace > .gitignore
|
||||||
|
echo .project >> .gitignore
|
||||||
|
echo .workspace.json >> .gitignore
|
||||||
|
echo .project.json >> .gitignore
|
||||||
|
echo altered/drawable >> .gitignore
|
||||||
|
echo altered/drawable/* >> .gitignore
|
||||||
|
echo created/drawable >> .gitignore
|
||||||
|
echo created/drawable/* >> .gitignore
|
||||||
|
echo tmp/res/values/loadresources.xml >> .gitignore
|
||||||
|
) else (
|
||||||
|
echo gitignore already existed
|
||||||
|
)
|
||||||
|
|
||||||
|
:git
|
||||||
|
if not exist %2\%1\.git (
|
||||||
|
echo Initializing git
|
||||||
|
git init -b main || (
|
||||||
|
echo "failed to init git. Please make sure it is installed"
|
||||||
|
pause
|
||||||
|
goto :git
|
||||||
|
)
|
||||||
|
:git_commit
|
||||||
|
git add readme.md
|
||||||
|
git add .gitignore
|
||||||
|
git commit -m "Init project" || (
|
||||||
|
echo "failed to create the initial commit."
|
||||||
|
pause
|
||||||
|
goto :git_commit
|
||||||
|
)
|
||||||
|
echo Done initializing git
|
||||||
|
) else (
|
||||||
|
echo git was already initialized
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Now create your repo %1 on https://github.com/%3 (if not already done)
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
echo pushing to git repo https://github.com/%3/%1.git
|
||||||
|
git remote add origin https://github.com/%3/%1.git
|
||||||
|
git push -u origin main
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo At last you have to find the repo in your git client:
|
||||||
|
echo - In Smartgit: Menu option: Repository / Search for repository
|
||||||
|
echo.
|
||||||
|
goto :end
|
||||||
|
|
||||||
|
:noParamError
|
||||||
|
echo.
|
||||||
|
echo You have given no parameter.
|
||||||
|
echo Maybe you have just double clicked it? That won't work.
|
||||||
|
echo I have opened a CMD shell for you. Enter the command in that shell.
|
||||||
|
start cmd
|
||||||
|
echo Please switch to the CMD shell
|
||||||
|
|
||||||
|
:help
|
||||||
|
echo.
|
||||||
|
echo Enter the command with 3 parameters:
|
||||||
|
echo %0 project path git-user
|
||||||
|
echo.
|
||||||
|
echo Example: %0 feygard_1 c:\AT\ATCS NutAndor
|
||||||
|
echo.
|
||||||
|
|
||||||
|
:end
|
||||||
|
echo.
|
||||||
|
echo *** End ***
|
||||||
|
pause
|
||||||
@@ -111,11 +111,14 @@ public class Map implements Iterable<MapLayer>
|
|||||||
|
|
||||||
public MapLayer addLayer(MapLayer layer) {
|
public MapLayer addLayer(MapLayer layer) {
|
||||||
layer.setMap(this);
|
layer.setMap(this);
|
||||||
layers.add(layer);
|
|
||||||
if (layer instanceof TileLayer) {
|
if (layer instanceof TileLayer) {
|
||||||
tileLayers.add((TileLayer) layer);
|
tileLayers.add((TileLayer) layer);
|
||||||
|
layers.add(layer);
|
||||||
} else if (layer instanceof ObjectGroup) {
|
} else if (layer instanceof ObjectGroup) {
|
||||||
|
layers.insertElementAt(layer, objectGroups.size());
|
||||||
objectGroups.add((ObjectGroup) layer);
|
objectGroups.add((ObjectGroup) layer);
|
||||||
|
} else {
|
||||||
|
layers.add(layer);
|
||||||
}
|
}
|
||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class MapObject implements Cloneable
|
|||||||
{
|
{
|
||||||
private Properties properties = new Properties();
|
private Properties properties = new Properties();
|
||||||
private ObjectGroup objectGroup;
|
private ObjectGroup objectGroup;
|
||||||
private Rectangle bounds = new Rectangle();
|
private Rectangle bounds;
|
||||||
private String name = "Object";
|
private String name = "Object";
|
||||||
private String type = "";
|
private String type = "";
|
||||||
private String imageSource = "";
|
private String imageSource = "";
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class Sprite
|
|||||||
|
|
||||||
private String name = null;
|
private String name = null;
|
||||||
private int id = -1;
|
private int id = -1;
|
||||||
private int flags = KEY_LOOP;
|
private int flags;
|
||||||
private float frameRate = 1.0f; //one fps
|
private float frameRate = 1.0f; //one fps
|
||||||
private Tile[] frames;
|
private Tile[] frames;
|
||||||
|
|
||||||
|
|||||||
@@ -98,27 +98,46 @@ public class TileSet implements Iterable<Tile>
|
|||||||
|
|
||||||
File f = new File(imgFilename);
|
File f = new File(imgFilename);
|
||||||
|
|
||||||
Image image = ImageIO.read(f.getCanonicalFile());
|
BufferedImage image;
|
||||||
|
try {
|
||||||
|
image = ImageIO.read(f.getCanonicalFile());
|
||||||
|
} catch (IOException e) { throw new IOException("Failed to load " + imgFilename);
|
||||||
|
}
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
throw new IOException("Failed to load " + tilebmpFile);
|
throw new IOException("Failed to load " + imgFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
tilebmpFile = f;
|
||||||
|
tileDimensions = new Rectangle(cutter.getTileDimensions());
|
||||||
|
|
||||||
if (transparentColor != null) {
|
// Toolkit tk = Toolkit.getDefaultToolkit();
|
||||||
int rgb = transparentColor.getRGB();
|
//
|
||||||
image = tk.createImage(
|
// if (transparentColor != null) {
|
||||||
new FilteredImageSource(image.getSource(),
|
// int rgb = transparentColor.getRGB();
|
||||||
new TransparentImageFilter(rgb)));
|
// image = tk.createImage(
|
||||||
|
// new FilteredImageSource(image.getSource(),
|
||||||
|
// new TransparentImageFilter(rgb)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// BufferedImage buffered = new BufferedImage(
|
||||||
|
// image.getWidth(null),
|
||||||
|
// image.getHeight(null),
|
||||||
|
// BufferedImage.TYPE_INT_ARGB);
|
||||||
|
// buffered.getGraphics().drawImage(image, 0, 0, null);
|
||||||
|
|
||||||
|
importTileBitmap(image, cutter);
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferedImage buffered = new BufferedImage(
|
public void weakImportTileBitmap(String imgFilename, TileCutter cutter)
|
||||||
image.getWidth(null),
|
throws IOException
|
||||||
image.getHeight(null),
|
{
|
||||||
BufferedImage.TYPE_INT_ARGB);
|
setTilesetImageFilename(imgFilename);
|
||||||
buffered.getGraphics().drawImage(image, 0, 0, null);
|
|
||||||
|
File f = new File(imgFilename);
|
||||||
|
|
||||||
|
tilebmpFile = f;
|
||||||
|
tileDimensions = new Rectangle(cutter.getTileDimensions());
|
||||||
|
|
||||||
importTileBitmap(buffered, cutter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFromProject(String name, TMXMap tmxMap, int tileWidth, int tileHeight) {
|
public void loadFromProject(String name, TMXMap tmxMap, int tileWidth, int tileHeight) {
|
||||||
|
|||||||
@@ -913,7 +913,8 @@ public class TMXMapReader
|
|||||||
private class MapEntityResolver implements EntityResolver
|
private class MapEntityResolver implements EntityResolver
|
||||||
{
|
{
|
||||||
public InputSource resolveEntity(String publicId, String systemId) {
|
public InputSource resolveEntity(String publicId, String systemId) {
|
||||||
if (systemId.equals("http://mapeditor.org/dtd/1.0/map.dtd")) {
|
if (systemId.equals("http://mapeditor.org/dtd/1.0/map.dtd") ||
|
||||||
|
systemId.equals("https://mapeditor.org/dtd/1.0/map.dtd")) {
|
||||||
return new InputSource(TMXMapReader.class.getResourceAsStream(
|
return new InputSource(TMXMapReader.class.getResourceAsStream(
|
||||||
"resources/map.dtd"));
|
"resources/map.dtd"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ import java.util.Vector;
|
|||||||
import java.util.zip.DeflaterOutputStream;
|
import java.util.zip.DeflaterOutputStream;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||||
|
|
||||||
import tiled.core.AnimatedTile;
|
import tiled.core.AnimatedTile;
|
||||||
import tiled.core.Map;
|
import tiled.core.Map;
|
||||||
import tiled.core.MapLayer;
|
import tiled.core.MapLayer;
|
||||||
@@ -150,7 +153,7 @@ public class TMXMapWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void writeMap(Map map, XMLWriter w, String wp) throws IOException {
|
private void writeMap(Map map, XMLWriter w, String wp) throws IOException {
|
||||||
w.writeDocType("map", null, "http://mapeditor.org/dtd/1.0/map.dtd");
|
w.writeDocType("map", null, "https://mapeditor.org/dtd/1.0/map.dtd");
|
||||||
w.startElement("map");
|
w.startElement("map");
|
||||||
|
|
||||||
w.writeAttribute("version", "1.0");
|
w.writeAttribute("version", "1.0");
|
||||||
@@ -181,7 +184,12 @@ public class TMXMapWriter
|
|||||||
firstgid += tileset.getMaxTileId() + 1;
|
firstgid += tileset.getMaxTileId() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MapLayer layer : map) {
|
for (MapLayer layer : map.getTileLayers()) {
|
||||||
|
writeMapLayer(layer, w, wp);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (MapLayer layer : map.getObjectGroup()) {
|
||||||
|
if (map.getTileLayers().contains(layer)) continue;
|
||||||
writeMapLayer(layer, w, wp);
|
writeMapLayer(layer, w, wp);
|
||||||
}
|
}
|
||||||
firstGidPerTileset = null;
|
firstGidPerTileset = null;
|
||||||
@@ -233,7 +241,15 @@ public class TMXMapWriter
|
|||||||
} else {
|
} else {
|
||||||
w.startElement("tileset");
|
w.startElement("tileset");
|
||||||
w.writeAttribute("firstgid", getFirstGidForTileset(set));
|
w.writeAttribute("firstgid", getFirstGidForTileset(set));
|
||||||
|
if (set.sheet != null && set.sheet.parent.getDataType() == Type.source) {
|
||||||
|
String fileName = set.getName();
|
||||||
|
if (fileName.length() > 3 && !(fileName.substring(fileName.length() - 4).equalsIgnoreCase(".png"))) {
|
||||||
|
fileName += ".png";
|
||||||
|
}
|
||||||
|
w.writeAttribute("source", (TMXMapSet.DEFAULT_REL_PATH_TO_DRAWABLE + fileName).replace("\\", "/"));
|
||||||
|
} else {
|
||||||
w.writeAttribute("source", getRelativePath(wp, source));
|
w.writeAttribute("source", getRelativePath(wp, source));
|
||||||
|
}
|
||||||
if (set.getBaseDir() != null) {
|
if (set.getBaseDir() != null) {
|
||||||
w.writeAttribute("basedir", set.getBaseDir());
|
w.writeAttribute("basedir", set.getBaseDir());
|
||||||
}
|
}
|
||||||
@@ -274,7 +290,15 @@ public class TMXMapWriter
|
|||||||
|
|
||||||
if (tileBitmapFile != null) {
|
if (tileBitmapFile != null) {
|
||||||
w.startElement("image");
|
w.startElement("image");
|
||||||
|
if (set.sheet != null && set.sheet.parent.getDataType() == Type.source) {
|
||||||
|
String fileName = set.getName();
|
||||||
|
if (fileName.length() > 3 && !(fileName.substring(fileName.length() - 4).equalsIgnoreCase(".png"))) {
|
||||||
|
fileName += ".png";
|
||||||
|
}
|
||||||
|
w.writeAttribute("source", (TMXMapSet.DEFAULT_REL_PATH_TO_DRAWABLE + fileName).replace("\\", "/"));
|
||||||
|
} else {
|
||||||
w.writeAttribute("source", getRelativePath(wp, tileBitmapFile));
|
w.writeAttribute("source", getRelativePath(wp, tileBitmapFile));
|
||||||
|
}
|
||||||
if (set.sheetDimensions != null) {
|
if (set.sheetDimensions != null) {
|
||||||
w.writeAttribute("width", set.sheetDimensions.width);
|
w.writeAttribute("width", set.sheetDimensions.width);
|
||||||
w.writeAttribute("height", set.sheetDimensions.height);
|
w.writeAttribute("height", set.sheetDimensions.height);
|
||||||
@@ -564,7 +588,7 @@ public class TMXMapWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Iterate while parents are the same
|
// Iterate while parents are the same
|
||||||
int shared = 0;
|
int shared;
|
||||||
int maxShared = Math.min(fromParents.size(), toParents.size());
|
int maxShared = Math.min(fromParents.size(), toParents.size());
|
||||||
for (shared = 0; shared < maxShared; shared++) {
|
for (shared = 0; shared < maxShared; shared++) {
|
||||||
String fromParent = fromParents.get(shared);
|
String fromParent = fromParents.get(shared);
|
||||||
|
|||||||
BIN
lib/jide-oss.jar
405
minify/com/whoischarles/util/json/Minify.java
Normal file
@@ -0,0 +1,405 @@
|
|||||||
|
/**
|
||||||
|
* ----------------------
|
||||||
|
* Minify.java 2015-10-04
|
||||||
|
* ----------------------
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015 Charles Bihis (www.whoischarles.com)
|
||||||
|
*
|
||||||
|
* This work is an adaptation of JSMin.java published by John Reilly which is a translation from C to Java of jsmin.c
|
||||||
|
* published by Douglas Crockford. Permission is hereby granted to use this Java version under the same conditions as
|
||||||
|
* the original jsmin.c on which all of these derivatives are based.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* ---------------------
|
||||||
|
* JSMin.java 2006-02-13
|
||||||
|
* ---------------------
|
||||||
|
*
|
||||||
|
* Copyright (c) 2006 John Reilly (www.inconspicuous.org)
|
||||||
|
*
|
||||||
|
* This work is a translation from C to Java of jsmin.c published by Douglas Crockford. Permission is hereby granted to
|
||||||
|
* use the Java version under the same conditions as the jsmin.c on which it is based.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* ------------------
|
||||||
|
* jsmin.c 2003-04-21
|
||||||
|
* ------------------
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 Douglas Crockford (www.crockford.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||||
|
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* The Software shall be used for Good, not Evil.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||||
|
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.whoischarles.util.json;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.PushbackInputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minify.java is written by Charles Bihis (www.whoischarles.com) and is adapted from JSMin.java written by John Reilly
|
||||||
|
* (www.inconspicuous.org) which is itself a translation of jsmin.c written by Douglas Crockford (www.crockford.com).
|
||||||
|
*
|
||||||
|
* @see <a href="http://www.unl.edu/ucomm/templatedependents/JSMin.java">http://www.unl.edu/ucomm/templatedependents/JSMin.java</a>
|
||||||
|
* @see <a href="http://www.crockford.com/javascript/jsmin.c">http://www.crockford.com/javascript/jsmin.c</a>
|
||||||
|
*/
|
||||||
|
public class Minify {
|
||||||
|
|
||||||
|
private static final int EOF = -1;
|
||||||
|
|
||||||
|
private PushbackInputStream in;
|
||||||
|
private OutputStream out;
|
||||||
|
private int currChar;
|
||||||
|
private int nextChar;
|
||||||
|
private int line;
|
||||||
|
private int column;
|
||||||
|
|
||||||
|
public static enum Action {
|
||||||
|
OUTPUT_CURR, DELETE_CURR, DELETE_NEXT
|
||||||
|
}
|
||||||
|
|
||||||
|
public Minify() {
|
||||||
|
this.in = null;
|
||||||
|
this.out = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minifies the input JSON string.
|
||||||
|
*
|
||||||
|
* Takes the input JSON string and deletes the characters which are insignificant to JavaScipt. Comments will be
|
||||||
|
* removed, tabs will be replaced with spaces, carriage returns will be replaced with line feeds, and most spaces
|
||||||
|
* and line feeds will be removed. The result will be returned.
|
||||||
|
*
|
||||||
|
* @param json The JSON string for which to minify
|
||||||
|
* @return A minified, yet functionally identical, version of the input JSON string
|
||||||
|
*/
|
||||||
|
public String minify(String json) {
|
||||||
|
InputStream in = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8));
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
try {
|
||||||
|
minify(in, out);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return out.toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes an input stream to a JSON string and outputs minified JSON to the output stream.
|
||||||
|
*
|
||||||
|
* Takes the input JSON via the input stream and deletes the characters which are insignificant to JavaScript.
|
||||||
|
* Comments will be removed, tabs will be replaced with spaaces, carriage returns will be replaced with line feeds,
|
||||||
|
* and most spaces and line feeds will be removed. The result is streamed to the output stream.
|
||||||
|
*
|
||||||
|
* @param in The <code>InputStream</code> from which to get the un-minified JSON
|
||||||
|
* @param out The <code>OutputStream</code> where the resulting minified JSON will be streamed to
|
||||||
|
* @throws IOException
|
||||||
|
* @throws UnterminatedRegExpLiteralException
|
||||||
|
* @throws UnterminatedCommentException
|
||||||
|
* @throws UnterminatedStringLiteralException
|
||||||
|
*/
|
||||||
|
public void minify(InputStream in, OutputStream out) throws IOException, UnterminatedRegExpLiteralException,
|
||||||
|
UnterminatedCommentException,
|
||||||
|
UnterminatedStringLiteralException {
|
||||||
|
|
||||||
|
// Initialize
|
||||||
|
this.in = new PushbackInputStream(in);
|
||||||
|
this.out = out;
|
||||||
|
this.line = 0;
|
||||||
|
this.column = 0;
|
||||||
|
// currChar = '\n';
|
||||||
|
// action(Action.DELETE_NEXT);
|
||||||
|
currChar = get();
|
||||||
|
nextChar = peek();
|
||||||
|
|
||||||
|
// Process input
|
||||||
|
while (currChar != EOF) {
|
||||||
|
switch (currChar) {
|
||||||
|
|
||||||
|
case ' ':
|
||||||
|
if (isAlphanum(nextChar)) {
|
||||||
|
action(Action.OUTPUT_CURR);
|
||||||
|
} else {
|
||||||
|
action(Action.DELETE_CURR);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '\n':
|
||||||
|
switch (nextChar) {
|
||||||
|
case '{':
|
||||||
|
case '[':
|
||||||
|
case '(':
|
||||||
|
case '+':
|
||||||
|
case '-':
|
||||||
|
action(Action.OUTPUT_CURR);
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
action(Action.DELETE_NEXT);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (isAlphanum(nextChar)) {
|
||||||
|
action(Action.OUTPUT_CURR);
|
||||||
|
} else {
|
||||||
|
action(Action.DELETE_CURR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
switch (nextChar) {
|
||||||
|
case ' ':
|
||||||
|
if (isAlphanum(currChar)) {
|
||||||
|
action(Action.OUTPUT_CURR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
action(Action.DELETE_NEXT);
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
switch (currChar) {
|
||||||
|
case '}':
|
||||||
|
case ']':
|
||||||
|
case ')':
|
||||||
|
case '+':
|
||||||
|
case '-':
|
||||||
|
case '"':
|
||||||
|
case '\'':
|
||||||
|
action(Action.OUTPUT_CURR);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (isAlphanum(currChar)) {
|
||||||
|
action(Action.OUTPUT_CURR);
|
||||||
|
} else {
|
||||||
|
action(Action.DELETE_NEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
action(Action.OUTPUT_CURR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the current character with an appropriate action.
|
||||||
|
*
|
||||||
|
* The action that occurs is determined by the current character. The options are:
|
||||||
|
*
|
||||||
|
* 1. Output currChar: output currChar, copy nextChar to currChar, get the next character and save it to nextChar
|
||||||
|
* 2. Delete currChar: copy nextChar to currChar, get the next character and save it to nextChar
|
||||||
|
* 3. Delete nextChar: get the next character and save it to nextChar
|
||||||
|
*
|
||||||
|
* This method essentially treats a string as a single character. Also recognizes regular expressions if they are
|
||||||
|
* preceded by '(', ',', or '='.
|
||||||
|
*
|
||||||
|
* @param action The action to perform
|
||||||
|
* @throws IOException
|
||||||
|
* @throws UnterminatedRegExpLiteralException
|
||||||
|
* @throws UnterminatedCommentException
|
||||||
|
* @throws UnterminatedStringLiteralException
|
||||||
|
*/
|
||||||
|
private void action(Action action) throws IOException, UnterminatedRegExpLiteralException, UnterminatedCommentException,
|
||||||
|
UnterminatedStringLiteralException {
|
||||||
|
|
||||||
|
// Process action
|
||||||
|
switch (action) {
|
||||||
|
|
||||||
|
case OUTPUT_CURR:
|
||||||
|
out.write(currChar);
|
||||||
|
|
||||||
|
case DELETE_CURR:
|
||||||
|
currChar = nextChar;
|
||||||
|
|
||||||
|
if (currChar == '\'' || currChar == '"') {
|
||||||
|
for ( ; ; ) {
|
||||||
|
out.write(currChar);
|
||||||
|
currChar = get();
|
||||||
|
if (currChar == nextChar) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (currChar <= '\n') {
|
||||||
|
throw new UnterminatedStringLiteralException(line,
|
||||||
|
column);
|
||||||
|
}
|
||||||
|
if (currChar == '\\') {
|
||||||
|
out.write(currChar);
|
||||||
|
currChar = get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case DELETE_NEXT:
|
||||||
|
nextChar = next();
|
||||||
|
if (nextChar == '/'
|
||||||
|
&& (currChar == '(' || currChar == ',' || currChar == '=' || currChar == ':')) {
|
||||||
|
out.write(currChar);
|
||||||
|
out.write(nextChar);
|
||||||
|
for ( ; ; ) {
|
||||||
|
currChar = get();
|
||||||
|
if (currChar == '/') {
|
||||||
|
break;
|
||||||
|
} else if (currChar == '\\') {
|
||||||
|
out.write(currChar);
|
||||||
|
currChar = get();
|
||||||
|
} else if (currChar <= '\n') {
|
||||||
|
throw new UnterminatedRegExpLiteralException(line,
|
||||||
|
column);
|
||||||
|
}
|
||||||
|
out.write(currChar);
|
||||||
|
}
|
||||||
|
nextChar = next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether a given character is a letter, digit, underscore, dollar sign, or non-ASCII character.
|
||||||
|
*
|
||||||
|
* @param c The character to compare
|
||||||
|
* @return True if the character is a letter, digit, underscore, dollar sign, or non-ASCII character. False otherwise.
|
||||||
|
*/
|
||||||
|
private boolean isAlphanum(int c) {
|
||||||
|
return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z')
|
||||||
|
|| c == '_' || c == '$' || c == '\\' || c > 126);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next character from the input stream.
|
||||||
|
*
|
||||||
|
* Will pop the next character from the input stack. If the character is a control character, translate it to a space
|
||||||
|
* or line feed.
|
||||||
|
*
|
||||||
|
* @return The next character from the input stream
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private int get() throws IOException {
|
||||||
|
int c = in.read();
|
||||||
|
|
||||||
|
if (c == '\n') {
|
||||||
|
line++;
|
||||||
|
column = 0;
|
||||||
|
} else {
|
||||||
|
column++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c >= ' ' || c == '\n' || c == EOF) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == '\r') {
|
||||||
|
column = 0;
|
||||||
|
return '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
return ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next character from the input stream without popping it from the stack.
|
||||||
|
*
|
||||||
|
* @return The next character from the input stream
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private int peek() throws IOException {
|
||||||
|
int lookaheadChar = in.read();
|
||||||
|
in.unread(lookaheadChar);
|
||||||
|
return lookaheadChar;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the next character from the input stream, excluding comments.
|
||||||
|
*
|
||||||
|
* Will read from the input stream via the <code>get()</code> method. Will exclude characters that are part of
|
||||||
|
* comments. <code>peek()</code> is used to se if a '/' is followed by a '/' or a '*' for the purpose of identifying
|
||||||
|
* comments.
|
||||||
|
*
|
||||||
|
* @return The next character from the input stream, excluding characters from comments
|
||||||
|
* @throws IOException
|
||||||
|
* @throws UnterminatedCommentException
|
||||||
|
*/
|
||||||
|
private int next() throws IOException, UnterminatedCommentException {
|
||||||
|
int c = get();
|
||||||
|
|
||||||
|
if (c == '/') {
|
||||||
|
switch (peek()) {
|
||||||
|
|
||||||
|
case '/':
|
||||||
|
for ( ; ; ) {
|
||||||
|
c = get();
|
||||||
|
if (c <= '\n') {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case '*':
|
||||||
|
get();
|
||||||
|
for ( ; ; ) {
|
||||||
|
switch (get()) {
|
||||||
|
case '*':
|
||||||
|
if (peek() == '/') {
|
||||||
|
get();
|
||||||
|
return ' ';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EOF:
|
||||||
|
throw new UnterminatedCommentException(line, column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception to be thrown when an unterminated comment appears in the input.
|
||||||
|
*/
|
||||||
|
public static class UnterminatedCommentException extends Exception {
|
||||||
|
public UnterminatedCommentException(int line, int column) {
|
||||||
|
super("Unterminated comment at line " + line + " and column " + column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception to be thrown when an unterminated string literal appears in the input.
|
||||||
|
*/
|
||||||
|
public static class UnterminatedStringLiteralException extends Exception {
|
||||||
|
public UnterminatedStringLiteralException(int line, int column) {
|
||||||
|
super("Unterminated string literal at line " + line + " and column " + column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception to be thrown when an unterminated regular expression literal appears in the input.
|
||||||
|
*/
|
||||||
|
public static class UnterminatedRegExpLiteralException extends Exception {
|
||||||
|
public UnterminatedRegExpLiteralException(int line, int column) {
|
||||||
|
super("Unterminated regular expression at line " + line + " and column " + column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
packaging/Linux/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
/ATCS_v*.zip
|
|
||||||
/ATCS_v*.zip.rename
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
ATCS_DIR=$(dirname $(readlink -f "$0" || greadlink -f "$0" || stat -f "$0"))
|
|
||||||
MAX_MEM=512M
|
|
||||||
CP=$(find ${ATCS_DIR}/lib/ -name '*.jar' | paste -sd: -)
|
|
||||||
JAVA=java
|
|
||||||
JAVA_OPTS=
|
|
||||||
ENV_FILE=${ATCS_DIR}/ATCS.env
|
|
||||||
MAIN_CLASS=com.gpl.rpg.atcontentstudio.ATContentStudio
|
|
||||||
|
|
||||||
if [ -f ${ENV_FILE} ]
|
|
||||||
then
|
|
||||||
source ${ENV_FILE}
|
|
||||||
else
|
|
||||||
echo "#MAX_MEM=${MAX_MEM}" > ${ENV_FILE}
|
|
||||||
echo "#JAVA=${JAVA}" >> ${ENV_FILE}
|
|
||||||
echo "#JAVA_OPTS=${JAVA_OPTS}" >> ${ENV_FILE}
|
|
||||||
echo "" >> ${ENV_FILE}
|
|
||||||
fi
|
|
||||||
|
|
||||||
export ENV_FILE
|
|
||||||
|
|
||||||
$JAVA ${JAVA_OPTS} -Xmx${MAX_MEM} -cp ${CP} ${MAIN_CLASS}
|
|
||||||
1
packaging/Linux/ATCS/lib/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
/*.jar
|
|
||||||
2
packaging/Manifest.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Main-Class: com.gpl.rpg.atcontentstudio.ATContentStudio
|
||||||
@@ -4,7 +4,7 @@ set "ATCS_DIR=%~dp0"
|
|||||||
set "MAX_MEM=512M"
|
set "MAX_MEM=512M"
|
||||||
set "CP=%ATCS_DIR%lib\*"
|
set "CP=%ATCS_DIR%lib\*"
|
||||||
set "JAVA=javaw.exe"
|
set "JAVA=javaw.exe"
|
||||||
set "JAVA_OPTS="
|
set "JAVA_OPTS=-DFONT_SCALE=1.0 -Dswing.aatext=true"
|
||||||
set "ENV_FILE=%ATCS_DIR%ATCS.env.bat"
|
set "ENV_FILE=%ATCS_DIR%ATCS.env.bat"
|
||||||
set "MAIN_CLASS=com.gpl.rpg.atcontentstudio.ATContentStudio"
|
set "MAIN_CLASS=com.gpl.rpg.atcontentstudio.ATContentStudio"
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
!include MUI2.nsh
|
!include MUI2.nsh
|
||||||
|
|
||||||
!define VERSION "0.6.2"
|
; Version will be passed as /DVERSION=vx.x.x
|
||||||
!define TRAINER_VERSION "0.1.4"
|
!define TRAINER_VERSION "0.1.5"
|
||||||
!define JAVA_BIN "javaw"
|
!define JAVA_BIN "java"
|
||||||
|
!define ATCS_SOURCE_DIR "..\..\"
|
||||||
|
|
||||||
Name "Andor's Trail Content Studio v${VERSION}"
|
Name "Andor's Trail Content Studio ${VERSION}"
|
||||||
OutFile "ATCS_v${VERSION}_Setup.exe"
|
OutFile "..\ATCS_${VERSION}_Setup.exe"
|
||||||
InstallDir "$PROGRAMFILES\ATCS\"
|
InstallDir "$PROGRAMFILES\ATCS\"
|
||||||
|
|
||||||
;SetCompressor /SOLID /FINAL lzma
|
;SetCompressor /SOLID /FINAL lzma
|
||||||
@@ -13,10 +14,10 @@ InstallDir "$PROGRAMFILES\ATCS\"
|
|||||||
Var StartMenuFolder
|
Var StartMenuFolder
|
||||||
|
|
||||||
!define MUI_WELCOMEPAGE_TITLE "Welcome to Andor's Trail Content Studio installer"
|
!define MUI_WELCOMEPAGE_TITLE "Welcome to Andor's Trail Content Studio installer"
|
||||||
!define MUI_WELCOMEPAGE_TEXT "This will install Andor's Trail Content Studio v${VERSION} installer"
|
!define MUI_WELCOMEPAGE_TEXT "This will install Andor's Trail Content Studio ${VERSION}"
|
||||||
!define MUI_FINISHPAGE_TEXT "Andor's Trail Content Studio v${VERSION} install completed !"
|
!define MUI_FINISHPAGE_TEXT "Andor's Trail Content Studio ${VERSION} - Install completed !"
|
||||||
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Andor's Trail Content Studio"
|
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Andor's Trail Content Studio"
|
||||||
!define MUI_PAGE_HEADER_TEXT "Installing Andor's Trail Content Studio v${VERSION}"
|
!define MUI_PAGE_HEADER_TEXT "Installing Andor's Trail Content Studio ${VERSION}"
|
||||||
|
|
||||||
|
|
||||||
;Start Menu Folder Page Configuration
|
;Start Menu Folder Page Configuration
|
||||||
@@ -46,24 +47,26 @@ Var StartMenuFolder
|
|||||||
!insertmacro MUI_UNPAGE_CONFIRM
|
!insertmacro MUI_UNPAGE_CONFIRM
|
||||||
!insertmacro MUI_UNPAGE_INSTFILES
|
!insertmacro MUI_UNPAGE_INSTFILES
|
||||||
|
|
||||||
|
|
||||||
!insertmacro MUI_LANGUAGE "English"
|
!insertmacro MUI_LANGUAGE "English"
|
||||||
|
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------------
|
||||||
Section install
|
Section install
|
||||||
|
|
||||||
|
;--- Create in ...\packaging\common\ ATCS.cmd ATCT.ico ATCS.jar
|
||||||
SetOutPath $INSTDIR
|
SetOutPath $INSTDIR
|
||||||
file "ATCS.ico"
|
file "ATCS.ico"
|
||||||
|
file "${ATCS_SOURCE_DIR}\packaging\common\ATCS.jar"
|
||||||
Delete "$INSTDIR\lib\*"
|
|
||||||
|
|
||||||
Call GetJRE
|
Call GetJRE
|
||||||
Pop $R0
|
Pop $R0
|
||||||
|
; file "${ATCS_SOURCE_DIR}\packaging\common\ATCS.cmd"
|
||||||
|
; !insertmacro _ReplaceInFile "ATCS.cmd" "java.exe" "$R0" (It was too much work this way)
|
||||||
FileOpen $9 "ATCS.cmd" w
|
FileOpen $9 "ATCS.cmd" w
|
||||||
FileWrite $9 '@echo off$\r$\n'
|
FileWrite $9 '@echo off$\r$\n'
|
||||||
FileWrite $9 '$\r$\n'
|
FileWrite $9 '$\r$\n'
|
||||||
FileWrite $9 'set "ATCS_DIR=%~dp0"$\r$\n'
|
FileWrite $9 'set "ATCS_DIR=%~dp0"$\r$\n'
|
||||||
FileWrite $9 'set "MAX_MEM=512M"$\r$\n'
|
FileWrite $9 'set "MAX_MEM=1024M"$\r$\n'
|
||||||
FileWrite $9 'set "CP=%ATCS_DIR%lib\*"$\r$\n'
|
FileWrite $9 'set "CP=%ATCS_DIR%lib\*"$\r$\n'
|
||||||
FileWrite $9 'set "JAVA=$R0"$\r$\n'
|
FileWrite $9 'set "JAVA=$R0"$\r$\n'
|
||||||
FileWrite $9 'set "JAVA_OPTS="$\r$\n'
|
FileWrite $9 'set "JAVA_OPTS="$\r$\n'
|
||||||
@@ -79,29 +82,15 @@ Section install
|
|||||||
FileWrite $9 ' echo.>>"%ENV_FILE%"$\r$\n'
|
FileWrite $9 ' echo.>>"%ENV_FILE%"$\r$\n'
|
||||||
FileWrite $9 ')$\r$\n'
|
FileWrite $9 ')$\r$\n'
|
||||||
FileWrite $9 '$\r$\n'
|
FileWrite $9 '$\r$\n'
|
||||||
FileWrite $9 'start "" "%JAVA%" %JAVA_OPTS% -Xmx%MAX_MEM% -cp "%CP%" %MAIN_CLASS%$\r$\n'
|
FileWrite $9 'start "" "%JAVA%" %JAVA_OPTS% -Xmx%MAX_MEM% -jar ATCS.jar$\r$\n'
|
||||||
FileClose $9
|
FileClose $9
|
||||||
|
|
||||||
SetOutPath "$INSTDIR\lib\"
|
|
||||||
file "jide-oss.jar"
|
|
||||||
file "ui.jar"
|
|
||||||
file "AndorsTrainer_v${TRAINER_VERSION}.jar"
|
|
||||||
file "junit-4.10.jar"
|
|
||||||
file "json_simple-1.1.jar"
|
|
||||||
file "ATCS_v${VERSION}.jar"
|
|
||||||
file "rsyntaxtextarea.jar"
|
|
||||||
file "prefuse.jar"
|
|
||||||
file "bsh-2.0b4.jar"
|
|
||||||
file "jsoup-1.10.2.jar"
|
|
||||||
|
|
||||||
SetOutPath $INSTDIR
|
|
||||||
|
|
||||||
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
||||||
|
|
||||||
|
|
||||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN "ATCS"
|
!insertmacro MUI_STARTMENU_WRITE_BEGIN "ATCS"
|
||||||
|
|
||||||
;Create shortcuts
|
;--- Create shortcuts
|
||||||
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
|
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
|
||||||
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Andor's Trail Content Studio.lnk" "$INSTDIR\ATCS.cmd" "" "$INSTDIR\ATCS.ico"
|
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Andor's Trail Content Studio.lnk" "$INSTDIR\ATCS.cmd" "" "$INSTDIR\ATCS.ico"
|
||||||
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
|
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
|
||||||
@@ -110,6 +99,8 @@ Section install
|
|||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------------
|
||||||
Section uninstall
|
Section uninstall
|
||||||
|
|
||||||
Delete "$INSTDIR\lib\jide-oss.jar"
|
Delete "$INSTDIR\lib\jide-oss.jar"
|
||||||
@@ -117,18 +108,17 @@ Section uninstall
|
|||||||
Delete "$INSTDIR\lib\junit-4.10.jar"
|
Delete "$INSTDIR\lib\junit-4.10.jar"
|
||||||
Delete "$INSTDIR\lib\json_simple-1.1.jar"
|
Delete "$INSTDIR\lib\json_simple-1.1.jar"
|
||||||
Delete "$INSTDIR\lib\AndorsTrainer_v${TRAINER_VERSION}.jar"
|
Delete "$INSTDIR\lib\AndorsTrainer_v${TRAINER_VERSION}.jar"
|
||||||
Delete "$INSTDIR\lib\ATCS_v${VERSION}.jar"
|
|
||||||
Delete "$INSTDIR\lib\rsyntaxtextarea.jar"
|
Delete "$INSTDIR\lib\rsyntaxtextarea.jar"
|
||||||
Delete "$INSTDIR\lib\prefuse.jar"
|
Delete "$INSTDIR\lib\prefuse.jar"
|
||||||
Delete "$INSTDIR\lib\bsh-2.0b4.jar"
|
Delete "$INSTDIR\lib\bsh-2.0b4.jar"
|
||||||
Delete "$INSTDIR\lib\jsoup-1.10.2.jar"
|
Delete "$INSTDIR\lib\jsoup-1.10.2.jar"
|
||||||
RMDir "$INSTDIR\lib\"
|
RMDir "$INSTDIR\lib\"
|
||||||
|
|
||||||
Delete "$INSTDIR\ATCS.ico"
|
Delete "$INSTDIR\ATCS.ico"
|
||||||
Delete "$INSTDIR\ATCS.cmd"
|
Delete "$INSTDIR\ATCS.cmd"
|
||||||
Delete "$INSTDIR\ATCS.env.bat"
|
Delete "$INSTDIR\ATCS.env.bat"
|
||||||
|
Delete "$INSTDIR\ATCS.jar"
|
||||||
Delete "$INSTDIR\Uninstall.exe"
|
Delete "$INSTDIR\Uninstall.exe"
|
||||||
|
|
||||||
RMDir "$INSTDIR"
|
RMDir "$INSTDIR"
|
||||||
|
|
||||||
!insertmacro MUI_STARTMENU_GETFOLDER "ATCS" $StartMenuFolder
|
!insertmacro MUI_STARTMENU_GETFOLDER "ATCS" $StartMenuFolder
|
||||||
@@ -140,19 +130,20 @@ Section uninstall
|
|||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------------
|
||||||
Function GetJRE
|
Function GetJRE
|
||||||
;
|
;
|
||||||
; Find JRE (javaw.exe)
|
; Find JRE (java.exe)
|
||||||
; DISABLED 1 - in .\jre directory (JRE Installed with application)
|
; DISABLED 1 - in .\jre directory (JRE Installed with application)
|
||||||
; 2 - in JAVA_HOME environment variable
|
; 2 - in JAVA_HOME environment variable
|
||||||
; 3 - in the registry
|
; 3 - in the registry
|
||||||
; 4 - assume javaw.exe in current dir or PATH
|
; 4 - assume java.exe in current dir or PATH
|
||||||
|
|
||||||
Push $R0
|
Push $R0
|
||||||
Push $R1
|
Push $R1
|
||||||
|
|
||||||
;ClearErrors
|
;ClearErrors
|
||||||
;StrCpy $R0 "$EXEDIR\jre\bin\javaw.exe"
|
;StrCpy $R0 "$EXEDIR\jre\bin\java.exe"
|
||||||
;IfFileExists $R0 JreFound
|
;IfFileExists $R0 JreFound
|
||||||
;StrCpy $R0 ""
|
;StrCpy $R0 ""
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
set "ATCS_DIR=%~dp0"
|
set "ATCS_DIR=%~dp0"
|
||||||
set "MAX_MEM=512M"
|
set "MAX_MEM=1024M"
|
||||||
set "CP=%ATCS_DIR%lib\*"
|
set "JAVA=java.exe"
|
||||||
set "JAVA=javaw.exe"
|
set "JAVA_OPTS=-DFONT_SCALE=1.0 -Dswing.aatext=true"
|
||||||
set "JAVA_OPTS="
|
|
||||||
set "ENV_FILE=%ATCS_DIR%ATCS.env.bat"
|
set "ENV_FILE=%ATCS_DIR%ATCS.env.bat"
|
||||||
set "MAIN_CLASS=com.gpl.rpg.atcontentstudio.ATContentStudio"
|
|
||||||
|
|
||||||
if exist "%ENV_FILE%" (
|
if exist "%ENV_FILE%" (
|
||||||
call "%ENV_FILE%"
|
call "%ENV_FILE%"
|
||||||
@@ -17,4 +15,4 @@ if exist "%ENV_FILE%" (
|
|||||||
echo.>>"%ENV_FILE%"
|
echo.>>"%ENV_FILE%"
|
||||||
)
|
)
|
||||||
|
|
||||||
start "" "%JAVA%" %JAVA_OPTS% -Xmx%MAX_MEM% -cp "%CP%" %MAIN_CLASS%
|
start "" "%JAVA%" %JAVA_OPTS% -Xmx%MAX_MEM% -jar "%ATCS_DIR%\ATCS.jar"
|
||||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
26
packaging/common/ATCS.sh
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
ATCS_DIR="$(dirname "$(readlink -f "$0" || greadlink -f "$0" || stat -f "$0")")"
|
||||||
|
echo "ATCS_DIR: '${ATCS_DIR}'"
|
||||||
|
|
||||||
|
MAX_MEM="512M"
|
||||||
|
JAVA="java"
|
||||||
|
JAVA_OPTS='-DFONT_SCALE=1.0 -Dswing.aatext=true'
|
||||||
|
|
||||||
|
ENV_FILE="${ATCS_DIR}/ATCS.env"
|
||||||
|
|
||||||
|
if [ -f "${ENV_FILE}" ]; then
|
||||||
|
source "${ENV_FILE}"
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "#MAX_MEM=\"${MAX_MEM}\""
|
||||||
|
echo "#JAVA=\"${JAVA}\""
|
||||||
|
echo "#JAVA_OPTS=\"${JAVA_OPTS}\""
|
||||||
|
echo ""
|
||||||
|
}>"${ENV_FILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export ENV_FILE
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# (spellchecker is disabled for this line, because we want it to be split into multiple arguments)
|
||||||
|
$JAVA ${JAVA_OPTS} -Xmx${MAX_MEM} -jar "${ATCS_DIR}/ATCS.jar"
|
||||||
1
packaging/package-windows.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
sh ./package.sh -windows
|
||||||
125
packaging/package.sh
Executable file
@@ -0,0 +1,125 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Script to build ATCS.jar, replicating IntelliJ artifact definition
|
||||||
|
# Linux and Windows compatible
|
||||||
|
|
||||||
|
# --- Platform Detection ---
|
||||||
|
if [ "$1" = "-windows" ]; then
|
||||||
|
echo "Got '-windows' flag. Running Windows version"
|
||||||
|
PLATFORM="WINDOWS"
|
||||||
|
else
|
||||||
|
echo "No '-windows' flag. Running Linux version"
|
||||||
|
PLATFORM="LINUX"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- Configuration ---
|
||||||
|
PACKAGING_DIR=$(dirname "$(readlink -f "$0" || greadlink -f "$0" || stat -f "$0")")
|
||||||
|
ATCS_SOURCE_DIR=$(dirname "${PACKAGING_DIR}")
|
||||||
|
TEMP_DIR="${PACKAGING_DIR}/tmp"
|
||||||
|
JAR_LOCATION="${PACKAGING_DIR}/ATCS.jar" # Output JAR location as per script
|
||||||
|
MANIFEST_LOCATION="${PACKAGING_DIR}/Manifest.txt"
|
||||||
|
VERSION_FILE="${ATCS_SOURCE_DIR}/res/ATCS_latest"
|
||||||
|
SOURCE_BASE_DIR="${ATCS_SOURCE_DIR}/src" # Base directory for standard source code
|
||||||
|
LIB_BASE_DIR="${ATCS_SOURCE_DIR}/lib" # Base directory for libraries
|
||||||
|
|
||||||
|
# --- **ADDITIONAL SOURCE CODE FOLDERS** ---
|
||||||
|
EXTRA_SOURCE_DIRS=(
|
||||||
|
"hacked-libtiled"
|
||||||
|
"minify"
|
||||||
|
"siphash-zackehh/src/main/java"
|
||||||
|
)
|
||||||
|
|
||||||
|
# --- Libraries to include ---
|
||||||
|
LIBRARIES=(
|
||||||
|
"bsh-2.0b4.jar"
|
||||||
|
"jide-oss.jar"
|
||||||
|
"json_simple-1.1.jar"
|
||||||
|
"jsoup-1.10.2.jar"
|
||||||
|
"junit-4.10.jar"
|
||||||
|
"prefuse.jar"
|
||||||
|
"rsyntaxtextarea.jar"
|
||||||
|
"ui.jar"
|
||||||
|
)
|
||||||
|
|
||||||
|
# --- Get version ---
|
||||||
|
echo "Getting version"
|
||||||
|
VERSION=$(tr -d '[:space:]' < "${VERSION_FILE}")
|
||||||
|
echo "Got version ${VERSION}"
|
||||||
|
|
||||||
|
# --- Prepare temporary directory ---
|
||||||
|
echo "Removing tmp folder"
|
||||||
|
rm -rf "${TEMP_DIR}"
|
||||||
|
echo "Recreating tmp folder"
|
||||||
|
mkdir -p "${TEMP_DIR}"
|
||||||
|
|
||||||
|
# --- **EXTRACT lib files directly to TEMP_DIR** ---
|
||||||
|
echo 'Extracting lib files to TEMP_DIR'
|
||||||
|
for LIB in "${LIBRARIES[@]}"; do
|
||||||
|
echo "Extracting library: ${LIB}"
|
||||||
|
unzip -qo "${LIB_BASE_DIR}/${LIB}" -d "${TEMP_DIR}" # Extract JAR contents to TEMP_DIR root
|
||||||
|
done
|
||||||
|
|
||||||
|
# --- Set ClassPath ---
|
||||||
|
echo "Getting source files"
|
||||||
|
# Find all java files in source directories
|
||||||
|
SOURCE_FILES=$(find "${SOURCE_BASE_DIR}" "${EXTRA_SOURCE_DIRS[@]/#/${ATCS_SOURCE_DIR}/}" -name "*.java" -print)
|
||||||
|
#echo "SourceFiles: ${SOURCE_FILES}"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# --- Build Java classes ---
|
||||||
|
echo 'Building java classes'
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# (we need word splitting here to pass multiple files)
|
||||||
|
javac -cp "${TEMP_DIR}" -d "${TEMP_DIR}" ${SOURCE_FILES}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Compilation failed. Please check errors above."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Compilation successful"
|
||||||
|
|
||||||
|
# --- Copy res stuff to temp folder ---
|
||||||
|
echo "Copying some stuff to temp folder"
|
||||||
|
cp -r "${ATCS_SOURCE_DIR}"/res/* "${TEMP_DIR}/"
|
||||||
|
mkdir -p "${TEMP_DIR}/com/gpl/rpg/atcontentstudio/img"
|
||||||
|
mkdir -p "${TEMP_DIR}/tiled/io/resources/"
|
||||||
|
cp -r "${ATCS_SOURCE_DIR}"/src/com/gpl/rpg/atcontentstudio/img/* "${TEMP_DIR}/com/gpl/rpg/atcontentstudio/img/" # some icons
|
||||||
|
cp -r "${ATCS_SOURCE_DIR}"/hacked-libtiled/tiled/io/resources/* "${TEMP_DIR}/tiled/io/resources/" # dtd file for tmx maps
|
||||||
|
cp "${VERSION_FILE}" "${TEMP_DIR}/" # Copy version file
|
||||||
|
|
||||||
|
# --- Create JAR file ---
|
||||||
|
echo ""
|
||||||
|
echo "Creating jar at location: ${JAR_LOCATION}"
|
||||||
|
|
||||||
|
cd "${TEMP_DIR}" || exit # Change to temp dir for JAR command
|
||||||
|
|
||||||
|
# JAR command WITHOUT lib directory
|
||||||
|
jar cfm "${JAR_LOCATION}" "${MANIFEST_LOCATION}" -C . .
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "JAR creation failed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "${PACKAGING_DIR}" || exit # Go back to packaging dir
|
||||||
|
|
||||||
|
echo ''
|
||||||
|
echo "Done creating jar at ${JAR_LOCATION}"
|
||||||
|
cp -f "${JAR_LOCATION}" "${PACKAGING_DIR}/common/ATCS.jar" # Copy JAR to versioned name
|
||||||
|
|
||||||
|
# --- Create archive ---
|
||||||
|
cd "${PACKAGING_DIR}" || exit
|
||||||
|
echo "Creating archive"
|
||||||
|
if [ "$PLATFORM" = "WINDOWS" ]; then
|
||||||
|
# Use PowerShell's Compress-Archive which is available by default on Windows
|
||||||
|
powershell.exe -Command "Compress-Archive -Path './common/*' -DestinationPath './ATCS_${VERSION}.zip' -Force"
|
||||||
|
else
|
||||||
|
# Use zip command on Linux
|
||||||
|
zip -r "ATCS_${VERSION}.zip" common/* # archive the 'common' folder which now contains the JAR and libs
|
||||||
|
fi
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Archive creation failed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Created archive at ${PACKAGING_DIR}/ATCS_${VERSION}.zip"
|
||||||
|
|
||||||
|
echo "Script finished."
|
||||||
1
res/ATCS_latest
Normal file
@@ -0,0 +1 @@
|
|||||||
|
v0.6.22
|
||||||
43
res/LICENSE.minify.txt
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
----------------------
|
||||||
|
Minify.java 2015-10-04
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Copyright (c) 2015 Charles Bihis (www.whoischarles.com)
|
||||||
|
|
||||||
|
This work is an adaptation of JSMin.java published by John Reilly which is a translation from C to Java of jsmin.c
|
||||||
|
published by Douglas Crockford. Permission is hereby granted to use this Java version under the same conditions as
|
||||||
|
the original jsmin.c on which all of these derivatives are based.
|
||||||
|
|
||||||
|
|
||||||
|
---------------------
|
||||||
|
JSMin.java 2006-02-13
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006 John Reilly (www.inconspicuous.org)
|
||||||
|
|
||||||
|
This work is a translation from C to Java of jsmin.c published by Douglas Crockford. Permission is hereby granted to
|
||||||
|
use the Java version under the same conditions as the jsmin.c on which it is based.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
------------------
|
||||||
|
jsmin.c 2003-04-21
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Copyright (c) 2002 Douglas Crockford (www.crockford.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||||
|
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||||
|
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||||
|
Software.
|
||||||
|
|
||||||
|
The Software shall be used for Good, not Evil.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||||
|
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
@@ -1,64 +1,94 @@
|
|||||||
atcs.spritesheet.actorconditions_1.category=actorcondition
|
atcs.spritesheet.actorconditions_1.category=actorcondition
|
||||||
atcs.spritesheet.actorconditions_2.category=actorcondition
|
atcs.spritesheet.actorconditions_2.category=actorcondition
|
||||||
atcs.spritesheet.actorconditions_japozero.category=actorcondition
|
atcs.spritesheet.actorconditions_japozero.category=actorcondition
|
||||||
|
atcs.spritesheet.actorconditions_newb.category=actorcondition
|
||||||
|
atcs.spritesheet.actorconditions_omi1.category=actorcondition
|
||||||
|
atcs.spritesheet.actorconditions_omi2.category=actorcondition
|
||||||
|
|
||||||
|
atcs.spritesheet.effect_blood3.animate=true
|
||||||
|
atcs.spritesheet.effect_blood4.animate=true
|
||||||
|
atcs.spritesheet.effect_bluetentacle.animate=true
|
||||||
|
atcs.spritesheet.effect_heal2.animate=true
|
||||||
|
atcs.spritesheet.effect_miss1.animate=true
|
||||||
|
atcs.spritesheet.effect_poison1.animate=true
|
||||||
|
atcs.spritesheet.effect_tometik1.animate=true
|
||||||
|
atcs.spritesheet.effect_tometik2.animate=true
|
||||||
|
|
||||||
atcs.spritesheet.items_armours.category=item
|
atcs.spritesheet.items_armours.category=item
|
||||||
atcs.spritesheet.items_armours_2.category=item
|
atcs.spritesheet.items_armours_2.category=item
|
||||||
atcs.spritesheet.items_armours_3.category=item
|
atcs.spritesheet.items_armours_3.category=item
|
||||||
atcs.spritesheet.items_weapons.category=item
|
|
||||||
atcs.spritesheet.items_weapons_2.category=item
|
|
||||||
atcs.spritesheet.items_weapons_3.category=item
|
|
||||||
atcs.spritesheet.items_jewelry.category=item
|
|
||||||
atcs.spritesheet.items_rings_1.category=item
|
|
||||||
atcs.spritesheet.items_necklaces_1.category=item
|
|
||||||
atcs.spritesheet.items_consumables.category=item
|
|
||||||
atcs.spritesheet.items_japozero.category=item
|
|
||||||
atcs.spritesheet.items_books.category=item
|
atcs.spritesheet.items_books.category=item
|
||||||
|
atcs.spritesheet.items_consumables.category=item
|
||||||
|
atcs.spritesheet.items_consumables_omi1.category=item
|
||||||
|
atcs.spritesheet.items_feygard1.category=item
|
||||||
|
atcs.spritesheet.items_g03_package_omi1.category=item
|
||||||
|
atcs.spritesheet.items_japozero.category=item
|
||||||
|
atcs.spritesheet.items_jewelry.category=item
|
||||||
atcs.spritesheet.items_misc.category=item
|
atcs.spritesheet.items_misc.category=item
|
||||||
atcs.spritesheet.items_misc_2.category=item
|
atcs.spritesheet.items_misc_2.category=item
|
||||||
atcs.spritesheet.items_misc_3.category=item
|
atcs.spritesheet.items_misc_3.category=item
|
||||||
atcs.spritesheet.items_misc_4.category=item
|
atcs.spritesheet.items_misc_4.category=item
|
||||||
atcs.spritesheet.items_misc_5.category=item
|
atcs.spritesheet.items_misc_5.category=item
|
||||||
atcs.spritesheet.items_misc_6.category=item
|
atcs.spritesheet.items_misc_6.category=item
|
||||||
|
atcs.spritesheet.items_necklaces_1.category=item
|
||||||
|
atcs.spritesheet.items_newb.category=item
|
||||||
|
atcs.spritesheet.items_omgeeky.category=item
|
||||||
|
atcs.spritesheet.items_omi2.category=item
|
||||||
|
atcs.spritesheet.items_phoenix01.category=item
|
||||||
atcs.spritesheet.items_reterski_1.category=item
|
atcs.spritesheet.items_reterski_1.category=item
|
||||||
|
atcs.spritesheet.items_rijackson_1.category=item
|
||||||
|
atcs.spritesheet.items_rings_1.category=item
|
||||||
atcs.spritesheet.items_tometik1.category=item
|
atcs.spritesheet.items_tometik1.category=item
|
||||||
atcs.spritesheet.items_tometik2.category=item
|
atcs.spritesheet.items_tometik2.category=item
|
||||||
atcs.spritesheet.items_tometik3.category=item
|
atcs.spritesheet.items_tometik3.category=item
|
||||||
|
atcs.spritesheet.items_weapons.category=item
|
||||||
|
atcs.spritesheet.items_weapons_2.category=item
|
||||||
|
atcs.spritesheet.items_weapons_3.category=item
|
||||||
|
|
||||||
atcs.spritesheet.monsters_armor1.category=monster
|
atcs.spritesheet.monsters_armor1.category=monster
|
||||||
|
atcs.spritesheet.monsters_arulirs.category=monster
|
||||||
|
|
||||||
|
atcs.spritesheet.monsters_cats.category=monster
|
||||||
atcs.spritesheet.monsters_dogs.category=monster
|
atcs.spritesheet.monsters_dogs.category=monster
|
||||||
atcs.spritesheet.monsters_eye1.category=monster
|
atcs.spritesheet.monsters_eye1.category=monster
|
||||||
atcs.spritesheet.monsters_eye2.category=monster
|
atcs.spritesheet.monsters_eye2.category=monster
|
||||||
atcs.spritesheet.monsters_eye3.category=monster
|
atcs.spritesheet.monsters_eye3.category=monster
|
||||||
atcs.spritesheet.monsters_eye4.category=monster
|
atcs.spritesheet.monsters_eye4.category=monster
|
||||||
|
atcs.spritesheet.monsters_fatboy73.category=monster
|
||||||
atcs.spritesheet.monsters_ghost1.category=monster
|
atcs.spritesheet.monsters_ghost1.category=monster
|
||||||
atcs.spritesheet.monsters_hydra1.category=monster
|
|
||||||
atcs.spritesheet.monsters_hydra1.sizex=64
|
atcs.spritesheet.monsters_gisons.category=monster
|
||||||
atcs.spritesheet.monsters_hydra1.sizey=64
|
atcs.spritesheet.monsters_guynmart.category=monster
|
||||||
|
|
||||||
atcs.spritesheet.monsters_insects.category=monster
|
atcs.spritesheet.monsters_insects.category=monster
|
||||||
|
atcs.spritesheet.monsters_johny.category=monster
|
||||||
|
atcs.spritesheet.monsters_karvis1.category=monster
|
||||||
|
atcs.spritesheet.monsters_karvis2.category=monster
|
||||||
|
atcs.spritesheet.monsters_ld1.category=monster
|
||||||
|
atcs.spritesheet.monsters_ld2.category=monster
|
||||||
atcs.spritesheet.monsters_liches.category=monster
|
atcs.spritesheet.monsters_liches.category=monster
|
||||||
atcs.spritesheet.monsters_mage.category=monster
|
atcs.spritesheet.monsters_mage.category=monster
|
||||||
atcs.spritesheet.monsters_mage2.category=monster
|
atcs.spritesheet.monsters_mage2.category=monster
|
||||||
|
atcs.spritesheet.monsters_maksiu1.category=monster
|
||||||
atcs.spritesheet.monsters_man1.category=monster
|
atcs.spritesheet.monsters_man1.category=monster
|
||||||
atcs.spritesheet.monsters_men.category=monster
|
atcs.spritesheet.monsters_men.category=monster
|
||||||
atcs.spritesheet.monsters_men2.category=monster
|
atcs.spritesheet.monsters_men2.category=monster
|
||||||
atcs.spritesheet.monsters_misc.category=monster
|
atcs.spritesheet.monsters_misc.category=monster
|
||||||
|
atcs.spritesheet.monsters_newb_1.category=monster
|
||||||
|
atcs.spritesheet.monsters_omi1.category=monster
|
||||||
|
atcs.spritesheet.monsters_omi1_b.category=monster
|
||||||
|
atcs.spritesheet.monsters_omi2.category=monster
|
||||||
|
atcs.spritesheet.monsters_phoenix01.category=monster
|
||||||
atcs.spritesheet.monsters_rats.category=monster
|
atcs.spritesheet.monsters_rats.category=monster
|
||||||
atcs.spritesheet.monsters_rogue1.category=monster
|
atcs.spritesheet.monsters_redshrike1.category=monster
|
||||||
atcs.spritesheet.monsters_skeleton1.category=monster
|
|
||||||
atcs.spritesheet.monsters_skeleton2.category=monster
|
|
||||||
atcs.spritesheet.monsters_snakes.category=monster
|
|
||||||
atcs.spritesheet.monsters_warrior1.category=monster
|
|
||||||
atcs.spritesheet.monsters_wraiths.category=monster
|
|
||||||
atcs.spritesheet.monsters_zombie1.category=monster
|
|
||||||
atcs.spritesheet.monsters_zombie2.category=monster
|
|
||||||
atcs.spritesheet.monsters_karvis1.category=monster
|
|
||||||
atcs.spritesheet.monsters_karvis2.category=monster
|
|
||||||
atcs.spritesheet.monsters_rltiles1.category=monster
|
atcs.spritesheet.monsters_rltiles1.category=monster
|
||||||
atcs.spritesheet.monsters_rltiles2.category=monster
|
atcs.spritesheet.monsters_rltiles2.category=monster
|
||||||
atcs.spritesheet.monsters_rltiles3.category=monster
|
atcs.spritesheet.monsters_rltiles3.category=monster
|
||||||
atcs.spritesheet.monsters_rltiles4.category=monster
|
atcs.spritesheet.monsters_rltiles4.category=monster
|
||||||
atcs.spritesheet.monsters_redshrike1.category=monster
|
atcs.spritesheet.monsters_rogue1.category=monster
|
||||||
atcs.spritesheet.monsters_ld1.category=monster
|
atcs.spritesheet.monsters_skeleton1.category=monster
|
||||||
atcs.spritesheet.monsters_ld2.category=monster
|
atcs.spritesheet.monsters_skeleton2.category=monster
|
||||||
|
atcs.spritesheet.monsters_snakes.category=monster
|
||||||
atcs.spritesheet.monsters_tometik1.category=monster
|
atcs.spritesheet.monsters_tometik1.category=monster
|
||||||
atcs.spritesheet.monsters_tometik2.category=monster
|
atcs.spritesheet.monsters_tometik2.category=monster
|
||||||
atcs.spritesheet.monsters_tometik3.category=monster
|
atcs.spritesheet.monsters_tometik3.category=monster
|
||||||
@@ -69,19 +99,36 @@ atcs.spritesheet.monsters_tometik7.category=monster
|
|||||||
atcs.spritesheet.monsters_tometik8.category=monster
|
atcs.spritesheet.monsters_tometik8.category=monster
|
||||||
atcs.spritesheet.monsters_tometik9.category=monster
|
atcs.spritesheet.monsters_tometik9.category=monster
|
||||||
atcs.spritesheet.monsters_tometik10.category=monster
|
atcs.spritesheet.monsters_tometik10.category=monster
|
||||||
|
atcs.spritesheet.monsters_warrior1.category=monster
|
||||||
|
atcs.spritesheet.monsters_unknown.category=monster
|
||||||
|
atcs.spritesheet.monsters_wraiths.category=monster
|
||||||
|
atcs.spritesheet.monsters_zombie1.category=monster
|
||||||
|
atcs.spritesheet.monsters_zombie2.category=monster
|
||||||
|
|
||||||
|
atcs.spritesheet.monsters_bosses_2x2.category=monster
|
||||||
|
atcs.spritesheet.monsters_bosses_2x2.sizex=64
|
||||||
|
atcs.spritesheet.monsters_bosses_2x2.sizey=64
|
||||||
|
atcs.spritesheet.monsters_cyclops.category=monster
|
||||||
|
atcs.spritesheet.monsters_cyclops.sizex=64
|
||||||
|
atcs.spritesheet.monsters_cyclops.sizey=96
|
||||||
atcs.spritesheet.monsters_demon1.category=monster
|
atcs.spritesheet.monsters_demon1.category=monster
|
||||||
atcs.spritesheet.monsters_demon1.sizex=64
|
atcs.spritesheet.monsters_demon1.sizex=64
|
||||||
atcs.spritesheet.monsters_demon1.sizey=64
|
atcs.spritesheet.monsters_demon1.sizey=64
|
||||||
atcs.spritesheet.monsters_demon2.category=monster
|
atcs.spritesheet.monsters_demon2.category=monster
|
||||||
atcs.spritesheet.monsters_demon2.sizex=64
|
atcs.spritesheet.monsters_demon2.sizex=64
|
||||||
atcs.spritesheet.monsters_demon2.sizey=64
|
atcs.spritesheet.monsters_demon2.sizey=64
|
||||||
atcs.spritesheet.monsters_cyclops.category=monster
|
atcs.spritesheet.monsters_giantbasilisk.category=monster
|
||||||
atcs.spritesheet.monsters_cyclops.sizex=64
|
atcs.spritesheet.monsters_giantbasilisk.sizex=64
|
||||||
atcs.spritesheet.monsters_cyclops.sizey=96
|
atcs.spritesheet.monsters_giantbasilisk.sizey=64
|
||||||
atcs.spritesheet.effect_blood3.animate=true
|
atcs.spritesheet.monsters_hydra1.category=monster
|
||||||
atcs.spritesheet.effect_blood4.animate=true
|
atcs.spritesheet.monsters_hydra1.sizex=64
|
||||||
atcs.spritesheet.effect_bluetentacle.animate=true
|
atcs.spritesheet.monsters_hydra1.sizey=64
|
||||||
atcs.spritesheet.effect_heal2.animate=true
|
atcs.spritesheet.monsters_newb_2.category=monster
|
||||||
atcs.spritesheet.effect_poison1.animate=true
|
atcs.spritesheet.monsters_newb_2.sizex=64
|
||||||
atcs.spritesheet.effect_tometik1.animate=true
|
atcs.spritesheet.monsters_newb_2.sizey=32
|
||||||
atcs.spritesheet.effect_tometik2.animate=true
|
atcs.spritesheet.monsters_newb_3.category=monster
|
||||||
|
atcs.spritesheet.monsters_newb_3.sizex=64
|
||||||
|
atcs.spritesheet.monsters_newb_3.sizey=64
|
||||||
|
atcs.spritesheet.monsters_newb_4.category=monster
|
||||||
|
atcs.spritesheet.monsters_newb_4.sizex=32
|
||||||
|
atcs.spritesheet.monsters_newb_4.sizey=64
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
package com.zackehh.siphash;
|
package com.zackehh.siphash;
|
||||||
|
|
||||||
import static com.zackehh.siphash.SipHashConstants.*;
|
import static com.zackehh.siphash.SipHashConstants.DEFAULT_C;
|
||||||
|
import static com.zackehh.siphash.SipHashConstants.DEFAULT_D;
|
||||||
|
import static com.zackehh.siphash.SipHashConstants.INITIAL_V0;
|
||||||
|
import static com.zackehh.siphash.SipHashConstants.INITIAL_V1;
|
||||||
|
import static com.zackehh.siphash.SipHashConstants.INITIAL_V2;
|
||||||
|
import static com.zackehh.siphash.SipHashConstants.INITIAL_V3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main entry point for SipHash, providing a basic hash
|
* Main entry point for SipHash, providing a basic hash
|
||||||
|
|||||||
6
src/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Main-Class: com.gpl.rpg.atcontentstudio.ATContentStudio
|
||||||
|
Class-Path: jide-oss.jar jsoup-1.10.2.jar ui.jar junit-4.10.jar AndorsTr
|
||||||
|
ainer_v0.1.5.jar prefuse.jar rsyntaxtextarea.jar bsh-2.0b4.jar json_sim
|
||||||
|
ple-1.1.jar
|
||||||
|
|
||||||
@@ -1,59 +1,75 @@
|
|||||||
package com.gpl.rpg.atcontentstudio;
|
package com.gpl.rpg.atcontentstudio;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.event.WindowAdapter;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.swing.UIManager;
|
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
|
||||||
|
|
||||||
import prefuse.data.expression.parser.ExpressionParser;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.StudioFrame;
|
import com.gpl.rpg.atcontentstudio.ui.StudioFrame;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector;
|
import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector;
|
||||||
|
import prefuse.data.expression.parser.ExpressionParser;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.HyperlinkEvent;
|
||||||
|
import javax.swing.event.HyperlinkListener;
|
||||||
|
import javax.swing.plaf.FontUIResource;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.http.HttpTimeoutException;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class ATContentStudio {
|
public class ATContentStudio {
|
||||||
|
|
||||||
public static final String APP_NAME = "Andor's Trail Content Studio";
|
public static final String APP_NAME = "Andor's Trail Content Studio";
|
||||||
public static final String APP_VERSION = "v0.6.2";
|
public static final String APP_VERSION = readVersionFromFile();
|
||||||
|
|
||||||
|
public static final String CHECK_UPDATE_URL = "https://andorstrail.com/static/ATCS_latest";
|
||||||
|
public static final String DOWNLOAD_URL = "https://andorstrail.com/viewtopic.php?f=6&t=4806";
|
||||||
|
|
||||||
|
public static final String FONT_SCALE_ENV_VAR_NAME = "FONT_SCALE";
|
||||||
|
|
||||||
public static boolean STARTED = false;
|
public static boolean STARTED = false;
|
||||||
|
public static float SCALING = 1.0f;
|
||||||
public static StudioFrame frame = null;
|
public static StudioFrame frame = null;
|
||||||
|
|
||||||
//Need to keep a strong reference to it, to avoid garbage collection that'll reset these loggers.
|
// Need to keep a strong reference to it, to avoid garbage collection that'll
|
||||||
|
// reset these loggers.
|
||||||
public static final List<Logger> configuredLoggers = new LinkedList<Logger>();
|
public static final List<Logger> configuredLoggers = new LinkedList<Logger>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
String fontScaling = System.getProperty(FONT_SCALE_ENV_VAR_NAME);
|
||||||
|
Float fontScale;
|
||||||
|
if (fontScaling != null) {
|
||||||
|
try {
|
||||||
|
fontScale = Float.parseFloat(fontScaling);
|
||||||
|
SCALING = fontScale;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
System.err.println("Failed to parse font scaling parameter. Using default.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ConfigCache.init();
|
ConfigCache.init();
|
||||||
|
|
||||||
try {
|
|
||||||
String laf = ConfigCache.getFavoriteLaFClassName();
|
String laf = ConfigCache.getFavoriteLaFClassName();
|
||||||
if (laf == null) laf = UIManager.getSystemLookAndFeelClassName();
|
setLookAndFeel(laf);
|
||||||
UIManager.setLookAndFeel(laf);
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (UnsupportedLookAndFeelException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Need to keep a strong reference to it, to avoid garbage collection that'll reset this setting.
|
// Need to keep a strong reference to it, to avoid garbage collection that'll
|
||||||
|
// reset this setting.
|
||||||
Logger l = Logger.getLogger(ExpressionParser.class.getName());
|
Logger l = Logger.getLogger(ExpressionParser.class.getName());
|
||||||
l.setLevel(Level.OFF);
|
l.setLevel(Level.OFF);
|
||||||
configuredLoggers.add(l);
|
configuredLoggers.add(l);
|
||||||
@@ -74,10 +90,18 @@ public class ATContentStudio {
|
|||||||
WorkerDialog.showTaskMessage("Loading your workspace...", null, new Runnable() {
|
WorkerDialog.showTaskMessage("Loading your workspace...", null, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Workspace.setActive(workspaceRoot);
|
Workspace.setActive(workspaceRoot);
|
||||||
|
if (Workspace.activeWorkspace.settings.useInternet.getCurrentValue()
|
||||||
|
&& Workspace.activeWorkspace.settings.checkUpdates.getCurrentValue()) {
|
||||||
|
new Thread() {
|
||||||
|
public void run() {
|
||||||
|
checkUpdate();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
frame = new StudioFrame(APP_NAME + " " + APP_VERSION);
|
frame = new StudioFrame(APP_NAME + " " + APP_VERSION);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
frame.setDefaultCloseOperation(StudioFrame.DO_NOTHING_ON_CLOSE);
|
frame.setDefaultCloseOperation(StudioFrame.DO_NOTHING_ON_CLOSE);
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
for (File f : ConfigCache.getKnownWorkspaces()) {
|
for (File f : ConfigCache.getKnownWorkspaces()) {
|
||||||
if (workspaceRoot.equals(f)) {
|
if (workspaceRoot.equals(f)) {
|
||||||
@@ -95,4 +119,136 @@ public class ATContentStudio {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setLookAndFeel(String laf) {
|
||||||
|
if (laf == null)
|
||||||
|
{
|
||||||
|
System.out.println("No look and feel specified, using system default.");
|
||||||
|
laf = UIManager.getSystemLookAndFeelClassName();
|
||||||
|
}
|
||||||
|
System.out.println("Info: Setting look and feel to: " + laf);
|
||||||
|
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel(laf);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
System.err.println("Failed to load system look and feel. ");
|
||||||
|
System.err.println("Installed look and feel classes: ");
|
||||||
|
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
|
||||||
|
System.err.println(" " + info.getName() + " (" + info.getClassName() + ")");
|
||||||
|
}
|
||||||
|
System.err.println("Tried to load: " + laf + " but got this error:");
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InstantiationException | UnsupportedLookAndFeelException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
var newLaF = UIManager.getLookAndFeel();
|
||||||
|
System.out.println("Using look and feel: " + newLaF.getName() + " (" + newLaF.getClass().getName() + ")");
|
||||||
|
|
||||||
|
scaleUIFont();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkUpdate() {
|
||||||
|
BufferedReader in = null;
|
||||||
|
try {
|
||||||
|
URL url = new URL(CHECK_UPDATE_URL);
|
||||||
|
in = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||||
|
|
||||||
|
String inputLine, lastLine = null;
|
||||||
|
while ((inputLine = in.readLine()) != null) {
|
||||||
|
lastLine = inputLine;
|
||||||
|
}
|
||||||
|
if (lastLine != null && !lastLine.equals(APP_VERSION)) {
|
||||||
|
|
||||||
|
// for copying style
|
||||||
|
JLabel label = new JLabel();
|
||||||
|
Font font = label.getFont();
|
||||||
|
Color color = label.getBackground();
|
||||||
|
|
||||||
|
// create some css from the label's font
|
||||||
|
StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
|
||||||
|
style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
|
||||||
|
style.append("font-size:" + font.getSize() + "pt;");
|
||||||
|
style.append("background-color: rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue()
|
||||||
|
+ ");");
|
||||||
|
|
||||||
|
JEditorPane ep = new JEditorPane("text/html",
|
||||||
|
"<html><body style=\"" + style + "\">" + "You are not running the latest ATCS version.<br/>"
|
||||||
|
+ "You can get the latest version (" + lastLine + ") by clicking the link below.<br/>"
|
||||||
|
+ "<a href=\"" + DOWNLOAD_URL + "\">" + DOWNLOAD_URL + "</a><br/>" + "<br/>"
|
||||||
|
+ "</body></html>");
|
||||||
|
|
||||||
|
ep.setEditable(false);
|
||||||
|
ep.setBorder(null);
|
||||||
|
|
||||||
|
ep.addHyperlinkListener(new HyperlinkListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||||
|
try {
|
||||||
|
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
|
||||||
|
Desktop.getDesktop().browse(e.getURL().toURI());
|
||||||
|
}
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (URISyntaxException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JOptionPane.showMessageDialog(null, ep, "Update available", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (HttpTimeoutException e) {
|
||||||
|
System.out.println("Could not connect to url to check for updates (timeout): " + CHECK_UPDATE_URL);
|
||||||
|
} catch (IOException e) {
|
||||||
|
if (e.getMessage() != null && e.getMessage().startsWith("Server returned HTTP response code:")) {
|
||||||
|
System.out.println("Could not fetch current version from server to check for updates (non-success-status): " + e.getMessage());
|
||||||
|
} else {
|
||||||
|
System.out.println("Could not check for updates: '" + CHECK_UPDATE_URL + "' - " + e.getMessage());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (in != null)
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void scaleUIFont() {
|
||||||
|
if (SCALING != 1.0f) {
|
||||||
|
System.out.println("Scaling fonts to " + SCALING);
|
||||||
|
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
|
||||||
|
Map<Object, Object> newDefaults = new HashMap<Object, Object>();
|
||||||
|
for (Enumeration<Object> e = defaults.keys(); e.hasMoreElements(); ) {
|
||||||
|
Object key = e.nextElement();
|
||||||
|
Object value = defaults.get(key);
|
||||||
|
if (value instanceof Font) {
|
||||||
|
Font font = (Font) value;
|
||||||
|
int newSize = (int) (font.getSize() * SCALING);
|
||||||
|
if (value instanceof FontUIResource) {
|
||||||
|
newDefaults.put(key, new FontUIResource(font.getName(), font.getStyle(), newSize));
|
||||||
|
} else {
|
||||||
|
newDefaults.put(key, new Font(font.getName(), font.getStyle(), newSize));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Object key : newDefaults.keySet()) {
|
||||||
|
defaults.put(key, newDefaults.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String readVersionFromFile() {
|
||||||
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||||
|
Objects.requireNonNull(ATContentStudio.class.getResourceAsStream("/ATCS_latest"))))) {
|
||||||
|
return reader.readLine();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.gpl.rpg.atcontentstudio;
|
package com.gpl.rpg.atcontentstudio;
|
||||||
|
|
||||||
|
import com.gpl.rpg.atcontentstudio.io.SettingsSave;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.io.SettingsSave;
|
|
||||||
|
|
||||||
public class ConfigCache implements Serializable {
|
public class ConfigCache implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 4584324644282843961L;
|
private static final long serialVersionUID = 4584324644282843961L;
|
||||||
@@ -91,7 +91,8 @@ public class ConfigCache implements Serializable {
|
|||||||
return instance.notifConfig;
|
return instance.notifConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {}
|
public static void init() {
|
||||||
|
}
|
||||||
|
|
||||||
public static void clear() {
|
public static void clear() {
|
||||||
instance.knownWorkspaces.clear();
|
instance.knownWorkspaces.clear();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class Notification {
|
|||||||
|
|
||||||
public static List<Notification> notifs = new ArrayList<Notification>();
|
public static List<Notification> notifs = new ArrayList<Notification>();
|
||||||
private static List<NotificationListener> listeners = new CopyOnWriteArrayList<NotificationListener>();
|
private static List<NotificationListener> listeners = new CopyOnWriteArrayList<NotificationListener>();
|
||||||
public static boolean showS = true, showI = true, showW = true, showE = true;
|
public static boolean showS, showI, showW, showE;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
boolean[] config = ConfigCache.getNotifViewConfig();
|
boolean[] config = ConfigCache.getNotifViewConfig();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.gpl.rpg.atcontentstudio;
|
|||||||
public interface NotificationListener {
|
public interface NotificationListener {
|
||||||
|
|
||||||
public void onNewNotification(Notification n);
|
public void onNewNotification(Notification n);
|
||||||
|
|
||||||
public void onListCleared(int i);
|
public void onListCleared(int i);
|
||||||
|
|
||||||
}
|
}
|
||||||
BIN
src/com/gpl/rpg/atcontentstudio/img/alignment.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
src/com/gpl/rpg/atcontentstudio/img/bonemeal.png
Normal file
|
After Width: | Height: | Size: 607 B |
BIN
src/com/gpl/rpg/atcontentstudio/img/bookmark_active.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/com/gpl/rpg/atcontentstudio/img/bookmark_inactive.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
src/com/gpl/rpg/atcontentstudio/img/date.png
Normal file
|
After Width: | Height: | Size: 275 B |
BIN
src/com/gpl/rpg/atcontentstudio/img/folder_bookmark_closed.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
src/com/gpl/rpg/atcontentstudio/img/folder_bookmark_open.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 3.9 KiB |
BIN
src/com/gpl/rpg/atcontentstudio/img/time.png
Normal file
|
After Width: | Height: | Size: 703 B |
BIN
src/com/gpl/rpg/atcontentstudio/img/timer.png
Normal file
|
After Width: | Height: | Size: 881 B |
BIN
src/com/gpl/rpg/atcontentstudio/img/ui_icon_immunity.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/com/gpl/rpg/atcontentstudio/img/ui_icon_skill.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
8
src/com/gpl/rpg/atcontentstudio/io/JsonSerializable.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package com.gpl.rpg.atcontentstudio.io;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface JsonSerializable {
|
||||||
|
Map toMap();
|
||||||
|
void fromMap(Map map);
|
||||||
|
}
|
||||||
@@ -1,15 +1,9 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.io;
|
package com.gpl.rpg.atcontentstudio.io;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
public class SettingsSave {
|
public class SettingsSave {
|
||||||
|
|
||||||
public static void saveInstance(Object obj, File f, String type) {
|
public static void saveInstance(Object obj, File f, String type) {
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model;
|
package com.gpl.rpg.atcontentstudio.model;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ClosedProject implements ProjectTreeNode {
|
public class ClosedProject implements ProjectTreeNode {
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
@@ -25,26 +24,32 @@ public class ClosedProject implements ProjectTreeNode {
|
|||||||
public TreeNode getChildAt(int childIndex) {
|
public TreeNode getChildAt(int childIndex) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChildCount() {
|
public int getChildCount() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TreeNode getParent() {
|
public TreeNode getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIndex(TreeNode node) {
|
public int getIndex(TreeNode node) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAllowsChildren() {
|
public boolean getAllowsChildren() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLeaf() {
|
public boolean isLeaf() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enumeration<ProjectTreeNode> children() {
|
public Enumeration<ProjectTreeNode> children() {
|
||||||
return null;
|
return null;
|
||||||
@@ -55,16 +60,19 @@ public class ClosedProject implements ProjectTreeNode {
|
|||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenAdded(path);
|
parent.childrenAdded(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenChanged(List<ProjectTreeNode> path) {
|
public void childrenChanged(List<ProjectTreeNode> path) {
|
||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenChanged(path);
|
parent.childrenChanged(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenRemoved(List<ProjectTreeNode> path) {
|
public void childrenRemoved(List<ProjectTreeNode> path) {
|
||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenRemoved(path);
|
parent.childrenRemoved(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyCreated() {
|
public void notifyCreated() {
|
||||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
@@ -85,16 +93,19 @@ public class ClosedProject implements ProjectTreeNode {
|
|||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return getOpenIcon();
|
return getOpenIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getClosedIcon() {
|
public Image getClosedIcon() {
|
||||||
//TODO Create a cool Project icon.
|
//TODO Create a cool Project icon.
|
||||||
return DefaultIcons.getStdClosedIcon();
|
return DefaultIcons.getStdClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getLeafIcon() {
|
public Image getLeafIcon() {
|
||||||
//TODO Create a cool Project icon.
|
//TODO Create a cool Project icon.
|
||||||
return DefaultIcons.getStdClosedIcon();
|
return DefaultIcons.getStdClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getOpenIcon() {
|
public Image getOpenIcon() {
|
||||||
//TODO Create a cool Project icon.
|
//TODO Create a cool Project icon.
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model;
|
package com.gpl.rpg.atcontentstudio.model;
|
||||||
|
|
||||||
import java.awt.Image;
|
import com.gpl.rpg.atcontentstudio.model.bookmarks.BookmarkEntry;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
||||||
|
|
||||||
@@ -31,6 +29,8 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
|||||||
|
|
||||||
public boolean writable = false;
|
public boolean writable = false;
|
||||||
|
|
||||||
|
public BookmarkEntry bookmark = null;
|
||||||
|
|
||||||
//List of objects whose transition to "linked" state made them point to this instance.
|
//List of objects whose transition to "linked" state made them point to this instance.
|
||||||
private Map<GameDataElement, Integer> backlinks = new ConcurrentHashMap<GameDataElement, Integer>();
|
private Map<GameDataElement, Integer> backlinks = new ConcurrentHashMap<GameDataElement, Integer>();
|
||||||
|
|
||||||
@@ -40,30 +40,37 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
|||||||
public Enumeration<ProjectTreeNode> children() {
|
public Enumeration<ProjectTreeNode> children() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAllowsChildren() {
|
public boolean getAllowsChildren() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TreeNode getChildAt(int arg0) {
|
public TreeNode getChildAt(int arg0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChildCount() {
|
public int getChildCount() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIndex(TreeNode arg0) {
|
public int getIndex(TreeNode arg0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TreeNode getParent() {
|
public TreeNode getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLeaf() {
|
public boolean isLeaf() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenAdded(List<ProjectTreeNode> path) {
|
public void childrenAdded(List<ProjectTreeNode> path) {
|
||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
@@ -81,10 +88,12 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
|||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenRemoved(path);
|
parent.childrenRemoved(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyCreated() {
|
public void notifyCreated() {
|
||||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract String getDesc();
|
public abstract String getDesc();
|
||||||
|
|
||||||
@@ -93,8 +102,8 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract void parse();
|
public abstract void parse();
|
||||||
public abstract void link();
|
|
||||||
|
|
||||||
|
public abstract void link();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,10 +115,17 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
|||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getClosedIcon() {return null;}
|
public Image getClosedIcon() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getOpenIcon() {return null;}
|
public Image getOpenIcon() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getLeafIcon() {
|
public Image getLeafIcon() {
|
||||||
return getIcon();
|
return getIcon();
|
||||||
@@ -168,6 +184,7 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
|||||||
|
|
||||||
public static interface BacklinksListener {
|
public static interface BacklinksListener {
|
||||||
public void backlinkAdded(GameDataElement gde);
|
public void backlinkAdded(GameDataElement gde);
|
||||||
|
|
||||||
public void backlinkRemoved(GameDataElement gde);
|
public void backlinkRemoved(GameDataElement gde);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,4 +203,35 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
|||||||
|
|
||||||
public abstract List<SaveEvent> attemptSave();
|
public abstract List<SaveEvent> attemptSave();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the current state indicates that parsing/linking should be skipped.
|
||||||
|
*
|
||||||
|
* @return true if the operation should be skipped, false otherwise
|
||||||
|
*/
|
||||||
|
protected boolean shouldSkipParseOrLink() {
|
||||||
|
if (shouldSkipParse()) return true;
|
||||||
|
if (this.state == State.linked) {
|
||||||
|
//Already linked.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean shouldSkipParse() {
|
||||||
|
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||||
|
//This type of state is unrelated to parsing/linking.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures the element is parsed if needed based on its current state.
|
||||||
|
*/
|
||||||
|
protected void ensureParseIfNeeded() {
|
||||||
|
if (this.state == State.init) {
|
||||||
|
//Not parsed yet.
|
||||||
|
this.parse();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,6 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model;
|
package com.gpl.rpg.atcontentstudio.model;
|
||||||
|
|
||||||
import java.awt.Image;
|
import com.gpl.rpg.atcontentstudio.io.JsonSerializable;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project.ResourceSet;
|
import com.gpl.rpg.atcontentstudio.model.Project.ResourceSet;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||||
@@ -32,8 +10,22 @@ import com.gpl.rpg.atcontentstudio.model.sprites.SpriteSheetSet;
|
|||||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||||
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeDataSet;
|
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeDataSet;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
public class GameSource implements ProjectTreeNode, Serializable {
|
import javax.swing.tree.TreeNode;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class GameSource implements ProjectTreeNode, Serializable, JsonSerializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -1512979360971918158L;
|
private static final long serialVersionUID = -1512979360971918158L;
|
||||||
|
|
||||||
@@ -47,6 +39,22 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
|||||||
public transient WriterModeDataSet writerModeDataSet;
|
public transient WriterModeDataSet writerModeDataSet;
|
||||||
private transient SavedSlotCollection v;
|
private transient SavedSlotCollection v;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map toMap() {
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("type", type.toString());
|
||||||
|
map.put("baseFolder", baseFolder.getPath());
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromMap(Map map) {
|
||||||
|
if(map==null)return;
|
||||||
|
type = Enum.valueOf(Type.class, (String)map.get("type"));
|
||||||
|
baseFolder = new File((String) map.get("baseFolder"));
|
||||||
|
}
|
||||||
|
|
||||||
public static enum Type {
|
public static enum Type {
|
||||||
source,
|
source,
|
||||||
referenced,
|
referenced,
|
||||||
@@ -57,10 +65,14 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
|||||||
public File baseFolder;
|
public File baseFolder;
|
||||||
public Type type;
|
public Type type;
|
||||||
|
|
||||||
public transient Project parent = null;
|
public transient Project parent;
|
||||||
|
|
||||||
public transient Map<String, List<String>> referencedSourceFiles = null;
|
public transient Map<String, List<String>> referencedSourceFiles = null;
|
||||||
|
|
||||||
|
public GameSource(Map json, Project parent) {
|
||||||
|
fromMap(json);
|
||||||
|
refreshTransients(parent);
|
||||||
|
}
|
||||||
public GameSource(File folder, Project parent) {
|
public GameSource(File folder, Project parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.baseFolder = folder;
|
this.baseFolder = folder;
|
||||||
@@ -105,7 +117,7 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void readResourceList() {
|
public void readResourceList() {
|
||||||
File xmlFile = null;
|
File xmlFile;
|
||||||
if (parent.sourceSetToUse == ResourceSet.gameData) {
|
if (parent.sourceSetToUse == ResourceSet.gameData) {
|
||||||
xmlFile = new File(baseFolder, DEFAULT_REL_PATH_FOR_GAME_RESOURCE);
|
xmlFile = new File(baseFolder, DEFAULT_REL_PATH_FOR_GAME_RESOURCE);
|
||||||
} else if (parent.sourceSetToUse == ResourceSet.debugData) {
|
} else if (parent.sourceSetToUse == ResourceSet.debugData) {
|
||||||
@@ -160,40 +172,49 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
|||||||
public Enumeration<ProjectTreeNode> children() {
|
public Enumeration<ProjectTreeNode> children() {
|
||||||
return v.getNonEmptyElements();
|
return v.getNonEmptyElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAllowsChildren() {
|
public boolean getAllowsChildren() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TreeNode getChildAt(int arg0) {
|
public TreeNode getChildAt(int arg0) {
|
||||||
return v.getNonEmptyElementAt(arg0);
|
return v.getNonEmptyElementAt(arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChildCount() {
|
public int getChildCount() {
|
||||||
return v.getNonEmptySize();
|
return v.getNonEmptySize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIndex(TreeNode arg0) {
|
public int getIndex(TreeNode arg0) {
|
||||||
return v.getNonEmptyIndexOf((ProjectTreeNode) arg0);
|
return v.getNonEmptyIndexOf((ProjectTreeNode) arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TreeNode getParent() {
|
public TreeNode getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLeaf() {
|
public boolean isLeaf() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenAdded(List<ProjectTreeNode> path) {
|
public void childrenAdded(List<ProjectTreeNode> path) {
|
||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenAdded(path);
|
parent.childrenAdded(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenChanged(List<ProjectTreeNode> path) {
|
public void childrenChanged(List<ProjectTreeNode> path) {
|
||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenChanged(path);
|
parent.childrenChanged(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenRemoved(List<ProjectTreeNode> path) {
|
public void childrenRemoved(List<ProjectTreeNode> path) {
|
||||||
if (path.size() == 1 && this.v.getNonEmptySize() == 1) {
|
if (path.size() == 1 && this.v.getNonEmptySize() == 1) {
|
||||||
@@ -203,6 +224,7 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
|||||||
parent.childrenRemoved(path);
|
parent.childrenRemoved(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyCreated() {
|
public void notifyCreated() {
|
||||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
@@ -210,14 +232,20 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
|||||||
node.notifyCreated();
|
node.notifyCreated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDesc() {
|
public String getDesc() {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case altered: return (needsSaving() ? "*" : "")+"Altered data";
|
case altered:
|
||||||
case created: return (needsSaving() ? "*" : "")+"Created data";
|
return (needsSaving() ? "*" : "") + "Altered data";
|
||||||
case referenced: return (needsSaving() ? "*" : "")+"Referenced data";
|
case created:
|
||||||
case source: return (needsSaving() ? "*" : "")+"AT Source"; //The fact that it is from "source" is already mentionned by its parent.
|
return (needsSaving() ? "*" : "") + "Created data";
|
||||||
default: return (needsSaving() ? "*" : "")+"Game data";
|
case referenced:
|
||||||
|
return (needsSaving() ? "*" : "") + "Referenced data";
|
||||||
|
case source:
|
||||||
|
return (needsSaving() ? "*" : "") + "AT Source"; //The fact that it is from "source" is already mentionned by its parent.
|
||||||
|
default:
|
||||||
|
return (needsSaving() ? "*" : "") + "Game data";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,18 +280,22 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
|||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return getOpenIcon();
|
return getOpenIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getClosedIcon() {
|
public Image getClosedIcon() {
|
||||||
return DefaultIcons.getATClosedIcon();
|
return DefaultIcons.getATClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getLeafIcon() {
|
public Image getLeafIcon() {
|
||||||
return DefaultIcons.getATClosedIcon();
|
return DefaultIcons.getATClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getOpenIcon() {
|
public Image getOpenIcon() {
|
||||||
return DefaultIcons.getATOpenIcon();
|
return DefaultIcons.getATOpenIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameDataSet getDataSet() {
|
public GameDataSet getDataSet() {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,19 +1,53 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model;
|
package com.gpl.rpg.atcontentstudio.model;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import com.gpl.rpg.atcontentstudio.io.JsonSerializable;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Preferences implements Serializable {
|
public class Preferences implements Serializable, JsonSerializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2455802658424031276L;
|
private static final long serialVersionUID = 2455802658424031276L;
|
||||||
|
|
||||||
public Dimension windowSize = null;
|
public Dimension windowSize = null;
|
||||||
public Map<String, Integer> splittersPositions = new HashMap<String, Integer>();
|
public Map<String, Integer> splittersPositions = new HashMap<>();
|
||||||
|
|
||||||
public Preferences() {
|
public Preferences() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map toMap() {
|
||||||
|
Map map = new HashMap();
|
||||||
|
|
||||||
|
if(windowSize!= null){
|
||||||
|
Map windowSizeMap = new HashMap<>();
|
||||||
|
windowSizeMap.put("width", windowSize.width);
|
||||||
|
windowSizeMap.put("height", windowSize.height);
|
||||||
|
map.put("windowSize", windowSizeMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
map.put("splittersPositions", splittersPositions);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromMap(Map map) {
|
||||||
|
if(map == null) return;
|
||||||
|
|
||||||
|
Map windowSize1 = (Map) map.get("windowSize");
|
||||||
|
if(windowSize1 != null){
|
||||||
|
windowSize = new Dimension(((Number) windowSize1.get("width")).intValue(), ((Number) windowSize1.get("height")).intValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Number> splitters = (Map<String, Number>) map.get("splittersPositions");
|
||||||
|
Map<String, Integer> splittersInt = new HashMap<>(splitters.size());
|
||||||
|
for (Map.Entry<String, Number> entry : splitters. entrySet()){
|
||||||
|
splittersInt.put(entry.getKey(), entry.getValue().intValue());
|
||||||
|
}
|
||||||
|
splittersPositions = splittersInt;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +1,54 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model;
|
package com.gpl.rpg.atcontentstudio.model;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
import com.gpl.rpg.atcontentstudio.io.JsonPrettyWriter;
|
import com.gpl.rpg.atcontentstudio.io.JsonSerializable;
|
||||||
import com.gpl.rpg.atcontentstudio.io.SettingsSave;
|
import com.gpl.rpg.atcontentstudio.io.SettingsSave;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
|
import com.gpl.rpg.atcontentstudio.model.bookmarks.BookmarksRoot;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.*;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Droplist;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataCategory;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Item;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ItemCategory;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.JSONElement;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.NPC;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Quest;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.QuestStage;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||||
import com.gpl.rpg.atcontentstudio.model.maps.Worldmap;
|
import com.gpl.rpg.atcontentstudio.model.maps.Worldmap;
|
||||||
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
|
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
|
||||||
import com.gpl.rpg.atcontentstudio.model.saves.SavedGamesSet;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||||
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeData;
|
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeData;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
||||||
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||||
|
import org.w3c.dom.Comment;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
public class Project implements ProjectTreeNode, Serializable {
|
import javax.swing.tree.TreeNode;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.*;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import javax.xml.transform.stream.StreamSource;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class Project implements ProjectTreeNode, Serializable, JsonSerializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 4807454973303366758L;
|
private static final long serialVersionUID = 4807454973303366758L;
|
||||||
|
private static final String drawablePath = TMXMapSet.DEFAULT_REL_PATH_TO_DRAWABLE.replace("\\", "/");
|
||||||
|
|
||||||
|
|
||||||
//Every instance field that is not transient will be saved in this file.
|
//Every instance field that is not transient will be saved in this file.
|
||||||
public static final String SETTINGS_FILE = ".project";
|
public static final String SETTINGS_FILE = ".project";
|
||||||
|
public static final String SETTINGS_FILE_JSON = ".project.json";
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
@@ -65,17 +57,39 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
|
|
||||||
public GameSource baseContent; //A.k.a library
|
public GameSource baseContent; //A.k.a library
|
||||||
|
|
||||||
public GameSource referencedContent; //Pointers to base content
|
|
||||||
public transient GameSource alteredContent; //Copied from base content (does not overwrite yet)
|
public transient GameSource alteredContent; //Copied from base content (does not overwrite yet)
|
||||||
public transient GameSource createdContent; //Stand-alone.
|
public transient GameSource createdContent; //Stand-alone.
|
||||||
|
public transient BookmarksRoot bookmarks;
|
||||||
|
|
||||||
public SavedGamesSet saves; //For simulations.
|
|
||||||
|
|
||||||
public transient SavedSlotCollection v;
|
public transient SavedSlotCollection v;
|
||||||
|
|
||||||
public transient Workspace parent;
|
public transient Workspace parent;
|
||||||
|
|
||||||
public Properties knownSpritesheetsProperties = null;
|
public Properties knownSpritesheetsProperties;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map toMap() {
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("name", name.toString());
|
||||||
|
map.put("baseFolder", baseFolder.getPath());
|
||||||
|
map.put("open", open);
|
||||||
|
map.put("baseContent", baseContent.toMap());
|
||||||
|
map.put("sourceSetToUse", sourceSetToUse.toString());
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromMap(Map map) {
|
||||||
|
if(map==null)return;
|
||||||
|
name = (String) map.get("name");
|
||||||
|
baseFolder = new File((String) map.get("baseFolder"));
|
||||||
|
open = (boolean) map.get("open");
|
||||||
|
|
||||||
|
baseContent = new GameSource((Map) map.get("baseContent"), this);
|
||||||
|
|
||||||
|
sourceSetToUse = Enum.valueOf(ResourceSet.class, (String)map.get("sourceSetToUse"));
|
||||||
|
}
|
||||||
|
|
||||||
public static enum ResourceSet {
|
public static enum ResourceSet {
|
||||||
gameData,
|
gameData,
|
||||||
@@ -83,8 +97,17 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
allFiles
|
allFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceSet sourceSetToUse = ResourceSet.allFiles;
|
public ResourceSet sourceSetToUse;
|
||||||
|
|
||||||
|
public Project(Workspace w, File projectFile) {
|
||||||
|
this.parent = w;
|
||||||
|
loadSpritesheetProperties();
|
||||||
|
Map json = FileUtils.mapFromJsonFile(projectFile);
|
||||||
|
this.fromMap(json);
|
||||||
|
|
||||||
|
initializeData();
|
||||||
|
save();
|
||||||
|
}
|
||||||
public Project(Workspace w, String name, File source, ResourceSet sourceSet){
|
public Project(Workspace w, String name, File source, ResourceSet sourceSet){
|
||||||
this.parent = w;
|
this.parent = w;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -98,36 +121,28 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
Notification.addError("Eror creating project root folder: " + e.getMessage());
|
Notification.addError("Eror creating project root folder: " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
open = true;
|
|
||||||
v = new SavedSlotCollection();
|
|
||||||
|
|
||||||
knownSpritesheetsProperties = new Properties();
|
loadSpritesheetProperties();
|
||||||
try {
|
baseContent = new GameSource(source, this);
|
||||||
knownSpritesheetsProperties.load(Project.class.getResourceAsStream("/spritesheets.properties"));
|
open = true;
|
||||||
} catch (IOException e) {
|
initializeData();
|
||||||
Notification.addWarn("Unable to load default spritesheets properties.");
|
linkAll();
|
||||||
e.printStackTrace();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initializeData() {
|
||||||
|
v = new SavedSlotCollection();
|
||||||
|
|
||||||
baseContent = new GameSource(source, this);
|
alteredContent = new GameSource(this, Type.altered);
|
||||||
|
createdContent = new GameSource(this, Type.created);
|
||||||
|
bookmarks = new BookmarksRoot(this);
|
||||||
|
|
||||||
// referencedContent = new GameSource(this, GameSource.Type.referenced);
|
|
||||||
|
|
||||||
alteredContent = new GameSource(this, GameSource.Type.altered);
|
|
||||||
createdContent = new GameSource(this, GameSource.Type.created);
|
|
||||||
|
|
||||||
saves = new SavedGamesSet(this);
|
|
||||||
|
|
||||||
v.add(createdContent);
|
v.add(createdContent);
|
||||||
v.add(alteredContent);
|
v.add(alteredContent);
|
||||||
// v.add(referencedContent);
|
// v.add(referencedContent);
|
||||||
v.add(baseContent);
|
v.add(baseContent);
|
||||||
v.add(saves);
|
v.add(bookmarks);
|
||||||
|
|
||||||
linkAll();
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,6 +198,7 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenRemoved(path);
|
parent.childrenRemoved(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyCreated() {
|
public void notifyCreated() {
|
||||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
@@ -190,6 +206,7 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
node.notifyCreated();
|
node.notifyCreated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDesc() {
|
public String getDesc() {
|
||||||
return (needsSaving() ? "*" : "") + name;
|
return (needsSaving() ? "*" : "") + name;
|
||||||
@@ -207,13 +224,21 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
|
|
||||||
|
|
||||||
public static Project fromFolder(Workspace w, File projRoot) {
|
public static Project fromFolder(Workspace w, File projRoot) {
|
||||||
Project p = null;
|
Project p;
|
||||||
|
|
||||||
|
File fJson = new File(projRoot, Project.SETTINGS_FILE_JSON);
|
||||||
|
if (fJson.exists()) {
|
||||||
|
p = new Project(w, fJson);
|
||||||
|
} else {
|
||||||
File f = new File(projRoot, Project.SETTINGS_FILE);
|
File f = new File(projRoot, Project.SETTINGS_FILE);
|
||||||
if (!f.exists()) {
|
if (!f.exists()) {
|
||||||
Notification.addError("Unable to find " + SETTINGS_FILE + " for project " + projRoot.getName());
|
Notification.addError("Unable to find " + SETTINGS_FILE + " for project " + projRoot.getName());
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
p = (Project) SettingsSave.loadInstance(f, "Project");
|
p = (Project) SettingsSave.loadInstance(f, "Project");
|
||||||
|
p.baseFolder = projRoot;
|
||||||
|
}
|
||||||
|
p.save();
|
||||||
}
|
}
|
||||||
p.refreshTransients(w);
|
p.refreshTransients(w);
|
||||||
return p;
|
return p;
|
||||||
@@ -222,13 +247,9 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
public void refreshTransients(Workspace w) {
|
public void refreshTransients(Workspace w) {
|
||||||
this.parent = w;
|
this.parent = w;
|
||||||
|
|
||||||
try {
|
projectElementListeners = new HashMap<Class<? extends GameDataElement>, List<ProjectElementListener>>();
|
||||||
knownSpritesheetsProperties = new Properties();
|
|
||||||
knownSpritesheetsProperties.load(Project.class.getResourceAsStream("/spritesheets.properties"));
|
loadSpritesheetProperties();
|
||||||
} catch (IOException e) {
|
|
||||||
Notification.addWarn("Unable to load default spritesheets properties.");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sourceSetToUse == null) {
|
if (sourceSetToUse == null) {
|
||||||
sourceSetToUse = ResourceSet.allFiles;
|
sourceSetToUse = ResourceSet.allFiles;
|
||||||
@@ -241,67 +262,54 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
// referencedContent.refreshTransients(this);
|
// referencedContent.refreshTransients(this);
|
||||||
alteredContent = new GameSource(this, GameSource.Type.altered);
|
alteredContent = new GameSource(this, GameSource.Type.altered);
|
||||||
createdContent = new GameSource(this, GameSource.Type.created);
|
createdContent = new GameSource(this, GameSource.Type.created);
|
||||||
|
bookmarks = new BookmarksRoot(this);
|
||||||
saves.refreshTransients();
|
|
||||||
|
|
||||||
v = new SavedSlotCollection();
|
v = new SavedSlotCollection();
|
||||||
v.add(createdContent);
|
v.add(createdContent);
|
||||||
v.add(alteredContent);
|
v.add(alteredContent);
|
||||||
// v.add(referencedContent);
|
// v.add(referencedContent);
|
||||||
v.add(baseContent);
|
v.add(baseContent);
|
||||||
v.add(saves);
|
v.add(bookmarks);
|
||||||
|
|
||||||
|
|
||||||
linkAll();
|
linkAll();
|
||||||
|
|
||||||
projectElementListeners = new HashMap<Class<? extends GameDataElement>, List<ProjectElementListener>>();
|
}
|
||||||
|
|
||||||
|
private void loadSpritesheetProperties() {
|
||||||
|
knownSpritesheetsProperties = new Properties();
|
||||||
|
try {
|
||||||
|
knownSpritesheetsProperties.load(Project.class.getResourceAsStream("/spritesheets.properties"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
Notification.addWarn("Unable to load default spritesheets properties.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void linkAll() {
|
public void linkAll() {
|
||||||
for (ProjectTreeNode node : baseContent.gameData.v.getNonEmptyIterable()) {
|
linkGameData(baseContent);
|
||||||
if (node instanceof GameDataCategory<?>) {
|
linkGameData(alteredContent);
|
||||||
for (GameDataElement e : ((GameDataCategory<?>) node)) {
|
linkGameData(createdContent);
|
||||||
e.link();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (ProjectTreeNode node : baseContent.gameMaps.tmxMaps) {
|
|
||||||
((TMXMap)node).link();
|
|
||||||
}
|
|
||||||
for (ProjectTreeNode node : alteredContent.gameData.v.getNonEmptyIterable()) {
|
|
||||||
if (node instanceof GameDataCategory<?>) {
|
|
||||||
for (GameDataElement e : ((GameDataCategory<?>) node)) {
|
|
||||||
e.link();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (ProjectTreeNode node : alteredContent.gameMaps.tmxMaps) {
|
|
||||||
((TMXMap)node).link();
|
|
||||||
}
|
|
||||||
for (ProjectTreeNode node : createdContent.gameData.v.getNonEmptyIterable()) {
|
|
||||||
if (node instanceof GameDataCategory<?>) {
|
|
||||||
for (GameDataElement e : ((GameDataCategory<?>) node)) {
|
|
||||||
e.link();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (ProjectTreeNode node : createdContent.gameMaps.tmxMaps) {
|
|
||||||
((TMXMap)node).link();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldmapSegment node : createdContent.worldmap) {
|
private void linkGameData(GameSource source) {
|
||||||
|
for (ProjectTreeNode node : source.gameData.v.getNonEmptyIterable()) {
|
||||||
|
if (node instanceof GameDataCategory<?>) {
|
||||||
|
for (GameDataElement e : ((GameDataCategory<?>) node).toList()) {
|
||||||
|
e.link();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (TMXMap node : source.gameMaps.tmxMaps) {
|
||||||
node.link();
|
node.link();
|
||||||
}
|
}
|
||||||
for (WorldmapSegment node : alteredContent.worldmap) {
|
for (WorldmapSegment node : source.worldmap) {
|
||||||
node.link();
|
|
||||||
}
|
|
||||||
for (WorldmapSegment node : baseContent.worldmap) {
|
|
||||||
node.link();
|
node.link();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
SettingsSave.saveInstance(this, new File(baseFolder, Project.SETTINGS_FILE), "Project "+this.name);
|
FileUtils.writeStringToFile(FileUtils.toJsonString(toMap()),new File(baseFolder, Project.SETTINGS_FILE_JSON), "Project " + this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -736,16 +744,19 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return getOpenIcon();
|
return getOpenIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getClosedIcon() {
|
public Image getClosedIcon() {
|
||||||
//TODO Create a cool Project icon.
|
//TODO Create a cool Project icon.
|
||||||
return DefaultIcons.getStdClosedIcon();
|
return DefaultIcons.getStdClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getLeafIcon() {
|
public Image getLeafIcon() {
|
||||||
//TODO Create a cool Project icon.
|
//TODO Create a cool Project icon.
|
||||||
return DefaultIcons.getStdClosedIcon();
|
return DefaultIcons.getStdClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getOpenIcon() {
|
public Image getOpenIcon() {
|
||||||
//TODO Create a cool Project icon.
|
//TODO Create a cool Project icon.
|
||||||
@@ -782,7 +793,6 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void makeWritable(TMXMap node) {
|
public void makeWritable(TMXMap node) {
|
||||||
GameSource.Type type = node.getDataType();
|
GameSource.Type type = node.getDataType();
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
@@ -826,7 +836,6 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param node. Before calling this method, make sure that no other node with the same class and id exist in either created or altered.
|
* @param node. Before calling this method, make sure that no other node with the same class and id exist in either created or altered.
|
||||||
*/
|
*/
|
||||||
public void createElement(JSONElement node) {
|
public void createElement(JSONElement node) {
|
||||||
@@ -850,7 +859,6 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param node. Before calling this method, make sure that no other node with the same class and id exist in either created or altered.
|
* @param node. Before calling this method, make sure that no other node with the same class and id exist in either created or altered.
|
||||||
*/
|
*/
|
||||||
public void createElements(List<? extends JSONElement> nodes) {
|
public void createElements(List<? extends JSONElement> nodes) {
|
||||||
@@ -878,7 +886,6 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param node. Before calling this method, make sure that no other map with the same id exist in either created or altered.
|
* @param node. Before calling this method, make sure that no other map with the same id exist in either created or altered.
|
||||||
*/
|
*/
|
||||||
public void createElement(TMXMap node) {
|
public void createElement(TMXMap node) {
|
||||||
@@ -908,14 +915,14 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
|
|
||||||
public void moveToCreated(JSONElement target) {
|
public void moveToCreated(JSONElement target) {
|
||||||
target.childrenRemoved(new ArrayList<ProjectTreeNode>());
|
target.childrenRemoved(new ArrayList<ProjectTreeNode>());
|
||||||
((GameDataCategory<?>)target.getParent()).remove(target);
|
((GameDataCategory<?>) target.getParent()).removeGeneric(target);
|
||||||
target.state = GameDataElement.State.created;
|
target.state = GameDataElement.State.created;
|
||||||
createdContent.gameData.addElement(target);
|
createdContent.gameData.addElement(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveToAltered(JSONElement target) {
|
public void moveToAltered(JSONElement target) {
|
||||||
target.childrenRemoved(new ArrayList<ProjectTreeNode>());
|
target.childrenRemoved(new ArrayList<ProjectTreeNode>());
|
||||||
((GameDataCategory<?>)target.getParent()).remove(target);
|
((GameDataCategory<?>) target.getParent()).removeGeneric(target);
|
||||||
target.state = GameDataElement.State.created;
|
target.state = GameDataElement.State.created;
|
||||||
((JSONElement) target).jsonFile = new File(baseContent.gameData.getGameDataElement(((JSONElement) target).getClass(), target.id).jsonFile.getAbsolutePath());
|
((JSONElement) target).jsonFile = new File(baseContent.gameData.getGameDataElement(((JSONElement) target).getClass(), target.id).jsonFile.getAbsolutePath());
|
||||||
alteredContent.gameData.addElement((JSONElement) target);
|
alteredContent.gameData.addElement((JSONElement) target);
|
||||||
@@ -942,7 +949,6 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void createWriterSketch(WriterModeData node) {
|
public void createWriterSketch(WriterModeData node) {
|
||||||
node.writable = true;
|
node.writable = true;
|
||||||
createdContent.writerModeDataSet.add(node);
|
createdContent.writerModeDataSet.add(node);
|
||||||
@@ -950,6 +956,10 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
fireElementAdded(node, getNodeIndex(node));
|
fireElementAdded(node, getNodeIndex(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void bookmark(GameDataElement gde) {
|
||||||
|
bookmarks.addBookmark(gde);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameDataSet getDataSet() {
|
public GameDataSet getDataSet() {
|
||||||
@@ -977,11 +987,6 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addSave(File selectedFile) {
|
|
||||||
saves.addSave(selectedFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<NPC> getSpawnGroup(String spawngroup_id) {
|
public List<NPC> getSpawnGroup(String spawngroup_id) {
|
||||||
List<NPC> result = new ArrayList<NPC>();
|
List<NPC> result = new ArrayList<NPC>();
|
||||||
int i = getNPCCount();
|
int i = getNPCCount();
|
||||||
@@ -1023,7 +1028,8 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeElementListener(Class<? extends GameDataElement> interestingType, ProjectElementListener listener) {
|
public void removeElementListener(Class<? extends GameDataElement> interestingType, ProjectElementListener listener) {
|
||||||
if (projectElementListeners.get(interestingType) != null) projectElementListeners.get(interestingType).remove(listener);
|
if (projectElementListeners.get(interestingType) != null)
|
||||||
|
projectElementListeners.get(interestingType).remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireElementAdded(GameDataElement element, int index) {
|
public void fireElementAdded(GameDataElement element, int index) {
|
||||||
@@ -1042,35 +1048,100 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateExportPackage(final File target) {
|
public void exportProjectAsZipPackage(final File target) {
|
||||||
WorkerDialog.showTaskMessage("Exporting project " + name + "...", ATContentStudio.frame, true, new Runnable() {
|
WorkerDialog.showTaskMessage("Exporting project " + name + "...", ATContentStudio.frame, true, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Notification.addInfo("Exporting project \"" + name + "\" as " + target.getAbsolutePath());
|
Notification.addInfo("Exporting project \"" + name + "\" as " + target.getAbsolutePath());
|
||||||
|
|
||||||
|
File tmpDir;
|
||||||
|
try {
|
||||||
|
tmpDir = exportProjectToTmpDir();
|
||||||
|
FileUtils.writeToZip(tmpDir, target);
|
||||||
|
FileUtils.deleteDir(tmpDir);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification.addSuccess("Project \"" + name + "\" exported as " + target.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exportProjectOverGameSource(final File target) {
|
||||||
|
WorkerDialog.showTaskMessage("Exporting project " + name + "...", ATContentStudio.frame, true, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Notification.addInfo("Exporting project \"" + name + "\" into " + target.getAbsolutePath());
|
||||||
|
|
||||||
|
File tmpDir;
|
||||||
|
try {
|
||||||
|
tmpDir = exportProjectToTmpDir();
|
||||||
|
FileUtils.copyOver(tmpDir, target);
|
||||||
|
FileUtils.deleteDir(tmpDir);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification.addSuccess("Project \"" + name + "\" exported into " + target.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public File exportProjectToTmpDir() throws IOException {
|
||||||
File tmpDir = new File(baseFolder, "tmp");
|
File tmpDir = new File(baseFolder, "tmp");
|
||||||
FileUtils.deleteDir(tmpDir);
|
FileUtils.deleteDir(tmpDir);
|
||||||
tmpDir.mkdir();
|
tmpDir.mkdir();
|
||||||
File tmpJsonDataDir = new File(tmpDir, GameDataSet.DEFAULT_REL_PATH_IN_SOURCE);
|
File tmpJsonDataDir = new File(tmpDir, GameDataSet.DEFAULT_REL_PATH_IN_SOURCE);
|
||||||
tmpJsonDataDir.mkdirs();
|
tmpJsonDataDir.mkdirs();
|
||||||
|
|
||||||
for (File createdJsonFile : createdContent.gameData.baseFolder.listFiles()) {
|
// for (File createdJsonFile : createdContent.gameData.baseFolder.listFiles()) {
|
||||||
FileUtils.copyFile(createdJsonFile, new File(tmpJsonDataDir, createdJsonFile.getName()));
|
// FileUtils.copyFile(createdJsonFile, new File(tmpJsonDataDir, createdJsonFile.getName()));
|
||||||
}
|
// }
|
||||||
writeAltered(alteredContent.gameData.actorConditions, baseContent.gameData.actorConditions, ActorCondition.class, tmpJsonDataDir);
|
Map<Class<? extends GameDataElement>, List<String>> writtenFilesPerDataType = new LinkedHashMap<Class<? extends GameDataElement>, List<String>>();
|
||||||
writeAltered(alteredContent.gameData.dialogues, baseContent.gameData.dialogues, Dialogue.class, tmpJsonDataDir);
|
List<String> writtenFiles;
|
||||||
writeAltered(alteredContent.gameData.droplists, baseContent.gameData.droplists, Droplist.class, tmpJsonDataDir);
|
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.actorConditions, alteredContent.gameData.actorConditions, baseContent.gameData.actorConditions, ActorCondition.class,
|
||||||
writeAltered(alteredContent.gameData.itemCategories, baseContent.gameData.itemCategories, ItemCategory.class, tmpJsonDataDir);
|
tmpJsonDataDir);
|
||||||
writeAltered(alteredContent.gameData.items, baseContent.gameData.items, Item.class, tmpJsonDataDir);
|
writtenFilesPerDataType.put(ActorCondition.class, writtenFiles);
|
||||||
writeAltered(alteredContent.gameData.npcs, baseContent.gameData.npcs, NPC.class, tmpJsonDataDir);
|
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.dialogues, alteredContent.gameData.dialogues, baseContent.gameData.dialogues, Dialogue.class, tmpJsonDataDir);
|
||||||
writeAltered(alteredContent.gameData.quests, baseContent.gameData.quests, Quest.class, tmpJsonDataDir);
|
writtenFilesPerDataType.put(Dialogue.class, writtenFiles);
|
||||||
|
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.droplists, alteredContent.gameData.droplists, baseContent.gameData.droplists, Droplist.class, tmpJsonDataDir);
|
||||||
|
writtenFilesPerDataType.put(Droplist.class, writtenFiles);
|
||||||
|
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.itemCategories, alteredContent.gameData.itemCategories, baseContent.gameData.itemCategories, ItemCategory.class,
|
||||||
|
tmpJsonDataDir);
|
||||||
|
writtenFilesPerDataType.put(ItemCategory.class, writtenFiles);
|
||||||
|
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.items, alteredContent.gameData.items, baseContent.gameData.items, Item.class, tmpJsonDataDir);
|
||||||
|
writtenFilesPerDataType.put(Item.class, writtenFiles);
|
||||||
|
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.npcs, alteredContent.gameData.npcs, baseContent.gameData.npcs, NPC.class, tmpJsonDataDir);
|
||||||
|
writtenFilesPerDataType.put(NPC.class, writtenFiles);
|
||||||
|
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.quests, alteredContent.gameData.quests, baseContent.gameData.quests, Quest.class, tmpJsonDataDir);
|
||||||
|
writtenFilesPerDataType.put(Quest.class, writtenFiles);
|
||||||
|
|
||||||
File tmpMapDir = new File(tmpDir, TMXMapSet.DEFAULT_REL_PATH_IN_SOURCE);
|
File tmpMapDir = new File(tmpDir, TMXMapSet.DEFAULT_REL_PATH_IN_SOURCE);
|
||||||
tmpMapDir.mkdirs();
|
tmpMapDir.mkdirs();
|
||||||
|
writtenFiles = new LinkedList<String>();
|
||||||
for (File createdMapFile : createdContent.gameMaps.mapFolder.listFiles()) {
|
for (File createdMapFile : createdContent.gameMaps.mapFolder.listFiles()) {
|
||||||
FileUtils.copyFile(createdMapFile, new File(tmpMapDir, createdMapFile.getName()));
|
if (createdMapFile.getName().equalsIgnoreCase("worldmap.xml")) continue;
|
||||||
|
copyTmxConverted(createdMapFile.toPath(), Paths.get(tmpMapDir.getAbsolutePath(), createdMapFile.getName()));
|
||||||
|
writtenFiles.add(createdMapFile.getName());
|
||||||
}
|
}
|
||||||
for (File alteredMapFile : alteredContent.gameMaps.mapFolder.listFiles()) {
|
for (File alteredMapFile : alteredContent.gameMaps.mapFolder.listFiles()) {
|
||||||
FileUtils.copyFile(alteredMapFile, new File(tmpMapDir, alteredMapFile.getName()));
|
if (alteredMapFile.getName().equalsIgnoreCase("worldmap.xml")) continue;
|
||||||
|
copyTmxConverted(alteredMapFile.toPath(), Paths.get(tmpMapDir.getAbsolutePath(), alteredMapFile.getName()));
|
||||||
|
writtenFiles.add(alteredMapFile.getName());
|
||||||
|
}
|
||||||
|
writtenFilesPerDataType.put(TMXMap.class, writtenFiles);
|
||||||
|
|
||||||
|
if (sourceSetToUse == ResourceSet.gameData) {
|
||||||
|
writeResourceListXml(writtenFilesPerDataType, GameSource.DEFAULT_REL_PATH_FOR_GAME_RESOURCE, baseContent.baseFolder, tmpDir);
|
||||||
|
} else if (sourceSetToUse == ResourceSet.debugData) {
|
||||||
|
writeResourceListXml(writtenFilesPerDataType, GameSource.DEFAULT_REL_PATH_FOR_DEBUG_RESOURCE, baseContent.baseFolder, tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1092,51 +1163,191 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileUtils.writeToZip(tmpDir, target);
|
return tmpDir;
|
||||||
FileUtils.deleteDir(tmpDir);
|
|
||||||
Notification.addSuccess("Project \""+name+"\" exported as "+target.getAbsolutePath());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void copyTmxConverted(Path from, Path to) throws IOException {
|
||||||
|
String xml = new String(Files.readAllBytes(from), StandardCharsets.UTF_8);
|
||||||
|
xml = xml.replace("../../altered/spritesheets/", drawablePath);
|
||||||
|
xml = xml.replace("../../created/spritesheets/", drawablePath);
|
||||||
|
xml = xml.replace("../spritesheets/", drawablePath);
|
||||||
|
xml = xml.replace("../spritesheets/", drawablePath);
|
||||||
|
Files.write(to, xml.getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public void writeAltered(GameDataCategory<? extends JSONElement> altered, GameDataCategory<? extends JSONElement> source, Class<? extends JSONElement> gdeClass, File targetFolder) {
|
public List<String> writeDataDeltaForDataType(GameDataCategory<? extends JSONElement> created, GameDataCategory<? extends JSONElement> altered, GameDataCategory<? extends JSONElement> source, Class<? extends JSONElement> gdeClass, File targetFolder) {
|
||||||
Set<String> alteredFileNames = new LinkedHashSet<String>();
|
List<String> filenamesToWrite = new LinkedList<String>();
|
||||||
Map<String, List<Map>> toWrite = new LinkedHashMap<String, List<Map>>();
|
Map<String, List<Map>> dataToWritePerFilename = new LinkedHashMap<String, List<Map>>();
|
||||||
for (JSONElement gde : altered) {
|
for (JSONElement gde : altered.toList()) {
|
||||||
alteredFileNames.add(gde.jsonFile.getName());
|
if (!filenamesToWrite.contains(gde.jsonFile.getName())) {
|
||||||
|
filenamesToWrite.add(gde.jsonFile.getName());
|
||||||
}
|
}
|
||||||
for (String fName : alteredFileNames) {
|
}
|
||||||
for (JSONElement gde : source) {
|
for (JSONElement gde : created.toList()) {
|
||||||
|
if (!filenamesToWrite.contains(gde.jsonFile.getName())) {
|
||||||
|
filenamesToWrite.add(gde.jsonFile.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String fName : filenamesToWrite) {
|
||||||
|
for (JSONElement gde : source.toList()) {
|
||||||
if (gde.jsonFile.getName().equals(fName)) {
|
if (gde.jsonFile.getName().equals(fName)) {
|
||||||
if (toWrite.get(fName) == null) {
|
if (dataToWritePerFilename.get(fName) == null) {
|
||||||
toWrite.put(fName, new ArrayList<Map>());
|
dataToWritePerFilename.put(fName, new ArrayList<Map>());
|
||||||
}
|
}
|
||||||
toWrite.get(fName).add(getGameDataElement(gdeClass, gde.id).toJson());
|
//Automatically fetches altered element over source element.
|
||||||
|
dataToWritePerFilename.get(fName).add(getGameDataElement(gdeClass, gde.id).toJson());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (JSONElement gde : created.toList()) {
|
||||||
|
if (gde.jsonFile.getName().equals(fName)) {
|
||||||
|
if (dataToWritePerFilename.get(fName) == null) {
|
||||||
|
dataToWritePerFilename.put(fName, new ArrayList<Map>());
|
||||||
|
}
|
||||||
|
//Add the created elements.
|
||||||
|
dataToWritePerFilename.get(fName).add(getGameDataElement(gdeClass, gde.id).toJson());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String fName : toWrite.keySet()) {
|
for (String fName : dataToWritePerFilename.keySet()) {
|
||||||
File jsonFile = new File(targetFolder, fName);
|
File jsonFile = new File(targetFolder, fName);
|
||||||
StringWriter writer = new JsonPrettyWriter();
|
|
||||||
try {
|
String textToWrite = FileUtils.toJsonString(dataToWritePerFilename.get(fName));
|
||||||
JSONArray.writeJSONString(toWrite.get(fName), writer);
|
FileUtils.writeStringToFile(textToWrite, jsonFile, "JSON file '"+jsonFile.getAbsolutePath()+"'", false);
|
||||||
} catch (IOException e) {
|
|
||||||
//Impossible with a StringWriter
|
|
||||||
}
|
}
|
||||||
String textToWrite = writer.toString();
|
return filenamesToWrite;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void writeResourceListXml(Map<Class<? extends GameDataElement>, List<String>> writtenFilesPerDataType, String xmlFileRelPath, File baseFolder, File tmpDir) {
|
||||||
|
File xmlFile = new File(baseFolder, xmlFileRelPath);
|
||||||
|
File outputFile = new File(tmpDir, xmlFileRelPath);
|
||||||
|
|
||||||
|
Map<String, Class<? extends GameDataElement>> classNamesByArrayNames = new HashMap<String, Class<? extends GameDataElement>>();
|
||||||
|
classNamesByArrayNames.put("loadresource_itemcategories", ItemCategory.class);
|
||||||
|
classNamesByArrayNames.put("loadresource_actorconditions", ActorCondition.class);
|
||||||
|
classNamesByArrayNames.put("loadresource_items", Item.class);
|
||||||
|
classNamesByArrayNames.put("loadresource_droplists", Droplist.class);
|
||||||
|
classNamesByArrayNames.put("loadresource_quests", Quest.class);
|
||||||
|
classNamesByArrayNames.put("loadresource_conversationlists", Dialogue.class);
|
||||||
|
classNamesByArrayNames.put("loadresource_monsters", NPC.class);
|
||||||
|
classNamesByArrayNames.put("loadresource_maps", TMXMap.class);
|
||||||
|
|
||||||
|
String jsonResPrefix = "@raw/";
|
||||||
|
String tmxResPrefix = "@xml/";
|
||||||
|
String jsonFileSuffix = ".json";
|
||||||
|
String tmxFileSuffix = ".tmx";
|
||||||
|
|
||||||
|
if (!xmlFile.exists()) return;
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
Document doc;
|
||||||
try {
|
try {
|
||||||
FileWriter w = new FileWriter(jsonFile);
|
factory.setIgnoringElementContentWhitespace(true);
|
||||||
w.write(textToWrite);
|
factory.setExpandEntityReferences(false);
|
||||||
w.close();
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
// Notification.addSuccess("Json file "+jsonFile.getAbsolutePath()+" saved.");
|
|
||||||
|
InputSource insrc = new InputSource(new FileInputStream(xmlFile));
|
||||||
|
insrc.setEncoding("UTF-8");
|
||||||
|
doc = builder.parse(insrc);
|
||||||
|
|
||||||
|
Element arrayNode;
|
||||||
|
String name, resPrefix, fileSuffix, resName, resToFile, fileToRes;
|
||||||
|
Class<? extends GameDataElement> clazz;
|
||||||
|
List<String> writtenFiles;
|
||||||
|
|
||||||
|
Element root = (Element) doc.getElementsByTagName("resources").item(0);
|
||||||
|
if (root != null) {
|
||||||
|
NodeList arraysList = root.getElementsByTagName("array");
|
||||||
|
if (arraysList != null) {
|
||||||
|
for (int i = 0; i < arraysList.getLength(); i++) {
|
||||||
|
arrayNode = (Element) arraysList.item(i);
|
||||||
|
name = arrayNode.getAttribute("name");
|
||||||
|
clazz = classNamesByArrayNames.get(name);
|
||||||
|
if (clazz == null) continue;
|
||||||
|
writtenFiles = writtenFilesPerDataType.get(clazz);
|
||||||
|
if (writtenFiles == null) continue;
|
||||||
|
if (clazz == TMXMap.class) {
|
||||||
|
resPrefix = tmxResPrefix;
|
||||||
|
fileSuffix = tmxFileSuffix;
|
||||||
|
} else {
|
||||||
|
resPrefix = jsonResPrefix;
|
||||||
|
fileSuffix = jsonFileSuffix;
|
||||||
|
}
|
||||||
|
NodeList arrayItems = arrayNode.getElementsByTagName("item");
|
||||||
|
if (arrayItems != null) {
|
||||||
|
for (int j = 0; j < arrayItems.getLength(); j++) {
|
||||||
|
resName = ((Element) arrayItems.item(j)).getTextContent();
|
||||||
|
if (resName == null) continue;
|
||||||
|
resToFile = resName.replaceFirst("\\A" + resPrefix, "") + fileSuffix;
|
||||||
|
writtenFiles.remove(resToFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!writtenFiles.isEmpty()) {
|
||||||
|
Comment com = doc.createComment("Added by ATCS " + ATContentStudio.APP_VERSION + " for project " + getProject().name);
|
||||||
|
arrayNode.appendChild(com);
|
||||||
|
Collections.sort(writtenFiles);
|
||||||
|
for (String missingRes : writtenFiles) {
|
||||||
|
Element item = doc.createElement("item");
|
||||||
|
fileToRes = resPrefix + missingRes.replaceFirst(fileSuffix + "\\z", "");
|
||||||
|
item.setTextContent(fileToRes);
|
||||||
|
arrayNode.appendChild(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||||
|
if (!outputFile.getParentFile().exists()) {
|
||||||
|
outputFile.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
StringWriter temp = new StringWriter();
|
||||||
|
Result output = new StreamResult(temp);
|
||||||
|
Source input = new DOMSource(doc);
|
||||||
|
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||||
|
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
|
||||||
|
transformer.transform(input, output);
|
||||||
|
|
||||||
|
String tempString = temp.toString();
|
||||||
|
doc = builder.parse(new ByteArrayInputStream(tempString.getBytes("UTF-8")));
|
||||||
|
input = new DOMSource(doc);
|
||||||
|
transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(new StringReader(
|
||||||
|
"<?xml version=\"1.0\"?>\r\n" +
|
||||||
|
"<xsl:stylesheet version=\"1.0\"\r\n" +
|
||||||
|
" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\r\n" +
|
||||||
|
" <xsl:strip-space elements=\"*\" />\r\n" +
|
||||||
|
" <xsl:output method=\"xml\" indent=\"yes\" />\r\n" +
|
||||||
|
"\r\n" +
|
||||||
|
" <xsl:template match=\"node() | @*\" name=\"identity\">\r\n" +
|
||||||
|
" <xsl:copy>\r\n" +
|
||||||
|
" <xsl:apply-templates select=\"node() | @*\" />\r\n" +
|
||||||
|
" </xsl:copy>\r\n" +
|
||||||
|
" </xsl:template>\r\n" +
|
||||||
|
"\r\n" +
|
||||||
|
" <xsl:template match=\"array\">\r\n" +
|
||||||
|
" <xsl:call-template name=\"identity\"/>\r\n" +
|
||||||
|
" <xsl:text>

    </xsl:text>\r\n" +
|
||||||
|
" </xsl:template>\r\n" +
|
||||||
|
"</xsl:stylesheet>")));
|
||||||
|
output = new StreamResult(new FileOutputStream(outputFile));
|
||||||
|
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
|
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
||||||
|
transformer.transform(input, output);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (SAXException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Notification.addError("Error while writing json file "+jsonFile.getAbsolutePath()+" : "+e.getMessage());
|
e.printStackTrace();
|
||||||
|
} catch (TransformerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean needsSaving() {
|
public boolean needsSaving() {
|
||||||
@@ -1147,7 +1358,4 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,26 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model;
|
package com.gpl.rpg.atcontentstudio.model;
|
||||||
|
|
||||||
import java.awt.Image;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
|
import java.awt.*;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ProjectTreeNode extends TreeNode {
|
public interface ProjectTreeNode extends TreeNode {
|
||||||
|
|
||||||
public void childrenAdded(List<ProjectTreeNode> path);
|
public void childrenAdded(List<ProjectTreeNode> path);
|
||||||
|
|
||||||
public void childrenChanged(List<ProjectTreeNode> path);
|
public void childrenChanged(List<ProjectTreeNode> path);
|
||||||
|
|
||||||
public void childrenRemoved(List<ProjectTreeNode> path);
|
public void childrenRemoved(List<ProjectTreeNode> path);
|
||||||
|
|
||||||
public void notifyCreated();
|
public void notifyCreated();
|
||||||
|
|
||||||
public String getDesc();
|
public String getDesc();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unnecessary for anything not below a Project. Can return null.
|
* Unnecessary for anything not below a Project. Can return null.
|
||||||
|
*
|
||||||
* @return the parent Project or null.
|
* @return the parent Project or null.
|
||||||
*/
|
*/
|
||||||
public Project getProject();
|
public Project getProject();
|
||||||
@@ -25,29 +28,31 @@ public interface ProjectTreeNode extends TreeNode {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unnecessary for anything not below a GameDataSet. Can return null.
|
* Unnecessary for anything not below a GameDataSet. Can return null.
|
||||||
|
*
|
||||||
* @return the parent GameDataSet or null.
|
* @return the parent GameDataSet or null.
|
||||||
*/
|
*/
|
||||||
public GameDataSet getDataSet();
|
public GameDataSet getDataSet();
|
||||||
|
|
||||||
public Image getIcon();
|
public Image getIcon();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return The icon depicting this node when it is an open folder. Can be null for leaves.
|
* @return The icon depicting this node when it is an open folder. Can be null for leaves.
|
||||||
*/
|
*/
|
||||||
public Image getOpenIcon();
|
public Image getOpenIcon();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return The icon depicting this node when it is a closed folder. Can be null for leaves.
|
* @return The icon depicting this node when it is a closed folder. Can be null for leaves.
|
||||||
*/
|
*/
|
||||||
public Image getClosedIcon();
|
public Image getClosedIcon();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return The icon depicting this node when it is a leaf. Should return the closed one for empty folders.
|
* @return The icon depicting this node when it is a leaf. Should return the closed one for empty folders.
|
||||||
*/
|
*/
|
||||||
public Image getLeafIcon();
|
public Image getLeafIcon();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unnecessary for anything not below a GameSource. Can return null.
|
* Unnecessary for anything not below a GameSource. Can return null.
|
||||||
|
*
|
||||||
* @return the parent GameSource or null.
|
* @return the parent GameSource or null.
|
||||||
*/
|
*/
|
||||||
public GameSource.Type getDataType();
|
public GameSource.Type getDataType();
|
||||||
|
|||||||
@@ -1,34 +1,30 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model;
|
package com.gpl.rpg.atcontentstudio.model;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
import javax.swing.tree.TreePath;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
|
import com.gpl.rpg.atcontentstudio.io.JsonSerializable;
|
||||||
import com.gpl.rpg.atcontentstudio.io.SettingsSave;
|
import com.gpl.rpg.atcontentstudio.io.SettingsSave;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.ProjectsTree.ProjectsTreeModel;
|
import com.gpl.rpg.atcontentstudio.ui.ProjectsTree.ProjectsTreeModel;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
||||||
|
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||||
|
import org.jsoup.SerializationException;
|
||||||
|
|
||||||
public class Workspace implements ProjectTreeNode, Serializable {
|
import javax.swing.tree.TreeNode;
|
||||||
|
import javax.swing.tree.TreePath;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class Workspace implements ProjectTreeNode, Serializable, JsonSerializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7938633033601384956L;
|
private static final long serialVersionUID = 7938633033601384956L;
|
||||||
|
|
||||||
public static final String WS_SETTINGS_FILE = ".workspace";
|
public static final String WS_SETTINGS_FILE = ".workspace";
|
||||||
|
public static final String WS_SETTINGS_FILE_JSON = ".workspace.json";
|
||||||
|
|
||||||
public static Workspace activeWorkspace;
|
public static Workspace activeWorkspace;
|
||||||
|
|
||||||
@@ -44,6 +40,7 @@ public class Workspace implements ProjectTreeNode, Serializable {
|
|||||||
public transient ProjectsTreeModel projectsTreeModel = null;
|
public transient ProjectsTreeModel projectsTreeModel = null;
|
||||||
|
|
||||||
public Workspace(File workspaceRoot) {
|
public Workspace(File workspaceRoot) {
|
||||||
|
boolean freshWorkspace = false;
|
||||||
baseFolder = workspaceRoot;
|
baseFolder = workspaceRoot;
|
||||||
if (!workspaceRoot.exists()) {
|
if (!workspaceRoot.exists()) {
|
||||||
try {
|
try {
|
||||||
@@ -55,23 +52,70 @@ public class Workspace implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings = new WorkspaceSettings(this);
|
settings = new WorkspaceSettings(this);
|
||||||
settingsFile = new File(workspaceRoot, WS_SETTINGS_FILE);
|
settingsFile = new File(workspaceRoot, WS_SETTINGS_FILE_JSON);
|
||||||
if (!settingsFile.exists()) {
|
if (!settingsFile.exists()) {
|
||||||
try {
|
try {
|
||||||
settingsFile.createNewFile();
|
settingsFile.createNewFile();
|
||||||
|
freshWorkspace = true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Notification.addError("Error creating workspace datafile: "
|
Notification.addError("Error creating workspace datafile: "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Notification.addSuccess("New workspace created: "
|
Notification.addSuccess("New workspace created: "
|
||||||
+ workspaceRoot.getAbsolutePath());
|
+ workspaceRoot.getAbsolutePath());
|
||||||
|
}
|
||||||
|
if (freshWorkspace)
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map toMap() {
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("serialVersionUID", serialVersionUID);
|
||||||
|
map.put("preferences", preferences.toMap());
|
||||||
|
map.put("projectsName", (new ArrayList<String>(projectsName)));
|
||||||
|
map.put("projectsOpenByName", projectsOpenByName);
|
||||||
|
List<String> l = new ArrayList<>(knownMapSourcesFolders.size());
|
||||||
|
for (File f: knownMapSourcesFolders){
|
||||||
|
l.add(f.getPath());
|
||||||
|
}
|
||||||
|
map.put("knownMapSourcesFolders", l);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromMap(Map map) {
|
||||||
|
if(serialVersionUID != (long) map.get("serialVersionUID")){
|
||||||
|
throw new SerializationException("wrong seriaVersionUID");
|
||||||
|
}
|
||||||
|
|
||||||
|
preferences.fromMap((Map) map.get("preferences"));
|
||||||
|
|
||||||
|
projectsName = new HashSet<>((List<String>) map.getOrDefault("projectsName", new HashSet<String>()));
|
||||||
|
|
||||||
|
projectsOpenByName = (Map<String, Boolean>) map.getOrDefault("projectsOpenByName", new HashMap<String, Boolean>() );
|
||||||
|
|
||||||
|
List<String> knownMapSourcesFolders1 = (List<String>) map.getOrDefault("knownMapSourcesFolders", new ArrayList<String>());
|
||||||
|
knownMapSourcesFolders = new HashSet<>();
|
||||||
|
if (knownMapSourcesFolders1 != null){
|
||||||
|
int size = knownMapSourcesFolders1.size();
|
||||||
|
for (String path: knownMapSourcesFolders1) {
|
||||||
|
//TODO: catch invalid paths...?
|
||||||
|
knownMapSourcesFolders.add(new File(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static void setActive(File workspaceRoot) {
|
public static void setActive(File workspaceRoot) {
|
||||||
Workspace w = null;
|
Workspace w;
|
||||||
|
File f2 = new File(workspaceRoot, WS_SETTINGS_FILE_JSON);
|
||||||
|
if (f2.exists()) {
|
||||||
|
w = loadWorkspaceFromJson(workspaceRoot, f2);
|
||||||
|
w.refreshTransients();
|
||||||
|
} else {
|
||||||
|
Notification.addInfo("Could not find json workspace file. Checking for binary file");
|
||||||
File f = new File(workspaceRoot, WS_SETTINGS_FILE);
|
File f = new File(workspaceRoot, WS_SETTINGS_FILE);
|
||||||
if (!workspaceRoot.exists() || !f.exists()) {
|
if (!workspaceRoot.exists() || !f.exists()) {
|
||||||
w = new Workspace(workspaceRoot);
|
w = new Workspace(workspaceRoot);
|
||||||
@@ -80,19 +124,33 @@ public class Workspace implements ProjectTreeNode, Serializable {
|
|||||||
if (w == null) {
|
if (w == null) {
|
||||||
w = new Workspace(workspaceRoot);
|
w = new Workspace(workspaceRoot);
|
||||||
} else {
|
} else {
|
||||||
|
w.settingsFile = f2;
|
||||||
|
w.baseFolder = workspaceRoot;
|
||||||
|
Notification.addInfo("Switched workspace to json format.");
|
||||||
w.refreshTransients();
|
w.refreshTransients();
|
||||||
}
|
}
|
||||||
|
w.save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
activeWorkspace = w;
|
activeWorkspace = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Workspace loadWorkspaceFromJson(File workspaceRoot, File settingsFile) {
|
||||||
|
Workspace w = w = new Workspace(workspaceRoot);
|
||||||
|
Map json = FileUtils.mapFromJsonFile(settingsFile);
|
||||||
|
if (json!= null) {
|
||||||
|
w.fromMap(json);
|
||||||
|
}
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
public static void saveActive() {
|
public static void saveActive() {
|
||||||
activeWorkspace.save();
|
activeWorkspace.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
settings.save();
|
settings.save();
|
||||||
SettingsSave.saveInstance(this, settingsFile, "Workspace");
|
FileUtils.writeStringToFile(FileUtils.toJsonString(this), settingsFile, "Workspace");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -310,7 +368,6 @@ public class Workspace implements ProjectTreeNode, Serializable {
|
|||||||
Notification.addError("Error while deleting closed project "
|
Notification.addError("Error while deleting closed project "
|
||||||
+ cp.name + ". Files may remain in the workspace.");
|
+ cp.name + ". Files may remain in the workspace.");
|
||||||
}
|
}
|
||||||
cp = null;
|
|
||||||
saveActive();
|
saveActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,17 +383,18 @@ public class Workspace implements ProjectTreeNode, Serializable {
|
|||||||
Notification.addError("Error while deleting project " + p.name
|
Notification.addError("Error while deleting project " + p.name
|
||||||
+ ". Files may remain in the workspace.");
|
+ ". Files may remain in the workspace.");
|
||||||
}
|
}
|
||||||
p = null;
|
|
||||||
saveActive();
|
saveActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean delete(File f) {
|
private static boolean delete(File f) {
|
||||||
boolean b = true;
|
boolean b = true;
|
||||||
if (f.isDirectory()) {
|
if (Files.isSymbolicLink(f.toPath())) {
|
||||||
|
b &= f.delete();
|
||||||
|
} else if (f.isDirectory()) {
|
||||||
for (File c : f.listFiles())
|
for (File c : f.listFiles())
|
||||||
b &= delete(c);
|
b &= delete(c);
|
||||||
}
|
}
|
||||||
return b &= f.delete();
|
return b & f.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -362,5 +420,4 @@ public class Workspace implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,15 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model;
|
package com.gpl.rpg.atcontentstudio.model;
|
||||||
|
|
||||||
import java.io.File;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
import java.io.FileReader;
|
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||||
import java.io.FileWriter;
|
import org.json.simple.parser.JSONParser;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
|
||||||
import com.gpl.rpg.atcontentstudio.io.JsonPrettyWriter;
|
|
||||||
|
|
||||||
public class WorkspaceSettings {
|
public class WorkspaceSettings {
|
||||||
|
|
||||||
public static final String VERSION_KEY = "ATCS_Version";
|
public static final String VERSION_KEY = "ATCS_Version";
|
||||||
@@ -38,10 +32,12 @@ public class WorkspaceSettings {
|
|||||||
public static String DEFAULT_IMG_EDITOR_COMMAND = "gimp";
|
public static String DEFAULT_IMG_EDITOR_COMMAND = "gimp";
|
||||||
public Setting<String> imageEditorCommand = new PrimitiveSetting<String>("imageEditorCommand", DEFAULT_IMG_EDITOR_COMMAND);
|
public Setting<String> imageEditorCommand = new PrimitiveSetting<String>("imageEditorCommand", DEFAULT_IMG_EDITOR_COMMAND);
|
||||||
|
|
||||||
public static String[] LANGUAGE_LIST = new String[]{null, "de", "ru", "pl", "fr", "it", "es", "nl", "uk", "ca", "sv", "pt", "pt_BR", "zh_Hant", "zh_Hans", "ja", "cs", "tr", "ko", "hu", "sl", "bg", "id", "fi", "th", "gl", "ms" ,"pa", "az"};
|
public static String[] LANGUAGE_LIST = new String[]{null, "de", "ru", "pl", "fr", "it", "es", "nl", "uk", "ca", "sv", "pt", "pt_BR", "zh_Hant", "zh_Hans", "ja", "cs", "tr", "ko", "hu", "sl", "bg", "id", "fi", "th", "gl", "ms", "pa", "az", "nb"};
|
||||||
public Setting<String> translatorLanguage = new NullDefaultPrimitiveSetting<String>("translatorLanguage");
|
public Setting<String> translatorLanguage = new NullDefaultPrimitiveSetting<String>("translatorLanguage");
|
||||||
public static Boolean DEFAULT_ALLOW_INTERNET = true;
|
public static Boolean DEFAULT_ALLOW_INTERNET = true;
|
||||||
public Setting<Boolean> useInternet = new PrimitiveSetting<Boolean>("useInternet", DEFAULT_ALLOW_INTERNET);
|
public Setting<Boolean> useInternet = new PrimitiveSetting<Boolean>("useInternet", DEFAULT_ALLOW_INTERNET);
|
||||||
|
public static Boolean DEFAULT_CHECK_UPDATE = true;
|
||||||
|
public Setting<Boolean> checkUpdates = new PrimitiveSetting<Boolean>("checkUpdates", DEFAULT_CHECK_UPDATE);
|
||||||
|
|
||||||
|
|
||||||
public List<Setting<? extends Object>> settings = new ArrayList<Setting<? extends Object>>();
|
public List<Setting<? extends Object>> settings = new ArrayList<Setting<? extends Object>>();
|
||||||
@@ -55,6 +51,7 @@ public class WorkspaceSettings {
|
|||||||
settings.add(imageEditorCommand);
|
settings.add(imageEditorCommand);
|
||||||
settings.add(translatorLanguage);
|
settings.add(translatorLanguage);
|
||||||
settings.add(useInternet);
|
settings.add(useInternet);
|
||||||
|
settings.add(checkUpdates);
|
||||||
file = new File(parent.baseFolder, FILENAME);
|
file = new File(parent.baseFolder, FILENAME);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
load(file);
|
load(file);
|
||||||
@@ -110,22 +107,8 @@ public class WorkspaceSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
json.put(VERSION_KEY, SETTINGS_VERSION);
|
json.put(VERSION_KEY, SETTINGS_VERSION);
|
||||||
StringWriter writer = new JsonPrettyWriter();
|
String toWrite = FileUtils.toJsonString(json);
|
||||||
try {
|
FileUtils.writeStringToFile(toWrite, file, "Workspace settings");
|
||||||
JSONObject.writeJSONString(json, writer);
|
|
||||||
} catch (IOException e) {
|
|
||||||
//Impossible with a StringWriter
|
|
||||||
}
|
|
||||||
String toWrite = writer.toString();
|
|
||||||
try {
|
|
||||||
FileWriter w = new FileWriter(file);
|
|
||||||
w.write(toWrite);
|
|
||||||
w.close();
|
|
||||||
Notification.addSuccess("Workspace settings saved.");
|
|
||||||
} catch (IOException e) {
|
|
||||||
Notification.addError("Error while saving workspace settings : "+e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetDefault() {
|
public void resetDefault() {
|
||||||
@@ -155,7 +138,7 @@ public class WorkspaceSettings {
|
|||||||
value = defaultValue;
|
value = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void readFromJson(Map json);
|
public abstract void readFromJson(@SuppressWarnings("rawtypes") Map json);
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
public void saveToJson(Map json) {
|
public void saveToJson(Map json) {
|
||||||
@@ -185,6 +168,7 @@ public class WorkspaceSettings {
|
|||||||
super(id, null);
|
super(id, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
@Override
|
@Override
|
||||||
public void saveToJson(Map json) {
|
public void saveToJson(Map json) {
|
||||||
if (value != null) json.put(id, value);
|
if (value != null) json.put(id, value);
|
||||||
@@ -198,6 +182,7 @@ public class WorkspaceSettings {
|
|||||||
this.value = this.defaultValue = defaultValue;
|
this.value = this.defaultValue = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Override
|
@Override
|
||||||
public void readFromJson(Map json) {
|
public void readFromJson(Map json) {
|
||||||
value = new ArrayList<X>();
|
value = new ArrayList<X>();
|
||||||
@@ -211,5 +196,4 @@ public class WorkspaceSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,161 @@
|
|||||||
|
package com.gpl.rpg.atcontentstudio.model.bookmarks;
|
||||||
|
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.gamedata.Quest;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.gamedata.QuestStage;
|
||||||
|
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BookmarkEntry implements BookmarkNode {
|
||||||
|
|
||||||
|
public GameDataElement bookmarkedElement;
|
||||||
|
public BookmarkFolder parent;
|
||||||
|
|
||||||
|
public BookmarkEntry(BookmarkFolder parent, GameDataElement target) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.bookmarkedElement = target;
|
||||||
|
target.bookmark = this;
|
||||||
|
parent.contents.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Enumeration<ProjectTreeNode> children() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getAllowsChildren() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TreeNode getChildAt(int childIndex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getChildCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIndex(TreeNode node) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TreeNode getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLeaf() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void childrenAdded(List<ProjectTreeNode> path) {
|
||||||
|
path.add(0, this);
|
||||||
|
parent.childrenAdded(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void childrenChanged(List<ProjectTreeNode> path) {
|
||||||
|
path.add(0, this);
|
||||||
|
parent.childrenChanged(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void childrenRemoved(List<ProjectTreeNode> path) {
|
||||||
|
path.add(0, this);
|
||||||
|
parent.childrenRemoved(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyCreated() {
|
||||||
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDesc() {
|
||||||
|
if (bookmarkedElement instanceof QuestStage) {
|
||||||
|
String text = ((GameDataElement) bookmarkedElement).getDesc();
|
||||||
|
if (text.length() > 60) {
|
||||||
|
text = text.substring(0, 57) + "...";
|
||||||
|
}
|
||||||
|
return ((GameDataElement) bookmarkedElement).getDataType().toString() +
|
||||||
|
"/" +
|
||||||
|
((Quest) ((QuestStage) bookmarkedElement).parent).id +
|
||||||
|
"#" +
|
||||||
|
((QuestStage) bookmarkedElement).progress +
|
||||||
|
":" +
|
||||||
|
text;
|
||||||
|
} else {
|
||||||
|
return ((GameDataElement) bookmarkedElement).getDataType().toString() + "/" + ((GameDataElement) bookmarkedElement).getDesc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Project getProject() {
|
||||||
|
return parent.getProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameDataSet getDataSet() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getIcon() {
|
||||||
|
return bookmarkedElement.getIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getOpenIcon() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getClosedIcon() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getLeafIcon() {
|
||||||
|
return getIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getDataType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean needsSaving() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete() {
|
||||||
|
bookmarkedElement.bookmark = null;
|
||||||
|
parent.delete(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save() {
|
||||||
|
parent.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
package com.gpl.rpg.atcontentstudio.model.bookmarks;
|
||||||
|
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class BookmarkFolder implements BookmarkNode {
|
||||||
|
|
||||||
|
List<BookmarkNode> contents = new LinkedList<BookmarkNode>();
|
||||||
|
BookmarkNode parent;
|
||||||
|
String name;
|
||||||
|
Image closedIcon, openIcon;
|
||||||
|
|
||||||
|
public BookmarkFolder(BookmarkNode parent, String name) {
|
||||||
|
this(parent, name, DefaultIcons.getStdClosedIcon(), DefaultIcons.getStdOpenIcon());
|
||||||
|
}
|
||||||
|
|
||||||
|
public BookmarkFolder(BookmarkNode parent, String name, Image closedIcon, Image openIcon) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.name = name;
|
||||||
|
this.closedIcon = closedIcon;
|
||||||
|
this.openIcon = openIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Enumeration<? extends ProjectTreeNode> children() {
|
||||||
|
return Collections.enumeration(contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getAllowsChildren() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TreeNode getChildAt(int childIndex) {
|
||||||
|
return contents.get(childIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getChildCount() {
|
||||||
|
return contents.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIndex(TreeNode node) {
|
||||||
|
return contents.indexOf(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TreeNode getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLeaf() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void childrenAdded(List<ProjectTreeNode> path) {
|
||||||
|
path.add(0, this);
|
||||||
|
parent.childrenAdded(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void childrenChanged(List<ProjectTreeNode> path) {
|
||||||
|
path.add(0, this);
|
||||||
|
parent.childrenChanged(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void childrenRemoved(List<ProjectTreeNode> path) {
|
||||||
|
if (path.size() == 1 && this.getChildCount() == 1) {
|
||||||
|
childrenRemoved(new ArrayList<ProjectTreeNode>());
|
||||||
|
} else {
|
||||||
|
path.add(0, this);
|
||||||
|
parent.childrenRemoved(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyCreated() {
|
||||||
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDesc() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Project getProject() {
|
||||||
|
return parent.getProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameDataSet getDataSet() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getIcon() {
|
||||||
|
return getClosedIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getOpenIcon() {
|
||||||
|
return openIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getClosedIcon() {
|
||||||
|
return closedIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getLeafIcon() {
|
||||||
|
return getClosedIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getDataType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return contents.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean needsSaving() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(BookmarkEntry bookmarkEntry) {
|
||||||
|
if (contents.contains(bookmarkEntry)) {
|
||||||
|
bookmarkEntry.childrenRemoved(new ArrayList<ProjectTreeNode>());
|
||||||
|
contents.remove(bookmarkEntry);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(BookmarkFolder bookmarkFolder) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
parent.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.gpl.rpg.atcontentstudio.model.bookmarks;
|
||||||
|
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||||
|
|
||||||
|
public interface BookmarkNode extends ProjectTreeNode {
|
||||||
|
|
||||||
|
public void save();
|
||||||
|
|
||||||
|
public void delete();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
package com.gpl.rpg.atcontentstudio.model.bookmarks;
|
||||||
|
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.SavedSlotCollection;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.gamedata.*;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||||
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BookmarksRoot implements BookmarkNode {
|
||||||
|
|
||||||
|
SavedSlotCollection v = new SavedSlotCollection();
|
||||||
|
|
||||||
|
public transient Project parent;
|
||||||
|
|
||||||
|
BookmarkFolder ac, diag, dl, it, ic, npc, q, tmx, sp, wm;
|
||||||
|
|
||||||
|
public BookmarksRoot(Project parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
|
||||||
|
v.add(ac = new BookmarkFolder(this, ActorCondition.getStaticDesc(), DefaultIcons.getJsonClosedIcon(), DefaultIcons.getJsonOpenIcon()));
|
||||||
|
v.add(diag = new BookmarkFolder(this, Dialogue.getStaticDesc(), DefaultIcons.getJsonClosedIcon(), DefaultIcons.getJsonOpenIcon()));
|
||||||
|
v.add(dl = new BookmarkFolder(this, Droplist.getStaticDesc(), DefaultIcons.getJsonClosedIcon(), DefaultIcons.getJsonOpenIcon()));
|
||||||
|
v.add(it = new BookmarkFolder(this, Item.getStaticDesc(), DefaultIcons.getJsonClosedIcon(), DefaultIcons.getJsonOpenIcon()));
|
||||||
|
v.add(ic = new BookmarkFolder(this, ItemCategory.getStaticDesc(), DefaultIcons.getJsonClosedIcon(), DefaultIcons.getJsonOpenIcon()));
|
||||||
|
v.add(npc = new BookmarkFolder(this, NPC.getStaticDesc(), DefaultIcons.getJsonClosedIcon(), DefaultIcons.getJsonOpenIcon()));
|
||||||
|
v.add(q = new BookmarkFolder(this, Quest.getStaticDesc(), DefaultIcons.getJsonClosedIcon(), DefaultIcons.getJsonOpenIcon()));
|
||||||
|
|
||||||
|
v.add(tmx = new BookmarkFolder(this, "TMX Maps", DefaultIcons.getTmxClosedIcon(), DefaultIcons.getTmxOpenIcon()));
|
||||||
|
v.add(sp = new BookmarkFolder(this, "Spritesheets", DefaultIcons.getSpriteClosedIcon(), DefaultIcons.getSpriteOpenIcon()));
|
||||||
|
v.add(wm = new BookmarkFolder(this, "Worldmap", DefaultIcons.getSpriteClosedIcon(), DefaultIcons.getSpriteOpenIcon()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Enumeration<ProjectTreeNode> children() {
|
||||||
|
return v.getNonEmptyElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getAllowsChildren() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TreeNode getChildAt(int arg0) {
|
||||||
|
return v.getNonEmptyElementAt(arg0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getChildCount() {
|
||||||
|
return v.getNonEmptySize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIndex(TreeNode arg0) {
|
||||||
|
return v.getNonEmptyIndexOf((ProjectTreeNode) arg0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TreeNode getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLeaf() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void childrenAdded(List<ProjectTreeNode> path) {
|
||||||
|
path.add(0, this);
|
||||||
|
parent.childrenAdded(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void childrenChanged(List<ProjectTreeNode> path) {
|
||||||
|
path.add(0, this);
|
||||||
|
parent.childrenChanged(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void childrenRemoved(List<ProjectTreeNode> path) {
|
||||||
|
if (path.size() == 1 && this.v.getNonEmptySize() == 1) {
|
||||||
|
childrenRemoved(new ArrayList<ProjectTreeNode>());
|
||||||
|
} else {
|
||||||
|
path.add(0, this);
|
||||||
|
parent.childrenRemoved(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyCreated() {
|
||||||
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
|
for (ProjectTreeNode node : v.getNonEmptyIterable()) {
|
||||||
|
node.notifyCreated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDesc() {
|
||||||
|
return (needsSaving() ? "*" : "") + "Bookmarks";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Project getProject() {
|
||||||
|
return parent == null ? null : parent.getProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameDataSet getDataSet() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getIcon() {
|
||||||
|
return getOpenIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getOpenIcon() {
|
||||||
|
return DefaultIcons.getBookmarkOpenIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getClosedIcon() {
|
||||||
|
return DefaultIcons.getBookmarkClosedIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getLeafIcon() {
|
||||||
|
return getClosedIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getDataType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return v.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean needsSaving() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBookmark(GameDataElement target) {
|
||||||
|
BookmarkEntry node;
|
||||||
|
BookmarkFolder folder;
|
||||||
|
if (target instanceof ActorCondition) {
|
||||||
|
folder = ac;
|
||||||
|
} else if (target instanceof Dialogue) {
|
||||||
|
folder = diag;
|
||||||
|
} else if (target instanceof Droplist) {
|
||||||
|
folder = dl;
|
||||||
|
} else if (target instanceof Item) {
|
||||||
|
folder = it;
|
||||||
|
} else if (target instanceof ItemCategory) {
|
||||||
|
folder = ic;
|
||||||
|
} else if (target instanceof NPC) {
|
||||||
|
folder = npc;
|
||||||
|
} else if (target instanceof Quest) {
|
||||||
|
folder = q;
|
||||||
|
} else if (target instanceof TMXMap) {
|
||||||
|
folder = tmx;
|
||||||
|
} else if (target instanceof Spritesheet) {
|
||||||
|
folder = sp;
|
||||||
|
} else if (target instanceof WorldmapSegment) {
|
||||||
|
folder = wm;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ProjectTreeNode higherEmptyParent = folder;
|
||||||
|
while (higherEmptyParent != null) {
|
||||||
|
if (higherEmptyParent.getParent() != null && ((ProjectTreeNode) higherEmptyParent.getParent()).isEmpty())
|
||||||
|
higherEmptyParent = (ProjectTreeNode) higherEmptyParent.getParent();
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
||||||
|
|
||||||
|
node = new BookmarkEntry(folder, target);
|
||||||
|
if (higherEmptyParent != null) higherEmptyParent.notifyCreated();
|
||||||
|
else node.notifyCreated();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
import java.awt.Image;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
@@ -9,24 +15,20 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
|
||||||
|
|
||||||
|
|
||||||
public class ActorCondition extends JSONElement {
|
public class ActorCondition extends JSONElement {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3969824899972048507L;
|
private static final long serialVersionUID = -3969824899972048507L;
|
||||||
|
|
||||||
public static final Integer CLEAR_AC_MAGNITUDE = -99;
|
public static final Integer MAGNITUDE_CLEAR = -99;
|
||||||
|
public static final Integer DURATION_FOREVER = 999;
|
||||||
|
public static final Integer DURATION_NONE = 0;
|
||||||
|
|
||||||
// Available from init state
|
// Available from init state
|
||||||
//public String id; inherited.
|
//public String id; inherited.
|
||||||
public String icon_id;
|
public String icon_id;
|
||||||
public String display_name;
|
public String display_name;
|
||||||
|
public String description;
|
||||||
|
|
||||||
// Available from parsed state
|
// Available from parsed state
|
||||||
public ACCategory category = null;
|
public ACCategory category = null;
|
||||||
@@ -43,9 +45,13 @@ public class ActorCondition extends JSONElement {
|
|||||||
blood
|
blood
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static enum VisualEffectID {
|
||||||
|
redSplash, blueSwirl, greenSplash, miss
|
||||||
|
}
|
||||||
|
|
||||||
public static class RoundEffect implements Cloneable {
|
public static class RoundEffect implements Cloneable {
|
||||||
// Available from parsed state
|
// Available from parsed state
|
||||||
public String visual_effect = null;
|
public VisualEffectID visual_effect = null;
|
||||||
public Integer hp_boost_min = null;
|
public Integer hp_boost_min = null;
|
||||||
public Integer hp_boost_max = null;
|
public Integer hp_boost_max = null;
|
||||||
public Integer ap_boost_min = null;
|
public Integer ap_boost_min = null;
|
||||||
@@ -148,6 +154,7 @@ public class ActorCondition extends JSONElement {
|
|||||||
@Override
|
@Override
|
||||||
public void parse(Map aCondJson) {
|
public void parse(Map aCondJson) {
|
||||||
|
|
||||||
|
if (aCondJson.get("description") != null) this.description = (String) aCondJson.get("description");
|
||||||
if (aCondJson.get("category") != null) this.category = ACCategory.valueOf((String) aCondJson.get("category"));
|
if (aCondJson.get("category") != null) this.category = ACCategory.valueOf((String) aCondJson.get("category"));
|
||||||
this.positive = JSONElement.getInteger((Number) aCondJson.get("isPositive"));
|
this.positive = JSONElement.getInteger((Number) aCondJson.get("isPositive"));
|
||||||
Map abilityEffect = (Map) aCondJson.get("abilityEffect");
|
Map abilityEffect = (Map) aCondJson.get("abilityEffect");
|
||||||
@@ -180,7 +187,14 @@ public class ActorCondition extends JSONElement {
|
|||||||
this.round_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map) roundEffect.get("increaseCurrentAP")).get("max")));
|
this.round_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map) roundEffect.get("increaseCurrentAP")).get("max")));
|
||||||
this.round_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map) roundEffect.get("increaseCurrentAP")).get("min")));
|
this.round_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map) roundEffect.get("increaseCurrentAP")).get("min")));
|
||||||
}
|
}
|
||||||
this.round_effect.visual_effect = (String) roundEffect.get("visualEffectID");
|
String vfx = (String) roundEffect.get("visualEffectID");
|
||||||
|
this.round_effect.visual_effect = null;
|
||||||
|
if (vfx != null) {
|
||||||
|
try {
|
||||||
|
this.round_effect.visual_effect = VisualEffectID.valueOf(vfx);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Map fullRoundEffect = (Map) aCondJson.get("fullRoundEffect");
|
Map fullRoundEffect = (Map) aCondJson.get("fullRoundEffect");
|
||||||
if (fullRoundEffect != null) {
|
if (fullRoundEffect != null) {
|
||||||
@@ -193,7 +207,14 @@ public class ActorCondition extends JSONElement {
|
|||||||
this.full_round_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map) fullRoundEffect.get("increaseCurrentAP")).get("max")));
|
this.full_round_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map) fullRoundEffect.get("increaseCurrentAP")).get("max")));
|
||||||
this.full_round_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map) fullRoundEffect.get("increaseCurrentAP")).get("min")));
|
this.full_round_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map) fullRoundEffect.get("increaseCurrentAP")).get("min")));
|
||||||
}
|
}
|
||||||
this.full_round_effect.visual_effect = (String) fullRoundEffect.get("visualEffectID");
|
String vfx = (String) fullRoundEffect.get("visualEffectID");
|
||||||
|
this.full_round_effect.visual_effect = null;
|
||||||
|
if (vfx != null) {
|
||||||
|
try {
|
||||||
|
this.full_round_effect.visual_effect = VisualEffectID.valueOf(vfx);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.state = State.parsed;
|
this.state = State.parsed;
|
||||||
|
|
||||||
@@ -201,19 +222,20 @@ public class ActorCondition extends JSONElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void link() {
|
public void link() {
|
||||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
if (shouldSkipParseOrLink()) {
|
||||||
//This type of state is unrelated to parsing/linking.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.state == State.init) {
|
|
||||||
//Not parsed yet.
|
|
||||||
this.parse();
|
|
||||||
} else if (this.state == State.linked) {
|
|
||||||
//Already linked.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ensureParseIfNeeded();
|
||||||
if (this.icon_id != null) {
|
if (this.icon_id != null) {
|
||||||
String spritesheetId = this.icon_id.split(":")[0];
|
String spritesheetId = this.icon_id.split(":")[0];
|
||||||
|
if (getProject().getSpritesheet(spritesheetId) == null) {
|
||||||
|
System.out.println("Actor Condition");
|
||||||
|
System.out.println(this.id);
|
||||||
|
System.out.println("failed to load spritesheet:");
|
||||||
|
System.out.println(spritesheetId);
|
||||||
|
System.out.println("while creating backlink for icon_id:");
|
||||||
|
System.out.println(this.icon_id);
|
||||||
|
}
|
||||||
getProject().getSpritesheet(spritesheetId).addBacklink(this);
|
getProject().getSpritesheet(spritesheetId).addBacklink(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,6 +264,7 @@ public class ActorCondition extends JSONElement {
|
|||||||
clone.state = this.state;
|
clone.state = this.state;
|
||||||
clone.id = this.id;
|
clone.id = this.id;
|
||||||
clone.display_name = this.display_name;
|
clone.display_name = this.display_name;
|
||||||
|
clone.description = this.description;
|
||||||
clone.icon_id = this.icon_id;
|
clone.icon_id = this.icon_id;
|
||||||
clone.category = this.category;
|
clone.category = this.category;
|
||||||
clone.positive = this.positive;
|
clone.positive = this.positive;
|
||||||
@@ -270,12 +293,14 @@ public class ActorCondition extends JSONElement {
|
|||||||
jsonAC.put("id", this.id);
|
jsonAC.put("id", this.id);
|
||||||
if (this.icon_id != null) jsonAC.put("iconID", this.icon_id);
|
if (this.icon_id != null) jsonAC.put("iconID", this.icon_id);
|
||||||
if (this.display_name != null) jsonAC.put("name", this.display_name);
|
if (this.display_name != null) jsonAC.put("name", this.display_name);
|
||||||
|
if (this.description != null) jsonAC.put("description", this.description);
|
||||||
if (this.category != null) jsonAC.put("category", this.category.toString());
|
if (this.category != null) jsonAC.put("category", this.category.toString());
|
||||||
if (this.positive != null && this.positive == 1) jsonAC.put("isPositive", this.positive);
|
if (this.positive != null && this.positive == 1) jsonAC.put("isPositive", this.positive);
|
||||||
if (this.stacking != null && this.stacking == 1) jsonAC.put("isStacking", this.stacking);
|
if (this.stacking != null && this.stacking == 1) jsonAC.put("isStacking", this.stacking);
|
||||||
if (this.round_effect != null) {
|
if (this.round_effect != null) {
|
||||||
Map jsonRound = new LinkedHashMap();
|
Map jsonRound = new LinkedHashMap();
|
||||||
if (this.round_effect.visual_effect != null) jsonRound.put("visualEffectID", this.round_effect.visual_effect);
|
if (this.round_effect.visual_effect != null)
|
||||||
|
jsonRound.put("visualEffectID", this.round_effect.visual_effect.toString());
|
||||||
if (this.round_effect.hp_boost_min != null || this.round_effect.hp_boost_max != null) {
|
if (this.round_effect.hp_boost_min != null || this.round_effect.hp_boost_max != null) {
|
||||||
Map jsonHP = new LinkedHashMap();
|
Map jsonHP = new LinkedHashMap();
|
||||||
if (this.round_effect.hp_boost_min != null) jsonHP.put("min", this.round_effect.hp_boost_min);
|
if (this.round_effect.hp_boost_min != null) jsonHP.put("min", this.round_effect.hp_boost_min);
|
||||||
@@ -296,7 +321,8 @@ public class ActorCondition extends JSONElement {
|
|||||||
}
|
}
|
||||||
if (this.full_round_effect != null) {
|
if (this.full_round_effect != null) {
|
||||||
Map jsonFullRound = new LinkedHashMap();
|
Map jsonFullRound = new LinkedHashMap();
|
||||||
if (this.full_round_effect.visual_effect != null) jsonFullRound.put("visualEffectID", this.full_round_effect.visual_effect);
|
if (this.full_round_effect.visual_effect != null)
|
||||||
|
jsonFullRound.put("visualEffectID", this.full_round_effect.visual_effect.toString());
|
||||||
if (this.full_round_effect.hp_boost_min != null || this.full_round_effect.hp_boost_max != null) {
|
if (this.full_round_effect.hp_boost_min != null || this.full_round_effect.hp_boost_max != null) {
|
||||||
Map jsonHP = new LinkedHashMap();
|
Map jsonHP = new LinkedHashMap();
|
||||||
if (this.full_round_effect.hp_boost_min != null) jsonHP.put("min", this.full_round_effect.hp_boost_min);
|
if (this.full_round_effect.hp_boost_min != null) jsonHP.put("min", this.full_round_effect.hp_boost_min);
|
||||||
@@ -317,24 +343,36 @@ public class ActorCondition extends JSONElement {
|
|||||||
}
|
}
|
||||||
if (this.constant_ability_effect != null) {
|
if (this.constant_ability_effect != null) {
|
||||||
Map jsonAbility = new LinkedHashMap();
|
Map jsonAbility = new LinkedHashMap();
|
||||||
if (this.constant_ability_effect.increase_attack_chance != null) jsonAbility.put("increaseAttackChance", this.constant_ability_effect.increase_attack_chance);
|
if (this.constant_ability_effect.increase_attack_chance != null)
|
||||||
|
jsonAbility.put("increaseAttackChance", this.constant_ability_effect.increase_attack_chance);
|
||||||
if (this.constant_ability_effect.increase_damage_min != null || this.constant_ability_effect.increase_damage_max != null) {
|
if (this.constant_ability_effect.increase_damage_min != null || this.constant_ability_effect.increase_damage_max != null) {
|
||||||
Map jsonAD = new LinkedHashMap();
|
Map jsonAD = new LinkedHashMap();
|
||||||
if (this.constant_ability_effect.increase_damage_min != null) jsonAD.put("min", this.constant_ability_effect.increase_damage_min);
|
if (this.constant_ability_effect.increase_damage_min != null)
|
||||||
|
jsonAD.put("min", this.constant_ability_effect.increase_damage_min);
|
||||||
else jsonAD.put("min", 0);
|
else jsonAD.put("min", 0);
|
||||||
if (this.constant_ability_effect.increase_damage_max != null) jsonAD.put("max", this.constant_ability_effect.increase_damage_max);
|
if (this.constant_ability_effect.increase_damage_max != null)
|
||||||
|
jsonAD.put("max", this.constant_ability_effect.increase_damage_max);
|
||||||
else jsonAD.put("max", 0);
|
else jsonAD.put("max", 0);
|
||||||
jsonAbility.put("increaseAttackDamage", jsonAD);
|
jsonAbility.put("increaseAttackDamage", jsonAD);
|
||||||
}
|
}
|
||||||
if (this.constant_ability_effect.max_hp_boost != null) jsonAbility.put("increaseMaxHP", this.constant_ability_effect.max_hp_boost);
|
if (this.constant_ability_effect.max_hp_boost != null)
|
||||||
if (this.constant_ability_effect.max_ap_boost != null) jsonAbility.put("increaseMaxAP", this.constant_ability_effect.max_ap_boost);
|
jsonAbility.put("increaseMaxHP", this.constant_ability_effect.max_hp_boost);
|
||||||
if (this.constant_ability_effect.increase_move_cost != null) jsonAbility.put("increaseMoveCost", this.constant_ability_effect.increase_move_cost);
|
if (this.constant_ability_effect.max_ap_boost != null)
|
||||||
if (this.constant_ability_effect.increase_use_cost != null) jsonAbility.put("increaseUseItemCost", this.constant_ability_effect.increase_use_cost);
|
jsonAbility.put("increaseMaxAP", this.constant_ability_effect.max_ap_boost);
|
||||||
if (this.constant_ability_effect.increase_reequip_cost != null) jsonAbility.put("increaseReequipCost", this.constant_ability_effect.increase_reequip_cost);
|
if (this.constant_ability_effect.increase_move_cost != null)
|
||||||
if (this.constant_ability_effect.increase_attack_cost != null) jsonAbility.put("increaseAttackCost", this.constant_ability_effect.increase_attack_cost);
|
jsonAbility.put("increaseMoveCost", this.constant_ability_effect.increase_move_cost);
|
||||||
if (this.constant_ability_effect.increase_critical_skill != null) jsonAbility.put("increaseCriticalSkill", this.constant_ability_effect.increase_critical_skill);
|
if (this.constant_ability_effect.increase_use_cost != null)
|
||||||
if (this.constant_ability_effect.increase_block_chance != null) jsonAbility.put("increaseBlockChance", this.constant_ability_effect.increase_block_chance);
|
jsonAbility.put("increaseUseItemCost", this.constant_ability_effect.increase_use_cost);
|
||||||
if (this.constant_ability_effect.increase_damage_resistance != null) jsonAbility.put("increaseDamageResistance", this.constant_ability_effect.increase_damage_resistance);
|
if (this.constant_ability_effect.increase_reequip_cost != null)
|
||||||
|
jsonAbility.put("increaseReequipCost", this.constant_ability_effect.increase_reequip_cost);
|
||||||
|
if (this.constant_ability_effect.increase_attack_cost != null)
|
||||||
|
jsonAbility.put("increaseAttackCost", this.constant_ability_effect.increase_attack_cost);
|
||||||
|
if (this.constant_ability_effect.increase_critical_skill != null)
|
||||||
|
jsonAbility.put("increaseCriticalSkill", this.constant_ability_effect.increase_critical_skill);
|
||||||
|
if (this.constant_ability_effect.increase_block_chance != null)
|
||||||
|
jsonAbility.put("increaseBlockChance", this.constant_ability_effect.increase_block_chance);
|
||||||
|
if (this.constant_ability_effect.increase_damage_resistance != null)
|
||||||
|
jsonAbility.put("increaseDamageResistance", this.constant_ability_effect.increase_damage_resistance);
|
||||||
jsonAC.put("abilityEffect", jsonAbility);
|
jsonAC.put("abilityEffect", jsonAbility);
|
||||||
}
|
}
|
||||||
return jsonAC;
|
return jsonAC;
|
||||||
|
|||||||
384
src/com/gpl/rpg/atcontentstudio/model/gamedata/Common.java
Normal file
@@ -0,0 +1,384 @@
|
|||||||
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public final class Common {
|
||||||
|
|
||||||
|
public static <T extends ActorConditionEffect> void actorConditionElementChanged(List<T> list, GameDataElement oldOne, GameDataElement newOne, GameDataElement backlink) {
|
||||||
|
if (list != null) {
|
||||||
|
for (T c : list) {
|
||||||
|
if (c.condition == oldOne) {
|
||||||
|
oldOne.removeBacklink(backlink);
|
||||||
|
c.condition = (ActorCondition) newOne;
|
||||||
|
if (newOne != null) newOne.addBacklink(backlink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//region link common stuff
|
||||||
|
public static void linkConditions(List<? extends ActorConditionEffect> conditions, Project proj, GameDataElement backlink) {
|
||||||
|
if (conditions != null) {
|
||||||
|
for (ActorConditionEffect ce : conditions) {
|
||||||
|
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
||||||
|
if (ce.condition != null) ce.condition.addBacklink(backlink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void linkEffects(HitEffect effect, Project proj, GameDataElement backlink) {
|
||||||
|
linkEffects((DeathEffect) effect, proj, backlink);
|
||||||
|
if (effect != null) {
|
||||||
|
linkConditions(effect.conditions_target, proj, backlink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void linkEffects(DeathEffect effect, Project proj, GameDataElement backlink) {
|
||||||
|
if (effect != null) {
|
||||||
|
linkConditions(effect.conditions_source, proj, backlink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void linkIcon(Project proj, String iconId, GameDataElement backlink) {
|
||||||
|
if (iconId != null) {
|
||||||
|
String spritesheetId = iconId.split(":")[0];
|
||||||
|
if (proj.getSpritesheet(spritesheetId) == null) {
|
||||||
|
Notification.addError("Error Spritesheet " + spritesheetId + ". has no backlink. (" + iconId + ")");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
proj.getSpritesheet(spritesheetId).addBacklink(backlink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region write common stuff
|
||||||
|
public static void writeMinMaxToMap(Map parent, Integer min, Integer max, int defaultValue) {
|
||||||
|
if (min != null || max != null) {
|
||||||
|
if (min != null)
|
||||||
|
parent.put("min", min);
|
||||||
|
else parent.put("min", defaultValue);
|
||||||
|
if (max != null)
|
||||||
|
parent.put("max", max);
|
||||||
|
else parent.put("max", defaultValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeMinMaxToMap(Map parent, String key, Integer min, Integer max, int defaultValue) {
|
||||||
|
if (min != null || max != null) {
|
||||||
|
Map minMaxMap = new LinkedHashMap();
|
||||||
|
parent.put(key, minMaxMap);
|
||||||
|
writeMinMaxToMap(minMaxMap, min, max, defaultValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeDescriptionToMap(Map parent, String description) {
|
||||||
|
if (description != null) parent.put("description", description);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeIconToMap(Map parent, String icon_id) {
|
||||||
|
if (icon_id != null) parent.put("iconID", icon_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeHitReceivedEffectToMap(Map parent, HitReceivedEffect effect) {
|
||||||
|
if (effect != null) {
|
||||||
|
writeHitEffectToMap(parent, effect);
|
||||||
|
writeBasicEffectObjectToMap(effect.target, parent, "increaseAttackerCurrentHP", "increaseAttackerCurrentAP");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeHitReceivedEffectToMap(Map parent, HitReceivedEffect effect, String key) {
|
||||||
|
if (effect != null) {
|
||||||
|
Map effectJson = new LinkedHashMap();
|
||||||
|
parent.put(key, effectJson);
|
||||||
|
writeHitReceivedEffectToMap(effectJson, effect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeHitEffectToMap(Map parent, HitEffect effect) {
|
||||||
|
if (effect != null) {
|
||||||
|
writeDeathEffectToMap(parent, effect);
|
||||||
|
writeTimedActorConditionEffectObjectToMap(effect.conditions_target, parent, "conditionsTarget");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeHitEffectToMap(Map parent, HitEffect effect, String key) {
|
||||||
|
if (effect != null) {
|
||||||
|
Map effectJson = new LinkedHashMap();
|
||||||
|
parent.put(key, effectJson);
|
||||||
|
writeHitEffectToMap(effectJson, effect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeDeathEffectToMap(Map parent, DeathEffect effect) {
|
||||||
|
writeBasicEffectObjectToMap(effect, parent, "increaseCurrentHP", "increaseCurrentAP");
|
||||||
|
writeTimedActorConditionEffectObjectToMap(effect.conditions_source, parent, "conditionsSource");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeDeathEffectToMap(Map parent, DeathEffect effect, String key) {
|
||||||
|
if (effect != null) {
|
||||||
|
Map effectJson = new LinkedHashMap();
|
||||||
|
parent.put(key, effectJson);
|
||||||
|
writeDeathEffectToMap(effectJson, effect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeBasicEffectObjectToMap(BasicEffect effect, Map parent, String keyHP, String keyAP) {
|
||||||
|
writeMinMaxToMap(parent, keyHP, effect.hp_boost_min, effect.hp_boost_max, 0);
|
||||||
|
|
||||||
|
writeMinMaxToMap(parent, keyAP, effect.ap_boost_min, effect.ap_boost_max, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeTimedActorConditionEffectObjectToMap(List<TimedActorConditionEffect> list, Map parent, String key) {
|
||||||
|
if (list != null) {
|
||||||
|
List conditionsSourceJson = new ArrayList();
|
||||||
|
parent.put(key, conditionsSourceJson);
|
||||||
|
for (TimedActorConditionEffect condition : list) {
|
||||||
|
Map conditionJson = new LinkedHashMap();
|
||||||
|
conditionsSourceJson.add(conditionJson);
|
||||||
|
writeTimedConditionEffectToMap(condition, conditionJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeConditionEffectToMap(ActorConditionEffect condition, Map parent) {
|
||||||
|
if (condition.condition != null) {
|
||||||
|
parent.put("condition", condition.condition.id);
|
||||||
|
} else if (condition.condition_id != null) {
|
||||||
|
parent.put("condition", condition.condition_id);
|
||||||
|
}
|
||||||
|
if (condition.magnitude != null) {
|
||||||
|
parent.put("magnitude", condition.magnitude);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeTimedConditionEffectToMap(TimedActorConditionEffect condition, Map parent) {
|
||||||
|
writeConditionEffectToMap(condition, parent);
|
||||||
|
if (condition.duration != null) {
|
||||||
|
parent.put("duration", condition.duration);
|
||||||
|
}
|
||||||
|
if (condition.chance != null) {
|
||||||
|
parent.put("chance", JSONElement.printJsonChance(condition.chance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
public static class TimedActorConditionEffect extends ActorConditionEffect {
|
||||||
|
//Available from parsed state
|
||||||
|
public Integer duration = null;
|
||||||
|
public Double chance = null;
|
||||||
|
|
||||||
|
public TimedActorConditionEffect createClone() {
|
||||||
|
TimedActorConditionEffect cclone = new TimedActorConditionEffect();
|
||||||
|
cclone.magnitude = this.magnitude;
|
||||||
|
cclone.condition_id = this.condition_id;
|
||||||
|
cclone.condition = this.condition;
|
||||||
|
cclone.chance = this.chance;
|
||||||
|
cclone.duration = this.duration;
|
||||||
|
return cclone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInfinite() {
|
||||||
|
return duration != null && duration.equals(ActorCondition.DURATION_FOREVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isImmunity() {
|
||||||
|
return (super.isClear()) && (duration != null && duration > ActorCondition.DURATION_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isClear() {
|
||||||
|
return (super.isClear()) && (duration == null || duration.equals(ActorCondition.DURATION_NONE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ActorConditionEffect {
|
||||||
|
//Available from parsed state
|
||||||
|
public Integer magnitude = null;
|
||||||
|
public String condition_id = null;
|
||||||
|
|
||||||
|
//Available from linked state
|
||||||
|
public ActorCondition condition = null;
|
||||||
|
|
||||||
|
public boolean isClear() {
|
||||||
|
return magnitude == null || magnitude.equals(ActorCondition.MAGNITUDE_CLEAR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static ArrayList<TimedActorConditionEffect> parseTimedConditionEffects(List conditionsSourceJson) {
|
||||||
|
ArrayList<TimedActorConditionEffect> conditions_source;
|
||||||
|
if (conditionsSourceJson != null && !conditionsSourceJson.isEmpty()) {
|
||||||
|
conditions_source = new ArrayList<>();
|
||||||
|
for (Object conditionJsonObj : conditionsSourceJson) {
|
||||||
|
Map conditionJson = (Map) conditionJsonObj;
|
||||||
|
TimedActorConditionEffect condition = new TimedActorConditionEffect();
|
||||||
|
readConditionEffect(condition, conditionJson);
|
||||||
|
condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration"));
|
||||||
|
if (conditionJson.get("chance") != null)
|
||||||
|
condition.chance = JSONElement.parseChance(conditionJson.get("chance").toString());
|
||||||
|
conditions_source.add(condition);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
conditions_source = null;
|
||||||
|
}
|
||||||
|
return conditions_source;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private static void readConditionEffect(ActorConditionEffect condition, Map conditionJson) {
|
||||||
|
condition.condition_id = (String) conditionJson.get("condition");
|
||||||
|
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static Common.DeathEffect parseDeathEffect(Map killEffect) {
|
||||||
|
Common.DeathEffect kill_effect = new Common.DeathEffect();
|
||||||
|
readDeathEffect(killEffect, kill_effect);
|
||||||
|
return kill_effect;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static HitEffect parseHitEffect(Map hitEffect) {
|
||||||
|
Common.HitEffect hit_effect = new Common.HitEffect();
|
||||||
|
readHitEffect(hitEffect, hit_effect);
|
||||||
|
return hit_effect;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static HitReceivedEffect parseHitReceivedEffect(Map hitReceivedEffect) {
|
||||||
|
HitReceivedEffect hit_received_effect = new Common.HitReceivedEffect();
|
||||||
|
readHitEffect(hitReceivedEffect, hit_received_effect);
|
||||||
|
if (hitReceivedEffect.get("increaseAttackerCurrentHP") != null) {
|
||||||
|
hit_received_effect.target.hp_boost_max = JSONElement.getInteger((Number) (((Map) hitReceivedEffect.get("increaseAttackerCurrentHP")).get("max")));
|
||||||
|
hit_received_effect.target.hp_boost_min = JSONElement.getInteger((Number) (((Map) hitReceivedEffect.get("increaseAttackerCurrentHP")).get("min")));
|
||||||
|
}
|
||||||
|
if (hitReceivedEffect.get("increaseAttackerCurrentAP") != null) {
|
||||||
|
hit_received_effect.target.ap_boost_max = JSONElement.getInteger((Number) (((Map) hitReceivedEffect.get("increaseAttackerCurrentAP")).get("max")));
|
||||||
|
hit_received_effect.target.ap_boost_min = JSONElement.getInteger((Number) (((Map) hitReceivedEffect.get("increaseAttackerCurrentAP")).get("min")));
|
||||||
|
}
|
||||||
|
return hit_received_effect;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private static void readDeathEffect(Map killEffect, DeathEffect kill_effect) {
|
||||||
|
if (killEffect.get("increaseCurrentHP") != null) {
|
||||||
|
kill_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map) killEffect.get("increaseCurrentHP")).get("min")));
|
||||||
|
kill_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map) killEffect.get("increaseCurrentHP")).get("max")));
|
||||||
|
}
|
||||||
|
if (killEffect.get("increaseCurrentAP") != null) {
|
||||||
|
kill_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map) killEffect.get("increaseCurrentAP")).get("min")));
|
||||||
|
kill_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map) killEffect.get("increaseCurrentAP")).get("max")));
|
||||||
|
}
|
||||||
|
List conditionsSourceJson = (List) killEffect.get("conditionsSource");
|
||||||
|
kill_effect.conditions_source = parseTimedConditionEffects(conditionsSourceJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private static void readHitEffect(Map hitEffect, HitEffect hit_effect) {
|
||||||
|
readDeathEffect(hitEffect, hit_effect);
|
||||||
|
List conditionsTargetJson = (List) hitEffect.get("conditionsTarget");
|
||||||
|
hit_effect.conditions_target = parseTimedConditionEffects(conditionsTargetJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BasicEffect {
|
||||||
|
public Integer hp_boost_min = null;
|
||||||
|
public Integer hp_boost_max = null;
|
||||||
|
public Integer ap_boost_min = null;
|
||||||
|
public Integer ap_boost_max = null;
|
||||||
|
|
||||||
|
public boolean isNull() {
|
||||||
|
if (ap_boost_min != null) return false;
|
||||||
|
if (ap_boost_max != null) return false;
|
||||||
|
if (hp_boost_min != null) return false;
|
||||||
|
if (hp_boost_max != null) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DeathEffect extends BasicEffect {
|
||||||
|
//Available from parsed state
|
||||||
|
public List<TimedActorConditionEffect> conditions_source = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNull() {
|
||||||
|
if (!super.isNull()) return false;
|
||||||
|
if (conditions_source != null) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class HitEffect extends DeathEffect {
|
||||||
|
//Available from parsed state
|
||||||
|
public List<TimedActorConditionEffect> conditions_target = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNull() {
|
||||||
|
if (!super.isNull()) return false;
|
||||||
|
if (conditions_target != null) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class HitReceivedEffect extends Common.HitEffect {
|
||||||
|
//Available from parsed state
|
||||||
|
public BasicEffect target = new BasicEffect();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNull() {
|
||||||
|
if (!super.isNull()) return false;
|
||||||
|
if (!target.isNull()) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void copyDeathEffectValues(Common.DeathEffect target, Common.DeathEffect source, GameDataElement backlink) {
|
||||||
|
copyEffectValues(target, source);
|
||||||
|
if (source.conditions_source != null) {
|
||||||
|
target.conditions_source = new ArrayList<>();
|
||||||
|
for (TimedActorConditionEffect c : source.conditions_source) {
|
||||||
|
TimedActorConditionEffect cclone = c.createClone();
|
||||||
|
if (cclone.condition != null) {
|
||||||
|
cclone.condition.addBacklink(backlink);
|
||||||
|
}
|
||||||
|
target.conditions_source.add(cclone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void copyEffectValues(BasicEffect target, BasicEffect source) {
|
||||||
|
target.ap_boost_max = source.ap_boost_max;
|
||||||
|
target.ap_boost_min = source.ap_boost_min;
|
||||||
|
target.hp_boost_max = source.hp_boost_max;
|
||||||
|
target.hp_boost_min = source.hp_boost_min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copyHitEffectValues(Common.HitEffect target, Common.HitEffect source, GameDataElement backlink) {
|
||||||
|
copyDeathEffectValues(target, source, backlink);
|
||||||
|
if (source.conditions_target != null) {
|
||||||
|
target.conditions_target = new ArrayList<>();
|
||||||
|
for (TimedActorConditionEffect c : source.conditions_target) {
|
||||||
|
TimedActorConditionEffect cclone = c.createClone();
|
||||||
|
if (cclone.condition != null) {
|
||||||
|
cclone.condition.addBacklink(backlink);
|
||||||
|
}
|
||||||
|
target.conditions_target.add(cclone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copyHitReceivedEffectValues(Common.HitReceivedEffect target, Common.HitReceivedEffect source, GameDataElement backlink) {
|
||||||
|
copyHitEffectValues(target, source, backlink);
|
||||||
|
copyEffectValues(target.target, source.target);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,19 +1,5 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||||
@@ -21,6 +7,16 @@ import com.gpl.rpg.atcontentstudio.model.Project;
|
|||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement.RequirementType;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement.RequirementType;
|
||||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
public class Dialogue extends JSONElement {
|
public class Dialogue extends JSONElement {
|
||||||
@@ -54,10 +50,13 @@ public class Dialogue extends JSONElement {
|
|||||||
|
|
||||||
public enum RewardType {
|
public enum RewardType {
|
||||||
questProgress,
|
questProgress,
|
||||||
|
removeQuestProgress,
|
||||||
dropList,
|
dropList,
|
||||||
skillIncrease,
|
skillIncrease,
|
||||||
actorCondition,
|
actorCondition,
|
||||||
|
actorConditionImmunity,
|
||||||
alignmentChange,
|
alignmentChange,
|
||||||
|
alignmentSet,
|
||||||
giveItem,
|
giveItem,
|
||||||
createTimer,
|
createTimer,
|
||||||
spawnAll,
|
spawnAll,
|
||||||
@@ -65,7 +64,8 @@ public class Dialogue extends JSONElement {
|
|||||||
deactivateSpawnArea,
|
deactivateSpawnArea,
|
||||||
activateMapObjectGroup,
|
activateMapObjectGroup,
|
||||||
deactivateMapObjectGroup,
|
deactivateMapObjectGroup,
|
||||||
changeMapFilter
|
changeMapFilter,
|
||||||
|
mapchange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,10 +170,13 @@ public class Dialogue extends JSONElement {
|
|||||||
Requirement requirement = new Requirement();
|
Requirement requirement = new Requirement();
|
||||||
requirement.jsonFile = this.jsonFile;
|
requirement.jsonFile = this.jsonFile;
|
||||||
requirement.parent = this;
|
requirement.parent = this;
|
||||||
if (requirementJson.get("requireType") != null) requirement.type = RequirementType.valueOf((String) requirementJson.get("requireType"));
|
if (requirementJson.get("requireType") != null)
|
||||||
|
requirement.type = RequirementType.valueOf((String) requirementJson.get("requireType"));
|
||||||
requirement.required_obj_id = (String) requirementJson.get("requireID");
|
requirement.required_obj_id = (String) requirementJson.get("requireID");
|
||||||
if (requirementJson.get("value") != null) requirement.required_value = JSONElement.getInteger(Integer.parseInt(requirementJson.get("value").toString()));
|
if (requirementJson.get("value") != null)
|
||||||
if (requirementJson.get("negate") != null) requirement.negated = (Boolean) requirementJson.get("negate");
|
requirement.required_value = JSONElement.getInteger(Integer.parseInt(requirementJson.get("value").toString()));
|
||||||
|
if (requirementJson.get("negate") != null)
|
||||||
|
requirement.negated = (Boolean) requirementJson.get("negate");
|
||||||
requirement.state = State.parsed;
|
requirement.state = State.parsed;
|
||||||
reply.requirements.add(requirement);
|
reply.requirements.add(requirement);
|
||||||
}
|
}
|
||||||
@@ -187,9 +190,11 @@ public class Dialogue extends JSONElement {
|
|||||||
for (Object rewardJsonObj : rewardsJson) {
|
for (Object rewardJsonObj : rewardsJson) {
|
||||||
Map rewardJson = (Map) rewardJsonObj;
|
Map rewardJson = (Map) rewardJsonObj;
|
||||||
Reward reward = new Reward();
|
Reward reward = new Reward();
|
||||||
if (rewardJson.get("rewardType") != null) reward.type = Reward.RewardType.valueOf((String) rewardJson.get("rewardType"));
|
if (rewardJson.get("rewardType") != null)
|
||||||
|
reward.type = Reward.RewardType.valueOf((String) rewardJson.get("rewardType"));
|
||||||
if (rewardJson.get("rewardID") != null) reward.reward_obj_id = (String) rewardJson.get("rewardID");
|
if (rewardJson.get("rewardID") != null) reward.reward_obj_id = (String) rewardJson.get("rewardID");
|
||||||
if (rewardJson.get("value") != null) reward.reward_value = JSONElement.getInteger((Number) rewardJson.get("value"));
|
if (rewardJson.get("value") != null)
|
||||||
|
reward.reward_value = JSONElement.getInteger((Number) rewardJson.get("value"));
|
||||||
if (rewardJson.get("mapName") != null) reward.map_name = (String) rewardJson.get("mapName");
|
if (rewardJson.get("mapName") != null) reward.map_name = (String) rewardJson.get("mapName");
|
||||||
this.rewards.add(reward);
|
this.rewards.add(reward);
|
||||||
}
|
}
|
||||||
@@ -198,21 +203,12 @@ public class Dialogue extends JSONElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void link() {
|
public void link() {
|
||||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
if (shouldSkipParseOrLink()) {
|
||||||
//This type of state is unrelated to parsing/linking.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.state == State.init) {
|
|
||||||
//Not parsed yet.
|
|
||||||
this.parse();
|
|
||||||
} else if (this.state == State.linked) {
|
|
||||||
//Already linked.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ensureParseIfNeeded();
|
||||||
Project proj = getProject();
|
Project proj = getProject();
|
||||||
if (proj == null) {
|
if (proj == null) {
|
||||||
Notification.addError("Error linking dialogue " + id + ". No parent project found.");
|
Notification.addError("Error linking dialogue " + id + ". No parent project found.");
|
||||||
@@ -246,12 +242,15 @@ public class Dialogue extends JSONElement {
|
|||||||
case removeSpawnArea:
|
case removeSpawnArea:
|
||||||
case deactivateSpawnArea:
|
case deactivateSpawnArea:
|
||||||
case changeMapFilter:
|
case changeMapFilter:
|
||||||
|
case mapchange:
|
||||||
reward.map = reward.map_name != null ? proj.getMap(reward.map_name) : null;
|
reward.map = reward.map_name != null ? proj.getMap(reward.map_name) : null;
|
||||||
break;
|
break;
|
||||||
case actorCondition:
|
case actorCondition:
|
||||||
|
case actorConditionImmunity:
|
||||||
reward.reward_obj = proj.getActorCondition(reward.reward_obj_id);
|
reward.reward_obj = proj.getActorCondition(reward.reward_obj_id);
|
||||||
break;
|
break;
|
||||||
case alignmentChange:
|
case alignmentChange:
|
||||||
|
case alignmentSet:
|
||||||
//Nothing to do (yet ?).
|
//Nothing to do (yet ?).
|
||||||
break;
|
break;
|
||||||
case createTimer:
|
case createTimer:
|
||||||
@@ -264,6 +263,7 @@ public class Dialogue extends JSONElement {
|
|||||||
reward.reward_obj = proj.getItem(reward.reward_obj_id);
|
reward.reward_obj = proj.getItem(reward.reward_obj_id);
|
||||||
break;
|
break;
|
||||||
case questProgress:
|
case questProgress:
|
||||||
|
case removeQuestProgress:
|
||||||
reward.reward_obj = proj.getQuest(reward.reward_obj_id);
|
reward.reward_obj = proj.getQuest(reward.reward_obj_id);
|
||||||
if (reward.reward_obj != null && reward.reward_value != null) {
|
if (reward.reward_obj != null && reward.reward_value != null) {
|
||||||
QuestStage stage = ((Quest) reward.reward_obj).getStage(reward.reward_value);
|
QuestStage stage = ((Quest) reward.reward_obj).getStage(reward.reward_value);
|
||||||
@@ -286,7 +286,6 @@ public class Dialogue extends JSONElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return DefaultIcons.getDialogueIcon();
|
return DefaultIcons.getDialogueIcon();
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
import java.awt.Image;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||||
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
@@ -10,15 +18,6 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
|
||||||
|
|
||||||
|
|
||||||
public class Droplist extends JSONElement {
|
public class Droplist extends JSONElement {
|
||||||
|
|
||||||
@@ -36,7 +35,7 @@ public class Droplist extends JSONElement {
|
|||||||
public static class DroppedItem {
|
public static class DroppedItem {
|
||||||
//Available from parsed state;
|
//Available from parsed state;
|
||||||
public String item_id = null;
|
public String item_id = null;
|
||||||
public Double chance = null;
|
public String chance = null;
|
||||||
public Integer quantity_min = null;
|
public Integer quantity_min = null;
|
||||||
public Integer quantity_max = null;
|
public Integer quantity_max = null;
|
||||||
|
|
||||||
@@ -114,7 +113,8 @@ public class Droplist extends JSONElement {
|
|||||||
Map droppedItemJson = (Map) droppedItemJsonObj;
|
Map droppedItemJson = (Map) droppedItemJsonObj;
|
||||||
DroppedItem droppedItem = new DroppedItem();
|
DroppedItem droppedItem = new DroppedItem();
|
||||||
droppedItem.item_id = (String) droppedItemJson.get("itemID");
|
droppedItem.item_id = (String) droppedItemJson.get("itemID");
|
||||||
if (droppedItemJson.get("chance") != null) droppedItem.chance = JSONElement.parseChance(droppedItemJson.get("chance").toString());
|
//if (droppedItemJson.get("chance") != null) droppedItem.chance = JSONElement.parseChance(droppedItemJson.get("chance").toString());
|
||||||
|
droppedItem.chance = (String) droppedItemJson.get("chance");
|
||||||
Map droppedItemQtyJson = (Map) droppedItemJson.get("quantity");
|
Map droppedItemQtyJson = (Map) droppedItemJson.get("quantity");
|
||||||
if (droppedItemQtyJson != null) {
|
if (droppedItemQtyJson != null) {
|
||||||
droppedItem.quantity_min = JSONElement.getInteger((Number) droppedItemQtyJson.get("min"));
|
droppedItem.quantity_min = JSONElement.getInteger((Number) droppedItemQtyJson.get("min"));
|
||||||
@@ -128,17 +128,10 @@ public class Droplist extends JSONElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void link() {
|
public void link() {
|
||||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
if (shouldSkipParseOrLink()) {
|
||||||
//This type of state is unrelated to parsing/linking.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.state == State.init) {
|
|
||||||
//Not parsed yet.
|
|
||||||
this.parse();
|
|
||||||
} else if (this.state == State.linked) {
|
|
||||||
//Already linked.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ensureParseIfNeeded();
|
||||||
Project proj = getProject();
|
Project proj = getProject();
|
||||||
if (proj == null) {
|
if (proj == null) {
|
||||||
Notification.addError("Error linking droplist " + id + ". No parent project found.");
|
Notification.addError("Error linking droplist " + id + ". No parent project found.");
|
||||||
@@ -154,7 +147,6 @@ public class Droplist extends JSONElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Image getImage() {
|
public static Image getImage() {
|
||||||
return DefaultIcons.getDroplistImage();
|
return DefaultIcons.getDroplistImage();
|
||||||
}
|
}
|
||||||
@@ -217,7 +209,8 @@ public class Droplist extends JSONElement {
|
|||||||
} else if (droppedItem.item_id != null) {
|
} else if (droppedItem.item_id != null) {
|
||||||
droppedItemJson.put("itemID", droppedItem.item_id);
|
droppedItemJson.put("itemID", droppedItem.item_id);
|
||||||
}
|
}
|
||||||
if (droppedItem.chance != null) droppedItemJson.put("chance", JSONElement.printJsonChance(droppedItem.chance));
|
//if (droppedItem.chance != null) droppedItemJson.put("chance", JSONElement.printJsonChance(droppedItem.chance));
|
||||||
|
if (droppedItem.chance != null) droppedItemJson.put("chance", droppedItem.chance);
|
||||||
if (droppedItem.quantity_min != null || droppedItem.quantity_max != null) {
|
if (droppedItem.quantity_min != null || droppedItem.quantity_max != null) {
|
||||||
Map quantityJson = new LinkedHashMap();
|
Map quantityJson = new LinkedHashMap();
|
||||||
droppedItemJson.put("quantity", quantityJson);
|
droppedItemJson.put("quantity", quantityJson);
|
||||||
|
|||||||
@@ -1,45 +1,115 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
import java.awt.Image;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
import java.io.File;
|
import com.gpl.rpg.atcontentstudio.model.*;
|
||||||
import java.io.FileWriter;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
import java.io.IOException;
|
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.json.simple.JSONArray;
|
public class GameDataCategory<E extends JSONElement> implements ProjectTreeNode {
|
||||||
|
//region Data
|
||||||
|
private final ArrayList<String> keyList = new ArrayList<>();
|
||||||
|
private final HashMap<String, E> dataMap = new HashMap<>();
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
//endregion
|
||||||
import com.gpl.rpg.atcontentstudio.io.JsonPrettyWriter;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
|
||||||
|
|
||||||
public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implements ProjectTreeNode, Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 5486008219704443733L;
|
|
||||||
|
|
||||||
public GameDataSet parent;
|
public GameDataSet parent;
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
public GameDataCategory(GameDataSet parent, String name) {
|
public GameDataCategory(GameDataSet parent, String name) {
|
||||||
super();
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//region Helpers
|
||||||
|
public E get(String key) {
|
||||||
|
return dataMap.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public E get(int index) {
|
||||||
|
String key = keyList.get(index);
|
||||||
|
return dataMap.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public E getIgnoreCase(String key) {
|
||||||
|
for (String k : keyList) {
|
||||||
|
if (k.equalsIgnoreCase(key)) {
|
||||||
|
return dataMap.get(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public E put(String key, E element) {
|
||||||
|
if (!dataMap.containsKey(key)) {
|
||||||
|
keyList.add(key);
|
||||||
|
}
|
||||||
|
return dataMap.put(key, element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(E quest) {
|
||||||
|
String key = quest.id;
|
||||||
|
put(key, quest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public E remove(String key) {
|
||||||
|
if (dataMap.containsKey(key)) {
|
||||||
|
keyList.remove(key);
|
||||||
|
}
|
||||||
|
return dataMap.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public E remove(int index) {
|
||||||
|
String key = keyList.get(index);
|
||||||
|
keyList.remove(index);
|
||||||
|
return dataMap.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeGeneric(JSONElement element){
|
||||||
|
return remove((E) element);
|
||||||
|
}
|
||||||
|
public boolean remove(E element) {
|
||||||
|
String key = element.id;
|
||||||
|
int index = getProject().getNodeIndex(element);
|
||||||
|
boolean result = false;
|
||||||
|
if (dataMap.containsKey(key)) {
|
||||||
|
keyList.remove(key);
|
||||||
|
dataMap.remove(key);
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
getProject().fireElementRemoved(element, index);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return dataMap.size();
|
||||||
|
}
|
||||||
|
public int indexOf(String key) {
|
||||||
|
return keyList.indexOf(key);
|
||||||
|
}
|
||||||
|
public int indexOf(E element) {
|
||||||
|
String key = element.id;
|
||||||
|
return keyList.indexOf(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<E> toList() {
|
||||||
|
ArrayList<E> list = new ArrayList<>();
|
||||||
|
for (String key : keyList) {
|
||||||
|
list.add(dataMap.get(key));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region copied implementation of ProjectTreeNode
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TreeNode getChildAt(int childIndex) {
|
public TreeNode getChildAt(int childIndex) {
|
||||||
return get(childIndex);
|
return get(childIndex);
|
||||||
@@ -57,7 +127,7 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIndex(TreeNode node) {
|
public int getIndex(TreeNode node) {
|
||||||
return indexOf(node);
|
return indexOf((E) node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,18 +142,21 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enumeration<E> children() {
|
public Enumeration<E> children() {
|
||||||
return Collections.enumeration(this);
|
return Collections.enumeration(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenAdded(List<ProjectTreeNode> path) {
|
public void childrenAdded(List<ProjectTreeNode> path) {
|
||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenAdded(path);
|
parent.childrenAdded(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenChanged(List<ProjectTreeNode> path) {
|
public void childrenChanged(List<ProjectTreeNode> path) {
|
||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenChanged(path);
|
parent.childrenChanged(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenRemoved(List<ProjectTreeNode> path) {
|
public void childrenRemoved(List<ProjectTreeNode> path) {
|
||||||
if (path.size() == 1 && this.getChildCount() == 1) {
|
if (path.size() == 1 && this.getChildCount() == 1) {
|
||||||
@@ -93,13 +166,15 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
|||||||
parent.childrenRemoved(path);
|
parent.childrenRemoved(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyCreated() {
|
public void notifyCreated() {
|
||||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
for (E node : this) {
|
for (E node : dataMap.values()) {
|
||||||
node.notifyCreated();
|
node.notifyCreated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDesc() {
|
public String getDesc() {
|
||||||
return (needsSaving() ? "*" : "") + this.name;
|
return (needsSaving() ? "*" : "") + this.name;
|
||||||
@@ -119,14 +194,17 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
|||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return getOpenIcon();
|
return getOpenIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getClosedIcon() {
|
public Image getClosedIcon() {
|
||||||
return DefaultIcons.getJsonClosedIcon();
|
return DefaultIcons.getJsonClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getLeafIcon() {
|
public Image getLeafIcon() {
|
||||||
return DefaultIcons.getJsonClosedIcon();
|
return DefaultIcons.getJsonClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getOpenIcon() {
|
public Image getOpenIcon() {
|
||||||
return DefaultIcons.getJsonOpenIcon();
|
return DefaultIcons.getJsonOpenIcon();
|
||||||
@@ -138,10 +216,15 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getDataType() {
|
public GameSource.Type getDataType() {
|
||||||
return parent.getDataType();
|
return parent.getDataType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return dataMap.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public void save(File jsonFile) {
|
public void save(File jsonFile) {
|
||||||
if (getDataType() != GameSource.Type.created && getDataType() != GameSource.Type.altered) {
|
if (getDataType() != GameSource.Type.created && getDataType() != GameSource.Type.altered) {
|
||||||
@@ -149,7 +232,7 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Map> dataToSave = new ArrayList<Map>();
|
List<Map> dataToSave = new ArrayList<Map>();
|
||||||
for (E element : this) {
|
for (E element : dataMap.values()) {
|
||||||
if (element.jsonFile.equals(jsonFile)) {
|
if (element.jsonFile.equals(jsonFile)) {
|
||||||
dataToSave.add(element.toJson());
|
dataToSave.add(element.toJson());
|
||||||
}
|
}
|
||||||
@@ -163,26 +246,13 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StringWriter writer = new JsonPrettyWriter();
|
|
||||||
try {
|
String toWrite = FileUtils.toJsonString(dataToSave);
|
||||||
JSONArray.writeJSONString(dataToSave, writer);
|
if(FileUtils.writeStringToFile(toWrite, jsonFile, "JSON file '"+jsonFile.getAbsolutePath()+"'")){
|
||||||
} catch (IOException e) {
|
for (E element : dataMap.values()) {
|
||||||
//Impossible with a StringWriter
|
|
||||||
}
|
|
||||||
String toWrite = writer.toString();
|
|
||||||
try {
|
|
||||||
FileWriter w = new FileWriter(jsonFile);
|
|
||||||
w.write(toWrite);
|
|
||||||
w.close();
|
|
||||||
for (E element : this) {
|
|
||||||
element.state = GameDataElement.State.saved;
|
element.state = GameDataElement.State.saved;
|
||||||
}
|
}
|
||||||
Notification.addSuccess("Json file "+jsonFile.getAbsolutePath()+" saved.");
|
|
||||||
} catch (IOException e) {
|
|
||||||
Notification.addError("Error while writing json file "+jsonFile.getAbsolutePath()+" : "+e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -191,7 +261,8 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
|||||||
GameDataCategory<? extends JSONElement> impactedCategory = null;
|
GameDataCategory<? extends JSONElement> impactedCategory = null;
|
||||||
String impactedFileName = fileName;
|
String impactedFileName = fileName;
|
||||||
Map<String, Integer> containedIds = new LinkedHashMap<String, Integer>();
|
Map<String, Integer> containedIds = new LinkedHashMap<String, Integer>();
|
||||||
for (JSONElement node : this) {
|
ArrayList<E> list = toList();
|
||||||
|
for (JSONElement node : list) {
|
||||||
if (node.getDataType() == GameSource.Type.created && getProject().baseContent.gameData.getGameDataElement(node.getClass(), node.id) != null) {
|
if (node.getDataType() == GameSource.Type.created && getProject().baseContent.gameData.getGameDataElement(node.getClass(), node.id) != null) {
|
||||||
if (getProject().alteredContent.gameData.getGameDataElement(node.getClass(), node.id) != null) {
|
if (getProject().alteredContent.gameData.getGameDataElement(node.getClass(), node.id) != null) {
|
||||||
events.add(new SaveEvent(SaveEvent.Type.moveToAltered, node, true, "Element ID matches one already present in the altered game content. Change this ID before saving."));
|
events.add(new SaveEvent(SaveEvent.Type.moveToAltered, node, true, "Element ID matches one already present in the altered game content. Change this ID before saving."));
|
||||||
@@ -220,13 +291,14 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
|||||||
for (String key : containedIds.keySet()) {
|
for (String key : containedIds.keySet()) {
|
||||||
if (containedIds.get(key) > 1) {
|
if (containedIds.get(key) > 1) {
|
||||||
E node = null;
|
E node = null;
|
||||||
for (E n : this) {
|
for (E n : list) {
|
||||||
if (key.equals(n.id)) {
|
if (key.equals(n.id)) {
|
||||||
node = n;
|
node = n;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
events.add(new SaveEvent(SaveEvent.Type.alsoSave, node, true, "There are "+containedIds.get(node.id)+" elements with this ID in this category. Change the conflicting IDs before saving."));
|
events.add(new SaveEvent(SaveEvent.Type.alsoSave, node, true,
|
||||||
|
"There are " + containedIds.get(node.id) + " elements with this ID in this category. Change the conflicting IDs before saving."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (checkImpactedCategory && impactedCategory != null) {
|
if (checkImpactedCategory && impactedCategory != null) {
|
||||||
@@ -235,19 +307,15 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
|||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove(E o) {
|
|
||||||
int index = getProject().getNodeIndex(o);
|
|
||||||
boolean result = super.remove(o);
|
|
||||||
getProject().fireElementRemoved(o, index);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean needsSaving() {
|
public boolean needsSaving() {
|
||||||
for (E node : this) {
|
for (E node : dataMap.values()) {
|
||||||
if (node.needsSaving()) return true;
|
if (node.needsSaving()) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,5 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
@@ -18,6 +9,14 @@ import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
|||||||
import com.gpl.rpg.atcontentstudio.model.SavedSlotCollection;
|
import com.gpl.rpg.atcontentstudio.model.SavedSlotCollection;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class GameDataSet implements ProjectTreeNode, Serializable {
|
public class GameDataSet implements ProjectTreeNode, Serializable {
|
||||||
|
|
||||||
@@ -68,7 +67,7 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
|||||||
items = new GameDataCategory<Item>(this, Item.getStaticDesc());
|
items = new GameDataCategory<Item>(this, Item.getStaticDesc());
|
||||||
itemCategories = new GameDataCategory<ItemCategory>(this, ItemCategory.getStaticDesc());
|
itemCategories = new GameDataCategory<ItemCategory>(this, ItemCategory.getStaticDesc());
|
||||||
npcs = new GameDataCategory<NPC>(this, NPC.getStaticDesc());
|
npcs = new GameDataCategory<NPC>(this, NPC.getStaticDesc());
|
||||||
quests = new GameDataCategory<Quest>(this, Quest.getStaticDesc());
|
quests = new GameDataCategory<>(this, Quest.getStaticDesc());
|
||||||
|
|
||||||
v.add(actorConditions);
|
v.add(actorConditions);
|
||||||
v.add(dialogues);
|
v.add(dialogues);
|
||||||
@@ -184,40 +183,49 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
|||||||
public Enumeration<ProjectTreeNode> children() {
|
public Enumeration<ProjectTreeNode> children() {
|
||||||
return v.getNonEmptyElements();
|
return v.getNonEmptyElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAllowsChildren() {
|
public boolean getAllowsChildren() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TreeNode getChildAt(int arg0) {
|
public TreeNode getChildAt(int arg0) {
|
||||||
return v.getNonEmptyElementAt(arg0);
|
return v.getNonEmptyElementAt(arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChildCount() {
|
public int getChildCount() {
|
||||||
return v.getNonEmptySize();
|
return v.getNonEmptySize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIndex(TreeNode arg0) {
|
public int getIndex(TreeNode arg0) {
|
||||||
return v.getNonEmptyIndexOf((ProjectTreeNode) arg0);
|
return v.getNonEmptyIndexOf((ProjectTreeNode) arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TreeNode getParent() {
|
public TreeNode getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLeaf() {
|
public boolean isLeaf() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenAdded(List<ProjectTreeNode> path) {
|
public void childrenAdded(List<ProjectTreeNode> path) {
|
||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenAdded(path);
|
parent.childrenAdded(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenChanged(List<ProjectTreeNode> path) {
|
public void childrenChanged(List<ProjectTreeNode> path) {
|
||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenChanged(path);
|
parent.childrenChanged(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenRemoved(List<ProjectTreeNode> path) {
|
public void childrenRemoved(List<ProjectTreeNode> path) {
|
||||||
if (path.size() == 1 && this.v.getNonEmptySize() == 1) {
|
if (path.size() == 1 && this.v.getNonEmptySize() == 1) {
|
||||||
@@ -227,6 +235,7 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
|||||||
parent.childrenRemoved(path);
|
parent.childrenRemoved(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyCreated() {
|
public void notifyCreated() {
|
||||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
@@ -234,6 +243,7 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
|||||||
node.notifyCreated();
|
node.notifyCreated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDesc() {
|
public String getDesc() {
|
||||||
return (needsSaving() ? "*" : "") + "JSON data";
|
return (needsSaving() ? "*" : "") + "JSON data";
|
||||||
@@ -246,82 +256,42 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
|||||||
|
|
||||||
public ActorCondition getActorCondition(String id) {
|
public ActorCondition getActorCondition(String id) {
|
||||||
if (actorConditions == null) return null;
|
if (actorConditions == null) return null;
|
||||||
for (ActorCondition gde : actorConditions) {
|
return actorConditions.get(id);
|
||||||
if (id.equals(gde.id)){
|
|
||||||
return gde;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dialogue getDialogue(String id) {
|
public Dialogue getDialogue(String id) {
|
||||||
if (dialogues == null) return null;
|
if (dialogues == null) return null;
|
||||||
for (Dialogue gde : dialogues) {
|
return dialogues.get(id);
|
||||||
if (id.equals(gde.id)){
|
|
||||||
return gde;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Droplist getDroplist(String id) {
|
public Droplist getDroplist(String id) {
|
||||||
if (droplists == null) return null;
|
if (droplists == null) return null;
|
||||||
for (Droplist gde : droplists) {
|
return droplists.get(id);
|
||||||
if (id.equals(gde.id)){
|
|
||||||
return gde;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item getItem(String id) {
|
public Item getItem(String id) {
|
||||||
if (items == null) return null;
|
if (items == null) return null;
|
||||||
for (Item gde : items) {
|
return items.get(id);
|
||||||
if (id.equals(gde.id)){
|
|
||||||
return gde;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemCategory getItemCategory(String id) {
|
public ItemCategory getItemCategory(String id) {
|
||||||
if (itemCategories == null) return null;
|
if (itemCategories == null) return null;
|
||||||
for (ItemCategory gde : itemCategories) {
|
return itemCategories.get(id);
|
||||||
if (id.equals(gde.id)){
|
|
||||||
return gde;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NPC getNPC(String id) {
|
public NPC getNPC(String id) {
|
||||||
if (npcs == null) return null;
|
if (npcs == null) return null;
|
||||||
for (NPC gde : npcs) {
|
return npcs.get(id);
|
||||||
if (id.equals(gde.id)){
|
|
||||||
return gde;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NPC getNPCIgnoreCase(String id) {
|
public NPC getNPCIgnoreCase(String id) {
|
||||||
if (npcs == null) return null;
|
if (npcs == null) return null;
|
||||||
for (NPC gde : npcs) {
|
return npcs.getIgnoreCase(id);
|
||||||
if (id.equalsIgnoreCase(gde.id)){
|
|
||||||
return gde;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Quest getQuest(String id) {
|
public Quest getQuest(String id) {
|
||||||
if (quests == null) return null;
|
if (quests == null) return null;
|
||||||
for (Quest gde : quests) {
|
return quests.get(id);
|
||||||
if (id.equals(gde.id)){
|
|
||||||
return gde;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -334,14 +304,17 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
|||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return getOpenIcon();
|
return getOpenIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getClosedIcon() {
|
public Image getClosedIcon() {
|
||||||
return DefaultIcons.getJsonClosedIcon();
|
return DefaultIcons.getJsonClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getLeafIcon() {
|
public Image getLeafIcon() {
|
||||||
return DefaultIcons.getJsonClosedIcon();
|
return DefaultIcons.getJsonClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getOpenIcon() {
|
public Image getOpenIcon() {
|
||||||
return DefaultIcons.getJsonOpenIcon();
|
return DefaultIcons.getJsonOpenIcon();
|
||||||
@@ -350,7 +323,8 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
|||||||
public void addElement(JSONElement node) {
|
public void addElement(JSONElement node) {
|
||||||
ProjectTreeNode higherEmptyParent = this;
|
ProjectTreeNode higherEmptyParent = this;
|
||||||
while (higherEmptyParent != null) {
|
while (higherEmptyParent != null) {
|
||||||
if (higherEmptyParent.getParent() != null && ((ProjectTreeNode)higherEmptyParent.getParent()).isEmpty()) higherEmptyParent = (ProjectTreeNode)higherEmptyParent.getParent();
|
if (higherEmptyParent.getParent() != null && ((ProjectTreeNode) higherEmptyParent.getParent()).isEmpty())
|
||||||
|
higherEmptyParent = (ProjectTreeNode) higherEmptyParent.getParent();
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
import java.awt.Image;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
@@ -10,13 +17,7 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.json.simple.parser.JSONParser;
|
import static com.gpl.rpg.atcontentstudio.model.gamedata.Common.*;
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
|
||||||
|
|
||||||
public class Item extends JSONElement {
|
public class Item extends JSONElement {
|
||||||
|
|
||||||
@@ -34,37 +35,21 @@ public class Item extends JSONElement {
|
|||||||
public String category_id = null;
|
public String category_id = null;
|
||||||
public String description = null;
|
public String description = null;
|
||||||
public HitEffect hit_effect = null;
|
public HitEffect hit_effect = null;
|
||||||
public KillEffect kill_effect = null;
|
public HitReceivedEffect hit_received_effect = null;
|
||||||
|
public DeathEffect kill_effect = null;
|
||||||
public EquipEffect equip_effect = null;
|
public EquipEffect equip_effect = null;
|
||||||
|
|
||||||
//Available from linked state
|
//Available from linked state
|
||||||
public ItemCategory category = null;
|
public ItemCategory category = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static class KillEffect {
|
|
||||||
//Available from parsed state
|
|
||||||
public Integer hp_boost_min = null;
|
|
||||||
public Integer hp_boost_max = null;
|
|
||||||
public Integer ap_boost_min = null;
|
|
||||||
public Integer ap_boost_max = null;
|
|
||||||
public List<TimedConditionEffect> conditions_source = null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Inheritance for code compactness, not semantically correct.
|
|
||||||
public static class HitEffect extends KillEffect {
|
|
||||||
//Available from parsed state
|
|
||||||
public List<TimedConditionEffect> conditions_target = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class EquipEffect {
|
public static class EquipEffect {
|
||||||
//Available from parsed state
|
//Available from parsed state
|
||||||
public Integer damage_boost_min = null;
|
public Integer damage_boost_min = null;
|
||||||
public Integer damage_boost_max = null;
|
public Integer damage_boost_max = null;
|
||||||
public Integer max_hp_boost = null;
|
public Integer max_hp_boost = null;
|
||||||
public Integer max_ap_boost = null;
|
public Integer max_ap_boost = null;
|
||||||
public List<ConditionEffect> conditions = null;
|
public List<ActorConditionEffect> conditions = null;
|
||||||
public Integer increase_move_cost = null;
|
public Integer increase_move_cost = null;
|
||||||
public Integer increase_use_item_cost = null;
|
public Integer increase_use_item_cost = null;
|
||||||
public Integer increase_reequip_cost = null;
|
public Integer increase_reequip_cost = null;
|
||||||
@@ -74,22 +59,9 @@ public class Item extends JSONElement {
|
|||||||
public Integer increase_block_chance = null;
|
public Integer increase_block_chance = null;
|
||||||
public Integer increase_damage_resistance = null;
|
public Integer increase_damage_resistance = null;
|
||||||
public Double critical_multiplier = null;
|
public Double critical_multiplier = null;
|
||||||
|
public Integer damage_modifier = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ConditionEffect {
|
|
||||||
//Available from parsed state
|
|
||||||
public Integer magnitude = null;
|
|
||||||
public String condition_id = null;
|
|
||||||
|
|
||||||
//Available from linked state
|
|
||||||
public ActorCondition condition = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TimedConditionEffect extends ConditionEffect {
|
|
||||||
//Available from parsed state
|
|
||||||
public Integer duration = null;
|
|
||||||
public Double chance = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum DisplayType {
|
public static enum DisplayType {
|
||||||
ordinary,
|
ordinary,
|
||||||
@@ -158,7 +130,8 @@ public class Item extends JSONElement {
|
|||||||
item.icon_id = (String) itemJson.get("iconID");
|
item.icon_id = (String) itemJson.get("iconID");
|
||||||
item.id = (String) itemJson.get("id");
|
item.id = (String) itemJson.get("id");
|
||||||
item.name = (String) itemJson.get("name");
|
item.name = (String) itemJson.get("name");
|
||||||
if (itemJson.get("displaytype") != null) item.display_type = DisplayType.valueOf((String) itemJson.get("displaytype"));
|
if (itemJson.get("displaytype") != null)
|
||||||
|
item.display_type = DisplayType.valueOf((String) itemJson.get("displaytype"));
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,14 +165,16 @@ public class Item extends JSONElement {
|
|||||||
this.equip_effect.increase_damage_resistance = JSONElement.getInteger((Number) equipEffect.get("increaseDamageResistance"));
|
this.equip_effect.increase_damage_resistance = JSONElement.getInteger((Number) equipEffect.get("increaseDamageResistance"));
|
||||||
//TODO correct game data, to unify format.
|
//TODO correct game data, to unify format.
|
||||||
// this.equip_effect.critical_multiplier = JSONElement.getDouble((Number) equipEffect.get("setCriticalMultiplier"));
|
// this.equip_effect.critical_multiplier = JSONElement.getDouble((Number) equipEffect.get("setCriticalMultiplier"));
|
||||||
if (equipEffect.get("setCriticalMultiplier") != null) this.equip_effect.critical_multiplier = JSONElement.getDouble(Double.parseDouble(equipEffect.get("setCriticalMultiplier").toString()));
|
if (equipEffect.get("setCriticalMultiplier") != null)
|
||||||
|
this.equip_effect.critical_multiplier = JSONElement.getDouble(Double.parseDouble(equipEffect.get("setCriticalMultiplier").toString()));
|
||||||
|
this.equip_effect.damage_modifier = JSONElement.getInteger((Number) equipEffect.get("setNonWeaponDamageModifier"));
|
||||||
|
|
||||||
List conditionsJson = (List) equipEffect.get("addedConditions");
|
List conditionsJson = (List) equipEffect.get("addedConditions");
|
||||||
if (conditionsJson != null && !conditionsJson.isEmpty()) {
|
if (conditionsJson != null && !conditionsJson.isEmpty()) {
|
||||||
this.equip_effect.conditions = new ArrayList<Item.ConditionEffect>();
|
this.equip_effect.conditions = new ArrayList<>();
|
||||||
for (Object conditionJsonObj : conditionsJson) {
|
for (Object conditionJsonObj : conditionsJson) {
|
||||||
Map conditionJson = (Map) conditionJsonObj;
|
Map conditionJson = (Map) conditionJsonObj;
|
||||||
ConditionEffect condition = new ConditionEffect();
|
ActorConditionEffect condition = new ActorConditionEffect();
|
||||||
condition.condition_id = (String) conditionJson.get("condition");
|
condition.condition_id = (String) conditionJson.get("condition");
|
||||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
||||||
this.equip_effect.conditions.add(condition);
|
this.equip_effect.conditions.add(condition);
|
||||||
@@ -207,43 +182,15 @@ public class Item extends JSONElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Map hitEffect = (Map) itemJson.get("hitEffect");
|
Map hitEffect = (Map) itemJson.get("hitEffect");
|
||||||
if (hitEffect != null) {
|
if (hitEffect != null) {
|
||||||
this.hit_effect = new HitEffect();
|
this.hit_effect = parseHitEffect(hitEffect);
|
||||||
if (hitEffect.get("increaseCurrentHP") != null) {
|
|
||||||
this.hit_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map)hitEffect.get("increaseCurrentHP")).get("min")));
|
|
||||||
this.hit_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map)hitEffect.get("increaseCurrentHP")).get("max")));
|
|
||||||
}
|
|
||||||
if (hitEffect.get("increaseCurrentAP") != null) {
|
|
||||||
this.hit_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)hitEffect.get("increaseCurrentAP")).get("min")));
|
|
||||||
this.hit_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)hitEffect.get("increaseCurrentAP")).get("max")));
|
|
||||||
}
|
|
||||||
List conditionsSourceJson = (List) hitEffect.get("conditionsSource");
|
|
||||||
if (conditionsSourceJson != null && !conditionsSourceJson.isEmpty()) {
|
|
||||||
this.hit_effect.conditions_source = new ArrayList<Item.TimedConditionEffect>();
|
|
||||||
for (Object conditionJsonObj : conditionsSourceJson) {
|
|
||||||
Map conditionJson = (Map)conditionJsonObj;
|
|
||||||
TimedConditionEffect condition = new TimedConditionEffect();
|
|
||||||
condition.condition_id = (String) conditionJson.get("condition");
|
|
||||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
|
||||||
condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration"));
|
|
||||||
if (conditionJson.get("chance") != null) condition.chance = JSONElement.parseChance(conditionJson.get("chance").toString());
|
|
||||||
this.hit_effect.conditions_source.add(condition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List conditionsTargetJson = (List) hitEffect.get("conditionsTarget");
|
|
||||||
if (conditionsTargetJson != null && !conditionsTargetJson.isEmpty()) {
|
|
||||||
this.hit_effect.conditions_target = new ArrayList<Item.TimedConditionEffect>();
|
|
||||||
for (Object conditionJsonObj : conditionsTargetJson) {
|
|
||||||
Map conditionJson = (Map)conditionJsonObj;
|
|
||||||
TimedConditionEffect condition = new TimedConditionEffect();
|
|
||||||
condition.condition_id = (String) conditionJson.get("condition");
|
|
||||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
|
||||||
condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration"));
|
|
||||||
if (conditionJson.get("chance") != null) condition.chance = JSONElement.parseChance(conditionJson.get("chance").toString());
|
|
||||||
this.hit_effect.conditions_target.add(condition);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map hitReceivedEffect = (Map) itemJson.get("hitReceivedEffect");
|
||||||
|
if (hitReceivedEffect != null) {
|
||||||
|
this.hit_received_effect = parseHitReceivedEffect(hitReceivedEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map killEffect = (Map) itemJson.get("killEffect");
|
Map killEffect = (Map) itemJson.get("killEffect");
|
||||||
@@ -251,28 +198,7 @@ public class Item extends JSONElement {
|
|||||||
killEffect = (Map) itemJson.get("useEffect");
|
killEffect = (Map) itemJson.get("useEffect");
|
||||||
}
|
}
|
||||||
if (killEffect != null) {
|
if (killEffect != null) {
|
||||||
this.kill_effect = new KillEffect();
|
this.kill_effect = parseDeathEffect(killEffect);
|
||||||
if (killEffect.get("increaseCurrentHP") != null) {
|
|
||||||
this.kill_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map)killEffect.get("increaseCurrentHP")).get("min")));
|
|
||||||
this.kill_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map)killEffect.get("increaseCurrentHP")).get("max")));
|
|
||||||
}
|
|
||||||
if (killEffect.get("increaseCurrentAP") != null) {
|
|
||||||
this.kill_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)killEffect.get("increaseCurrentAP")).get("min")));
|
|
||||||
this.kill_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)killEffect.get("increaseCurrentAP")).get("max")));
|
|
||||||
}
|
|
||||||
List conditionsSourceJson = (List) killEffect.get("conditionsSource");
|
|
||||||
if (conditionsSourceJson != null && !conditionsSourceJson.isEmpty()) {
|
|
||||||
this.kill_effect.conditions_source = new ArrayList<Item.TimedConditionEffect>();
|
|
||||||
for (Object conditionJsonObj : conditionsSourceJson) {
|
|
||||||
Map conditionJson = (Map)conditionJsonObj;
|
|
||||||
TimedConditionEffect condition = new TimedConditionEffect();
|
|
||||||
condition.condition_id = (String) conditionJson.get("condition");
|
|
||||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
|
||||||
condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration"));
|
|
||||||
if (conditionJson.get("chance") != null) condition.chance = JSONElement.parseChance(conditionJson.get("chance").toString());
|
|
||||||
this.kill_effect.conditions_source.add(condition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.state = State.parsed;
|
this.state = State.parsed;
|
||||||
}
|
}
|
||||||
@@ -280,56 +206,30 @@ public class Item extends JSONElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void link() {
|
public void link() {
|
||||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
if (shouldSkipParseOrLink()) {
|
||||||
//This type of state is unrelated to parsing/linking.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.state == State.init) {
|
|
||||||
//Not parsed yet.
|
|
||||||
this.parse();
|
|
||||||
} else if (this.state == State.linked) {
|
|
||||||
//Already linked.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ensureParseIfNeeded();
|
||||||
Project proj = getProject();
|
Project proj = getProject();
|
||||||
if (proj == null) {
|
if (proj == null) {
|
||||||
Notification.addError("Error linking item " + id + ". No parent project found.");
|
Notification.addError("Error linking item " + id + ". No parent project found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.icon_id != null) {
|
linkIcon(proj, this.icon_id, this);
|
||||||
String spritesheetId = this.icon_id.split(":")[0];
|
|
||||||
proj.getSpritesheet(spritesheetId).addBacklink(this);
|
|
||||||
}
|
|
||||||
if (this.category_id != null) this.category = proj.getItemCategory(this.category_id);
|
if (this.category_id != null) this.category = proj.getItemCategory(this.category_id);
|
||||||
if (this.category != null) this.category.addBacklink(this);
|
if (this.category != null) this.category.addBacklink(this);
|
||||||
if (this.equip_effect != null && this.equip_effect.conditions != null) {
|
if (this.equip_effect != null && this.equip_effect.conditions != null) {
|
||||||
for (ConditionEffect ce : this.equip_effect.conditions) {
|
linkConditions(this.equip_effect.conditions, proj, this);
|
||||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
|
||||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.hit_effect != null && this.hit_effect.conditions_source != null) {
|
|
||||||
for (TimedConditionEffect ce : this.hit_effect.conditions_source) {
|
|
||||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
|
||||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.hit_effect != null && this.hit_effect.conditions_target != null) {
|
|
||||||
for (TimedConditionEffect ce : this.hit_effect.conditions_target) {
|
|
||||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
|
||||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.kill_effect != null && this.kill_effect.conditions_source != null) {
|
|
||||||
for (TimedConditionEffect ce : this.kill_effect.conditions_source) {
|
|
||||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
|
||||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linkEffects(this.hit_effect, proj, this);
|
||||||
|
linkEffects(this.hit_received_effect, proj, this);
|
||||||
|
linkEffects(this.kill_effect, proj, this);
|
||||||
this.state = State.linked;
|
this.state = State.linked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return getProject().getIcon(icon_id);
|
return getProject().getIcon(icon_id);
|
||||||
@@ -358,6 +258,7 @@ public class Item extends JSONElement {
|
|||||||
clone.has_manual_price = this.has_manual_price;
|
clone.has_manual_price = this.has_manual_price;
|
||||||
if (this.equip_effect != null) {
|
if (this.equip_effect != null) {
|
||||||
clone.equip_effect = new EquipEffect();
|
clone.equip_effect = new EquipEffect();
|
||||||
|
clone.equip_effect.damage_modifier = this.equip_effect.damage_modifier;
|
||||||
clone.equip_effect.critical_multiplier = this.equip_effect.critical_multiplier;
|
clone.equip_effect.critical_multiplier = this.equip_effect.critical_multiplier;
|
||||||
clone.equip_effect.damage_boost_max = this.equip_effect.damage_boost_max;
|
clone.equip_effect.damage_boost_max = this.equip_effect.damage_boost_max;
|
||||||
clone.equip_effect.damage_boost_min = this.equip_effect.damage_boost_min;
|
clone.equip_effect.damage_boost_min = this.equip_effect.damage_boost_min;
|
||||||
@@ -372,9 +273,9 @@ public class Item extends JSONElement {
|
|||||||
clone.equip_effect.max_ap_boost = this.equip_effect.max_ap_boost;
|
clone.equip_effect.max_ap_boost = this.equip_effect.max_ap_boost;
|
||||||
clone.equip_effect.max_hp_boost = this.equip_effect.max_hp_boost;
|
clone.equip_effect.max_hp_boost = this.equip_effect.max_hp_boost;
|
||||||
if (this.equip_effect.conditions != null) {
|
if (this.equip_effect.conditions != null) {
|
||||||
clone.equip_effect.conditions = new ArrayList<Item.ConditionEffect>();
|
clone.equip_effect.conditions = new ArrayList<>();
|
||||||
for (ConditionEffect c : this.equip_effect.conditions) {
|
for (ActorConditionEffect c : this.equip_effect.conditions) {
|
||||||
ConditionEffect cclone = new ConditionEffect();
|
ActorConditionEffect cclone = new ActorConditionEffect();
|
||||||
cclone.magnitude = c.magnitude;
|
cclone.magnitude = c.magnitude;
|
||||||
cclone.condition_id = c.condition_id;
|
cclone.condition_id = c.condition_id;
|
||||||
cclone.condition = c.condition;
|
cclone.condition = c.condition;
|
||||||
@@ -387,62 +288,15 @@ public class Item extends JSONElement {
|
|||||||
}
|
}
|
||||||
if (this.hit_effect != null) {
|
if (this.hit_effect != null) {
|
||||||
clone.hit_effect = new HitEffect();
|
clone.hit_effect = new HitEffect();
|
||||||
clone.hit_effect.ap_boost_max = this.hit_effect.ap_boost_max;
|
copyHitEffectValues(clone.hit_effect, this.hit_effect, clone);
|
||||||
clone.hit_effect.ap_boost_min = this.hit_effect.ap_boost_min;
|
|
||||||
clone.hit_effect.hp_boost_max = this.hit_effect.hp_boost_max;
|
|
||||||
clone.hit_effect.hp_boost_min = this.hit_effect.hp_boost_min;
|
|
||||||
if (this.hit_effect.conditions_source != null) {
|
|
||||||
clone.hit_effect.conditions_source = new ArrayList<Item.TimedConditionEffect>();
|
|
||||||
for (TimedConditionEffect c : this.hit_effect.conditions_source) {
|
|
||||||
TimedConditionEffect cclone = new TimedConditionEffect();
|
|
||||||
cclone.magnitude = c.magnitude;
|
|
||||||
cclone.condition_id = c.condition_id;
|
|
||||||
cclone.condition = c.condition;
|
|
||||||
cclone.chance = c.chance;
|
|
||||||
cclone.duration = c.duration;
|
|
||||||
if (cclone.condition != null) {
|
|
||||||
cclone.condition.addBacklink(clone);
|
|
||||||
}
|
|
||||||
clone.hit_effect.conditions_source.add(cclone);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.hit_effect.conditions_target != null) {
|
|
||||||
clone.hit_effect.conditions_target = new ArrayList<Item.TimedConditionEffect>();
|
|
||||||
for (TimedConditionEffect c : this.hit_effect.conditions_target) {
|
|
||||||
TimedConditionEffect cclone = new TimedConditionEffect();
|
|
||||||
cclone.magnitude = c.magnitude;
|
|
||||||
cclone.condition_id = c.condition_id;
|
|
||||||
cclone.condition = c.condition;
|
|
||||||
cclone.chance = c.chance;
|
|
||||||
cclone.duration = c.duration;
|
|
||||||
if (cclone.condition != null) {
|
|
||||||
cclone.condition.addBacklink(clone);
|
|
||||||
}
|
|
||||||
clone.hit_effect.conditions_target.add(cclone);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (this.hit_received_effect != null) {
|
||||||
|
clone.hit_received_effect = new HitReceivedEffect();
|
||||||
|
copyHitReceivedEffectValues(clone.hit_received_effect, this.hit_received_effect, clone);
|
||||||
}
|
}
|
||||||
if (this.kill_effect != null) {
|
if (this.kill_effect != null) {
|
||||||
clone.kill_effect = new KillEffect();
|
clone.kill_effect = new DeathEffect();
|
||||||
clone.kill_effect.ap_boost_max = this.kill_effect.ap_boost_max;
|
copyDeathEffectValues(clone.kill_effect, this.kill_effect, clone);
|
||||||
clone.kill_effect.ap_boost_min = this.kill_effect.ap_boost_min;
|
|
||||||
clone.kill_effect.hp_boost_max = this.kill_effect.hp_boost_max;
|
|
||||||
clone.kill_effect.hp_boost_min = this.kill_effect.hp_boost_min;
|
|
||||||
if (this.kill_effect.conditions_source != null) {
|
|
||||||
clone.kill_effect.conditions_source = new ArrayList<Item.TimedConditionEffect>();
|
|
||||||
for (TimedConditionEffect c : this.kill_effect.conditions_source) {
|
|
||||||
TimedConditionEffect cclone = new TimedConditionEffect();
|
|
||||||
cclone.magnitude = c.magnitude;
|
|
||||||
cclone.condition_id = c.condition_id;
|
|
||||||
cclone.condition = c.condition;
|
|
||||||
cclone.chance = c.chance;
|
|
||||||
cclone.duration = c.duration;
|
|
||||||
if (cclone.condition != null) {
|
|
||||||
cclone.condition.addBacklink(clone);
|
|
||||||
}
|
|
||||||
clone.kill_effect.conditions_source.add(cclone);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
@@ -454,42 +308,18 @@ public class Item extends JSONElement {
|
|||||||
this.category = (ItemCategory) newOne;
|
this.category = (ItemCategory) newOne;
|
||||||
if (newOne != null) newOne.addBacklink(this);
|
if (newOne != null) newOne.addBacklink(this);
|
||||||
} else {
|
} else {
|
||||||
if (this.equip_effect != null && this.equip_effect.conditions != null) {
|
if (this.equip_effect != null) {
|
||||||
for (ConditionEffect c : this.equip_effect.conditions) {
|
if (this.equip_effect.conditions != null) {
|
||||||
if (c.condition == oldOne) {
|
actorConditionElementChanged(this.equip_effect.conditions, oldOne, newOne, this);
|
||||||
oldOne.removeBacklink(this);
|
|
||||||
c.condition = (ActorCondition) newOne;
|
|
||||||
if (newOne != null) newOne.addBacklink(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.hit_effect != null && this.hit_effect.conditions_source != null) {
|
|
||||||
for (TimedConditionEffect c : this.hit_effect.conditions_source) {
|
|
||||||
if (c.condition == oldOne) {
|
|
||||||
oldOne.removeBacklink(this);
|
|
||||||
c.condition = (ActorCondition) newOne;
|
|
||||||
if (newOne != null) newOne.addBacklink(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.hit_effect != null && this.hit_effect.conditions_target != null) {
|
|
||||||
for (TimedConditionEffect c : this.hit_effect.conditions_target) {
|
|
||||||
if (c.condition == oldOne) {
|
|
||||||
oldOne.removeBacklink(this);
|
|
||||||
c.condition = (ActorCondition) newOne;
|
|
||||||
if (newOne != null) newOne.addBacklink(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.hit_effect != null) {
|
||||||
|
actorConditionElementChanged(this.hit_effect.conditions_source, oldOne, newOne, this);
|
||||||
|
actorConditionElementChanged(this.hit_effect.conditions_target, oldOne, newOne, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.kill_effect != null && this.kill_effect.conditions_source != null) {
|
if (this.kill_effect != null) {
|
||||||
for (TimedConditionEffect c : this.kill_effect.conditions_source) {
|
actorConditionElementChanged(this.kill_effect.conditions_source, oldOne, newOne, this);
|
||||||
if (c.condition == oldOne) {
|
|
||||||
oldOne.removeBacklink(this);
|
|
||||||
c.condition = (ActorCondition) newOne;
|
|
||||||
if (newOne != null) newOne.addBacklink(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -499,7 +329,7 @@ public class Item extends JSONElement {
|
|||||||
public Map toJson() {
|
public Map toJson() {
|
||||||
Map itemJson = new LinkedHashMap();
|
Map itemJson = new LinkedHashMap();
|
||||||
itemJson.put("id", this.id);
|
itemJson.put("id", this.id);
|
||||||
if (this.icon_id != null) itemJson.put("iconID", this.icon_id);
|
writeIconToMap(itemJson, this.icon_id);
|
||||||
if (this.name != null) itemJson.put("name", this.name);
|
if (this.name != null) itemJson.put("name", this.name);
|
||||||
if (this.display_type != null) itemJson.put("displaytype", this.display_type.toString());
|
if (this.display_type != null) itemJson.put("displaytype", this.display_type.toString());
|
||||||
|
|
||||||
@@ -510,139 +340,65 @@ public class Item extends JSONElement {
|
|||||||
} else if (this.category_id != null) {
|
} else if (this.category_id != null) {
|
||||||
itemJson.put("category", this.category_id);
|
itemJson.put("category", this.category_id);
|
||||||
}
|
}
|
||||||
if (this.description != null) itemJson.put("description", this.description);
|
writeDescriptionToMap(itemJson, this.description);
|
||||||
if (this.equip_effect != null) {
|
if (this.equip_effect != null) {
|
||||||
Map equipEffectJson = new LinkedHashMap();
|
Map equipEffectJson = new LinkedHashMap();
|
||||||
itemJson.put("equipEffect", equipEffectJson);
|
itemJson.put("equipEffect", equipEffectJson);
|
||||||
if (this.equip_effect.damage_boost_min != null || this.equip_effect.damage_boost_max != null) {
|
writeMinMaxToMap(equipEffectJson, "increaseAttackDamage", this.equip_effect.damage_boost_min, this.equip_effect.damage_boost_max, 0);
|
||||||
Map damageJson = new LinkedHashMap();
|
if (this.equip_effect.max_hp_boost != null)
|
||||||
equipEffectJson.put("increaseAttackDamage", damageJson);
|
equipEffectJson.put("increaseMaxHP", this.equip_effect.max_hp_boost);
|
||||||
if (this.equip_effect.damage_boost_min != null) damageJson.put("min", this.equip_effect.damage_boost_min);
|
if (this.equip_effect.max_ap_boost != null)
|
||||||
else damageJson.put("min", 0);
|
equipEffectJson.put("increaseMaxAP", this.equip_effect.max_ap_boost);
|
||||||
if (this.equip_effect.damage_boost_max != null) damageJson.put("max", this.equip_effect.damage_boost_max);
|
if (this.equip_effect.increase_move_cost != null)
|
||||||
else damageJson.put("max", 0);
|
equipEffectJson.put("increaseMoveCost", this.equip_effect.increase_move_cost);
|
||||||
}
|
if (this.equip_effect.increase_use_item_cost != null)
|
||||||
if (this.equip_effect.max_hp_boost != null) equipEffectJson.put("increaseMaxHP", this.equip_effect.max_hp_boost);
|
equipEffectJson.put("increaseUseItemCost", this.equip_effect.increase_use_item_cost);
|
||||||
if (this.equip_effect.max_ap_boost != null) equipEffectJson.put("increaseMaxAP", this.equip_effect.max_ap_boost);
|
if (this.equip_effect.increase_reequip_cost != null)
|
||||||
if (this.equip_effect.increase_move_cost != null) equipEffectJson.put("increaseMoveCost", this.equip_effect.increase_move_cost);
|
equipEffectJson.put("increaseReequipCost", this.equip_effect.increase_reequip_cost);
|
||||||
if (this.equip_effect.increase_use_item_cost != null) equipEffectJson.put("increaseUseItemCost", this.equip_effect.increase_use_item_cost);
|
if (this.equip_effect.increase_attack_cost != null)
|
||||||
if (this.equip_effect.increase_reequip_cost != null) equipEffectJson.put("increaseReequipCost", this.equip_effect.increase_reequip_cost);
|
equipEffectJson.put("increaseAttackCost", this.equip_effect.increase_attack_cost);
|
||||||
if (this.equip_effect.increase_attack_cost != null) equipEffectJson.put("increaseAttackCost", this.equip_effect.increase_attack_cost);
|
if (this.equip_effect.increase_attack_chance != null)
|
||||||
if (this.equip_effect.increase_attack_chance != null) equipEffectJson.put("increaseAttackChance", this.equip_effect.increase_attack_chance);
|
equipEffectJson.put("increaseAttackChance", this.equip_effect.increase_attack_chance);
|
||||||
if (this.equip_effect.increase_critical_skill != null) equipEffectJson.put("increaseCriticalSkill", this.equip_effect.increase_critical_skill);
|
if (this.equip_effect.increase_critical_skill != null)
|
||||||
if (this.equip_effect.increase_block_chance != null) equipEffectJson.put("increaseBlockChance", this.equip_effect.increase_block_chance);
|
equipEffectJson.put("increaseCriticalSkill", this.equip_effect.increase_critical_skill);
|
||||||
if (this.equip_effect.increase_damage_resistance != null) equipEffectJson.put("increaseDamageResistance", this.equip_effect.increase_damage_resistance);
|
if (this.equip_effect.increase_block_chance != null)
|
||||||
if (this.equip_effect.critical_multiplier != null) equipEffectJson.put("setCriticalMultiplier", this.equip_effect.critical_multiplier);
|
equipEffectJson.put("increaseBlockChance", this.equip_effect.increase_block_chance);
|
||||||
|
if (this.equip_effect.increase_damage_resistance != null)
|
||||||
|
equipEffectJson.put("increaseDamageResistance", this.equip_effect.increase_damage_resistance);
|
||||||
|
if (this.equip_effect.critical_multiplier != null)
|
||||||
|
equipEffectJson.put("setCriticalMultiplier", this.equip_effect.critical_multiplier);
|
||||||
|
if (this.equip_effect.damage_modifier != null)
|
||||||
|
equipEffectJson.put("setNonWeaponDamageModifier", this.equip_effect.damage_modifier);
|
||||||
if (this.equip_effect.conditions != null) {
|
if (this.equip_effect.conditions != null) {
|
||||||
List conditionsJson = new ArrayList();
|
List conditionsJson = new ArrayList();
|
||||||
equipEffectJson.put("addedConditions", conditionsJson);
|
equipEffectJson.put("addedConditions", conditionsJson);
|
||||||
for (ConditionEffect condition : this.equip_effect.conditions) {
|
for (ActorConditionEffect condition : this.equip_effect.conditions) {
|
||||||
Map conditionJson = new LinkedHashMap();
|
Map conditionJson = new LinkedHashMap();
|
||||||
conditionsJson.add(conditionJson);
|
conditionsJson.add(conditionJson);
|
||||||
if (condition.condition != null) {
|
writeConditionEffectToMap(condition, conditionJson);
|
||||||
conditionJson.put("condition", condition.condition.id);
|
|
||||||
} else if (condition.condition_id != null) {
|
|
||||||
conditionJson.put("condition", condition.condition_id);
|
|
||||||
}
|
|
||||||
if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.hit_effect != null) {
|
writeHitEffectToMap(itemJson, this.hit_effect, "hitEffect");
|
||||||
Map hitEffectJson = new LinkedHashMap();
|
writeHitReceivedEffectToMap(itemJson, this.hit_received_effect, "hitReceivedEffect");
|
||||||
itemJson.put("hitEffect", hitEffectJson);
|
|
||||||
if (this.hit_effect.hp_boost_min != null || this.hit_effect.hp_boost_max != null) {
|
String key;
|
||||||
Map hpJson = new LinkedHashMap();
|
|
||||||
hitEffectJson.put("increaseCurrentHP", hpJson);
|
|
||||||
if (this.hit_effect.hp_boost_min != null) hpJson.put("min", this.hit_effect.hp_boost_min);
|
|
||||||
else hpJson.put("min", 0);
|
|
||||||
if (this.hit_effect.hp_boost_max != null) hpJson.put("max", this.hit_effect.hp_boost_max);
|
|
||||||
else hpJson.put("max", 0);
|
|
||||||
}
|
|
||||||
if (this.hit_effect.ap_boost_min != null || this.hit_effect.ap_boost_max != null) {
|
|
||||||
Map apJson = new LinkedHashMap();
|
|
||||||
hitEffectJson.put("increaseCurrentAP", apJson);
|
|
||||||
if (this.hit_effect.ap_boost_min != null) apJson.put("min", this.hit_effect.ap_boost_min);
|
|
||||||
else apJson.put("min", 0);
|
|
||||||
if (this.hit_effect.ap_boost_max != null) apJson.put("max", this.hit_effect.ap_boost_max);
|
|
||||||
else apJson.put("max", 0);
|
|
||||||
}
|
|
||||||
if (this.hit_effect.conditions_source != null) {
|
|
||||||
List conditionsSourceJson = new ArrayList();
|
|
||||||
hitEffectJson.put("conditionsSource", conditionsSourceJson);
|
|
||||||
for (TimedConditionEffect condition : this.hit_effect.conditions_source) {
|
|
||||||
Map conditionJson = new LinkedHashMap();
|
|
||||||
conditionsSourceJson.add(conditionJson);
|
|
||||||
if (condition.condition != null) {
|
|
||||||
conditionJson.put("condition", condition.condition.id);
|
|
||||||
} else if (condition.condition_id != null) {
|
|
||||||
conditionJson.put("condition", condition.condition_id);
|
|
||||||
}
|
|
||||||
if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude);
|
|
||||||
if (condition.duration != null) conditionJson.put("duration", condition.duration);
|
|
||||||
if (condition.chance != null) conditionJson.put("chance", JSONElement.printJsonChance(condition.chance));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.hit_effect.conditions_target != null) {
|
|
||||||
List conditionsTargetJson = new ArrayList();
|
|
||||||
hitEffectJson.put("conditionsTarget", conditionsTargetJson);
|
|
||||||
for (TimedConditionEffect condition : this.hit_effect.conditions_target) {
|
|
||||||
Map conditionJson = new LinkedHashMap();
|
|
||||||
conditionsTargetJson.add(conditionJson);
|
|
||||||
if (condition.condition != null) {
|
|
||||||
conditionJson.put("condition", condition.condition.id);
|
|
||||||
} else if (condition.condition_id != null) {
|
|
||||||
conditionJson.put("condition", condition.condition_id);
|
|
||||||
}
|
|
||||||
if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude);
|
|
||||||
if (condition.duration != null) conditionJson.put("duration", condition.duration);
|
|
||||||
if (condition.chance != null) conditionJson.put("chance", JSONElement.printJsonChance(condition.chance));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.kill_effect != null) {
|
|
||||||
Map killEffectJson = new LinkedHashMap();
|
|
||||||
if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.equip) {
|
if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.equip) {
|
||||||
itemJson.put("killEffect", killEffectJson);
|
key = "killEffect";
|
||||||
} else if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.use) {
|
} else if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.use) {
|
||||||
itemJson.put("useEffect", killEffectJson);
|
key = "useEffect";
|
||||||
}
|
} else {
|
||||||
if (this.kill_effect.hp_boost_min != null || this.kill_effect.hp_boost_max != null) {
|
System.out.println("Could not create JSON-Map for Item: Failed to determine if the item should be used or equipped.");
|
||||||
Map hpJson = new LinkedHashMap();
|
key = null;
|
||||||
killEffectJson.put("increaseCurrentHP", hpJson);
|
|
||||||
if (this.kill_effect.hp_boost_min != null) hpJson.put("min", this.kill_effect.hp_boost_min);
|
|
||||||
else hpJson.put("min", 0);
|
|
||||||
if (this.kill_effect.hp_boost_max != null) hpJson.put("max", this.kill_effect.hp_boost_max);
|
|
||||||
else hpJson.put("min", 0);
|
|
||||||
}
|
|
||||||
if (this.kill_effect.ap_boost_min != null || this.kill_effect.ap_boost_max != null) {
|
|
||||||
Map apJson = new LinkedHashMap();
|
|
||||||
killEffectJson.put("increaseCurrentAP", apJson);
|
|
||||||
if (this.kill_effect.ap_boost_min != null) apJson.put("min", this.kill_effect.ap_boost_min);
|
|
||||||
else apJson.put("min", 0);
|
|
||||||
if (this.kill_effect.ap_boost_max != null) apJson.put("max", this.kill_effect.ap_boost_max);
|
|
||||||
else apJson.put("max", 0);
|
|
||||||
}
|
|
||||||
if (this.kill_effect.conditions_source != null) {
|
|
||||||
List conditionsSourceJson = new ArrayList();
|
|
||||||
killEffectJson.put("conditionsSource", conditionsSourceJson);
|
|
||||||
for (TimedConditionEffect condition : this.kill_effect.conditions_source) {
|
|
||||||
Map conditionJson = new LinkedHashMap();
|
|
||||||
conditionsSourceJson.add(conditionJson);
|
|
||||||
if (condition.condition != null) {
|
|
||||||
conditionJson.put("condition", condition.condition.id);
|
|
||||||
} else if (condition.condition_id != null) {
|
|
||||||
conditionJson.put("condition", condition.condition_id);
|
|
||||||
}
|
|
||||||
if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude);
|
|
||||||
if (condition.duration != null) conditionJson.put("duration", condition.duration);
|
|
||||||
if (condition.chance != null) conditionJson.put("chance", JSONElement.printJsonChance(condition.chance));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (key != null) {
|
||||||
|
writeDeathEffectToMap(itemJson, this.kill_effect, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return itemJson;
|
return itemJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProjectFilename() {
|
public String getProjectFilename() {
|
||||||
return "itemlist_" + getProject().name + ".json";
|
return "itemlist_" + getProject().name + ".json";
|
||||||
@@ -654,7 +410,7 @@ public class Item extends JSONElement {
|
|||||||
if (category.action_type == ItemCategory.ActionType.use) {
|
if (category.action_type == ItemCategory.ActionType.use) {
|
||||||
price += kill_effect == null ? 0 : calculateUseCost();
|
price += kill_effect == null ? 0 : calculateUseCost();
|
||||||
} else if (category.action_type == ItemCategory.ActionType.equip) {
|
} else if (category.action_type == ItemCategory.ActionType.equip) {
|
||||||
price += equip_effect == null ? 0 : calculateEquipCost(isWeapon());;
|
price += equip_effect == null ? 0 : calculateEquipCost(isWeapon());
|
||||||
price += hit_effect == null ? 0 : calculateHitCost();
|
price += hit_effect == null ? 0 : calculateHitCost();
|
||||||
price += kill_effect == null ? 0 : calculateKillCost();
|
price += kill_effect == null ? 0 : calculateKillCost();
|
||||||
}
|
}
|
||||||
@@ -682,7 +438,8 @@ public class Item extends JSONElement {
|
|||||||
|
|
||||||
public int calculateEquipCost(boolean isWeapon) {
|
public int calculateEquipCost(boolean isWeapon) {
|
||||||
final int costBC = (int) (3 * Math.pow(Math.max(0, zeroForNull(equip_effect.increase_block_chance)), 2.5) + 28 * zeroForNull(equip_effect.increase_block_chance));
|
final int costBC = (int) (3 * Math.pow(Math.max(0, zeroForNull(equip_effect.increase_block_chance)), 2.5) + 28 * zeroForNull(equip_effect.increase_block_chance));
|
||||||
final int costAC = (int) (0.4*Math.pow(Math.max(0,zeroForNull(equip_effect.increase_attack_chance)), 2.5) - 6*Math.pow(Math.abs(Math.min(0,zeroForNull(equip_effect.increase_attack_chance))),2.7));
|
final int costAC = (int) (0.4 * Math.pow(Math.max(0, zeroForNull(equip_effect.increase_attack_chance)), 2.5) - 6 * Math.pow(
|
||||||
|
Math.abs(Math.min(0, zeroForNull(equip_effect.increase_attack_chance))), 2.7));
|
||||||
final int costAP = isWeapon ?
|
final int costAP = isWeapon ?
|
||||||
(int) (0.2 * Math.pow(10.0f / zeroForNull(equip_effect.increase_attack_cost), 8) - 25 * zeroForNull(equip_effect.increase_attack_cost))
|
(int) (0.2 * Math.pow(10.0f / zeroForNull(equip_effect.increase_attack_cost), 8) - 25 * zeroForNull(equip_effect.increase_attack_cost))
|
||||||
: -3125 * zeroForNull(equip_effect.increase_attack_cost);
|
: -3125 * zeroForNull(equip_effect.increase_attack_cost);
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
import java.awt.Image;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
@@ -9,15 +16,6 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
|
||||||
|
|
||||||
public class ItemCategory extends JSONElement {
|
public class ItemCategory extends JSONElement {
|
||||||
|
|
||||||
private static final long serialVersionUID = -348864002519568300L;
|
private static final long serialVersionUID = -348864002519568300L;
|
||||||
@@ -156,14 +154,16 @@ public class ItemCategory extends JSONElement {
|
|||||||
ItemCategory itemCat = new ItemCategory();
|
ItemCategory itemCat = new ItemCategory();
|
||||||
itemCat.id = (String) itemCatJson.get("id");
|
itemCat.id = (String) itemCatJson.get("id");
|
||||||
itemCat.name = (String) itemCatJson.get("name");
|
itemCat.name = (String) itemCatJson.get("name");
|
||||||
if (itemCatJson.get("inventorySlot") != null) itemCat.slot = InventorySlot.valueOf((String) itemCatJson.get("inventorySlot"));
|
if (itemCatJson.get("inventorySlot") != null)
|
||||||
|
itemCat.slot = InventorySlot.valueOf((String) itemCatJson.get("inventorySlot"));
|
||||||
return itemCat;
|
return itemCat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public void parse(Map itemCatJson) {
|
public void parse(Map itemCatJson) {
|
||||||
if (itemCatJson.get("actionType") != null) action_type = ActionType.valueOf((String) itemCatJson.get("actionType"));
|
if (itemCatJson.get("actionType") != null)
|
||||||
|
action_type = ActionType.valueOf((String) itemCatJson.get("actionType"));
|
||||||
if (itemCatJson.get("size") != null) size = Size.valueOf((String) itemCatJson.get("size"));
|
if (itemCatJson.get("size") != null) size = Size.valueOf((String) itemCatJson.get("size"));
|
||||||
this.state = State.parsed;
|
this.state = State.parsed;
|
||||||
|
|
||||||
@@ -171,17 +171,10 @@ public class ItemCategory extends JSONElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void link() {
|
public void link() {
|
||||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
if (shouldSkipParseOrLink()) {
|
||||||
//This type of state is unrelated to parsing/linking.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.state == State.init) {
|
|
||||||
//Not parsed yet.
|
|
||||||
this.parse();
|
|
||||||
} else if (this.state == State.linked) {
|
|
||||||
//Already linked.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ensureParseIfNeeded();
|
||||||
|
|
||||||
//Nothing to link to :D
|
//Nothing to link to :D
|
||||||
this.state = State.linked;
|
this.state = State.linked;
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
import com.gpl.rpg.atcontentstudio.io.JsonPrettyWriter;
|
import com.gpl.rpg.atcontentstudio.io.JsonPrettyWriter;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
||||||
|
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class JSONElement extends GameDataElement {
|
public abstract class JSONElement extends GameDataElement {
|
||||||
|
|
||||||
@@ -26,8 +22,7 @@ public abstract class JSONElement extends GameDataElement {
|
|||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public void parse() {
|
public void parse() {
|
||||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
if (shouldSkipParse()) {
|
||||||
//This type of state is unrelated to parsing/linking.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
@@ -38,11 +33,16 @@ public abstract class JSONElement extends GameDataElement {
|
|||||||
for (Object obj : gameDataElements) {
|
for (Object obj : gameDataElements) {
|
||||||
Map jsonObj = (Map) obj;
|
Map jsonObj = (Map) obj;
|
||||||
String id = (String) jsonObj.get("id");
|
String id = (String) jsonObj.get("id");
|
||||||
|
try {
|
||||||
if (id != null && id.equals(this.id)) {
|
if (id != null && id.equals(this.id)) {
|
||||||
this.parse(jsonObj);
|
this.parse(jsonObj);
|
||||||
this.state = State.parsed;
|
this.state = State.parsed;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("Error in ID: " + id);
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
Notification.addError("Error while parsing JSON file " + jsonFile.getAbsolutePath() + ": " + e.getMessage());
|
Notification.addError("Error while parsing JSON file " + jsonFile.getAbsolutePath() + ": " + e.getMessage());
|
||||||
@@ -53,6 +53,10 @@ public abstract class JSONElement extends GameDataElement {
|
|||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
Notification.addError("Error while parsing JSON file " + jsonFile.getAbsolutePath() + ": " + e.getMessage());
|
Notification.addError("Error while parsing JSON file " + jsonFile.getAbsolutePath() + ": " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
System.out.println(id);
|
||||||
|
Notification.addError("Error while parsing JSON file " + jsonFile.getAbsolutePath() + ": " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if (reader != null)
|
if (reader != null)
|
||||||
try {
|
try {
|
||||||
@@ -68,16 +72,11 @@ public abstract class JSONElement extends GameDataElement {
|
|||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public abstract Map toJson();
|
public abstract Map toJson();
|
||||||
public String toJsonString() {
|
|
||||||
StringWriter writer = new JsonPrettyWriter();
|
|
||||||
try {
|
|
||||||
JSONObject.writeJSONString(this.toJson(), writer);
|
|
||||||
} catch (IOException e) {
|
|
||||||
//Impossible with a StringWriter
|
|
||||||
}
|
|
||||||
return writer.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public String toJsonString() {
|
||||||
|
Map json = this.toJson();
|
||||||
|
return FileUtils.toJsonString(json);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameDataSet getDataSet() {
|
public GameDataSet getDataSet() {
|
||||||
@@ -132,18 +131,20 @@ public abstract class JSONElement extends GameDataElement {
|
|||||||
double a = 1;
|
double a = 1;
|
||||||
try {
|
try {
|
||||||
a = Integer.parseInt(s.substring(0, c));
|
a = Integer.parseInt(s.substring(0, c));
|
||||||
} catch (NumberFormatException nfe) {}
|
} catch (NumberFormatException nfe) {
|
||||||
|
}
|
||||||
double b = 100;
|
double b = 100;
|
||||||
try {
|
try {
|
||||||
b = Integer.parseInt(s.substring(c + 1));
|
b = Integer.parseInt(s.substring(c + 1));
|
||||||
} catch (NumberFormatException nfe) {}
|
} catch (NumberFormatException nfe) {
|
||||||
return a/b;
|
|
||||||
}
|
}
|
||||||
else {
|
return a / b;
|
||||||
|
} else {
|
||||||
double a = 10;
|
double a = 10;
|
||||||
try {
|
try {
|
||||||
a = Double.parseDouble(s);
|
a = Double.parseDouble(s);
|
||||||
} catch (NumberFormatException nfe) {}
|
} catch (NumberFormatException nfe) {
|
||||||
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.gpl.rpg.atcontentstudio.model.gamedata.Common.*;
|
||||||
|
|
||||||
public class NPC extends JSONElement {
|
public class NPC extends JSONElement {
|
||||||
|
|
||||||
@@ -47,6 +47,8 @@ public class NPC extends JSONElement {
|
|||||||
public Integer block_chance = null;
|
public Integer block_chance = null;
|
||||||
public Integer damage_resistance = null;
|
public Integer damage_resistance = null;
|
||||||
public HitEffect hit_effect = null;
|
public HitEffect hit_effect = null;
|
||||||
|
public HitReceivedEffect hit_received_effect = null;
|
||||||
|
public DeathEffect death_effect = null;
|
||||||
|
|
||||||
//Available from linked state
|
//Available from linked state
|
||||||
public Dialogue dialogue = null;
|
public Dialogue dialogue = null;
|
||||||
@@ -71,28 +73,6 @@ public class NPC extends JSONElement {
|
|||||||
wholeMap
|
wholeMap
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class HitEffect {
|
|
||||||
//Available from parsed state
|
|
||||||
public Integer hp_boost_min = null;
|
|
||||||
public Integer hp_boost_max = null;
|
|
||||||
public Integer ap_boost_min = null;
|
|
||||||
public Integer ap_boost_max = null;
|
|
||||||
public List<TimedConditionEffect> conditions_source = null;
|
|
||||||
public List<TimedConditionEffect> conditions_target = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TimedConditionEffect {
|
|
||||||
//Available from parsed state
|
|
||||||
public Integer magnitude = null;
|
|
||||||
public String condition_id = null;
|
|
||||||
public Integer duration = null;
|
|
||||||
public Double chance = null;
|
|
||||||
|
|
||||||
//Available from linked state
|
|
||||||
public ActorCondition condition = null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDesc() {
|
public String getDesc() {
|
||||||
return (needsSaving() ? "*" : "") + name + " (" + id + ")";
|
return (needsSaving() ? "*" : "") + name + " (" + id + ")";
|
||||||
@@ -165,8 +145,10 @@ public class NPC extends JSONElement {
|
|||||||
this.max_ap = JSONElement.getInteger((Number) npcJson.get("maxAP"));
|
this.max_ap = JSONElement.getInteger((Number) npcJson.get("maxAP"));
|
||||||
this.move_cost = JSONElement.getInteger((Number) npcJson.get("moveCost"));
|
this.move_cost = JSONElement.getInteger((Number) npcJson.get("moveCost"));
|
||||||
this.unique = JSONElement.getInteger((Number) npcJson.get("unique"));
|
this.unique = JSONElement.getInteger((Number) npcJson.get("unique"));
|
||||||
if (npcJson.get("monsterClass") != null) this.monster_class = MonsterClass.valueOf((String) npcJson.get("monsterClass"));
|
if (npcJson.get("monsterClass") != null)
|
||||||
if (npcJson.get("movementAggressionType") != null) this.movement_type = MovementType.valueOf((String) npcJson.get("movementAggressionType"));
|
this.monster_class = MonsterClass.valueOf((String) npcJson.get("monsterClass"));
|
||||||
|
if (npcJson.get("movementAggressionType") != null)
|
||||||
|
this.movement_type = MovementType.valueOf((String) npcJson.get("movementAggressionType"));
|
||||||
if (npcJson.get("attackDamage") != null) {
|
if (npcJson.get("attackDamage") != null) {
|
||||||
this.attack_damage_min = JSONElement.getInteger((Number) (((Map) npcJson.get("attackDamage")).get("min")));
|
this.attack_damage_min = JSONElement.getInteger((Number) (((Map) npcJson.get("attackDamage")).get("min")));
|
||||||
this.attack_damage_max = JSONElement.getInteger((Number) (((Map) npcJson.get("attackDamage")).get("max")));
|
this.attack_damage_max = JSONElement.getInteger((Number) (((Map) npcJson.get("attackDamage")).get("max")));
|
||||||
@@ -180,93 +162,49 @@ public class NPC extends JSONElement {
|
|||||||
this.critical_skill = JSONElement.getInteger((Number) npcJson.get("criticalSkill"));
|
this.critical_skill = JSONElement.getInteger((Number) npcJson.get("criticalSkill"));
|
||||||
//TODO correct game data, to unify format.
|
//TODO correct game data, to unify format.
|
||||||
// this.critical_multiplier = JSONElement.getDouble((Number) npcJson.get("criticalMultiplier"));
|
// this.critical_multiplier = JSONElement.getDouble((Number) npcJson.get("criticalMultiplier"));
|
||||||
if (npcJson.get("criticalMultiplier") != null) this.critical_multiplier = JSONElement.getDouble(Double.parseDouble(npcJson.get("criticalMultiplier").toString()));
|
if (npcJson.get("criticalMultiplier") != null)
|
||||||
|
this.critical_multiplier = JSONElement.getDouble(Double.parseDouble(npcJson.get("criticalMultiplier").toString()));
|
||||||
|
|
||||||
this.block_chance = JSONElement.getInteger((Number) npcJson.get("blockChance"));
|
this.block_chance = JSONElement.getInteger((Number) npcJson.get("blockChance"));
|
||||||
this.damage_resistance = JSONElement.getInteger((Number) npcJson.get("damageResistance"));
|
this.damage_resistance = JSONElement.getInteger((Number) npcJson.get("damageResistance"));
|
||||||
|
|
||||||
Map hitEffect = (Map) npcJson.get("hitEffect");
|
Map hitEffect = (Map) npcJson.get("hitEffect");
|
||||||
if (hitEffect != null) {
|
if (hitEffect != null) {
|
||||||
this.hit_effect = new HitEffect();
|
this.hit_effect = parseHitEffect(hitEffect);
|
||||||
if (hitEffect.get("increaseCurrentHP") != null) {
|
|
||||||
this.hit_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map)hitEffect.get("increaseCurrentHP")).get("max")));
|
|
||||||
this.hit_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map)hitEffect.get("increaseCurrentHP")).get("min")));
|
|
||||||
}
|
|
||||||
if (hitEffect.get("increaseCurrentAP") != null) {
|
|
||||||
this.hit_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)hitEffect.get("increaseCurrentAP")).get("max")));
|
|
||||||
this.hit_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)hitEffect.get("increaseCurrentAP")).get("min")));
|
|
||||||
}
|
|
||||||
List conditionsSourceJson = (List) hitEffect.get("conditionsSource");
|
|
||||||
if (conditionsSourceJson != null && !conditionsSourceJson.isEmpty()) {
|
|
||||||
this.hit_effect.conditions_source = new ArrayList<NPC.TimedConditionEffect>();
|
|
||||||
for (Object conditionJsonObj : conditionsSourceJson) {
|
|
||||||
Map conditionJson = (Map)conditionJsonObj;
|
|
||||||
TimedConditionEffect condition = new TimedConditionEffect();
|
|
||||||
condition.condition_id = (String) conditionJson.get("condition");
|
|
||||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
|
||||||
condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration"));
|
|
||||||
if (conditionJson.get("chance") != null) condition.chance = JSONElement.parseChance(conditionJson.get("chance").toString());
|
|
||||||
this.hit_effect.conditions_source.add(condition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List conditionsTargetJson = (List) hitEffect.get("conditionsTarget");
|
|
||||||
if (conditionsTargetJson != null && !conditionsTargetJson.isEmpty()) {
|
|
||||||
this.hit_effect.conditions_target = new ArrayList<NPC.TimedConditionEffect>();
|
|
||||||
for (Object conditionJsonObj : conditionsTargetJson) {
|
|
||||||
Map conditionJson = (Map)conditionJsonObj;
|
|
||||||
TimedConditionEffect condition = new TimedConditionEffect();
|
|
||||||
condition.condition_id = (String) conditionJson.get("condition");
|
|
||||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
|
||||||
condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration"));
|
|
||||||
if (conditionJson.get("chance") != null) condition.chance = JSONElement.parseChance(conditionJson.get("chance").toString());
|
|
||||||
this.hit_effect.conditions_target.add(condition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map hitReceivedEffect = (Map) npcJson.get("hitReceivedEffect");
|
||||||
|
if (hitReceivedEffect != null) {
|
||||||
|
this.hit_received_effect = parseHitReceivedEffect(hitReceivedEffect);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map deathEffect = (Map) npcJson.get("deathEffect");
|
||||||
|
if (deathEffect != null) {
|
||||||
|
this.death_effect = parseDeathEffect(deathEffect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void link() {
|
public void link() {
|
||||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
if (shouldSkipParseOrLink()) {
|
||||||
//This type of state is unrelated to parsing/linking.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.state == State.init) {
|
|
||||||
//Not parsed yet.
|
|
||||||
this.parse();
|
|
||||||
} else if (this.state == State.linked) {
|
|
||||||
//Already linked.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ensureParseIfNeeded();
|
||||||
Project proj = getProject();
|
Project proj = getProject();
|
||||||
if (proj == null) {
|
if (proj == null) {
|
||||||
Notification.addError("Error linking item " + id + ". No parent project found.");
|
Notification.addError("Error linking item " + id + ". No parent project found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.icon_id != null) {
|
linkIcon(proj, this.icon_id, this);
|
||||||
String spritesheetId = this.icon_id.split(":")[0];
|
|
||||||
proj.getSpritesheet(spritesheetId).addBacklink(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.dialogue_id != null) this.dialogue = proj.getDialogue(this.dialogue_id);
|
if (this.dialogue_id != null) this.dialogue = proj.getDialogue(this.dialogue_id);
|
||||||
if (this.dialogue != null) this.dialogue.addBacklink(this);
|
if (this.dialogue != null) this.dialogue.addBacklink(this);
|
||||||
|
|
||||||
if (this.droplist_id != null) this.droplist = proj.getDroplist(this.droplist_id);
|
if (this.droplist_id != null) this.droplist = proj.getDroplist(this.droplist_id);
|
||||||
if (this.droplist != null) this.droplist.addBacklink(this);
|
if (this.droplist != null) this.droplist.addBacklink(this);
|
||||||
|
|
||||||
if (this.hit_effect != null && this.hit_effect.conditions_source != null) {
|
linkEffects(this.hit_effect, proj, this);
|
||||||
for (TimedConditionEffect ce : this.hit_effect.conditions_source) {
|
linkEffects(this.hit_received_effect, proj, this);
|
||||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
linkEffects(this.death_effect, proj, this);
|
||||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.hit_effect != null && this.hit_effect.conditions_target != null) {
|
|
||||||
for (TimedConditionEffect ce : this.hit_effect.conditions_target) {
|
|
||||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
|
||||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.state = State.linked;
|
this.state = State.linked;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,40 +246,15 @@ public class NPC extends JSONElement {
|
|||||||
clone.faction_id = this.faction_id;
|
clone.faction_id = this.faction_id;
|
||||||
if (this.hit_effect != null) {
|
if (this.hit_effect != null) {
|
||||||
clone.hit_effect = new HitEffect();
|
clone.hit_effect = new HitEffect();
|
||||||
clone.hit_effect.ap_boost_max = this.hit_effect.ap_boost_max;
|
copyHitEffectValues(clone.hit_effect, this.hit_effect, clone);
|
||||||
clone.hit_effect.ap_boost_min = this.hit_effect.ap_boost_min;
|
|
||||||
clone.hit_effect.hp_boost_max = this.hit_effect.hp_boost_max;
|
|
||||||
clone.hit_effect.hp_boost_min = this.hit_effect.hp_boost_min;
|
|
||||||
if (this.hit_effect.conditions_source != null) {
|
|
||||||
clone.hit_effect.conditions_source = new ArrayList<TimedConditionEffect>();
|
|
||||||
for (TimedConditionEffect c : this.hit_effect.conditions_source) {
|
|
||||||
TimedConditionEffect cclone = new TimedConditionEffect();
|
|
||||||
cclone.magnitude = c.magnitude;
|
|
||||||
cclone.condition_id = c.condition_id;
|
|
||||||
cclone.condition = c.condition;
|
|
||||||
cclone.chance = c.chance;
|
|
||||||
cclone.duration = c.duration;
|
|
||||||
if (cclone.condition != null) {
|
|
||||||
cclone.condition.addBacklink(clone);
|
|
||||||
}
|
|
||||||
clone.hit_effect.conditions_source.add(cclone);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.hit_effect.conditions_target != null) {
|
|
||||||
clone.hit_effect.conditions_target = new ArrayList<TimedConditionEffect>();
|
|
||||||
for (TimedConditionEffect c : this.hit_effect.conditions_target) {
|
|
||||||
TimedConditionEffect cclone = new TimedConditionEffect();
|
|
||||||
cclone.magnitude = c.magnitude;
|
|
||||||
cclone.condition_id = c.condition_id;
|
|
||||||
cclone.condition = c.condition;
|
|
||||||
cclone.chance = c.chance;
|
|
||||||
cclone.duration = c.duration;
|
|
||||||
if (cclone.condition != null) {
|
|
||||||
cclone.condition.addBacklink(clone);
|
|
||||||
}
|
|
||||||
clone.hit_effect.conditions_target.add(cclone);
|
|
||||||
}
|
}
|
||||||
|
if (this.hit_received_effect != null) {
|
||||||
|
clone.hit_received_effect = new HitReceivedEffect();
|
||||||
|
copyHitReceivedEffectValues(clone.hit_received_effect, this.hit_received_effect, clone);
|
||||||
}
|
}
|
||||||
|
if (this.death_effect != null) {
|
||||||
|
clone.death_effect = new DeathEffect();
|
||||||
|
copyDeathEffectValues(clone.death_effect, this.death_effect, clone);
|
||||||
}
|
}
|
||||||
clone.max_ap = this.max_ap;
|
clone.max_ap = this.max_ap;
|
||||||
clone.max_hp = this.max_hp;
|
clone.max_hp = this.max_hp;
|
||||||
@@ -365,23 +278,9 @@ public class NPC extends JSONElement {
|
|||||||
this.droplist = (Droplist) newOne;
|
this.droplist = (Droplist) newOne;
|
||||||
if (newOne != null) newOne.addBacklink(this);
|
if (newOne != null) newOne.addBacklink(this);
|
||||||
} else {
|
} else {
|
||||||
if (this.hit_effect != null && this.hit_effect.conditions_source != null) {
|
if (this.hit_effect != null) {
|
||||||
for (TimedConditionEffect tce : this.hit_effect.conditions_source) {
|
actorConditionElementChanged(this.hit_effect.conditions_source, oldOne, newOne, this);
|
||||||
if (tce.condition == oldOne) {
|
actorConditionElementChanged(this.hit_effect.conditions_target, oldOne, newOne, this);
|
||||||
oldOne.removeBacklink(this);
|
|
||||||
tce.condition = (ActorCondition) newOne;
|
|
||||||
if (newOne != null) newOne.addBacklink(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.hit_effect != null && this.hit_effect.conditions_target != null) {
|
|
||||||
for (TimedConditionEffect tce : this.hit_effect.conditions_target) {
|
|
||||||
if (tce.condition == oldOne) {
|
|
||||||
oldOne.removeBacklink(this);
|
|
||||||
tce.condition = (ActorCondition) newOne;
|
|
||||||
if (newOne != null) newOne.addBacklink(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -393,21 +292,14 @@ public class NPC extends JSONElement {
|
|||||||
Map npcJson = new LinkedHashMap();
|
Map npcJson = new LinkedHashMap();
|
||||||
npcJson.put("id", this.id);
|
npcJson.put("id", this.id);
|
||||||
if (this.name != null) npcJson.put("name", this.name);
|
if (this.name != null) npcJson.put("name", this.name);
|
||||||
if (this.icon_id != null) npcJson.put("iconID", this.icon_id);
|
writeIconToMap(npcJson, this.icon_id);
|
||||||
if (this.max_hp != null) npcJson.put("maxHP", this.max_hp);
|
if (this.max_hp != null) npcJson.put("maxHP", this.max_hp);
|
||||||
if (this.max_ap != null) npcJson.put("maxAP", this.max_ap);
|
if (this.max_ap != null) npcJson.put("maxAP", this.max_ap);
|
||||||
if (this.move_cost != null) npcJson.put("moveCost", this.move_cost);
|
if (this.move_cost != null) npcJson.put("moveCost", this.move_cost);
|
||||||
if (this.unique != null) npcJson.put("unique", this.unique);
|
if (this.unique != null) npcJson.put("unique", this.unique);
|
||||||
if (this.monster_class != null) npcJson.put("monsterClass", this.monster_class.toString());
|
if (this.monster_class != null) npcJson.put("monsterClass", this.monster_class.toString());
|
||||||
if (this.movement_type != null) npcJson.put("movementAggressionType", this.movement_type.toString());
|
if (this.movement_type != null) npcJson.put("movementAggressionType", this.movement_type.toString());
|
||||||
if (this.attack_damage_min != null || this.attack_damage_max != null) {
|
writeMinMaxToMap(npcJson, "attackDamage", this.attack_damage_min, attack_damage_max, 0);
|
||||||
Map adJson = new LinkedHashMap();
|
|
||||||
npcJson.put("attackDamage", adJson);
|
|
||||||
if (this.attack_damage_min != null) adJson.put("min", this.attack_damage_min);
|
|
||||||
else adJson.put("min", 0);
|
|
||||||
if (this.attack_damage_max != null) adJson.put("max", this.attack_damage_max);
|
|
||||||
else adJson.put("max", 0);
|
|
||||||
}
|
|
||||||
if (this.spawngroup_id != null) npcJson.put("spawnGroup", this.spawngroup_id);
|
if (this.spawngroup_id != null) npcJson.put("spawnGroup", this.spawngroup_id);
|
||||||
if (this.faction_id != null) npcJson.put("faction", this.faction_id);
|
if (this.faction_id != null) npcJson.put("faction", this.faction_id);
|
||||||
if (this.dialogue != null) {
|
if (this.dialogue != null) {
|
||||||
@@ -426,58 +318,9 @@ public class NPC extends JSONElement {
|
|||||||
if (this.critical_multiplier != null) npcJson.put("criticalMultiplier", this.critical_multiplier);
|
if (this.critical_multiplier != null) npcJson.put("criticalMultiplier", this.critical_multiplier);
|
||||||
if (this.block_chance != null) npcJson.put("blockChance", this.block_chance);
|
if (this.block_chance != null) npcJson.put("blockChance", this.block_chance);
|
||||||
if (this.damage_resistance != null) npcJson.put("damageResistance", this.damage_resistance);
|
if (this.damage_resistance != null) npcJson.put("damageResistance", this.damage_resistance);
|
||||||
if (this.hit_effect != null) {
|
writeHitEffectToMap(npcJson, this.hit_effect, "hitEffect");
|
||||||
Map hitEffectJson = new LinkedHashMap();
|
writeHitReceivedEffectToMap(npcJson, this.hit_received_effect, "hitReceivedEffect");
|
||||||
npcJson.put("hitEffect", hitEffectJson);
|
writeDeathEffectToMap(npcJson, this.death_effect, "deathEffect");
|
||||||
if (this.hit_effect.hp_boost_min != null || this.hit_effect.hp_boost_max != null) {
|
|
||||||
Map hpJson = new LinkedHashMap();
|
|
||||||
hitEffectJson.put("increaseCurrentHP", hpJson);
|
|
||||||
if (this.hit_effect.hp_boost_min != null) hpJson.put("min", this.hit_effect.hp_boost_min);
|
|
||||||
else hpJson.put("min", 0);
|
|
||||||
if (this.hit_effect.hp_boost_max != null) hpJson.put("max", this.hit_effect.hp_boost_max);
|
|
||||||
else hpJson.put("max", 0);
|
|
||||||
}
|
|
||||||
if (this.hit_effect.ap_boost_min != null || this.hit_effect.ap_boost_max != null) {
|
|
||||||
Map apJson = new LinkedHashMap();
|
|
||||||
hitEffectJson.put("increaseCurrentAP", apJson);
|
|
||||||
if (this.hit_effect.ap_boost_min != null) apJson.put("min", this.hit_effect.ap_boost_min);
|
|
||||||
else apJson.put("min", 0);
|
|
||||||
if (this.hit_effect.ap_boost_max != null) apJson.put("max", this.hit_effect.ap_boost_max);
|
|
||||||
else apJson.put("max", 0);
|
|
||||||
}
|
|
||||||
if (this.hit_effect.conditions_source != null) {
|
|
||||||
List conditionsSourceJson = new ArrayList();
|
|
||||||
hitEffectJson.put("conditionsSource", conditionsSourceJson);
|
|
||||||
for (TimedConditionEffect condition : this.hit_effect.conditions_source) {
|
|
||||||
Map conditionJson = new LinkedHashMap();
|
|
||||||
conditionsSourceJson.add(conditionJson);
|
|
||||||
if (condition.condition != null) {
|
|
||||||
conditionJson.put("condition", condition.condition.id);
|
|
||||||
} else if (condition.condition_id != null) {
|
|
||||||
conditionJson.put("condition", condition.condition_id);
|
|
||||||
}
|
|
||||||
if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude);
|
|
||||||
if (condition.duration != null) conditionJson.put("duration", condition.duration);
|
|
||||||
if (condition.chance != null) conditionJson.put("chance", JSONElement.printJsonChance(condition.chance));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.hit_effect.conditions_target != null) {
|
|
||||||
List conditionsTargetJson = new ArrayList();
|
|
||||||
hitEffectJson.put("conditionsTarget", conditionsTargetJson);
|
|
||||||
for (TimedConditionEffect condition : this.hit_effect.conditions_target) {
|
|
||||||
Map conditionJson = new LinkedHashMap();
|
|
||||||
conditionsTargetJson.add(conditionJson);
|
|
||||||
if (condition.condition != null) {
|
|
||||||
conditionJson.put("condition", condition.condition.id);
|
|
||||||
} else if (condition.condition_id != null) {
|
|
||||||
conditionJson.put("condition", condition.condition_id);
|
|
||||||
}
|
|
||||||
if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude);
|
|
||||||
if (condition.duration != null) conditionJson.put("duration", condition.duration);
|
|
||||||
if (condition.chance != null) conditionJson.put("chance", JSONElement.printJsonChance(condition.chance));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return npcJson;
|
return npcJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,7 +344,8 @@ public class NPC extends JSONElement {
|
|||||||
avgCrit = (double) (critical_skill / 100.0) * critical_multiplier;
|
avgCrit = (double) (critical_skill / 100.0) * critical_multiplier;
|
||||||
}
|
}
|
||||||
double avgAttackHP = attacksPerTurn * ((double) (attack_chance != null ? attack_chance : 0) / 100.0) * avgDamagePotential * (1 + avgCrit);
|
double avgAttackHP = attacksPerTurn * ((double) (attack_chance != null ? attack_chance : 0) / 100.0) * avgDamagePotential * (1 + avgCrit);
|
||||||
double avgDefenseHP = ((max_hp != null ? max_hp : 1) * (1 + ((double)(block_chance != null ? block_chance : 0) / 100.0))) + ( EXP_FACTOR_DAMAGERESISTANCE * (damage_resistance != null ? damage_resistance : 0));
|
double avgDefenseHP = ((max_hp != null ? max_hp : 1) * (1 + ((double) (block_chance != null ? block_chance : 0) / 100.0))) +
|
||||||
|
(EXP_FACTOR_DAMAGERESISTANCE * (damage_resistance != null ? damage_resistance : 0));
|
||||||
double attackConditionBonus = 0;
|
double attackConditionBonus = 0;
|
||||||
if (hit_effect != null && hit_effect.conditions_target != null && hit_effect.conditions_target.size() > 0) {
|
if (hit_effect != null && hit_effect.conditions_target != null && hit_effect.conditions_target.size() > 0) {
|
||||||
attackConditionBonus = 50;
|
attackConditionBonus = 50;
|
||||||
@@ -509,7 +353,7 @@ public class NPC extends JSONElement {
|
|||||||
double experience = (((avgAttackHP * 3) + avgDefenseHP) * EXP_FACTOR_SCALING) + attackConditionBonus;
|
double experience = (((avgAttackHP * 3) + avgDefenseHP) * EXP_FACTOR_SCALING) + attackConditionBonus;
|
||||||
|
|
||||||
return new Double(Math.ceil(experience)).intValue();
|
return new Double(Math.ceil(experience)).intValue();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
import java.awt.Image;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||||
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
@@ -10,14 +17,6 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
|
||||||
|
|
||||||
public class Quest extends JSONElement {
|
public class Quest extends JSONElement {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2004839647483250099L;
|
private static final long serialVersionUID = 2004839647483250099L;
|
||||||
@@ -99,8 +98,8 @@ public class Quest extends JSONElement {
|
|||||||
public void parse(Map questJson) {
|
public void parse(Map questJson) {
|
||||||
this.visible_in_log = JSONElement.getInteger((Number) questJson.get("showInLog"));
|
this.visible_in_log = JSONElement.getInteger((Number) questJson.get("showInLog"));
|
||||||
List questStagesJson = (List) questJson.get("stages");
|
List questStagesJson = (List) questJson.get("stages");
|
||||||
if (questStagesJson != null && !questStagesJson.isEmpty()) {
|
|
||||||
this.stages = new ArrayList<QuestStage>();
|
this.stages = new ArrayList<QuestStage>();
|
||||||
|
if (questStagesJson != null && !questStagesJson.isEmpty()) {
|
||||||
for (Object questStageJsonObj : questStagesJson) {
|
for (Object questStageJsonObj : questStagesJson) {
|
||||||
Map questStageJson = (Map) questStageJsonObj;
|
Map questStageJson = (Map) questStageJsonObj;
|
||||||
QuestStage questStage = new QuestStage(this);
|
QuestStage questStage = new QuestStage(this);
|
||||||
@@ -113,17 +112,10 @@ public class Quest extends JSONElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void link() {
|
public void link() {
|
||||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
if (shouldSkipParseOrLink()) {
|
||||||
//This type of state is unrelated to parsing/linking.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.state == State.init) {
|
|
||||||
//Not parsed yet.
|
|
||||||
this.parse();
|
|
||||||
} else if (this.state == State.linked) {
|
|
||||||
//Already linked.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ensureParseIfNeeded();
|
||||||
|
|
||||||
for (QuestStage stage : stages) {
|
for (QuestStage stage : stages) {
|
||||||
stage.link();
|
stage.link();
|
||||||
@@ -194,5 +186,4 @@ public class Quest extends JSONElement {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class QuestStage extends JSONElement {
|
public class QuestStage extends JSONElement {
|
||||||
|
|
||||||
private static final long serialVersionUID = 8313645819951513431L;
|
private static final long serialVersionUID = 8313645819951513431L;
|
||||||
@@ -59,17 +59,10 @@ public class QuestStage extends JSONElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void link() {
|
public void link() {
|
||||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
if (shouldSkipParseOrLink()) {
|
||||||
//This type of state is unrelated to parsing/linking.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.state == State.init) {
|
|
||||||
//Not parsed yet.
|
|
||||||
this.parse();
|
|
||||||
} else if (this.state == State.linked) {
|
|
||||||
//Already linked.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ensureParseIfNeeded();
|
||||||
|
|
||||||
//Nothing to link to :D
|
//Nothing to link to :D
|
||||||
this.state = State.linked;
|
this.state = State.linked;
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||||
|
|
||||||
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
|
||||||
|
|
||||||
public class Requirement extends JSONElement {
|
public class Requirement extends JSONElement {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7295593297142310955L;
|
private static final long serialVersionUID = 7295593297142310955L;
|
||||||
@@ -26,10 +26,13 @@ public class Requirement extends JSONElement {
|
|||||||
countedItemTypes.add(RequirementType.inventoryRemove);
|
countedItemTypes.add(RequirementType.inventoryRemove);
|
||||||
countedItemTypes.add(RequirementType.inventoryKeep);
|
countedItemTypes.add(RequirementType.inventoryKeep);
|
||||||
countedItemTypes.add(RequirementType.usedItem);
|
countedItemTypes.add(RequirementType.usedItem);
|
||||||
|
countedItemTypes.add(RequirementType.wear);
|
||||||
|
countedItemTypes.add(RequirementType.wearRemove);
|
||||||
COMPATIBLE_TYPES.put(RequirementType.inventoryRemove, countedItemTypes);
|
COMPATIBLE_TYPES.put(RequirementType.inventoryRemove, countedItemTypes);
|
||||||
COMPATIBLE_TYPES.put(RequirementType.inventoryKeep, countedItemTypes);
|
COMPATIBLE_TYPES.put(RequirementType.inventoryKeep, countedItemTypes);
|
||||||
COMPATIBLE_TYPES.put(RequirementType.usedItem, countedItemTypes);
|
COMPATIBLE_TYPES.put(RequirementType.usedItem, countedItemTypes);
|
||||||
|
COMPATIBLE_TYPES.put(RequirementType.wear, countedItemTypes);
|
||||||
|
COMPATIBLE_TYPES.put(RequirementType.wearRemove, countedItemTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Available from parsed state
|
//Available from parsed state
|
||||||
@@ -53,12 +56,51 @@ public class Requirement extends JSONElement {
|
|||||||
usedItem,
|
usedItem,
|
||||||
spentGold,
|
spentGold,
|
||||||
consumedBonemeals,
|
consumedBonemeals,
|
||||||
hasActorCondition
|
hasActorCondition,
|
||||||
|
factionScore,
|
||||||
|
random,
|
||||||
|
factionScoreEquals,
|
||||||
|
wearRemove,
|
||||||
|
date,
|
||||||
|
dateEquals,
|
||||||
|
time,
|
||||||
|
timeEquals
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SkillID {
|
||||||
|
weaponChance, weaponDmg, barter, dodge, barkSkin, moreCriticals, betterCriticals, speed // Raises max ap
|
||||||
|
, coinfinder, moreExp, cleave // +10ap on kill
|
||||||
|
, eater // +1hp per kill
|
||||||
|
, fortitude // +N hp per levelup
|
||||||
|
, evasion // increase successful flee chance & reduce chance of monster attack
|
||||||
|
, regeneration // +N hp per round
|
||||||
|
, lowerExploss, magicfinder, resistanceMental // lowers chance to get negative active conditions by monsters (Mental like Dazed)
|
||||||
|
, resistancePhysical // lowers chance to get negative active conditions by monsters (Physical Capacity like Minor fatigue)
|
||||||
|
, resistanceBlood // lowers chance to get negative active conditions by monsters (Blood Disorder like Weak Poison)
|
||||||
|
, shadowBless, sporeImmunity, crit1 // lowers atk ability
|
||||||
|
, crit2 // lowers def ability ,rejuvenation // Reduces magnitudes of conditions
|
||||||
|
, rejuvenation // Reduces magnitudes of conditions
|
||||||
|
, taunt // Causes AP loss of attackers that miss
|
||||||
|
, concussion // AC loss for monsters with (AC-BC)>N
|
||||||
|
, weaponProficiencyDagger, weaponProficiency1hsword, weaponProficiency2hsword, weaponProficiencyAxe, weaponProficiencyBlunt, weaponProficiencyUnarmed, weaponProficiencyPole, armorProficiencyShield, armorProficiencyUnarmored, armorProficiencyLight, armorProficiencyHeavy, fightstyleDualWield, fightstyle2hand, fightstyleWeaponShield, specializationDualWield, specialization2hand, specializationWeaponShield
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDesc() {
|
public String getDesc() {
|
||||||
return ((negated != null && negated) ? "NOT " : "")+required_obj_id+(required_value == null ? "" : ":"+required_value.toString());
|
String obj_id = "";
|
||||||
|
if (required_obj_id != null) {
|
||||||
|
obj_id = required_obj_id;
|
||||||
|
if (type != null && type == RequirementType.random) {
|
||||||
|
obj_id = " Chance " + obj_id + (required_obj_id.contains("/") ? "" : "%");
|
||||||
|
} else {
|
||||||
|
obj_id += ":";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((negated != null && negated) ? "NOT " : "")
|
||||||
|
+ (type == null ? "" : type.toString() + ":")
|
||||||
|
+ obj_id
|
||||||
|
+ (required_value == null ? "" : required_value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -80,17 +122,10 @@ public class Requirement extends JSONElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void link() {
|
public void link() {
|
||||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
if (shouldSkipParseOrLink()) {
|
||||||
//This type of state is unrelated to parsing/linking.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.state == State.init) {
|
|
||||||
//Not parsed yet.
|
|
||||||
this.parse();
|
|
||||||
} else if (this.state == State.linked) {
|
|
||||||
//Already linked.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ensureParseIfNeeded();
|
||||||
Project proj = getProject();
|
Project proj = getProject();
|
||||||
if (proj == null) {
|
if (proj == null) {
|
||||||
Notification.addError("Error linking requirement " + getDesc() + ". No parent project found.");
|
Notification.addError("Error linking requirement " + getDesc() + ". No parent project found.");
|
||||||
@@ -104,6 +139,7 @@ public class Requirement extends JSONElement {
|
|||||||
case inventoryRemove:
|
case inventoryRemove:
|
||||||
case usedItem:
|
case usedItem:
|
||||||
case wear:
|
case wear:
|
||||||
|
case wearRemove:
|
||||||
this.required_obj = proj.getItem(required_obj_id);
|
this.required_obj = proj.getItem(required_obj_id);
|
||||||
break;
|
break;
|
||||||
case killedMonster:
|
case killedMonster:
|
||||||
@@ -123,6 +159,13 @@ public class Requirement extends JSONElement {
|
|||||||
case skillLevel:
|
case skillLevel:
|
||||||
case spentGold:
|
case spentGold:
|
||||||
case timerElapsed:
|
case timerElapsed:
|
||||||
|
case factionScore:
|
||||||
|
case factionScoreEquals:
|
||||||
|
case random:
|
||||||
|
case date:
|
||||||
|
case dateEquals:
|
||||||
|
case time:
|
||||||
|
case timeEquals:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.required_obj != null) this.required_obj.addBacklink((GameDataElement) this.parent);
|
if (this.required_obj != null) this.required_obj.addBacklink((GameDataElement) this.parent);
|
||||||
@@ -141,6 +184,7 @@ public class Requirement extends JSONElement {
|
|||||||
clone.state = this.state;
|
clone.state = this.state;
|
||||||
clone.required_obj_id = this.required_obj_id;
|
clone.required_obj_id = this.required_obj_id;
|
||||||
clone.required_value = this.required_value;
|
clone.required_value = this.required_value;
|
||||||
|
clone.negated = this.negated;
|
||||||
clone.required_obj = this.required_obj;
|
clone.required_obj = this.required_obj;
|
||||||
clone.type = this.type;
|
clone.type = this.type;
|
||||||
if (clone.required_obj != null && parent != null) {
|
if (clone.required_obj != null && parent != null) {
|
||||||
@@ -163,6 +207,7 @@ public class Requirement extends JSONElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProjectFilename() {
|
public String getProjectFilename() {
|
||||||
throw new Error("Thou shalt not reach this method.");
|
throw new Error("Thou shalt not reach this method.");
|
||||||
@@ -174,6 +219,11 @@ public class Requirement extends JSONElement {
|
|||||||
required_obj_id = null;
|
required_obj_id = null;
|
||||||
required_value = null;
|
required_value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (destType == RequirementType.random) {
|
||||||
|
required_obj_id = "50/100";
|
||||||
|
}
|
||||||
|
|
||||||
type = destType;
|
type = destType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Droplist;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.Droplist;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class ContainerArea extends MapObject {
|
public class ContainerArea extends MapObject {
|
||||||
|
|
||||||
public Droplist droplist = null;
|
public Droplist droplist = null;
|
||||||
|
|
||||||
public ContainerArea(tiled.core.MapObject obj) {}
|
public ContainerArea(tiled.core.MapObject obj) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void link() {
|
public void link() {
|
||||||
|
|||||||
@@ -1,44 +1,47 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class KeyArea extends MapObject {
|
public class KeyArea extends MapObject {
|
||||||
|
|
||||||
public String dialogue_id = null;
|
public String dialogue_id;
|
||||||
public Dialogue dialogue = null;
|
public Dialogue dialogue = null;
|
||||||
public Requirement requirement = null;
|
public Requirement requirement;
|
||||||
public boolean oldSchoolRequirement = true;
|
public boolean oldSchoolRequirement;
|
||||||
|
|
||||||
public KeyArea(tiled.core.MapObject obj) {
|
public KeyArea(tiled.core.MapObject obj) {
|
||||||
dialogue_id = obj.getProperties().getProperty("phrase");
|
dialogue_id = obj.getProperties().getProperty("phrase");
|
||||||
String requireType = obj.getProperties().getProperty("requireType");
|
String requireType = obj.getProperties().getProperty("requireType");
|
||||||
String requireId = obj.getProperties().getProperty("requireId");
|
String requireId = obj.getProperties().getProperty("requireId");
|
||||||
String requireValue = obj.getProperties().getProperty("requireValue");
|
String requireValue = obj.getProperties().getProperty("requireValue");
|
||||||
if (requireId == null) {
|
String requireNegation = obj.getProperties().getProperty("requireNegation");
|
||||||
|
oldSchoolRequirement = false;
|
||||||
|
if (requireType == null) {
|
||||||
String[] fields = obj.getName().split(":");
|
String[] fields = obj.getName().split(":");
|
||||||
if (fields.length == 2) {
|
if (fields.length == 2) {
|
||||||
requireType = Requirement.RequirementType.questProgress.toString();
|
requireType = Requirement.RequirementType.questProgress.toString();
|
||||||
requireValue = fields[1];
|
requireValue = fields[1];
|
||||||
requireId = fields[0];
|
requireId = fields[0];
|
||||||
|
oldSchoolRequirement = true;
|
||||||
} else if (fields.length == 3) {
|
} else if (fields.length == 3) {
|
||||||
requireValue = fields[2];
|
requireValue = fields[2];
|
||||||
requireType = fields[0];
|
requireType = fields[0];
|
||||||
requireId = fields[1];
|
requireId = fields[1];
|
||||||
}
|
|
||||||
oldSchoolRequirement = true;
|
oldSchoolRequirement = true;
|
||||||
} else {
|
}
|
||||||
oldSchoolRequirement = false;
|
|
||||||
}
|
}
|
||||||
requirement = new Requirement();
|
requirement = new Requirement();
|
||||||
if (requireType != null) requirement.type = Requirement.RequirementType.valueOf(requireType);
|
if (requireType != null) requirement.type = Requirement.RequirementType.valueOf(requireType);
|
||||||
requirement.required_obj_id = requireId;
|
requirement.required_obj_id = requireId;
|
||||||
if (requireValue != null) requirement.required_value = Integer.parseInt(requireValue);
|
if (requireValue != null) requirement.required_value = Integer.parseInt(requireValue);
|
||||||
|
if (requireNegation != null) requirement.negated = Boolean.parseBoolean(requireNegation);
|
||||||
requirement.state = GameDataElement.State.parsed;
|
requirement.state = GameDataElement.State.parsed;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,7 +79,7 @@ public class KeyArea extends MapObject {
|
|||||||
}
|
}
|
||||||
if (requirement != null) {
|
if (requirement != null) {
|
||||||
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
||||||
tmxObject.setName(requirement.required_obj_id+":"+Integer.toString(requirement.required_value));
|
tmxObject.setName(requirement.required_obj_id + ":" + ((requirement.required_value == null) ? "" : Integer.toString(requirement.required_value)));
|
||||||
} else {
|
} else {
|
||||||
if (requirement.type != null) {
|
if (requirement.type != null) {
|
||||||
tmxObject.getProperties().setProperty("requireType", requirement.type.toString());
|
tmxObject.getProperties().setProperty("requireType", requirement.type.toString());
|
||||||
@@ -89,13 +92,17 @@ public class KeyArea extends MapObject {
|
|||||||
if (requirement.required_value != null) {
|
if (requirement.required_value != null) {
|
||||||
tmxObject.getProperties().setProperty("requireValue", requirement.required_value.toString());
|
tmxObject.getProperties().setProperty("requireValue", requirement.required_value.toString());
|
||||||
}
|
}
|
||||||
|
if (requirement.negated != null) {
|
||||||
|
tmxObject.getProperties().setProperty("requireNegation", Boolean.toString(requirement.negated));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateNameFromRequirementChange() {
|
public void updateNameFromRequirementChange() {
|
||||||
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
||||||
name = requirement.required_obj_id+":"+Integer.toString(requirement.required_value);
|
name = (requirement.negated != null && requirement.negated) ? "NOT " : "" + requirement.required_obj_id + ":" + ((requirement.required_value == null) ? "" : Integer.toString(
|
||||||
|
requirement.required_value));
|
||||||
} else if (oldSchoolRequirement) {
|
} else if (oldSchoolRequirement) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
String futureName = requirement.type.toString() + "#" + Integer.toString(i);
|
String futureName = requirement.type.toString() + "#" + Integer.toString(i);
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
|
||||||
public class MapChange extends MapObject {
|
public class MapChange extends MapObject {
|
||||||
|
|
||||||
public String map_id = null;
|
public String map_id;
|
||||||
public TMXMap map = null;
|
public TMXMap map = null;
|
||||||
public String place_id = null;
|
public String place_id;
|
||||||
|
|
||||||
public MapChange(tiled.core.MapObject obj) {
|
public MapChange(tiled.core.MapObject obj) {
|
||||||
this.map_id = obj.getProperties().getProperty("map");
|
this.map_id = obj.getProperties().getProperty("map");
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public abstract class MapObject {
|
public abstract class MapObject {
|
||||||
|
|
||||||
public int x, y, w, h;
|
public int x, y, w, h;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
|
||||||
|
|
||||||
public class MapObjectGroup {
|
public class MapObjectGroup {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +1,49 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class ReplaceArea extends MapObject {
|
public class ReplaceArea extends MapObject {
|
||||||
|
|
||||||
public Requirement requirement = null;
|
public Requirement requirement;
|
||||||
public boolean oldSchoolRequirement = true;
|
public boolean oldSchoolRequirement = false;
|
||||||
|
|
||||||
public List<ReplaceArea.Replacement> replacements = null;
|
public List<ReplaceArea.Replacement> replacements = null;
|
||||||
|
|
||||||
public ReplaceArea(tiled.core.MapObject obj) {
|
public ReplaceArea(tiled.core.MapObject obj) {
|
||||||
// String requireType = obj.getProperties().getProperty("requireType");
|
String requireType = obj.getProperties().getProperty("requireType");
|
||||||
String requireId = obj.getProperties().getProperty("requireId");
|
String requireId = obj.getProperties().getProperty("requireId");
|
||||||
String requireValue = obj.getProperties().getProperty("requireValue");
|
String requireValue = obj.getProperties().getProperty("requireValue");
|
||||||
if (requireId == null) {
|
String requireNegation = obj.getProperties().getProperty("requireNegation");
|
||||||
|
if (requireType == null) {
|
||||||
String[] fields = obj.getName().split(":");
|
String[] fields = obj.getName().split(":");
|
||||||
if (fields.length == 2) {
|
if (fields.length == 2) {
|
||||||
// requireType = Requirement.RequirementType.questProgress.toString();
|
requireType = Requirement.RequirementType.questProgress.toString();
|
||||||
requireValue = fields[1];
|
requireValue = fields[1];
|
||||||
requireId = fields[0];
|
requireId = fields[0];
|
||||||
|
oldSchoolRequirement = true;
|
||||||
} /*else if (fields.length == 3) {
|
} /*else if (fields.length == 3) {
|
||||||
requireValue = fields[2];
|
requireValue = fields[2];
|
||||||
requireType = fields[0];
|
requireType = fields[0];
|
||||||
requireId = fields[1];
|
requireId = fields[1];
|
||||||
}*/
|
}*/
|
||||||
oldSchoolRequirement = true;
|
|
||||||
} else {
|
|
||||||
oldSchoolRequirement = false;
|
|
||||||
}
|
}
|
||||||
requirement = new Requirement();
|
requirement = new Requirement();
|
||||||
//Replace areas only support questProgress requirements ATM
|
if (requireType != null) requirement.type = Requirement.RequirementType.valueOf(requireType);
|
||||||
//requirement.type = Requirement.RequirementType.valueOf(requireType);
|
|
||||||
requirement.type = Requirement.RequirementType.questProgress;
|
|
||||||
requirement.required_obj_id = requireId;
|
requirement.required_obj_id = requireId;
|
||||||
if (requireValue != null) requirement.required_value = Integer.parseInt(requireValue);
|
if (requireValue != null) requirement.required_value = Integer.parseInt(requireValue);
|
||||||
|
if (requireNegation != null) requirement.negated = Boolean.parseBoolean(requireNegation);
|
||||||
requirement.state = GameDataElement.State.parsed;
|
requirement.state = GameDataElement.State.parsed;
|
||||||
|
|
||||||
|
|
||||||
for (Object s : obj.getProperties().keySet()) {
|
for (Object s : obj.getProperties().keySet()) {
|
||||||
|
if (!TMXMap.isPaintedLayerName(s.toString())) continue;
|
||||||
if (replacements == null) replacements = new ArrayList<ReplaceArea.Replacement>();
|
if (replacements == null) replacements = new ArrayList<ReplaceArea.Replacement>();
|
||||||
replacements.add(new Replacement(s.toString(), obj.getProperties().getProperty(s.toString())));
|
replacements.add(new Replacement(s.toString(), obj.getProperties().getProperty(s.toString())));
|
||||||
}
|
}
|
||||||
@@ -67,25 +66,11 @@ public class ReplaceArea extends MapObject {
|
|||||||
requirement.elementChanged(oldOne, newOne);
|
requirement.elementChanged(oldOne, newOne);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplaceArea.Replacement addReplacement(String source, String target) {
|
public ReplaceArea.Replacement createReplacement(String source, String target) {
|
||||||
Replacement repl = new Replacement(source, target);
|
Replacement repl = new Replacement(source, target);
|
||||||
addReplacement(repl);
|
|
||||||
return repl;
|
return repl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addReplacement(ReplaceArea.Replacement repl) {
|
|
||||||
if (replacements == null) replacements = new ArrayList<ReplaceArea.Replacement>();
|
|
||||||
replacements.add(repl);
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void removeReplacement(String source, String target) {
|
|
||||||
// replacedLayers.remove(source);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void removeReplacement(Replacement repl) {
|
|
||||||
replacements.remove(repl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void savePropertiesInTmxObject(tiled.core.MapObject tmxObject) {
|
public void savePropertiesInTmxObject(tiled.core.MapObject tmxObject) {
|
||||||
if (replacements != null) {
|
if (replacements != null) {
|
||||||
@@ -94,9 +79,11 @@ public class ReplaceArea extends MapObject {
|
|||||||
}
|
}
|
||||||
if (requirement != null) {
|
if (requirement != null) {
|
||||||
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
||||||
tmxObject.setName(requirement.required_obj_id+":"+Integer.toString(requirement.required_value));
|
tmxObject.setName(requirement.required_obj_id + ":" + ((requirement.required_value == null) ? "" : Integer.toString(requirement.required_value)));
|
||||||
} else {
|
} else {
|
||||||
|
if (requirement.type != null) {
|
||||||
tmxObject.getProperties().setProperty("requireType", requirement.type.toString());
|
tmxObject.getProperties().setProperty("requireType", requirement.type.toString());
|
||||||
|
}
|
||||||
if (requirement.required_obj != null) {
|
if (requirement.required_obj != null) {
|
||||||
tmxObject.getProperties().setProperty("requireId", requirement.required_obj.id);
|
tmxObject.getProperties().setProperty("requireId", requirement.required_obj.id);
|
||||||
} else if (requirement.required_obj_id != null) {
|
} else if (requirement.required_obj_id != null) {
|
||||||
@@ -105,6 +92,9 @@ public class ReplaceArea extends MapObject {
|
|||||||
if (requirement.required_value != null) {
|
if (requirement.required_value != null) {
|
||||||
tmxObject.getProperties().setProperty("requireValue", requirement.required_value.toString());
|
tmxObject.getProperties().setProperty("requireValue", requirement.required_value.toString());
|
||||||
}
|
}
|
||||||
|
if (requirement.negated != null) {
|
||||||
|
tmxObject.getProperties().setProperty("requireNegation", Boolean.toString(requirement.negated));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +102,8 @@ public class ReplaceArea extends MapObject {
|
|||||||
//Don't use yet !
|
//Don't use yet !
|
||||||
public void updateNameFromRequirementChange() {
|
public void updateNameFromRequirementChange() {
|
||||||
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
||||||
name = requirement.required_obj_id+":"+Integer.toString(requirement.required_value);
|
name = (requirement.negated != null && requirement.negated) ? "NOT " : "" + requirement.required_obj_id + ":" + ((requirement.required_value == null) ? "" : Integer.toString(
|
||||||
|
requirement.required_value));
|
||||||
} else if (oldSchoolRequirement) {
|
} else if (oldSchoolRequirement) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
String futureName = requirement.type.toString() + "#" + Integer.toString(i);
|
String futureName = requirement.type.toString() + "#" + Integer.toString(i);
|
||||||
@@ -126,6 +117,7 @@ public class ReplaceArea extends MapObject {
|
|||||||
|
|
||||||
public class Replacement {
|
public class Replacement {
|
||||||
public String sourceLayer, targetLayer;
|
public String sourceLayer, targetLayer;
|
||||||
|
|
||||||
public Replacement(String source, String target) {
|
public Replacement(String source, String target) {
|
||||||
this.sourceLayer = source;
|
this.sourceLayer = source;
|
||||||
this.targetLayer = target;
|
this.targetLayer = target;
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
|
||||||
public class RestArea extends MapObject {
|
public class RestArea extends MapObject {
|
||||||
|
|
||||||
public RestArea(tiled.core.MapObject obj) {}
|
public RestArea(tiled.core.MapObject obj) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void link() {}
|
public void link() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class ScriptArea extends MapObject {
|
public class ScriptArea extends MapObject {
|
||||||
|
|
||||||
public Dialogue dialogue = null;
|
public Dialogue dialogue = null;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class SignArea extends MapObject {
|
public class SignArea extends MapObject {
|
||||||
|
|
||||||
public Dialogue dialogue = null;
|
public Dialogue dialogue = null;
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.NPC;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.NPC;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SpawnArea extends MapObject {
|
public class SpawnArea extends MapObject {
|
||||||
|
|
||||||
public int quantity = 1;
|
public int quantity = 1;
|
||||||
public int spawnchance = 10;
|
public int respawnSpeed = 10;
|
||||||
public boolean active = true;
|
public boolean active = true;
|
||||||
|
public boolean ignoreAreas = false;
|
||||||
public String spawngroup_id;
|
public String spawngroup_id;
|
||||||
public List<NPC> spawnGroup = new ArrayList<NPC>();
|
public List<NPC> spawnGroup = new ArrayList<NPC>();
|
||||||
|
|
||||||
@@ -20,12 +21,15 @@ public class SpawnArea extends MapObject {
|
|||||||
if (obj.getProperties().getProperty("quantity") != null) {
|
if (obj.getProperties().getProperty("quantity") != null) {
|
||||||
this.quantity = Integer.parseInt(obj.getProperties().getProperty("quantity"));
|
this.quantity = Integer.parseInt(obj.getProperties().getProperty("quantity"));
|
||||||
}
|
}
|
||||||
if (obj.getProperties().getProperty("spawnchance") != null) {
|
if (obj.getProperties().getProperty("respawnspeed") != null) {
|
||||||
this.spawnchance = Integer.parseInt(obj.getProperties().getProperty("spawnchance"));
|
this.respawnSpeed = Integer.parseInt(obj.getProperties().getProperty("respawnspeed"));
|
||||||
}
|
}
|
||||||
if (obj.getProperties().getProperty("active") != null) {
|
if (obj.getProperties().getProperty("active") != null) {
|
||||||
this.active = Boolean.parseBoolean(obj.getProperties().getProperty("active"));
|
this.active = Boolean.parseBoolean(obj.getProperties().getProperty("active"));
|
||||||
}
|
}
|
||||||
|
if (obj.getProperties().getProperty("ignoreAreas") != null) {
|
||||||
|
this.ignoreAreas = Boolean.parseBoolean(obj.getProperties().getProperty("ignoreAreas"));
|
||||||
|
}
|
||||||
if (obj.getProperties().getProperty("spawngroup") != null) {
|
if (obj.getProperties().getProperty("spawngroup") != null) {
|
||||||
this.spawngroup_id = obj.getProperties().getProperty("spawngroup");
|
this.spawngroup_id = obj.getProperties().getProperty("spawngroup");
|
||||||
} else if (obj.getName() != null) {
|
} else if (obj.getName() != null) {
|
||||||
@@ -78,12 +82,14 @@ public class SpawnArea extends MapObject {
|
|||||||
if (quantity != 1) {
|
if (quantity != 1) {
|
||||||
tmxObject.getProperties().setProperty("quantity", Integer.toString(quantity));
|
tmxObject.getProperties().setProperty("quantity", Integer.toString(quantity));
|
||||||
}
|
}
|
||||||
if (spawnchance != 10) {
|
if (respawnSpeed != 10) {
|
||||||
tmxObject.getProperties().setProperty("spawnchance", Integer.toString(spawnchance));
|
tmxObject.getProperties().setProperty("respawnspeed", Integer.toString(respawnSpeed));
|
||||||
}
|
}
|
||||||
if (!this.active) {
|
if (!this.active) {
|
||||||
tmxObject.getProperties().setProperty("active", Boolean.toString(active));
|
tmxObject.getProperties().setProperty("active", Boolean.toString(active));
|
||||||
}
|
}
|
||||||
|
if (this.ignoreAreas) {
|
||||||
|
tmxObject.getProperties().setProperty("ignoreAreas", Boolean.toString(ignoreAreas));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,21 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
|
|
||||||
import tiled.io.TMXMapReader;
|
|
||||||
import tiled.io.TMXMapWriter;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.*;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.NPC;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.NPC;
|
||||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
import tiled.io.TMXMapReader;
|
||||||
|
import tiled.io.TMXMapWriter;
|
||||||
|
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
public class TMXMap extends GameDataElement {
|
public class TMXMap extends GameDataElement {
|
||||||
|
|
||||||
@@ -38,6 +24,7 @@ public class TMXMap extends GameDataElement {
|
|||||||
public static final String GROUND_LAYER_NAME = "Ground";
|
public static final String GROUND_LAYER_NAME = "Ground";
|
||||||
public static final String OBJECTS_LAYER_NAME = "Objects";
|
public static final String OBJECTS_LAYER_NAME = "Objects";
|
||||||
public static final String ABOVE_LAYER_NAME = "Above";
|
public static final String ABOVE_LAYER_NAME = "Above";
|
||||||
|
public static final String TOP_LAYER_NAME = "Top";
|
||||||
public static final String WALKABLE_LAYER_NAME = "Walkable";
|
public static final String WALKABLE_LAYER_NAME = "Walkable";
|
||||||
|
|
||||||
public enum ColorFilter {
|
public enum ColorFilter {
|
||||||
@@ -53,7 +40,7 @@ public class TMXMap extends GameDataElement {
|
|||||||
bluetint
|
bluetint
|
||||||
}
|
}
|
||||||
|
|
||||||
public File tmxFile = null;
|
public File tmxFile;
|
||||||
public tiled.core.Map tmxMap = null;
|
public tiled.core.Map tmxMap = null;
|
||||||
public Set<Spritesheet> usedSpritesheets = null;
|
public Set<Spritesheet> usedSpritesheets = null;
|
||||||
public List<MapObjectGroup> groups = null;
|
public List<MapObjectGroup> groups = null;
|
||||||
@@ -195,10 +182,12 @@ public class TMXMap extends GameDataElement {
|
|||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenRemoved(path);
|
parent.childrenRemoved(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyCreated() {
|
public void notifyCreated() {
|
||||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDesc() {
|
public String getDesc() {
|
||||||
return (needsSaving() ? "*" : "") + id;
|
return (needsSaving() ? "*" : "") + id;
|
||||||
@@ -213,14 +202,21 @@ public class TMXMap extends GameDataElement {
|
|||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return DefaultIcons.getTiledIconIcon();
|
return DefaultIcons.getTiledIconIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getLeafIcon() {
|
public Image getLeafIcon() {
|
||||||
return DefaultIcons.getTiledIconIcon();
|
return DefaultIcons.getTiledIconIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getClosedIcon() {return null;}
|
public Image getClosedIcon() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getOpenIcon() {return null;}
|
public Image getOpenIcon() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameDataSet getDataSet() {
|
public GameDataSet getDataSet() {
|
||||||
@@ -257,7 +253,7 @@ public class TMXMap extends GameDataElement {
|
|||||||
if (getDataType() == GameSource.Type.source) {
|
if (getDataType() == GameSource.Type.source) {
|
||||||
writer.writeMap(tmxMap, baos, tmxFile.getAbsolutePath());
|
writer.writeMap(tmxMap, baos, tmxFile.getAbsolutePath());
|
||||||
} else {
|
} else {
|
||||||
writer.writeMap(tmxMap, baos, getProject().baseContent.gameMaps.mapFolder.getAbsolutePath()+File.separator+"placeholder.tmx");
|
writer.writeMap(tmxMap, baos, ((TMXMapSet) this.parent).mapFolder.getAbsolutePath() + File.separator + "placeholder.tmx");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Notification.addError("Error while converting map " + getDesc() + " to XML: " + e.getMessage());
|
Notification.addError("Error while converting map " + getDesc() + " to XML: " + e.getMessage());
|
||||||
@@ -273,11 +269,12 @@ public class TMXMap extends GameDataElement {
|
|||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
if (writable) {
|
if (writable) {
|
||||||
|
String xml = toXml();
|
||||||
try {
|
try {
|
||||||
//TODO: check in fileutils, to test the workspace's filesystem once at startup, and figure out how many of these can occur, instead of hard-coded '2'
|
//TODO: check in fileutils, to test the workspace's filesystem once at startup, and figure out how many of these can occur, instead of hard-coded '2'
|
||||||
dismissNextChangeNotif += 2;
|
dismissNextChangeNotif += 2;
|
||||||
FileWriter w = new FileWriter(tmxFile);
|
FileWriter w = new FileWriter(tmxFile);
|
||||||
w.write(toXml());
|
w.write(xml);
|
||||||
w.close();
|
w.close();
|
||||||
this.state = State.saved;
|
this.state = State.saved;
|
||||||
changedOnDisk = false;
|
changedOnDisk = false;
|
||||||
@@ -397,6 +394,7 @@ public class TMXMap extends GameDataElement {
|
|||||||
return GROUND_LAYER_NAME.equalsIgnoreCase(name) ||
|
return GROUND_LAYER_NAME.equalsIgnoreCase(name) ||
|
||||||
OBJECTS_LAYER_NAME.equalsIgnoreCase(name) ||
|
OBJECTS_LAYER_NAME.equalsIgnoreCase(name) ||
|
||||||
ABOVE_LAYER_NAME.equalsIgnoreCase(name) ||
|
ABOVE_LAYER_NAME.equalsIgnoreCase(name) ||
|
||||||
|
TOP_LAYER_NAME.equalsIgnoreCase(name) ||
|
||||||
WALKABLE_LAYER_NAME.equalsIgnoreCase(name);
|
WALKABLE_LAYER_NAME.equalsIgnoreCase(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,11 +411,13 @@ public class TMXMap extends GameDataElement {
|
|||||||
if (((ContainerArea) o).droplist != null) ((ContainerArea) o).droplist.elementChanged(this, null);
|
if (((ContainerArea) o).droplist != null) ((ContainerArea) o).droplist.elementChanged(this, null);
|
||||||
} else if (o instanceof KeyArea) {
|
} else if (o instanceof KeyArea) {
|
||||||
if (((KeyArea) o).dialogue != null) ((KeyArea) o).dialogue.elementChanged(this, null);
|
if (((KeyArea) o).dialogue != null) ((KeyArea) o).dialogue.elementChanged(this, null);
|
||||||
if (((KeyArea)o).requirement != null && ((KeyArea)o).requirement.required_obj != null) ((KeyArea)o).requirement.required_obj.elementChanged(this, null);
|
if (((KeyArea) o).requirement != null && ((KeyArea) o).requirement.required_obj != null)
|
||||||
|
((KeyArea) o).requirement.required_obj.elementChanged(this, null);
|
||||||
} else if (o instanceof MapChange) {
|
} else if (o instanceof MapChange) {
|
||||||
if (((MapChange) o).map != null) ((MapChange) o).map.elementChanged(this, null);
|
if (((MapChange) o).map != null) ((MapChange) o).map.elementChanged(this, null);
|
||||||
} else if (o instanceof ReplaceArea) {
|
} else if (o instanceof ReplaceArea) {
|
||||||
if (((ReplaceArea)o).requirement != null && ((ReplaceArea)o).requirement.required_obj != null) ((ReplaceArea)o).requirement.required_obj.elementChanged(this, null);
|
if (((ReplaceArea) o).requirement != null && ((ReplaceArea) o).requirement.required_obj != null)
|
||||||
|
((ReplaceArea) o).requirement.required_obj.elementChanged(this, null);
|
||||||
} else if (o instanceof RestArea) {
|
} else if (o instanceof RestArea) {
|
||||||
} else if (o instanceof ScriptArea) {
|
} else if (o instanceof ScriptArea) {
|
||||||
if (((ScriptArea) o).dialogue != null) ((ScriptArea) o).dialogue.elementChanged(this, null);
|
if (((ScriptArea) o).dialogue != null) ((ScriptArea) o).dialogue.elementChanged(this, null);
|
||||||
@@ -458,6 +458,7 @@ public class TMXMap extends GameDataElement {
|
|||||||
|
|
||||||
public interface MapChangedOnDiskListener {
|
public interface MapChangedOnDiskListener {
|
||||||
public void mapChanged();
|
public void mapChanged();
|
||||||
|
|
||||||
public void mapReloaded();
|
public void mapReloaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,5 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.FileSystems;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.nio.file.StandardWatchEventKinds;
|
|
||||||
import java.nio.file.WatchEvent;
|
|
||||||
import java.nio.file.WatchKey;
|
|
||||||
import java.nio.file.WatchService;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
import com.gpl.rpg.atcontentstudio.Notification;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
@@ -28,6 +10,15 @@ import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
|||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||||
|
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class TMXMapSet implements ProjectTreeNode {
|
public class TMXMapSet implements ProjectTreeNode {
|
||||||
|
|
||||||
public static final String DEFAULT_REL_PATH_IN_SOURCE = "res" + File.separator + "xml" + File.separator;
|
public static final String DEFAULT_REL_PATH_IN_SOURCE = "res" + File.separator + "xml" + File.separator;
|
||||||
@@ -48,8 +39,7 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
this.parent = source;
|
this.parent = source;
|
||||||
if (source.type == GameSource.Type.source) {
|
if (source.type == GameSource.Type.source) {
|
||||||
this.mapFolder = new File(source.baseFolder, DEFAULT_REL_PATH_IN_SOURCE);
|
this.mapFolder = new File(source.baseFolder, DEFAULT_REL_PATH_IN_SOURCE);
|
||||||
}
|
} else if (source.type == GameSource.Type.created | source.type == GameSource.Type.altered) {
|
||||||
else if (source.type == GameSource.Type.created | source.type == GameSource.Type.altered) {
|
|
||||||
this.mapFolder = new File(source.baseFolder, DEFAULT_REL_PATH_IN_PROJECT);
|
this.mapFolder = new File(source.baseFolder, DEFAULT_REL_PATH_IN_PROJECT);
|
||||||
if (!this.mapFolder.exists()) {
|
if (!this.mapFolder.exists()) {
|
||||||
this.mapFolder.mkdirs();
|
this.mapFolder.mkdirs();
|
||||||
@@ -92,17 +82,20 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
});
|
});
|
||||||
if (source.type == GameSource.Type.created | source.type == GameSource.Type.altered) {
|
if (source.type == GameSource.Type.created | source.type == GameSource.Type.altered) {
|
||||||
final Path folderPath = Paths.get(mapFolder.getAbsolutePath());
|
final Path folderPath = Paths.get(mapFolder.getAbsolutePath());
|
||||||
Thread watcher = new Thread("Map folder watcher for "+source.type) {
|
Thread watcher = new Thread("Map folder watcher for " + getProject().name + "/" + source.type) {
|
||||||
public void run() {
|
public void run() {
|
||||||
WatchService watchService;
|
WatchService watchService;
|
||||||
|
|
||||||
while (getProject().open) {
|
while (getProject().open) {
|
||||||
try {
|
try {
|
||||||
watchService = FileSystems.getDefault().newWatchService();
|
watchService = FileSystems.getDefault().newWatchService();
|
||||||
WatchKey watchKey = folderPath.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
|
/*WatchKey watchKey = */
|
||||||
|
folderPath.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE);
|
||||||
WatchKey wk;
|
WatchKey wk;
|
||||||
validService: while(getProject().open) {
|
validService:
|
||||||
wk = watchService.take();
|
while (getProject().open) {
|
||||||
|
wk = watchService.poll(10, TimeUnit.SECONDS);
|
||||||
|
if (wk != null) {
|
||||||
for (WatchEvent<?> event : wk.pollEvents()) {
|
for (WatchEvent<?> event : wk.pollEvents()) {
|
||||||
Path changed = (Path) event.context();
|
Path changed = (Path) event.context();
|
||||||
String name = changed.getFileName().toString();
|
String name = changed.getFileName().toString();
|
||||||
@@ -117,13 +110,15 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
break validService;
|
break validService;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
watcher.start();
|
watcher.start();
|
||||||
}
|
}
|
||||||
@@ -133,40 +128,49 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
public Enumeration<TMXMap> children() {
|
public Enumeration<TMXMap> children() {
|
||||||
return Collections.enumeration(tmxMaps);
|
return Collections.enumeration(tmxMaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAllowsChildren() {
|
public boolean getAllowsChildren() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TreeNode getChildAt(int arg0) {
|
public TreeNode getChildAt(int arg0) {
|
||||||
return tmxMaps.get(arg0);
|
return tmxMaps.get(arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChildCount() {
|
public int getChildCount() {
|
||||||
return tmxMaps.size();
|
return tmxMaps.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIndex(TreeNode arg0) {
|
public int getIndex(TreeNode arg0) {
|
||||||
return tmxMaps.indexOf(arg0);
|
return tmxMaps.indexOf(arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TreeNode getParent() {
|
public TreeNode getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLeaf() {
|
public boolean isLeaf() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenAdded(List<ProjectTreeNode> path) {
|
public void childrenAdded(List<ProjectTreeNode> path) {
|
||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenAdded(path);
|
parent.childrenAdded(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenChanged(List<ProjectTreeNode> path) {
|
public void childrenChanged(List<ProjectTreeNode> path) {
|
||||||
path.add(0, this);
|
path.add(0, this);
|
||||||
parent.childrenChanged(path);
|
parent.childrenChanged(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void childrenRemoved(List<ProjectTreeNode> path) {
|
public void childrenRemoved(List<ProjectTreeNode> path) {
|
||||||
if (path.size() == 1 && this.getChildCount() == 1) {
|
if (path.size() == 1 && this.getChildCount() == 1) {
|
||||||
@@ -176,6 +180,7 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
parent.childrenRemoved(path);
|
parent.childrenRemoved(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyCreated() {
|
public void notifyCreated() {
|
||||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
@@ -183,6 +188,7 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
map.notifyCreated();
|
map.notifyCreated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDesc() {
|
public String getDesc() {
|
||||||
return (needsSaving() ? "*" : "") + "TMX Maps";
|
return (needsSaving() ? "*" : "") + "TMX Maps";
|
||||||
@@ -198,14 +204,17 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return getOpenIcon();
|
return getOpenIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getClosedIcon() {
|
public Image getClosedIcon() {
|
||||||
return DefaultIcons.getTmxClosedIcon();
|
return DefaultIcons.getTmxClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getLeafIcon() {
|
public Image getLeafIcon() {
|
||||||
return DefaultIcons.getTmxClosedIcon();
|
return DefaultIcons.getTmxClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getOpenIcon() {
|
public Image getOpenIcon() {
|
||||||
return DefaultIcons.getTmxOpenIcon();
|
return DefaultIcons.getTmxOpenIcon();
|
||||||
@@ -239,7 +248,8 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
public void addMap(TMXMap node) {
|
public void addMap(TMXMap node) {
|
||||||
ProjectTreeNode higherEmptyParent = this;
|
ProjectTreeNode higherEmptyParent = this;
|
||||||
while (higherEmptyParent != null) {
|
while (higherEmptyParent != null) {
|
||||||
if (higherEmptyParent.getParent() != null && ((ProjectTreeNode)higherEmptyParent.getParent()).isEmpty()) higherEmptyParent = (ProjectTreeNode)higherEmptyParent.getParent();
|
if (higherEmptyParent.getParent() != null && ((ProjectTreeNode) higherEmptyParent.getParent()).isEmpty())
|
||||||
|
higherEmptyParent = (ProjectTreeNode) higherEmptyParent.getParent();
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
||||||
|
|||||||
@@ -1,46 +1,29 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import java.awt.Point;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import javax.xml.transform.OutputKeys;
|
|
||||||
import javax.xml.transform.Result;
|
|
||||||
import javax.xml.transform.Source;
|
|
||||||
import javax.xml.transform.Transformer;
|
|
||||||
import javax.xml.transform.TransformerConfigurationException;
|
|
||||||
import javax.xml.transform.TransformerException;
|
|
||||||
import javax.xml.transform.TransformerFactory;
|
|
||||||
import javax.xml.transform.TransformerFactoryConfigurationError;
|
|
||||||
import javax.xml.transform.dom.DOMSource;
|
|
||||||
import javax.xml.transform.stream.StreamResult;
|
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.*;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class Worldmap extends ArrayList<WorldmapSegment> implements ProjectTreeNode {
|
public class Worldmap extends ArrayList<WorldmapSegment> implements ProjectTreeNode {
|
||||||
|
|
||||||
@@ -175,6 +158,7 @@ public class Worldmap extends ArrayList<WorldmapSegment> implements ProjectTreeN
|
|||||||
public String getDesc() {
|
public String getDesc() {
|
||||||
return (needsSaving() ? "*" : "") + "Worldmap";
|
return (needsSaving() ? "*" : "") + "Worldmap";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyCreated() {
|
public void notifyCreated() {
|
||||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||||
@@ -189,14 +173,17 @@ public class Worldmap extends ArrayList<WorldmapSegment> implements ProjectTreeN
|
|||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return DefaultIcons.getMapClosedIcon();
|
return DefaultIcons.getMapClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getLeafIcon() {
|
public Image getLeafIcon() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getClosedIcon() {
|
public Image getClosedIcon() {
|
||||||
return DefaultIcons.getMapClosedIcon();
|
return DefaultIcons.getMapClosedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getOpenIcon() {
|
public Image getOpenIcon() {
|
||||||
return DefaultIcons.getMapOpenIcon();
|
return DefaultIcons.getMapOpenIcon();
|
||||||
@@ -222,6 +209,7 @@ public class Worldmap extends ArrayList<WorldmapSegment> implements ProjectTreeN
|
|||||||
|
|
||||||
for (WorldmapSegment segment : this) {
|
for (WorldmapSegment segment : this) {
|
||||||
root.appendChild(segment.toXmlElement(doc));
|
root.appendChild(segment.toXmlElement(doc));
|
||||||
|
segment.state = GameDataElement.State.saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveDocToFile(doc, worldmapFile);
|
saveDocToFile(doc, worldmapFile);
|
||||||
@@ -243,7 +231,8 @@ public class Worldmap extends ArrayList<WorldmapSegment> implements ProjectTreeN
|
|||||||
public void addSegment(WorldmapSegment node) {
|
public void addSegment(WorldmapSegment node) {
|
||||||
ProjectTreeNode higherEmptyParent = this;
|
ProjectTreeNode higherEmptyParent = this;
|
||||||
while (higherEmptyParent != null) {
|
while (higherEmptyParent != null) {
|
||||||
if (higherEmptyParent.getParent() != null && ((ProjectTreeNode)higherEmptyParent.getParent()).isEmpty()) higherEmptyParent = (ProjectTreeNode)higherEmptyParent.getParent();
|
if (higherEmptyParent.getParent() != null && ((ProjectTreeNode) higherEmptyParent.getParent()).isEmpty())
|
||||||
|
higherEmptyParent = (ProjectTreeNode) higherEmptyParent.getParent();
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
||||||
|
|||||||
@@ -1,33 +1,27 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||||
|
|
||||||
import java.awt.Image;
|
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||||
import java.awt.Point;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.*;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import java.awt.*;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import javax.xml.transform.OutputKeys;
|
|
||||||
import javax.xml.transform.Result;
|
|
||||||
import javax.xml.transform.Source;
|
|
||||||
import javax.xml.transform.Transformer;
|
|
||||||
import javax.xml.transform.TransformerException;
|
|
||||||
import javax.xml.transform.TransformerFactory;
|
|
||||||
import javax.xml.transform.dom.DOMSource;
|
|
||||||
import javax.xml.transform.stream.StreamResult;
|
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
|
||||||
|
|
||||||
public class WorldmapSegment extends GameDataElement {
|
public class WorldmapSegment extends GameDataElement {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2658610076889592723L;
|
private static final long serialVersionUID = 2658610076889592723L;
|
||||||
@@ -104,8 +98,37 @@ public class WorldmapSegment extends GameDataElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void elementChanged(GameDataElement oldOne, GameDataElement newOne) {
|
public void elementChanged(GameDataElement oldOne, GameDataElement newOne) {
|
||||||
|
boolean modified = false;
|
||||||
|
if (newOne == null && writable) {
|
||||||
|
//A referenced map may have been deleted.
|
||||||
|
if (mapLocations.containsKey(oldOne.id)) {
|
||||||
|
mapLocations.remove(oldOne.id);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
List<String> deprecatedLabels = new ArrayList<String>();
|
||||||
|
for (String label : labelledMaps.keySet()) {
|
||||||
|
if (labelledMaps.get(label).contains(oldOne.id)) {
|
||||||
|
labelledMaps.get(label).remove(oldOne.id);
|
||||||
|
modified = true;
|
||||||
|
if (labelledMaps.get(label).isEmpty()) {
|
||||||
|
deprecatedLabels.add(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String label : deprecatedLabels) {
|
||||||
|
labelledMaps.remove(label);
|
||||||
|
labels.remove(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
oldOne.removeBacklink(this);
|
oldOne.removeBacklink(this);
|
||||||
if (newOne != null) newOne.addBacklink(this);
|
if (newOne != null) newOne.addBacklink(this);
|
||||||
|
|
||||||
|
if (modified) {
|
||||||
|
this.state = GameDataElement.State.modified;
|
||||||
|
childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||||
|
ATContentStudio.frame.editorChanged(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -201,6 +224,7 @@ public class WorldmapSegment extends GameDataElement {
|
|||||||
public Image getIcon() {
|
public Image getIcon() {
|
||||||
return DefaultIcons.getUIMapIcon();
|
return DefaultIcons.getUIMapIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getLeafIcon() {
|
public Image getLeafIcon() {
|
||||||
return DefaultIcons.getUIMapIcon();
|
return DefaultIcons.getUIMapIcon();
|
||||||
|
|||||||
@@ -1,177 +0,0 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.saves;
|
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
|
|
||||||
import com.gpl.rpg.andorstrainer.io.SavedGameIO;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
|
||||||
|
|
||||||
public class SavedGame extends GameDataElement {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -6443495534761084990L;
|
|
||||||
|
|
||||||
public File savedFile;
|
|
||||||
transient public com.gpl.rpg.andorstrainer.model.SavedGame loadedSave = null;
|
|
||||||
transient public SavedGamesSet parent;
|
|
||||||
|
|
||||||
public SavedGame(SavedGamesSet parent, File f) throws IOException {
|
|
||||||
savedFile = f;
|
|
||||||
refreshTransients(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refreshTransients(SavedGamesSet parent) throws IOException {
|
|
||||||
this.parent = parent;
|
|
||||||
this.loadedSave = SavedGameIO.loadFile(savedFile);
|
|
||||||
if (this.loadedSave == null) {
|
|
||||||
throw new IOException("Unable to load save: "+savedFile.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Enumeration<ProjectTreeNode> children() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getAllowsChildren() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TreeNode getChildAt(int arg0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getChildCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getIndex(TreeNode arg0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TreeNode getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isLeaf() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void childrenAdded(List<ProjectTreeNode> path) {
|
|
||||||
path.add(0,this);
|
|
||||||
parent.childrenAdded(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void childrenChanged(List<ProjectTreeNode> path) {
|
|
||||||
path.add(0,this);
|
|
||||||
parent.childrenChanged(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void childrenRemoved(List<ProjectTreeNode> path) {
|
|
||||||
path.add(0,this);
|
|
||||||
parent.childrenRemoved(path);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void notifyCreated() {
|
|
||||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getDesc() {
|
|
||||||
return (needsSaving() ? "*" : "")+loadedSave.displayInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Project getProject() {
|
|
||||||
return parent.getProject();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Image getIcon() {
|
|
||||||
return DefaultIcons.getHeroIcon();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Image getLeafIcon() {
|
|
||||||
return DefaultIcons.getHeroIcon();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Image getClosedIcon() {return null;}
|
|
||||||
@Override
|
|
||||||
public Image getOpenIcon() {return null;}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GameDataSet getDataSet() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type getDataType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parse() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void link() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GameDataElement clone() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void elementChanged(GameDataElement oldOne, GameDataElement newOne) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getProjectFilename() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<SaveEvent> attemptSave() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,180 +0,0 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.model.saves;
|
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.Notification;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
|
||||||
|
|
||||||
public class SavedGamesSet implements ProjectTreeNode, Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -6565834239789184087L;
|
|
||||||
|
|
||||||
public Vector<SavedGame> saves; //For simulations.
|
|
||||||
|
|
||||||
public Project parent;
|
|
||||||
|
|
||||||
public SavedGamesSet(Project parent) {
|
|
||||||
this.parent = parent;
|
|
||||||
saves = new Vector<SavedGame>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refreshTransients() {
|
|
||||||
for (SavedGame save : saves) {
|
|
||||||
try {
|
|
||||||
save.refreshTransients(this);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Notification.addError(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSave(File f) {
|
|
||||||
try {
|
|
||||||
ProjectTreeNode higherEmptyParent = this;
|
|
||||||
while (higherEmptyParent != null) {
|
|
||||||
if (higherEmptyParent.getParent() != null && ((ProjectTreeNode)higherEmptyParent.getParent()).isEmpty()) higherEmptyParent = (ProjectTreeNode)higherEmptyParent.getParent();
|
|
||||||
else break;
|
|
||||||
}
|
|
||||||
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
|
||||||
SavedGame node = new SavedGame(this, f);
|
|
||||||
saves.add(node);
|
|
||||||
if (higherEmptyParent != null) higherEmptyParent.notifyCreated();
|
|
||||||
else node.notifyCreated();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Notification.addError(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SavedGame getSave(File f) {
|
|
||||||
for (SavedGame save : saves) {
|
|
||||||
if (save.savedFile.equals(f)) return save;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Enumeration<? extends ProjectTreeNode> children() {
|
|
||||||
return saves.elements();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getAllowsChildren() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TreeNode getChildAt(int arg0) {
|
|
||||||
return saves.elementAt(arg0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getChildCount() {
|
|
||||||
return saves.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getIndex(TreeNode arg0) {
|
|
||||||
return saves.indexOf(arg0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TreeNode getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isLeaf() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void childrenAdded(List<ProjectTreeNode> path) {
|
|
||||||
path.add(0, this);
|
|
||||||
parent.childrenAdded(path);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void childrenChanged(List<ProjectTreeNode> path) {
|
|
||||||
path.add(0, this);
|
|
||||||
parent.childrenChanged(path);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void childrenRemoved(List<ProjectTreeNode> path) {
|
|
||||||
if (path.size() == 1 && this.getChildCount() == 1) {
|
|
||||||
childrenRemoved(new ArrayList<ProjectTreeNode>());
|
|
||||||
} else {
|
|
||||||
path.add(0, this);
|
|
||||||
parent.childrenRemoved(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void notifyCreated() {
|
|
||||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
|
||||||
for (SavedGame s : saves) {
|
|
||||||
s.notifyCreated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getDesc() {
|
|
||||||
return (needsSaving() ? "*" : "")+"Saved games";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Project getProject() {
|
|
||||||
return parent.getProject();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Image getIcon() {
|
|
||||||
return getOpenIcon();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Image getClosedIcon() {
|
|
||||||
return DefaultIcons.getSavClosedIcon();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Image getLeafIcon() {
|
|
||||||
return DefaultIcons.getSavClosedIcon();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Image getOpenIcon() {
|
|
||||||
return DefaultIcons.getSavOpenIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GameDataSet getDataSet() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Type getDataType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return saves.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean needsSaving() {
|
|
||||||
for (ProjectTreeNode node : saves) {
|
|
||||||
if (node.needsSaving()) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||