├── .gitattributes ├── .gitignore ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java └── fr │ └── flowarg │ └── flowupdaterjsoncreator │ ├── FlowUpdaterJsonCreator.java │ ├── Main.java │ ├── json │ ├── ExternalFile.java │ ├── MCP.java │ └── Mod.java │ ├── processors │ ├── ExternalFileProcessor.java │ ├── IProcessor.java │ ├── MCPProcessor.java │ └── ModProcessor.java │ └── ui │ ├── FxApplication.java │ ├── PanelManager.java │ ├── components │ ├── IMovable.java │ ├── ITakePlace.java │ └── JsonTypeButton.java │ └── panels │ ├── AbstractPanel.java │ ├── BrowsePanel.java │ ├── ChooseJsonTypePanel.java │ ├── EndPanel.java │ ├── IPanel.java │ ├── JsonType.java │ ├── LoadingPanel.java │ ├── Panels.java │ ├── UrlPanel.java │ └── includes │ └── TopPanel.java └── resources └── assets └── icon.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build 3 | .idea 4 | jsoncreator.log -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.github.johnrengelman.shadow' version '6.0.0' 3 | } 4 | 5 | apply plugin: 'java-library' 6 | apply plugin: 'application' 7 | apply plugin: 'idea' 8 | 9 | group 'fr.flowarg' 10 | version '1.2.0' 11 | archivesBaseName = "FlowUpdaterJsonCreator" 12 | 13 | compileJava { 14 | targetCompatibility = sourceCompatibility = JavaVersion.VERSION_1_8 15 | options.encoding = 'UTF-8' 16 | } 17 | 18 | task sourcesJar(type: Jar) { 19 | classifier 'sources' 20 | from sourceSets.main.allSource 21 | } 22 | 23 | repositories { 24 | jcenter() 25 | } 26 | 27 | dependencies { 28 | implementation 'fr.flowarg:flowmultitools:1.2.1' 29 | implementation 'com.jfoenix:jfoenix:8.0.9' 30 | implementation 'com.google.code.gson:gson:2.8.6' 31 | implementation 'de.jensd:fontawesomefx:8.9' 32 | } 33 | 34 | application { 35 | mainClassName = 'fr.flowarg.flowupdaterjsoncreator.Main' 36 | } 37 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlowArg/FlowUpdaterJsonCreator/551b1244db788aa4f66302c80005fbc0f7aaff72/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'FlowUpdaterJsonCreator' 2 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/FlowUpdaterJsonCreator.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator; 2 | 3 | import fr.flowarg.flowlogger.ILogger; 4 | import fr.flowarg.flowlogger.Logger; 5 | import fr.flowarg.flowupdaterjsoncreator.processors.ExternalFileProcessor; 6 | import fr.flowarg.flowupdaterjsoncreator.processors.IProcessor; 7 | import fr.flowarg.flowupdaterjsoncreator.processors.MCPProcessor; 8 | import fr.flowarg.flowupdaterjsoncreator.processors.ModProcessor; 9 | import fr.flowarg.flowupdaterjsoncreator.ui.FxApplication; 10 | import fr.flowarg.flowupdaterjsoncreator.ui.PanelManager; 11 | import javafx.application.Application; 12 | import javafx.stage.Stage; 13 | 14 | public class FlowUpdaterJsonCreator 15 | { 16 | private static FlowUpdaterJsonCreator instance; 17 | private final ILogger logger; 18 | private final IProcessor modProcessor; 19 | private final IProcessor mcpProcessor; 20 | private final IProcessor externalFileProcessor; 21 | private PanelManager panelManager; 22 | 23 | FlowUpdaterJsonCreator() 24 | { 25 | instance = this; 26 | this.logger = new Logger("[JsonCreator]", null); 27 | this.modProcessor = new ModProcessor(); 28 | this.mcpProcessor = new MCPProcessor(); 29 | this.externalFileProcessor = new ExternalFileProcessor(); 30 | } 31 | 32 | public void start() 33 | { 34 | this.logger.info("Starting json creator..."); 35 | try 36 | { 37 | Class.forName("javafx.application.Application"); 38 | } catch (ClassNotFoundException e) 39 | { 40 | this.logger.err("You must have JavaFX !"); 41 | this.shutdown(); 42 | } 43 | Application.launch(FxApplication.class); 44 | } 45 | 46 | public void shutdown() 47 | { 48 | this.logger.info("Shutting down..."); 49 | System.exit(0); 50 | } 51 | 52 | public ILogger getLogger() 53 | { 54 | return this.logger; 55 | } 56 | 57 | public PanelManager getPanelManager() 58 | { 59 | return this.panelManager; 60 | } 61 | 62 | public void setPanelManager(Stage stage) 63 | { 64 | this.panelManager = new PanelManager(this, stage); 65 | } 66 | 67 | public IProcessor getModProcessor() 68 | { 69 | return this.modProcessor; 70 | } 71 | 72 | public IProcessor getMCPProcessor() 73 | { 74 | return this.mcpProcessor; 75 | } 76 | 77 | public IProcessor getExternalFileProcessor() 78 | { 79 | return this.externalFileProcessor; 80 | } 81 | 82 | public static FlowUpdaterJsonCreator getInstance() 83 | { 84 | return instance; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/Main.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator; 2 | 3 | public class Main 4 | { 5 | public static void main(String[] args) 6 | { 7 | new FlowUpdaterJsonCreator().start(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/json/ExternalFile.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.json; 2 | 3 | public class ExternalFile 4 | { 5 | private final String path; 6 | private final String downloadURL; 7 | private final String sha1; 8 | private final long size; 9 | private final boolean update; 10 | 11 | public ExternalFile(String path, String downloadURL, String sha1, long size, boolean update) 12 | { 13 | this.path = path; 14 | this.downloadURL = downloadURL; 15 | this.sha1 = sha1; 16 | this.size = size; 17 | this.update = update; 18 | } 19 | 20 | public ExternalFile(String path, String downloadURL, String sha1, long size) 21 | { 22 | this.path = path; 23 | this.downloadURL = downloadURL; 24 | this.sha1 = sha1; 25 | this.size = size; 26 | this.update = true; 27 | } 28 | 29 | public String getPath() 30 | { 31 | return this.path; 32 | } 33 | 34 | public String getDownloadURL() 35 | { 36 | return this.downloadURL; 37 | } 38 | 39 | public String getSha1() 40 | { 41 | return this.sha1; 42 | } 43 | 44 | public long getSize() 45 | { 46 | return this.size; 47 | } 48 | 49 | public boolean isUpdate() 50 | { 51 | return this.update; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/json/MCP.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.json; 2 | 3 | public class MCP 4 | { 5 | private final String clientDownloadURL; 6 | private final String clientSha1; 7 | private final int clientSize; 8 | 9 | private final String serverDownloadURL; 10 | private final String serverSha1; 11 | private final int serverSize; 12 | 13 | public MCP(String clientDownloadURL, String clientSha1, int clientSize, String serverDownloadURL, String serverSha1, int serverSize) 14 | { 15 | this.clientDownloadURL = clientDownloadURL; 16 | this.clientSha1 = clientSha1; 17 | this.clientSize = clientSize; 18 | this.serverDownloadURL = serverDownloadURL; 19 | this.serverSha1 = serverSha1; 20 | this.serverSize = serverSize; 21 | } 22 | 23 | public String getClientDownloadURL() 24 | { 25 | return this.clientDownloadURL; 26 | } 27 | 28 | public String getClientSha1() 29 | { 30 | return this.clientSha1; 31 | } 32 | 33 | public int getClientSize() 34 | { 35 | return this.clientSize; 36 | } 37 | 38 | public String getServerDownloadURL() 39 | { 40 | return this.serverDownloadURL; 41 | } 42 | 43 | public String getServerSha1() 44 | { 45 | return this.serverSha1; 46 | } 47 | 48 | public int getServerSize() 49 | { 50 | return this.serverSize; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/json/Mod.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.json; 2 | 3 | public class Mod 4 | { 5 | private final String name; 6 | private final String downloadURL; 7 | private final String sha1; 8 | private final long size; 9 | 10 | public Mod(String name, String downloadURL, String sha1, long size) 11 | { 12 | this.name = name; 13 | this.downloadURL = downloadURL; 14 | this.sha1 = sha1; 15 | this.size = size; 16 | } 17 | 18 | public String getName() 19 | { 20 | return this.name; 21 | } 22 | 23 | public String getDownloadURL() 24 | { 25 | return this.downloadURL; 26 | } 27 | 28 | public String getSha1() 29 | { 30 | return this.sha1; 31 | } 32 | 33 | public long getSize() 34 | { 35 | return this.size; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/processors/ExternalFileProcessor.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.processors; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | import com.google.gson.JsonArray; 6 | import com.google.gson.JsonObject; 7 | import fr.flowarg.flowio.FileUtils; 8 | import fr.flowarg.flowupdaterjsoncreator.FlowUpdaterJsonCreator; 9 | import fr.flowarg.flowupdaterjsoncreator.json.ExternalFile; 10 | import fr.flowarg.flowupdaterjsoncreator.ui.panels.Panels; 11 | 12 | import java.io.File; 13 | import java.io.IOException; 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | public class ExternalFileProcessor implements IProcessor 18 | { 19 | private final List externalFiles = new ArrayList<>(); 20 | private String finalJson; 21 | 22 | @Override 23 | public void process(File dir, Object... args) throws Exception 24 | { 25 | this.externalFiles.clear(); 26 | if(dir.listFiles() != null) 27 | for (File extFile : dir.listFiles()) 28 | if(!extFile.isDirectory()) 29 | this.externalFiles.add(new ExternalFile(extFile.getName(), Panels.URL_PANEL.getDefaultUrl() + extFile.getName(), FileUtils.getSHA1(extFile), FileUtils.getFileSizeBytes(extFile))); 30 | else 31 | { 32 | for (File sub : this.getSubFiles(extFile)) 33 | this.externalFiles.add(new ExternalFile(sub.getAbsolutePath().replace(dir.getAbsolutePath() + File.separator, ""), Panels.URL_PANEL.getDefaultUrl() + sub.getAbsolutePath().replace(dir.getAbsolutePath() + File.separator, ""), FileUtils.getSHA1(sub), FileUtils.getFileSizeBytes(sub))); 34 | } 35 | } 36 | 37 | private List getSubFiles(File fi) 38 | { 39 | final List files = new ArrayList<>(); 40 | 41 | for(File file : fi.listFiles()) 42 | { 43 | if(file.isDirectory()) 44 | files.addAll(this.getSubFiles(file)); 45 | else files.add(file); 46 | } 47 | 48 | return files; 49 | } 50 | 51 | @Override 52 | public void generate(Object... args) 53 | { 54 | final JsonObject object = new JsonObject(); 55 | final JsonArray extFilesArray = new JsonArray(this.externalFiles.size()); 56 | final Gson gson = new GsonBuilder().setPrettyPrinting().create(); 57 | this.externalFiles.forEach(extFile -> { 58 | final JsonObject extFileObject = new JsonObject(); 59 | extFileObject.addProperty("path", extFile.getPath()); 60 | extFileObject.addProperty("downloadURL", extFile.getDownloadURL()); 61 | extFileObject.addProperty("sha1", extFile.getSha1()); 62 | extFileObject.addProperty("size", extFile.getSize()); 63 | extFilesArray.add(extFileObject); 64 | }); 65 | object.add("extfiles", extFilesArray); 66 | 67 | this.finalJson = gson.toJson(object); 68 | } 69 | 70 | @Override 71 | public void save(File file, Object... args) 72 | { 73 | try 74 | { 75 | FileUtils.saveFile(file, this.finalJson); 76 | } catch (IOException e) 77 | { 78 | FlowUpdaterJsonCreator.getInstance().getLogger().printStackTrace(e); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/processors/IProcessor.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.processors; 2 | 3 | import java.io.File; 4 | 5 | public interface IProcessor 6 | { 7 | void process(File dir, Object... args) throws Exception; 8 | void generate(Object... args); 9 | void save(File file, Object... args); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/processors/MCPProcessor.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.processors; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | import com.google.gson.JsonObject; 6 | import fr.flowarg.flowio.FileUtils; 7 | import fr.flowarg.flowupdaterjsoncreator.FlowUpdaterJsonCreator; 8 | import fr.flowarg.flowupdaterjsoncreator.json.MCP; 9 | import fr.flowarg.flowupdaterjsoncreator.ui.panels.Panels; 10 | 11 | import java.io.File; 12 | import java.io.IOException; 13 | 14 | public class MCPProcessor implements IProcessor 15 | { 16 | private MCP mcp; 17 | private String finalJson; 18 | 19 | @Override 20 | public void process(File dir, Object... args) throws Exception 21 | { 22 | final File client = new File(dir, "client.jar"); 23 | final boolean clientExist = client.exists(); 24 | final File server = new File(dir, "server.jar"); 25 | final boolean serverExist = server.exists(); 26 | this.mcp = new MCP(clientExist ? Panels.URL_PANEL.getDefaultUrl() + client.getName() : "", clientExist ? FileUtils.getSHA1(client) : "", clientExist ? (int)FileUtils.getFileSizeBytes(client) : -1, 27 | serverExist ? Panels.URL_PANEL.getDefaultUrl() + server.getName() : "", serverExist ? FileUtils.getSHA1(server) : "", serverExist ? (int)FileUtils.getFileSizeBytes(server) : -1); 28 | } 29 | 30 | @Override 31 | public void generate(Object... args) 32 | { 33 | final JsonObject object = new JsonObject(); 34 | object.addProperty("clientURL", this.mcp.getClientDownloadURL()); 35 | object.addProperty("clientSha1", this.mcp.getClientSha1()); 36 | object.addProperty("clientSize", this.mcp.getClientSize()); 37 | object.addProperty("serverURL", this.mcp.getServerDownloadURL()); 38 | object.addProperty("serverSha1", this.mcp.getServerSha1()); 39 | object.addProperty("serverSize", this.mcp.getServerSize()); 40 | final Gson gson = new GsonBuilder().setPrettyPrinting().create(); 41 | this.finalJson = gson.toJson(object); 42 | } 43 | 44 | @Override 45 | public void save(File file, Object... args) 46 | { 47 | try 48 | { 49 | FileUtils.saveFile(file, this.finalJson); 50 | } catch (IOException e) 51 | { 52 | FlowUpdaterJsonCreator.getInstance().getLogger().printStackTrace(e); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/processors/ModProcessor.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.processors; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | import com.google.gson.JsonArray; 6 | import com.google.gson.JsonObject; 7 | import fr.flowarg.flowio.FileUtils; 8 | import fr.flowarg.flowupdaterjsoncreator.FlowUpdaterJsonCreator; 9 | import fr.flowarg.flowupdaterjsoncreator.json.Mod; 10 | import fr.flowarg.flowupdaterjsoncreator.ui.panels.Panels; 11 | 12 | import java.io.File; 13 | import java.io.IOException; 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | public class ModProcessor implements IProcessor 18 | { 19 | private final List mods = new ArrayList<>(); 20 | private String finalJson; 21 | 22 | @Override 23 | public void process(File dir, Object... args) throws Exception 24 | { 25 | this.mods.clear(); 26 | if(dir.listFiles() != null) 27 | for (File mod : dir.listFiles()) 28 | if(!mod.isDirectory()) 29 | mods.add(new Mod(mod.getName(), Panels.URL_PANEL.getDefaultUrl() + "mods/" + mod.getName(), FileUtils.getSHA1(mod), FileUtils.getFileSizeBytes(mod))); 30 | } 31 | 32 | @Override 33 | public void generate(Object... args) 34 | { 35 | final JsonObject object = new JsonObject(); 36 | final JsonArray modArray = new JsonArray(this.mods.size()); 37 | final Gson gson = new GsonBuilder().setPrettyPrinting().create(); 38 | this.mods.forEach(mod -> { 39 | final JsonObject modObject = new JsonObject(); 40 | modObject.addProperty("name", mod.getName()); 41 | modObject.addProperty("downloadURL", mod.getDownloadURL()); 42 | modObject.addProperty("sha1", mod.getSha1()); 43 | modObject.addProperty("size", mod.getSize()); 44 | modArray.add(modObject); 45 | }); 46 | object.add("mods", modArray); 47 | 48 | this.finalJson = gson.toJson(object); 49 | } 50 | 51 | @Override 52 | public void save(File file, Object... args) 53 | { 54 | try 55 | { 56 | FileUtils.saveFile(file, this.finalJson); 57 | } catch (IOException e) 58 | { 59 | FlowUpdaterJsonCreator.getInstance().getLogger().printStackTrace(e); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/FxApplication.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui; 2 | 3 | import fr.flowarg.flowupdaterjsoncreator.FlowUpdaterJsonCreator; 4 | import fr.flowarg.flowupdaterjsoncreator.ui.panels.Panels; 5 | import javafx.application.Application; 6 | import javafx.stage.Stage; 7 | 8 | public class FxApplication extends Application 9 | { 10 | @Override 11 | public void start(Stage stage) 12 | { 13 | final FlowUpdaterJsonCreator jsonCreator = FlowUpdaterJsonCreator.getInstance(); 14 | jsonCreator.setPanelManager(stage); 15 | jsonCreator.getPanelManager().init(); 16 | jsonCreator.getPanelManager().showPanel(Panels.URL_PANEL); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/PanelManager.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui; 2 | 3 | import fr.flowarg.flowupdaterjsoncreator.FlowUpdaterJsonCreator; 4 | import fr.flowarg.flowupdaterjsoncreator.Main; 5 | import fr.flowarg.flowupdaterjsoncreator.ui.panels.IPanel; 6 | import fr.flowarg.flowupdaterjsoncreator.ui.panels.includes.TopPanel; 7 | import javafx.geometry.VPos; 8 | import javafx.scene.Scene; 9 | import javafx.scene.image.Image; 10 | import javafx.scene.layout.GridPane; 11 | import javafx.scene.layout.Priority; 12 | import javafx.scene.layout.RowConstraints; 13 | import javafx.stage.Stage; 14 | import javafx.stage.StageStyle; 15 | 16 | public class PanelManager 17 | { 18 | private final FlowUpdaterJsonCreator jsonCreator; 19 | private final Stage stage; 20 | private final IPanel topPanel; 21 | private final GridPane centerPanel; 22 | 23 | public PanelManager(FlowUpdaterJsonCreator jsonCreator, Stage stage) 24 | { 25 | this.jsonCreator = jsonCreator; 26 | this.stage = stage; 27 | this.topPanel = new TopPanel(); 28 | this.centerPanel = new GridPane(); 29 | } 30 | 31 | public void init() 32 | { 33 | this.stage.getIcons().add(new Image(Main.class.getResourceAsStream("/assets/icon.png"))); 34 | this.stage.setTitle("FlowUpdater - JsonEditor"); 35 | this.stage.setMinWidth(1280); 36 | this.stage.setMinHeight(720); 37 | this.stage.setWidth(1280); 38 | this.stage.setHeight(720); 39 | this.stage.initStyle(StageStyle.UNDECORATED); 40 | this.stage.show(); 41 | this.stage.centerOnScreen(); 42 | 43 | final GridPane layout = new GridPane(); 44 | this.setBackground(layout); 45 | this.stage.setScene(new Scene(layout)); 46 | 47 | final RowConstraints topPanelRules = new RowConstraints(); 48 | topPanelRules.setValignment(VPos.TOP); 49 | topPanelRules.setMaxHeight(27); 50 | topPanelRules.setMinHeight(27); 51 | 52 | layout.getRowConstraints().addAll(topPanelRules, new RowConstraints()); 53 | layout.add(this.topPanel.getLayout(), 0, 0); 54 | 55 | this.topPanel.init(this); 56 | layout.add(this.centerPanel, 0, 1); 57 | GridPane.setHgrow(this.centerPanel, Priority.ALWAYS); 58 | GridPane.setVgrow(this.centerPanel, Priority.ALWAYS); 59 | } 60 | 61 | public void showPanel(IPanel panel) 62 | { 63 | this.jsonCreator.getLogger().debug("Opening : " + panel.getName()); 64 | this.centerPanel.getChildren().clear(); 65 | this.centerPanel.getChildren().add(panel.getLayout()); 66 | panel.init(this); 67 | panel.onShow(); 68 | } 69 | 70 | public void setBackground(GridPane layout) 71 | { 72 | layout.setStyle("-fx-background-color: rgb(28,27,27);" + "-fx-backgound-repeat: skretch;" + "-fx-backgound-position: center;" + "-fx-background-size: cover;"); 73 | } 74 | 75 | public Stage getStage() 76 | { 77 | return this.stage; 78 | } 79 | 80 | public FlowUpdaterJsonCreator getJsonCreator() 81 | { 82 | return this.jsonCreator; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/components/IMovable.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.components; 2 | 3 | import javafx.scene.Node; 4 | 5 | public interface IMovable 6 | { 7 | void setLeft(Node node); 8 | void setRight(Node node); 9 | void setTop(Node node); 10 | void setBottom(Node node); 11 | void setBaseLine(Node node); 12 | void setCenterH(Node node); 13 | void setCenterV(Node node); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/components/ITakePlace.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.components; 2 | 3 | import javafx.scene.Node; 4 | import javafx.scene.layout.GridPane; 5 | import javafx.scene.layout.Priority; 6 | 7 | public interface ITakePlace 8 | { 9 | default void setCanTakeAllSize(Node node) 10 | { 11 | GridPane.setHgrow(node, Priority.ALWAYS); 12 | GridPane.setVgrow(node, Priority.ALWAYS); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/components/JsonTypeButton.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.components; 2 | 3 | import com.jfoenix.controls.JFXButton; 4 | import fr.flowarg.flowupdaterjsoncreator.FlowUpdaterJsonCreator; 5 | import fr.flowarg.flowupdaterjsoncreator.ui.panels.BrowsePanel; 6 | import fr.flowarg.flowupdaterjsoncreator.ui.panels.JsonType; 7 | import javafx.scene.Cursor; 8 | import javafx.scene.layout.GridPane; 9 | import javafx.scene.text.Font; 10 | 11 | public class JsonTypeButton extends GridPane implements ITakePlace 12 | { 13 | public JsonTypeButton(JsonType type) 14 | { 15 | this.setMinSize(230, 80); 16 | this.setMaxSize(230, 80); 17 | final JFXButton button = new JFXButton(type.getButtonName()); 18 | button.setFont(Font.font("Consolas", 24)); 19 | button.setButtonType(JFXButton.ButtonType.RAISED); 20 | button.setStyle("-fx-background-color: rgb(59,58,58); -fx-text-fill: white;"); 21 | button.setMaxSize(230, 80); 22 | button.setMinSize(230, 80); 23 | button.setOnMouseEntered(event -> button.setCursor(Cursor.HAND)); 24 | button.setOnMouseExited(event -> button.setCursor(Cursor.DEFAULT)); 25 | button.setOnMouseClicked(event -> FlowUpdaterJsonCreator.getInstance().getPanelManager().showPanel(new BrowsePanel(type))); 26 | this.add(button, 0, 0); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/panels/AbstractPanel.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.panels; 2 | 3 | import fr.flowarg.flowlogger.ILogger; 4 | import fr.flowarg.flowupdaterjsoncreator.FlowUpdaterJsonCreator; 5 | import fr.flowarg.flowupdaterjsoncreator.ui.PanelManager; 6 | import fr.flowarg.flowupdaterjsoncreator.ui.components.IMovable; 7 | import javafx.animation.FadeTransition; 8 | import javafx.geometry.HPos; 9 | import javafx.geometry.VPos; 10 | import javafx.scene.Node; 11 | import javafx.scene.layout.GridPane; 12 | import javafx.scene.layout.Priority; 13 | import javafx.util.Duration; 14 | 15 | public abstract class AbstractPanel implements IPanel, IMovable 16 | { 17 | protected GridPane layout = new GridPane(); 18 | protected PanelManager panelManager; 19 | protected final ILogger logger; 20 | 21 | public AbstractPanel() 22 | { 23 | this.logger = FlowUpdaterJsonCreator.getInstance().getLogger(); 24 | } 25 | 26 | @Override 27 | public void init(PanelManager panelManager) 28 | { 29 | this.panelManager = panelManager; 30 | GridPane.setHgrow(this.layout, Priority.ALWAYS); 31 | GridPane.setVgrow(this.layout, Priority.ALWAYS); 32 | } 33 | 34 | @Override 35 | public GridPane getLayout() 36 | { 37 | return this.layout; 38 | } 39 | 40 | @Override 41 | public void onShow() 42 | { 43 | final FadeTransition transition = new FadeTransition(Duration.seconds(1), this.layout); 44 | transition.setFromValue(0); 45 | transition.setToValue(1); 46 | transition.setAutoReverse(true); 47 | transition.play(); 48 | } 49 | 50 | @Override 51 | public abstract String getName(); 52 | 53 | @Override 54 | public void setLeft(Node node) 55 | { 56 | GridPane.setHalignment(node, HPos.LEFT); 57 | } 58 | 59 | @Override 60 | public void setRight(Node node) 61 | { 62 | GridPane.setHalignment(node, HPos.RIGHT); 63 | } 64 | 65 | @Override 66 | public void setTop(Node node) 67 | { 68 | GridPane.setValignment(node, VPos.TOP); 69 | } 70 | 71 | @Override 72 | public void setBottom(Node node) 73 | { 74 | GridPane.setValignment(node, VPos.BOTTOM); 75 | } 76 | 77 | @Override 78 | public void setBaseLine(Node node) 79 | { 80 | GridPane.setValignment(node, VPos.BASELINE); 81 | } 82 | 83 | @Override 84 | public void setCenterH(Node node) 85 | { 86 | GridPane.setHalignment(node, HPos.CENTER); 87 | } 88 | 89 | @Override 90 | public void setCenterV(Node node) 91 | { 92 | GridPane.setValignment(node, VPos.CENTER); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/panels/BrowsePanel.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.panels; 2 | 3 | import com.jfoenix.controls.JFXButton; 4 | import fr.flowarg.flowupdaterjsoncreator.FlowUpdaterJsonCreator; 5 | import fr.flowarg.flowupdaterjsoncreator.processors.IProcessor; 6 | import fr.flowarg.flowupdaterjsoncreator.ui.PanelManager; 7 | import javafx.application.Platform; 8 | import javafx.scene.Cursor; 9 | import javafx.scene.control.Alert; 10 | import javafx.scene.control.Label; 11 | import javafx.scene.paint.Color; 12 | import javafx.scene.text.Font; 13 | import javafx.stage.DirectoryChooser; 14 | import javafx.stage.FileChooser; 15 | 16 | import java.io.File; 17 | import java.util.concurrent.atomic.AtomicReference; 18 | 19 | public class BrowsePanel extends AbstractPanel 20 | { 21 | private final JsonType type; 22 | 23 | public BrowsePanel(JsonType type) 24 | { 25 | this.type = type; 26 | } 27 | 28 | @Override 29 | public void init(PanelManager panelManager) 30 | { 31 | super.init(panelManager); 32 | final Label action = new Label(this.type.getLabelText()); 33 | action.setFont(Font.font("Consolas", 48)); 34 | action.setTextFill(Color.WHITE); 35 | 36 | final JFXButton button = new JFXButton("Browse"); 37 | button.setFont(Font.font("Consolas", 38)); 38 | button.setButtonType(JFXButton.ButtonType.RAISED); 39 | button.setStyle("-fx-background-color: rgb(59,58,58); -fx-text-fill: white;"); 40 | button.setMaxSize(430, 100); 41 | button.setMinSize(430, 100); 42 | button.setOnMouseEntered(event -> button.setCursor(Cursor.HAND)); 43 | button.setOnMouseExited(event -> button.setCursor(Cursor.DEFAULT)); 44 | button.setOnMouseClicked(event -> { 45 | button.setCursor(Cursor.DEFAULT); 46 | final DirectoryChooser chooser = new DirectoryChooser(); 47 | chooser.setTitle(this.type.getLabelText()); 48 | final File file = chooser.showDialog(this.panelManager.getStage()); 49 | if(file != null) 50 | { 51 | this.panelManager.showPanel(Panels.LOADING_PANEL); 52 | new Thread(() -> { 53 | IProcessor processor; 54 | switch (this.type) 55 | { 56 | case MCP: 57 | processor = this.panelManager.getJsonCreator().getMCPProcessor(); 58 | break; 59 | case EXT_FILES: 60 | processor = this.panelManager.getJsonCreator().getExternalFileProcessor(); 61 | break; 62 | default: 63 | processor = this.panelManager.getJsonCreator().getModProcessor(); 64 | break; 65 | } 66 | try 67 | { 68 | processor.process(file); 69 | } catch (Exception e) 70 | { 71 | FlowUpdaterJsonCreator.getInstance().getLogger().printStackTrace(e); 72 | } 73 | processor.generate(); 74 | final AtomicReference jsonFile = new AtomicReference<>(null); 75 | Platform.runLater(() -> { 76 | final Alert alert = new Alert(Alert.AlertType.INFORMATION); 77 | alert.setTitle("Next step"); 78 | alert.setContentText("Now, you have to select the output JSON file !"); 79 | alert.showAndWait(); 80 | final FileChooser jsonFileChooser = new FileChooser(); 81 | jsonFileChooser.setInitialFileName(this.type.getDefaultFileName()); 82 | jsonFileChooser.setTitle("Choose output JSON file"); 83 | jsonFileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("JavaScript Object Notation JSON", "*.json")); 84 | jsonFile.set(jsonFileChooser.showSaveDialog(this.panelManager.getStage())); 85 | if(jsonFile.get() != null) 86 | { 87 | processor.save(jsonFile.get()); 88 | this.panelManager.showPanel(Panels.END_PANEL); 89 | } 90 | else this.panelManager.showPanel(new BrowsePanel(this.type)); 91 | }); 92 | }).start(); 93 | } 94 | }); 95 | 96 | this.setCenterH(action); 97 | this.setCenterH(button); 98 | this.setCenterV(action); 99 | this.setCenterV(button); 100 | this.setCanTakeAllSize(action); 101 | this.setCanTakeAllSize(button); 102 | 103 | action.setTranslateY(-80); 104 | button.setTranslateY(60); 105 | 106 | this.layout.getChildren().addAll(action, button); 107 | } 108 | 109 | @Override 110 | public String getName() 111 | { 112 | return "Generation panel"; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/panels/ChooseJsonTypePanel.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.panels; 2 | 3 | import fr.flowarg.flowupdaterjsoncreator.ui.PanelManager; 4 | import fr.flowarg.flowupdaterjsoncreator.ui.components.JsonTypeButton; 5 | import javafx.scene.layout.GridPane; 6 | 7 | class ChooseJsonTypePanel extends AbstractPanel 8 | { 9 | @Override 10 | public void init(PanelManager panelManager) 11 | { 12 | super.init(panelManager); 13 | final GridPane mods = new JsonTypeButton(JsonType.MODS); 14 | final GridPane externalFiles = new JsonTypeButton(JsonType.EXT_FILES); 15 | final GridPane mcp = new JsonTypeButton(JsonType.MCP); 16 | 17 | mods.setTranslateY(20); 18 | mcp.setTranslateY(-20); 19 | 20 | this.setTop(mods); 21 | this.setCenterV(externalFiles); 22 | this.setBottom(mcp); 23 | 24 | this.setCenterH(mods); 25 | this.setCenterH(externalFiles); 26 | this.setCenterH(mcp); 27 | 28 | this.setCanTakeAllSize(mods); 29 | this.setCanTakeAllSize(externalFiles); 30 | this.setCanTakeAllSize(mcp); 31 | 32 | this.layout.getChildren().addAll(mods, externalFiles, mcp); 33 | } 34 | 35 | @Override 36 | public String getName() 37 | { 38 | return "Choose JsonType panel"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/panels/EndPanel.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.panels; 2 | 3 | import com.jfoenix.controls.JFXButton; 4 | import fr.flowarg.flowupdaterjsoncreator.FlowUpdaterJsonCreator; 5 | import fr.flowarg.flowupdaterjsoncreator.ui.PanelManager; 6 | import javafx.scene.Cursor; 7 | import javafx.scene.control.Label; 8 | import javafx.scene.paint.Color; 9 | import javafx.scene.text.Font; 10 | 11 | class EndPanel extends AbstractPanel 12 | { 13 | @Override 14 | public void init(PanelManager panelManager) 15 | { 16 | super.init(panelManager); 17 | final String text = Panels.URL_PANEL.getDefaultUrl().equals("/") ? "Don't forget to add manually\ndownload urls in the json file !" : "Don't forget to check if\n the json is correct !"; 18 | final Label label = new Label(text); 19 | final JFXButton button = new JFXButton("Exit"); 20 | button.setButtonType(JFXButton.ButtonType.RAISED); 21 | button.setStyle("-fx-background-color: rgb(59,58,58); -fx-text-fill: white;"); 22 | button.setMaxSize(400, 90); 23 | button.setMinSize(400, 90); 24 | button.setTranslateY(60); 25 | button.setOnMouseEntered(event -> button.setCursor(Cursor.HAND)); 26 | button.setOnMouseExited(event -> button.setCursor(Cursor.DEFAULT)); 27 | button.setOnMouseClicked(event -> { 28 | button.setCursor(Cursor.DEFAULT); 29 | FlowUpdaterJsonCreator.getInstance().shutdown(); 30 | }); 31 | button.setFont(Font.font("Consolas", 38)); 32 | label.setFont(Font.font("Consolas", 32)); 33 | label.setTranslateY(-45); 34 | label.setTextFill(Color.WHITE); 35 | this.setCenterH(label); 36 | this.setCenterV(label); 37 | this.setCanTakeAllSize(label); 38 | this.setCenterH(button); 39 | this.setCenterV(button); 40 | this.setCanTakeAllSize(button); 41 | this.layout.getChildren().addAll(label, button); 42 | } 43 | 44 | @Override 45 | public String getName() 46 | { 47 | return "End panel"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/panels/IPanel.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.panels; 2 | 3 | import fr.flowarg.flowupdaterjsoncreator.ui.PanelManager; 4 | import fr.flowarg.flowupdaterjsoncreator.ui.components.ITakePlace; 5 | import javafx.scene.layout.GridPane; 6 | 7 | public interface IPanel extends ITakePlace 8 | { 9 | void init(PanelManager panelManager); 10 | GridPane getLayout(); 11 | void onShow(); 12 | String getName(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/panels/JsonType.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.panels; 2 | 3 | public enum JsonType 4 | { 5 | MODS("Select mods directory", "mods.json", "Mods"), 6 | EXT_FILES("Select external files directory", "externalfiles.json", "External Files"), 7 | MCP("Select mcp directory", "mcp.json", "MCP"); 8 | 9 | private final String labelText; 10 | private final String defaultFileName; 11 | private final String buttonName; 12 | 13 | JsonType(String labelText, String defaultFileName, String buttonName) 14 | { 15 | this.labelText = labelText; 16 | this.defaultFileName = defaultFileName; 17 | this.buttonName = buttonName; 18 | } 19 | 20 | public String getLabelText() 21 | { 22 | return this.labelText; 23 | } 24 | 25 | public String getDefaultFileName() 26 | { 27 | return this.defaultFileName; 28 | } 29 | 30 | public String getButtonName() 31 | { 32 | return this.buttonName; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/panels/LoadingPanel.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.panels; 2 | 3 | import com.jfoenix.controls.JFXSpinner; 4 | import fr.flowarg.flowupdaterjsoncreator.ui.PanelManager; 5 | 6 | class LoadingPanel extends AbstractPanel 7 | { 8 | @Override 9 | public void init(PanelManager panelManager) 10 | { 11 | super.init(panelManager); 12 | final JFXSpinner spinner = new JFXSpinner(); 13 | spinner.setRadius(200); 14 | this.setCenterH(spinner); 15 | this.setCenterV(spinner); 16 | this.setCanTakeAllSize(spinner); 17 | this.layout.getChildren().add(spinner); 18 | } 19 | 20 | @Override 21 | public String getName() 22 | { 23 | return "Loading panel"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/panels/Panels.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.panels; 2 | 3 | public class Panels 4 | { 5 | public static final ChooseJsonTypePanel CHOOSE_JSON_TYPE_PANEL = new ChooseJsonTypePanel(); 6 | public static final LoadingPanel LOADING_PANEL = new LoadingPanel(); 7 | public static final EndPanel END_PANEL = new EndPanel(); 8 | public static final UrlPanel URL_PANEL = new UrlPanel(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/panels/UrlPanel.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.panels; 2 | 3 | import com.jfoenix.controls.JFXButton; 4 | import com.jfoenix.controls.JFXTextArea; 5 | import fr.flowarg.flowupdaterjsoncreator.ui.PanelManager; 6 | import javafx.scene.Cursor; 7 | import javafx.scene.control.Label; 8 | import javafx.scene.paint.Color; 9 | import javafx.scene.text.Font; 10 | 11 | public class UrlPanel extends AbstractPanel 12 | { 13 | private String defaultUrl = "/"; 14 | 15 | @Override 16 | public void init(PanelManager panelManager) 17 | { 18 | super.init(panelManager); 19 | 20 | final Label enterUrl = new Label("Enter the default URL"); 21 | enterUrl.setFont(Font.font("Consolas", 48)); 22 | enterUrl.setTextFill(Color.WHITE); 23 | 24 | final JFXTextArea urlArea = new JFXTextArea(); 25 | urlArea.setMinSize(400, 90); 26 | urlArea.setMaxSize(400, 90); 27 | urlArea.setFocusColor(Color.WHITE); 28 | urlArea.setUnFocusColor(Color.BLUEVIOLET); 29 | urlArea.setFocusTraversable(false); 30 | urlArea.setStyle("-fx-text-fill: white;"); 31 | urlArea.setFont(Font.font("Consolas", 24)); 32 | 33 | final JFXButton skip = new JFXButton("Skip this step ?"); 34 | skip.setUnderline(true); 35 | skip.setStyle("-fx-text-fill: white; -fx-background-color: rgba(0, 0, 0, 0);"); 36 | skip.setButtonType(JFXButton.ButtonType.RAISED); 37 | skip.setOnMouseEntered(event -> skip.setCursor(Cursor.HAND)); 38 | skip.setOnMouseExited(event -> skip.setCursor(Cursor.DEFAULT)); 39 | skip.setOnMouseClicked(event -> { 40 | skip.setCursor(Cursor.DEFAULT); 41 | panelManager.showPanel(Panels.CHOOSE_JSON_TYPE_PANEL); 42 | }); 43 | skip.setFont(Font.font("Consolas", 22)); 44 | skip.setFocusTraversable(false); 45 | 46 | final JFXButton enter = new JFXButton("Done"); 47 | enter.setFont(Font.font("Consolas", 34)); 48 | enter.setButtonType(JFXButton.ButtonType.RAISED); 49 | enter.setStyle("-fx-text-fill: white; -fx-background-color: rgb(59, 58, 58);"); 50 | enter.setOnMouseEntered(event -> enter.setCursor(Cursor.HAND)); 51 | enter.setOnMouseExited(event -> enter.setCursor(Cursor.DEFAULT)); 52 | enter.setOnMouseClicked(event -> { 53 | final String txt = urlArea.getText(); 54 | if(txt.contains("\n") || txt.contains("\t") || txt.trim().equalsIgnoreCase("") || !txt.contains("://")) 55 | { 56 | enterUrl.setText("Invalid URL !"); 57 | enterUrl.setTextFill(Color.RED); 58 | } 59 | else 60 | { 61 | skip.setCursor(Cursor.DEFAULT); 62 | this.defaultUrl = urlArea.getText(); 63 | panelManager.showPanel(Panels.CHOOSE_JSON_TYPE_PANEL); 64 | } 65 | }); 66 | enter.setFocusTraversable(false); 67 | 68 | this.setCenterH(enterUrl); 69 | this.setCenterV(enterUrl); 70 | this.setCenterV(urlArea); 71 | this.setCenterH(urlArea); 72 | this.setCenterH(skip); 73 | this.setCenterV(skip); 74 | this.setCenterH(enter); 75 | this.setCenterV(enter); 76 | this.setCanTakeAllSize(enterUrl); 77 | this.setCanTakeAllSize(urlArea); 78 | this.setCanTakeAllSize(skip); 79 | this.setCanTakeAllSize(enter); 80 | 81 | enterUrl.setTranslateY(-60); 82 | urlArea.setTranslateY(20); 83 | skip.setTranslateY(250); 84 | enter.setTranslateY(120); 85 | 86 | this.getLayout().getChildren().addAll(enterUrl, urlArea, skip, enter); 87 | } 88 | 89 | @Override 90 | public String getName() 91 | { 92 | return "UrlPanel"; 93 | } 94 | 95 | public String getDefaultUrl() 96 | { 97 | return this.defaultUrl.endsWith("/") ? this.defaultUrl : this.defaultUrl + '/'; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/fr/flowarg/flowupdaterjsoncreator/ui/panels/includes/TopPanel.java: -------------------------------------------------------------------------------- 1 | package fr.flowarg.flowupdaterjsoncreator.ui.panels.includes; 2 | 3 | import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; 4 | import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView; 5 | import fr.flowarg.flowupdaterjsoncreator.Main; 6 | import fr.flowarg.flowupdaterjsoncreator.ui.PanelManager; 7 | import fr.flowarg.flowupdaterjsoncreator.ui.panels.AbstractPanel; 8 | import javafx.scene.control.Label; 9 | import javafx.scene.image.Image; 10 | import javafx.scene.image.ImageView; 11 | import javafx.scene.layout.GridPane; 12 | import javafx.scene.layout.Priority; 13 | import javafx.scene.paint.Color; 14 | import javafx.scene.text.Font; 15 | import javafx.scene.text.FontPosture; 16 | import javafx.scene.text.FontWeight; 17 | 18 | public class TopPanel extends AbstractPanel 19 | { 20 | private static double xOffset = 0; 21 | private static double yOffset = 0; 22 | 23 | @Override 24 | public void init(PanelManager panelManager) 25 | { 26 | super.init(panelManager); 27 | 28 | this.layout.setStyle("-fx-background-color: rgb(31,35,37);"); 29 | 30 | final GridPane topBarButton = new GridPane(); 31 | final Label title = new Label(); 32 | 33 | this.layout.getChildren().add(topBarButton); 34 | this.layout.getChildren().add(title); 35 | title.setFont(Font.font("Consolas", FontWeight.THIN, FontPosture.REGULAR, 19.0f)); 36 | title.setStyle("-fx-text-fill: white;"); 37 | title.setText("FlowUpdater - JsonCreator"); 38 | 39 | this.setCenterH(title); 40 | topBarButton.setMinWidth(100); 41 | topBarButton.setMaxWidth(100); 42 | 43 | this.setCanTakeAllSize(topBarButton); 44 | this.setRight(topBarButton); 45 | 46 | final MaterialDesignIconView close = new MaterialDesignIconView(MaterialDesignIcon.WINDOW_CLOSE); 47 | final MaterialDesignIconView resize = new MaterialDesignIconView(MaterialDesignIcon.WINDOW_MAXIMIZE); 48 | final MaterialDesignIconView minimize = new MaterialDesignIconView(MaterialDesignIcon.WINDOW_MINIMIZE); 49 | final Image iconImage = new Image(Main.class.getResourceAsStream("/assets/icon.png")); 50 | final ImageView icon = new ImageView(iconImage); 51 | 52 | GridPane.setVgrow(close, Priority.ALWAYS); 53 | GridPane.setVgrow(resize, Priority.ALWAYS); 54 | GridPane.setVgrow(minimize, Priority.ALWAYS); 55 | GridPane.setVgrow(icon, Priority.ALWAYS); 56 | 57 | icon.setFitHeight(27); 58 | icon.setFitWidth(27); 59 | 60 | this.setLeft(icon); 61 | icon.setTranslateX(7); 62 | icon.setTranslateY(1); 63 | 64 | this.layout.getChildren().add(icon); 65 | 66 | close.setFill(Color.WHITE); 67 | close.setOpacity(0.70d); 68 | close.setSize("30px"); 69 | close.setOnMouseEntered(event -> close.setOpacity(1.0d)); 70 | close.setOnMouseExited(event -> close.setOpacity(0.70d)); 71 | close.setOnMouseClicked(event -> panelManager.getJsonCreator().shutdown()); 72 | close.setTranslateX(65); 73 | 74 | resize.setFill(Color.WHITE); 75 | resize.setOpacity(0.70d); 76 | resize.setSize("28px"); 77 | resize.setOnMouseEntered(event -> resize.setOpacity(1.0d)); 78 | resize.setOnMouseExited(event -> resize.setOpacity(0.70d)); 79 | resize.setOnMouseClicked(event -> this.panelManager.getStage().setMaximized(!this.panelManager.getStage().isMaximized())); 80 | resize.setTranslateX(38); 81 | 82 | minimize.setFill(Color.WHITE); 83 | minimize.setOpacity(0.70d); 84 | minimize.setSize("30px"); 85 | minimize.setOnMouseEntered(event -> minimize.setOpacity(1.0d)); 86 | minimize.setOnMouseExited(event -> minimize.setOpacity(0.70d)); 87 | minimize.setOnMouseClicked(event -> this.panelManager.getStage().setIconified(true)); 88 | minimize.setTranslateX(7); 89 | 90 | this.layout.setOnMousePressed(event -> { 91 | if(!this.panelManager.getStage().isMaximized()) 92 | { 93 | xOffset = panelManager.getStage().getX() - event.getScreenX(); 94 | yOffset = panelManager.getStage().getY() - event.getScreenY(); 95 | } 96 | }); 97 | 98 | this.layout.setOnMouseClicked(event -> { 99 | if(!this.panelManager.getStage().isMaximized()) 100 | panelManager.getStage().setOpacity(1d); 101 | }); 102 | 103 | this.layout.setOnMouseReleased(event -> { 104 | if(!this.panelManager.getStage().isMaximized()) 105 | panelManager.getStage().setOpacity(1d); }); 106 | 107 | this.layout.setOnMouseDragged(event -> { 108 | if(!this.panelManager.getStage().isMaximized()) 109 | { 110 | panelManager.getStage().setOpacity(0.75d); 111 | panelManager.getStage().setX(event.getScreenX() + xOffset); 112 | panelManager.getStage().setY(event.getScreenY() + yOffset); 113 | } 114 | }); 115 | 116 | topBarButton.getChildren().addAll(close, resize, minimize); 117 | } 118 | 119 | @Override 120 | public String getName() 121 | { 122 | return ""; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/main/resources/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlowArg/FlowUpdaterJsonCreator/551b1244db788aa4f66302c80005fbc0f7aaff72/src/main/resources/assets/icon.png --------------------------------------------------------------------------------