From 35d96a0f2be455861f50c2d3b03135b7cc3414bf Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Wed, 27 Oct 2021 10:35:09 +0000 Subject: [PATCH 01/11] add devcontainer boilerplate --- .classpath | 49 +++++ .devcontainer/Dockerfile | 35 ++++ .devcontainer/devcontainer.json | 37 ++++ .markdownlint.yaml | 15 ++ .pre-commit-config.yaml | 18 ++ .project | 34 ++++ .secrets.baseline | 197 +++++++++++++++++++++ .settings/org.eclipse.core.resources.prefs | 4 + .settings/org.eclipse.jdt.apt.core.prefs | 2 + .settings/org.eclipse.jdt.core.prefs | 9 + .settings/org.eclipse.m2e.core.prefs | 4 + README.md | 45 +++-- {img => assets}/screenshot01.png | Bin 13 files changed, 431 insertions(+), 18 deletions(-) create mode 100644 .classpath create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .markdownlint.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 .project create mode 100644 .secrets.baseline create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.apt.core.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs rename {img => assets}/screenshot01.png (100%) diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..8b73b29 --- /dev/null +++ b/.classpath @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..5f40bbd --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,35 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/java/.devcontainer/base.Dockerfile + +# [Choice] Java version: 11, 15 +ARG VARIANT="15" +FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT} + +# Install additional OS packages +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends \ + wixl \ + python3-pip + +# Install Maven +ARG MAVEN_VERSION="" +RUN su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\"" + +# Install Node.js +ARG NODE_VERSION="lts/*" +RUN su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1" + +# Install global node packages +RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g \ + markdownlint-cli \ + " 2>&1 + +# Install Python packages +RUN pip3 install \ + pre-commit==2.12.1 \ + detect-secrets==1.1.0 \ + setuptools==39.1.0 + +# Install launch4j +RUN curl -SOLJ https://sourceforge.net/projects/launch4j/files/launch4j-3/3.14/launch4j-3.14-linux-x64.tgz/download && \ + tar zxvf launch4j-3.14-linux-x64.tgz -C /usr/bin && \ + rm launch4j-3.14-linux-x64.tgz diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..940b0c9 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,37 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/java +{ + "name": "DuckDNSUpdater", + "build": { + "dockerfile": "Dockerfile", + "args": { + // Update the VARIANT arg to pick a Java version: 11, 15 + "VARIANT": "15", + // Options + "INSTALL_MAVEN": "true", + "INSTALL_NODE": "true", + "NODE_VERSION": "lts/*" + } + }, + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "java.home": "/docker-java-home" + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "vscjava.vscode-java-pack", + "vscjava.vscode-java-dependency", + "idleberg.innosetup", + "redhat.vscode-xml", + "redhat.fabric8-analytics", + "davidanson.vscode-markdownlint", + "redhat.vscode-yaml" + ], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "pre-commit install", + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..be0f9a9 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,15 @@ +--- +MD007: + indent: 4 +MD013: + line_length: 80 + tables: false +MD030: + ul_single: 3 + ol_single: 2 + ul_multi: 3 + ol_multi: 2 +MD033: + allowed_elements: + - pre + - br diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..358793c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/Yelp/detect-secrets + rev: v1.1.0 + hooks: + - id: detect-secrets + args: + - --baseline + - .secrets.baseline + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.27.1 + hooks: + - id: markdownlint diff --git a/.project b/.project new file mode 100644 index 0000000..c69d29c --- /dev/null +++ b/.project @@ -0,0 +1,34 @@ + + + ftl-mod-manager + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + + + 1635330454157 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/.secrets.baseline b/.secrets.baseline new file mode 100644 index 0000000..6c8f82e --- /dev/null +++ b/.secrets.baseline @@ -0,0 +1,197 @@ +{ + "version": "1.1.0", + "plugins_used": [ + { + "name": "ArtifactoryDetector" + }, + { + "name": "AWSKeyDetector" + }, + { + "name": "AzureStorageKeyDetector" + }, + { + "name": "Base64HighEntropyString", + "limit": 4.5 + }, + { + "name": "BasicAuthDetector" + }, + { + "name": "CloudantDetector" + }, + { + "name": "HexHighEntropyString", + "limit": 3.0 + }, + { + "name": "IbmCloudIamDetector" + }, + { + "name": "IbmCosHmacDetector" + }, + { + "name": "JwtTokenDetector" + }, + { + "name": "KeywordDetector", + "keyword_exclude": "" + }, + { + "name": "MailchimpDetector" + }, + { + "name": "NpmDetector" + }, + { + "name": "PrivateKeyDetector" + }, + { + "name": "SlackDetector" + }, + { + "name": "SoftlayerDetector" + }, + { + "name": "SquareOAuthDetector" + }, + { + "name": "StripeDetector" + }, + { + "name": "TwilioKeyDetector" + } + ], + "filters_used": [ + { + "path": "detect_secrets.filters.allowlist.is_line_allowlisted" + }, + { + "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies", + "min_level": 2 + }, + { + "path": "detect_secrets.filters.heuristic.is_indirect_reference" + }, + { + "path": "detect_secrets.filters.heuristic.is_likely_id_string" + }, + { + "path": "detect_secrets.filters.heuristic.is_lock_file" + }, + { + "path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string" + }, + { + "path": "detect_secrets.filters.heuristic.is_potential_uuid" + }, + { + "path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign" + }, + { + "path": "detect_secrets.filters.heuristic.is_sequential_string" + }, + { + "path": "detect_secrets.filters.heuristic.is_swagger_file" + }, + { + "path": "detect_secrets.filters.heuristic.is_templated_secret" + } + ], + "results": { + "skel_common/backup/current_catalog.json": [ + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "454b70be301a759838999c60c83ba9d32500a9ef", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "4caca8023a59674f9210d3c93af9334963cda634", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "6e7361fca6cf06aa9e1bc837152219e5e42bd755", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "70791078427537d2f151bff9eb499fa3965fd085", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "7929f477d34a1cf2b23f9e80d7fcf7934b3b5470", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "7c64543f6ab0ee3fc27f6390ec3953a180e157a6", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "7f2cef99fe333412d50d140693854a6f781694be", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "a758c37e8d70b7e4be15f368a0da548f60ac4b9d", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "b40843939fd785c4984d73fa471092e14bc6ad9e", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "c2ecca408cb2333b51ad8bce1daf9df45b4b45bb", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "e0e8fea5e2f3406eaf4c87c2c87826d58a266c64", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "ec8da74216b9c2aa454584ea9fc1c422f00e347e", + "is_verified": false, + "line_number": 1 + }, + { + "type": "Hex High Entropy String", + "filename": "skel_common/backup/current_catalog.json", + "hashed_secret": "ed37981799b51e1a914756e75896724619be8519", + "is_verified": false, + "line_number": 1 + } + ] + }, + "generated_at": "2021-10-27T10:33:58Z" +} diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..abdea9a --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.apt.core.prefs b/.settings/org.eclipse.jdt.apt.core.prefs new file mode 100644 index 0000000..d4313d4 --- /dev/null +++ b/.settings/org.eclipse.jdt.apt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.apt.aptEnabled=false diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3fc7e86 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/README.md b/README.md index 2100342..ff99565 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,35 @@ -Slipstream Mod Manager -====================== +# Slipstream Mod Manager -Slipstream is a mod manager for the game FasterThanLight ([FTL](https://subsetgames.com/)), making it easy to install multiple mods at the same time and, later, revert to vanilla gameplay. +Slipstream is a mod manager for the game FasterThanLight +([FTL](https://subsetgames.com/ftl.html)), making it easy to install multiple +mods at the same time and, later, revert to vanilla gameplay. -It is the successor to Grognak's Mod Manager ([GMM](https://subsetgames.com/forum/viewtopic.php?p=9994)). +It is the successor to Grognak's Mod Manager +([GMM](https://subsetgames.com/forum/viewtopic.php?p=9994)). - +![Screenshot of the mod manager in use](assets/screenshot01.png) -To download compiled binaries, [click here](https://sourceforge.net/projects/slipstreammodmanager/). +## Requirements -Comments can be made in a forum thread [here](https://subsetgames.com/forum/viewtopic.php?f=12&t=17102). +- Java (1.6 or higher). + - +- FTL (1.01-1.6.3, Windows/OSX/Linux, Steam/GOG/Standalone). + - +- WinXP SP1 can't run Java 1.7. + - (1.7 was built with VisualStudio 2010, causing a DecodePointer error.) + - To get 1.6, you may have to google "jdk-6u45-windows-i586.exe". -I can accept PayPal donations [here](https://vhati.github.io/donate.html). -That would be fantastic. +## Building +1. Open the repository in the provided Visual Studio Code devcontainer. +2. Run `mvn package` from the repository root to compile the source and + generate a JAR file. -Requirements ------------- -* Java (1.6 or higher). - * http://www.java.com/en/download/ -* FTL (1.01-1.6.3, Windows/OSX/Linux, Steam/GOG/Standalone). - * https://subsetgames.com/ -* WinXP SP1 can't run Java 1.7. - * (1.7 was built with VisualStudio 2010, causing a DecodePointer error.) - * To get 1.6, you may have to google "jdk-6u45-windows-i586.exe". +## Downloads, comments and donations + +[Download compiled binaries](https://sourceforge.net/projects/slipstreammodmanager/). + +Comments can be made in [this forum thread](https://subsetgames.com/forum/viewtopic.php?f=12&t=17102). + +I can accept [PayPal donations](https://vhati.github.io/donate.html). That +would be fantastic. diff --git a/img/screenshot01.png b/assets/screenshot01.png similarity index 100% rename from img/screenshot01.png rename to assets/screenshot01.png From 6c407afa64af18fcc56f33dda54bba6e4695c22c Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Wed, 27 Oct 2021 10:41:54 +0000 Subject: [PATCH 02/11] merge readmes, still untested --- README.md | 55 +++++++++++++++++++++++++++++++ readme_developers.txt | 75 ------------------------------------------- 2 files changed, 55 insertions(+), 75 deletions(-) delete mode 100644 readme_developers.txt diff --git a/README.md b/README.md index ff99565..d005d70 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,61 @@ It is the successor to Grognak's Mod Manager 2. Run `mvn package` from the repository root to compile the source and generate a JAR file. +The build process for this project is automated by +[Maven](http://maven.apache.org/) ([guide](http://docs.codehaus.org/display/MAVENUSER/Getting+Started+with+Maven)). + +To build, run `mvn clean package` in the root directory. + +- `assets/` + - Screenshots. +- `skel_common/` + - Files to include in distribution archives. +- `skel_win/` and `skel_unix/` + - System-specific files to include in distribution archives. +- `skel_exe/` + - Materials to create modman.exe (not part of Maven). + - Get Launch4j: + - Drag "launch4j_*.xml" onto "launch4jc.exe". + - "modman.exe" will appear alongside the xml. + - Drag modman.exe into "skel_win/". + - Run "mvn clean package". + - The manifest files will be embedded to + [prevent VirtualStore redirection](http://www.codeproject.com/Articles/17968/Making-Your-Application-UAC-Aware). +- `auto_update.json` + - Info about the latest release, downloaded periodically by clients. + +This project depends on the following libraries. + +- [Apache HttpComponents](https://hc.apache.org/) (For JavaDocs, click + HttpCore or HttpClient, then again under "Project reports".) +- [Jackson JSON Processor 2.x](http://jackson.codehaus.org/Home) (For + JavaDocs, look right.) +- [PNGJ](https://code.google.com/p/pngj/) (For JavaDocs, scroll down.) +- [JDOM 2.x](http://www.jdom.org/) (For JavaDocs, look left.) +- [SLF4J](https://www.slf4j.org/) (For JavaDocs, look left.) +- [Logback](https://logback.qos.ch/) (For JavaDocs, look left.) +- [picocli 2.x](http://picocli.info/) (For JavaDocs, look left and scroll + down to "API Javadoc".) + +Here's a batch file that builds when double-clicked (edit the vars): + +```bat +@ECHO OFF +SETLOCAL + +SET JAVA_HOME=D:\Apps\j2sdk1.6.0_45 +SET M2_HOME=D:\Apps\Maven + +SET M2=%M2_HOME%\bin +SET PATH=%M2%;%PATH% + +CD /D "%~dp0" +CALL mvn clean package + +PAUSE +ENDLOCAL & EXIT /B +``` + ## Downloads, comments and donations [Download compiled binaries](https://sourceforge.net/projects/slipstreammodmanager/). diff --git a/readme_developers.txt b/readme_developers.txt deleted file mode 100644 index 7a9c7b1..0000000 --- a/readme_developers.txt +++ /dev/null @@ -1,75 +0,0 @@ -The build process for this project is automated by Maven. - http://maven.apache.org/ - http://docs.codehaus.org/display/MAVENUSER/Getting+Started+with+Maven - - -To build, run "mvn clean package" in this folder. - - -"img/" - Screenshots. - -"skel_common/" - Files to include in distribution archives. - -"skel_win/" and "skel_unix/" - System-specific files to include in distribution archives. - -"skel_exe/" - Materials to create modman.exe (not part of Maven). - - Get Launch4j: http://launch4j.sourceforge.net/index.html - - Drag "launch4j_*.xml" onto "launch4jc.exe". - - "modman.exe" will appear alongside the xml. - - Drag modman.exe into "skel_win/". - - Run "mvn clean package". - - - The manifest files will be embedded to prevent VirtualStore redirection. - http://www.codeproject.com/Articles/17968/Making-Your-Application-UAC-Aware - -"auto_update.json" - Info about the latest release, downloaded periodically by clients. - - - -This project depends on the following libraries. -- Apache HttpComponents - https://hc.apache.org/ - (For JavaDocs, click HttpCore or HttpClient, then again under "Project reports".) -- Jackson JSON Processor 2.x - http://jackson.codehaus.org/Home - (For JavaDocs, look right.) -- PNGJ - https://code.google.com/p/pngj/ - (For JavaDocs, scroll down.) -- JDOM 2.x - http://www.jdom.org/ - (For JavaDocs, look left.) -- SLF4J - https://www.slf4j.org/ - (For JavaDocs, look left.) -- Logback - https://logback.qos.ch/ - (For JavaDocs, look left.) -- picocli 2.x - http://picocli.info/ - (For JavaDocs, look left and scroll down to "API Javadoc".) - - - -Here's a batch file that builds when double-clicked (edit the vars). -- - - - -@ECHO OFF -SETLOCAL - -SET JAVA_HOME=D:\Apps\j2sdk1.6.0_45 -SET M2_HOME=D:\Apps\Maven - -SET M2=%M2_HOME%\bin -SET PATH=%M2%;%PATH% - -CD /D "%~dp0" -CALL mvn clean package - -PAUSE -ENDLOCAL & EXIT /B -- - - - From b5354abb4f9a40a030a001034a4145d593c7b6c2 Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Wed, 27 Oct 2021 11:07:39 +0000 Subject: [PATCH 03/11] Fix build, tidy readme Maven no longer supports Java 1.6, so bump to 1.8 Also fix a Swing compilation issue with a cast, fix copied from [here](https://github.com/magiruuvelvet/chatty/commit/256e3cf8123993e01d6d33911e47608ae4f59383 ). --- .classpath | 2 +- .devcontainer/devcontainer.json | 9 - .settings/org.eclipse.jdt.core.prefs | 6 +- .vscode/settings.json | 3 + README.md | 44 +- pom.xml | 162 +++--- .../vhati/modmanager/ui/ModXMLSandbox.java | 535 +++++++++--------- 7 files changed, 380 insertions(+), 381 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.classpath b/.classpath index 8b73b29..39abf1c 100644 --- a/.classpath +++ b/.classpath @@ -18,7 +18,7 @@ - + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 940b0c9..8fcea5d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,20 +5,15 @@ "build": { "dockerfile": "Dockerfile", "args": { - // Update the VARIANT arg to pick a Java version: 11, 15 "VARIANT": "15", - // Options "INSTALL_MAVEN": "true", "INSTALL_NODE": "true", "NODE_VERSION": "lts/*" } }, - // Set *default* container specific settings.json values on container create. "settings": { - "terminal.integrated.shell.linux": "/bin/bash", "java.home": "/docker-java-home" }, - // Add the IDs of extensions you want installed when the container is created. "extensions": [ "vscjava.vscode-java-pack", "vscjava.vscode-java-dependency", @@ -28,10 +23,6 @@ "davidanson.vscode-markdownlint", "redhat.vscode-yaml" ], - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": "pre-commit install", - // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. "remoteUser": "vscode" } diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 3fc7e86..1b6e1ef 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..385f27a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive" +} diff --git a/README.md b/README.md index d005d70..a4d91d6 100644 --- a/README.md +++ b/README.md @@ -19,16 +19,7 @@ It is the successor to Grognak's Mod Manager - (1.7 was built with VisualStudio 2010, causing a DecodePointer error.) - To get 1.6, you may have to google "jdk-6u45-windows-i586.exe". -## Building - -1. Open the repository in the provided Visual Studio Code devcontainer. -2. Run `mvn package` from the repository root to compile the source and - generate a JAR file. - -The build process for this project is automated by -[Maven](http://maven.apache.org/) ([guide](http://docs.codehaus.org/display/MAVENUSER/Getting+Started+with+Maven)). - -To build, run `mvn clean package` in the root directory. +## Directory structure - `assets/` - Screenshots. @@ -38,7 +29,7 @@ To build, run `mvn clean package` in the root directory. - System-specific files to include in distribution archives. - `skel_exe/` - Materials to create modman.exe (not part of Maven). - - Get Launch4j: + - [Get Launch4j](http://launch4j.sourceforge.net/index.html) - Drag "launch4j_*.xml" onto "launch4jc.exe". - "modman.exe" will appear alongside the xml. - Drag modman.exe into "skel_win/". @@ -48,6 +39,18 @@ To build, run `mvn clean package` in the root directory. - `auto_update.json` - Info about the latest release, downloaded periodically by clients. +## Building + +The build process for this project is automated by +[Maven](http://maven.apache.org/) ([guide](http://docs.codehaus.org/display/MAVENUSER/Getting+Started+with+Maven)). + +1. Open the repository in the provided Visual Studio Code devcontainer. +2. Run `mvn package` from the repository root to compile the source and + generate a zip file containing the compiled assets for each platform in the + `target` directory. + +## Dependencies + This project depends on the following libraries. - [Apache HttpComponents](https://hc.apache.org/) (For JavaDocs, click @@ -61,25 +64,6 @@ This project depends on the following libraries. - [picocli 2.x](http://picocli.info/) (For JavaDocs, look left and scroll down to "API Javadoc".) -Here's a batch file that builds when double-clicked (edit the vars): - -```bat -@ECHO OFF -SETLOCAL - -SET JAVA_HOME=D:\Apps\j2sdk1.6.0_45 -SET M2_HOME=D:\Apps\Maven - -SET M2=%M2_HOME%\bin -SET PATH=%M2%;%PATH% - -CD /D "%~dp0" -CALL mvn clean package - -PAUSE -ENDLOCAL & EXIT /B -``` - ## Downloads, comments and donations [Download compiled binaries](https://sourceforge.net/projects/slipstreammodmanager/). diff --git a/pom.xml b/pom.xml index b235564..6ea97c6 100644 --- a/pom.xml +++ b/pom.xml @@ -10,9 +10,9 @@ 2.2.1 - 1.6 - 1.6 - 1.6 + 1.8 + 1.8 + 1.8 UTF-8 @@ -44,10 +44,11 @@ logback-classic 1.2.3 - + + com.fasterxml.jackson.core jackson-databind - 2.7.9.2 + 2.13.0 ar.com.hjg @@ -62,7 +63,7 @@ org.apache.httpcomponents httpclient - 4.5.4 + 4.5.13 info.picocli @@ -70,82 +71,85 @@ 2.2.0 - + - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - -Xlint:unchecked - -Xlint:deprecation - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.4.1 - - - jar-with-dependencies - package - - single - - - - jar-with-dependencies - - - - net.vhati.modmanager.FTLModManager - - - Vhati - - - modman - false - false - - - - dist-win - package - - single - - - - src/main/assembly/dist-win.xml - - SlipstreamModManager_${project.version}-Win - false - - - - dist-unix - package - - single - - - - src/main/assembly/dist-unix.xml - - SlipstreamModManager_${project.version}-Unix - false - - - - - - - \ No newline at end of file + org.apache.maven.plugins + maven-assembly-plugin + 2.4.1 + + + + jar-with-dependencies + package + + single + + + + jar-with-dependencies + + + + net.vhati.modmanager.FTLModManager + + + Vhati + + + modman + false + false + + + + + dist-win + package + + single + + + + src/main/assembly/dist-win.xml + + SlipstreamModManager_${project.version}-Win + false + + + + + dist-unix + package + + single + + + + src/main/assembly/dist-unix.xml + + SlipstreamModManager_${project.version}-Unix + false + + + + + + + diff --git a/src/main/java/net/vhati/modmanager/ui/ModXMLSandbox.java b/src/main/java/net/vhati/modmanager/ui/ModXMLSandbox.java index 8a07df2..e4bddf9 100644 --- a/src/main/java/net/vhati/modmanager/ui/ModXMLSandbox.java +++ b/src/main/java/net/vhati/modmanager/ui/ModXMLSandbox.java @@ -66,7 +66,6 @@ import org.jdom2.JDOMException; - /** * A basic text editor to test XML modding. */ @@ -95,374 +94,387 @@ public class ModXMLSandbox extends JFrame implements ActionListener { private JButton patchBtn; private JLabel statusLbl; - - public ModXMLSandbox( File datsDir ) { - super( baseTitle ); - this.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); + public ModXMLSandbox(File datsDir) { + super(baseTitle); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.datsDir = datsDir; - Font sandboxFont = new Font( Font.MONOSPACED, Font.PLAIN, 13 ); + Font sandboxFont = new Font(Font.MONOSPACED, Font.PLAIN, 13); mainArea = new JTextArea(); - mainArea.setTabSize( 4 ); - mainArea.setFont( sandboxFont ); - mainArea.setEditable( false ); - mainArea.addMouseListener( new ClipboardMenuMouseListener() ); - mainScroll = new JScrollPane( mainArea ); + mainArea.setTabSize(4); + mainArea.setFont(sandboxFont); + mainArea.setEditable(false); + mainArea.addMouseListener(new ClipboardMenuMouseListener()); + mainScroll = new JScrollPane(mainArea); appendArea = new JTextArea(); - appendArea.setTabSize( 4 ); - appendArea.setFont( sandboxFont ); - appendArea.addMouseListener( new ClipboardMenuMouseListener() ); - appendScroll = new JScrollPane( appendArea ); + appendArea.setTabSize(4); + appendArea.setFont(sandboxFont); + appendArea.addMouseListener(new ClipboardMenuMouseListener()); + appendScroll = new JScrollPane(appendArea); resultArea = new JTextArea(); - resultArea.setTabSize( 4 ); - resultArea.setFont( sandboxFont ); - resultArea.setEditable( false ); - resultArea.addMouseListener( new ClipboardMenuMouseListener() ); - resultScroll = new JScrollPane( resultArea ); + resultArea.setTabSize(4); + resultArea.setFont(sandboxFont); + resultArea.setEditable(false); + resultArea.addMouseListener(new ClipboardMenuMouseListener()); + resultScroll = new JScrollPane(resultArea); messageArea = new JTextArea(); - messageArea.setLineWrap( true ); - messageArea.setWrapStyleWord( true ); - messageArea.setTabSize( 4 ); - messageArea.setFont( sandboxFont ); - messageArea.setEditable( false ); - messageArea.addMouseListener( new ClipboardMenuMouseListener() ); - messageArea.setText( "This is a sandbox to tinker with advanced mod syntax.\n1) Open XML from data.dat to fill the 'main' tab. (ctrl-o)\n2) Write some tags in the 'append' tab. (alt-1,2,3)\n3) Click Patch to see what would happen. (ctrl-p)\nUndo/redo is available. (ctrl-z/ctrl-y)" ); - messageScroll = new JScrollPane( messageArea ); + messageArea.setLineWrap(true); + messageArea.setWrapStyleWord(true); + messageArea.setTabSize(4); + messageArea.setFont(sandboxFont); + messageArea.setEditable(false); + messageArea.addMouseListener(new ClipboardMenuMouseListener()); + messageArea.setText( + "This is a sandbox to tinker with advanced mod syntax.\n1) Open XML from data.dat to fill the 'main' tab. (ctrl-o)\n2) Write some tags in the 'append' tab. (alt-1,2,3)\n3) Click Patch to see what would happen. (ctrl-p)\nUndo/redo is available. (ctrl-z/ctrl-y)"); + messageScroll = new JScrollPane(messageArea); JPanel ctrlPanel = new JPanel(); - ctrlPanel.setLayout( new BoxLayout( ctrlPanel, BoxLayout.X_AXIS ) ); + ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.X_AXIS)); - openBtn = new JButton( "Open Main..." ); - openBtn.addActionListener( this ); - ctrlPanel.add( openBtn ); + openBtn = new JButton("Open Main..."); + openBtn.addActionListener(this); + ctrlPanel.add(openBtn); - ctrlPanel.add( Box.createHorizontalGlue() ); + ctrlPanel.add(Box.createHorizontalGlue()); - findField = new JTextField( "", 20 ); - findField.setMaximumSize( new Dimension( 60, findField.getPreferredSize().height ) ); - ctrlPanel.add( findField ); + findField = new JTextField("", 20); + findField.setMaximumSize(new Dimension(60, findField.getPreferredSize().height)); + ctrlPanel.add(findField); - ctrlPanel.add( Box.createHorizontalGlue() ); + ctrlPanel.add(Box.createHorizontalGlue()); - patchBtn = new JButton( "Patch" ); - patchBtn.addActionListener( this ); - ctrlPanel.add( patchBtn ); + patchBtn = new JButton("Patch"); + patchBtn.addActionListener(this); + ctrlPanel.add(patchBtn); - areasPane = new JTabbedPane( JTabbedPane.BOTTOM ); - areasPane.add( "Main", mainScroll ); - areasPane.add( "Append", appendScroll ); - areasPane.add( "Result", resultScroll ); + areasPane = new JTabbedPane(JTabbedPane.BOTTOM); + areasPane.add("Main", mainScroll); + areasPane.add("Append", appendScroll); + areasPane.add("Result", resultScroll); - JPanel topPanel = new JPanel( new BorderLayout() ); - topPanel.add( areasPane, BorderLayout.CENTER ); - topPanel.add( ctrlPanel, BorderLayout.SOUTH ); + JPanel topPanel = new JPanel(new BorderLayout()); + topPanel.add(areasPane, BorderLayout.CENTER); + topPanel.add(ctrlPanel, BorderLayout.SOUTH); - splitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT ); - splitPane.setTopComponent( topPanel ); - splitPane.setBottomComponent( messageScroll ); + splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + splitPane.setTopComponent(topPanel); + splitPane.setBottomComponent(messageScroll); JPanel statusPanel = new JPanel(); - statusPanel.setLayout( new BoxLayout( statusPanel, BoxLayout.Y_AXIS ) ); - statusPanel.setBorder( BorderFactory.createLoweredBevelBorder() ); - statusLbl = new JLabel( " " ); - statusLbl.setBorder( BorderFactory.createEmptyBorder( 2, 4, 2, 4 ) ); - statusLbl.setAlignmentX( Component.LEFT_ALIGNMENT ); - statusPanel.add( statusLbl ); - - JPanel contentPane = new JPanel( new BorderLayout() ); - contentPane.add( splitPane, BorderLayout.CENTER ); - contentPane.add( statusPanel, BorderLayout.SOUTH ); - this.setContentPane( contentPane ); + statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.Y_AXIS)); + statusPanel.setBorder(BorderFactory.createLoweredBevelBorder()); + statusLbl = new JLabel(" "); + statusLbl.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); + statusLbl.setAlignmentX(Component.LEFT_ALIGNMENT); + statusPanel.add(statusLbl); + + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(splitPane, BorderLayout.CENTER); + contentPane.add(statusPanel, BorderLayout.SOUTH); + this.setContentPane(contentPane); findField.addFocusListener(new FocusAdapter() { @Override - public void focusGained( FocusEvent e ) { + public void focusGained(FocusEvent e) { findField.selectAll(); } }); CaretListener caretListener = new CaretListener() { @Override - public void caretUpdate( CaretEvent e ) { + public void caretUpdate(CaretEvent e) { JTextArea currentArea = getCurrentArea(); - if ( currentArea == null ) return; - if ( e.getSource() != currentArea ) return; + if (currentArea == null) + return; + if (e.getSource() != currentArea) + return; updateCaretStatus(); } }; - mainArea.addCaretListener( caretListener ); - appendArea.addCaretListener( caretListener ); - resultArea.addCaretListener( caretListener ); + mainArea.addCaretListener(caretListener); + appendArea.addCaretListener(caretListener); + resultArea.addCaretListener(caretListener); CaretAncestorListener caretAncestorListener = new CaretAncestorListener(); - mainArea.addAncestorListener( caretAncestorListener ); - appendArea.addAncestorListener( caretAncestorListener ); - resultArea.addAncestorListener( caretAncestorListener ); + mainArea.addAncestorListener(caretAncestorListener); + appendArea.addAncestorListener(caretAncestorListener); + resultArea.addAncestorListener(caretAncestorListener); appendArea.getDocument().addUndoableEditListener(new UndoableEditListener() { @Override - public void undoableEditHappened( UndoableEditEvent e ) { - undoManager.addEdit( e.getEdit() ); + public void undoableEditHappened(UndoableEditEvent e) { + undoManager.addEdit(e.getEdit()); } }); - AbstractAction undoAction = new AbstractAction( "Undo" ) { + AbstractAction undoAction = new AbstractAction("Undo") { @Override - public void actionPerformed( ActionEvent e ) { - try {undoManager.undo();} - catch ( CannotRedoException f ) {} + public void actionPerformed(ActionEvent e) { + try { + undoManager.undo(); + } catch (CannotRedoException f) { + } } }; - AbstractAction redoAction = new AbstractAction( "Redo" ) { + AbstractAction redoAction = new AbstractAction("Redo") { @Override - public void actionPerformed( ActionEvent e ) { - try {undoManager.redo();} - catch ( CannotRedoException f ) {} + public void actionPerformed(ActionEvent e) { + try { + undoManager.redo(); + } catch (CannotRedoException f) { + } } }; - AbstractAction openAction = new AbstractAction( "Open" ) { + AbstractAction openAction = new AbstractAction("Open") { @Override - public void actionPerformed( ActionEvent e ) { + public void actionPerformed(ActionEvent e) { open(); } }; - AbstractAction patchAction = new AbstractAction( "Patch" ) { + AbstractAction patchAction = new AbstractAction("Patch") { @Override - public void actionPerformed( ActionEvent e ) { + public void actionPerformed(ActionEvent e) { patch(); } }; - AbstractAction focusFindAction = new AbstractAction( "Focus Find" ) { + AbstractAction focusFindAction = new AbstractAction("Focus Find") { @Override - public void actionPerformed( ActionEvent e ) { + public void actionPerformed(ActionEvent e) { findField.requestFocusInWindow(); } }; - AbstractAction findNextAction = new AbstractAction( "Find Next" ) { + AbstractAction findNextAction = new AbstractAction("Find Next") { @Override - public void actionPerformed( ActionEvent e ) { + public void actionPerformed(ActionEvent e) { findNext(); } }; - AbstractAction findPreviousAction = new AbstractAction( "Find Previous" ) { + AbstractAction findPreviousAction = new AbstractAction("Find Previous") { @Override - public void actionPerformed( ActionEvent e ) { + public void actionPerformed(ActionEvent e) { findPrevious(); } }; - KeyStroke undoShortcut = KeyStroke.getKeyStroke( "control Z" ); - appendArea.getInputMap().put( undoShortcut, "undo" ); - appendArea.getActionMap().put( "undo", undoAction ); - KeyStroke redoShortcut = KeyStroke.getKeyStroke( "control Y" ); - appendArea.getInputMap().put( redoShortcut, "redo" ); - appendArea.getActionMap().put( "redo", redoAction ); - - KeyStroke openShortcut = KeyStroke.getKeyStroke( "control O" ); - contentPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( openShortcut, "open" ); - contentPane.getActionMap().put( "open", openAction ); - KeyStroke patchShortcut = KeyStroke.getKeyStroke( "control P" ); - contentPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( patchShortcut, "patch" ); - contentPane.getActionMap().put( "patch", patchAction ); - KeyStroke focusFindShortcut = KeyStroke.getKeyStroke( "control F" ); - contentPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( focusFindShortcut, "focus find" ); - contentPane.getActionMap().put( "focus find", focusFindAction ); - KeyStroke findNextShortcut = KeyStroke.getKeyStroke( "F3" ); - contentPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( findNextShortcut, "find next" ); - contentPane.getActionMap().put( "find next", findNextAction ); - KeyStroke findPreviousShortcut = KeyStroke.getKeyStroke( "shift F3" ); - contentPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( findPreviousShortcut, "find previous" ); - contentPane.getActionMap().put( "find previous", findPreviousAction ); - - findField.getInputMap().put( KeyStroke.getKeyStroke( "released ENTER" ), "find next" ); - findField.getActionMap().put( "find next", findNextAction ); - - areasPane.setMnemonicAt( 0, KeyEvent.VK_1 ); - areasPane.setMnemonicAt( 1, KeyEvent.VK_2 ); - areasPane.setMnemonicAt( 2, KeyEvent.VK_3 ); - mainArea.addAncestorListener( new FocusAncestorListener( mainArea ) ); - appendArea.addAncestorListener( new FocusAncestorListener( appendArea ) ); - resultArea.addAncestorListener( new FocusAncestorListener( resultArea ) ); + KeyStroke undoShortcut = KeyStroke.getKeyStroke("control Z"); + appendArea.getInputMap().put(undoShortcut, "undo"); + appendArea.getActionMap().put("undo", undoAction); + KeyStroke redoShortcut = KeyStroke.getKeyStroke("control Y"); + appendArea.getInputMap().put(redoShortcut, "redo"); + appendArea.getActionMap().put("redo", redoAction); + + KeyStroke openShortcut = KeyStroke.getKeyStroke("control O"); + contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(openShortcut, "open"); + contentPane.getActionMap().put("open", openAction); + KeyStroke patchShortcut = KeyStroke.getKeyStroke("control P"); + contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(patchShortcut, "patch"); + contentPane.getActionMap().put("patch", patchAction); + KeyStroke focusFindShortcut = KeyStroke.getKeyStroke("control F"); + contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(focusFindShortcut, "focus find"); + contentPane.getActionMap().put("focus find", focusFindAction); + KeyStroke findNextShortcut = KeyStroke.getKeyStroke("F3"); + contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(findNextShortcut, "find next"); + contentPane.getActionMap().put("find next", findNextAction); + KeyStroke findPreviousShortcut = KeyStroke.getKeyStroke("shift F3"); + contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(findPreviousShortcut, "find previous"); + contentPane.getActionMap().put("find previous", findPreviousAction); + + findField.getInputMap().put(KeyStroke.getKeyStroke("released ENTER"), "find next"); + findField.getActionMap().put("find next", findNextAction); + + areasPane.setMnemonicAt(0, KeyEvent.VK_1); + areasPane.setMnemonicAt(1, KeyEvent.VK_2); + areasPane.setMnemonicAt(2, KeyEvent.VK_3); + mainArea.addAncestorListener(new FocusAncestorListener(mainArea)); + appendArea.addAncestorListener(new FocusAncestorListener(appendArea)); + resultArea.addAncestorListener(new FocusAncestorListener(resultArea)); this.pack(); } @Override - public void setVisible( boolean b ) { - super.setVisible( b ); + public void setVisible(boolean b) { + super.setVisible(b); - if ( b ) { + if (b) { // Splitpane has to be realized before the divider can be moved. SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - splitPane.setDividerLocation( 0.80d ); + splitPane.setDividerLocation(0.80d); } }); } } @Override - public void actionPerformed( ActionEvent e ) { + public void actionPerformed(ActionEvent e) { Object source = e.getSource(); - if ( source == openBtn ) { + if (source == openBtn) { open(); - } - else if ( source == patchBtn ) { + } else if (source == patchBtn) { patch(); } } private void open() { - messageArea.setText( "" ); + messageArea.setText(""); AbstractPack pack = null; InputStream is = null; try { - File ftlDatFile = new File( datsDir, "ftl.dat" ); - File dataDatFile = new File( datsDir, "data.dat" ); - - if ( ftlDatFile.exists() ) { // FTL 1.6.1. - pack = new PkgPack( ftlDatFile, "r" ); - } - else if ( dataDatFile.exists() ) { // FTL 1.01-1.5.13. - pack = new FTLPack( dataDatFile, "r" ); - } - else { - throw new FileNotFoundException( String.format( "Could not find either \"%s\" or \"%s\"", ftlDatFile.getName(), dataDatFile.getName() ) ); + File ftlDatFile = new File(datsDir, "ftl.dat"); + File dataDatFile = new File(datsDir, "data.dat"); + + if (ftlDatFile.exists()) { // FTL 1.6.1. + pack = new PkgPack(ftlDatFile, "r"); + } else if (dataDatFile.exists()) { // FTL 1.01-1.5.13. + pack = new FTLPack(dataDatFile, "r"); + } else { + throw new FileNotFoundException( + String.format("Could not find either \"%s\" or \"%s\"", ftlDatFile.getName(), dataDatFile.getName())); } List innerPaths = pack.list(); - String innerPath = promptForInnerPath( innerPaths ); - if ( innerPath == null ) return; + String innerPath = promptForInnerPath(innerPaths); + if (innerPath == null) + return; - is = pack.getInputStream( innerPath ); - InputStream rebuiltStream = ModUtilities.rebuildXMLFile( is, "windows-1252", pack.getName()+":"+innerPath ); - String rebuiltText = ModUtilities.decodeText( rebuiltStream, "Sandbox Main XML" ).text; + is = pack.getInputStream(innerPath); + InputStream rebuiltStream = ModUtilities.rebuildXMLFile(is, "windows-1252", pack.getName() + ":" + innerPath); + String rebuiltText = ModUtilities.decodeText(rebuiltStream, "Sandbox Main XML").text; is.close(); - mainArea.setText( rebuiltText ); - mainArea.setCaretPosition( 0 ); - areasPane.setSelectedComponent( mainScroll ); - resultArea.setText( "" ); - this.setTitle( String.format( "%s - %s", innerPath, baseTitle ) ); - } - catch ( IOException f ) { - messageArea.setText( f.getMessage() ); - messageArea.setCaretPosition( 0 ); - } - catch ( JDOMException f ) { - messageArea.setText( f.getMessage() ); - messageArea.setCaretPosition( 0 ); - } - finally { - try {if ( is != null ) is.close();} - catch ( IOException f ) {} + mainArea.setText(rebuiltText); + mainArea.setCaretPosition(0); + areasPane.setSelectedComponent(mainScroll); + resultArea.setText(""); + this.setTitle(String.format("%s - %s", innerPath, baseTitle)); + } catch (IOException f) { + messageArea.setText(f.getMessage()); + messageArea.setCaretPosition(0); + } catch (JDOMException f) { + messageArea.setText(f.getMessage()); + messageArea.setCaretPosition(0); + } finally { + try { + if (is != null) + is.close(); + } catch (IOException f) { + } - try {if ( pack != null ) pack.close();} - catch ( IOException f ) {} + try { + if (pack != null) + pack.close(); + } catch (IOException f) { + } } } private void patch() { String mainText = mainArea.getText(); - if ( mainText.length() == 0 ) return; + if (mainText.length() == 0) + return; - messageArea.setText( "" ); + messageArea.setText(""); try { - InputStream mainStream = new ByteArrayInputStream( mainText.getBytes( "UTF-8" ) ); + InputStream mainStream = new ByteArrayInputStream(mainText.getBytes("UTF-8")); String appendText = appendArea.getText(); - InputStream appendStream = new ByteArrayInputStream( appendText.getBytes( "UTF-8" ) ); - - InputStream resultStream = ModUtilities.patchXMLFile( mainStream, appendStream, "windows-1252", false, "Sandbox Main XML", "Sandbox Append XML" ); - String resultText = ModUtilities.decodeText( resultStream, "Sandbox Result XML" ).text; - - resultArea.setText( resultText ); - resultArea.setCaretPosition( 0 ); - areasPane.setSelectedComponent( resultScroll ); - } - catch ( Exception e ) { - messageArea.setText( e.toString() ); - messageArea.setCaretPosition( 0 ); + InputStream appendStream = new ByteArrayInputStream(appendText.getBytes("UTF-8")); + + InputStream resultStream = ModUtilities.patchXMLFile(mainStream, appendStream, "windows-1252", false, + "Sandbox Main XML", "Sandbox Append XML"); + String resultText = ModUtilities.decodeText(resultStream, "Sandbox Result XML").text; + + resultArea.setText(resultText); + resultArea.setCaretPosition(0); + areasPane.setSelectedComponent(resultScroll); + } catch (Exception e) { + messageArea.setText(e.toString()); + messageArea.setCaretPosition(0); } } private void findNext() { JTextArea currentArea = getCurrentArea(); - if ( currentArea == null ) return; + if (currentArea == null) + return; String query = findField.getText(); - if ( query.length() == 0 ) return; + if (query.length() == 0) + return; Caret caret = currentArea.getCaret(); - int from = Math.max( caret.getDot(), caret.getMark() ); - - Pattern ptn = Pattern.compile( "(?i)"+ Pattern.quote( query ) ); - Matcher m = ptn.matcher( currentArea.getText() ); - if ( m.find(from) ) { - caret.setDot( m.start() ); - caret.moveDot( m.end() ); - caret.setSelectionVisible( true ); + int from = Math.max(caret.getDot(), caret.getMark()); + + Pattern ptn = Pattern.compile("(?i)" + Pattern.quote(query)); + Matcher m = ptn.matcher(currentArea.getText()); + if (m.find(from)) { + caret.setDot(m.start()); + caret.moveDot(m.end()); + caret.setSelectionVisible(true); } } private void findPrevious() { JTextArea currentArea = getCurrentArea(); - if ( currentArea == null ) return; + if (currentArea == null) + return; String query = findField.getText(); - if ( query.length() == 0 ) return; + if (query.length() == 0) + return; Caret caret = currentArea.getCaret(); - int from = Math.min( caret.getDot(), caret.getMark() ); + int from = Math.min(caret.getDot(), caret.getMark()); - Pattern ptn = Pattern.compile( "(?i)"+ Pattern.quote(query) ); - Matcher m = ptn.matcher( currentArea.getText() ); - m.region( 0, from ); + Pattern ptn = Pattern.compile("(?i)" + Pattern.quote(query)); + Matcher m = ptn.matcher(currentArea.getText()); + m.region(0, from); int lastStart = -1; int lastEnd = -1; - while ( m.find() ) { + while (m.find()) { lastStart = m.start(); lastEnd = m.end(); } - if ( lastStart != -1 ) { - caret.setDot( lastStart ); - caret.moveDot( lastEnd ); - caret.setSelectionVisible( true ); + if (lastStart != -1) { + caret.setDot(lastStart); + caret.moveDot(lastEnd); + caret.setSelectionVisible(true); } } private void updateCaretStatus() { JTextArea currentArea = getCurrentArea(); - if ( currentArea == null ) return; + if (currentArea == null) + return; try { int offset = currentArea.getCaretPosition(); - int line = currentArea.getLineOfOffset( offset ); - int lineStart = currentArea.getLineStartOffset( line ); + int line = currentArea.getLineOfOffset(offset); + int lineStart = currentArea.getLineStartOffset(line); int col = offset - lineStart; int lineCount = currentArea.getLineCount(); - statusLbl.setText( String.format( "Line: %4d/%4d Col: %3d", line+1, lineCount, col+1 ) ); - } - catch ( BadLocationException e ) { - statusLbl.setText( String.format( "Line: ???/ ??? Col: ???" ) ); + statusLbl.setText(String.format("Line: %4d/%4d Col: %3d", line + 1, lineCount, col + 1)); + } catch (BadLocationException e) { + statusLbl.setText(String.format("Line: ???/ ??? Col: ???")); } } private JTextArea getCurrentArea() { - if ( areasPane.getSelectedIndex() == 0 ) + if (areasPane.getSelectedIndex() == 0) return mainArea; - else if ( areasPane.getSelectedIndex() == 1 ) + else if (areasPane.getSelectedIndex() == 1) return appendArea; - else if ( areasPane.getSelectedIndex() == 2 ) + else if (areasPane.getSelectedIndex() == 2) return resultArea; else return null; @@ -473,46 +485,49 @@ else if ( areasPane.getSelectedIndex() == 2 ) * * @return the selected path, null otherwise */ - private String promptForInnerPath( List innerPaths ) { + private String promptForInnerPath(List innerPaths) { String result = null; - Set sortedPaths = new TreeSet( innerPaths ); - for ( Iterator it = sortedPaths.iterator(); it.hasNext(); ) { - if ( !it.next().endsWith(".xml") ) it.remove(); + Set sortedPaths = new TreeSet(innerPaths); + for (Iterator it = sortedPaths.iterator(); it.hasNext();) { + if (!it.next().endsWith(".xml")) + it.remove(); } - DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( "/" ); - DefaultTreeModel treeModel = new DefaultTreeModel( rootNode ); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("/"); + DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); - for ( String innerPath : sortedPaths ) { - buildTreeFromString( treeModel, innerPath ); + for (String innerPath : sortedPaths) { + buildTreeFromString(treeModel, innerPath); } - JTree pathTree = new JTree( treeModel ); - pathTree.setRootVisible( false ); - for ( int i=0; i < pathTree.getRowCount(); i++ ) { - pathTree.expandRow( i ); + JTree pathTree = new JTree(treeModel); + pathTree.setRootVisible(false); + for (int i = 0; i < pathTree.getRowCount(); i++) { + pathTree.expandRow(i); } - JScrollPane treeScroll = new JScrollPane( pathTree ); - treeScroll.setPreferredSize( new Dimension( pathTree.getPreferredSize().width, 300 ) ); + JScrollPane treeScroll = new JScrollPane(pathTree); + treeScroll.setPreferredSize(new Dimension(pathTree.getPreferredSize().width, 300)); - pathTree.addAncestorListener( new FocusAncestorListener( pathTree ) ); + pathTree.addAncestorListener(new FocusAncestorListener(pathTree)); - int popupResult = JOptionPane.showOptionDialog( this, treeScroll, "Open an XML Resource", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, new String[]{"OK"}, "OK" ); + int popupResult = JOptionPane.showOptionDialog(this, treeScroll, "Open an XML Resource", + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, new String[] { "OK" }, "OK"); - if ( popupResult == JOptionPane.OK_OPTION ) { + if (popupResult == JOptionPane.OK_OPTION) { StringBuilder buf = new StringBuilder(); TreePath selectedPath = pathTree.getSelectionPath(); - if ( selectedPath != null ) { - for ( Object o : selectedPath.getPath() ) { - DefaultMutableTreeNode pathComp = (DefaultMutableTreeNode)o; - if ( !pathComp.isRoot() ) { + if (selectedPath != null) { + for (Object o : selectedPath.getPath()) { + DefaultMutableTreeNode pathComp = (DefaultMutableTreeNode) o; + if (!pathComp.isRoot()) { Object userObject = pathComp.getUserObject(); - buf.append( userObject.toString() ); + buf.append(userObject.toString()); } } - if ( buf.length() > 0 ) result = buf.toString(); + if (buf.length() > 0) + result = buf.toString(); } } @@ -520,71 +535,73 @@ private String promptForInnerPath( List innerPaths ) { } /** - * Adds TreeNodes, if they don't already exist, based on a shash-delimited string. + * Adds TreeNodes, if they don't already exist, based on a shash-delimited + * string. */ @SuppressWarnings("unchecked") - private void buildTreeFromString( DefaultTreeModel treeModel, String path ) { - DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode)treeModel.getRoot(); + private void buildTreeFromString(DefaultTreeModel treeModel, String path) { + DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) treeModel.getRoot(); DefaultMutableTreeNode currentNode = rootNode; - String[] chunks = path.split( "/" ); + String[] chunks = path.split("/"); - for ( int i=0; i < chunks.length; i++ ) { + for (int i = 0; i < chunks.length; i++) { String chunk = chunks[i]; - if ( i < chunks.length-1 ) + if (i < chunks.length - 1) chunk += "/"; boolean found = false; - Enumeration enumIt = currentNode.children(); - while ( enumIt.hasMoreElements() ) { + Enumeration enumIt = (Enumeration) (Object) currentNode + .children(); + while (enumIt.hasMoreElements()) { DefaultMutableTreeNode tmpNode = enumIt.nextElement(); - if ( chunk.equals( tmpNode.getUserObject() ) ) { + if (chunk.equals(tmpNode.getUserObject())) { found = true; currentNode = tmpNode; break; } } - if ( !found ) { - DefaultMutableTreeNode newNode = new DefaultMutableTreeNode( chunk ); - currentNode.insert( newNode, currentNode.getChildCount() ); + if (!found) { + DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(chunk); + currentNode.insert(newNode, currentNode.getChildCount()); currentNode = newNode; } } } - - private class CaretAncestorListener implements AncestorListener { @Override - public void ancestorAdded( AncestorEvent e ) { + public void ancestorAdded(AncestorEvent e) { updateCaretStatus(); } + @Override - public void ancestorMoved( AncestorEvent e ) { + public void ancestorMoved(AncestorEvent e) { } + @Override - public void ancestorRemoved( AncestorEvent e ) { + public void ancestorRemoved(AncestorEvent e) { } } - - private static class FocusAncestorListener implements AncestorListener { private JComponent comp; - public FocusAncestorListener( JComponent comp ) { + public FocusAncestorListener(JComponent comp) { this.comp = comp; } @Override - public void ancestorAdded( AncestorEvent e ) { + public void ancestorAdded(AncestorEvent e) { comp.requestFocusInWindow(); } + @Override - public void ancestorMoved( AncestorEvent e ) { + public void ancestorMoved(AncestorEvent e) { } + @Override - public void ancestorRemoved( AncestorEvent e ) { + public void ancestorRemoved(AncestorEvent e) { } } } From 1b934492e0ebc8202e90ff6d41714b69a3d1a7e2 Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Wed, 27 Oct 2021 11:24:31 +0000 Subject: [PATCH 04/11] update gitignore and remove generated files --- .gitignore | 73 ++++++++++++++++++---- .settings/org.eclipse.core.resources.prefs | 4 -- .settings/org.eclipse.jdt.apt.core.prefs | 2 - .settings/org.eclipse.jdt.core.prefs | 9 --- .settings/org.eclipse.m2e.core.prefs | 4 -- .vscode/settings.json | 3 - 6 files changed, 60 insertions(+), 35 deletions(-) delete mode 100644 .settings/org.eclipse.core.resources.prefs delete mode 100644 .settings/org.eclipse.jdt.apt.core.prefs delete mode 100644 .settings/org.eclipse.jdt.core.prefs delete mode 100644 .settings/org.eclipse.m2e.core.prefs delete mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 2b925ad..58804e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,69 @@ -target/ +# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig + +# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,java,maven +# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,java,maven +### Java ### +# Compiled class file *.class -*.tmp -*.bak -~$* +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar -# Windows image file caches -Thumbs.db +### Maven Patch ### +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath -# Windows folder config file -Desktop.ini +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace +# Local History for Visual Studio Code +.history/ -# Mac junk -.DS_Store +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide +# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,java,maven -# IdeaJ -*.idea -*.iml +# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index abdea9a..0000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/main/resources=UTF-8 -encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.apt.core.prefs b/.settings/org.eclipse.jdt.apt.core.prefs deleted file mode 100644 index d4313d4..0000000 --- a/.settings/org.eclipse.jdt.apt.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.apt.aptEnabled=false diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 1b6e1ef..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore -org.eclipse.jdt.core.compiler.processAnnotations=disabled -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f..0000000 --- a/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 385f27a..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "interactive" -} From cdf2ba76a91fbe0bf89b46df6bfcd37d1a97c7c3 Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Wed, 27 Oct 2021 11:29:22 +0000 Subject: [PATCH 05/11] minimise diff --- .../vhati/modmanager/ui/ModXMLSandbox.java | 535 +++++++++--------- 1 file changed, 259 insertions(+), 276 deletions(-) diff --git a/src/main/java/net/vhati/modmanager/ui/ModXMLSandbox.java b/src/main/java/net/vhati/modmanager/ui/ModXMLSandbox.java index e4bddf9..a08e06d 100644 --- a/src/main/java/net/vhati/modmanager/ui/ModXMLSandbox.java +++ b/src/main/java/net/vhati/modmanager/ui/ModXMLSandbox.java @@ -66,6 +66,7 @@ import org.jdom2.JDOMException; + /** * A basic text editor to test XML modding. */ @@ -94,387 +95,374 @@ public class ModXMLSandbox extends JFrame implements ActionListener { private JButton patchBtn; private JLabel statusLbl; - public ModXMLSandbox(File datsDir) { - super(baseTitle); - this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + public ModXMLSandbox( File datsDir ) { + super( baseTitle ); + this.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); this.datsDir = datsDir; - Font sandboxFont = new Font(Font.MONOSPACED, Font.PLAIN, 13); + Font sandboxFont = new Font( Font.MONOSPACED, Font.PLAIN, 13 ); mainArea = new JTextArea(); - mainArea.setTabSize(4); - mainArea.setFont(sandboxFont); - mainArea.setEditable(false); - mainArea.addMouseListener(new ClipboardMenuMouseListener()); - mainScroll = new JScrollPane(mainArea); + mainArea.setTabSize( 4 ); + mainArea.setFont( sandboxFont ); + mainArea.setEditable( false ); + mainArea.addMouseListener( new ClipboardMenuMouseListener() ); + mainScroll = new JScrollPane( mainArea ); appendArea = new JTextArea(); - appendArea.setTabSize(4); - appendArea.setFont(sandboxFont); - appendArea.addMouseListener(new ClipboardMenuMouseListener()); - appendScroll = new JScrollPane(appendArea); + appendArea.setTabSize( 4 ); + appendArea.setFont( sandboxFont ); + appendArea.addMouseListener( new ClipboardMenuMouseListener() ); + appendScroll = new JScrollPane( appendArea ); resultArea = new JTextArea(); - resultArea.setTabSize(4); - resultArea.setFont(sandboxFont); - resultArea.setEditable(false); - resultArea.addMouseListener(new ClipboardMenuMouseListener()); - resultScroll = new JScrollPane(resultArea); + resultArea.setTabSize( 4 ); + resultArea.setFont( sandboxFont ); + resultArea.setEditable( false ); + resultArea.addMouseListener( new ClipboardMenuMouseListener() ); + resultScroll = new JScrollPane( resultArea ); messageArea = new JTextArea(); - messageArea.setLineWrap(true); - messageArea.setWrapStyleWord(true); - messageArea.setTabSize(4); - messageArea.setFont(sandboxFont); - messageArea.setEditable(false); - messageArea.addMouseListener(new ClipboardMenuMouseListener()); - messageArea.setText( - "This is a sandbox to tinker with advanced mod syntax.\n1) Open XML from data.dat to fill the 'main' tab. (ctrl-o)\n2) Write some tags in the 'append' tab. (alt-1,2,3)\n3) Click Patch to see what would happen. (ctrl-p)\nUndo/redo is available. (ctrl-z/ctrl-y)"); - messageScroll = new JScrollPane(messageArea); + messageArea.setLineWrap( true ); + messageArea.setWrapStyleWord( true ); + messageArea.setTabSize( 4 ); + messageArea.setFont( sandboxFont ); + messageArea.setEditable( false ); + messageArea.addMouseListener( new ClipboardMenuMouseListener() ); + messageArea.setText( "This is a sandbox to tinker with advanced mod syntax.\n1) Open XML from data.dat to fill the 'main' tab. (ctrl-o)\n2) Write some tags in the 'append' tab. (alt-1,2,3)\n3) Click Patch to see what would happen. (ctrl-p)\nUndo/redo is available. (ctrl-z/ctrl-y)" ); + messageScroll = new JScrollPane( messageArea ); JPanel ctrlPanel = new JPanel(); - ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.X_AXIS)); + ctrlPanel.setLayout( new BoxLayout( ctrlPanel, BoxLayout.X_AXIS ) ); - openBtn = new JButton("Open Main..."); - openBtn.addActionListener(this); - ctrlPanel.add(openBtn); + openBtn = new JButton( "Open Main..." ); + openBtn.addActionListener( this ); + ctrlPanel.add( openBtn ); - ctrlPanel.add(Box.createHorizontalGlue()); + ctrlPanel.add( Box.createHorizontalGlue() ); - findField = new JTextField("", 20); - findField.setMaximumSize(new Dimension(60, findField.getPreferredSize().height)); - ctrlPanel.add(findField); + findField = new JTextField( "", 20 ); + findField.setMaximumSize( new Dimension( 60, findField.getPreferredSize().height ) ); + ctrlPanel.add( findField ); - ctrlPanel.add(Box.createHorizontalGlue()); + ctrlPanel.add( Box.createHorizontalGlue() ); - patchBtn = new JButton("Patch"); - patchBtn.addActionListener(this); - ctrlPanel.add(patchBtn); + patchBtn = new JButton( "Patch" ); + patchBtn.addActionListener( this ); + ctrlPanel.add( patchBtn ); - areasPane = new JTabbedPane(JTabbedPane.BOTTOM); - areasPane.add("Main", mainScroll); - areasPane.add("Append", appendScroll); - areasPane.add("Result", resultScroll); + areasPane = new JTabbedPane( JTabbedPane.BOTTOM ); + areasPane.add( "Main", mainScroll ); + areasPane.add( "Append", appendScroll ); + areasPane.add( "Result", resultScroll ); - JPanel topPanel = new JPanel(new BorderLayout()); - topPanel.add(areasPane, BorderLayout.CENTER); - topPanel.add(ctrlPanel, BorderLayout.SOUTH); + JPanel topPanel = new JPanel( new BorderLayout() ); + topPanel.add( areasPane, BorderLayout.CENTER ); + topPanel.add( ctrlPanel, BorderLayout.SOUTH ); - splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); - splitPane.setTopComponent(topPanel); - splitPane.setBottomComponent(messageScroll); + splitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT ); + splitPane.setTopComponent( topPanel ); + splitPane.setBottomComponent( messageScroll ); JPanel statusPanel = new JPanel(); - statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.Y_AXIS)); - statusPanel.setBorder(BorderFactory.createLoweredBevelBorder()); - statusLbl = new JLabel(" "); - statusLbl.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); - statusLbl.setAlignmentX(Component.LEFT_ALIGNMENT); - statusPanel.add(statusLbl); - - JPanel contentPane = new JPanel(new BorderLayout()); - contentPane.add(splitPane, BorderLayout.CENTER); - contentPane.add(statusPanel, BorderLayout.SOUTH); - this.setContentPane(contentPane); + statusPanel.setLayout( new BoxLayout( statusPanel, BoxLayout.Y_AXIS ) ); + statusPanel.setBorder( BorderFactory.createLoweredBevelBorder() ); + statusLbl = new JLabel( " " ); + statusLbl.setBorder( BorderFactory.createEmptyBorder( 2, 4, 2, 4 ) ); + statusLbl.setAlignmentX( Component.LEFT_ALIGNMENT ); + statusPanel.add( statusLbl ); + + JPanel contentPane = new JPanel( new BorderLayout() ); + contentPane.add( splitPane, BorderLayout.CENTER ); + contentPane.add( statusPanel, BorderLayout.SOUTH ); + this.setContentPane( contentPane ); findField.addFocusListener(new FocusAdapter() { @Override - public void focusGained(FocusEvent e) { + public void focusGained( FocusEvent e ) { findField.selectAll(); } }); CaretListener caretListener = new CaretListener() { @Override - public void caretUpdate(CaretEvent e) { + public void caretUpdate( CaretEvent e ) { JTextArea currentArea = getCurrentArea(); - if (currentArea == null) - return; - if (e.getSource() != currentArea) - return; + if ( currentArea == null ) return; + if ( e.getSource() != currentArea ) return; updateCaretStatus(); } }; - mainArea.addCaretListener(caretListener); - appendArea.addCaretListener(caretListener); - resultArea.addCaretListener(caretListener); + mainArea.addCaretListener( caretListener ); + appendArea.addCaretListener( caretListener ); + resultArea.addCaretListener( caretListener ); CaretAncestorListener caretAncestorListener = new CaretAncestorListener(); - mainArea.addAncestorListener(caretAncestorListener); - appendArea.addAncestorListener(caretAncestorListener); - resultArea.addAncestorListener(caretAncestorListener); + mainArea.addAncestorListener( caretAncestorListener ); + appendArea.addAncestorListener( caretAncestorListener ); + resultArea.addAncestorListener( caretAncestorListener ); appendArea.getDocument().addUndoableEditListener(new UndoableEditListener() { @Override - public void undoableEditHappened(UndoableEditEvent e) { - undoManager.addEdit(e.getEdit()); + public void undoableEditHappened( UndoableEditEvent e ) { + undoManager.addEdit( e.getEdit() ); } }); - AbstractAction undoAction = new AbstractAction("Undo") { + AbstractAction undoAction = new AbstractAction( "Undo" ) { @Override - public void actionPerformed(ActionEvent e) { - try { - undoManager.undo(); - } catch (CannotRedoException f) { - } + public void actionPerformed( ActionEvent e ) { + try {undoManager.undo();} + catch ( CannotRedoException f ) {} } }; - AbstractAction redoAction = new AbstractAction("Redo") { + AbstractAction redoAction = new AbstractAction( "Redo" ) { @Override - public void actionPerformed(ActionEvent e) { - try { - undoManager.redo(); - } catch (CannotRedoException f) { - } + public void actionPerformed( ActionEvent e ) { + try {undoManager.redo();} + catch ( CannotRedoException f ) {} } }; - AbstractAction openAction = new AbstractAction("Open") { + AbstractAction openAction = new AbstractAction( "Open" ) { @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed( ActionEvent e ) { open(); } }; - AbstractAction patchAction = new AbstractAction("Patch") { + AbstractAction patchAction = new AbstractAction( "Patch" ) { @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed( ActionEvent e ) { patch(); } }; - AbstractAction focusFindAction = new AbstractAction("Focus Find") { + AbstractAction focusFindAction = new AbstractAction( "Focus Find" ) { @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed( ActionEvent e ) { findField.requestFocusInWindow(); } }; - AbstractAction findNextAction = new AbstractAction("Find Next") { + AbstractAction findNextAction = new AbstractAction( "Find Next" ) { @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed( ActionEvent e ) { findNext(); } }; - AbstractAction findPreviousAction = new AbstractAction("Find Previous") { + AbstractAction findPreviousAction = new AbstractAction( "Find Previous" ) { @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed( ActionEvent e ) { findPrevious(); } }; - KeyStroke undoShortcut = KeyStroke.getKeyStroke("control Z"); - appendArea.getInputMap().put(undoShortcut, "undo"); - appendArea.getActionMap().put("undo", undoAction); - KeyStroke redoShortcut = KeyStroke.getKeyStroke("control Y"); - appendArea.getInputMap().put(redoShortcut, "redo"); - appendArea.getActionMap().put("redo", redoAction); - - KeyStroke openShortcut = KeyStroke.getKeyStroke("control O"); - contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(openShortcut, "open"); - contentPane.getActionMap().put("open", openAction); - KeyStroke patchShortcut = KeyStroke.getKeyStroke("control P"); - contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(patchShortcut, "patch"); - contentPane.getActionMap().put("patch", patchAction); - KeyStroke focusFindShortcut = KeyStroke.getKeyStroke("control F"); - contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(focusFindShortcut, "focus find"); - contentPane.getActionMap().put("focus find", focusFindAction); - KeyStroke findNextShortcut = KeyStroke.getKeyStroke("F3"); - contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(findNextShortcut, "find next"); - contentPane.getActionMap().put("find next", findNextAction); - KeyStroke findPreviousShortcut = KeyStroke.getKeyStroke("shift F3"); - contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(findPreviousShortcut, "find previous"); - contentPane.getActionMap().put("find previous", findPreviousAction); - - findField.getInputMap().put(KeyStroke.getKeyStroke("released ENTER"), "find next"); - findField.getActionMap().put("find next", findNextAction); - - areasPane.setMnemonicAt(0, KeyEvent.VK_1); - areasPane.setMnemonicAt(1, KeyEvent.VK_2); - areasPane.setMnemonicAt(2, KeyEvent.VK_3); - mainArea.addAncestorListener(new FocusAncestorListener(mainArea)); - appendArea.addAncestorListener(new FocusAncestorListener(appendArea)); - resultArea.addAncestorListener(new FocusAncestorListener(resultArea)); + KeyStroke undoShortcut = KeyStroke.getKeyStroke( "control Z" ); + appendArea.getInputMap().put( undoShortcut, "undo" ); + appendArea.getActionMap().put( "undo", undoAction ); + KeyStroke redoShortcut = KeyStroke.getKeyStroke( "control Y" ); + appendArea.getInputMap().put( redoShortcut, "redo" ); + appendArea.getActionMap().put( "redo", redoAction ); + + KeyStroke openShortcut = KeyStroke.getKeyStroke( "control O" ); + contentPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( openShortcut, "open" ); + contentPane.getActionMap().put( "open", openAction ); + KeyStroke patchShortcut = KeyStroke.getKeyStroke( "control P" ); + contentPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( patchShortcut, "patch" ); + contentPane.getActionMap().put( "patch", patchAction ); + KeyStroke focusFindShortcut = KeyStroke.getKeyStroke( "control F" ); + contentPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( focusFindShortcut, "focus find" ); + contentPane.getActionMap().put( "focus find", focusFindAction ); + KeyStroke findNextShortcut = KeyStroke.getKeyStroke( "F3" ); + contentPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( findNextShortcut, "find next" ); + contentPane.getActionMap().put( "find next", findNextAction ); + KeyStroke findPreviousShortcut = KeyStroke.getKeyStroke( "shift F3" ); + contentPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( findPreviousShortcut, "find previous" ); + contentPane.getActionMap().put( "find previous", findPreviousAction ); + + findField.getInputMap().put( KeyStroke.getKeyStroke( "released ENTER" ), "find next" ); + findField.getActionMap().put( "find next", findNextAction ); + + areasPane.setMnemonicAt( 0, KeyEvent.VK_1 ); + areasPane.setMnemonicAt( 1, KeyEvent.VK_2 ); + areasPane.setMnemonicAt( 2, KeyEvent.VK_3 ); + mainArea.addAncestorListener( new FocusAncestorListener( mainArea ) ); + appendArea.addAncestorListener( new FocusAncestorListener( appendArea ) ); + resultArea.addAncestorListener( new FocusAncestorListener( resultArea ) ); this.pack(); } @Override - public void setVisible(boolean b) { - super.setVisible(b); + public void setVisible( boolean b ) { + super.setVisible( b ); - if (b) { + if ( b ) { // Splitpane has to be realized before the divider can be moved. SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - splitPane.setDividerLocation(0.80d); + splitPane.setDividerLocation( 0.80d ); } }); } } @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed( ActionEvent e ) { Object source = e.getSource(); - if (source == openBtn) { + if ( source == openBtn ) { open(); - } else if (source == patchBtn) { + } + else if ( source == patchBtn ) { patch(); } } private void open() { - messageArea.setText(""); + messageArea.setText( "" ); AbstractPack pack = null; InputStream is = null; try { - File ftlDatFile = new File(datsDir, "ftl.dat"); - File dataDatFile = new File(datsDir, "data.dat"); - - if (ftlDatFile.exists()) { // FTL 1.6.1. - pack = new PkgPack(ftlDatFile, "r"); - } else if (dataDatFile.exists()) { // FTL 1.01-1.5.13. - pack = new FTLPack(dataDatFile, "r"); - } else { - throw new FileNotFoundException( - String.format("Could not find either \"%s\" or \"%s\"", ftlDatFile.getName(), dataDatFile.getName())); + File ftlDatFile = new File( datsDir, "ftl.dat" ); + File dataDatFile = new File( datsDir, "data.dat" ); + + if ( ftlDatFile.exists() ) { // FTL 1.6.1. + pack = new PkgPack( ftlDatFile, "r" ); + } + else if ( dataDatFile.exists() ) { // FTL 1.01-1.5.13. + pack = new FTLPack( dataDatFile, "r" ); + } + else { + throw new FileNotFoundException( String.format( "Could not find either \"%s\" or \"%s\"", ftlDatFile.getName(), dataDatFile.getName() ) ); } List innerPaths = pack.list(); - String innerPath = promptForInnerPath(innerPaths); - if (innerPath == null) - return; + String innerPath = promptForInnerPath( innerPaths ); + if ( innerPath == null ) return; - is = pack.getInputStream(innerPath); - InputStream rebuiltStream = ModUtilities.rebuildXMLFile(is, "windows-1252", pack.getName() + ":" + innerPath); - String rebuiltText = ModUtilities.decodeText(rebuiltStream, "Sandbox Main XML").text; + is = pack.getInputStream( innerPath ); + InputStream rebuiltStream = ModUtilities.rebuildXMLFile( is, "windows-1252", pack.getName()+":"+innerPath ); + String rebuiltText = ModUtilities.decodeText( rebuiltStream, "Sandbox Main XML" ).text; is.close(); - mainArea.setText(rebuiltText); - mainArea.setCaretPosition(0); - areasPane.setSelectedComponent(mainScroll); - resultArea.setText(""); - this.setTitle(String.format("%s - %s", innerPath, baseTitle)); - } catch (IOException f) { - messageArea.setText(f.getMessage()); - messageArea.setCaretPosition(0); - } catch (JDOMException f) { - messageArea.setText(f.getMessage()); - messageArea.setCaretPosition(0); - } finally { - try { - if (is != null) - is.close(); - } catch (IOException f) { - } + mainArea.setText( rebuiltText ); + mainArea.setCaretPosition( 0 ); + areasPane.setSelectedComponent( mainScroll ); + resultArea.setText( "" ); + this.setTitle( String.format( "%s - %s", innerPath, baseTitle ) ); + } + catch ( IOException f ) { + messageArea.setText( f.getMessage() ); + messageArea.setCaretPosition( 0 ); + } + catch ( JDOMException f ) { + messageArea.setText( f.getMessage() ); + messageArea.setCaretPosition( 0 ); + } + finally { + try {if ( is != null ) is.close();} + catch ( IOException f ) {} - try { - if (pack != null) - pack.close(); - } catch (IOException f) { - } + try {if ( pack != null ) pack.close();} + catch ( IOException f ) {} } } private void patch() { String mainText = mainArea.getText(); - if (mainText.length() == 0) - return; + if ( mainText.length() == 0 ) return; - messageArea.setText(""); + messageArea.setText( "" ); try { - InputStream mainStream = new ByteArrayInputStream(mainText.getBytes("UTF-8")); + InputStream mainStream = new ByteArrayInputStream( mainText.getBytes( "UTF-8" ) ); String appendText = appendArea.getText(); - InputStream appendStream = new ByteArrayInputStream(appendText.getBytes("UTF-8")); - - InputStream resultStream = ModUtilities.patchXMLFile(mainStream, appendStream, "windows-1252", false, - "Sandbox Main XML", "Sandbox Append XML"); - String resultText = ModUtilities.decodeText(resultStream, "Sandbox Result XML").text; - - resultArea.setText(resultText); - resultArea.setCaretPosition(0); - areasPane.setSelectedComponent(resultScroll); - } catch (Exception e) { - messageArea.setText(e.toString()); - messageArea.setCaretPosition(0); + InputStream appendStream = new ByteArrayInputStream( appendText.getBytes( "UTF-8" ) ); + + InputStream resultStream = ModUtilities.patchXMLFile( mainStream, appendStream, "windows-1252", false, "Sandbox Main XML", "Sandbox Append XML" ); + String resultText = ModUtilities.decodeText( resultStream, "Sandbox Result XML" ).text; + + resultArea.setText( resultText ); + resultArea.setCaretPosition( 0 ); + areasPane.setSelectedComponent( resultScroll ); + } + catch ( Exception e ) { + messageArea.setText( e.toString() ); + messageArea.setCaretPosition( 0 ); } } private void findNext() { JTextArea currentArea = getCurrentArea(); - if (currentArea == null) - return; + if ( currentArea == null ) return; String query = findField.getText(); - if (query.length() == 0) - return; + if ( query.length() == 0 ) return; Caret caret = currentArea.getCaret(); - int from = Math.max(caret.getDot(), caret.getMark()); - - Pattern ptn = Pattern.compile("(?i)" + Pattern.quote(query)); - Matcher m = ptn.matcher(currentArea.getText()); - if (m.find(from)) { - caret.setDot(m.start()); - caret.moveDot(m.end()); - caret.setSelectionVisible(true); + int from = Math.max( caret.getDot(), caret.getMark() ); + + Pattern ptn = Pattern.compile( "(?i)"+ Pattern.quote( query ) ); + Matcher m = ptn.matcher( currentArea.getText() ); + if ( m.find(from) ) { + caret.setDot( m.start() ); + caret.moveDot( m.end() ); + caret.setSelectionVisible( true ); } } private void findPrevious() { JTextArea currentArea = getCurrentArea(); - if (currentArea == null) - return; + if ( currentArea == null ) return; String query = findField.getText(); - if (query.length() == 0) - return; + if ( query.length() == 0 ) return; Caret caret = currentArea.getCaret(); - int from = Math.min(caret.getDot(), caret.getMark()); + int from = Math.min( caret.getDot(), caret.getMark() ); - Pattern ptn = Pattern.compile("(?i)" + Pattern.quote(query)); - Matcher m = ptn.matcher(currentArea.getText()); - m.region(0, from); + Pattern ptn = Pattern.compile( "(?i)"+ Pattern.quote(query) ); + Matcher m = ptn.matcher( currentArea.getText() ); + m.region( 0, from ); int lastStart = -1; int lastEnd = -1; - while (m.find()) { + while ( m.find() ) { lastStart = m.start(); lastEnd = m.end(); } - if (lastStart != -1) { - caret.setDot(lastStart); - caret.moveDot(lastEnd); - caret.setSelectionVisible(true); + if ( lastStart != -1 ) { + caret.setDot( lastStart ); + caret.moveDot( lastEnd ); + caret.setSelectionVisible( true ); } } private void updateCaretStatus() { JTextArea currentArea = getCurrentArea(); - if (currentArea == null) - return; + if ( currentArea == null ) return; try { int offset = currentArea.getCaretPosition(); - int line = currentArea.getLineOfOffset(offset); - int lineStart = currentArea.getLineStartOffset(line); + int line = currentArea.getLineOfOffset( offset ); + int lineStart = currentArea.getLineStartOffset( line ); int col = offset - lineStart; int lineCount = currentArea.getLineCount(); - statusLbl.setText(String.format("Line: %4d/%4d Col: %3d", line + 1, lineCount, col + 1)); - } catch (BadLocationException e) { - statusLbl.setText(String.format("Line: ???/ ??? Col: ???")); + statusLbl.setText( String.format( "Line: %4d/%4d Col: %3d", line+1, lineCount, col+1 ) ); + } + catch ( BadLocationException e ) { + statusLbl.setText( String.format( "Line: ???/ ??? Col: ???" ) ); } } private JTextArea getCurrentArea() { - if (areasPane.getSelectedIndex() == 0) + if ( areasPane.getSelectedIndex() == 0 ) return mainArea; - else if (areasPane.getSelectedIndex() == 1) + else if ( areasPane.getSelectedIndex() == 1 ) return appendArea; - else if (areasPane.getSelectedIndex() == 2) + else if ( areasPane.getSelectedIndex() == 2 ) return resultArea; else return null; @@ -485,49 +473,46 @@ else if (areasPane.getSelectedIndex() == 2) * * @return the selected path, null otherwise */ - private String promptForInnerPath(List innerPaths) { + private String promptForInnerPath( List innerPaths ) { String result = null; - Set sortedPaths = new TreeSet(innerPaths); - for (Iterator it = sortedPaths.iterator(); it.hasNext();) { - if (!it.next().endsWith(".xml")) - it.remove(); + Set sortedPaths = new TreeSet( innerPaths ); + for ( Iterator it = sortedPaths.iterator(); it.hasNext(); ) { + if ( !it.next().endsWith(".xml") ) it.remove(); } - DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("/"); - DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( "/" ); + DefaultTreeModel treeModel = new DefaultTreeModel( rootNode ); - for (String innerPath : sortedPaths) { - buildTreeFromString(treeModel, innerPath); + for ( String innerPath : sortedPaths ) { + buildTreeFromString( treeModel, innerPath ); } - JTree pathTree = new JTree(treeModel); - pathTree.setRootVisible(false); - for (int i = 0; i < pathTree.getRowCount(); i++) { - pathTree.expandRow(i); + JTree pathTree = new JTree( treeModel ); + pathTree.setRootVisible( false ); + for ( int i=0; i < pathTree.getRowCount(); i++ ) { + pathTree.expandRow( i ); } - JScrollPane treeScroll = new JScrollPane(pathTree); - treeScroll.setPreferredSize(new Dimension(pathTree.getPreferredSize().width, 300)); + JScrollPane treeScroll = new JScrollPane( pathTree ); + treeScroll.setPreferredSize( new Dimension( pathTree.getPreferredSize().width, 300 ) ); - pathTree.addAncestorListener(new FocusAncestorListener(pathTree)); + pathTree.addAncestorListener( new FocusAncestorListener( pathTree ) ); - int popupResult = JOptionPane.showOptionDialog(this, treeScroll, "Open an XML Resource", - JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, new String[] { "OK" }, "OK"); + int popupResult = JOptionPane.showOptionDialog( this, treeScroll, "Open an XML Resource", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, new String[]{"OK"}, "OK" ); - if (popupResult == JOptionPane.OK_OPTION) { + if ( popupResult == JOptionPane.OK_OPTION ) { StringBuilder buf = new StringBuilder(); TreePath selectedPath = pathTree.getSelectionPath(); - if (selectedPath != null) { - for (Object o : selectedPath.getPath()) { - DefaultMutableTreeNode pathComp = (DefaultMutableTreeNode) o; - if (!pathComp.isRoot()) { + if ( selectedPath != null ) { + for ( Object o : selectedPath.getPath() ) { + DefaultMutableTreeNode pathComp = (DefaultMutableTreeNode)o; + if ( !pathComp.isRoot() ) { Object userObject = pathComp.getUserObject(); - buf.append(userObject.toString()); + buf.append( userObject.toString() ); } } - if (buf.length() > 0) - result = buf.toString(); + if ( buf.length() > 0 ) result = buf.toString(); } } @@ -535,73 +520,71 @@ private String promptForInnerPath(List innerPaths) { } /** - * Adds TreeNodes, if they don't already exist, based on a shash-delimited - * string. + * Adds TreeNodes, if they don't already exist, based on a shash-delimited string. */ @SuppressWarnings("unchecked") - private void buildTreeFromString(DefaultTreeModel treeModel, String path) { - DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) treeModel.getRoot(); + private void buildTreeFromString( DefaultTreeModel treeModel, String path ) { + DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode)treeModel.getRoot(); DefaultMutableTreeNode currentNode = rootNode; - String[] chunks = path.split("/"); + String[] chunks = path.split( "/" ); - for (int i = 0; i < chunks.length; i++) { + for ( int i=0; i < chunks.length; i++ ) { String chunk = chunks[i]; - if (i < chunks.length - 1) + if ( i < chunks.length-1 ) chunk += "/"; boolean found = false; - Enumeration enumIt = (Enumeration) (Object) currentNode - .children(); - while (enumIt.hasMoreElements()) { + Enumeration enumIt = (Enumeration)(Object)currentNode.children(); + while ( enumIt.hasMoreElements() ) { DefaultMutableTreeNode tmpNode = enumIt.nextElement(); - if (chunk.equals(tmpNode.getUserObject())) { + if ( chunk.equals( tmpNode.getUserObject() ) ) { found = true; currentNode = tmpNode; break; } } - if (!found) { - DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(chunk); - currentNode.insert(newNode, currentNode.getChildCount()); + if ( !found ) { + DefaultMutableTreeNode newNode = new DefaultMutableTreeNode( chunk ); + currentNode.insert( newNode, currentNode.getChildCount() ); currentNode = newNode; } } } + + private class CaretAncestorListener implements AncestorListener { @Override - public void ancestorAdded(AncestorEvent e) { + public void ancestorAdded( AncestorEvent e ) { updateCaretStatus(); } - @Override - public void ancestorMoved(AncestorEvent e) { + public void ancestorMoved( AncestorEvent e ) { } - @Override - public void ancestorRemoved(AncestorEvent e) { + public void ancestorRemoved( AncestorEvent e ) { } } + + private static class FocusAncestorListener implements AncestorListener { private JComponent comp; - public FocusAncestorListener(JComponent comp) { + public FocusAncestorListener( JComponent comp ) { this.comp = comp; } @Override - public void ancestorAdded(AncestorEvent e) { + public void ancestorAdded( AncestorEvent e ) { comp.requestFocusInWindow(); } - @Override - public void ancestorMoved(AncestorEvent e) { + public void ancestorMoved( AncestorEvent e ) { } - @Override - public void ancestorRemoved(AncestorEvent e) { + public void ancestorRemoved( AncestorEvent e ) { } } } From 5bebfd480138f7ad2a738869769552fde4aae134 Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Wed, 27 Oct 2021 11:31:18 +0000 Subject: [PATCH 06/11] excess extensions --- .devcontainer/devcontainer.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8fcea5d..b33cf46 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,9 +17,7 @@ "extensions": [ "vscjava.vscode-java-pack", "vscjava.vscode-java-dependency", - "idleberg.innosetup", "redhat.vscode-xml", - "redhat.fabric8-analytics", "davidanson.vscode-markdownlint", "redhat.vscode-yaml" ], From 7b931d0a07d7cd4efac81bbae3b38f8bd804a503 Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Wed, 27 Oct 2021 11:35:44 +0000 Subject: [PATCH 07/11] minimise diff in pom --- README.md | 4 +- {assets => img}/screenshot01.png | Bin pom.xml | 156 +++++++++++++++---------------- 3 files changed, 78 insertions(+), 82 deletions(-) rename {assets => img}/screenshot01.png (100%) diff --git a/README.md b/README.md index a4d91d6..118a36a 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ mods at the same time and, later, revert to vanilla gameplay. It is the successor to Grognak's Mod Manager ([GMM](https://subsetgames.com/forum/viewtopic.php?p=9994)). -![Screenshot of the mod manager in use](assets/screenshot01.png) +![Screenshot of the mod manager in use](img/screenshot01.png) ## Requirements - Java (1.6 or higher). - - FTL (1.01-1.6.3, Windows/OSX/Linux, Steam/GOG/Standalone). - - + - - WinXP SP1 can't run Java 1.7. - (1.7 was built with VisualStudio 2010, causing a DecodePointer error.) - To get 1.6, you may have to google "jdk-6u45-windows-i586.exe". diff --git a/assets/screenshot01.png b/img/screenshot01.png similarity index 100% rename from assets/screenshot01.png rename to img/screenshot01.png diff --git a/pom.xml b/pom.xml index 6ea97c6..50e8e09 100644 --- a/pom.xml +++ b/pom.xml @@ -10,9 +10,9 @@ 2.2.1 - 1.8 - 1.8 - 1.8 + 1.6 + 1.6 + 1.6 UTF-8 @@ -44,11 +44,10 @@ logback-classic 1.2.3 - - + com.fasterxml.jackson.core jackson-databind - 2.13.0 + 2.13.0 ar.com.hjg @@ -73,83 +72,80 @@ - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - -Xlint:unchecked - -Xlint:deprecation - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.4.1 - - - - jar-with-dependencies - package - - single - - - - jar-with-dependencies - - - - net.vhati.modmanager.FTLModManager - - - Vhati - - - modman - false - false - - - - - dist-win - package - - single - - - - src/main/assembly/dist-win.xml - - SlipstreamModManager_${project.version}-Win - false - - - - - dist-unix - package - - single - - - - src/main/assembly/dist-unix.xml - - SlipstreamModManager_${project.version}-Unix - false - - - - - - + org.apache.maven.plugins + maven-assembly-plugin + 2.4.1 + + + jar-with-dependencies + package + + single + + + + jar-with-dependencies + + + + net.vhati.modmanager.FTLModManager + + + Vhati + + + modman + false + false + + + + dist-win + package + + single + + + + src/main/assembly/dist-win.xml + + SlipstreamModManager_${project.version}-Win + false + + + + dist-unix + package + + single + + + + src/main/assembly/dist-unix.xml + + SlipstreamModManager_${project.version}-Unix + false + + + + + + From e0df8ca419a4053ee4f2dee406e7ad31c1ff78c6 Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Wed, 27 Oct 2021 11:45:06 +0000 Subject: [PATCH 08/11] minimise dockerfile --- .classpath | 2 +- .devcontainer/Dockerfile | 26 ----- .devcontainer/devcontainer.json | 11 +- .markdownlint.yaml | 15 --- .pre-commit-config.yaml | 18 --- .secrets.baseline | 197 -------------------------------- 6 files changed, 3 insertions(+), 266 deletions(-) delete mode 100644 .markdownlint.yaml delete mode 100644 .pre-commit-config.yaml delete mode 100644 .secrets.baseline diff --git a/.classpath b/.classpath index 39abf1c..8b73b29 100644 --- a/.classpath +++ b/.classpath @@ -18,7 +18,7 @@ - + diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 5f40bbd..82801d8 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -4,32 +4,6 @@ ARG VARIANT="15" FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT} -# Install additional OS packages -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends \ - wixl \ - python3-pip - # Install Maven ARG MAVEN_VERSION="" RUN su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\"" - -# Install Node.js -ARG NODE_VERSION="lts/*" -RUN su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1" - -# Install global node packages -RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g \ - markdownlint-cli \ - " 2>&1 - -# Install Python packages -RUN pip3 install \ - pre-commit==2.12.1 \ - detect-secrets==1.1.0 \ - setuptools==39.1.0 - -# Install launch4j -RUN curl -SOLJ https://sourceforge.net/projects/launch4j/files/launch4j-3/3.14/launch4j-3.14-linux-x64.tgz/download && \ - tar zxvf launch4j-3.14-linux-x64.tgz -C /usr/bin && \ - rm launch4j-3.14-linux-x64.tgz diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b33cf46..4bde082 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,15 +1,9 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/java { - "name": "DuckDNSUpdater", + "name": "Slipstream-Mod-Manager", "build": { "dockerfile": "Dockerfile", - "args": { - "VARIANT": "15", - "INSTALL_MAVEN": "true", - "INSTALL_NODE": "true", - "NODE_VERSION": "lts/*" - } }, "settings": { "java.home": "/docker-java-home" @@ -21,6 +15,5 @@ "davidanson.vscode-markdownlint", "redhat.vscode-yaml" ], - "postCreateCommand": "pre-commit install", "remoteUser": "vscode" -} +} \ No newline at end of file diff --git a/.markdownlint.yaml b/.markdownlint.yaml deleted file mode 100644 index be0f9a9..0000000 --- a/.markdownlint.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -MD007: - indent: 4 -MD013: - line_length: 80 - tables: false -MD030: - ul_single: 3 - ol_single: 2 - ul_multi: 3 - ol_multi: 2 -MD033: - allowed_elements: - - pre - - br diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 358793c..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,18 +0,0 @@ -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 - hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace - - repo: https://github.com/Yelp/detect-secrets - rev: v1.1.0 - hooks: - - id: detect-secrets - args: - - --baseline - - .secrets.baseline - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.27.1 - hooks: - - id: markdownlint diff --git a/.secrets.baseline b/.secrets.baseline deleted file mode 100644 index 6c8f82e..0000000 --- a/.secrets.baseline +++ /dev/null @@ -1,197 +0,0 @@ -{ - "version": "1.1.0", - "plugins_used": [ - { - "name": "ArtifactoryDetector" - }, - { - "name": "AWSKeyDetector" - }, - { - "name": "AzureStorageKeyDetector" - }, - { - "name": "Base64HighEntropyString", - "limit": 4.5 - }, - { - "name": "BasicAuthDetector" - }, - { - "name": "CloudantDetector" - }, - { - "name": "HexHighEntropyString", - "limit": 3.0 - }, - { - "name": "IbmCloudIamDetector" - }, - { - "name": "IbmCosHmacDetector" - }, - { - "name": "JwtTokenDetector" - }, - { - "name": "KeywordDetector", - "keyword_exclude": "" - }, - { - "name": "MailchimpDetector" - }, - { - "name": "NpmDetector" - }, - { - "name": "PrivateKeyDetector" - }, - { - "name": "SlackDetector" - }, - { - "name": "SoftlayerDetector" - }, - { - "name": "SquareOAuthDetector" - }, - { - "name": "StripeDetector" - }, - { - "name": "TwilioKeyDetector" - } - ], - "filters_used": [ - { - "path": "detect_secrets.filters.allowlist.is_line_allowlisted" - }, - { - "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies", - "min_level": 2 - }, - { - "path": "detect_secrets.filters.heuristic.is_indirect_reference" - }, - { - "path": "detect_secrets.filters.heuristic.is_likely_id_string" - }, - { - "path": "detect_secrets.filters.heuristic.is_lock_file" - }, - { - "path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string" - }, - { - "path": "detect_secrets.filters.heuristic.is_potential_uuid" - }, - { - "path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign" - }, - { - "path": "detect_secrets.filters.heuristic.is_sequential_string" - }, - { - "path": "detect_secrets.filters.heuristic.is_swagger_file" - }, - { - "path": "detect_secrets.filters.heuristic.is_templated_secret" - } - ], - "results": { - "skel_common/backup/current_catalog.json": [ - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "454b70be301a759838999c60c83ba9d32500a9ef", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "4caca8023a59674f9210d3c93af9334963cda634", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "6e7361fca6cf06aa9e1bc837152219e5e42bd755", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "70791078427537d2f151bff9eb499fa3965fd085", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "7929f477d34a1cf2b23f9e80d7fcf7934b3b5470", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "7c64543f6ab0ee3fc27f6390ec3953a180e157a6", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "7f2cef99fe333412d50d140693854a6f781694be", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "a758c37e8d70b7e4be15f368a0da548f60ac4b9d", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "b40843939fd785c4984d73fa471092e14bc6ad9e", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "c2ecca408cb2333b51ad8bce1daf9df45b4b45bb", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "e0e8fea5e2f3406eaf4c87c2c87826d58a266c64", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "ec8da74216b9c2aa454584ea9fc1c422f00e347e", - "is_verified": false, - "line_number": 1 - }, - { - "type": "Hex High Entropy String", - "filename": "skel_common/backup/current_catalog.json", - "hashed_secret": "ed37981799b51e1a914756e75896724619be8519", - "is_verified": false, - "line_number": 1 - } - ] - }, - "generated_at": "2021-10-27T10:33:58Z" -} From 0851feb6403b0200ce301b91097ef4791dbc6066 Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Wed, 27 Oct 2021 11:50:16 +0000 Subject: [PATCH 09/11] last of the generated boilerplate --- .settings/org.eclipse.core.resources.prefs | 4 ++++ .settings/org.eclipse.jdt.apt.core.prefs | 2 ++ .settings/org.eclipse.jdt.core.prefs | 9 +++++++++ .settings/org.eclipse.m2e.core.prefs | 4 ++++ 4 files changed, 19 insertions(+) create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.apt.core.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..abdea9a --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.apt.core.prefs b/.settings/org.eclipse.jdt.apt.core.prefs new file mode 100644 index 0000000..d4313d4 --- /dev/null +++ b/.settings/org.eclipse.jdt.apt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.apt.aptEnabled=false diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3fc7e86 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 From 912b56a02eba7d078d1f31720cd5fcd4e6cb4abb Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Wed, 27 Oct 2021 16:45:47 +0000 Subject: [PATCH 10/11] minimise diff further by using jdk11 --- .devcontainer/Dockerfile | 2 +- pom.xml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 82801d8..f542ec4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,7 +1,7 @@ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/java/.devcontainer/base.Dockerfile # [Choice] Java version: 11, 15 -ARG VARIANT="15" +ARG VARIANT="11" FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT} # Install Maven diff --git a/pom.xml b/pom.xml index 50e8e09..b235564 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,7 @@ com.fasterxml.jackson.core jackson-databind - 2.13.0 + 2.7.9.2 ar.com.hjg @@ -62,7 +62,7 @@ org.apache.httpcomponents httpclient - 4.5.13 + 4.5.4 info.picocli @@ -70,7 +70,7 @@ 2.2.0 - + @@ -148,4 +148,4 @@ - + \ No newline at end of file From 36b73644c8956b37d6422912855e5196abc0be28 Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Wed, 27 Oct 2021 19:23:21 +0000 Subject: [PATCH 11/11] fix bytecode generation issues --- pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b235564..7801ad0 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 2.2.1 - 1.6 + 11 1.6 1.6 UTF-8 @@ -76,10 +76,11 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.0 -Xlint:unchecked -Xlint:deprecation + 6