mirror of
https://github.com/OMGeeky/ATCS.git
synced 2026-01-02 01:20:15 +01:00
Compare commits
1 Commits
performanc
...
version-ch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85e0a1fd28 |
6
.gitattributes
vendored
6
.gitattributes
vendored
@@ -1,6 +0,0 @@
|
||||
# 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
56
.github/workflows/release.yml
vendored
@@ -1,56 +0,0 @@
|
||||
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
|
||||
1
.idea/artifacts/ATContentStudio_jar.xml
generated
1
.idea/artifacts/ATContentStudio_jar.xml
generated
@@ -10,6 +10,7 @@
|
||||
<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/AndorsTrainer_v0.1.5.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/lib/jide-oss.jar" path-in-jar="/" />
|
||||
</element>
|
||||
</root>
|
||||
|
||||
19
.idea/codeStyles/Project.xml
generated
19
.idea/codeStyles/Project.xml
generated
@@ -1,19 +0,0 @@
|
||||
<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
5
.idea/codeStyles/codeStyleConfig.xml
generated
@@ -1,5 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,4 +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" />
|
||||
<component name="ProjectRootManager" version="2" default="true" />
|
||||
</project>
|
||||
@@ -61,8 +61,6 @@ if not exist %2\%1\.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
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MapObject implements Cloneable
|
||||
{
|
||||
private Properties properties = new Properties();
|
||||
private ObjectGroup objectGroup;
|
||||
private Rectangle bounds;
|
||||
private Rectangle bounds = new Rectangle();
|
||||
private String name = "Object";
|
||||
private String type = "";
|
||||
private String imageSource = "";
|
||||
|
||||
@@ -57,7 +57,7 @@ public class Sprite
|
||||
|
||||
private String name = null;
|
||||
private int id = -1;
|
||||
private int flags;
|
||||
private int flags = KEY_LOOP;
|
||||
private float frameRate = 1.0f; //one fps
|
||||
private Tile[] frames;
|
||||
|
||||
|
||||
@@ -98,11 +98,7 @@ public class TileSet implements Iterable<Tile>
|
||||
|
||||
File f = new File(imgFilename);
|
||||
|
||||
BufferedImage image;
|
||||
try {
|
||||
image = ImageIO.read(f.getCanonicalFile());
|
||||
} catch (IOException e) { throw new IOException("Failed to load " + imgFilename);
|
||||
}
|
||||
BufferedImage image = ImageIO.read(f.getCanonicalFile());
|
||||
if (image == null) {
|
||||
throw new IOException("Failed to load " + imgFilename);
|
||||
}
|
||||
|
||||
@@ -588,7 +588,7 @@ public class TMXMapWriter
|
||||
}
|
||||
|
||||
// Iterate while parents are the same
|
||||
int shared;
|
||||
int shared = 0;
|
||||
int maxShared = Math.min(fromParents.size(), toParents.size());
|
||||
for (shared = 0; shared < maxShared; shared++) {
|
||||
String fromParent = fromParents.get(shared);
|
||||
|
||||
BIN
lib/AndorsTrainer_v0.1.5.jar
Normal file
BIN
lib/AndorsTrainer_v0.1.5.jar
Normal file
Binary file not shown.
BIN
lib/jide-oss.jar
BIN
lib/jide-oss.jar
Binary file not shown.
1
packaging/ATCS_latest
Normal file
1
packaging/ATCS_latest
Normal file
@@ -0,0 +1 @@
|
||||
v0.6.21
|
||||
2
packaging/Linux/.gitignore
vendored
Normal file
2
packaging/Linux/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/ATCS_v*.zip
|
||||
/ATCS_v*.zip.rename
|
||||
20
packaging/Linux/ATCS/ATCS.cmd
Normal file
20
packaging/Linux/ATCS/ATCS.cmd
Normal file
@@ -0,0 +1,20 @@
|
||||
@echo off
|
||||
|
||||
set "ATCS_DIR=%~dp0"
|
||||
set "MAX_MEM=512M"
|
||||
set "CP=%ATCS_DIR%lib\*"
|
||||
set "JAVA=javaw.exe"
|
||||
set "JAVA_OPTS=-DFONT_SCALE=1.0 -Dswing.aatext=true"
|
||||
set "ENV_FILE=%ATCS_DIR%ATCS.env.bat"
|
||||
set "MAIN_CLASS=com.gpl.rpg.atcontentstudio.ATContentStudio"
|
||||
|
||||
if exist "%ENV_FILE%" (
|
||||
call "%ENV_FILE%"
|
||||
) else (
|
||||
echo REM set "MAX_MEM=%MAX_MEM%">"%ENV_FILE%"
|
||||
echo REM set "JAVA=%JAVA%">>"%ENV_FILE%"
|
||||
echo REM set "JAVA_OPTS=%JAVA_OPTS%">>"%ENV_FILE%"
|
||||
echo.>>"%ENV_FILE%"
|
||||
)
|
||||
|
||||
start "" "%JAVA%" %JAVA_OPTS% -Xmx%MAX_MEM% -cp "%CP%" %MAIN_CLASS%
|
||||
BIN
packaging/Linux/ATCS/ATCS.ico
Normal file
BIN
packaging/Linux/ATCS/ATCS.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
22
packaging/Linux/ATCS/ATCS.sh
Normal file
22
packaging/Linux/ATCS/ATCS.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/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='-DFONT_SCALE=1.0 -Dswing.aatext=true'
|
||||
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
Normal file
1
packaging/Linux/ATCS/lib/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/*.jar
|
||||
@@ -1,12 +1,12 @@
|
||||
!include MUI2.nsh
|
||||
|
||||
; Version will be passed as /DVERSION=vx.x.x
|
||||
!define VERSION "0.6.21"
|
||||
!define TRAINER_VERSION "0.1.5"
|
||||
!define JAVA_BIN "java"
|
||||
!define ATCS_SOURCE_DIR "..\..\"
|
||||
!define ATCS_SOURCE_DIR "C:\ATCS"
|
||||
|
||||
Name "Andor's Trail Content Studio ${VERSION}"
|
||||
OutFile "..\ATCS_${VERSION}_Setup.exe"
|
||||
Name "Andor's Trail Content Studio v${VERSION}"
|
||||
OutFile "ATCS_v${VERSION}_Setup.exe"
|
||||
InstallDir "$PROGRAMFILES\ATCS\"
|
||||
|
||||
;SetCompressor /SOLID /FINAL lzma
|
||||
@@ -14,10 +14,10 @@ InstallDir "$PROGRAMFILES\ATCS\"
|
||||
Var StartMenuFolder
|
||||
|
||||
!define MUI_WELCOMEPAGE_TITLE "Welcome to Andor's Trail Content Studio installer"
|
||||
!define MUI_WELCOMEPAGE_TEXT "This will install Andor's Trail Content Studio ${VERSION}"
|
||||
!define MUI_FINISHPAGE_TEXT "Andor's Trail Content Studio ${VERSION} - Install completed !"
|
||||
!define MUI_WELCOMEPAGE_TEXT "This will install Andor's Trail Content Studio v${VERSION}"
|
||||
!define MUI_FINISHPAGE_TEXT "Andor's Trail Content Studio v${VERSION} - Install completed !"
|
||||
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Andor's Trail Content Studio"
|
||||
!define MUI_PAGE_HEADER_TEXT "Installing Andor's Trail Content Studio ${VERSION}"
|
||||
!define MUI_PAGE_HEADER_TEXT "Installing Andor's Trail Content Studio v${VERSION}"
|
||||
|
||||
|
||||
;Start Menu Folder Page Configuration
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
#!/bin/bash
|
||||
ATCS_DIR="$(dirname "$(readlink -f "$0" || greadlink -f "$0" || stat -f "$0")")"
|
||||
echo "ATCS_DIR: '${ATCS_DIR}'"
|
||||
ATCS_DIR=$(dirname $(readlink -f "$0" || greadlink -f "$0" || stat -f "$0"))
|
||||
|
||||
MAX_MEM="512M"
|
||||
JAVA="java"
|
||||
MAX_MEM=512M
|
||||
|
||||
JAVA=java
|
||||
JAVA_OPTS='-DFONT_SCALE=1.0 -Dswing.aatext=true'
|
||||
ENV_FILE=${ATCS_DIR}/ATCS.env
|
||||
|
||||
ENV_FILE="${ATCS_DIR}/ATCS.env"
|
||||
|
||||
if [ -f "${ENV_FILE}" ]; then
|
||||
source "${ENV_FILE}"
|
||||
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}"
|
||||
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
|
||||
|
||||
# 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"
|
||||
$JAVA ${JAVA_OPTS} -Xmx${MAX_MEM} -jar ${ATCS_DIR}/ATCS.jar
|
||||
|
||||
@@ -18,9 +18,10 @@ 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"
|
||||
VERSION_FILE="${PACKAGING_DIR}/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
|
||||
OUTPUT_JAR_DIR="${PACKAGING_DIR}" # Directory where the final JAR will be placed - as per script
|
||||
|
||||
# --- **ADDITIONAL SOURCE CODE FOLDERS** ---
|
||||
EXTRA_SOURCE_DIRS=(
|
||||
@@ -29,8 +30,9 @@ EXTRA_SOURCE_DIRS=(
|
||||
"siphash-zackehh/src/main/java"
|
||||
)
|
||||
|
||||
# --- Libraries to include ---
|
||||
# --- Libraries to include (from IntelliJ artifact definition) ---
|
||||
LIBRARIES=(
|
||||
"AndorsTrainer_v0.1.5.jar"
|
||||
"bsh-2.0b4.jar"
|
||||
"jide-oss.jar"
|
||||
"json_simple-1.1.jar"
|
||||
@@ -43,7 +45,7 @@ LIBRARIES=(
|
||||
|
||||
# --- Get version ---
|
||||
echo "Getting version"
|
||||
VERSION=$(tr -d '[:space:]' < "${VERSION_FILE}")
|
||||
VERSION=$(cat "${VERSION_FILE}")
|
||||
echo "Got version ${VERSION}"
|
||||
|
||||
# --- Prepare temporary directory ---
|
||||
@@ -61,7 +63,7 @@ done
|
||||
|
||||
# --- Set ClassPath ---
|
||||
echo "Getting source files"
|
||||
# Find all java files in source directories
|
||||
# Find all java files in source directories and compile them
|
||||
SOURCE_FILES=$(find "${SOURCE_BASE_DIR}" "${EXTRA_SOURCE_DIRS[@]/#/${ATCS_SOURCE_DIR}/}" -name "*.java" -print)
|
||||
#echo "SourceFiles: ${SOURCE_FILES}"
|
||||
echo ""
|
||||
@@ -69,8 +71,6 @@ 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."
|
||||
@@ -85,7 +85,6 @@ 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 ""
|
||||
@@ -104,22 +103,17 @@ 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
|
||||
cp -f "${JAR_LOCATION}" "${OUTPUT_JAR_DIR}/common/ATCS.jar" # Copy JAR to versioned name
|
||||
|
||||
# --- Create archive ---
|
||||
cd "${PACKAGING_DIR}" || exit
|
||||
if [ "$PLATFORM" = "LINUX" ]; then
|
||||
cd "${OUTPUT_JAR_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"
|
||||
tar caf "ATCS_${VERSION}.tar.gz" common/* # archive the 'common' folder which now contains the JAR and libs
|
||||
echo "Created archive at ${OUTPUT_JAR_DIR}/ATCS_${VERSION}.tar.gz"
|
||||
cd "${PACKAGING_DIR}" || exit
|
||||
else
|
||||
# Use zip command on Linux
|
||||
zip -r "ATCS_${VERSION}.zip" common/* # archive the 'common' folder which now contains the JAR and libs
|
||||
echo "Can't create zip files on windows yet. Please pack the content of the '${OUTPUT_JAR_DIR}/common/' folder yourself"
|
||||
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 +0,0 @@
|
||||
v0.6.22
|
||||
@@ -1,16 +1,10 @@
|
||||
package com.gpl.rpg.atcontentstudio;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
import com.gpl.rpg.atcontentstudio.ui.StudioFrame;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
||||
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.Color;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.BufferedReader;
|
||||
@@ -20,19 +14,35 @@ 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.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
|
||||
import prefuse.data.expression.parser.ExpressionParser;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
import com.gpl.rpg.atcontentstudio.ui.StudioFrame;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector;
|
||||
|
||||
public class ATContentStudio {
|
||||
|
||||
public static final String APP_NAME = "Andor's Trail Content Studio";
|
||||
public static final String APP_VERSION = readVersionFromFile();
|
||||
public static final String APP_VERSION = "v0.6.21";
|
||||
|
||||
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";
|
||||
@@ -52,7 +62,7 @@ public class ATContentStudio {
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String fontScaling = System.getProperty(FONT_SCALE_ENV_VAR_NAME);
|
||||
Float fontScale;
|
||||
Float fontScale = null;
|
||||
if (fontScaling != null) {
|
||||
try {
|
||||
fontScale = Float.parseFloat(fontScaling);
|
||||
@@ -65,8 +75,22 @@ public class ATContentStudio {
|
||||
|
||||
ConfigCache.init();
|
||||
|
||||
try {
|
||||
String laf = ConfigCache.getFavoriteLaFClassName();
|
||||
setLookAndFeel(laf);
|
||||
if (laf == null)
|
||||
laf = UIManager.getSystemLookAndFeelClassName();
|
||||
UIManager.setLookAndFeel(laf);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UnsupportedLookAndFeelException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
scaleUIFont();
|
||||
|
||||
// Need to keep a strong reference to it, to avoid garbage collection that'll
|
||||
// reset this setting.
|
||||
@@ -101,7 +125,7 @@ public class ATContentStudio {
|
||||
frame = new StudioFrame(APP_NAME + " " + APP_VERSION);
|
||||
frame.setVisible(true);
|
||||
frame.setDefaultCloseOperation(StudioFrame.DO_NOTHING_ON_CLOSE);
|
||||
}
|
||||
};
|
||||
});
|
||||
for (File f : ConfigCache.getKnownWorkspaces()) {
|
||||
if (workspaceRoot.equals(f)) {
|
||||
@@ -119,34 +143,6 @@ 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 {
|
||||
@@ -157,8 +153,7 @@ public class ATContentStudio {
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
lastLine = inputLine;
|
||||
}
|
||||
if (lastLine != null && !lastLine.equals(APP_VERSION)) {
|
||||
|
||||
if (lastLine != null && compareVersions(lastLine) < 0) {
|
||||
// for copying style
|
||||
JLabel label = new JLabel();
|
||||
Font font = label.getFont();
|
||||
@@ -200,14 +195,8 @@ public class ATContentStudio {
|
||||
}
|
||||
} 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());
|
||||
}
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (in != null)
|
||||
@@ -242,13 +231,18 @@ public class ATContentStudio {
|
||||
}
|
||||
}
|
||||
|
||||
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";
|
||||
/// returns The difference between the the latest version and the current one (CURRENT - LATEST)
|
||||
private static int compareVersions(String latest) {
|
||||
String[] levels1 = ATContentStudio.APP_VERSION.substring(1).split("\\.");
|
||||
String[] levels2 = latest.substring(1).split("\\.");
|
||||
int length = Math.max(levels1.length, levels2.length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
int v1 = i < levels1.length ? Integer.parseInt(levels1[i]) : 0;
|
||||
int v2 = i < levels2.length ? Integer.parseInt(levels2[i]) : 0;
|
||||
if (v1 != v2) {
|
||||
return v1 - v2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.gpl.rpg.atcontentstudio;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.io.SettingsSave;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.io.SettingsSave;
|
||||
|
||||
public class ConfigCache implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4584324644282843961L;
|
||||
@@ -91,8 +91,7 @@ public class ConfigCache implements Serializable {
|
||||
return instance.notifConfig;
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
}
|
||||
public static void init() {}
|
||||
|
||||
public static void clear() {
|
||||
instance.knownWorkspaces.clear();
|
||||
|
||||
@@ -8,7 +8,7 @@ public class Notification {
|
||||
|
||||
public static List<Notification> notifs = new ArrayList<Notification>();
|
||||
private static List<NotificationListener> listeners = new CopyOnWriteArrayList<NotificationListener>();
|
||||
public static boolean showS, showI, showW, showE;
|
||||
public static boolean showS = true, showI = true, showW = true, showE = true;
|
||||
|
||||
static {
|
||||
boolean[] config = ConfigCache.getNotifViewConfig();
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gpl.rpg.atcontentstudio;
|
||||
public interface NotificationListener {
|
||||
|
||||
public void onNewNotification(Notification n);
|
||||
|
||||
public void onListCleared(int i);
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.gpl.rpg.atcontentstudio.io;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface JsonSerializable {
|
||||
Map toMap();
|
||||
void fromMap(Map map);
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
package com.gpl.rpg.atcontentstudio.io;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
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 java.io.*;
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
|
||||
public class SettingsSave {
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
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.gamedata.GameDataSet;
|
||||
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 {
|
||||
|
||||
String name;
|
||||
@@ -24,32 +25,26 @@ public class ClosedProject implements ProjectTreeNode {
|
||||
public TreeNode getChildAt(int childIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeNode getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndex(TreeNode node) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAllowsChildren() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeaf() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<ProjectTreeNode> children() {
|
||||
return null;
|
||||
@@ -60,19 +55,16 @@ public class ClosedProject implements ProjectTreeNode {
|
||||
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>());
|
||||
@@ -93,19 +85,16 @@ public class ClosedProject implements ProjectTreeNode {
|
||||
public Image getIcon() {
|
||||
return getOpenIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
//TODO Create a cool Project icon.
|
||||
return DefaultIcons.getStdClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
//TODO Create a cool Project icon.
|
||||
return DefaultIcons.getStdClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
//TODO Create a cool Project icon.
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.gpl.rpg.atcontentstudio.model;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.bookmarks.BookmarkEntry;
|
||||
import java.awt.Image;
|
||||
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 java.awt.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.bookmarks.BookmarkEntry;
|
||||
|
||||
public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
||||
|
||||
@@ -40,37 +44,30 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
||||
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);
|
||||
@@ -88,12 +85,10 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
||||
path.add(0,this);
|
||||
parent.childrenRemoved(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract String getDesc();
|
||||
|
||||
@@ -102,10 +97,10 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
||||
}
|
||||
|
||||
public abstract void parse();
|
||||
|
||||
public abstract void link();
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Project getProject() {
|
||||
return parent == null ? null : parent.getProject();
|
||||
@@ -115,17 +110,10 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
||||
public Image getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Image getClosedIcon() {return null;}
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Image getOpenIcon() {return null;}
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
return getIcon();
|
||||
@@ -184,7 +172,6 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
||||
|
||||
public static interface BacklinksListener {
|
||||
public void backlinkAdded(GameDataElement gde);
|
||||
|
||||
public void backlinkRemoved(GameDataElement gde);
|
||||
}
|
||||
|
||||
@@ -203,35 +190,4 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
||||
|
||||
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,6 +1,28 @@
|
||||
package com.gpl.rpg.atcontentstudio.model;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.io.JsonSerializable;
|
||||
import java.awt.Image;
|
||||
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.gamedata.GameDataSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||
@@ -10,22 +32,8 @@ import com.gpl.rpg.atcontentstudio.model.sprites.SpriteSheetSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeDataSet;
|
||||
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 java.awt.*;
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class GameSource implements ProjectTreeNode, Serializable, JsonSerializable {
|
||||
public class GameSource implements ProjectTreeNode, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1512979360971918158L;
|
||||
|
||||
@@ -39,22 +47,6 @@ public class GameSource implements ProjectTreeNode, Serializable, JsonSerializab
|
||||
public transient WriterModeDataSet writerModeDataSet;
|
||||
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 {
|
||||
source,
|
||||
referenced,
|
||||
@@ -65,14 +57,10 @@ public class GameSource implements ProjectTreeNode, Serializable, JsonSerializab
|
||||
public File baseFolder;
|
||||
public Type type;
|
||||
|
||||
public transient Project parent;
|
||||
public transient Project parent = 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) {
|
||||
this.parent = parent;
|
||||
this.baseFolder = folder;
|
||||
@@ -117,7 +105,7 @@ public class GameSource implements ProjectTreeNode, Serializable, JsonSerializab
|
||||
}
|
||||
|
||||
public void readResourceList() {
|
||||
File xmlFile;
|
||||
File xmlFile = null;
|
||||
if (parent.sourceSetToUse == ResourceSet.gameData) {
|
||||
xmlFile = new File(baseFolder, DEFAULT_REL_PATH_FOR_GAME_RESOURCE);
|
||||
} else if (parent.sourceSetToUse == ResourceSet.debugData) {
|
||||
@@ -172,49 +160,40 @@ public class GameSource implements ProjectTreeNode, Serializable, JsonSerializab
|
||||
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) {
|
||||
@@ -224,7 +203,6 @@ public class GameSource implements ProjectTreeNode, Serializable, JsonSerializab
|
||||
parent.childrenRemoved(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
@@ -232,20 +210,14 @@ public class GameSource implements ProjectTreeNode, Serializable, JsonSerializab
|
||||
node.notifyCreated();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
switch(type) {
|
||||
case altered:
|
||||
return (needsSaving() ? "*" : "") + "Altered data";
|
||||
case created:
|
||||
return (needsSaving() ? "*" : "") + "Created 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";
|
||||
case altered: return (needsSaving() ? "*" : "")+"Altered data";
|
||||
case created: return (needsSaving() ? "*" : "")+"Created 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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,22 +252,18 @@ public class GameSource implements ProjectTreeNode, Serializable, JsonSerializab
|
||||
public Image getIcon() {
|
||||
return getOpenIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
return DefaultIcons.getATClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
return DefaultIcons.getATClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
return DefaultIcons.getATOpenIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameDataSet getDataSet() {
|
||||
return null;
|
||||
|
||||
@@ -1,53 +1,19 @@
|
||||
package com.gpl.rpg.atcontentstudio.model;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.io.JsonSerializable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Dimension;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Preferences implements Serializable, JsonSerializable {
|
||||
public class Preferences implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2455802658424031276L;
|
||||
|
||||
public Dimension windowSize = null;
|
||||
public Map<String, Integer> splittersPositions = new HashMap<>();
|
||||
public Map<String, Integer> splittersPositions = new HashMap<String, Integer>();
|
||||
|
||||
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,21 +1,45 @@
|
||||
package com.gpl.rpg.atcontentstudio.model;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
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.model.GameSource.Type;
|
||||
import com.gpl.rpg.atcontentstudio.model.bookmarks.BookmarksRoot;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.*;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.Worldmap;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeData;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
||||
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||
import java.awt.Image;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
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.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.w3c.dom.Comment;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
@@ -23,24 +47,35 @@ 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 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.*;
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.io.JsonPrettyWriter;
|
||||
import com.gpl.rpg.atcontentstudio.io.SettingsSave;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||
import com.gpl.rpg.atcontentstudio.model.bookmarks.BookmarksRoot;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
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.TMXMapSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.Worldmap;
|
||||
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.tools.writermode.WriterModeData;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
||||
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||
|
||||
public class Project implements ProjectTreeNode, Serializable, JsonSerializable {
|
||||
public class Project implements ProjectTreeNode, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4807454973303366758L;
|
||||
private static final String drawablePath = TMXMapSet.DEFAULT_REL_PATH_TO_DRAWABLE.replace("\\", "/");
|
||||
@@ -48,7 +83,6 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
|
||||
//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_JSON = ".project.json";
|
||||
|
||||
public String name;
|
||||
|
||||
@@ -57,39 +91,19 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
|
||||
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 createdContent; //Stand-alone.
|
||||
public transient BookmarksRoot bookmarks;
|
||||
|
||||
|
||||
public SavedGamesSet saves; //For simulations.
|
||||
|
||||
public transient SavedSlotCollection v;
|
||||
|
||||
public transient Workspace parent;
|
||||
|
||||
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 Properties knownSpritesheetsProperties = null;
|
||||
|
||||
public static enum ResourceSet {
|
||||
gameData,
|
||||
@@ -97,17 +111,8 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
allFiles
|
||||
}
|
||||
|
||||
public ResourceSet sourceSetToUse;
|
||||
public ResourceSet sourceSetToUse = ResourceSet.allFiles;
|
||||
|
||||
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) {
|
||||
this.parent = w;
|
||||
this.name = name;
|
||||
@@ -121,28 +126,38 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
Notification.addError("Eror creating project root folder: "+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
loadSpritesheetProperties();
|
||||
baseContent = new GameSource(source, this);
|
||||
open = true;
|
||||
initializeData();
|
||||
linkAll();
|
||||
save();
|
||||
}
|
||||
|
||||
private void initializeData() {
|
||||
v = new SavedSlotCollection();
|
||||
|
||||
alteredContent = new GameSource(this, Type.altered);
|
||||
createdContent = new GameSource(this, Type.created);
|
||||
knownSpritesheetsProperties = new Properties();
|
||||
try {
|
||||
knownSpritesheetsProperties.load(Project.class.getResourceAsStream("/spritesheets.properties"));
|
||||
} catch (IOException e) {
|
||||
Notification.addWarn("Unable to load default spritesheets properties.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
baseContent = new GameSource(source, this);
|
||||
|
||||
// referencedContent = new GameSource(this, GameSource.Type.referenced);
|
||||
|
||||
alteredContent = new GameSource(this, GameSource.Type.altered);
|
||||
createdContent = new GameSource(this, GameSource.Type.created);
|
||||
bookmarks = new BookmarksRoot(this);
|
||||
|
||||
saves = new SavedGamesSet(this);
|
||||
|
||||
v.add(createdContent);
|
||||
v.add(alteredContent);
|
||||
// v.add(referencedContent);
|
||||
v.add(baseContent);
|
||||
v.add(saves);
|
||||
v.add(bookmarks);
|
||||
|
||||
linkAll();
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +213,6 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
path.add(0,this);
|
||||
parent.childrenRemoved(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
@@ -206,7 +220,6 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
node.notifyCreated();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return (needsSaving() ? "*" : "")+name;
|
||||
@@ -224,21 +237,13 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
|
||||
|
||||
public static Project fromFolder(Workspace w, File projRoot) {
|
||||
Project p;
|
||||
|
||||
File fJson = new File(projRoot, Project.SETTINGS_FILE_JSON);
|
||||
if (fJson.exists()) {
|
||||
p = new Project(w, fJson);
|
||||
} else {
|
||||
Project p = null;
|
||||
File f = new File(projRoot, Project.SETTINGS_FILE);
|
||||
if (!f.exists()) {
|
||||
Notification.addError("Unable to find "+SETTINGS_FILE+" for project "+projRoot.getName());
|
||||
return null;
|
||||
} else {
|
||||
p = (Project) SettingsSave.loadInstance(f, "Project");
|
||||
p.baseFolder = projRoot;
|
||||
}
|
||||
p.save();
|
||||
}
|
||||
p.refreshTransients(w);
|
||||
return p;
|
||||
@@ -249,7 +254,13 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
|
||||
projectElementListeners = new HashMap<Class<? extends GameDataElement>, List<ProjectElementListener>>();
|
||||
|
||||
loadSpritesheetProperties();
|
||||
try {
|
||||
knownSpritesheetsProperties = new Properties();
|
||||
knownSpritesheetsProperties.load(Project.class.getResourceAsStream("/spritesheets.properties"));
|
||||
} catch (IOException e) {
|
||||
Notification.addWarn("Unable to load default spritesheets properties.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (sourceSetToUse == null) {
|
||||
sourceSetToUse = ResourceSet.allFiles;
|
||||
@@ -264,11 +275,14 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
createdContent = new GameSource(this, GameSource.Type.created);
|
||||
bookmarks = new BookmarksRoot(this);
|
||||
|
||||
saves.refreshTransients();
|
||||
|
||||
v = new SavedSlotCollection();
|
||||
v.add(createdContent);
|
||||
v.add(alteredContent);
|
||||
// v.add(referencedContent);
|
||||
v.add(baseContent);
|
||||
v.add(saves);
|
||||
v.add(bookmarks);
|
||||
|
||||
|
||||
@@ -276,40 +290,51 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
|
||||
}
|
||||
|
||||
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() {
|
||||
linkGameData(baseContent);
|
||||
linkGameData(alteredContent);
|
||||
linkGameData(createdContent);
|
||||
}
|
||||
|
||||
private void linkGameData(GameSource source) {
|
||||
for (ProjectTreeNode node : source.gameData.v.getNonEmptyIterable()) {
|
||||
for (ProjectTreeNode node : baseContent.gameData.v.getNonEmptyIterable()) {
|
||||
if (node instanceof GameDataCategory<?>) {
|
||||
for (GameDataElement e : ((GameDataCategory<?>) node).toList()) {
|
||||
for (GameDataElement e : ((GameDataCategory<?>) node)) {
|
||||
e.link();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (TMXMap node : source.gameMaps.tmxMaps) {
|
||||
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) {
|
||||
node.link();
|
||||
}
|
||||
for (WorldmapSegment node : source.worldmap) {
|
||||
for (WorldmapSegment node : alteredContent.worldmap) {
|
||||
node.link();
|
||||
}
|
||||
for (WorldmapSegment node : baseContent.worldmap) {
|
||||
node.link();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
FileUtils.writeStringToFile(FileUtils.toJsonString(toMap()),new File(baseFolder, Project.SETTINGS_FILE_JSON), "Project " + this.name);
|
||||
SettingsSave.saveInstance(this, new File(baseFolder, Project.SETTINGS_FILE), "Project "+this.name);
|
||||
}
|
||||
|
||||
|
||||
@@ -744,19 +769,16 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
public Image getIcon() {
|
||||
return getOpenIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
//TODO Create a cool Project icon.
|
||||
return DefaultIcons.getStdClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
//TODO Create a cool Project icon.
|
||||
return DefaultIcons.getStdClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
//TODO Create a cool Project icon.
|
||||
@@ -793,6 +815,7 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void makeWritable(TMXMap node) {
|
||||
GameSource.Type type = node.getDataType();
|
||||
if (type == null) {
|
||||
@@ -836,6 +859,7 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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) {
|
||||
@@ -859,6 +883,7 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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) {
|
||||
@@ -886,6 +911,7 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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) {
|
||||
@@ -915,14 +941,14 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
|
||||
public void moveToCreated(JSONElement target) {
|
||||
target.childrenRemoved(new ArrayList<ProjectTreeNode>());
|
||||
((GameDataCategory<?>) target.getParent()).removeGeneric(target);
|
||||
((GameDataCategory<?>)target.getParent()).remove(target);
|
||||
target.state = GameDataElement.State.created;
|
||||
createdContent.gameData.addElement(target);
|
||||
}
|
||||
|
||||
public void moveToAltered(JSONElement target) {
|
||||
target.childrenRemoved(new ArrayList<ProjectTreeNode>());
|
||||
((GameDataCategory<?>) target.getParent()).removeGeneric(target);
|
||||
((GameDataCategory<?>)target.getParent()).remove(target);
|
||||
target.state = GameDataElement.State.created;
|
||||
((JSONElement) target).jsonFile = new File(baseContent.gameData.getGameDataElement(((JSONElement)target).getClass(), target.id).jsonFile.getAbsolutePath());
|
||||
alteredContent.gameData.addElement((JSONElement) target);
|
||||
@@ -949,6 +975,7 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void createWriterSketch(WriterModeData node) {
|
||||
node.writable = true;
|
||||
createdContent.writerModeDataSet.add(node);
|
||||
@@ -987,6 +1014,11 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
}
|
||||
|
||||
|
||||
public void addSave(File selectedFile) {
|
||||
saves.addSave(selectedFile);
|
||||
}
|
||||
|
||||
|
||||
public List<NPC> getSpawnGroup(String spawngroup_id) {
|
||||
List<NPC> result = new ArrayList<NPC>();
|
||||
int i = getNPCCount();
|
||||
@@ -1028,8 +1060,7 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -1106,15 +1137,13 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
// }
|
||||
Map<Class<? extends GameDataElement>, List<String>> writtenFilesPerDataType = new LinkedHashMap<Class<? extends GameDataElement>, List<String>>();
|
||||
List<String> writtenFiles;
|
||||
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.actorConditions, alteredContent.gameData.actorConditions, baseContent.gameData.actorConditions, ActorCondition.class,
|
||||
tmpJsonDataDir);
|
||||
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.actorConditions, alteredContent.gameData.actorConditions, baseContent.gameData.actorConditions, ActorCondition.class, tmpJsonDataDir);
|
||||
writtenFilesPerDataType.put(ActorCondition.class, writtenFiles);
|
||||
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.dialogues, alteredContent.gameData.dialogues, baseContent.gameData.dialogues, Dialogue.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);
|
||||
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);
|
||||
@@ -1180,18 +1209,18 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
public List<String> writeDataDeltaForDataType(GameDataCategory<? extends JSONElement> created, GameDataCategory<? extends JSONElement> altered, GameDataCategory<? extends JSONElement> source, Class<? extends JSONElement> gdeClass, File targetFolder) {
|
||||
List<String> filenamesToWrite = new LinkedList<String>();
|
||||
Map<String, List<Map>> dataToWritePerFilename = new LinkedHashMap<String, List<Map>>();
|
||||
for (JSONElement gde : altered.toList()) {
|
||||
for (JSONElement gde : altered) {
|
||||
if (!filenamesToWrite.contains(gde.jsonFile.getName())) {
|
||||
filenamesToWrite.add(gde.jsonFile.getName());
|
||||
}
|
||||
}
|
||||
for (JSONElement gde : created.toList()) {
|
||||
for (JSONElement gde : created) {
|
||||
if (!filenamesToWrite.contains(gde.jsonFile.getName())) {
|
||||
filenamesToWrite.add(gde.jsonFile.getName());
|
||||
}
|
||||
}
|
||||
for (String fName : filenamesToWrite) {
|
||||
for (JSONElement gde : source.toList()) {
|
||||
for (JSONElement gde : source) {
|
||||
if (gde.jsonFile.getName().equals(fName)) {
|
||||
if (dataToWritePerFilename.get(fName) == null) {
|
||||
dataToWritePerFilename.put(fName, new ArrayList<Map>());
|
||||
@@ -1200,7 +1229,7 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
dataToWritePerFilename.get(fName).add(getGameDataElement(gdeClass, gde.id).toJson());
|
||||
}
|
||||
}
|
||||
for (JSONElement gde : created.toList()) {
|
||||
for (JSONElement gde : created) {
|
||||
if (gde.jsonFile.getName().equals(fName)) {
|
||||
if (dataToWritePerFilename.get(fName) == null) {
|
||||
dataToWritePerFilename.put(fName, new ArrayList<Map>());
|
||||
@@ -1212,9 +1241,22 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
}
|
||||
for (String fName : dataToWritePerFilename.keySet()) {
|
||||
File jsonFile = new File(targetFolder, fName);
|
||||
|
||||
String textToWrite = FileUtils.toJsonString(dataToWritePerFilename.get(fName));
|
||||
FileUtils.writeStringToFile(textToWrite, jsonFile, "JSON file '"+jsonFile.getAbsolutePath()+"'", false);
|
||||
StringWriter writer = new JsonPrettyWriter();
|
||||
try {
|
||||
JSONArray.writeJSONString(dataToWritePerFilename.get(fName), writer);
|
||||
} catch (IOException e) {
|
||||
//Impossible with a StringWriter
|
||||
}
|
||||
String textToWrite = writer.toString();
|
||||
try {
|
||||
FileWriter w = new FileWriter(jsonFile);
|
||||
w.write(textToWrite);
|
||||
w.close();
|
||||
// Notification.addSuccess("Json file "+jsonFile.getAbsolutePath()+" saved.");
|
||||
} catch (IOException e) {
|
||||
Notification.addError("Error while writing json file "+jsonFile.getAbsolutePath()+" : "+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return filenamesToWrite;
|
||||
}
|
||||
@@ -1358,4 +1400,7 @@ public class Project implements ProjectTreeNode, Serializable, JsonSerializable
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
package com.gpl.rpg.atcontentstudio.model;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
import java.awt.Image;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.tree.TreeNode;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
|
||||
public interface ProjectTreeNode extends TreeNode {
|
||||
|
||||
public void childrenAdded(List<ProjectTreeNode> path);
|
||||
|
||||
public void childrenChanged(List<ProjectTreeNode> path);
|
||||
|
||||
public void childrenRemoved(List<ProjectTreeNode> path);
|
||||
|
||||
public void notifyCreated();
|
||||
|
||||
public String getDesc();
|
||||
|
||||
/**
|
||||
* Unnecessary for anything not below a Project. Can return null.
|
||||
*
|
||||
* @return the parent Project or null.
|
||||
*/
|
||||
public Project getProject();
|
||||
@@ -28,31 +25,29 @@ public interface ProjectTreeNode extends TreeNode {
|
||||
|
||||
/**
|
||||
* Unnecessary for anything not below a GameDataSet. Can return null.
|
||||
*
|
||||
* @return the parent GameDataSet or null.
|
||||
*/
|
||||
public GameDataSet getDataSet();
|
||||
|
||||
public Image getIcon();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The icon depicting this node when it is an open folder. Can be null for leaves.
|
||||
*/
|
||||
public Image getOpenIcon();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The icon depicting this node when it is a closed folder. Can be null for leaves.
|
||||
*/
|
||||
public Image getClosedIcon();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The icon depicting this node when it is a leaf. Should return the closed one for empty folders.
|
||||
*/
|
||||
public Image getLeafIcon();
|
||||
|
||||
/**
|
||||
* Unnecessary for anything not below a GameSource. Can return null.
|
||||
*
|
||||
* @return the parent GameSource or null.
|
||||
*/
|
||||
public GameSource.Type getDataType();
|
||||
|
||||
@@ -1,30 +1,35 @@
|
||||
package com.gpl.rpg.atcontentstudio.model;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.nio.file.Files;
|
||||
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.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.io.JsonSerializable;
|
||||
import com.gpl.rpg.atcontentstudio.io.SettingsSave;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.ProjectsTree.ProjectsTreeModel;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
||||
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||
import org.jsoup.SerializationException;
|
||||
|
||||
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 {
|
||||
public class Workspace implements ProjectTreeNode, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7938633033601384956L;
|
||||
|
||||
public static final String WS_SETTINGS_FILE = ".workspace";
|
||||
public static final String WS_SETTINGS_FILE_JSON = ".workspace.json";
|
||||
|
||||
public static Workspace activeWorkspace;
|
||||
|
||||
@@ -40,7 +45,6 @@ public class Workspace implements ProjectTreeNode, Serializable, JsonSerializabl
|
||||
public transient ProjectsTreeModel projectsTreeModel = null;
|
||||
|
||||
public Workspace(File workspaceRoot) {
|
||||
boolean freshWorkspace = false;
|
||||
baseFolder = workspaceRoot;
|
||||
if (!workspaceRoot.exists()) {
|
||||
try {
|
||||
@@ -52,70 +56,23 @@ public class Workspace implements ProjectTreeNode, Serializable, JsonSerializabl
|
||||
}
|
||||
}
|
||||
settings = new WorkspaceSettings(this);
|
||||
settingsFile = new File(workspaceRoot, WS_SETTINGS_FILE_JSON);
|
||||
settingsFile = new File(workspaceRoot, WS_SETTINGS_FILE);
|
||||
if (!settingsFile.exists()) {
|
||||
try {
|
||||
settingsFile.createNewFile();
|
||||
freshWorkspace = true;
|
||||
} catch (IOException e) {
|
||||
Notification.addError("Error creating workspace datafile: "
|
||||
+ e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Notification.addSuccess("New workspace created: "
|
||||
+ workspaceRoot.getAbsolutePath());
|
||||
}
|
||||
if (freshWorkspace)
|
||||
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) {
|
||||
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");
|
||||
Workspace w = null;
|
||||
File f = new File(workspaceRoot, WS_SETTINGS_FILE);
|
||||
if (!workspaceRoot.exists() || !f.exists()) {
|
||||
w = new Workspace(workspaceRoot);
|
||||
@@ -124,33 +81,19 @@ public class Workspace implements ProjectTreeNode, Serializable, JsonSerializabl
|
||||
if (w == null) {
|
||||
w = new Workspace(workspaceRoot);
|
||||
} else {
|
||||
w.settingsFile = f2;
|
||||
w.baseFolder = workspaceRoot;
|
||||
Notification.addInfo("Switched workspace to json format.");
|
||||
w.refreshTransients();
|
||||
}
|
||||
w.save();
|
||||
}
|
||||
}
|
||||
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() {
|
||||
activeWorkspace.save();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
settings.save();
|
||||
FileUtils.writeStringToFile(FileUtils.toJsonString(this), settingsFile, "Workspace");
|
||||
SettingsSave.saveInstance(this, settingsFile, "Workspace");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -368,6 +311,7 @@ public class Workspace implements ProjectTreeNode, Serializable, JsonSerializabl
|
||||
Notification.addError("Error while deleting closed project "
|
||||
+ cp.name + ". Files may remain in the workspace.");
|
||||
}
|
||||
cp = null;
|
||||
saveActive();
|
||||
}
|
||||
|
||||
@@ -383,6 +327,7 @@ public class Workspace implements ProjectTreeNode, Serializable, JsonSerializabl
|
||||
Notification.addError("Error while deleting project " + p.name
|
||||
+ ". Files may remain in the workspace.");
|
||||
}
|
||||
p = null;
|
||||
saveActive();
|
||||
}
|
||||
|
||||
@@ -394,7 +339,7 @@ public class Workspace implements ProjectTreeNode, Serializable, JsonSerializabl
|
||||
for (File c : f.listFiles())
|
||||
b &= delete(c);
|
||||
}
|
||||
return b & f.delete();
|
||||
return b &= f.delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -420,4 +365,5 @@ public class Workspace implements ProjectTreeNode, Serializable, JsonSerializabl
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
package com.gpl.rpg.atcontentstudio.model;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
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 static final String VERSION_KEY = "ATCS_Version";
|
||||
@@ -107,8 +113,22 @@ public class WorkspaceSettings {
|
||||
}
|
||||
|
||||
json.put(VERSION_KEY, SETTINGS_VERSION);
|
||||
String toWrite = FileUtils.toJsonString(json);
|
||||
FileUtils.writeStringToFile(toWrite, file, "Workspace settings");
|
||||
StringWriter writer = new JsonPrettyWriter();
|
||||
try {
|
||||
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() {
|
||||
@@ -196,4 +216,5 @@ public class WorkspaceSettings {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.bookmarks;
|
||||
|
||||
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.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
@@ -8,12 +15,6 @@ 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;
|
||||
@@ -78,7 +79,6 @@ public class BookmarkEntry implements BookmarkNode {
|
||||
path.add(0,this);
|
||||
parent.childrenRemoved(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
@@ -91,13 +91,7 @@ public class BookmarkEntry implements BookmarkNode {
|
||||
if (text.length() > 60) {
|
||||
text = text.substring(0, 57)+"...";
|
||||
}
|
||||
return ((GameDataElement) bookmarkedElement).getDataType().toString() +
|
||||
"/" +
|
||||
((Quest) ((QuestStage) bookmarkedElement).parent).id +
|
||||
"#" +
|
||||
((QuestStage) bookmarkedElement).progress +
|
||||
":" +
|
||||
text;
|
||||
return ((GameDataElement)bookmarkedElement).getDataType().toString()+"/"+((Quest)((QuestStage)bookmarkedElement).parent).id+"#"+((QuestStage)bookmarkedElement).progress+":"+text;
|
||||
} else {
|
||||
return ((GameDataElement)bookmarkedElement).getDataType().toString()+"/"+((GameDataElement)bookmarkedElement).getDesc();
|
||||
}
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.bookmarks;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
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>();
|
||||
@@ -85,7 +89,6 @@ public class BookmarkFolder implements BookmarkNode {
|
||||
parent.childrenRemoved(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
public interface BookmarkNode extends ProjectTreeNode{
|
||||
|
||||
public void save();
|
||||
|
||||
public void delete();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,36 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.bookmarks;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
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.gamedata.ActorCondition;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Droplist;
|
||||
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.NPC;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Quest;
|
||||
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;
|
||||
public transient Project parent = null;
|
||||
|
||||
BookmarkFolder ac, diag, dl, it, ic, npc, q, tmx, sp, wm;
|
||||
|
||||
@@ -81,13 +90,11 @@ public class BookmarksRoot implements BookmarkNode {
|
||||
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) {
|
||||
@@ -97,7 +104,6 @@ public class BookmarksRoot implements BookmarkNode {
|
||||
parent.childrenRemoved(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
@@ -161,12 +167,11 @@ public class BookmarksRoot implements BookmarkNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
}
|
||||
public void delete() {}
|
||||
|
||||
public void addBookmark(GameDataElement target) {
|
||||
BookmarkEntry node;
|
||||
BookmarkFolder folder;
|
||||
BookmarkFolder folder = null;
|
||||
if (target instanceof ActorCondition) {
|
||||
folder = ac;
|
||||
} else if (target instanceof Dialogue) {
|
||||
@@ -192,8 +197,7 @@ public class BookmarksRoot implements BookmarkNode {
|
||||
}
|
||||
ProjectTreeNode higherEmptyParent = folder;
|
||||
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;
|
||||
}
|
||||
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
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.GameSource;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
@@ -15,13 +9,20 @@ 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.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||
|
||||
|
||||
public class ActorCondition extends JSONElement {
|
||||
|
||||
private static final long serialVersionUID = -3969824899972048507L;
|
||||
|
||||
public static final Integer MAGNITUDE_CLEAR = -99;
|
||||
public static final Integer DURATION_FOREVER = 999;
|
||||
public static final Integer DURATION_FOREVER = 999;;
|
||||
public static final Integer DURATION_NONE = 0;
|
||||
|
||||
// Available from init state
|
||||
@@ -46,7 +47,10 @@ public class ActorCondition extends JSONElement {
|
||||
}
|
||||
|
||||
public static enum VisualEffectID {
|
||||
redSplash, blueSwirl, greenSplash, miss
|
||||
redSplash
|
||||
,blueSwirl
|
||||
,greenSplash
|
||||
,miss
|
||||
}
|
||||
|
||||
public static class RoundEffect implements Cloneable {
|
||||
@@ -192,8 +196,7 @@ public class ActorCondition extends JSONElement {
|
||||
if (vfx != null) {
|
||||
try {
|
||||
this.round_effect.visual_effect = VisualEffectID.valueOf(vfx);
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
} catch(IllegalArgumentException e) {}
|
||||
}
|
||||
}
|
||||
Map fullRoundEffect = (Map) aCondJson.get("fullRoundEffect");
|
||||
@@ -212,8 +215,7 @@ public class ActorCondition extends JSONElement {
|
||||
if (vfx != null) {
|
||||
try {
|
||||
this.full_round_effect.visual_effect = VisualEffectID.valueOf(vfx);
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
} catch(IllegalArgumentException e) {}
|
||||
}
|
||||
}
|
||||
this.state = State.parsed;
|
||||
@@ -222,10 +224,17 @@ public class ActorCondition extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (shouldSkipParseOrLink()) {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//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;
|
||||
}
|
||||
ensureParseIfNeeded();
|
||||
if (this.icon_id != null) {
|
||||
String spritesheetId = this.icon_id.split(":")[0];
|
||||
if (getProject().getSpritesheet(spritesheetId) == null) {
|
||||
@@ -299,8 +308,7 @@ public class ActorCondition extends JSONElement {
|
||||
if (this.stacking != null && this.stacking == 1) jsonAC.put("isStacking", this.stacking);
|
||||
if (this.round_effect != null) {
|
||||
Map jsonRound = new LinkedHashMap();
|
||||
if (this.round_effect.visual_effect != null)
|
||||
jsonRound.put("visualEffectID", this.round_effect.visual_effect.toString());
|
||||
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) {
|
||||
Map jsonHP = new LinkedHashMap();
|
||||
if (this.round_effect.hp_boost_min != null) jsonHP.put("min", this.round_effect.hp_boost_min);
|
||||
@@ -321,8 +329,7 @@ public class ActorCondition extends JSONElement {
|
||||
}
|
||||
if (this.full_round_effect != null) {
|
||||
Map jsonFullRound = new LinkedHashMap();
|
||||
if (this.full_round_effect.visual_effect != null)
|
||||
jsonFullRound.put("visualEffectID", this.full_round_effect.visual_effect.toString());
|
||||
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) {
|
||||
Map jsonHP = new LinkedHashMap();
|
||||
if (this.full_round_effect.hp_boost_min != null) jsonHP.put("min", this.full_round_effect.hp_boost_min);
|
||||
@@ -343,36 +350,24 @@ public class ActorCondition extends JSONElement {
|
||||
}
|
||||
if (this.constant_ability_effect != null) {
|
||||
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) {
|
||||
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);
|
||||
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);
|
||||
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_ap_boost != null)
|
||||
jsonAbility.put("increaseMaxAP", this.constant_ability_effect.max_ap_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.increase_use_cost != null)
|
||||
jsonAbility.put("increaseUseItemCost", this.constant_ability_effect.increase_use_cost);
|
||||
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);
|
||||
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_ap_boost != null) jsonAbility.put("increaseMaxAP", this.constant_ability_effect.max_ap_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.increase_use_cost != null) jsonAbility.put("increaseUseItemCost", this.constant_ability_effect.increase_use_cost);
|
||||
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);
|
||||
}
|
||||
return jsonAC;
|
||||
|
||||
@@ -1,384 +0,0 @@
|
||||
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,5 +1,19 @@
|
||||
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.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||
@@ -7,16 +21,6 @@ import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement.RequirementType;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||
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 {
|
||||
@@ -170,13 +174,10 @@ public class Dialogue extends JSONElement {
|
||||
Requirement requirement = new Requirement();
|
||||
requirement.jsonFile = this.jsonFile;
|
||||
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");
|
||||
if (requirementJson.get("value") != null)
|
||||
requirement.required_value = JSONElement.getInteger(Integer.parseInt(requirementJson.get("value").toString()));
|
||||
if (requirementJson.get("negate") != null)
|
||||
requirement.negated = (Boolean) requirementJson.get("negate");
|
||||
if (requirementJson.get("value") != null) 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;
|
||||
reply.requirements.add(requirement);
|
||||
}
|
||||
@@ -190,11 +191,9 @@ public class Dialogue extends JSONElement {
|
||||
for (Object rewardJsonObj : rewardsJson) {
|
||||
Map rewardJson = (Map)rewardJsonObj;
|
||||
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("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");
|
||||
this.rewards.add(reward);
|
||||
}
|
||||
@@ -203,12 +202,21 @@ public class Dialogue extends JSONElement {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (shouldSkipParseOrLink()) {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//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;
|
||||
}
|
||||
ensureParseIfNeeded();
|
||||
Project proj = getProject();
|
||||
if (proj == null) {
|
||||
Notification.addError("Error linking dialogue "+id+". No parent project found.");
|
||||
@@ -286,6 +294,7 @@ public class Dialogue extends JSONElement {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Image getIcon() {
|
||||
return DefaultIcons.getDialogueIcon();
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
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.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.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
@@ -18,6 +10,15 @@ 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.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 {
|
||||
|
||||
@@ -128,10 +129,17 @@ public class Droplist extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (shouldSkipParseOrLink()) {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//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;
|
||||
}
|
||||
ensureParseIfNeeded();
|
||||
Project proj = getProject();
|
||||
if (proj == null) {
|
||||
Notification.addError("Error linking droplist "+id+". No parent project found.");
|
||||
@@ -147,6 +155,7 @@ public class Droplist extends JSONElement {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Image getImage() {
|
||||
return DefaultIcons.getDroplistImage();
|
||||
}
|
||||
|
||||
@@ -1,115 +1,45 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.gamedata;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.model.*;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||
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.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.tree.TreeNode;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
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 org.json.simple.JSONArray;
|
||||
|
||||
//endregion
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
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 String name;
|
||||
|
||||
public GameDataCategory(GameDataSet parent, String name) {
|
||||
super();
|
||||
this.parent = parent;
|
||||
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
|
||||
public TreeNode getChildAt(int childIndex) {
|
||||
return get(childIndex);
|
||||
@@ -127,7 +57,7 @@ public class GameDataCategory<E extends JSONElement> implements ProjectTreeNode
|
||||
|
||||
@Override
|
||||
public int getIndex(TreeNode node) {
|
||||
return indexOf((E) node);
|
||||
return indexOf(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,21 +72,18 @@ public class GameDataCategory<E extends JSONElement> implements ProjectTreeNode
|
||||
|
||||
@Override
|
||||
public Enumeration<E> children() {
|
||||
return Collections.enumeration(toList());
|
||||
return Collections.enumeration(this);
|
||||
}
|
||||
|
||||
@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) {
|
||||
@@ -166,15 +93,13 @@ public class GameDataCategory<E extends JSONElement> implements ProjectTreeNode
|
||||
parent.childrenRemoved(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
for (E node : dataMap.values()) {
|
||||
for (E node : this) {
|
||||
node.notifyCreated();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return (needsSaving() ? "*" : "")+this.name;
|
||||
@@ -194,17 +119,14 @@ public class GameDataCategory<E extends JSONElement> implements ProjectTreeNode
|
||||
public Image getIcon() {
|
||||
return getOpenIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
return DefaultIcons.getJsonClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
return DefaultIcons.getJsonClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
return DefaultIcons.getJsonOpenIcon();
|
||||
@@ -216,15 +138,10 @@ public class GameDataCategory<E extends JSONElement> implements ProjectTreeNode
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameSource.Type getDataType() {
|
||||
public Type getDataType() {
|
||||
return parent.getDataType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return dataMap.isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void save(File jsonFile) {
|
||||
if (getDataType() != GameSource.Type.created && getDataType() != GameSource.Type.altered) {
|
||||
@@ -232,7 +149,7 @@ public class GameDataCategory<E extends JSONElement> implements ProjectTreeNode
|
||||
return;
|
||||
}
|
||||
List<Map> dataToSave = new ArrayList<Map>();
|
||||
for (E element : dataMap.values()) {
|
||||
for (E element : this) {
|
||||
if (element.jsonFile.equals(jsonFile)) {
|
||||
dataToSave.add(element.toJson());
|
||||
}
|
||||
@@ -246,13 +163,26 @@ public class GameDataCategory<E extends JSONElement> implements ProjectTreeNode
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String toWrite = FileUtils.toJsonString(dataToSave);
|
||||
if(FileUtils.writeStringToFile(toWrite, jsonFile, "JSON file '"+jsonFile.getAbsolutePath()+"'")){
|
||||
for (E element : dataMap.values()) {
|
||||
StringWriter writer = new JsonPrettyWriter();
|
||||
try {
|
||||
JSONArray.writeJSONString(dataToSave, writer);
|
||||
} catch (IOException e) {
|
||||
//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;
|
||||
}
|
||||
Notification.addSuccess("Json file "+jsonFile.getAbsolutePath()+" saved.");
|
||||
} catch (IOException e) {
|
||||
Notification.addError("Error while writing json file "+jsonFile.getAbsolutePath()+" : "+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -261,8 +191,7 @@ public class GameDataCategory<E extends JSONElement> implements ProjectTreeNode
|
||||
GameDataCategory<? extends JSONElement> impactedCategory = null;
|
||||
String impactedFileName = fileName;
|
||||
Map<String, Integer> containedIds = new LinkedHashMap<String, Integer>();
|
||||
ArrayList<E> list = toList();
|
||||
for (JSONElement node : list) {
|
||||
for (JSONElement node : this) {
|
||||
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) {
|
||||
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."));
|
||||
@@ -291,14 +220,13 @@ public class GameDataCategory<E extends JSONElement> implements ProjectTreeNode
|
||||
for (String key : containedIds.keySet()) {
|
||||
if (containedIds.get(key) > 1) {
|
||||
E node = null;
|
||||
for (E n : list) {
|
||||
for (E n : this) {
|
||||
if (key.equals(n.id)) {
|
||||
node = n;
|
||||
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) {
|
||||
@@ -307,15 +235,19 @@ public class GameDataCategory<E extends JSONElement> implements ProjectTreeNode
|
||||
return events;
|
||||
}
|
||||
|
||||
public boolean remove(E o) {
|
||||
int index = getProject().getNodeIndex(o);
|
||||
boolean result = super.remove(o);
|
||||
getProject().fireElementRemoved(o, index);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
for (E node : dataMap.values()) {
|
||||
for (E node : this) {
|
||||
if (node.needsSaving()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
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.model.GameSource;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||
@@ -9,14 +18,6 @@ import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
import com.gpl.rpg.atcontentstudio.model.SavedSlotCollection;
|
||||
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 {
|
||||
|
||||
@@ -67,7 +68,7 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
||||
items = new GameDataCategory<Item>(this, Item.getStaticDesc());
|
||||
itemCategories = new GameDataCategory<ItemCategory>(this, ItemCategory.getStaticDesc());
|
||||
npcs = new GameDataCategory<NPC>(this, NPC.getStaticDesc());
|
||||
quests = new GameDataCategory<>(this, Quest.getStaticDesc());
|
||||
quests = new GameDataCategory<Quest>(this, Quest.getStaticDesc());
|
||||
|
||||
v.add(actorConditions);
|
||||
v.add(dialogues);
|
||||
@@ -183,49 +184,40 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
||||
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) {
|
||||
@@ -235,7 +227,6 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
||||
parent.childrenRemoved(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
@@ -243,7 +234,6 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
||||
node.notifyCreated();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return (needsSaving() ? "*" : "")+"JSON data";
|
||||
@@ -256,42 +246,82 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
||||
|
||||
public ActorCondition getActorCondition(String id) {
|
||||
if (actorConditions == null) return null;
|
||||
return actorConditions.get(id);
|
||||
for (ActorCondition gde : actorConditions) {
|
||||
if (id.equals(gde.id)){
|
||||
return gde;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Dialogue getDialogue(String id) {
|
||||
if (dialogues == null) return null;
|
||||
return dialogues.get(id);
|
||||
for (Dialogue gde : dialogues) {
|
||||
if (id.equals(gde.id)){
|
||||
return gde;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Droplist getDroplist(String id) {
|
||||
if (droplists == null) return null;
|
||||
return droplists.get(id);
|
||||
for (Droplist gde : droplists) {
|
||||
if (id.equals(gde.id)){
|
||||
return gde;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Item getItem(String id) {
|
||||
if (items == null) return null;
|
||||
return items.get(id);
|
||||
for (Item gde : items) {
|
||||
if (id.equals(gde.id)){
|
||||
return gde;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemCategory getItemCategory(String id) {
|
||||
if (itemCategories == null) return null;
|
||||
return itemCategories.get(id);
|
||||
for (ItemCategory gde : itemCategories) {
|
||||
if (id.equals(gde.id)){
|
||||
return gde;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public NPC getNPC(String id) {
|
||||
if (npcs == null) return null;
|
||||
return npcs.get(id);
|
||||
for (NPC gde : npcs) {
|
||||
if (id.equals(gde.id)){
|
||||
return gde;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public NPC getNPCIgnoreCase(String id) {
|
||||
if (npcs == null) return null;
|
||||
return npcs.getIgnoreCase(id);
|
||||
for (NPC gde : npcs) {
|
||||
if (id.equalsIgnoreCase(gde.id)){
|
||||
return gde;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Quest getQuest(String id) {
|
||||
if (quests == null) return null;
|
||||
return quests.get(id);
|
||||
for (Quest gde : quests) {
|
||||
if (id.equals(gde.id)){
|
||||
return gde;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -304,17 +334,14 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
||||
public Image getIcon() {
|
||||
return getOpenIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
return DefaultIcons.getJsonClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
return DefaultIcons.getJsonClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
return DefaultIcons.getJsonOpenIcon();
|
||||
@@ -323,8 +350,7 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
||||
public void addElement(JSONElement node) {
|
||||
ProjectTreeNode higherEmptyParent = this;
|
||||
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;
|
||||
}
|
||||
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
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.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.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
@@ -17,7 +10,13 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.gpl.rpg.atcontentstudio.model.gamedata.Common.*;
|
||||
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;
|
||||
|
||||
public class Item extends JSONElement {
|
||||
|
||||
@@ -36,20 +35,45 @@ public class Item extends JSONElement {
|
||||
public String description = null;
|
||||
public HitEffect hit_effect = null;
|
||||
public HitReceivedEffect hit_received_effect = null;
|
||||
public DeathEffect kill_effect = null;
|
||||
public KillEffect kill_effect = null;
|
||||
public EquipEffect equip_effect = null;
|
||||
|
||||
//Available from linked state
|
||||
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 HitReceivedEffect extends HitEffect {
|
||||
//Available from parsed state
|
||||
public Integer hp_boost_min_target = null;
|
||||
public Integer hp_boost_max_target = null;
|
||||
public Integer ap_boost_min_target = null;
|
||||
public Integer ap_boost_max_target = null;
|
||||
}
|
||||
|
||||
public static class EquipEffect {
|
||||
//Available from parsed state
|
||||
public Integer damage_boost_min = null;
|
||||
public Integer damage_boost_max = null;
|
||||
public Integer max_hp_boost = null;
|
||||
public Integer max_ap_boost = null;
|
||||
public List<ActorConditionEffect> conditions = null;
|
||||
public List<ConditionEffect> conditions = null;
|
||||
public Integer increase_move_cost = null;
|
||||
public Integer increase_use_item_cost = null;
|
||||
public Integer increase_reequip_cost = null;
|
||||
@@ -62,6 +86,20 @@ public class Item extends JSONElement {
|
||||
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 {
|
||||
ordinary,
|
||||
@@ -130,8 +168,7 @@ public class Item extends JSONElement {
|
||||
item.icon_id = (String) itemJson.get("iconID");
|
||||
item.id = (String) itemJson.get("id");
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -165,16 +202,15 @@ public class Item extends JSONElement {
|
||||
this.equip_effect.increase_damage_resistance = JSONElement.getInteger((Number) equipEffect.get("increaseDamageResistance"));
|
||||
//TODO correct game data, to unify format.
|
||||
// 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");
|
||||
if (conditionsJson != null && !conditionsJson.isEmpty()) {
|
||||
this.equip_effect.conditions = new ArrayList<>();
|
||||
this.equip_effect.conditions = new ArrayList<Item.ConditionEffect>();
|
||||
for (Object conditionJsonObj : conditionsJson) {
|
||||
Map conditionJson = (Map)conditionJsonObj;
|
||||
ActorConditionEffect condition = new ActorConditionEffect();
|
||||
ConditionEffect condition = new ConditionEffect();
|
||||
condition.condition_id = (String) conditionJson.get("condition");
|
||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
||||
this.equip_effect.conditions.add(condition);
|
||||
@@ -185,12 +221,88 @@ public class Item extends JSONElement {
|
||||
|
||||
Map hitEffect = (Map) itemJson.get("hitEffect");
|
||||
if (hitEffect != null) {
|
||||
this.hit_effect = parseHitEffect(hitEffect);
|
||||
this.hit_effect = new 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);
|
||||
this.hit_received_effect = new HitReceivedEffect();
|
||||
if (hitReceivedEffect.get("increaseCurrentHP") != null) {
|
||||
this.hit_received_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentHP")).get("min")));
|
||||
this.hit_received_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentHP")).get("max")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseCurrentAP") != null) {
|
||||
this.hit_received_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentAP")).get("min")));
|
||||
this.hit_received_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentAP")).get("max")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseAttackerCurrentHP") != null) {
|
||||
this.hit_received_effect.hp_boost_min_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentHP")).get("min")));
|
||||
this.hit_received_effect.hp_boost_max_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentHP")).get("max")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseAttackerCurrentAP") != null) {
|
||||
this.hit_received_effect.ap_boost_min_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentAP")).get("min")));
|
||||
this.hit_received_effect.ap_boost_max_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentAP")).get("max")));
|
||||
}
|
||||
List conditionsSourceJson = (List) hitReceivedEffect.get("conditionsSource");
|
||||
if (conditionsSourceJson != null && !conditionsSourceJson.isEmpty()) {
|
||||
this.hit_received_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_received_effect.conditions_source.add(condition);
|
||||
}
|
||||
}
|
||||
List conditionsTargetJson = (List) hitReceivedEffect.get("conditionsTarget");
|
||||
if (conditionsTargetJson != null && !conditionsTargetJson.isEmpty()) {
|
||||
this.hit_received_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_received_effect.conditions_target.add(condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map killEffect = (Map) itemJson.get("killEffect");
|
||||
@@ -198,7 +310,28 @@ public class Item extends JSONElement {
|
||||
killEffect = (Map) itemJson.get("useEffect");
|
||||
}
|
||||
if (killEffect != null) {
|
||||
this.kill_effect = parseDeathEffect(killEffect);
|
||||
this.kill_effect = new 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;
|
||||
}
|
||||
@@ -206,30 +339,68 @@ public class Item extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (shouldSkipParseOrLink()) {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//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;
|
||||
}
|
||||
ensureParseIfNeeded();
|
||||
Project proj = getProject();
|
||||
if (proj == null) {
|
||||
Notification.addError("Error linking item "+id+". No parent project found.");
|
||||
return;
|
||||
}
|
||||
|
||||
linkIcon(proj, this.icon_id, this);
|
||||
if (this.icon_id != null) {
|
||||
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 != null) this.category.addBacklink(this);
|
||||
if (this.equip_effect != null && this.equip_effect.conditions != null) {
|
||||
linkConditions(this.equip_effect.conditions, proj, this);
|
||||
for (ConditionEffect ce : this.equip_effect.conditions) {
|
||||
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.hit_received_effect != null && this.hit_received_effect.conditions_source != null) {
|
||||
for (TimedConditionEffect ce : this.hit_received_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_received_effect != null && this.hit_received_effect.conditions_target != null) {
|
||||
for (TimedConditionEffect ce : this.hit_received_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;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Image getIcon() {
|
||||
return getProject().getIcon(icon_id);
|
||||
@@ -273,9 +444,9 @@ public class Item extends JSONElement {
|
||||
clone.equip_effect.max_ap_boost = this.equip_effect.max_ap_boost;
|
||||
clone.equip_effect.max_hp_boost = this.equip_effect.max_hp_boost;
|
||||
if (this.equip_effect.conditions != null) {
|
||||
clone.equip_effect.conditions = new ArrayList<>();
|
||||
for (ActorConditionEffect c : this.equip_effect.conditions) {
|
||||
ActorConditionEffect cclone = new ActorConditionEffect();
|
||||
clone.equip_effect.conditions = new ArrayList<Item.ConditionEffect>();
|
||||
for (ConditionEffect c : this.equip_effect.conditions) {
|
||||
ConditionEffect cclone = new ConditionEffect();
|
||||
cclone.magnitude = c.magnitude;
|
||||
cclone.condition_id = c.condition_id;
|
||||
cclone.condition = c.condition;
|
||||
@@ -288,15 +459,103 @@ public class Item extends JSONElement {
|
||||
}
|
||||
if (this.hit_effect != null) {
|
||||
clone.hit_effect = new HitEffect();
|
||||
copyHitEffectValues(clone.hit_effect, this.hit_effect, clone);
|
||||
clone.hit_effect.ap_boost_max = this.hit_effect.ap_boost_max;
|
||||
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);
|
||||
clone.hit_received_effect.ap_boost_max = this.hit_received_effect.ap_boost_max;
|
||||
clone.hit_received_effect.ap_boost_min = this.hit_received_effect.ap_boost_min;
|
||||
clone.hit_received_effect.hp_boost_max = this.hit_received_effect.hp_boost_max;
|
||||
clone.hit_received_effect.hp_boost_min = this.hit_received_effect.hp_boost_min;
|
||||
clone.hit_received_effect.ap_boost_max_target = this.hit_received_effect.ap_boost_max_target;
|
||||
clone.hit_received_effect.ap_boost_min_target = this.hit_received_effect.ap_boost_min_target;
|
||||
clone.hit_received_effect.hp_boost_max_target = this.hit_received_effect.hp_boost_max_target;
|
||||
clone.hit_received_effect.hp_boost_min_target = this.hit_received_effect.hp_boost_min_target;
|
||||
if (this.hit_received_effect.conditions_source != null) {
|
||||
clone.hit_received_effect.conditions_source = new ArrayList<Item.TimedConditionEffect>();
|
||||
for (TimedConditionEffect c : this.hit_received_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_received_effect.conditions_source.add(cclone);
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect.conditions_target != null) {
|
||||
clone.hit_received_effect.conditions_target = new ArrayList<Item.TimedConditionEffect>();
|
||||
for (TimedConditionEffect c : this.hit_received_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_received_effect.conditions_target.add(cclone);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.kill_effect != null) {
|
||||
clone.kill_effect = new DeathEffect();
|
||||
copyDeathEffectValues(clone.kill_effect, this.kill_effect, clone);
|
||||
clone.kill_effect = new KillEffect();
|
||||
clone.kill_effect.ap_boost_max = this.kill_effect.ap_boost_max;
|
||||
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;
|
||||
}
|
||||
@@ -308,18 +567,42 @@ public class Item extends JSONElement {
|
||||
this.category = (ItemCategory) newOne;
|
||||
if (newOne != null) newOne.addBacklink(this);
|
||||
} else {
|
||||
if (this.equip_effect != null) {
|
||||
if (this.equip_effect.conditions != null) {
|
||||
actorConditionElementChanged(this.equip_effect.conditions, oldOne, newOne, this);
|
||||
if (this.equip_effect != null && this.equip_effect.conditions != null) {
|
||||
for (ConditionEffect c : this.equip_effect.conditions) {
|
||||
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_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) {
|
||||
actorConditionElementChanged(this.kill_effect.conditions_source, oldOne, newOne, this);
|
||||
if (this.kill_effect != null && this.kill_effect.conditions_source != null) {
|
||||
for (TimedConditionEffect c : this.kill_effect.conditions_source) {
|
||||
if (c.condition == oldOne) {
|
||||
oldOne.removeBacklink(this);
|
||||
c.condition = (ActorCondition) newOne;
|
||||
if (newOne != null) newOne.addBacklink(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,7 +612,7 @@ public class Item extends JSONElement {
|
||||
public Map toJson() {
|
||||
Map itemJson = new LinkedHashMap();
|
||||
itemJson.put("id", this.id);
|
||||
writeIconToMap(itemJson, this.icon_id);
|
||||
if (this.icon_id != null) itemJson.put("iconID", this.icon_id);
|
||||
if (this.name != null) itemJson.put("name", this.name);
|
||||
if(this.display_type != null) itemJson.put("displaytype", this.display_type.toString());
|
||||
|
||||
@@ -340,65 +623,208 @@ public class Item extends JSONElement {
|
||||
} else if (this.category_id != null) {
|
||||
itemJson.put("category", this.category_id);
|
||||
}
|
||||
writeDescriptionToMap(itemJson, this.description);
|
||||
if (this.description != null) itemJson.put("description", this.description);
|
||||
if (this.equip_effect != null) {
|
||||
Map equipEffectJson = new LinkedHashMap();
|
||||
itemJson.put("equipEffect", equipEffectJson);
|
||||
writeMinMaxToMap(equipEffectJson, "increaseAttackDamage", this.equip_effect.damage_boost_min, this.equip_effect.damage_boost_max, 0);
|
||||
if (this.equip_effect.max_hp_boost != null)
|
||||
equipEffectJson.put("increaseMaxHP", this.equip_effect.max_hp_boost);
|
||||
if (this.equip_effect.max_ap_boost != null)
|
||||
equipEffectJson.put("increaseMaxAP", this.equip_effect.max_ap_boost);
|
||||
if (this.equip_effect.increase_move_cost != null)
|
||||
equipEffectJson.put("increaseMoveCost", this.equip_effect.increase_move_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_reequip_cost != null)
|
||||
equipEffectJson.put("increaseReequipCost", this.equip_effect.increase_reequip_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)
|
||||
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_block_chance != null)
|
||||
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.damage_boost_min != null || this.equip_effect.damage_boost_max != null) {
|
||||
Map damageJson = new LinkedHashMap();
|
||||
equipEffectJson.put("increaseAttackDamage", damageJson);
|
||||
if (this.equip_effect.damage_boost_min != null) damageJson.put("min", this.equip_effect.damage_boost_min);
|
||||
else damageJson.put("min", 0);
|
||||
if (this.equip_effect.damage_boost_max != null) damageJson.put("max", this.equip_effect.damage_boost_max);
|
||||
else damageJson.put("max", 0);
|
||||
}
|
||||
if (this.equip_effect.max_hp_boost != null) equipEffectJson.put("increaseMaxHP", this.equip_effect.max_hp_boost);
|
||||
if (this.equip_effect.max_ap_boost != null) equipEffectJson.put("increaseMaxAP", this.equip_effect.max_ap_boost);
|
||||
if (this.equip_effect.increase_move_cost != null) equipEffectJson.put("increaseMoveCost", this.equip_effect.increase_move_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_reequip_cost != null) equipEffectJson.put("increaseReequipCost", this.equip_effect.increase_reequip_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) 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_block_chance != null) 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) {
|
||||
List conditionsJson = new ArrayList();
|
||||
equipEffectJson.put("addedConditions", conditionsJson);
|
||||
for (ActorConditionEffect condition : this.equip_effect.conditions) {
|
||||
for (ConditionEffect condition : this.equip_effect.conditions) {
|
||||
Map conditionJson = new LinkedHashMap();
|
||||
conditionsJson.add(conditionJson);
|
||||
writeConditionEffectToMap(condition, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
writeHitEffectToMap(itemJson, this.hit_effect, "hitEffect");
|
||||
writeHitReceivedEffectToMap(itemJson, this.hit_received_effect, "hitReceivedEffect");
|
||||
|
||||
String key;
|
||||
if (this.hit_effect != null) {
|
||||
Map hitEffectJson = new LinkedHashMap();
|
||||
itemJson.put("hitEffect", hitEffectJson);
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect != null) {
|
||||
Map hitReceivedEffectJson = new LinkedHashMap();
|
||||
itemJson.put("hitReceivedEffect", hitReceivedEffectJson);
|
||||
if (this.hit_received_effect.hp_boost_min != null || this.hit_received_effect.hp_boost_max != null) {
|
||||
Map hpJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseCurrentHP", hpJson);
|
||||
if (this.hit_received_effect.hp_boost_min != null) hpJson.put("min", this.hit_received_effect.hp_boost_min);
|
||||
else hpJson.put("min", 0);
|
||||
if (this.hit_received_effect.hp_boost_max != null) hpJson.put("max", this.hit_received_effect.hp_boost_max);
|
||||
else hpJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.ap_boost_min != null || this.hit_received_effect.ap_boost_max != null) {
|
||||
Map apJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseCurrentAP", apJson);
|
||||
if (this.hit_received_effect.ap_boost_min != null) apJson.put("min", this.hit_received_effect.ap_boost_min);
|
||||
else apJson.put("min", 0);
|
||||
if (this.hit_received_effect.ap_boost_max != null) apJson.put("max", this.hit_received_effect.ap_boost_max);
|
||||
else apJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.hp_boost_min_target != null || this.hit_received_effect.hp_boost_max_target != null) {
|
||||
Map hpJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseAttackerCurrentHP", hpJson);
|
||||
if (this.hit_received_effect.hp_boost_min_target != null) hpJson.put("min", this.hit_received_effect.hp_boost_min_target);
|
||||
else hpJson.put("min", 0);
|
||||
if (this.hit_received_effect.hp_boost_max_target != null) hpJson.put("max", this.hit_received_effect.hp_boost_max_target);
|
||||
else hpJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.ap_boost_min_target != null || this.hit_received_effect.ap_boost_max_target != null) {
|
||||
Map apJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseAttackerCurrentAP", apJson);
|
||||
if (this.hit_received_effect.ap_boost_min_target != null) apJson.put("min", this.hit_received_effect.ap_boost_min_target);
|
||||
else apJson.put("min", 0);
|
||||
if (this.hit_received_effect.ap_boost_max_target != null) apJson.put("max", this.hit_received_effect.ap_boost_max_target);
|
||||
else apJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.conditions_source != null) {
|
||||
List conditionsSourceJson = new ArrayList();
|
||||
hitReceivedEffectJson.put("conditionsSource", conditionsSourceJson);
|
||||
for (TimedConditionEffect condition : this.hit_received_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_received_effect.conditions_target != null) {
|
||||
List conditionsTargetJson = new ArrayList();
|
||||
hitReceivedEffectJson.put("conditionsTarget", conditionsTargetJson);
|
||||
for (TimedConditionEffect condition : this.hit_received_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) {
|
||||
key = "killEffect";
|
||||
itemJson.put("killEffect", killEffectJson);
|
||||
} else if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.use) {
|
||||
key = "useEffect";
|
||||
} else {
|
||||
System.out.println("Could not create JSON-Map for Item: Failed to determine if the item should be used or equipped.");
|
||||
key = null;
|
||||
itemJson.put("useEffect", killEffectJson);
|
||||
}
|
||||
if (this.kill_effect.hp_boost_min != null || this.kill_effect.hp_boost_max != null) {
|
||||
Map hpJson = new LinkedHashMap();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getProjectFilename() {
|
||||
return "itemlist_"+getProject().name+".json";
|
||||
@@ -410,7 +836,7 @@ public class Item extends JSONElement {
|
||||
if (category.action_type == ItemCategory.ActionType.use) {
|
||||
price += kill_effect == null ? 0 : calculateUseCost();
|
||||
} 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 += kill_effect == null ? 0 : calculateKillCost();
|
||||
}
|
||||
@@ -438,8 +864,7 @@ public class Item extends JSONElement {
|
||||
|
||||
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 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 ?
|
||||
(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);
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
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.GameSource;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
@@ -16,6 +9,15 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = -348864002519568300L;
|
||||
@@ -154,16 +156,14 @@ public class ItemCategory extends JSONElement {
|
||||
ItemCategory itemCat = new ItemCategory();
|
||||
itemCat.id = (String) itemCatJson.get("id");
|
||||
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;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
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"));
|
||||
this.state = State.parsed;
|
||||
|
||||
@@ -171,10 +171,17 @@ public class ItemCategory extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (shouldSkipParseOrLink()) {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//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;
|
||||
}
|
||||
ensureParseIfNeeded();
|
||||
|
||||
//Nothing to link to :D
|
||||
this.state = State.linked;
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
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.io.JsonPrettyWriter;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
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 {
|
||||
|
||||
@@ -22,7 +26,8 @@ public abstract class JSONElement extends GameDataElement {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void parse() {
|
||||
if (shouldSkipParse()) {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//This type of state is unrelated to parsing/linking.
|
||||
return;
|
||||
}
|
||||
JSONParser parser = new JSONParser();
|
||||
@@ -39,7 +44,8 @@ public abstract class JSONElement extends GameDataElement {
|
||||
this.state = State.parsed;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch(Exception e){
|
||||
System.out.println("Error in ID: " + id);
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
@@ -72,11 +78,16 @@ public abstract class JSONElement extends GameDataElement {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract Map toJson();
|
||||
|
||||
public String toJsonString() {
|
||||
Map json = this.toJson();
|
||||
return FileUtils.toJsonString(json);
|
||||
StringWriter writer = new JsonPrettyWriter();
|
||||
try {
|
||||
JSONObject.writeJSONString(this.toJson(), writer);
|
||||
} catch (IOException e) {
|
||||
//Impossible with a StringWriter
|
||||
}
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public GameDataSet getDataSet() {
|
||||
@@ -131,20 +142,18 @@ public abstract class JSONElement extends GameDataElement {
|
||||
double a = 1;
|
||||
try {
|
||||
a = Integer.parseInt(s.substring(0, c));
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
} catch (NumberFormatException nfe) {}
|
||||
double b = 100;
|
||||
try {
|
||||
b = Integer.parseInt(s.substring(c+1));
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
} catch (NumberFormatException nfe) {}
|
||||
return a/b;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
double a = 10;
|
||||
try {
|
||||
a = Double.parseDouble(s);
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
} catch (NumberFormatException nfe) {}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
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.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.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 {
|
||||
|
||||
@@ -73,6 +73,40 @@ public class NPC extends JSONElement {
|
||||
wholeMap
|
||||
}
|
||||
|
||||
public static class DeathEffect {
|
||||
//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 static class HitEffect extends DeathEffect {
|
||||
//Available from parsed state
|
||||
public List<TimedConditionEffect> conditions_target = null;
|
||||
}
|
||||
|
||||
public static class HitReceivedEffect extends HitEffect {
|
||||
//Available from parsed state
|
||||
public Integer hp_boost_min_target = null;
|
||||
public Integer hp_boost_max_target = null;
|
||||
public Integer ap_boost_min_target = null;
|
||||
public Integer ap_boost_max_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
|
||||
public String getDesc() {
|
||||
return (needsSaving() ? "*" : "")+name+" ("+id+")";
|
||||
@@ -145,10 +179,8 @@ public class NPC extends JSONElement {
|
||||
this.max_ap = JSONElement.getInteger((Number) npcJson.get("maxAP"));
|
||||
this.move_cost = JSONElement.getInteger((Number) npcJson.get("moveCost"));
|
||||
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("movementAggressionType") != null)
|
||||
this.movement_type = MovementType.valueOf((String) npcJson.get("movementAggressionType"));
|
||||
if (npcJson.get("monsterClass") != null) 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) {
|
||||
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")));
|
||||
@@ -162,49 +194,184 @@ public class NPC extends JSONElement {
|
||||
this.critical_skill = JSONElement.getInteger((Number) npcJson.get("criticalSkill"));
|
||||
//TODO correct game data, to unify format.
|
||||
// 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.damage_resistance = JSONElement.getInteger((Number) npcJson.get("damageResistance"));
|
||||
|
||||
Map hitEffect = (Map) npcJson.get("hitEffect");
|
||||
if (hitEffect != null) {
|
||||
this.hit_effect = parseHitEffect(hitEffect);
|
||||
this.hit_effect = new 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);
|
||||
this.hit_received_effect = new HitReceivedEffect();
|
||||
if (hitReceivedEffect.get("increaseCurrentHP") != null) {
|
||||
this.hit_received_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentHP")).get("max")));
|
||||
this.hit_received_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentHP")).get("min")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseCurrentAP") != null) {
|
||||
this.hit_received_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentAP")).get("max")));
|
||||
this.hit_received_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentAP")).get("min")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseAttackerCurrentHP") != null) {
|
||||
this.hit_received_effect.hp_boost_max_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentHP")).get("max")));
|
||||
this.hit_received_effect.hp_boost_min_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentHP")).get("min")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseAttackerCurrentAP") != null) {
|
||||
this.hit_received_effect.ap_boost_max_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentAP")).get("max")));
|
||||
this.hit_received_effect.ap_boost_min_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentAP")).get("min")));
|
||||
}
|
||||
List conditionsSourceJson = (List) hitReceivedEffect.get("conditionsSource");
|
||||
if (conditionsSourceJson != null && !conditionsSourceJson.isEmpty()) {
|
||||
this.hit_received_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_received_effect.conditions_source.add(condition);
|
||||
}
|
||||
}
|
||||
List conditionsTargetJson = (List) hitReceivedEffect.get("conditionsTarget");
|
||||
if (conditionsTargetJson != null && !conditionsTargetJson.isEmpty()) {
|
||||
this.hit_received_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_received_effect.conditions_target.add(condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map deathEffect = (Map) npcJson.get("deathEffect");
|
||||
if (deathEffect != null) {
|
||||
this.death_effect = parseDeathEffect(deathEffect);
|
||||
this.death_effect = new HitEffect();
|
||||
if (deathEffect.get("increaseCurrentHP") != null) {
|
||||
this.death_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map)deathEffect.get("increaseCurrentHP")).get("max")));
|
||||
this.death_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map)deathEffect.get("increaseCurrentHP")).get("min")));
|
||||
}
|
||||
if (deathEffect.get("increaseCurrentAP") != null) {
|
||||
this.death_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)deathEffect.get("increaseCurrentAP")).get("max")));
|
||||
this.death_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)deathEffect.get("increaseCurrentAP")).get("min")));
|
||||
}
|
||||
List conditionsSourceJson = (List) deathEffect.get("conditionsSource");
|
||||
if (conditionsSourceJson != null && !conditionsSourceJson.isEmpty()) {
|
||||
this.death_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.death_effect.conditions_source.add(condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (shouldSkipParseOrLink()) {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//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;
|
||||
}
|
||||
ensureParseIfNeeded();
|
||||
Project proj = getProject();
|
||||
if (proj == null) {
|
||||
Notification.addError("Error linking item "+id+". No parent project found.");
|
||||
return;
|
||||
}
|
||||
linkIcon(proj, this.icon_id, this);
|
||||
if (this.icon_id != null) {
|
||||
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 != null) this.dialogue.addBacklink(this);
|
||||
|
||||
if (this.droplist_id != null) this.droplist = proj.getDroplist(this.droplist_id);
|
||||
if (this.droplist != null) this.droplist.addBacklink(this);
|
||||
|
||||
linkEffects(this.hit_effect, proj, this);
|
||||
linkEffects(this.hit_received_effect, proj, this);
|
||||
linkEffects(this.death_effect, proj, 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.hit_received_effect != null && this.hit_received_effect.conditions_source != null) {
|
||||
for (TimedConditionEffect ce : this.hit_received_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_received_effect != null && this.hit_received_effect.conditions_target != null) {
|
||||
for (TimedConditionEffect ce : this.hit_received_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.death_effect != null && this.death_effect.conditions_source != null) {
|
||||
for (TimedConditionEffect ce : this.death_effect.conditions_source) {
|
||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
||||
}
|
||||
}
|
||||
this.state = State.linked;
|
||||
}
|
||||
|
||||
@@ -246,15 +413,103 @@ public class NPC extends JSONElement {
|
||||
clone.faction_id = this.faction_id;
|
||||
if (this.hit_effect != null) {
|
||||
clone.hit_effect = new HitEffect();
|
||||
copyHitEffectValues(clone.hit_effect, this.hit_effect, clone);
|
||||
clone.hit_effect.ap_boost_max = this.hit_effect.ap_boost_max;
|
||||
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);
|
||||
clone.hit_received_effect.ap_boost_max = this.hit_received_effect.ap_boost_max;
|
||||
clone.hit_received_effect.ap_boost_min = this.hit_received_effect.ap_boost_min;
|
||||
clone.hit_received_effect.hp_boost_max = this.hit_received_effect.hp_boost_max;
|
||||
clone.hit_received_effect.hp_boost_min = this.hit_received_effect.hp_boost_min;
|
||||
clone.hit_received_effect.ap_boost_max_target = this.hit_received_effect.ap_boost_max_target;
|
||||
clone.hit_received_effect.ap_boost_min_target = this.hit_received_effect.ap_boost_min_target;
|
||||
clone.hit_received_effect.hp_boost_max_target = this.hit_received_effect.hp_boost_max_target;
|
||||
clone.hit_received_effect.hp_boost_min_target = this.hit_received_effect.hp_boost_min_target;
|
||||
if (this.hit_received_effect.conditions_source != null) {
|
||||
clone.hit_received_effect.conditions_source = new ArrayList<TimedConditionEffect>();
|
||||
for (TimedConditionEffect c : this.hit_received_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_received_effect.conditions_source.add(cclone);
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect.conditions_target != null) {
|
||||
clone.hit_received_effect.conditions_target = new ArrayList<TimedConditionEffect>();
|
||||
for (TimedConditionEffect c : this.hit_received_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_received_effect.conditions_target.add(cclone);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.death_effect != null) {
|
||||
clone.death_effect = new DeathEffect();
|
||||
copyDeathEffectValues(clone.death_effect, this.death_effect, clone);
|
||||
clone.death_effect.ap_boost_max = this.death_effect.ap_boost_max;
|
||||
clone.death_effect.ap_boost_min = this.death_effect.ap_boost_min;
|
||||
clone.death_effect.hp_boost_max = this.death_effect.hp_boost_max;
|
||||
clone.death_effect.hp_boost_min = this.death_effect.hp_boost_min;
|
||||
if (this.death_effect.conditions_source != null) {
|
||||
clone.death_effect.conditions_source = new ArrayList<TimedConditionEffect>();
|
||||
for (TimedConditionEffect c : this.death_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.death_effect.conditions_source.add(cclone);
|
||||
}
|
||||
}
|
||||
}
|
||||
clone.max_ap = this.max_ap;
|
||||
clone.max_hp = this.max_hp;
|
||||
@@ -278,9 +533,23 @@ public class NPC extends JSONElement {
|
||||
this.droplist = (Droplist) newOne;
|
||||
if (newOne != null) newOne.addBacklink(this);
|
||||
} else {
|
||||
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.hit_effect != null && this.hit_effect.conditions_source != null) {
|
||||
for (TimedConditionEffect tce : this.hit_effect.conditions_source) {
|
||||
if (tce.condition == oldOne) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -292,14 +561,21 @@ public class NPC extends JSONElement {
|
||||
Map npcJson = new LinkedHashMap();
|
||||
npcJson.put("id", this.id);
|
||||
if (this.name != null) npcJson.put("name", this.name);
|
||||
writeIconToMap(npcJson, this.icon_id);
|
||||
if (this.icon_id != null) npcJson.put("iconID", this.icon_id);
|
||||
if (this.max_hp != null) npcJson.put("maxHP", this.max_hp);
|
||||
if (this.max_ap != null) npcJson.put("maxAP", this.max_ap);
|
||||
if (this.move_cost != null) npcJson.put("moveCost", this.move_cost);
|
||||
if (this.unique != null) npcJson.put("unique", this.unique);
|
||||
if (this.monster_class != null) npcJson.put("monsterClass", this.monster_class.toString());
|
||||
if (this.movement_type != null) npcJson.put("movementAggressionType", this.movement_type.toString());
|
||||
writeMinMaxToMap(npcJson, "attackDamage", this.attack_damage_min, attack_damage_max, 0);
|
||||
if (this.attack_damage_min != null || this.attack_damage_max != null) {
|
||||
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.faction_id != null) npcJson.put("faction", this.faction_id);
|
||||
if (this.dialogue != null) {
|
||||
@@ -318,9 +594,162 @@ public class NPC extends JSONElement {
|
||||
if (this.critical_multiplier != null) npcJson.put("criticalMultiplier", this.critical_multiplier);
|
||||
if (this.block_chance != null) npcJson.put("blockChance", this.block_chance);
|
||||
if (this.damage_resistance != null) npcJson.put("damageResistance", this.damage_resistance);
|
||||
writeHitEffectToMap(npcJson, this.hit_effect, "hitEffect");
|
||||
writeHitReceivedEffectToMap(npcJson, this.hit_received_effect, "hitReceivedEffect");
|
||||
writeDeathEffectToMap(npcJson, this.death_effect, "deathEffect");
|
||||
if (this.hit_effect != null) {
|
||||
Map hitEffectJson = new LinkedHashMap();
|
||||
npcJson.put("hitEffect", hitEffectJson);
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect != null) {
|
||||
Map hitReceivedEffectJson = new LinkedHashMap();
|
||||
npcJson.put("hitReceivedEffect", hitReceivedEffectJson);
|
||||
if (this.hit_received_effect.hp_boost_min != null || this.hit_received_effect.hp_boost_max != null) {
|
||||
Map hpJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseCurrentHP", hpJson);
|
||||
if (this.hit_received_effect.hp_boost_min != null) hpJson.put("min", this.hit_received_effect.hp_boost_min);
|
||||
else hpJson.put("min", 0);
|
||||
if (this.hit_received_effect.hp_boost_max != null) hpJson.put("max", this.hit_received_effect.hp_boost_max);
|
||||
else hpJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.ap_boost_min != null || this.hit_received_effect.ap_boost_max != null) {
|
||||
Map apJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseCurrentAP", apJson);
|
||||
if (this.hit_received_effect.ap_boost_min != null) apJson.put("min", this.hit_received_effect.ap_boost_min);
|
||||
else apJson.put("min", 0);
|
||||
if (this.hit_received_effect.ap_boost_max != null) apJson.put("max", this.hit_received_effect.ap_boost_max);
|
||||
else apJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.hp_boost_min_target != null || this.hit_received_effect.hp_boost_max_target != null) {
|
||||
Map hpJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseAttackerCurrentHP", hpJson);
|
||||
if (this.hit_received_effect.hp_boost_min_target != null) hpJson.put("min", this.hit_received_effect.hp_boost_min_target);
|
||||
else hpJson.put("min", 0);
|
||||
if (this.hit_received_effect.hp_boost_max_target != null) hpJson.put("max", this.hit_received_effect.hp_boost_max_target);
|
||||
else hpJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.ap_boost_min_target != null || this.hit_received_effect.ap_boost_max_target != null) {
|
||||
Map apJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseAttackerCurrentAP", apJson);
|
||||
if (this.hit_received_effect.ap_boost_min_target != null) apJson.put("min", this.hit_received_effect.ap_boost_min_target);
|
||||
else apJson.put("min", 0);
|
||||
if (this.hit_received_effect.ap_boost_max_target != null) apJson.put("max", this.hit_received_effect.ap_boost_max_target);
|
||||
else apJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.conditions_source != null) {
|
||||
List conditionsSourceJson = new ArrayList();
|
||||
hitReceivedEffectJson.put("conditionsSource", conditionsSourceJson);
|
||||
for (TimedConditionEffect condition : this.hit_received_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_received_effect.conditions_target != null) {
|
||||
List conditionsTargetJson = new ArrayList();
|
||||
hitReceivedEffectJson.put("conditionsTarget", conditionsTargetJson);
|
||||
for (TimedConditionEffect condition : this.hit_received_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.death_effect != null) {
|
||||
Map deathEffectJson = new LinkedHashMap();
|
||||
npcJson.put("deathEffect", deathEffectJson);
|
||||
if (this.death_effect.hp_boost_min != null || this.death_effect.hp_boost_max != null) {
|
||||
Map hpJson = new LinkedHashMap();
|
||||
deathEffectJson.put("increaseCurrentHP", hpJson);
|
||||
if (this.death_effect.hp_boost_min != null) hpJson.put("min", this.death_effect.hp_boost_min);
|
||||
else hpJson.put("min", 0);
|
||||
if (this.death_effect.hp_boost_max != null) hpJson.put("max", this.death_effect.hp_boost_max);
|
||||
else hpJson.put("max", 0);
|
||||
}
|
||||
if (this.death_effect.ap_boost_min != null || this.death_effect.ap_boost_max != null) {
|
||||
Map apJson = new LinkedHashMap();
|
||||
deathEffectJson.put("increaseCurrentAP", apJson);
|
||||
if (this.death_effect.ap_boost_min != null) apJson.put("min", this.death_effect.ap_boost_min);
|
||||
else apJson.put("min", 0);
|
||||
if (this.death_effect.ap_boost_max != null) apJson.put("max", this.death_effect.ap_boost_max);
|
||||
else apJson.put("max", 0);
|
||||
}
|
||||
if (this.death_effect.conditions_source != null) {
|
||||
List conditionsSourceJson = new ArrayList();
|
||||
deathEffectJson.put("conditionsSource", conditionsSourceJson);
|
||||
for (TimedConditionEffect condition : this.death_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));
|
||||
}
|
||||
}
|
||||
}
|
||||
return npcJson;
|
||||
}
|
||||
|
||||
@@ -344,8 +773,7 @@ public class NPC extends JSONElement {
|
||||
avgCrit = (double)(critical_skill / 100.0) * critical_multiplier;
|
||||
}
|
||||
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;
|
||||
if (hit_effect != null && hit_effect.conditions_target != null && hit_effect.conditions_target.size() > 0) {
|
||||
attackConditionBonus = 50;
|
||||
@@ -353,7 +781,7 @@ public class NPC extends JSONElement {
|
||||
double experience = (((avgAttackHP * 3) + avgDefenseHP) * EXP_FACTOR_SCALING) + attackConditionBonus;
|
||||
|
||||
return new Double(Math.ceil(experience)).intValue();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
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.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.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
@@ -17,6 +10,14 @@ 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.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
public class Quest extends JSONElement {
|
||||
|
||||
private static final long serialVersionUID = 2004839647483250099L;
|
||||
@@ -112,10 +113,17 @@ public class Quest extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (shouldSkipParseOrLink()) {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//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;
|
||||
}
|
||||
ensureParseIfNeeded();
|
||||
|
||||
for (QuestStage stage : stages) {
|
||||
stage.link();
|
||||
@@ -186,4 +194,5 @@ public class Quest extends JSONElement {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
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.ui.DefaultIcons;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class QuestStage extends JSONElement {
|
||||
|
||||
private static final long serialVersionUID = 8313645819951513431L;
|
||||
@@ -59,10 +59,17 @@ public class QuestStage extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (shouldSkipParseOrLink()) {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//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;
|
||||
}
|
||||
ensureParseIfNeeded();
|
||||
|
||||
//Nothing to link to :D
|
||||
this.state = State.linked;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
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;
|
||||
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 7295593297142310955L;
|
||||
@@ -68,31 +68,62 @@ public class Requirement extends JSONElement {
|
||||
}
|
||||
|
||||
public enum SkillID {
|
||||
weaponChance, weaponDmg, barter, dodge, barkSkin, moreCriticals, betterCriticals, speed // Raises max ap
|
||||
, coinfinder, moreExp, cleave // +10ap on kill
|
||||
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)
|
||||
,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
|
||||
,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
|
||||
,weaponProficiencyDagger
|
||||
,weaponProficiency1hsword
|
||||
,weaponProficiency2hsword
|
||||
,weaponProficiencyAxe
|
||||
,weaponProficiencyBlunt
|
||||
,weaponProficiencyUnarmed
|
||||
,weaponProficiencyPole
|
||||
,armorProficiencyShield
|
||||
,armorProficiencyUnarmored
|
||||
,armorProficiencyLight
|
||||
,armorProficiencyHeavy
|
||||
,fightstyleDualWield
|
||||
,fightstyle2hand
|
||||
,fightstyleWeaponShield
|
||||
,specializationDualWield
|
||||
,specialization2hand
|
||||
,specializationWeaponShield
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
String obj_id = "";
|
||||
if (required_obj_id != null) {
|
||||
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 {
|
||||
}
|
||||
else {
|
||||
obj_id += ":";
|
||||
}
|
||||
}
|
||||
@@ -122,10 +153,17 @@ public class Requirement extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (shouldSkipParseOrLink()) {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//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;
|
||||
}
|
||||
ensureParseIfNeeded();
|
||||
Project proj = getProject();
|
||||
if (proj == null) {
|
||||
Notification.addError("Error linking requirement "+getDesc()+". No parent project found.");
|
||||
@@ -207,7 +245,6 @@ public class Requirement extends JSONElement {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectFilename() {
|
||||
throw new Error("Thou shalt not reach this method.");
|
||||
@@ -220,7 +257,8 @@ public class Requirement extends JSONElement {
|
||||
required_value = null;
|
||||
}
|
||||
|
||||
if (destType == RequirementType.random) {
|
||||
if(destType==RequirementType.random)
|
||||
{
|
||||
required_obj_id = "50/100";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Droplist;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class ContainerArea extends MapObject {
|
||||
|
||||
public Droplist droplist = null;
|
||||
|
||||
public ContainerArea(tiled.core.MapObject obj) {
|
||||
}
|
||||
public ContainerArea(tiled.core.MapObject obj) {}
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class KeyArea extends MapObject {
|
||||
|
||||
public String dialogue_id;
|
||||
public String dialogue_id = null;
|
||||
public Dialogue dialogue = null;
|
||||
public Requirement requirement;
|
||||
public boolean oldSchoolRequirement;
|
||||
public Requirement requirement = null;
|
||||
public boolean oldSchoolRequirement = true;
|
||||
|
||||
public KeyArea(tiled.core.MapObject obj) {
|
||||
dialogue_id = obj.getProperties().getProperty("phrase");
|
||||
@@ -101,8 +101,7 @@ public class KeyArea extends MapObject {
|
||||
|
||||
public void updateNameFromRequirementChange() {
|
||||
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
||||
name = (requirement.negated != null && requirement.negated) ? "NOT " : "" + requirement.required_obj_id + ":" + ((requirement.required_value == null) ? "" : 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) {
|
||||
int i = 0;
|
||||
String futureName = requirement.type.toString() + "#" + Integer.toString(i);
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
|
||||
public class MapChange extends MapObject {
|
||||
|
||||
public String map_id;
|
||||
public String map_id = null;
|
||||
public TMXMap map = null;
|
||||
public String place_id;
|
||||
public String place_id = null;
|
||||
|
||||
public MapChange(tiled.core.MapObject obj) {
|
||||
this.map_id = obj.getProperties().getProperty("map");
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public abstract class MapObject {
|
||||
|
||||
public int x, y, w, h;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
|
||||
public class MapObjectGroup {
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
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.gamedata.Requirement;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ReplaceArea extends MapObject {
|
||||
|
||||
public Requirement requirement;
|
||||
public Requirement requirement = null;
|
||||
public boolean oldSchoolRequirement = false;
|
||||
|
||||
public List<ReplaceArea.Replacement> replacements = null;
|
||||
@@ -66,11 +66,25 @@ public class ReplaceArea extends MapObject {
|
||||
requirement.elementChanged(oldOne, newOne);
|
||||
}
|
||||
|
||||
public ReplaceArea.Replacement createReplacement(String source, String target) {
|
||||
public ReplaceArea.Replacement addReplacement(String source, String target) {
|
||||
Replacement repl = new Replacement(source, target);
|
||||
addReplacement(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
|
||||
public void savePropertiesInTmxObject(tiled.core.MapObject tmxObject) {
|
||||
if (replacements != null) {
|
||||
@@ -102,8 +116,7 @@ public class ReplaceArea extends MapObject {
|
||||
//Don't use yet !
|
||||
public void updateNameFromRequirementChange() {
|
||||
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
||||
name = (requirement.negated != null && requirement.negated) ? "NOT " : "" + requirement.required_obj_id + ":" + ((requirement.required_value == null) ? "" : 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) {
|
||||
int i = 0;
|
||||
String futureName = requirement.type.toString() + "#" + Integer.toString(i);
|
||||
@@ -117,7 +130,6 @@ public class ReplaceArea extends MapObject {
|
||||
|
||||
public class Replacement {
|
||||
public String sourceLayer, targetLayer;
|
||||
|
||||
public Replacement(String source, String target) {
|
||||
this.sourceLayer = source;
|
||||
this.targetLayer = target;
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
|
||||
public class RestArea extends MapObject {
|
||||
|
||||
public RestArea(tiled.core.MapObject obj) {
|
||||
}
|
||||
public RestArea(tiled.core.MapObject obj) {}
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
}
|
||||
public void link() {}
|
||||
|
||||
@Override
|
||||
public Image getIcon() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class ScriptArea extends MapObject {
|
||||
|
||||
public Dialogue dialogue = null;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class SignArea extends MapObject {
|
||||
|
||||
public Dialogue dialogue = null;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
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.gamedata.NPC;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SpawnArea extends MapObject {
|
||||
|
||||
public int quantity = 1;
|
||||
|
||||
@@ -1,21 +1,35 @@
|
||||
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.model.*;
|
||||
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.model.gamedata.GameDataSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.NPC;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
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 {
|
||||
|
||||
@@ -40,7 +54,7 @@ public class TMXMap extends GameDataElement {
|
||||
bluetint
|
||||
}
|
||||
|
||||
public File tmxFile;
|
||||
public File tmxFile = null;
|
||||
public tiled.core.Map tmxMap = null;
|
||||
public Set<Spritesheet> usedSpritesheets = null;
|
||||
public List<MapObjectGroup> groups = null;
|
||||
@@ -182,12 +196,10 @@ public class TMXMap extends GameDataElement {
|
||||
path.add(0,this);
|
||||
parent.childrenRemoved(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return (needsSaving() ? "*" : "")+id;
|
||||
@@ -202,21 +214,14 @@ public class TMXMap extends GameDataElement {
|
||||
public Image getIcon() {
|
||||
return DefaultIcons.getTiledIconIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
return DefaultIcons.getTiledIconIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Image getClosedIcon() {return null;}
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
return null;
|
||||
}
|
||||
public Image getOpenIcon() {return null;}
|
||||
|
||||
@Override
|
||||
public GameDataSet getDataSet() {
|
||||
@@ -411,13 +416,11 @@ public class TMXMap extends GameDataElement {
|
||||
if (((ContainerArea)o).droplist != null) ((ContainerArea)o).droplist.elementChanged(this, null);
|
||||
} else if (o instanceof KeyArea) {
|
||||
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) {
|
||||
if (((MapChange)o).map != null) ((MapChange)o).map.elementChanged(this, null);
|
||||
} 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 ScriptArea) {
|
||||
if (((ScriptArea)o).dialogue != null) ((ScriptArea)o).dialogue.elementChanged(this, null);
|
||||
@@ -458,7 +461,6 @@ public class TMXMap extends GameDataElement {
|
||||
|
||||
public interface MapChangedOnDiskListener {
|
||||
public void mapChanged();
|
||||
|
||||
public void mapReloaded();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
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 java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||
@@ -10,15 +29,6 @@ import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
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 static final String DEFAULT_REL_PATH_IN_SOURCE = "res"+File.separator+"xml"+File.separator;
|
||||
@@ -39,7 +49,8 @@ public class TMXMapSet implements ProjectTreeNode {
|
||||
this.parent = source;
|
||||
if (source.type == GameSource.Type.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);
|
||||
if (!this.mapFolder.exists()) {
|
||||
this.mapFolder.mkdirs();
|
||||
@@ -89,11 +100,9 @@ public class TMXMapSet implements ProjectTreeNode {
|
||||
while(getProject().open) {
|
||||
try {
|
||||
watchService = FileSystems.getDefault().newWatchService();
|
||||
/*WatchKey watchKey = */
|
||||
folderPath.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE);
|
||||
/*WatchKey watchKey = */folderPath.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE);
|
||||
WatchKey wk;
|
||||
validService:
|
||||
while (getProject().open) {
|
||||
validService: while(getProject().open) {
|
||||
wk = watchService.poll(10, TimeUnit.SECONDS);
|
||||
if (wk != null) {
|
||||
for (WatchEvent<?> event : wk.pollEvents()) {
|
||||
@@ -117,8 +126,7 @@ public class TMXMapSet implements ProjectTreeNode {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
watcher.start();
|
||||
}
|
||||
@@ -128,49 +136,40 @@ public class TMXMapSet implements ProjectTreeNode {
|
||||
public Enumeration<TMXMap> children() {
|
||||
return Collections.enumeration(tmxMaps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAllowsChildren() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeNode getChildAt(int arg0) {
|
||||
return tmxMaps.get(arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildCount() {
|
||||
return tmxMaps.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndex(TreeNode arg0) {
|
||||
return tmxMaps.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) {
|
||||
@@ -180,7 +179,6 @@ public class TMXMapSet implements ProjectTreeNode {
|
||||
parent.childrenRemoved(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
@@ -188,7 +186,6 @@ public class TMXMapSet implements ProjectTreeNode {
|
||||
map.notifyCreated();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return (needsSaving() ? "*" : "")+"TMX Maps";
|
||||
@@ -204,17 +201,14 @@ public class TMXMapSet implements ProjectTreeNode {
|
||||
public Image getIcon() {
|
||||
return getOpenIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
return DefaultIcons.getTmxClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
return DefaultIcons.getTmxClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
return DefaultIcons.getTmxOpenIcon();
|
||||
@@ -248,8 +242,7 @@ public class TMXMapSet implements ProjectTreeNode {
|
||||
public void addMap(TMXMap node) {
|
||||
ProjectTreeNode higherEmptyParent = this;
|
||||
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;
|
||||
}
|
||||
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
||||
|
||||
@@ -1,5 +1,40 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import java.awt.Image;
|
||||
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.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||
@@ -7,23 +42,6 @@ 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 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 {
|
||||
|
||||
@@ -158,7 +176,6 @@ public class Worldmap extends ArrayList<WorldmapSegment> implements ProjectTreeN
|
||||
public String getDesc() {
|
||||
return (needsSaving() ? "*" : "")+"Worldmap";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
@@ -173,17 +190,14 @@ public class Worldmap extends ArrayList<WorldmapSegment> implements ProjectTreeN
|
||||
public Image getIcon() {
|
||||
return DefaultIcons.getMapClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
return DefaultIcons.getMapClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
return DefaultIcons.getMapOpenIcon();
|
||||
@@ -231,8 +245,7 @@ public class Worldmap extends ArrayList<WorldmapSegment> implements ProjectTreeN
|
||||
public void addSegment(WorldmapSegment node) {
|
||||
ProjectTreeNode higherEmptyParent = this;
|
||||
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;
|
||||
}
|
||||
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
||||
|
||||
@@ -1,26 +1,34 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
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.ATContentStudio;
|
||||
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.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WorldmapSegment extends GameDataElement {
|
||||
|
||||
@@ -224,7 +232,6 @@ public class WorldmapSegment extends GameDataElement {
|
||||
public Image getIcon() {
|
||||
return DefaultIcons.getUIMapIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
return DefaultIcons.getUIMapIcon();
|
||||
|
||||
177
src/com/gpl/rpg/atcontentstudio/model/saves/SavedGame.java
Normal file
177
src/com/gpl/rpg/atcontentstudio/model/saves/SavedGame.java
Normal file
@@ -0,0 +1,177 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
180
src/com/gpl/rpg/atcontentstudio/model/saves/SavedGamesSet.java
Normal file
180
src/com/gpl/rpg/atcontentstudio/model/saves/SavedGamesSet.java
Normal file
@@ -0,0 +1,180 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,14 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.sprites;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
@@ -7,12 +16,6 @@ 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.io.File;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class SpriteSheetSet implements ProjectTreeNode {
|
||||
|
||||
public static final String DEFAULT_REL_PATH_IN_SOURCE = "res"+File.separator+"drawable"+File.separator;
|
||||
@@ -26,8 +29,7 @@ public class SpriteSheetSet implements ProjectTreeNode {
|
||||
|
||||
public SpriteSheetSet(GameSource source) {
|
||||
this.parent = source;
|
||||
if (source.type == GameSource.Type.source)
|
||||
this.drawableFolder = new File(source.baseFolder, DEFAULT_REL_PATH_IN_SOURCE);
|
||||
if (source.type == GameSource.Type.source) this.drawableFolder = new File(source.baseFolder, DEFAULT_REL_PATH_IN_SOURCE);
|
||||
else if (source.type == GameSource.Type.created | source.type == GameSource.Type.altered) {
|
||||
this.drawableFolder = new File(source.baseFolder, DEFAULT_REL_PATH_IN_PROJECT);
|
||||
if (!this.drawableFolder.exists()) {
|
||||
@@ -42,56 +44,46 @@ public class SpriteSheetSet implements ProjectTreeNode {
|
||||
}
|
||||
}
|
||||
}
|
||||
spritesheets.sort(Comparator.comparing(s -> s.id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<Spritesheet> children() {
|
||||
return Collections.enumeration(spritesheets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAllowsChildren() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeNode getChildAt(int arg0) {
|
||||
return spritesheets.get(arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildCount() {
|
||||
return spritesheets.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndex(TreeNode arg0) {
|
||||
return spritesheets.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) {
|
||||
@@ -101,7 +93,6 @@ public class SpriteSheetSet implements ProjectTreeNode {
|
||||
parent.childrenRemoved(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
childrenAdded(new ArrayList<ProjectTreeNode>());
|
||||
@@ -109,7 +100,6 @@ public class SpriteSheetSet implements ProjectTreeNode {
|
||||
s.notifyCreated();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return (needsSaving() ? "*" : "")+"Spritesheets";
|
||||
@@ -124,17 +114,14 @@ public class SpriteSheetSet implements ProjectTreeNode {
|
||||
public Image getIcon() {
|
||||
return getOpenIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
return DefaultIcons.getSpriteClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
return DefaultIcons.getSpriteClosedIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
return DefaultIcons.getSpriteOpenIcon();
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.sprites;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
@@ -9,15 +23,6 @@ import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class Spritesheet extends GameDataElement {
|
||||
|
||||
private static final long serialVersionUID = -5981708088278528586L;
|
||||
@@ -35,7 +40,7 @@ public class Spritesheet extends GameDataElement {
|
||||
monster,
|
||||
item,
|
||||
actorcondition
|
||||
}
|
||||
};
|
||||
|
||||
//Lazy initialization.
|
||||
public BufferedImage spritesheet = null;
|
||||
@@ -69,60 +74,49 @@ public class Spritesheet extends GameDataElement {
|
||||
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() ? "*" : "")+spritesheetFile.getName();
|
||||
@@ -196,21 +190,14 @@ public class Spritesheet extends GameDataElement {
|
||||
public Image getIcon() {
|
||||
return getIcon(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
return getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Image getClosedIcon() {return null;}
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
return null;
|
||||
}
|
||||
public Image getOpenIcon() {return null;}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -268,14 +255,10 @@ public class Spritesheet extends GameDataElement {
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if (this.category != null)
|
||||
getProject().setSpritesheetsProperty("atcs.spritesheet." + this.id + ".category", this.category.toString());
|
||||
if (this.spriteWidth != 32)
|
||||
getProject().setSpritesheetsProperty("atcs.spritesheet." + this.id + ".sizex", Integer.toString(this.spriteWidth));
|
||||
if (this.spriteHeight != 32)
|
||||
getProject().setSpritesheetsProperty("atcs.spritesheet." + this.id + ".sizey", Integer.toString(this.spriteHeight));
|
||||
if (this.animated)
|
||||
getProject().setSpritesheetsProperty("atcs.spritesheet." + this.id + ".animate", Boolean.toString(this.animated));
|
||||
if (this.category != null) getProject().setSpritesheetsProperty("atcs.spritesheet."+this.id+".category", this.category.toString());
|
||||
if (this.spriteWidth != 32) getProject().setSpritesheetsProperty("atcs.spritesheet."+this.id+".sizex", Integer.toString(this.spriteWidth));
|
||||
if (this.spriteHeight != 32) getProject().setSpritesheetsProperty("atcs.spritesheet."+this.id+".sizey", Integer.toString(this.spriteHeight));
|
||||
if (this.animated)getProject().setSpritesheetsProperty("atcs.spritesheet."+this.id+".animate", Boolean.toString(this.animated));
|
||||
getProject().save();
|
||||
|
||||
this.state = GameDataElement.State.saved;
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.tools.i18n;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
@@ -1,34 +1,41 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.tools.i18n;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
|
||||
import net.launchpad.tobal.poparser.POEntry;
|
||||
import net.launchpad.tobal.poparser.POFile;
|
||||
import net.launchpad.tobal.poparser.POParser;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Kevin
|
||||
* <p>
|
||||
*
|
||||
* To use this, paste the following script in the beanshell console of ATCS.
|
||||
* Don't forget to change the project number to suit your needs.
|
||||
* <p>
|
||||
* <code>
|
||||
*
|
||||
* import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
* import com.gpl.rpg.atcontentstudio.model.tools.i18n.PotGenerator;
|
||||
* import com.gpl.rpg.atcontentstudio.model.tools.i18n.PotComparator;
|
||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
import com.gpl.rpg.atcontentstudio.model.tools.i18n.PotGenerator;
|
||||
import com.gpl.rpg.atcontentstudio.model.tools.i18n.PotComparator;
|
||||
|
||||
proj = Workspace.activeWorkspace.projects.get(7);
|
||||
PotGenerator.generatePotFileForProject(proj);
|
||||
comp = new PotComparator(proj);
|
||||
comp.compare();
|
||||
comp.updatePoFiles(proj);
|
||||
*
|
||||
*
|
||||
*
|
||||
* proj = Workspace.activeWorkspace.projects.get(7);
|
||||
* PotGenerator.generatePotFileForProject(proj);
|
||||
* comp = new PotComparator(proj);
|
||||
* comp.compare();
|
||||
* comp.updatePoFiles(proj);
|
||||
* </code>
|
||||
*/
|
||||
public class PotComparator {
|
||||
|
||||
@@ -149,8 +156,7 @@ public class PotComparator {
|
||||
}
|
||||
}
|
||||
}
|
||||
removedStrings:
|
||||
for (String oldString : stringsResourcesOld.keySet()) {
|
||||
removedStrings: for (String oldString : stringsResourcesOld.keySet()) {
|
||||
if (stringsResourcesNew.get(oldString) == null) {
|
||||
List<String> allOldResources = stringsResourcesOld.get(oldString);
|
||||
if (allOldResources.size() >= 1) {
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.tools.i18n;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.*;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
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.WorldmapSegment;
|
||||
|
||||
public class PotGenerator {
|
||||
|
||||
public static void generatePotFileForProject(Project proj) {
|
||||
@@ -19,12 +26,12 @@ public class PotGenerator {
|
||||
|
||||
GameSource gsrc = proj.baseContent;
|
||||
|
||||
for (ActorCondition ac : gsrc.gameData.actorConditions.toList()) {
|
||||
for (ActorCondition ac : gsrc.gameData.actorConditions) {
|
||||
pushString(stringsResources, resourcesStrings, ac.display_name, getPotContextComment(ac));
|
||||
pushString(stringsResources, resourcesStrings, ac.description, getPotContextComment(ac)+":description");
|
||||
}
|
||||
|
||||
for (Dialogue d : gsrc.gameData.dialogues.toList()) {
|
||||
for (Dialogue d : gsrc.gameData.dialogues ) {
|
||||
pushString(stringsResources, resourcesStrings, d.message, getPotContextComment(d));
|
||||
if (d.replies == null) continue;
|
||||
for (Dialogue.Reply r : d.replies) {
|
||||
@@ -34,20 +41,20 @@ public class PotGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemCategory ic : gsrc.gameData.itemCategories.toList()) {
|
||||
for (ItemCategory ic : gsrc.gameData.itemCategories) {
|
||||
pushString(stringsResources, resourcesStrings, ic.name, getPotContextComment(ic));
|
||||
}
|
||||
|
||||
for (Item i : gsrc.gameData.items.toList()) {
|
||||
for (Item i : gsrc.gameData.items) {
|
||||
pushString(stringsResources, resourcesStrings, i.name, getPotContextComment(i));
|
||||
pushString(stringsResources, resourcesStrings, i.description, getPotContextComment(i)+":description");
|
||||
}
|
||||
|
||||
for (NPC npc : gsrc.gameData.npcs.toList()) {
|
||||
for (NPC npc : gsrc.gameData.npcs ) {
|
||||
pushString(stringsResources, resourcesStrings, npc.name, getPotContextComment(npc));
|
||||
}
|
||||
|
||||
for (Quest q : gsrc.gameData.quests.toList()) {
|
||||
for (Quest q : gsrc.gameData.quests) {
|
||||
if (q.visible_in_log != null && q.visible_in_log != 0) {
|
||||
pushString(stringsResources, resourcesStrings, q.name, getPotContextComment(q));
|
||||
for (QuestStage qs : q.stages) {
|
||||
|
||||
@@ -1,9 +1,35 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.tools.resoptimizer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.CharBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
|
||||
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.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.*;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Item;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.NPC;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.SpriteSheetSet;
|
||||
@@ -12,30 +38,23 @@ import com.whoischarles.util.json.Minify;
|
||||
import com.whoischarles.util.json.Minify.UnterminatedCommentException;
|
||||
import com.whoischarles.util.json.Minify.UnterminatedRegExpLiteralException;
|
||||
import com.whoischarles.util.json.Minify.UnterminatedStringLiteralException;
|
||||
import org.json.simple.JSONArray;
|
||||
|
||||
import tiled.core.TileSet;
|
||||
import tiled.io.TMXMapWriter;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Kevin
|
||||
* <p>
|
||||
*
|
||||
* To use this, paste the following script in the beanshell console of ATCS.
|
||||
* Don't forget to change the project number to suit your needs.
|
||||
* <p>
|
||||
* <code>
|
||||
* import com.gpl.rpg.atcontentstudio.model.tools.resoptimizer.ResourcesCompactor;
|
||||
* import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
*
|
||||
* proj = Workspace.activeWorkspace.projects.get(0);
|
||||
* new ResourcesCompactor(proj).compactData();
|
||||
* </code>
|
||||
import com.gpl.rpg.atcontentstudio.model.tools.resoptimizer.ResourcesCompactor;
|
||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
|
||||
proj = Workspace.activeWorkspace.projects.get(0);
|
||||
new ResourcesCompactor(proj).compactData();
|
||||
*
|
||||
*/
|
||||
public class ResourcesCompactor {
|
||||
|
||||
@@ -78,13 +97,12 @@ public class ResourcesCompactor {
|
||||
File folder = new File(baseFolder.getAbsolutePath()+File.separator+GameDataSet.DEFAULT_REL_PATH_IN_SOURCE);
|
||||
if (!folder.exists()) folder.mkdirs();
|
||||
|
||||
ArrayList<ActorCondition> actorConditions = proj.baseContent.gameData.actorConditions.toList();
|
||||
for (ActorCondition ac : actorConditions) {
|
||||
for (ActorCondition ac : proj.baseContent.gameData.actorConditions) {
|
||||
if (filesCovered.contains(ac.jsonFile)) continue;
|
||||
File currentFile = ac.jsonFile;
|
||||
filesCovered.add(currentFile);
|
||||
List<Map> dataToSave = new ArrayList<Map>();
|
||||
for (ActorCondition acond : actorConditions) {
|
||||
for (ActorCondition acond : proj.baseContent.gameData.actorConditions) {
|
||||
if (!acond.jsonFile.equals(currentFile)) continue;
|
||||
Map json = acond.toJson();
|
||||
json.put("iconID", convertObjectSprite(acond.icon_id).toStringID());
|
||||
@@ -94,13 +112,12 @@ public class ResourcesCompactor {
|
||||
writeJson(dataToSave, target);
|
||||
}
|
||||
|
||||
ArrayList<Item> items = proj.baseContent.gameData.items.toList();
|
||||
for (Item it : items) {
|
||||
for (Item it : proj.baseContent.gameData.items) {
|
||||
if (filesCovered.contains(it.jsonFile)) continue;
|
||||
File currentFile = it.jsonFile;
|
||||
filesCovered.add(currentFile);
|
||||
List<Map> dataToSave = new ArrayList<Map>();
|
||||
for (Item item : items) {
|
||||
for (Item item : proj.baseContent.gameData.items) {
|
||||
if (!item.jsonFile.equals(currentFile)) continue;
|
||||
Map json = item.toJson();
|
||||
json.put("iconID", convertObjectSprite(item.icon_id).toStringID());
|
||||
@@ -111,13 +128,12 @@ public class ResourcesCompactor {
|
||||
}
|
||||
|
||||
|
||||
ArrayList<NPC> npcs = proj.baseContent.gameData.npcs.toList();
|
||||
for (NPC np : npcs) {
|
||||
for (NPC np : proj.baseContent.gameData.npcs) {
|
||||
if (filesCovered.contains(np.jsonFile)) continue;
|
||||
File currentFile = np.jsonFile;
|
||||
filesCovered.add(currentFile);
|
||||
List<Map> dataToSave = new ArrayList<Map>();
|
||||
for (NPC npc : npcs) {
|
||||
for (NPC npc : proj.baseContent.gameData.npcs) {
|
||||
if (!npc.jsonFile.equals(currentFile)) continue;
|
||||
Map json = npc.toJson();
|
||||
if (proj.getImage(npc.icon_id).getWidth(null) == TILE_WIDTH_IN_PIXELS || proj.getImage(npc.icon_id).getHeight(null) == TILE_HEIGHT_IN_PIXELS) {
|
||||
@@ -145,12 +161,16 @@ public class ResourcesCompactor {
|
||||
private Minify jsonMinifier = new Minify();
|
||||
|
||||
private void writeJson(List<Map> dataToSave, File target) {
|
||||
String toWrite = FileUtils.toJsonString(dataToSave);
|
||||
toWrite = jsonMinifier.minify(toWrite);
|
||||
FileUtils.writeStringToFile(toWrite, target, null);
|
||||
StringWriter writer = new JsonPrettyWriter();
|
||||
try {
|
||||
JSONArray.writeJSONString(dataToSave, writer);
|
||||
} catch (IOException e) {
|
||||
//Impossible with a StringWriter
|
||||
}
|
||||
String toWrite = writer.toString();
|
||||
try {
|
||||
FileWriter w = new FileWriter(target);
|
||||
w.write(toWrite);
|
||||
w.write(jsonMinifier.minify(toWrite));
|
||||
w.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -175,7 +195,6 @@ public class ResourcesCompactor {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void compactMaps() {
|
||||
for (TMXMap map : proj.baseContent.gameMaps.tmxMaps) {
|
||||
TMXMap clone = map.clone();
|
||||
@@ -187,6 +206,7 @@ public class ResourcesCompactor {
|
||||
compactMap(tmx, map.id);
|
||||
clone.tmxMap = null;
|
||||
clone.groups.clear();
|
||||
clone = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.tools.writermode;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
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.Dialogue;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
@@ -23,6 +12,18 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
public class WriterModeData extends GameDataElement {
|
||||
private static final long serialVersionUID = -7062544089063979696L;
|
||||
|
||||
@@ -94,8 +95,7 @@ public class WriterModeData extends GameDataElement {
|
||||
public String dialogue_id;
|
||||
public Dialogue dialogue;
|
||||
|
||||
public WriterDialogue() {
|
||||
}
|
||||
public WriterDialogue() {}
|
||||
|
||||
public WriterDialogue(Dialogue dialogue) {
|
||||
this.dialogue = dialogue;
|
||||
@@ -186,9 +186,7 @@ public class WriterModeData extends GameDataElement {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSpecial() {
|
||||
return false;
|
||||
}
|
||||
public boolean isSpecial() {return false;}
|
||||
|
||||
|
||||
public Dialogue toDialogue(Map<WriterDialogue, Dialogue> visited, List<Dialogue> created, List<Dialogue> modified) {
|
||||
@@ -262,63 +260,35 @@ public class WriterModeData extends GameDataElement {
|
||||
|
||||
public abstract class SpecialDialogue extends WriterDialogue {
|
||||
|
||||
public SpecialDialogue() {
|
||||
}
|
||||
|
||||
public boolean isSpecial() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public SpecialDialogue() {}
|
||||
public boolean isSpecial() {return true;}
|
||||
public abstract SpecialDialogue duplicate();
|
||||
|
||||
public SpecialDialogue(Dialogue dialogue) {
|
||||
super(dialogue);
|
||||
}
|
||||
}
|
||||
|
||||
public class SelectorDialogue extends SpecialDialogue {
|
||||
public SelectorDialogue() {
|
||||
}
|
||||
|
||||
public SpecialDialogue duplicate() {
|
||||
return new SelectorDialogue();
|
||||
}
|
||||
|
||||
public SelectorDialogue() {}
|
||||
public SpecialDialogue duplicate() {return new SelectorDialogue();}
|
||||
public SelectorDialogue(Dialogue dialogue) {
|
||||
super(dialogue);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShopDialogue extends SpecialDialogue {
|
||||
public static final String id = Dialogue.Reply.SHOP_PHRASE_ID;
|
||||
|
||||
public SpecialDialogue duplicate() {
|
||||
return new ShopDialogue();
|
||||
public SpecialDialogue duplicate() {return new ShopDialogue();}
|
||||
}
|
||||
}
|
||||
|
||||
public class FightDialogue extends SpecialDialogue {
|
||||
public static final String id = Dialogue.Reply.FIGHT_PHRASE_ID;
|
||||
|
||||
public SpecialDialogue duplicate() {
|
||||
return new FightDialogue();
|
||||
public SpecialDialogue duplicate() {return new FightDialogue();}
|
||||
}
|
||||
}
|
||||
|
||||
public class EndDialogue extends SpecialDialogue {
|
||||
public static final String id = Dialogue.Reply.EXIT_PHRASE_ID;
|
||||
|
||||
public SpecialDialogue duplicate() {
|
||||
return new EndDialogue();
|
||||
public SpecialDialogue duplicate() {return new EndDialogue();}
|
||||
}
|
||||
}
|
||||
|
||||
public class RemoveNPCDialogue extends SpecialDialogue {
|
||||
public static final String id = Dialogue.Reply.REMOVE_PHRASE_ID;
|
||||
|
||||
public SpecialDialogue duplicate() {
|
||||
return new RemoveNPCDialogue();
|
||||
}
|
||||
public SpecialDialogue duplicate() {return new RemoveNPCDialogue();}
|
||||
}
|
||||
|
||||
public class WriterReply extends WriterNode {
|
||||
@@ -327,8 +297,7 @@ public class WriterModeData extends GameDataElement {
|
||||
public WriterDialogue next_dialogue;
|
||||
public Dialogue.Reply reply;
|
||||
|
||||
public WriterReply() {
|
||||
}
|
||||
public WriterReply() {}
|
||||
|
||||
public WriterReply(WriterDialogue parent) {
|
||||
this.parent = parent;
|
||||
@@ -374,9 +343,7 @@ public class WriterModeData extends GameDataElement {
|
||||
return replyJson;
|
||||
}
|
||||
|
||||
public boolean isSpecial() {
|
||||
return false;
|
||||
}
|
||||
public boolean isSpecial() {return false;}
|
||||
|
||||
public Dialogue.Reply toReply(Map<WriterDialogue, Dialogue> visited, List<Dialogue> created, List<Dialogue> modified) {
|
||||
if (reply == null) {
|
||||
@@ -408,13 +375,12 @@ public class WriterModeData extends GameDataElement {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class SpecialReply extends WriterReply {
|
||||
|
||||
public boolean isSpecial() {
|
||||
return true;
|
||||
}
|
||||
public boolean isSpecial() {return true;}
|
||||
|
||||
public SpecialReply(WriterDialogue parent, Dialogue.Reply reply) {
|
||||
super(parent, reply);
|
||||
@@ -428,7 +394,6 @@ public class WriterModeData extends GameDataElement {
|
||||
super(parent, json);
|
||||
}
|
||||
}
|
||||
|
||||
public class EmptyReply extends SpecialReply {
|
||||
|
||||
public EmptyReply(WriterDialogue parent, Dialogue.Reply reply) {
|
||||
@@ -448,11 +413,11 @@ public class WriterModeData extends GameDataElement {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return (needsSaving() ? "*" : "")+id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project getProject() {
|
||||
return parent.getProject();
|
||||
@@ -462,22 +427,18 @@ public class WriterModeData extends GameDataElement {
|
||||
public Image getIcon() {
|
||||
return DefaultIcons.getDialogueIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getOpenIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getClosedIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getLeafIcon() {
|
||||
return getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameDataSet getDataSet() {
|
||||
return null;
|
||||
@@ -488,13 +449,11 @@ public class WriterModeData extends GameDataElement {
|
||||
//TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementChanged(GameDataElement oldOne, GameDataElement newOne) {
|
||||
// Useless here.
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectFilename() {
|
||||
return WriterModeDataSet.DEFAULT_REL_PATH_IN_PROJECT;
|
||||
@@ -530,7 +489,10 @@ public class WriterModeData extends GameDataElement {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void parse() {
|
||||
if (shouldSkipParse()) return;
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//This type of state is unrelated to parsing/linking.
|
||||
return;
|
||||
}
|
||||
JSONParser parser = new JSONParser();
|
||||
FileReader reader = null;
|
||||
try {
|
||||
@@ -630,13 +592,11 @@ public class WriterModeData extends GameDataElement {
|
||||
score = 0;
|
||||
//Arbitrary values... hopefully this gives good results.
|
||||
//Same target gives good hope of preserving at least the structure.
|
||||
if (dReply.next_phrase_id != null && dReply.next_phrase_id.equals(reply.next_dialogue_id))
|
||||
score += 50;
|
||||
if (dReply.next_phrase_id != null && dReply.next_phrase_id.equals(reply.next_dialogue_id)) score +=50;
|
||||
//Same text is almost as good as an ID, but there may be duplicates due to requirements system...
|
||||
if (dReply.text != null && dReply.text.equals(reply.text)) score +=40;
|
||||
//Same slot in the list. That's not so bad if all else fails, and could help sort duplicates with same text.
|
||||
if (dialogue.dialogue.replies.indexOf(dReply) == dialogue.replies.indexOf(reply))
|
||||
score += 20;
|
||||
if (dialogue.dialogue.replies.indexOf(dReply) == dialogue.replies.indexOf(reply)) score +=20;
|
||||
//Both have null text. It's not much, but it's something....
|
||||
if (dReply.text == null && reply.text == null) score += 10;
|
||||
if (score > maxScore) {
|
||||
|
||||
@@ -1,21 +1,35 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.tools.writermode;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.io.JsonPrettyWriter;
|
||||
import com.gpl.rpg.atcontentstudio.model.*;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||
import java.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import javax.swing.tree.TreeNode;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
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.model.gamedata.GameDataSet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
public class WriterModeDataSet implements ProjectTreeNode, Serializable {
|
||||
|
||||
@@ -156,12 +170,24 @@ public class WriterModeDataSet implements ProjectTreeNode, Serializable {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String toWrite = FileUtils.toJsonString(dataToSave);
|
||||
if(FileUtils.writeStringToFile(toWrite, writerFile, "Json file " + writerFile.getAbsolutePath())) {
|
||||
StringWriter writer = new JsonPrettyWriter();
|
||||
try {
|
||||
JSONArray.writeJSONString(dataToSave, writer);
|
||||
} catch (IOException e) {
|
||||
//Impossible with a StringWriter
|
||||
}
|
||||
String toWrite = writer.toString();
|
||||
try {
|
||||
FileWriter w = new FileWriter(writerFile);
|
||||
w.write(toWrite);
|
||||
w.close();
|
||||
for (WriterModeData element : writerModeDataList) {
|
||||
element.state = GameDataElement.State.saved;
|
||||
}
|
||||
Notification.addSuccess("Json file "+writerFile.getAbsolutePath()+" saved.");
|
||||
} catch (IOException e) {
|
||||
Notification.addError("Error while writing json file "+writerFile.getAbsolutePath()+" : "+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,8 +250,7 @@ public class WriterModeDataSet implements ProjectTreeNode, Serializable {
|
||||
public void add(WriterModeData node) {
|
||||
ProjectTreeNode higherEmptyParent = this;
|
||||
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;
|
||||
}
|
||||
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Desktop;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkEvent.EventType;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkEvent.EventType;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class AboutEditor extends Editor {
|
||||
|
||||
private static final long serialVersionUID = 6230549148222457139L;
|
||||
@@ -50,7 +55,6 @@ public class AboutEditor extends Editor {
|
||||
"Quentin Delvallet<br/>" +
|
||||
"Žižkin<br/>" +
|
||||
"Gonk<br/>" +
|
||||
"<a href=\"https://github.com/OMGeeky\">OMGeeky</a><br/>" +
|
||||
"<br/>" +
|
||||
"This project uses the following libraries:<br/>" +
|
||||
"<a href=\"http://code.google.com/p/json-simple/\">JSON.simple</a> by Yidong Fang & Chris Nokleberg.<br/>" +
|
||||
@@ -93,54 +97,30 @@ public class AboutEditor extends Editor {
|
||||
|
||||
|
||||
public static final AboutEditor instance = new AboutEditor();
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
private AboutEditor() {
|
||||
this.name="About "+ATContentStudio.APP_NAME;
|
||||
this.icon = new ImageIcon(DefaultIcons.getMainIconIcon());
|
||||
this.target = new GameDataElement(){
|
||||
private static final long serialVersionUID = -227480102288529682L;
|
||||
|
||||
@Override
|
||||
public GameDataSet getDataSet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public GameDataSet getDataSet() {return null;}
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getDesc() {return null;}
|
||||
@Override
|
||||
public void parse() {
|
||||
}
|
||||
|
||||
public void parse() {}
|
||||
@Override
|
||||
public void link() {
|
||||
}
|
||||
|
||||
public void link() {}
|
||||
@Override
|
||||
public GameDataElement clone() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public GameDataElement clone() {return null;}
|
||||
@Override
|
||||
public void elementChanged(GameDataElement oldOne, GameDataElement newOne) {
|
||||
}
|
||||
|
||||
public void elementChanged(GameDataElement oldOne, GameDataElement newOne) {}
|
||||
@Override
|
||||
public String getProjectFilename() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getProjectFilename() {return null;}
|
||||
@Override
|
||||
public void save() {
|
||||
}
|
||||
|
||||
public void save() {}
|
||||
@Override
|
||||
public List<SaveEvent> attemptSave() {
|
||||
return null;
|
||||
}
|
||||
public List<SaveEvent> attemptSave() {return null;}
|
||||
};
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
@@ -152,14 +132,12 @@ public class AboutEditor extends Editor {
|
||||
|
||||
editorTabsHolder.add("Welcome", getInfoPane(WELCOME_STRING, "text/html"));
|
||||
editorTabsHolder.add("JSON.simple License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.JSON.simple.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
editorTabsHolder.add("RSyntaxTextArea License",
|
||||
getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/RSyntaxTextArea.License.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
editorTabsHolder.add("RSyntaxTextArea License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/RSyntaxTextArea.License.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
editorTabsHolder.add("JIDE Common Layer License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.JIDE.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
editorTabsHolder.add("libtiled-java License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.libtiled.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
editorTabsHolder.add("prefuse License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/license-prefuse.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
editorTabsHolder.add("BeanShell License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.LGPLv3.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
editorTabsHolder.add("SipHash for Java License",
|
||||
getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.siphash-zackehh.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
editorTabsHolder.add("SipHash for Java License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.siphash-zackehh.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
editorTabsHolder.add("jsoup License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.jsoup.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
editorTabsHolder.add("General PO Parser License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.GPLv3.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
editorTabsHolder.add("Minify.java License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.minify.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
|
||||
@@ -197,7 +175,6 @@ public class AboutEditor extends Editor {
|
||||
|
||||
|
||||
@Override
|
||||
public void targetUpdated() {
|
||||
}
|
||||
public void targetUpdated() {}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JCheckBox;
|
||||
|
||||
public class BooleanBasedCheckBox extends JCheckBox {
|
||||
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class CollapsiblePanel extends JPanel {
|
||||
|
||||
@@ -34,7 +42,6 @@ public class CollapsiblePanel extends JPanel {
|
||||
public void componentShown(ComponentEvent e) {
|
||||
updateBorderTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
updateBorderTitle();
|
||||
@@ -143,11 +150,9 @@ public class CollapsiblePanel extends JPanel {
|
||||
public void collapse() {
|
||||
toggleVisibility(false);
|
||||
}
|
||||
|
||||
public void expand() {
|
||||
toggleVisibility(true);
|
||||
}
|
||||
|
||||
public void setExpanded(boolean expand) {
|
||||
toggleVisibility(expand);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.Image;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
|
||||
public class DefaultIcons {
|
||||
|
||||
private static Map<String, Image> imageCache = new LinkedHashMap<String, Image>();
|
||||
@@ -16,714 +17,288 @@ public class DefaultIcons {
|
||||
|
||||
|
||||
private static String MAIN_ICON_RES = "/com/gpl/rpg/atcontentstudio/img/andorstrainer.png";
|
||||
|
||||
public static Image getMainIconImage() {
|
||||
return getImage(MAIN_ICON_RES);
|
||||
}
|
||||
|
||||
public static Image getMainIconIcon() {
|
||||
return getIcon(MAIN_ICON_RES);
|
||||
}
|
||||
public static Image getMainIconImage() { return getImage(MAIN_ICON_RES); }
|
||||
public static Image getMainIconIcon() { return getIcon(MAIN_ICON_RES); }
|
||||
|
||||
private static String FOLDER_STD_CLOSED_RES = "/com/gpl/rpg/atcontentstudio/img/folder_std_closed.png";
|
||||
|
||||
public static Image getStdClosedImage() {
|
||||
return getImage(FOLDER_STD_CLOSED_RES);
|
||||
}
|
||||
|
||||
public static Image getStdClosedIcon() {
|
||||
return getIcon(FOLDER_STD_CLOSED_RES);
|
||||
}
|
||||
public static Image getStdClosedImage() { return getImage(FOLDER_STD_CLOSED_RES); }
|
||||
public static Image getStdClosedIcon() { return getIcon(FOLDER_STD_CLOSED_RES); }
|
||||
|
||||
private static String FOLDER_STD_OPEN_RES = "/com/gpl/rpg/atcontentstudio/img/folder_std_open.png";
|
||||
|
||||
public static Image getStdOpenImage() {
|
||||
return getImage(FOLDER_STD_OPEN_RES);
|
||||
}
|
||||
|
||||
public static Image getStdOpenIcon() {
|
||||
return getIcon(FOLDER_STD_OPEN_RES);
|
||||
}
|
||||
public static Image getStdOpenImage() { return getImage(FOLDER_STD_OPEN_RES); }
|
||||
public static Image getStdOpenIcon() { return getIcon(FOLDER_STD_OPEN_RES); }
|
||||
|
||||
private static String FOLDER_JSON_CLOSED_RES = "/com/gpl/rpg/atcontentstudio/img/folder_json_closed.png";
|
||||
|
||||
public static Image getJsonClosedImage() {
|
||||
return getImage(FOLDER_JSON_CLOSED_RES);
|
||||
}
|
||||
|
||||
public static Image getJsonClosedIcon() {
|
||||
return getIcon(FOLDER_JSON_CLOSED_RES);
|
||||
}
|
||||
public static Image getJsonClosedImage() { return getImage(FOLDER_JSON_CLOSED_RES); }
|
||||
public static Image getJsonClosedIcon() { return getIcon(FOLDER_JSON_CLOSED_RES); }
|
||||
|
||||
private static String FOLDER_JSON_OPEN_RES = "/com/gpl/rpg/atcontentstudio/img/folder_json_open.png";
|
||||
|
||||
public static Image getJsonOpenImage() {
|
||||
return getImage(FOLDER_JSON_OPEN_RES);
|
||||
}
|
||||
|
||||
public static Image getJsonOpenIcon() {
|
||||
return getIcon(FOLDER_JSON_OPEN_RES);
|
||||
}
|
||||
public static Image getJsonOpenImage() { return getImage(FOLDER_JSON_OPEN_RES); }
|
||||
public static Image getJsonOpenIcon() { return getIcon(FOLDER_JSON_OPEN_RES); }
|
||||
|
||||
private static String FOLDER_SAV_CLOSED_RES = "/com/gpl/rpg/atcontentstudio/img/folder_sav_closed.png";
|
||||
|
||||
public static Image getSavClosedImage() {
|
||||
return getImage(FOLDER_SAV_CLOSED_RES);
|
||||
}
|
||||
|
||||
public static Image getSavClosedIcon() {
|
||||
return getIcon(FOLDER_SAV_CLOSED_RES);
|
||||
}
|
||||
public static Image getSavClosedImage() { return getImage(FOLDER_SAV_CLOSED_RES); }
|
||||
public static Image getSavClosedIcon() { return getIcon(FOLDER_SAV_CLOSED_RES); }
|
||||
|
||||
private static String FOLDER_SAV_OPEN_RES = "/com/gpl/rpg/atcontentstudio/img/folder_sav_open.png";
|
||||
|
||||
public static Image getSavOpenImage() {
|
||||
return getImage(FOLDER_SAV_OPEN_RES);
|
||||
}
|
||||
|
||||
public static Image getSavOpenIcon() {
|
||||
return getIcon(FOLDER_SAV_OPEN_RES);
|
||||
}
|
||||
public static Image getSavOpenImage() { return getImage(FOLDER_SAV_OPEN_RES); }
|
||||
public static Image getSavOpenIcon() { return getIcon(FOLDER_SAV_OPEN_RES); }
|
||||
|
||||
private static String FOLDER_SPRITE_CLOSED_RES = "/com/gpl/rpg/atcontentstudio/img/folder_sprite_closed.png";
|
||||
|
||||
public static Image getSpriteClosedImage() {
|
||||
return getImage(FOLDER_SPRITE_CLOSED_RES);
|
||||
}
|
||||
|
||||
public static Image getSpriteClosedIcon() {
|
||||
return getIcon(FOLDER_SPRITE_CLOSED_RES);
|
||||
}
|
||||
public static Image getSpriteClosedImage() { return getImage(FOLDER_SPRITE_CLOSED_RES); }
|
||||
public static Image getSpriteClosedIcon() { return getIcon(FOLDER_SPRITE_CLOSED_RES); }
|
||||
|
||||
private static String FOLDER_SPRITE_OPEN_RES = "/com/gpl/rpg/atcontentstudio/img/folder_sprite_open.png";
|
||||
|
||||
public static Image getSpriteOpenImage() {
|
||||
return getImage(FOLDER_SPRITE_OPEN_RES);
|
||||
}
|
||||
|
||||
public static Image getSpriteOpenIcon() {
|
||||
return getIcon(FOLDER_SPRITE_OPEN_RES);
|
||||
}
|
||||
public static Image getSpriteOpenImage() { return getImage(FOLDER_SPRITE_OPEN_RES); }
|
||||
public static Image getSpriteOpenIcon() { return getIcon(FOLDER_SPRITE_OPEN_RES); }
|
||||
|
||||
private static String FOLDER_TMX_CLOSED_RES = "/com/gpl/rpg/atcontentstudio/img/folder_tmx_closed.png";
|
||||
|
||||
public static Image getTmxClosedImage() {
|
||||
return getImage(FOLDER_TMX_CLOSED_RES);
|
||||
}
|
||||
|
||||
public static Image getTmxClosedIcon() {
|
||||
return getIcon(FOLDER_TMX_CLOSED_RES);
|
||||
}
|
||||
public static Image getTmxClosedImage() { return getImage(FOLDER_TMX_CLOSED_RES); }
|
||||
public static Image getTmxClosedIcon() { return getIcon(FOLDER_TMX_CLOSED_RES); }
|
||||
|
||||
private static String FOLDER_TMX_OPEN_RES = "/com/gpl/rpg/atcontentstudio/img/folder_tmx_open.png";
|
||||
|
||||
public static Image getTmxOpenImage() {
|
||||
return getImage(FOLDER_TMX_OPEN_RES);
|
||||
}
|
||||
|
||||
public static Image getTmxOpenIcon() {
|
||||
return getIcon(FOLDER_TMX_OPEN_RES);
|
||||
}
|
||||
public static Image getTmxOpenImage() { return getImage(FOLDER_TMX_OPEN_RES); }
|
||||
public static Image getTmxOpenIcon() { return getIcon(FOLDER_TMX_OPEN_RES); }
|
||||
|
||||
private static String FOLDER_MAP_CLOSED_RES = "/com/gpl/rpg/atcontentstudio/img/folder_map_closed.png";
|
||||
|
||||
public static Image getMapClosedImage() {
|
||||
return getImage(FOLDER_MAP_CLOSED_RES);
|
||||
}
|
||||
|
||||
public static Image getMapClosedIcon() {
|
||||
return getIcon(FOLDER_MAP_CLOSED_RES);
|
||||
}
|
||||
public static Image getMapClosedImage() { return getImage(FOLDER_MAP_CLOSED_RES); }
|
||||
public static Image getMapClosedIcon() { return getIcon(FOLDER_MAP_CLOSED_RES); }
|
||||
|
||||
private static String FOLDER_MAP_OPEN_RES = "/com/gpl/rpg/atcontentstudio/img/folder_map_open.png";
|
||||
|
||||
public static Image getMapOpenImage() {
|
||||
return getImage(FOLDER_MAP_OPEN_RES);
|
||||
}
|
||||
|
||||
public static Image getMapOpenIcon() {
|
||||
return getIcon(FOLDER_MAP_OPEN_RES);
|
||||
}
|
||||
public static Image getMapOpenImage() { return getImage(FOLDER_MAP_OPEN_RES); }
|
||||
public static Image getMapOpenIcon() { return getIcon(FOLDER_MAP_OPEN_RES); }
|
||||
|
||||
private static String FOLDER_AT_CLOSED_RES = "/com/gpl/rpg/atcontentstudio/img/folder_at_closed.png";
|
||||
|
||||
public static Image getATClosedImage() {
|
||||
return getImage(FOLDER_AT_CLOSED_RES);
|
||||
}
|
||||
|
||||
public static Image getATClosedIcon() {
|
||||
return getIcon(FOLDER_AT_CLOSED_RES);
|
||||
}
|
||||
public static Image getATClosedImage() { return getImage(FOLDER_AT_CLOSED_RES); }
|
||||
public static Image getATClosedIcon() { return getIcon(FOLDER_AT_CLOSED_RES); }
|
||||
|
||||
private static String FOLDER_AT_OPEN_RES = "/com/gpl/rpg/atcontentstudio/img/folder_at_open.png";
|
||||
|
||||
public static Image getATOpenImage() {
|
||||
return getImage(FOLDER_AT_OPEN_RES);
|
||||
}
|
||||
|
||||
public static Image getATOpenIcon() {
|
||||
return getIcon(FOLDER_AT_OPEN_RES);
|
||||
}
|
||||
public static Image getATOpenImage() { return getImage(FOLDER_AT_OPEN_RES); }
|
||||
public static Image getATOpenIcon() { return getIcon(FOLDER_AT_OPEN_RES); }
|
||||
|
||||
private static String FOLDER_BOOKMARK_CLOSED_RES = "/com/gpl/rpg/atcontentstudio/img/folder_bookmark_closed.png";
|
||||
|
||||
public static Image getBookmarkClosedImage() {
|
||||
return getImage(FOLDER_BOOKMARK_CLOSED_RES);
|
||||
}
|
||||
|
||||
public static Image getBookmarkClosedIcon() {
|
||||
return getIcon(FOLDER_BOOKMARK_CLOSED_RES);
|
||||
}
|
||||
public static Image getBookmarkClosedImage() { return getImage(FOLDER_BOOKMARK_CLOSED_RES); }
|
||||
public static Image getBookmarkClosedIcon() { return getIcon(FOLDER_BOOKMARK_CLOSED_RES); }
|
||||
|
||||
private static String FOLDER_BOOKMARK_OPEN_RES = "/com/gpl/rpg/atcontentstudio/img/folder_bookmark_open.png";
|
||||
|
||||
public static Image getBookmarkOpenImage() {
|
||||
return getImage(FOLDER_BOOKMARK_OPEN_RES);
|
||||
}
|
||||
|
||||
public static Image getBookmarkOpenIcon() {
|
||||
return getIcon(FOLDER_BOOKMARK_OPEN_RES);
|
||||
}
|
||||
public static Image getBookmarkOpenImage() { return getImage(FOLDER_BOOKMARK_OPEN_RES); }
|
||||
public static Image getBookmarkOpenIcon() { return getIcon(FOLDER_BOOKMARK_OPEN_RES); }
|
||||
|
||||
private static String TILED_ICON_RES = "/com/gpl/rpg/atcontentstudio/img/tiled-icon.png";
|
||||
|
||||
public static Image getTiledIconImage() {
|
||||
return getImage(TILED_ICON_RES);
|
||||
}
|
||||
|
||||
public static Image getTiledIconIcon() {
|
||||
return getIcon(TILED_ICON_RES);
|
||||
}
|
||||
public static Image getTiledIconImage() { return getImage(TILED_ICON_RES); }
|
||||
public static Image getTiledIconIcon() { return getIcon(TILED_ICON_RES); }
|
||||
|
||||
private static String UI_MAP_RES = "/com/gpl/rpg/atcontentstudio/img/ui_icon_map.png";
|
||||
|
||||
public static Image getUIMapImage() {
|
||||
return getImage(UI_MAP_RES);
|
||||
}
|
||||
|
||||
public static Image getUIMapIcon() {
|
||||
return getIcon(UI_MAP_RES);
|
||||
}
|
||||
public static Image getUIMapImage() { return getImage(UI_MAP_RES); }
|
||||
public static Image getUIMapIcon() { return getIcon(UI_MAP_RES); }
|
||||
|
||||
private static String HERO_RES = "/com/gpl/rpg/atcontentstudio/img/char_hero.png";
|
||||
|
||||
public static Image getHeroImage() {
|
||||
return getImage(HERO_RES);
|
||||
}
|
||||
|
||||
public static Image getHeroIcon() {
|
||||
return getIcon(HERO_RES);
|
||||
}
|
||||
public static Image getHeroImage() { return getImage(HERO_RES); }
|
||||
public static Image getHeroIcon() { return getIcon(HERO_RES); }
|
||||
|
||||
private static String TILE_LAYER_RES = "/com/gpl/rpg/atcontentstudio/img/tile_layer.png";
|
||||
|
||||
public static Image getTileLayerImage() {
|
||||
return getImage(TILE_LAYER_RES);
|
||||
}
|
||||
|
||||
public static Image getTileLayerIcon() {
|
||||
return getIcon(TILE_LAYER_RES);
|
||||
}
|
||||
public static Image getTileLayerImage() { return getImage(TILE_LAYER_RES); }
|
||||
public static Image getTileLayerIcon() { return getIcon(TILE_LAYER_RES); }
|
||||
|
||||
private static String OBJECT_LAYER_RES = "/com/gpl/rpg/atcontentstudio/img/object_layer.png";
|
||||
|
||||
public static Image getObjectLayerImage() {
|
||||
return getImage(OBJECT_LAYER_RES);
|
||||
}
|
||||
|
||||
public static Image getObjectLayerIcon() {
|
||||
return getIcon(OBJECT_LAYER_RES);
|
||||
}
|
||||
public static Image getObjectLayerImage() { return getImage(OBJECT_LAYER_RES); }
|
||||
public static Image getObjectLayerIcon() { return getIcon(OBJECT_LAYER_RES); }
|
||||
|
||||
private static String ACTOR_CONDITION_RES = "/com/gpl/rpg/atcontentstudio/img/actor_condition.png";
|
||||
|
||||
public static Image getActorConditionImage() {
|
||||
return getImage(ACTOR_CONDITION_RES);
|
||||
}
|
||||
|
||||
public static Image getActorConditionIcon() {
|
||||
return getIcon(ACTOR_CONDITION_RES);
|
||||
}
|
||||
public static Image getActorConditionImage() { return getImage(ACTOR_CONDITION_RES); }
|
||||
public static Image getActorConditionIcon() { return getIcon(ACTOR_CONDITION_RES); }
|
||||
|
||||
private static String ITEM_RES = "/com/gpl/rpg/atcontentstudio/img/item.png";
|
||||
|
||||
public static Image getItemImage() {
|
||||
return getImage(ITEM_RES);
|
||||
}
|
||||
|
||||
public static Image getItemIcon() {
|
||||
return getIcon(ITEM_RES);
|
||||
}
|
||||
public static Image getItemImage() { return getImage(ITEM_RES); }
|
||||
public static Image getItemIcon() { return getIcon(ITEM_RES); }
|
||||
|
||||
private static String NPC_RES = "/com/gpl/rpg/atcontentstudio/img/npc.png";
|
||||
|
||||
public static Image getNPCImage() {
|
||||
return getImage(NPC_RES);
|
||||
}
|
||||
|
||||
public static Image getNPCIcon() {
|
||||
return getIcon(NPC_RES);
|
||||
}
|
||||
public static Image getNPCImage() { return getImage(NPC_RES); }
|
||||
public static Image getNPCIcon() { return getIcon(NPC_RES); }
|
||||
|
||||
private static String BONEMEAL_RES = "/com/gpl/rpg/atcontentstudio/img/bonemeal.png";
|
||||
|
||||
public static Image getBonemealImage() {
|
||||
return getImage(BONEMEAL_RES);
|
||||
}
|
||||
|
||||
public static Image getBonemealIcon() {
|
||||
return getIcon(BONEMEAL_RES);
|
||||
}
|
||||
public static Image getBonemealImage() { return getImage(BONEMEAL_RES); }
|
||||
public static Image getBonemealIcon() { return getIcon(BONEMEAL_RES); }
|
||||
|
||||
private static String NPC_CLOSE_RES = "/com/gpl/rpg/atcontentstudio/img/npc_close.png";
|
||||
|
||||
public static Image getNPCCloseImage() {
|
||||
return getImage(NPC_CLOSE_RES);
|
||||
}
|
||||
|
||||
public static Image getNPCCloseIcon() {
|
||||
return getIcon(NPC_CLOSE_RES);
|
||||
}
|
||||
public static Image getNPCCloseImage() { return getImage(NPC_CLOSE_RES); }
|
||||
public static Image getNPCCloseIcon() { return getIcon(NPC_CLOSE_RES); }
|
||||
|
||||
private static String DIALOGUE_RES = "/com/gpl/rpg/atcontentstudio/img/dialogue.png";
|
||||
|
||||
public static Image getDialogueImage() {
|
||||
return getImage(DIALOGUE_RES);
|
||||
}
|
||||
|
||||
public static Image getDialogueIcon() {
|
||||
return getIcon(DIALOGUE_RES);
|
||||
}
|
||||
public static Image getDialogueImage() { return getImage(DIALOGUE_RES); }
|
||||
public static Image getDialogueIcon() { return getIcon(DIALOGUE_RES); }
|
||||
|
||||
private static String QUEST_RES = "/com/gpl/rpg/atcontentstudio/img/ui_icon_quest.png";
|
||||
|
||||
public static Image getQuestImage() {
|
||||
return getImage(QUEST_RES);
|
||||
}
|
||||
|
||||
public static Image getQuestIcon() {
|
||||
return getIcon(QUEST_RES);
|
||||
}
|
||||
public static Image getQuestImage() { return getImage(QUEST_RES); }
|
||||
public static Image getQuestIcon() { return getIcon(QUEST_RES); }
|
||||
|
||||
private static String DROPLIST_RES = "/com/gpl/rpg/atcontentstudio/img/ui_icon_equipment.png";
|
||||
|
||||
public static Image getDroplistImage() {
|
||||
return getImage(DROPLIST_RES);
|
||||
}
|
||||
|
||||
public static Image getDroplistIcon() {
|
||||
return getIcon(DROPLIST_RES);
|
||||
}
|
||||
public static Image getDroplistImage() { return getImage(DROPLIST_RES); }
|
||||
public static Image getDroplistIcon() { return getIcon(DROPLIST_RES); }
|
||||
|
||||
private static String COMBAT_RES = "/com/gpl/rpg/atcontentstudio/img/ui_icon_combat.png";
|
||||
|
||||
public static Image getCombatImage() {
|
||||
return getImage(COMBAT_RES);
|
||||
}
|
||||
|
||||
public static Image getCombatIcon() {
|
||||
return getIcon(COMBAT_RES);
|
||||
}
|
||||
public static Image getCombatImage() { return getImage(COMBAT_RES); }
|
||||
public static Image getCombatIcon() { return getIcon(COMBAT_RES); }
|
||||
|
||||
private static String GOLD_RES = "/com/gpl/rpg/atcontentstudio/img/ui_icon_coins.png";
|
||||
|
||||
public static Image getGoldImage() {
|
||||
return getImage(GOLD_RES);
|
||||
}
|
||||
|
||||
public static Image getGoldIcon() {
|
||||
return getIcon(GOLD_RES);
|
||||
}
|
||||
public static Image getGoldImage() { return getImage(GOLD_RES); }
|
||||
public static Image getGoldIcon() { return getIcon(GOLD_RES); }
|
||||
|
||||
private static String SKILL_RES = "/com/gpl/rpg/atcontentstudio/img/ui_icon_skill.png";
|
||||
|
||||
public static Image getSkillImage() {
|
||||
return getImage(SKILL_RES);
|
||||
}
|
||||
|
||||
public static Image getSkillIcon() {
|
||||
return getIcon(SKILL_RES);
|
||||
}
|
||||
public static Image getSkillImage() { return getImage(SKILL_RES); }
|
||||
public static Image getSkillIcon() { return getIcon(SKILL_RES); }
|
||||
|
||||
private static String IMMUNITY_RES = "/com/gpl/rpg/atcontentstudio/img/ui_icon_immunity.png";
|
||||
|
||||
public static Image getImmunityImage() {
|
||||
return getImage(IMMUNITY_RES);
|
||||
}
|
||||
|
||||
public static Image getImmunityIcon() {
|
||||
return getIcon(IMMUNITY_RES);
|
||||
}
|
||||
public static Image getImmunityImage() { return getImage(IMMUNITY_RES); }
|
||||
public static Image getImmunityIcon() { return getIcon(IMMUNITY_RES); }
|
||||
|
||||
private static String ITEM_CATEGORY_RES = "/com/gpl/rpg/atcontentstudio/img/equip_weapon.png";
|
||||
|
||||
public static Image getItemCategoryImage() {
|
||||
return getImage(ITEM_CATEGORY_RES);
|
||||
}
|
||||
|
||||
public static Image getItemCategoryIcon() {
|
||||
return getIcon(ITEM_CATEGORY_RES);
|
||||
}
|
||||
public static Image getItemCategoryImage() { return getImage(ITEM_CATEGORY_RES); }
|
||||
public static Image getItemCategoryIcon() { return getIcon(ITEM_CATEGORY_RES); }
|
||||
|
||||
private static String NULLIFY_RES = "/com/gpl/rpg/atcontentstudio/img/nullify.png";
|
||||
|
||||
public static Image getNullifyImage() {
|
||||
return getImage(NULLIFY_RES);
|
||||
}
|
||||
|
||||
public static Image getNullifyIcon() {
|
||||
return getIcon(NULLIFY_RES);
|
||||
}
|
||||
public static Image getNullifyImage() { return getImage(NULLIFY_RES); }
|
||||
public static Image getNullifyIcon() { return getIcon(NULLIFY_RES); }
|
||||
|
||||
private static String CREATE_RES = "/com/gpl/rpg/atcontentstudio/img/file_create.png";
|
||||
|
||||
public static Image getCreateImage() {
|
||||
return getImage(CREATE_RES);
|
||||
}
|
||||
|
||||
public static Image getCreateIcon() {
|
||||
return getIcon(CREATE_RES);
|
||||
}
|
||||
public static Image getCreateImage() { return getImage(CREATE_RES); }
|
||||
public static Image getCreateIcon() { return getIcon(CREATE_RES); }
|
||||
|
||||
private static String ARROW_UP_RES = "/com/gpl/rpg/atcontentstudio/img/arrow_up.png";
|
||||
|
||||
public static Image getArrowUpImage() {
|
||||
return getImage(ARROW_UP_RES);
|
||||
}
|
||||
|
||||
public static Image getArrowUpIcon() {
|
||||
return getIcon(ARROW_UP_RES);
|
||||
}
|
||||
public static Image getArrowUpImage() { return getImage(ARROW_UP_RES); }
|
||||
public static Image getArrowUpIcon() { return getIcon(ARROW_UP_RES); }
|
||||
|
||||
private static String ARROW_DOWN_RES = "/com/gpl/rpg/atcontentstudio/img/arrow_down.png";
|
||||
|
||||
public static Image getArrowDownImage() {
|
||||
return getImage(ARROW_DOWN_RES);
|
||||
}
|
||||
|
||||
public static Image getArrowDownIcon() {
|
||||
return getIcon(ARROW_DOWN_RES);
|
||||
}
|
||||
public static Image getArrowDownImage() { return getImage(ARROW_DOWN_RES); }
|
||||
public static Image getArrowDownIcon() { return getIcon(ARROW_DOWN_RES); }
|
||||
|
||||
private static String ARROW_LEFT_RES = "/com/gpl/rpg/atcontentstudio/img/arrow_left.png";
|
||||
|
||||
public static Image getArrowLeftImage() {
|
||||
return getImage(ARROW_LEFT_RES);
|
||||
}
|
||||
|
||||
public static Image getArrowLeftIcon() {
|
||||
return getIcon(ARROW_LEFT_RES);
|
||||
}
|
||||
public static Image getArrowLeftImage() { return getImage(ARROW_LEFT_RES); }
|
||||
public static Image getArrowLeftIcon() { return getIcon(ARROW_LEFT_RES); }
|
||||
|
||||
private static String ARROW_RIGHT_RES = "/com/gpl/rpg/atcontentstudio/img/arrow_right.png";
|
||||
|
||||
public static Image getArrowRightImage() {
|
||||
return getImage(ARROW_RIGHT_RES);
|
||||
}
|
||||
|
||||
public static Image getArrowRightIcon() {
|
||||
return getIcon(ARROW_RIGHT_RES);
|
||||
}
|
||||
public static Image getArrowRightImage() { return getImage(ARROW_RIGHT_RES); }
|
||||
public static Image getArrowRightIcon() { return getIcon(ARROW_RIGHT_RES); }
|
||||
|
||||
private static String CONTAINER_RES = "/com/gpl/rpg/atcontentstudio/img/container.png";
|
||||
|
||||
public static Image getContainerImage() {
|
||||
return getImage(CONTAINER_RES);
|
||||
}
|
||||
|
||||
public static Image getContainerIcon() {
|
||||
return getIcon(CONTAINER_RES);
|
||||
}
|
||||
public static Image getContainerImage() { return getImage(CONTAINER_RES); }
|
||||
public static Image getContainerIcon() { return getIcon(CONTAINER_RES); }
|
||||
|
||||
private static String KEY_RES = "/com/gpl/rpg/atcontentstudio/img/key.png";
|
||||
|
||||
public static Image getKeyImage() {
|
||||
return getImage(KEY_RES);
|
||||
}
|
||||
|
||||
public static Image getKeyIcon() {
|
||||
return getIcon(KEY_RES);
|
||||
}
|
||||
public static Image getKeyImage() { return getImage(KEY_RES); }
|
||||
public static Image getKeyIcon() { return getIcon(KEY_RES); }
|
||||
|
||||
private static String MAPCHANGE_RES = "/com/gpl/rpg/atcontentstudio/img/mapchange.png";
|
||||
|
||||
public static Image getMapchangeImage() {
|
||||
return getImage(MAPCHANGE_RES);
|
||||
}
|
||||
|
||||
public static Image getMapchangeIcon() {
|
||||
return getIcon(MAPCHANGE_RES);
|
||||
}
|
||||
public static Image getMapchangeImage() { return getImage(MAPCHANGE_RES); }
|
||||
public static Image getMapchangeIcon() { return getIcon(MAPCHANGE_RES); }
|
||||
|
||||
private static String REPLACE_RES = "/com/gpl/rpg/atcontentstudio/img/replace.png";
|
||||
|
||||
public static Image getReplaceImage() {
|
||||
return getImage(REPLACE_RES);
|
||||
}
|
||||
|
||||
public static Image getReplaceIcon() {
|
||||
return getIcon(REPLACE_RES);
|
||||
}
|
||||
public static Image getReplaceImage() { return getImage(REPLACE_RES); }
|
||||
public static Image getReplaceIcon() { return getIcon(REPLACE_RES); }
|
||||
|
||||
private static String REST_RES = "/com/gpl/rpg/atcontentstudio/img/rest.png";
|
||||
|
||||
public static Image getRestImage() {
|
||||
return getImage(REST_RES);
|
||||
}
|
||||
|
||||
public static Image getRestIcon() {
|
||||
return getIcon(REST_RES);
|
||||
}
|
||||
public static Image getRestImage() { return getImage(REST_RES); }
|
||||
public static Image getRestIcon() { return getIcon(REST_RES); }
|
||||
|
||||
private static String SCRIPT_RES = "/com/gpl/rpg/atcontentstudio/img/script.png";
|
||||
|
||||
public static Image getScriptImage() {
|
||||
return getImage(SCRIPT_RES);
|
||||
}
|
||||
|
||||
public static Image getScriptIcon() {
|
||||
return getIcon(SCRIPT_RES);
|
||||
}
|
||||
public static Image getScriptImage() { return getImage(SCRIPT_RES); }
|
||||
public static Image getScriptIcon() { return getIcon(SCRIPT_RES); }
|
||||
|
||||
private static String SIGN_RES = "/com/gpl/rpg/atcontentstudio/img/sign.png";
|
||||
|
||||
public static Image getSignImage() {
|
||||
return getImage(SIGN_RES);
|
||||
}
|
||||
|
||||
public static Image getSignIcon() {
|
||||
return getIcon(SIGN_RES);
|
||||
}
|
||||
public static Image getSignImage() { return getImage(SIGN_RES); }
|
||||
public static Image getSignIcon() { return getIcon(SIGN_RES); }
|
||||
|
||||
private static String CREATE_CONTAINER_RES = "/com/gpl/rpg/atcontentstudio/img/create_container.png";
|
||||
|
||||
public static Image getCreateContainerImage() {
|
||||
return getImage(CREATE_CONTAINER_RES);
|
||||
}
|
||||
|
||||
public static Image getCreateContainerIcon() {
|
||||
return getIcon(CREATE_CONTAINER_RES);
|
||||
}
|
||||
public static Image getCreateContainerImage() { return getImage(CREATE_CONTAINER_RES); }
|
||||
public static Image getCreateContainerIcon() { return getIcon(CREATE_CONTAINER_RES); }
|
||||
|
||||
private static String CREATE_KEY_RES = "/com/gpl/rpg/atcontentstudio/img/create_key.png";
|
||||
|
||||
public static Image getCreateKeyImage() {
|
||||
return getImage(CREATE_KEY_RES);
|
||||
}
|
||||
|
||||
public static Image getCreateKeyIcon() {
|
||||
return getIcon(CREATE_KEY_RES);
|
||||
}
|
||||
public static Image getCreateKeyImage() { return getImage(CREATE_KEY_RES); }
|
||||
public static Image getCreateKeyIcon() { return getIcon(CREATE_KEY_RES); }
|
||||
|
||||
private static String CREATE_REPLACE_RES = "/com/gpl/rpg/atcontentstudio/img/create_replace.png";
|
||||
|
||||
public static Image getCreateReplaceImage() {
|
||||
return getImage(CREATE_REPLACE_RES);
|
||||
}
|
||||
|
||||
public static Image getCreateReplaceIcon() {
|
||||
return getIcon(CREATE_REPLACE_RES);
|
||||
}
|
||||
public static Image getCreateReplaceImage() { return getImage(CREATE_REPLACE_RES); }
|
||||
public static Image getCreateReplaceIcon() { return getIcon(CREATE_REPLACE_RES); }
|
||||
|
||||
private static String CREATE_REST_RES = "/com/gpl/rpg/atcontentstudio/img/create_rest.png";
|
||||
|
||||
public static Image getCreateRestImage() {
|
||||
return getImage(CREATE_REST_RES);
|
||||
}
|
||||
|
||||
public static Image getCreateRestIcon() {
|
||||
return getIcon(CREATE_REST_RES);
|
||||
}
|
||||
public static Image getCreateRestImage() { return getImage(CREATE_REST_RES); }
|
||||
public static Image getCreateRestIcon() { return getIcon(CREATE_REST_RES); }
|
||||
|
||||
private static String CREATE_SCRIPT_RES = "/com/gpl/rpg/atcontentstudio/img/create_script.png";
|
||||
|
||||
public static Image getCreateScriptImage() {
|
||||
return getImage(CREATE_SCRIPT_RES);
|
||||
}
|
||||
|
||||
public static Image getCreateScriptIcon() {
|
||||
return getIcon(CREATE_SCRIPT_RES);
|
||||
}
|
||||
public static Image getCreateScriptImage() { return getImage(CREATE_SCRIPT_RES); }
|
||||
public static Image getCreateScriptIcon() { return getIcon(CREATE_SCRIPT_RES); }
|
||||
|
||||
private static String CREATE_SIGN_RES = "/com/gpl/rpg/atcontentstudio/img/create_sign.png";
|
||||
|
||||
public static Image getCreateSignImage() {
|
||||
return getImage(CREATE_SIGN_RES);
|
||||
}
|
||||
|
||||
public static Image getCreateSignIcon() {
|
||||
return getIcon(CREATE_SIGN_RES);
|
||||
}
|
||||
public static Image getCreateSignImage() { return getImage(CREATE_SIGN_RES); }
|
||||
public static Image getCreateSignIcon() { return getIcon(CREATE_SIGN_RES); }
|
||||
|
||||
private static String CREATE_SPAWNAREA_RES = "/com/gpl/rpg/atcontentstudio/img/create_spawnarea.png";
|
||||
|
||||
public static Image getCreateSpawnareaImage() {
|
||||
return getImage(CREATE_SPAWNAREA_RES);
|
||||
}
|
||||
|
||||
public static Image getCreateSpawnareaIcon() {
|
||||
return getIcon(CREATE_SPAWNAREA_RES);
|
||||
}
|
||||
public static Image getCreateSpawnareaImage() { return getImage(CREATE_SPAWNAREA_RES); }
|
||||
public static Image getCreateSpawnareaIcon() { return getIcon(CREATE_SPAWNAREA_RES); }
|
||||
|
||||
private static String CREATE_MAPCHANGE_RES = "/com/gpl/rpg/atcontentstudio/img/create_tiled.png";
|
||||
|
||||
public static Image getCreateMapchangeImage() {
|
||||
return getImage(CREATE_MAPCHANGE_RES);
|
||||
}
|
||||
|
||||
public static Image getCreateMapchangeIcon() {
|
||||
return getIcon(CREATE_MAPCHANGE_RES);
|
||||
}
|
||||
public static Image getCreateMapchangeImage() { return getImage(CREATE_MAPCHANGE_RES); }
|
||||
public static Image getCreateMapchangeIcon() { return getIcon(CREATE_MAPCHANGE_RES); }
|
||||
|
||||
private static String CREATE_OBJECT_GROUP_RES = "/com/gpl/rpg/atcontentstudio/img/create_object_group.png";
|
||||
|
||||
public static Image getCreateObjectGroupImage() {
|
||||
return getImage(CREATE_OBJECT_GROUP_RES);
|
||||
}
|
||||
|
||||
public static Image getCreateObjectGroupIcon() {
|
||||
return getIcon(CREATE_OBJECT_GROUP_RES);
|
||||
}
|
||||
public static Image getCreateObjectGroupImage() { return getImage(CREATE_OBJECT_GROUP_RES); }
|
||||
public static Image getCreateObjectGroupIcon() { return getIcon(CREATE_OBJECT_GROUP_RES); }
|
||||
|
||||
private static String CREATE_TILE_LAYER_RES = "/com/gpl/rpg/atcontentstudio/img/create_tile_layer.png";
|
||||
|
||||
public static Image getCreateTileLayerImage() {
|
||||
return getImage(CREATE_TILE_LAYER_RES);
|
||||
}
|
||||
|
||||
public static Image getCreateTileLayerIcon() {
|
||||
return getIcon(CREATE_TILE_LAYER_RES);
|
||||
}
|
||||
public static Image getCreateTileLayerImage() { return getImage(CREATE_TILE_LAYER_RES); }
|
||||
public static Image getCreateTileLayerIcon() { return getIcon(CREATE_TILE_LAYER_RES); }
|
||||
|
||||
private static String LABEL_RES = "/com/gpl/rpg/atcontentstudio/img/label.png";
|
||||
|
||||
public static Image getLabelImage() {
|
||||
return getImage(LABEL_RES);
|
||||
}
|
||||
|
||||
public static Image getLabelIcon() {
|
||||
return getIcon(LABEL_RES);
|
||||
}
|
||||
public static Image getLabelImage() { return getImage(LABEL_RES); }
|
||||
public static Image getLabelIcon() { return getIcon(LABEL_RES); }
|
||||
|
||||
private static String ZOOM_RES = "/com/gpl/rpg/atcontentstudio/img/zoom.png";
|
||||
|
||||
public static Image getZoomImage() {
|
||||
return getImage(ZOOM_RES);
|
||||
}
|
||||
|
||||
public static Image getZoomIcon() {
|
||||
return getIcon(ZOOM_RES);
|
||||
}
|
||||
public static Image getZoomImage() { return getImage(ZOOM_RES); }
|
||||
public static Image getZoomIcon() { return getIcon(ZOOM_RES); }
|
||||
|
||||
private static String TIMER_RES = "/com/gpl/rpg/atcontentstudio/img/timer.png";
|
||||
|
||||
public static Image getTimerImage() {
|
||||
return getImage(TIMER_RES);
|
||||
}
|
||||
|
||||
public static Image getTimerIcon() {
|
||||
return getIcon(TIMER_RES);
|
||||
}
|
||||
public static Image getTimerImage() { return getImage(TIMER_RES); }
|
||||
public static Image getTimerIcon() { return getIcon(TIMER_RES); }
|
||||
|
||||
private static String DATE_RES = "/com/gpl/rpg/atcontentstudio/img/date.png";
|
||||
|
||||
public static Image getDateImage() {
|
||||
return getImage(DATE_RES);
|
||||
}
|
||||
|
||||
public static Image getDateIcon() {
|
||||
return getIcon(DATE_RES);
|
||||
}
|
||||
public static Image getDateImage() { return getImage(DATE_RES); }
|
||||
public static Image getDateIcon() { return getIcon(DATE_RES); }
|
||||
|
||||
private static String TIME_RES = "/com/gpl/rpg/atcontentstudio/img/date.png";
|
||||
|
||||
public static Image getTimeImage() {
|
||||
return getImage(TIME_RES);
|
||||
}
|
||||
|
||||
public static Image getTimeIcon() {
|
||||
return getIcon(TIME_RES);
|
||||
}
|
||||
public static Image getTimeImage() { return getImage(TIME_RES); }
|
||||
public static Image getTimeIcon() { return getIcon(TIME_RES); }
|
||||
|
||||
private static String ALIGNMENT_RES = "/com/gpl/rpg/atcontentstudio/img/alignment.png";
|
||||
|
||||
public static Image getAlignmentImage() {
|
||||
return getImage(ALIGNMENT_RES);
|
||||
}
|
||||
|
||||
public static Image getAlignmentIcon() {
|
||||
return getIcon(ALIGNMENT_RES);
|
||||
}
|
||||
public static Image getAlignmentImage() { return getImage(ALIGNMENT_RES); }
|
||||
public static Image getAlignmentIcon() { return getIcon(ALIGNMENT_RES); }
|
||||
|
||||
private static String STATUS_RED_RES = "/com/gpl/rpg/atcontentstudio/img/status_red.png";
|
||||
|
||||
public static Image getStatusRedImage() {
|
||||
return getImage(STATUS_RED_RES);
|
||||
}
|
||||
|
||||
public static Image getStatusRedIcon() {
|
||||
return getIcon(STATUS_RED_RES);
|
||||
}
|
||||
public static Image getStatusRedImage() { return getImage(STATUS_RED_RES); }
|
||||
public static Image getStatusRedIcon() { return getIcon(STATUS_RED_RES); }
|
||||
|
||||
private static String STATUS_ORANGE_RES = "/com/gpl/rpg/atcontentstudio/img/status_orange.png";
|
||||
|
||||
public static Image getStatusOrangeImage() {
|
||||
return getImage(STATUS_ORANGE_RES);
|
||||
}
|
||||
|
||||
public static Image getStatusOrangeIcon() {
|
||||
return getIcon(STATUS_ORANGE_RES);
|
||||
}
|
||||
public static Image getStatusOrangeImage() { return getImage(STATUS_ORANGE_RES); }
|
||||
public static Image getStatusOrangeIcon() { return getIcon(STATUS_ORANGE_RES); }
|
||||
|
||||
private static String STATUS_GREEN_RES = "/com/gpl/rpg/atcontentstudio/img/status_green.png";
|
||||
|
||||
public static Image getStatusGreenImage() {
|
||||
return getImage(STATUS_GREEN_RES);
|
||||
}
|
||||
|
||||
public static Image getStatusGreenIcon() {
|
||||
return getIcon(STATUS_GREEN_RES);
|
||||
}
|
||||
public static Image getStatusGreenImage() { return getImage(STATUS_GREEN_RES); }
|
||||
public static Image getStatusGreenIcon() { return getIcon(STATUS_GREEN_RES); }
|
||||
|
||||
private static String STATUS_BLUE_RES = "/com/gpl/rpg/atcontentstudio/img/status_blue.png";
|
||||
|
||||
public static Image getStatusBlueImage() {
|
||||
return getImage(STATUS_BLUE_RES);
|
||||
}
|
||||
|
||||
public static Image getStatusBlueIcon() {
|
||||
return getIcon(STATUS_BLUE_RES);
|
||||
}
|
||||
public static Image getStatusBlueImage() { return getImage(STATUS_BLUE_RES); }
|
||||
public static Image getStatusBlueIcon() { return getIcon(STATUS_BLUE_RES); }
|
||||
|
||||
private static String STATUS_UNKNOWN_RES = "/com/gpl/rpg/atcontentstudio/img/status_unknown.png";
|
||||
|
||||
public static Image getStatusUnknownImage() {
|
||||
return getImage(STATUS_UNKNOWN_RES);
|
||||
}
|
||||
|
||||
public static Image getStatusUnknownIcon() {
|
||||
return getIcon(STATUS_UNKNOWN_RES);
|
||||
}
|
||||
public static Image getStatusUnknownImage() { return getImage(STATUS_UNKNOWN_RES); }
|
||||
public static Image getStatusUnknownIcon() { return getIcon(STATUS_UNKNOWN_RES); }
|
||||
|
||||
private static String BOOKMARK_INACTIVE = "/com/gpl/rpg/atcontentstudio/img/bookmark_inactive.png";
|
||||
|
||||
public static Image getBookmarkInactiveImage() {
|
||||
return getImage(BOOKMARK_INACTIVE);
|
||||
}
|
||||
|
||||
public static Image getBookmarkInactiveIcon() {
|
||||
return getIcon(BOOKMARK_INACTIVE);
|
||||
}
|
||||
public static Image getBookmarkInactiveImage() { return getImage(BOOKMARK_INACTIVE); }
|
||||
public static Image getBookmarkInactiveIcon() { return getIcon(BOOKMARK_INACTIVE); }
|
||||
|
||||
private static String BOOKMARK_ACTIVE = "/com/gpl/rpg/atcontentstudio/img/bookmark_active.png";
|
||||
|
||||
public static Image getBookmarkActiveImage() {
|
||||
return getImage(BOOKMARK_ACTIVE);
|
||||
}
|
||||
|
||||
public static Image getBookmarkActiveIcon() {
|
||||
return getIcon(BOOKMARK_ACTIVE);
|
||||
}
|
||||
public static Image getBookmarkActiveImage() { return getImage(BOOKMARK_ACTIVE); }
|
||||
public static Image getBookmarkActiveIcon() { return getIcon(BOOKMARK_ACTIVE); }
|
||||
|
||||
|
||||
private static Image getImage(String res) {
|
||||
|
||||
@@ -1,40 +1,78 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import javax.swing.AbstractListModel;
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JSpinner.NumberEditor;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import javax.swing.text.DefaultFormatter;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.ProjectElementListener;
|
||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.*;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Droplist;
|
||||
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.utils.WeblateIntegration;
|
||||
import com.jidesoft.swing.ComboBoxSearchable;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JSpinner.NumberEditor;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.text.DefaultFormatter;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
|
||||
private static final long serialVersionUID = 241750514033596878L;
|
||||
private static final FieldUpdateListener nullListener = new FieldUpdateListener() {
|
||||
@Override
|
||||
public void valueChanged(JComponent source, Object value) {
|
||||
}
|
||||
};
|
||||
private static final FieldUpdateListener nullListener = new FieldUpdateListener() {@Override public void valueChanged(JComponent source, Object value) {}};
|
||||
|
||||
public static final String SAVE = "Save";
|
||||
public static final String DELETE = "Delete";
|
||||
@@ -79,8 +117,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
return addTextField(pane, label, value, false, nullListener);
|
||||
}
|
||||
|
||||
public static void addTranslationPane(JPanel pane, final JTextComponent tfComponent, final String initialValue) {
|
||||
if (Workspace.activeWorkspace.settings.translatorLanguage.getCurrentValue() != null) {
|
||||
public static void addTranslationPane(JPanel pane, final JTextComponent tfComponent, final String initialValue) {if (Workspace.activeWorkspace.settings.translatorLanguage.getCurrentValue() != null) {
|
||||
JPanel labelPane = new JPanel();
|
||||
labelPane.setLayout(new JideBoxLayout(labelPane, JideBoxLayout.LINE_AXIS, 6));
|
||||
final JLabel translateLinkLabel = new JLabel(getWeblateLabelLink(initialValue));
|
||||
@@ -124,8 +161,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
break;
|
||||
}
|
||||
translationStatus.setText(unit.translatedText);
|
||||
}
|
||||
|
||||
};
|
||||
}.start();
|
||||
pane.add(labelPane, JideBoxLayout.FIX);
|
||||
tfComponent.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@@ -135,14 +171,12 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
translateLinkLabel.revalidate();
|
||||
translateLinkLabel.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
translateLinkLabel.setText(getWeblateLabelLink(tfComponent.getText().replaceAll("\n", Matcher.quoteReplacement("\n"))));
|
||||
translateLinkLabel.revalidate();
|
||||
translateLinkLabel.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
translateLinkLabel.setText(getWeblateLabelLink(tfComponent.getText().replaceAll("\n", Matcher.quoteReplacement("\n"))));
|
||||
@@ -179,30 +213,13 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
}
|
||||
|
||||
public static JTextField addTextField(JPanel pane, String label, String initialValue, boolean editable, final FieldUpdateListener listener) {
|
||||
final JTextField tfField = new JTextField(initialValue);
|
||||
addTextComponent(pane, label, editable, listener, tfField, false, false);
|
||||
tfField.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
listener.valueChanged(tfField, tfField.getText());
|
||||
}
|
||||
});
|
||||
return tfField;
|
||||
}
|
||||
|
||||
public static <T extends JTextComponent> T addTextComponent(JPanel pane, String label, boolean editable, final FieldUpdateListener listener, T tfField, boolean specialNewLinesHandling, boolean scrollable) {
|
||||
JPanel tfPane = new JPanel();
|
||||
tfPane.setLayout(new JideBoxLayout(tfPane, JideBoxLayout.LINE_AXIS, 6));
|
||||
JLabel tfLabel = new JLabel(label);
|
||||
tfPane.add(tfLabel, JideBoxLayout.FIX);
|
||||
final JTextField tfField = new JTextField(initialValue);
|
||||
tfField.setEditable(editable);
|
||||
JComponent component;
|
||||
if (scrollable) {
|
||||
component = new JScrollPane(tfField);
|
||||
} else {
|
||||
component = tfField;
|
||||
}
|
||||
tfPane.add(component, JideBoxLayout.VARY);
|
||||
tfPane.add(tfField, JideBoxLayout.VARY);
|
||||
JButton nullify = new JButton(new ImageIcon(DefaultIcons.getNullifyIcon()));
|
||||
tfPane.add(nullify, JideBoxLayout.FIX);
|
||||
nullify.setEnabled(editable);
|
||||
@@ -218,23 +235,21 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
tfField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
String text = tfField.getText();
|
||||
if (specialNewLinesHandling) text = text.replaceAll("\n", Matcher.quoteReplacement("\n"));
|
||||
listener.valueChanged(tfField, text);
|
||||
listener.valueChanged(tfField, tfField.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
String text = tfField.getText();
|
||||
if (specialNewLinesHandling) text = text.replaceAll("\n", Matcher.quoteReplacement("\n"));
|
||||
listener.valueChanged(tfField, text);
|
||||
listener.valueChanged(tfField, tfField.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
String text = tfField.getText();
|
||||
if (specialNewLinesHandling) text = text.replaceAll("\n", Matcher.quoteReplacement("\n"));
|
||||
listener.valueChanged(tfField, text);
|
||||
listener.valueChanged(tfField, tfField.getText());
|
||||
}
|
||||
});
|
||||
tfField.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
listener.valueChanged(tfField, tfField.getText());
|
||||
}
|
||||
});
|
||||
return tfField;
|
||||
@@ -249,12 +264,49 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
|
||||
public static JTextArea addTextArea(JPanel pane, String label, String initialValue, boolean editable, final FieldUpdateListener listener) {
|
||||
String text= initialValue == null ? "" : initialValue.replaceAll("\\n", "\n");
|
||||
|
||||
JPanel tfPane = new JPanel();
|
||||
tfPane.setLayout(new JideBoxLayout(tfPane, JideBoxLayout.LINE_AXIS, 6));
|
||||
JLabel tfLabel = new JLabel(label);
|
||||
tfPane.add(tfLabel, JideBoxLayout.FIX);
|
||||
final JTextArea tfArea = new JTextArea(text);
|
||||
tfArea.setEditable(editable);
|
||||
tfArea.setRows(2);
|
||||
tfArea.setLineWrap(true);
|
||||
tfArea.setWrapStyleWord(true);
|
||||
tfPane.add(new JScrollPane(tfArea), JideBoxLayout.VARY);
|
||||
JButton nullify = new JButton(new ImageIcon(DefaultIcons.getNullifyIcon()));
|
||||
tfPane.add(nullify, JideBoxLayout.FIX);
|
||||
nullify.setEnabled(editable);
|
||||
pane.add(tfPane, JideBoxLayout.FIX);
|
||||
|
||||
addTextComponent(pane, label, editable, listener, tfArea, true, true);
|
||||
nullify.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfArea.setText("");
|
||||
listener.valueChanged(tfArea, null);
|
||||
}
|
||||
});
|
||||
tfArea.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
listener.valueChanged(tfArea, tfArea.getText().replaceAll("\n", Matcher.quoteReplacement("\n")));
|
||||
}
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
listener.valueChanged(tfArea, tfArea.getText().replaceAll("\n", Matcher.quoteReplacement("\n")));
|
||||
}
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
listener.valueChanged(tfArea, tfArea.getText().replaceAll("\n", Matcher.quoteReplacement("\n")));
|
||||
}
|
||||
});
|
||||
// tfArea.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// listener.valueChanged(tfArea, tfArea.getText().replaceAll("\n", "\\n"));
|
||||
// }
|
||||
// });
|
||||
return tfArea;
|
||||
}
|
||||
|
||||
@@ -266,17 +318,12 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
return addIntegerField(pane, label, initialValue, 0, allowNegatives, editable, listener);
|
||||
}
|
||||
|
||||
public static <T extends Number & Comparable<T>> JSpinner addNumberField(JPanel pane, String label, boolean editable, final FieldUpdateListener listener, T minimum, T maximum, Number stepSize, T value, T defaultValue) {
|
||||
public static JSpinner addIntegerField(JPanel pane, String label, Integer initialValue, Integer defaultValue, boolean allowNegatives, boolean editable, final FieldUpdateListener listener) {
|
||||
JPanel tfPane = new JPanel();
|
||||
tfPane.setLayout(new JideBoxLayout(tfPane, JideBoxLayout.LINE_AXIS, 6));
|
||||
JLabel tfLabel = new JLabel(label);
|
||||
tfPane.add(tfLabel, JideBoxLayout.FIX);
|
||||
if (!(((minimum == null) || (minimum.compareTo(value) <= 0)) &&
|
||||
((maximum == null) || (maximum.compareTo(value) >= 0)))) {
|
||||
System.err.printf("Value for number field outside of range: %s <= %s <= %s is false%n", minimum, value, maximum);
|
||||
value = defaultValue;
|
||||
}
|
||||
final JSpinner spinner = new JSpinner(new SpinnerNumberModel(value, minimum, maximum, stepSize));
|
||||
final JSpinner spinner = new JSpinner(new SpinnerNumberModel(initialValue != null ? initialValue.intValue() : defaultValue.intValue(), allowNegatives ? Integer.MIN_VALUE : 0, Integer.MAX_VALUE, 1));
|
||||
((JSpinner.DefaultEditor)spinner.getEditor()).getTextField().setHorizontalAlignment(JTextField.LEFT);
|
||||
spinner.setEnabled(editable);
|
||||
((DefaultFormatter)((NumberEditor)spinner.getEditor()).getTextField().getFormatter()).setCommitsOnValidEdit(true);
|
||||
@@ -285,44 +332,35 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
tfPane.add(nullify, JideBoxLayout.FIX);
|
||||
nullify.setEnabled(editable);
|
||||
pane.add(tfPane, JideBoxLayout.FIX);
|
||||
spinner.addChangeListener(e -> listener.valueChanged(spinner, spinner.getValue()));
|
||||
nullify.addActionListener(e -> {
|
||||
spinner.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
listener.valueChanged(spinner, spinner.getValue());
|
||||
}
|
||||
});
|
||||
nullify.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
spinner.setValue(0);
|
||||
listener.valueChanged(spinner, null);
|
||||
}
|
||||
});
|
||||
return spinner;
|
||||
}
|
||||
|
||||
public static JSpinner addIntegerField(JPanel pane, String label, Integer initialValue, Integer defaultValue, boolean allowNegatives, boolean editable, final FieldUpdateListener listener) {
|
||||
int value = initialValue != null ? initialValue : defaultValue;
|
||||
int minimum = allowNegatives ? Integer.MIN_VALUE : 0;
|
||||
int maximum = Integer.MAX_VALUE;
|
||||
return addNumberField(pane, label, editable, listener, minimum, maximum, 1, value, defaultValue);
|
||||
}
|
||||
|
||||
|
||||
private static final String percent = "%";
|
||||
private static final String ratio = "x/y";
|
||||
|
||||
public static JComponent addChanceField(JPanel pane, String label, String initialValue, String defaultValue, boolean editable, final FieldUpdateListener listener) {
|
||||
int defaultChance = 1;
|
||||
int defaultMaxChance = 100;
|
||||
if (defaultValue != null) {
|
||||
if (defaultValue.contains("/")) {
|
||||
int c = defaultValue.indexOf('/');
|
||||
try {
|
||||
defaultChance = Integer.parseInt(defaultValue.substring(0, c));
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
try {
|
||||
defaultMaxChance = Integer.parseInt(defaultValue.substring(c + 1));
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
try { defaultChance = Integer.parseInt(defaultValue.substring(0, c)); } catch (NumberFormatException nfe) {};
|
||||
try { defaultMaxChance = Integer.parseInt(defaultValue.substring(c+1)); } catch (NumberFormatException nfe) {};
|
||||
} else {
|
||||
try {
|
||||
defaultChance = Integer.parseInt(defaultValue);
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
try { defaultChance = Integer.parseInt(defaultValue); } catch (NumberFormatException nfe) {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,20 +370,13 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
if (initialValue != null) {
|
||||
if (initialValue.contains("/")) {
|
||||
int c = initialValue.indexOf('/');
|
||||
try {
|
||||
chance = Integer.parseInt(initialValue.substring(0, c));
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
try {
|
||||
maxChance = Integer.parseInt(initialValue.substring(c + 1));
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
try { chance = Integer.parseInt(initialValue.substring(0, c)); } catch (NumberFormatException nfe) {};
|
||||
try { maxChance = Integer.parseInt(initialValue.substring(c+1)); } catch (NumberFormatException nfe) {};
|
||||
} else {
|
||||
try {
|
||||
chance = Integer.parseInt(initialValue);
|
||||
currentFormIsRatio = false;
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
} catch (NumberFormatException nfe) {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,15 +394,11 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
entryTypeBox.setEnabled(editable);
|
||||
tfPane.add(entryTypeBox, JideBoxLayout.FIX);
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////// make sure "chance" is between 1 and 100. If lower than 1 get 1. If higher than 100, get chance/maxChance * 100... Then do the same with defaultChance, in case no value exist.
|
||||
final SpinnerNumberModel percentModel = new SpinnerNumberModel(
|
||||
initialValue != null ? ((chance > 1 ? chance : 1) < 100 ? chance : (chance * 100 / maxChance)) : ((defaultChance > 1 ? defaultChance : 1) < 100 ? defaultChance : (defaultChance * 100 /
|
||||
defaultMaxChance)),
|
||||
1, 100, 1);
|
||||
final SpinnerNumberModel percentModel = new SpinnerNumberModel(initialValue != null ? ((chance > 1 ? chance : 1) < 100 ? chance : (chance * 100 / maxChance)) : ((defaultChance > 1 ? defaultChance : 1) < 100 ? defaultChance : (defaultChance * 100 / defaultMaxChance)) , 1, 100, 1);
|
||||
final SpinnerNumberModel ratioChanceModel = new SpinnerNumberModel(initialValue != null ? chance : defaultChance, 1, Integer.MAX_VALUE, 1);
|
||||
|
||||
final JSpinner chanceSpinner = new JSpinner(currentFormIsRatio ? ratioChanceModel : percentModel);
|
||||
if (!currentFormIsRatio)
|
||||
((JSpinner.DefaultEditor) chanceSpinner.getEditor()).getTextField().setHorizontalAlignment(JTextField.LEFT);
|
||||
if (!currentFormIsRatio) ((JSpinner.DefaultEditor)chanceSpinner.getEditor()).getTextField().setHorizontalAlignment(JTextField.LEFT);
|
||||
chanceSpinner.setEnabled(editable);
|
||||
((DefaultFormatter)((NumberEditor)chanceSpinner.getEditor()).getTextField().getFormatter()).setCommitsOnValidEdit(true);
|
||||
tfPane.add(chanceSpinner, JideBoxLayout.FLEXIBLE);
|
||||
@@ -458,11 +485,34 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
// }
|
||||
|
||||
public static JSpinner addDoubleField(JPanel pane, String label, Double initialValue, boolean editable, final FieldUpdateListener listener) {
|
||||
double minimum = 0.0d;
|
||||
double defaultValue = 0.0d;
|
||||
double value = initialValue != null ? initialValue : minimum;
|
||||
double maximum = Float.valueOf(Float.MAX_VALUE).doubleValue();
|
||||
return addNumberField(pane, label, editable, listener, minimum, maximum, 1.0d, value, defaultValue);
|
||||
JPanel tfPane = new JPanel();
|
||||
tfPane.setLayout(new JideBoxLayout(tfPane, JideBoxLayout.LINE_AXIS, 6));
|
||||
JLabel tfLabel = new JLabel(label);
|
||||
tfPane.add(tfLabel, JideBoxLayout.FIX);
|
||||
final JSpinner spinner = new JSpinner(new SpinnerNumberModel(initialValue != null ? initialValue.doubleValue() : 0.0d, 0.0d, new Float(Float.MAX_VALUE).doubleValue(), 1.0d));
|
||||
((JSpinner.DefaultEditor)spinner.getEditor()).getTextField().setHorizontalAlignment(JTextField.LEFT);
|
||||
spinner.setEnabled(editable);
|
||||
((DefaultFormatter)((NumberEditor)spinner.getEditor()).getTextField().getFormatter()).setCommitsOnValidEdit(true);
|
||||
tfPane.add(spinner, JideBoxLayout.VARY);
|
||||
JButton nullify = new JButton(new ImageIcon(DefaultIcons.getNullifyIcon()));
|
||||
tfPane.add(nullify, JideBoxLayout.FIX);
|
||||
nullify.setEnabled(editable);
|
||||
pane.add(tfPane, JideBoxLayout.FIX);
|
||||
pane.add(tfPane, JideBoxLayout.FIX);
|
||||
spinner.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
listener.valueChanged(spinner, spinner.getValue());
|
||||
}
|
||||
});
|
||||
nullify.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
spinner.setValue(0.0d);
|
||||
listener.valueChanged(spinner, null);
|
||||
}
|
||||
});
|
||||
return spinner;
|
||||
}
|
||||
|
||||
public static IntegerBasedCheckBox addIntegerBasedCheckBox(JPanel pane, String label, Integer initialValue, boolean editable) {
|
||||
@@ -509,11 +559,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static JComboBox addEnumValueBox(JPanel pane, String label, Enum[] values, Enum initialValue, boolean writable) {
|
||||
return addEnumValueBox(pane, label, values, initialValue, writable, new FieldUpdateListener() {
|
||||
@Override
|
||||
public void valueChanged(JComponent source, Object value) {
|
||||
}
|
||||
});
|
||||
return addEnumValueBox(pane, label, values, initialValue, writable, new FieldUpdateListener() {@Override public void valueChanged(JComponent source, Object value) {}});
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -522,7 +568,8 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
comboPane.setLayout(new JideBoxLayout(comboPane, JideBoxLayout.LINE_AXIS, 6));
|
||||
JLabel comboLabel = new JLabel(label);
|
||||
comboPane.add(comboLabel, JideBoxLayout.FIX);
|
||||
@SuppressWarnings("unchecked") final JComboBox enumValuesCombo = new JComboBox(values);
|
||||
@SuppressWarnings("unchecked")
|
||||
final JComboBox enumValuesCombo = new JComboBox(values);
|
||||
enumValuesCombo.setEnabled(writable);
|
||||
enumValuesCombo.setSelectedItem(initialValue);
|
||||
comboPane.add(enumValuesCombo, JideBoxLayout.VARY);
|
||||
@@ -553,12 +600,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
public MyComboBox addNPCBox(JPanel pane, Project proj, String label, NPC npc, boolean writable, FieldUpdateListener listener) {
|
||||
final GDEComboModel<NPC> comboModel = new GDEComboModel<NPC>(proj, npc){
|
||||
private static final long serialVersionUID = 2638082961277241764L;
|
||||
|
||||
@Override
|
||||
public NPC getTypedElementAt(int index) {
|
||||
return project.getNPC(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return project.getNPCCount()+1;
|
||||
@@ -570,12 +615,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
public MyComboBox addActorConditionBox(JPanel pane, Project proj, String label, ActorCondition acond, boolean writable, FieldUpdateListener listener) {
|
||||
final GDEComboModel<ActorCondition> comboModel = new GDEComboModel<ActorCondition>(proj, acond){
|
||||
private static final long serialVersionUID = 2638082961277241764L;
|
||||
|
||||
@Override
|
||||
public ActorCondition getTypedElementAt(int index) {
|
||||
return project.getActorCondition(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return project.getActorConditionCount()+1;
|
||||
@@ -587,12 +630,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
public MyComboBox addItemBox(JPanel pane, Project proj, String label, Item item, boolean writable, FieldUpdateListener listener) {
|
||||
final GDEComboModel<Item> comboModel = new GDEComboModel<Item>(proj, item){
|
||||
private static final long serialVersionUID = 2638082961277241764L;
|
||||
|
||||
@Override
|
||||
public Item getTypedElementAt(int index) {
|
||||
return project.getItem(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return project.getItemCount()+1;
|
||||
@@ -604,12 +645,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
public MyComboBox addItemCategoryBox(JPanel pane, Project proj, String label, ItemCategory ic, boolean writable, FieldUpdateListener listener) {
|
||||
final GDEComboModel<ItemCategory> comboModel = new GDEComboModel<ItemCategory>(proj, ic){
|
||||
private static final long serialVersionUID = 2638082961277241764L;
|
||||
|
||||
@Override
|
||||
public ItemCategory getTypedElementAt(int index) {
|
||||
return project.getItemCategory(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return project.getItemCategoryCount()+1;
|
||||
@@ -621,12 +660,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
public MyComboBox addQuestBox(JPanel pane, Project proj, String label, Quest quest, boolean writable, FieldUpdateListener listener) {
|
||||
final GDEComboModel<Quest> comboModel = new GDEComboModel<Quest>(proj, quest){
|
||||
private static final long serialVersionUID = 2638082961277241764L;
|
||||
|
||||
@Override
|
||||
public Quest getTypedElementAt(int index) {
|
||||
return project.getQuest(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return project.getQuestCount()+1;
|
||||
@@ -638,12 +675,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
public MyComboBox addDroplistBox(JPanel pane, Project proj, String label, Droplist droplist, boolean writable, FieldUpdateListener listener) {
|
||||
final GDEComboModel<Droplist> comboModel = new GDEComboModel<Droplist>(proj, droplist){
|
||||
private static final long serialVersionUID = 2638082961277241764L;
|
||||
|
||||
@Override
|
||||
public Droplist getTypedElementAt(int index) {
|
||||
return project.getDroplist(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return project.getDroplistCount()+1;
|
||||
@@ -655,12 +690,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
public MyComboBox addDialogueBox(JPanel pane, Project proj, String label, Dialogue dialogue, boolean writable, final FieldUpdateListener listener) {
|
||||
final GDEComboModel<Dialogue> comboModel = new GDEComboModel<Dialogue>(proj, dialogue){
|
||||
private static final long serialVersionUID = 2638082961277241764L;
|
||||
|
||||
@Override
|
||||
public Dialogue getTypedElementAt(int index) {
|
||||
return project.getDialogue(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return project.getDialogueCount()+1;
|
||||
@@ -672,12 +705,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
public MyComboBox addMapBox(JPanel pane, Project proj, String label, TMXMap map, boolean writable, final FieldUpdateListener listener) {
|
||||
final GDEComboModel<TMXMap> comboModel = new GDEComboModel<TMXMap>(proj, map){
|
||||
private static final long serialVersionUID = 2638082961277241764L;
|
||||
|
||||
@Override
|
||||
public TMXMap getTypedElementAt(int index) {
|
||||
return project.getMap(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return project.getMapCount()+1;
|
||||
@@ -792,6 +823,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
});
|
||||
|
||||
|
||||
|
||||
combo.setEnabled(writable);
|
||||
gdePane.add(combo, JideBoxLayout.VARY);
|
||||
|
||||
@@ -801,6 +833,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings({ "rawtypes"})
|
||||
public JList addBacklinksList(JPanel pane, GameDataElement gde) {
|
||||
return addBacklinksList(pane, gde, "Elements linking to this one");
|
||||
@@ -889,8 +922,8 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
|
||||
private static final long serialVersionUID = 6819681566800482793L;
|
||||
|
||||
private boolean includeType;
|
||||
private boolean writable;
|
||||
private boolean includeType = false;
|
||||
private boolean writable = false;
|
||||
|
||||
public GDERenderer(boolean includeType, boolean writable) {
|
||||
super();
|
||||
@@ -995,7 +1028,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
}
|
||||
|
||||
|
||||
public static class GDEBacklinksListModel implements ListenerCollectionModel<GameDataElement> {
|
||||
public static class GDEBacklinksListModel implements ListModel<GameDataElement> {
|
||||
|
||||
GameDataElement source;
|
||||
|
||||
@@ -1007,7 +1040,6 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
public void backlinkRemoved(GameDataElement gde) {
|
||||
fireListChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void backlinkAdded(GameDataElement gde) {
|
||||
fireListChanged();
|
||||
@@ -1016,17 +1048,36 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<GameDataElement> getElements() {
|
||||
return source.getBacklinks();
|
||||
public int getSize() {
|
||||
return source.getBacklinks().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameDataElement getElementAt(int index) {
|
||||
for (GameDataElement gde : source.getBacklinks()) {
|
||||
if (index == 0) return gde;
|
||||
index --;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ListDataListener> listeners = new CopyOnWriteArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
public void fireListChanged() {
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, this.getSize()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@@ -1062,6 +1113,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
public abstract void targetUpdated();
|
||||
|
||||
|
||||
|
||||
transient Map<Class<? extends GameDataElement>, List<ProjectElementListener>> projectElementListeners = new HashMap<Class<? extends GameDataElement>, List<ProjectElementListener>>();
|
||||
|
||||
public void addElementListener(Class<? extends GameDataElement> interestingType, ProjectElementListener listener) {
|
||||
@@ -1110,21 +1162,4 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
}
|
||||
|
||||
|
||||
public <E extends Common.ActorConditionEffect, T extends OrderedListenerListModel<?, E>> void updateConditionEffect(ActorCondition value,
|
||||
GameDataElement backlink,
|
||||
E selectedHitEffectTargetCondition,
|
||||
T hitTargetConditionsModel) {
|
||||
if (selectedHitEffectTargetCondition.condition != null) {
|
||||
selectedHitEffectTargetCondition.condition.removeBacklink(backlink);
|
||||
}
|
||||
selectedHitEffectTargetCondition.condition = value;
|
||||
if (selectedHitEffectTargetCondition.condition != null) {
|
||||
selectedHitEffectTargetCondition.condition_id = selectedHitEffectTargetCondition.condition.id;
|
||||
selectedHitEffectTargetCondition.condition.addBacklink(backlink);
|
||||
} else {
|
||||
selectedHitEffectTargetCondition.condition_id = null;
|
||||
}
|
||||
hitTargetConditionsModel.itemChanged(selectedHitEffectTargetCondition);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +1,42 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
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.model.tools.writermode.WriterModeData;
|
||||
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.*;
|
||||
import com.gpl.rpg.atcontentstudio.ui.map.TMXMapEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.map.WorldMapEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.sprites.SpritesheetEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.tools.writermode.WriterModeEditor;
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Droplist;
|
||||
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.maps.TMXMap;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
|
||||
import com.gpl.rpg.atcontentstudio.model.saves.SavedGame;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeData;
|
||||
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.ActorConditionEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.DialogueEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.DroplistEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.ItemCategoryEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.ItemEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.NPCEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.QuestEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.map.TMXMapEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.map.WorldMapEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.saves.SavedGameEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.sprites.SpritesheetEditor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.tools.writermode.WriterModeEditor;
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
|
||||
public class EditorsArea extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 8801849846876081538L;
|
||||
@@ -44,25 +61,20 @@ public class EditorsArea extends JPanel {
|
||||
@Override
|
||||
public void setEnabled(boolean b) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putValue(String key, Object value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
}
|
||||
@@ -127,6 +139,15 @@ public class EditorsArea extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
public void openEditor(SavedGame save) {
|
||||
if (editors.containsKey(save)) {
|
||||
tabHolder.setSelectedComponent(editors.get(save));
|
||||
return;
|
||||
}
|
||||
openEditor(new SavedGameEditor(save));
|
||||
}
|
||||
|
||||
|
||||
public void openEditor(WorldmapSegment node) {
|
||||
if (editors.containsKey(node)) {
|
||||
tabHolder.setSelectedComponent(editors.get(node));
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
@@ -7,12 +23,6 @@ import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.SpriteSheetSet;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
|
||||
public class ExportProjectWizard extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = -8745083621008868612L;
|
||||
@@ -70,7 +80,6 @@ public class ExportProjectWizard extends JDialog {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser jfc = new JFileChooser(){
|
||||
private static final long serialVersionUID = -3001082967957619011L;
|
||||
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
if (asZip.isSelected()) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
public interface FieldUpdateListener {
|
||||
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
public class IdChangeImpactWizard extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = 8532169707953315739L;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JCheckBox;
|
||||
|
||||
public class IntegerBasedCheckBox extends JCheckBox {
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
|
||||
public class JMovingIdler extends JComponent {
|
||||
@@ -28,8 +33,7 @@ public class JMovingIdler extends JComponent {
|
||||
}
|
||||
try {
|
||||
sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
} catch (InterruptedException e) {}
|
||||
JMovingIdler.this.revalidate();
|
||||
JMovingIdler.this.repaint();
|
||||
}
|
||||
@@ -53,8 +57,7 @@ public class JMovingIdler extends JComponent {
|
||||
running = false;
|
||||
try {
|
||||
moverThread.join();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
} catch (InterruptedException e) {}
|
||||
}
|
||||
|
||||
protected void paintComponent(Graphics g) {
|
||||
|
||||
@@ -1,20 +1,9 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement.State;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.*;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.sprites.SpriteChooser;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import java.awt.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
@@ -22,6 +11,37 @@ import java.awt.event.ItemListener;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.event.ListDataListener;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement.State;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Droplist;
|
||||
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.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.sprites.SpriteChooser;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
public class JSONCreationWizard extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = -5744628699021314026L;
|
||||
@@ -298,12 +318,10 @@ public class JSONCreationWizard extends JDialog {
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
updateStatus();
|
||||
|
||||
@@ -1,22 +1,9 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
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.model.gamedata.*;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import java.awt.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
@@ -26,11 +13,50 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.ListDataListener;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
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.model.gamedata.ActorCondition;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Droplist;
|
||||
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.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
public class JSONImportWizard extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = 661234868711700156L;
|
||||
@@ -129,12 +155,10 @@ public class JSONImportWizard extends JDialog {
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
checkEnableNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
checkEnableNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
checkEnableNext();
|
||||
@@ -146,7 +170,6 @@ public class JSONImportWizard extends JDialog {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser jfc = new JFileChooser(){
|
||||
private static final long serialVersionUID = -3001082967957619011L;
|
||||
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
if (f.isDirectory() || f.getName().endsWith(".json") || f.getName().endsWith(".JSON")) {
|
||||
@@ -193,6 +216,8 @@ public class JSONImportWizard extends JDialog {
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS, 6));
|
||||
buttonPane.add(new JPanel(), JideBoxLayout.VARY);
|
||||
@@ -267,8 +292,8 @@ public class JSONImportWizard extends JDialog {
|
||||
errors.add("Invalid JSON content: neither an array nor an object.");
|
||||
}
|
||||
if (jsonObjects != null) {
|
||||
JSONElement node;
|
||||
JSONElement existingNode;
|
||||
JSONElement node = null;
|
||||
JSONElement existingNode = null;
|
||||
int i = 0;
|
||||
for (Map jsonObject : jsonObjects) {
|
||||
switch ((DataType)dataTypeCombo.getSelectedItem()) {
|
||||
@@ -316,7 +341,9 @@ public class JSONImportWizard extends JDialog {
|
||||
node.jsonFile = existingNode.jsonFile;
|
||||
warnings.add("An item with id "+node.id+" exists in the used game source. This one will be inserted as \"altered\"");
|
||||
}
|
||||
existingNode = null;
|
||||
}
|
||||
node = null;
|
||||
} else {
|
||||
warnings.add("Failed to load element #"+i);
|
||||
}
|
||||
@@ -480,7 +507,7 @@ public class JSONImportWizard extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = 6819681566800482793L;
|
||||
|
||||
private boolean includeType;
|
||||
private boolean includeType = false;
|
||||
|
||||
public GDERenderer(boolean includeType) {
|
||||
super();
|
||||
@@ -532,7 +559,6 @@ public class JSONImportWizard extends JDialog {
|
||||
|
||||
public static class ErrorRenderer extends DefaultListCellRenderer {
|
||||
private static final long serialVersionUID = -4265342800284721660L;
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
@@ -546,7 +572,6 @@ public class JSONImportWizard extends JDialog {
|
||||
|
||||
public static class WarningRenderer extends DefaultListCellRenderer {
|
||||
private static final long serialVersionUID = -3836045237946111606L;
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
@@ -558,7 +583,7 @@ public class JSONImportWizard extends JDialog {
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static class GDEListModel implements ListenerCollectionModel {
|
||||
public static class GDEListModel implements ListModel {
|
||||
|
||||
List<? extends Object> source;
|
||||
|
||||
@@ -567,15 +592,35 @@ public class JSONImportWizard extends JDialog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection getElements() {
|
||||
return source;
|
||||
public int getSize() {
|
||||
return source.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
for (Object obj : source) {
|
||||
if (index == 0) return obj;
|
||||
index --;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ListDataListener> listeners = new CopyOnWriteArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
public void fireListChanged() {
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, this.getSize()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface ListenerCollectionModel<E> extends ListenerListModel<E> {
|
||||
public Collection<E> getElements();
|
||||
|
||||
@Override
|
||||
default int getSize() {
|
||||
Collection<E> elements = getElements();
|
||||
if (elements == null) return 0;
|
||||
return elements.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
default E getElementAt(int index) {
|
||||
for (E obj : getElements()) {
|
||||
if (index == 0) return obj;
|
||||
index--;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import java.util.List;
|
||||
|
||||
public interface ListenerListModel<E> extends ListModel<E> {
|
||||
List<ListDataListener> getListeners();
|
||||
|
||||
default void notifyListeners(ChangeType event, int index0, int index1) {
|
||||
notifyListeners(this, event, index0, index1);
|
||||
}
|
||||
|
||||
default void notifyListeners(Object source, ChangeType event, int index0, int index1) {
|
||||
int eventCode;
|
||||
switch (event) {
|
||||
case CHANGED:
|
||||
eventCode = ListDataEvent.CONTENTS_CHANGED;
|
||||
break;
|
||||
case ADDED:
|
||||
eventCode = ListDataEvent.INTERVAL_ADDED;
|
||||
break;
|
||||
case REMOVED:
|
||||
eventCode = ListDataEvent.INTERVAL_REMOVED;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
for (ListDataListener l : getListeners()) {
|
||||
ListDataEvent e = new ListDataEvent(source, eventCode, index0, index1);
|
||||
switch (event) {
|
||||
case CHANGED: {
|
||||
l.contentsChanged(e);
|
||||
break;
|
||||
}
|
||||
case ADDED: {
|
||||
l.intervalAdded(e);
|
||||
break;
|
||||
}
|
||||
case REMOVED: {
|
||||
l.intervalRemoved(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default void addListDataListener(ListDataListener l) {
|
||||
getListeners().add(l);
|
||||
}
|
||||
|
||||
default void removeListDataListener(ListDataListener l) {
|
||||
getListeners().remove(l);
|
||||
}
|
||||
|
||||
default void fireListChanged() {
|
||||
notifyListeners(this, ChangeType.CHANGED, 0, getSize() - 1);
|
||||
}
|
||||
|
||||
enum ChangeType {
|
||||
CHANGED,
|
||||
ADDED,
|
||||
REMOVED,
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,27 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.NotificationListener;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Font;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.ListCellRenderer;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.ListDataListener;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
import com.gpl.rpg.atcontentstudio.NotificationListener;
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class NotificationsPane extends JList {
|
||||
@@ -54,18 +64,13 @@ public class NotificationsPane extends JList {
|
||||
}
|
||||
|
||||
|
||||
private class MyListModel implements ListenerListModel<Notification>, NotificationListener {
|
||||
private class MyListModel implements ListModel, NotificationListener {
|
||||
|
||||
@Override
|
||||
public Notification getElementAt(int index) {
|
||||
public Object getElementAt(int index) {
|
||||
return Notification.notifs.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return Notification.notifs.size();
|
||||
@@ -73,15 +78,28 @@ public class NotificationsPane extends JList {
|
||||
|
||||
@Override
|
||||
public void onNewNotification(Notification n) {
|
||||
notifyListeners(NotificationsPane.this, ChangeType.ADDED, Notification.notifs.size() - 1, Notification.notifs.size() - 1);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalAdded(new ListDataEvent(NotificationsPane.this, ListDataEvent.INTERVAL_ADDED, Notification.notifs.size() - 1 , Notification.notifs.size() - 1));
|
||||
}
|
||||
NotificationsPane.this.ensureIndexIsVisible(Notification.notifs.indexOf(n));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListCleared(int i) {
|
||||
notifyListeners(NotificationsPane.this, ChangeType.REMOVED, 0, i);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalRemoved(new ListDataEvent(NotificationsPane.this, ListDataEvent.INTERVAL_REMOVED, 0 , i));
|
||||
}
|
||||
}
|
||||
|
||||
private List<ListDataListener> listeners = new CopyOnWriteArrayList<ListDataListener>();
|
||||
@Override
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import javax.swing.event.ListDataListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public abstract class OrderedListenerListModel<S, E> implements ListenerCollectionModel<E> {
|
||||
protected S source;
|
||||
|
||||
protected abstract List<E> getItems();
|
||||
|
||||
protected abstract void setItems(List<E> items);
|
||||
|
||||
public OrderedListenerListModel(S source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<E> getElements() {
|
||||
return getItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E getElementAt(int index) {
|
||||
if (index < 0 || index >= getSize()) return null;
|
||||
return getItems().get(index);
|
||||
}
|
||||
|
||||
public E setElementAt(int index, E value) {
|
||||
if (index < 0 || index >= getSize()) return null;
|
||||
return getItems().set(index, value);
|
||||
}
|
||||
|
||||
public void addObject(E item) {
|
||||
addItem(item);
|
||||
}
|
||||
|
||||
public void addItem(E item) {
|
||||
if (getItems() == null) {
|
||||
setItems(new ArrayList<E>());
|
||||
}
|
||||
getItems().add(item);
|
||||
int index = getItems().indexOf(item);
|
||||
notifyListeners(ChangeType.ADDED, index, index);
|
||||
}
|
||||
|
||||
public void removeObject(E item) {
|
||||
removeItem(item);
|
||||
}
|
||||
|
||||
public void removeItem(E item) {
|
||||
int index = getItems().indexOf(item);
|
||||
getItems().remove(item);
|
||||
if (getSize() == 0) {
|
||||
setItems(null);
|
||||
}
|
||||
notifyListeners(this, ChangeType.REMOVED, index, index);
|
||||
}
|
||||
|
||||
|
||||
public void moveUp(E item) {
|
||||
moveUpOrDown(item, -1);
|
||||
}
|
||||
|
||||
public void moveDown(E item) {
|
||||
moveUpOrDown(item, 1);
|
||||
}
|
||||
|
||||
private void moveUpOrDown(E item, int direction) {
|
||||
int index = getItems().indexOf(item);
|
||||
E exchanged = getElementAt(index + direction);
|
||||
setElementAt(index, exchanged);
|
||||
setElementAt(index + direction, item);
|
||||
notifyListeners(this, ChangeType.CHANGED, index + direction, index);
|
||||
}
|
||||
|
||||
public void objectChanged(E item) {
|
||||
itemChanged(item);
|
||||
}
|
||||
|
||||
public void itemChanged(E item) {
|
||||
int index = getItems().indexOf(item);
|
||||
notifyListeners(this, ChangeType.CHANGED, index, index);
|
||||
}
|
||||
|
||||
private final List<ListDataListener> listeners = new CopyOnWriteArrayList<ListDataListener>();
|
||||
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
public class OverlayIcon implements Icon {
|
||||
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListCellRenderer;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.event.ListDataListener;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project.ResourceSet;
|
||||
@@ -8,18 +34,6 @@ import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.SpriteSheetSet;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class ProjectCreationWizard extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = -2854969975146867119L;
|
||||
@@ -104,12 +118,10 @@ public class ProjectCreationWizard extends JDialog {
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
updateOkButtonEnablement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
updateOkButtonEnablement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
updateOkButtonEnablement();
|
||||
@@ -222,6 +234,8 @@ public class ProjectCreationWizard extends JDialog {
|
||||
buttonPane.setLayout(new GridBagLayout());
|
||||
GridBagConstraints c2 = new GridBagConstraints();
|
||||
c2.fill = GridBagConstraints.HORIZONTAL;
|
||||
c2.gridx = 1;
|
||||
c2.weightx = 80;
|
||||
|
||||
c2.gridx = 1;
|
||||
c2.weightx = 80;
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
import com.gpl.rpg.atcontentstudio.model.bookmarks.BookmarkEntry;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.JSONElement;
|
||||
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.model.tools.writermode.WriterModeData;
|
||||
import com.jidesoft.swing.TreeSearchable;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
@@ -20,11 +28,19 @@ import javax.swing.tree.DefaultTreeCellRenderer;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import com.gpl.rpg.andorstrainer.AndorsTrainer;
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
import com.gpl.rpg.atcontentstudio.model.bookmarks.BookmarkEntry;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.JSONElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
|
||||
import com.gpl.rpg.atcontentstudio.model.saves.SavedGame;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeData;
|
||||
import com.jidesoft.swing.TreeSearchable;
|
||||
|
||||
public class ProjectsTree extends JPanel {
|
||||
|
||||
@@ -34,6 +50,12 @@ public class ProjectsTree extends JPanel {
|
||||
|
||||
private JPopupMenu popupMenu;
|
||||
|
||||
private Thread konamiTimeout = null;
|
||||
private boolean exit = false;
|
||||
private int timeout = 200;
|
||||
private Integer[] konamiBuffer = new Integer[]{null, null, null, null, null, null, null, null, null, null};
|
||||
private boolean konamiCodeEntered = false;
|
||||
|
||||
public ProjectsTree() {
|
||||
super();
|
||||
setLayout(new BorderLayout());
|
||||
@@ -60,6 +82,22 @@ public class ProjectsTree extends JPanel {
|
||||
if (projectsTree.getSelectionPath() != null) {
|
||||
itemAction((ProjectTreeNode) projectsTree.getSelectionPath().getLastPathComponent());
|
||||
}
|
||||
} else {
|
||||
if (konamiTimeout == null) {
|
||||
startKonamiCount();
|
||||
}
|
||||
int i = 0;
|
||||
while (i < konamiBuffer.length && konamiBuffer[i] != null) {
|
||||
i++;
|
||||
}
|
||||
if (i < konamiBuffer.length) {
|
||||
konamiBuffer[i] = e.getKeyCode();
|
||||
if (!compareBuffers()) {
|
||||
exit = true;
|
||||
} else {
|
||||
resetTimeout();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -174,6 +212,10 @@ public class ProjectsTree extends JPanel {
|
||||
addNextSeparator = true;
|
||||
popupMenu.add(new JMenuItem(actions.createWorldmap));
|
||||
}
|
||||
if (actions.loadSave.isEnabled()) {
|
||||
addNextSeparator = true;
|
||||
popupMenu.add(new JMenuItem(actions.loadSave));
|
||||
}
|
||||
if (addNextSeparator) {
|
||||
popupMenu.add(new JSeparator());
|
||||
addNextSeparator = false;
|
||||
@@ -217,6 +259,311 @@ public class ProjectsTree extends JPanel {
|
||||
popupMenu.add(new JSeparator());
|
||||
addNextSeparator = false;
|
||||
}
|
||||
|
||||
if (konamiCodeEntered) {
|
||||
JMenuItem openTrainer = new JMenuItem("Start Andor's Trainer...");
|
||||
popupMenu.add(openTrainer);
|
||||
popupMenu.addSeparator();
|
||||
openTrainer.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Thread() {
|
||||
public void run() {
|
||||
AndorsTrainer.startApp(false);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// if (projectsTree.getSelectionPath() == null || projectsTree.getSelectionPath().getLastPathComponent() == null) {
|
||||
// JMenuItem addProject = new JMenuItem("Create project...");
|
||||
// popupMenu.add(addProject);
|
||||
// addProject.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// new ProjectCreationWizard().setVisible(true);
|
||||
// }
|
||||
// });
|
||||
// popupMenu.addSeparator();
|
||||
// } else if (projectsTree.getSelectionPaths().length > 1) {
|
||||
// boolean deleteAll = false;
|
||||
// final List<GameDataElement> elementsToDelete = new ArrayList<GameDataElement>();
|
||||
// for (TreePath selected : projectsTree.getSelectionPaths()) {
|
||||
// if (selected.getLastPathComponent() instanceof GameDataElement && ((GameDataElement)selected.getLastPathComponent()).writable) {
|
||||
// elementsToDelete.add((GameDataElement) selected.getLastPathComponent());
|
||||
// deleteAll = true;
|
||||
// } else {
|
||||
// deleteAll = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (deleteAll) {
|
||||
// JMenuItem deleteItems = new JMenuItem("Delete all selected elements");
|
||||
// popupMenu.add(deleteItems);
|
||||
// deleteItems.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// final Map<GameDataCategory<JSONElement>, Set<File>> impactedCategories = new IdentityHashMap<GameDataCategory<JSONElement>, Set<File>>();
|
||||
// for (GameDataElement element : elementsToDelete) {
|
||||
// ATContentStudio.frame.closeEditor(element);
|
||||
// element.childrenRemoved(new ArrayList<ProjectTreeNode>());
|
||||
// if (element instanceof JSONElement) {
|
||||
// @SuppressWarnings("unchecked")
|
||||
// GameDataCategory<JSONElement> category = (GameDataCategory<JSONElement>) element.getParent();
|
||||
// category.remove(element);
|
||||
// if (impactedCategories.get(category) == null) {
|
||||
// impactedCategories.put(category, new HashSet<File>());
|
||||
// }
|
||||
// impactedCategories.get(category).add(((JSONElement) element).jsonFile);
|
||||
// } else if (element instanceof TMXMap) {
|
||||
// TMXMapSet parent = (TMXMapSet) element.getParent();
|
||||
// parent.tmxMaps.remove(element);
|
||||
// }
|
||||
// }
|
||||
// new Thread() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// final List<SaveEvent> events = new ArrayList<SaveEvent>();
|
||||
// List<SaveEvent> catEvents = null;
|
||||
// for (GameDataCategory<JSONElement> category : impactedCategories.keySet()) {
|
||||
// for (File f : impactedCategories.get(category)) {
|
||||
// catEvents = category.attemptSave(true, f.getName());
|
||||
// if (catEvents.isEmpty()) {
|
||||
// category.save(f);
|
||||
// } else {
|
||||
// events.addAll(catEvents);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (!events.isEmpty()) {
|
||||
// new SaveItemsWizard(events, null).setVisible(true);
|
||||
// }
|
||||
// }
|
||||
// }.start();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// popupMenu.addSeparator();
|
||||
// } else {
|
||||
// final ProjectTreeNode selected = (ProjectTreeNode) projectsTree.getSelectionPath().getLastPathComponent();
|
||||
// if (selected instanceof Project) {
|
||||
// JMenuItem closeProject = new JMenuItem("Close Project...");
|
||||
// JMenuItem deleteProject = new JMenuItem("Delete Project...");
|
||||
// popupMenu.add(closeProject);
|
||||
// popupMenu.add(deleteProject);
|
||||
// popupMenu.addSeparator();
|
||||
// closeProject.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// Workspace.closeProject((Project) selected);
|
||||
// }
|
||||
// });
|
||||
// deleteProject.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// int confirm = JOptionPane.showConfirmDialog(ProjectsTree.this, "Are you sure you wish to delete this project ?\nAll files created for it will be deleted too...", "Delete this project ?", JOptionPane.OK_CANCEL_OPTION);
|
||||
// if (confirm == JOptionPane.OK_OPTION) {
|
||||
// Workspace.deleteProject(((Project)projectsTree.getSelectionPath().getLastPathComponent()));
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// if (selected instanceof ClosedProject) {
|
||||
// JMenuItem openProject = new JMenuItem("Open Project...");
|
||||
// JMenuItem deleteProject = new JMenuItem("Delete Project...");
|
||||
// popupMenu.add(openProject);
|
||||
// popupMenu.add(deleteProject);
|
||||
// popupMenu.addSeparator();
|
||||
// openProject.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// Workspace.openProject(((ClosedProject)selected));
|
||||
// }
|
||||
// });
|
||||
// deleteProject.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// int confirm = JOptionPane.showConfirmDialog(ProjectsTree.this, "Are you sure you wish to delete this project ?\nAll files created for it will be deleted too...", "Delete this project ?", JOptionPane.OK_CANCEL_OPTION);
|
||||
// if (confirm == JOptionPane.OK_OPTION) {
|
||||
// Workspace.deleteProject(((ClosedProject)selected));
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// if (selected.getProject() != null) {
|
||||
// final Project proj = ((ProjectTreeNode)selected).getProject();
|
||||
// JMenuItem createGDE = new JMenuItem("Create Game Data Element (JSON)");
|
||||
// popupMenu.add(createGDE);
|
||||
// createGDE.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// new JSONCreationWizard(proj).setVisible(true);
|
||||
// }
|
||||
// });
|
||||
// JMenuItem importJson = new JMenuItem("Import JSON data");
|
||||
// popupMenu.add(importJson);
|
||||
// importJson.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// new JSONImportWizard(proj).setVisible(true);
|
||||
// }
|
||||
// });
|
||||
// //TODO move somewhere else
|
||||
// JMenu compareElementsMenu = new JMenu("Open comparator for...");
|
||||
// JMenuItem compareItems = new JMenuItem("Items");
|
||||
// compareElementsMenu.add(compareItems);
|
||||
// compareItems.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// ATContentStudio.frame.editors.openEditor(new ItemsTableView(selected.getProject()));
|
||||
// }
|
||||
// });
|
||||
// JMenuItem compareNPCs = new JMenuItem("NPCs");
|
||||
// compareElementsMenu.add(compareNPCs);
|
||||
// compareNPCs.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// ATContentStudio.frame.editors.openEditor(new NPCsTableView(selected.getProject()));
|
||||
// }
|
||||
// });
|
||||
// popupMenu.add(compareElementsMenu);
|
||||
//
|
||||
// JMenuItem exportProjectPackage = new JMenuItem("Export project");
|
||||
// exportProjectPackage.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// JFileChooser chooser = new JFileChooser() {
|
||||
// private static final long serialVersionUID = 8039332384370636746L;
|
||||
// public boolean accept(File f) {
|
||||
// return f.isDirectory() || f.getName().endsWith(".zip") || f.getName().endsWith(".ZIP");
|
||||
// }
|
||||
// };
|
||||
// chooser.setMultiSelectionEnabled(false);
|
||||
// int result = chooser.showSaveDialog(ATContentStudio.frame);
|
||||
// if (result == JFileChooser.APPROVE_OPTION) {
|
||||
// selected.getProject().generateExportPackage(chooser.getSelectedFile());
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// popupMenu.add(exportProjectPackage);
|
||||
// popupMenu.addSeparator();
|
||||
// }
|
||||
// if (selected instanceof GameDataElement) {
|
||||
// final GameDataElement node = ((GameDataElement)selected);
|
||||
// if (node.state == GameDataElement.State.modified){
|
||||
// JMenuItem saveItem = new JMenuItem("Save this element");
|
||||
// saveItem.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// node.save();
|
||||
// ATContentStudio.frame.nodeChanged(node);
|
||||
// }
|
||||
// });
|
||||
// popupMenu.add(saveItem);
|
||||
// }
|
||||
//
|
||||
// JMenuItem deleteItem = null;
|
||||
// if (node.getDataType() == GameSource.Type.created) {
|
||||
// deleteItem = new JMenuItem("Delete this element");
|
||||
// } else if (node.getDataType() == GameSource.Type.altered) {
|
||||
// deleteItem = new JMenuItem("Revert to original");
|
||||
// }
|
||||
// if (deleteItem != null) {
|
||||
// popupMenu.add(deleteItem);
|
||||
// deleteItem.addActionListener(new ActionListener() {
|
||||
// @SuppressWarnings("unchecked")
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// ATContentStudio.frame.closeEditor(node);
|
||||
// new Thread() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// node.childrenRemoved(new ArrayList<ProjectTreeNode>());
|
||||
// if (node.getParent() instanceof GameDataCategory<?>) {
|
||||
// ((GameDataCategory<?>)node.getParent()).remove(node);
|
||||
// List<SaveEvent> events = node.attemptSave();
|
||||
// if (events == null || events.isEmpty()) {
|
||||
// node.save();
|
||||
// } else {
|
||||
// new SaveItemsWizard(events, null).setVisible(true);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }.start();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// popupMenu.addSeparator();
|
||||
//
|
||||
// }
|
||||
// if (selected instanceof Project || selected instanceof SavedGamesSet) {
|
||||
// JMenuItem addSave = new JMenuItem("Load saved game...");
|
||||
// popupMenu.add(addSave);
|
||||
// popupMenu.addSeparator();
|
||||
// addSave.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// JFileChooser chooser = new JFileChooser("Select an Andor's Trail save file");
|
||||
// if (chooser.showOpenDialog(ATContentStudio.frame) == JFileChooser.APPROVE_OPTION) {
|
||||
// selected.getProject().addSave(chooser.getSelectedFile());
|
||||
// selected.getProject().save();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// if (konamiCodeEntered) {
|
||||
// JMenuItem openTrainer = new JMenuItem("Start Andor's Trainer...");
|
||||
// popupMenu.add(openTrainer);
|
||||
// popupMenu.addSeparator();
|
||||
// openTrainer.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// new Thread() {
|
||||
// public void run() {
|
||||
// AndorsTrainer.startApp(false);
|
||||
// }
|
||||
// }.start();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// JMenu changeLaF = new JMenu("Change Look and Feel");
|
||||
// for (final LookAndFeelInfo i : UIManager.getInstalledLookAndFeels()) {
|
||||
// final JMenuItem lafItem = new JMenuItem("Switch to "+i.getName());
|
||||
// changeLaF.add(lafItem);
|
||||
// lafItem.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// try {
|
||||
// UIManager.setLookAndFeel(i.getClassName());
|
||||
// SwingUtilities.updateComponentTreeUI(ATContentStudio.frame);
|
||||
// ConfigCache.setFavoriteLaFClassName(i.getClassName());
|
||||
// } catch (ClassNotFoundException e1) {
|
||||
// e1.printStackTrace();
|
||||
// } catch (InstantiationException e1) {
|
||||
// e1.printStackTrace();
|
||||
// } catch (IllegalAccessException e1) {
|
||||
// e1.printStackTrace();
|
||||
// } catch (UnsupportedLookAndFeelException e1) {
|
||||
// e1.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// popupMenu.add(changeLaF);
|
||||
// popupMenu.addSeparator();
|
||||
// JMenuItem showAbout = new JMenuItem("About...");
|
||||
// popupMenu.add(showAbout);
|
||||
// popupMenu.addSeparator();
|
||||
// showAbout.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// ATContentStudio.frame.showAbout();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
public void popupActivated(MouseEvent e) {
|
||||
@@ -251,6 +598,10 @@ public class ProjectsTree extends JPanel {
|
||||
ATContentStudio.frame.openEditor((WriterModeData)node);
|
||||
} else if (node instanceof BookmarkEntry) {
|
||||
ATContentStudio.frame.openEditor(((BookmarkEntry)node).bookmarkedElement);
|
||||
} else if (node instanceof SavedGame) {
|
||||
if (konamiCodeEntered) {
|
||||
ATContentStudio.frame.openEditor((SavedGame)node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,25 +638,19 @@ public class ProjectsTree extends JPanel {
|
||||
|
||||
public void insertNode(TreePath node) {
|
||||
for (TreeModelListener l : listeners) {
|
||||
l.treeNodesInserted(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath().getPath(),
|
||||
new int[]{((ProjectTreeNode) node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode) node.getLastPathComponent())},
|
||||
new Object[]{node.getLastPathComponent()}));
|
||||
l.treeNodesInserted(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath().getPath(), new int[]{((ProjectTreeNode)node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode)node.getLastPathComponent())}, new Object[]{node.getLastPathComponent()} ));
|
||||
}
|
||||
}
|
||||
|
||||
public void changeNode(TreePath node) {
|
||||
for (TreeModelListener l : listeners) {
|
||||
l.treeNodesChanged(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath(),
|
||||
new int[]{((ProjectTreeNode) node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode) node.getLastPathComponent())},
|
||||
new Object[]{node.getLastPathComponent()}));
|
||||
l.treeNodesChanged(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath(), new int[]{((ProjectTreeNode)node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode)node.getLastPathComponent())}, new Object[]{node.getLastPathComponent()} ));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeNode(TreePath node) {
|
||||
for (TreeModelListener l : listeners) {
|
||||
l.treeNodesRemoved(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath(),
|
||||
new int[]{((ProjectTreeNode) node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode) node.getLastPathComponent())},
|
||||
new Object[]{node.getLastPathComponent()}));
|
||||
l.treeNodesRemoved(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath(), new int[]{((ProjectTreeNode)node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode)node.getLastPathComponent())}, new Object[]{node.getLastPathComponent()} ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +685,7 @@ public class ProjectsTree extends JPanel {
|
||||
JLabel label = (JLabel)c;
|
||||
String text = ((ProjectTreeNode)value).getDesc();
|
||||
if (text != null) label.setText(text);
|
||||
Image img;
|
||||
Image img = null;
|
||||
if (leaf) img = ((ProjectTreeNode)value).getLeafIcon();
|
||||
else if (expanded) img = ((ProjectTreeNode)value).getOpenIcon();
|
||||
else img = ((ProjectTreeNode)value).getClosedIcon();
|
||||
@@ -367,4 +712,64 @@ public class ProjectsTree extends JPanel {
|
||||
projectsTree.scrollPathToVisible(tp);
|
||||
}
|
||||
|
||||
protected void startKonamiCount() {
|
||||
resetTimeout();
|
||||
exit = false;
|
||||
konamiTimeout = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (!exit && timeout > 0) {
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {}
|
||||
timeout -= 10;
|
||||
}
|
||||
konamiTimeout = null;
|
||||
konamiBuffer = new Integer[]{null, null, null, null, null, null, null, null, null, null};
|
||||
}
|
||||
};
|
||||
konamiTimeout.start();
|
||||
}
|
||||
|
||||
protected void resetTimeout() {
|
||||
timeout = 400;
|
||||
}
|
||||
|
||||
protected boolean compareBuffers() {
|
||||
if (konamiBuffer[0] == null) return true;
|
||||
else if (konamiBuffer[0] != KeyEvent.VK_UP) return false;
|
||||
|
||||
if (konamiBuffer[1] == null) return true;
|
||||
else if (konamiBuffer[1] != KeyEvent.VK_UP) return false;
|
||||
|
||||
if (konamiBuffer[2] == null) return true;
|
||||
else if (konamiBuffer[2] != KeyEvent.VK_DOWN) return false;
|
||||
|
||||
if (konamiBuffer[3] == null) return true;
|
||||
else if (konamiBuffer[3] != KeyEvent.VK_DOWN) return false;
|
||||
|
||||
if (konamiBuffer[4] == null) return true;
|
||||
else if (konamiBuffer[4] != KeyEvent.VK_LEFT) return false;
|
||||
|
||||
if (konamiBuffer[5] == null) return true;
|
||||
else if (konamiBuffer[5] != KeyEvent.VK_RIGHT) return false;
|
||||
|
||||
if (konamiBuffer[6] == null) return true;
|
||||
else if (konamiBuffer[6] != KeyEvent.VK_LEFT) return false;
|
||||
|
||||
if (konamiBuffer[7] == null) return true;
|
||||
else if (konamiBuffer[7] != KeyEvent.VK_RIGHT) return false;
|
||||
|
||||
if (konamiBuffer[8] == null) return true;
|
||||
else if (konamiBuffer[8] != KeyEvent.VK_B) return false;
|
||||
|
||||
if (konamiBuffer[9] == null) return true;
|
||||
else if (konamiBuffer[9] != KeyEvent.VK_A) return false;
|
||||
|
||||
konamiCodeEntered = true;
|
||||
|
||||
exit = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
||||
@@ -7,14 +29,6 @@ import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataCategory;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.JSONElement;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class SaveItemsWizard extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = -3301878024575930527L;
|
||||
@@ -163,7 +177,7 @@ public class SaveItemsWizard extends JDialog {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
Map<GameDataCategory<JSONElement>, Set<File>> jsonToSave = new IdentityHashMap<>();
|
||||
Map<GameDataCategory<JSONElement>, Set<File>> jsonToSave = new IdentityHashMap<GameDataCategory<JSONElement>, Set<File>>();
|
||||
for (SaveEvent event : movedToCreatedList) {
|
||||
if (event.target instanceof JSONElement) {
|
||||
if (!jsonToSave.containsKey(event.target.getParent())){
|
||||
|
||||
@@ -1,21 +1,30 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.LayoutManager;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.Scrollable;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
public class ScrollablePanel extends JPanel implements Scrollable, SwingConstants {
|
||||
|
||||
private static final long serialVersionUID = 6498229143202972325L;
|
||||
|
||||
public enum ScrollableSizeHint {
|
||||
public enum ScrollableSizeHint
|
||||
{
|
||||
NONE,
|
||||
FIT,
|
||||
STRETCH
|
||||
STRETCH;
|
||||
}
|
||||
|
||||
public enum IncrementType {
|
||||
public enum IncrementType
|
||||
{
|
||||
PERCENT,
|
||||
PIXELS
|
||||
PIXELS;
|
||||
}
|
||||
|
||||
private ScrollableSizeHint scrollableHeight = ScrollableSizeHint.NONE;
|
||||
@@ -29,7 +38,8 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
/**
|
||||
* Default constructor that uses a FlowLayout
|
||||
*/
|
||||
public ScrollablePanel() {
|
||||
public ScrollablePanel()
|
||||
{
|
||||
this( new FlowLayout() );
|
||||
}
|
||||
|
||||
@@ -38,7 +48,8 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
*
|
||||
* @param layout the LayountManger for the panel
|
||||
*/
|
||||
public ScrollablePanel(LayoutManager layout) {
|
||||
public ScrollablePanel(LayoutManager layout)
|
||||
{
|
||||
super( layout );
|
||||
|
||||
IncrementInfo block = new IncrementInfo(IncrementType.PERCENT, 100);
|
||||
@@ -55,7 +66,8 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
*
|
||||
* @return the ScrollableSizeHint enum for the height
|
||||
*/
|
||||
public ScrollableSizeHint getScrollableHeight() {
|
||||
public ScrollableSizeHint getScrollableHeight()
|
||||
{
|
||||
return scrollableHeight;
|
||||
}
|
||||
|
||||
@@ -63,7 +75,7 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
* Set the ScrollableSizeHint enum for the height. The enum is used to
|
||||
* determine the boolean value that is returned by the
|
||||
* getScrollableTracksViewportHeight() method. The valid values are:
|
||||
* <p>
|
||||
*
|
||||
* ScrollableSizeHint.NONE - return "false", which causes the height
|
||||
* of the panel to be used when laying out the children
|
||||
* ScrollableSizeHint.FIT - return "true", which causes the height of
|
||||
@@ -73,7 +85,8 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
*
|
||||
* @param scrollableHeight as represented by the ScrollableSizeHint enum.
|
||||
*/
|
||||
public void setScrollableHeight(ScrollableSizeHint scrollableHeight) {
|
||||
public void setScrollableHeight(ScrollableSizeHint scrollableHeight)
|
||||
{
|
||||
this.scrollableHeight = scrollableHeight;
|
||||
revalidate();
|
||||
}
|
||||
@@ -83,7 +96,8 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
*
|
||||
* @return the ScrollableSizeHint enum for the width
|
||||
*/
|
||||
public ScrollableSizeHint getScrollableWidth() {
|
||||
public ScrollableSizeHint getScrollableWidth()
|
||||
{
|
||||
return scrollableWidth;
|
||||
}
|
||||
|
||||
@@ -91,7 +105,7 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
* Set the ScrollableSizeHint enum for the width. The enum is used to
|
||||
* determine the boolean value that is returned by the
|
||||
* getScrollableTracksViewportWidth() method. The valid values are:
|
||||
* <p>
|
||||
*
|
||||
* ScrollableSizeHint.NONE - return "false", which causes the width
|
||||
* of the panel to be used when laying out the children
|
||||
* ScrollableSizeHint.FIT - return "true", which causes the width of
|
||||
@@ -101,7 +115,8 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
*
|
||||
* @param scrollableWidth as represented by the ScrollableSizeHint enum.
|
||||
*/
|
||||
public void setScrollableWidth(ScrollableSizeHint scrollableWidth) {
|
||||
public void setScrollableWidth(ScrollableSizeHint scrollableWidth)
|
||||
{
|
||||
this.scrollableWidth = scrollableWidth;
|
||||
revalidate();
|
||||
}
|
||||
@@ -111,7 +126,8 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
*
|
||||
* @return the block IncrementInfo for the specified orientation
|
||||
*/
|
||||
public IncrementInfo getScrollableBlockIncrement(int orientation) {
|
||||
public IncrementInfo getScrollableBlockIncrement(int orientation)
|
||||
{
|
||||
return orientation == SwingConstants.HORIZONTAL ? horizontalBlock : verticalBlock;
|
||||
}
|
||||
|
||||
@@ -120,14 +136,15 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
*
|
||||
* @param orientation specify the scrolling orientation. Must be either:
|
||||
* SwingContants.HORIZONTAL or SwingContants.VERTICAL.
|
||||
* @param amount a value used with the IncrementType to determine the
|
||||
* scrollable amount
|
||||
* @paran type specify how the amount parameter in the calculation of
|
||||
* the scrollable amount. Valid values are:
|
||||
* IncrementType.PERCENT - treat the amount as a % of the viewport size
|
||||
* IncrementType.PIXEL - treat the amount as the scrollable amount
|
||||
* @param amount a value used with the IncrementType to determine the
|
||||
* scrollable amount
|
||||
*/
|
||||
public void setScrollableBlockIncrement(int orientation, IncrementType type, int amount) {
|
||||
public void setScrollableBlockIncrement(int orientation, IncrementType type, int amount)
|
||||
{
|
||||
IncrementInfo info = new IncrementInfo(type, amount);
|
||||
setScrollableBlockIncrement(orientation, info);
|
||||
}
|
||||
@@ -140,8 +157,10 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
* @param info An IncrementInfo object containing information of how to
|
||||
* calculate the scrollable amount.
|
||||
*/
|
||||
public void setScrollableBlockIncrement(int orientation, IncrementInfo info) {
|
||||
switch (orientation) {
|
||||
public void setScrollableBlockIncrement(int orientation, IncrementInfo info)
|
||||
{
|
||||
switch(orientation)
|
||||
{
|
||||
case SwingConstants.HORIZONTAL:
|
||||
horizontalBlock = info;
|
||||
break;
|
||||
@@ -158,7 +177,8 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
*
|
||||
* @return the unit IncrementInfo for the specified orientation
|
||||
*/
|
||||
public IncrementInfo getScrollableUnitIncrement(int orientation) {
|
||||
public IncrementInfo getScrollableUnitIncrement(int orientation)
|
||||
{
|
||||
return orientation == SwingConstants.HORIZONTAL ? horizontalUnit : verticalUnit;
|
||||
}
|
||||
|
||||
@@ -167,14 +187,15 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
*
|
||||
* @param orientation specify the scrolling orientation. Must be either:
|
||||
* SwingContants.HORIZONTAL or SwingContants.VERTICAL.
|
||||
* @param amount a value used with the IncrementType to determine the
|
||||
* scrollable amount
|
||||
* @paran type specify how the amount parameter in the calculation of
|
||||
* the scrollable amount. Valid values are:
|
||||
* IncrementType.PERCENT - treat the amount as a % of the viewport size
|
||||
* IncrementType.PIXEL - treat the amount as the scrollable amount
|
||||
* @param amount a value used with the IncrementType to determine the
|
||||
* scrollable amount
|
||||
*/
|
||||
public void setScrollableUnitIncrement(int orientation, IncrementType type, int amount) {
|
||||
public void setScrollableUnitIncrement(int orientation, IncrementType type, int amount)
|
||||
{
|
||||
IncrementInfo info = new IncrementInfo(type, amount);
|
||||
setScrollableUnitIncrement(orientation, info);
|
||||
}
|
||||
@@ -187,8 +208,10 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
* @param info An IncrementInfo object containing information of how to
|
||||
* calculate the scrollable amount.
|
||||
*/
|
||||
public void setScrollableUnitIncrement(int orientation, IncrementInfo info) {
|
||||
switch (orientation) {
|
||||
public void setScrollableUnitIncrement(int orientation, IncrementInfo info)
|
||||
{
|
||||
switch(orientation)
|
||||
{
|
||||
case SwingConstants.HORIZONTAL:
|
||||
horizontalUnit = info;
|
||||
break;
|
||||
@@ -202,13 +225,16 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
|
||||
//Implement Scrollable interface
|
||||
|
||||
public Dimension getPreferredScrollableViewportSize() {
|
||||
public Dimension getPreferredScrollableViewportSize()
|
||||
{
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
public int getScrollableUnitIncrement(
|
||||
Rectangle visible, int orientation, int direction) {
|
||||
switch (orientation) {
|
||||
Rectangle visible, int orientation, int direction)
|
||||
{
|
||||
switch(orientation)
|
||||
{
|
||||
case SwingConstants.HORIZONTAL:
|
||||
return getScrollableIncrement(horizontalUnit, visible.width);
|
||||
case SwingConstants.VERTICAL:
|
||||
@@ -219,8 +245,10 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
}
|
||||
|
||||
public int getScrollableBlockIncrement(
|
||||
Rectangle visible, int orientation, int direction) {
|
||||
switch (orientation) {
|
||||
Rectangle visible, int orientation, int direction)
|
||||
{
|
||||
switch(orientation)
|
||||
{
|
||||
case SwingConstants.HORIZONTAL:
|
||||
return getScrollableIncrement(horizontalBlock, visible.width);
|
||||
case SwingConstants.VERTICAL:
|
||||
@@ -230,14 +258,16 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
}
|
||||
}
|
||||
|
||||
protected int getScrollableIncrement(IncrementInfo info, int distance) {
|
||||
protected int getScrollableIncrement(IncrementInfo info, int distance)
|
||||
{
|
||||
if (info.getIncrement() == IncrementType.PIXELS)
|
||||
return info.getAmount();
|
||||
else
|
||||
return distance * info.getAmount() / 100;
|
||||
}
|
||||
|
||||
public boolean getScrollableTracksViewportWidth() {
|
||||
public boolean getScrollableTracksViewportWidth()
|
||||
{
|
||||
if (scrollableWidth == ScrollableSizeHint.NONE)
|
||||
return false;
|
||||
|
||||
@@ -246,14 +276,16 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
|
||||
// STRETCH sizing, use the greater of the panel or viewport width
|
||||
|
||||
if (getParent() instanceof JViewport) {
|
||||
if (getParent() instanceof JViewport)
|
||||
{
|
||||
return (((JViewport)getParent()).getWidth() > getPreferredSize().width);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getScrollableTracksViewportHeight() {
|
||||
public boolean getScrollableTracksViewportHeight()
|
||||
{
|
||||
if (scrollableHeight == ScrollableSizeHint.NONE)
|
||||
return false;
|
||||
|
||||
@@ -263,7 +295,8 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
// STRETCH sizing, use the greater of the panel or viewport height
|
||||
|
||||
|
||||
if (getParent() instanceof JViewport) {
|
||||
if (getParent() instanceof JViewport)
|
||||
{
|
||||
return (((JViewport)getParent()).getHeight() > getPreferredSize().height);
|
||||
}
|
||||
|
||||
@@ -273,24 +306,29 @@ public class ScrollablePanel extends JPanel implements Scrollable, SwingConstant
|
||||
/**
|
||||
* Helper class to hold the information required to calculate the scroll amount.
|
||||
*/
|
||||
static class IncrementInfo {
|
||||
static class IncrementInfo
|
||||
{
|
||||
private IncrementType type;
|
||||
private int amount;
|
||||
|
||||
public IncrementInfo(IncrementType type, int amount) {
|
||||
public IncrementInfo(IncrementType type, int amount)
|
||||
{
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public IncrementType getIncrement() {
|
||||
public IncrementType getIncrement()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
public int getAmount()
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
return
|
||||
"ScrollablePanel[" +
|
||||
type + ", " +
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user