diff --git a/.gitmodules b/.gitmodules index bb4db48..c82164f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "pswgcommon"] path = pswgcommon url = git@bitbucket.org:projectswg/pswgcommon.git -[submodule "pswgcommonfx"] - path = pswgcommonfx - url = git@bitbucket.org:projectswg/pswgcommonfx.git [submodule "forwarder"] path = forwarder url = git@bitbucket.org:projectswg/forwarder.git diff --git a/build.gradle b/build.gradle index 39da7b1..d812aa4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,33 +1,41 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' - } -} +import org.beryx.jlink.data.TargetPlatform plugins { id 'application' id 'java' id 'idea' id "edu.sc.seis.macAppBundle" version "2.2.1" + id "com.github.johnrengelman.shadow" version "4.0.3" + id "org.openjfx.javafxplugin" version "0.0.5" + id "org.beryx.jlink" version "2.2.1" + id "org.javamodularity.moduleplugin" version "1.3.0" } -group = 'com.projectswg.launcher' -version = '0.1' -mainClassName = 'com.projectswg.launcher.core.Launcher' -sourceCompatibility = 9 -targetCompatibility = 9 +// Note: define javaVersion, javaHomeLinux, javaHomeMac, and javaHomeWindows inside your gradle.properties file -apply plugin: 'com.github.johnrengelman.shadow' +group = 'com.projectswg.launcher' +version = '1.1.13' +mainClassName = "com.projectswg.launcher.core.Launcher" +sourceCompatibility = 11 +targetCompatibility = 11 sourceSets { - utility { - - } + main {} + utility {} +} + +idea { + module { + inheritOutputDirs = true + } +} + +jlink { + options.addAll('--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages') + targetPlatforms.orNull.put('linux', new TargetPlatform('linux', javaHomeLinux)) + targetPlatforms.orNull.put('mac', new TargetPlatform('mac', javaHomeMac)) + targetPlatforms.orNull.put('windows', new TargetPlatform('windows', javaHomeWindows)) } shadowJar { @@ -37,10 +45,18 @@ shadowJar { } macAppBundle { - appName = "ProjectSWG Launcher" - dmgName = "Launcher-mac" - icon = "src/main/resources/theme/projectswg/graphics/ProjectSWGLaunchpad.icns" - mainClassName = "${->project.mainClassName}" + appName "ProjectSWG" + dmgName "ProjectSWG" + icon "src/main/resources/theme/projectswg/graphics/ProjectSWGLaunchpad.icns" + mainClassName "${->project.mainClassName}" + jarTask 'shadowJar' + jvmVersion javaVersion + jreHome javaHomeMac + bundleJRE true +} + +javafx { + modules = ['javafx.controls', 'javafx.fxml'] } repositories { @@ -49,14 +65,14 @@ repositories { dependencies { compile project(':pswgcommon') - compile project(':pswgcommonfx') compile project(':client-holocore') compile project(':forwarder') compile 'net.openhft:zero-allocation-hashing:0.8' compile group: 'me.joshlarson', name: 'fast-json', version: '2.2.3' + compile group: 'me.joshlarson', name: 'jlcommon-fx', version: '1.0.3' compile 'de.jensd:fontawesomefx-fontawesome:4.7.0-9.1.2' - utilityCompile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.59' + utilityCompile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.60' utilityCompile group: 'me.joshlarson', name: 'fast-json', version: '2.2.3' utilityCompile 'net.openhft:zero-allocation-hashing:0.8' @@ -70,3 +86,4 @@ task CreateUpdateListTask(type: ShadowJar) { configurations = [project.configurations.utilityRuntime] exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA') } + diff --git a/client-holocore b/client-holocore index 5ca8bf2..18e78ef 160000 --- a/client-holocore +++ b/client-holocore @@ -1 +1 @@ -Subproject commit 5ca8bf29ac55824735723713729e713d1f36c50d +Subproject commit 18e78ef9b4de179c9841b5910bc695de0d265e8d diff --git a/forwarder b/forwarder index 668025f..b104f07 160000 --- a/forwarder +++ b/forwarder @@ -1 +1 @@ -Subproject commit 668025fac8b4ea7361e26e6407c43268f19eb12a +Subproject commit b104f07fd7bf9c4783493fe9e7edba80bf2fac4c diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..457aad0 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..20c9e57 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Dec 22 15:24:22 CST 2018 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..af6708f --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..0f8d593 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..be3f7b2 --- /dev/null +++ b/license.txt @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/pswgcommon b/pswgcommon index 5da6077..81bb85c 160000 --- a/pswgcommon +++ b/pswgcommon @@ -1 +1 @@ -Subproject commit 5da607789212896e3f27fc2936bb0ae10902a9ae +Subproject commit 81bb85c1ee17f3ee9653588498dd55cf7ab6994d diff --git a/pswgcommonfx b/pswgcommonfx deleted file mode 160000 index 2c647b2..0000000 --- a/pswgcommonfx +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2c647b2775fc808a98cc88b2cc95e50e1fd3e92a diff --git a/settings.gradle b/settings.gradle index 2326ead..cd946e6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,4 @@ rootProject.name = 'launcher' include 'pswgcommon' -include 'pswgcommonfx' include 'client-holocore' include 'forwarder' diff --git a/src/main/java/com/projectswg/launcher/core/Launcher.java b/src/main/java/com/projectswg/launcher/core/Launcher.java index 5f42f4b..dddef58 100644 --- a/src/main/java/com/projectswg/launcher/core/Launcher.java +++ b/src/main/java/com/projectswg/launcher/core/Launcher.java @@ -20,14 +20,16 @@ package com.projectswg.launcher.core; -import com.projectswg.common.javafx.ResourceUtilities; +import com.projectswg.common.data.CrcDatabase; import com.projectswg.common.utilities.LocalUtilities; +import com.projectswg.launcher.core.resources.data.LauncherData; import com.projectswg.launcher.core.services.data.DataManager; import com.projectswg.launcher.core.services.launcher.LauncherManager; import me.joshlarson.jlcommon.control.IntentManager; import me.joshlarson.jlcommon.control.Manager; import me.joshlarson.jlcommon.control.SafeMain; import me.joshlarson.jlcommon.control.ServiceBase; +import me.joshlarson.jlcommon.javafx.control.FXMLManager; import me.joshlarson.jlcommon.log.Log; import me.joshlarson.jlcommon.log.log_wrapper.ConsoleLogWrapper; import me.joshlarson.jlcommon.log.log_wrapper.FileLogWrapper; @@ -40,37 +42,44 @@ import java.util.List; public class Launcher { - private final List services; - - private Launcher() { - this.services = new ArrayList<>(); + public static void main(String [] args) { + LocalUtilities.setApplicationName(".projectswg/launcher"); + Log.addWrapper(new ConsoleLogWrapper()); + Log.addWrapper(new FileLogWrapper(new File(LocalUtilities.getApplicationDirectory(), "log.txt"))); + + SafeMain.main("launcher", Launcher::run); + // No code can run after this point - SafeMain calls System.exit } - private void run() { + private static void run() { + List services = new ArrayList<>(List.of( + new DataManager(), + new LauncherManager(), + FXMLManager.builder() + .withResourceBundlePath("strings.strings") + .withKlass(Launcher.class) + .withLocale(LauncherData.INSTANCE.getGeneral().getLocale()) + .addFxml(Launcher.class.getResource("/fxml/navigation.fxml")) + .build() + )); + try (IntentManager intentManager = new IntentManager(Runtime.getRuntime().availableProcessors())) { IntentManager.setInstance(intentManager); - services.clear(); - services.add(new DataManager()); - services.add(new LauncherManager()); + for (ServiceBase s : services) s.setIntentManager(intentManager); + Manager.start(services); Manager.run(services, 100); Collections.reverse(services); // Allows the data services to stay alive longer Manager.stop(services); + + for (ServiceBase s : services) + s.setIntentManager(null); + IntentManager.setInstance(null); ThreadUtilities.printActiveThreads(); } } - public static void main(String [] args) { - LocalUtilities.setApplicationName(".projectswg/launcher"); - ResourceUtilities.setPrimarySource(Launcher.class); - Log.addWrapper(new ConsoleLogWrapper()); - Log.addWrapper(new FileLogWrapper(new File(LocalUtilities.getApplicationDirectory(), "log.txt"))); - - SafeMain.main("launcher", new Launcher()::run); - // No code can run after this point - SafeMain calls System.exit - } - } diff --git a/src/main/java/com/projectswg/launcher/core/services/launcher/UserInterfaceService.java b/src/main/java/com/projectswg/launcher/core/Test.java similarity index 62% rename from src/main/java/com/projectswg/launcher/core/services/launcher/UserInterfaceService.java rename to src/main/java/com/projectswg/launcher/core/Test.java index 37ef065..fb2ee5f 100644 --- a/src/main/java/com/projectswg/launcher/core/services/launcher/UserInterfaceService.java +++ b/src/main/java/com/projectswg/launcher/core/Test.java @@ -18,50 +18,28 @@ * * ***********************************************************************************/ -package com.projectswg.launcher.core.services.launcher; +package com.projectswg.launcher.core; -import com.projectswg.launcher.core.resources.gui.LauncherUI; -import javafx.application.Application; -import javafx.application.Platform; -import me.joshlarson.jlcommon.concurrency.ThreadPool; -import me.joshlarson.jlcommon.control.Service; +import com.projectswg.common.network.packets.swg.holo.HoloConnectionStopped.ConnectionStoppedReason; +import com.projectswg.holocore.client.HolocoreSocket; +import me.joshlarson.jlcommon.concurrency.Delay; -public class UserInterfaceService extends Service { +import java.net.InetAddress; + +public class Test { - private final ThreadPool uiThread; - - public UserInterfaceService() { - this.uiThread = new ThreadPool(1, "user-interface"); - } - - @Override - public boolean initialize() { - uiThread.start(); - uiThread.execute(this::run); - return true; - } - - @Override - public boolean isOperational() { - LauncherUI ui = LauncherUI.getInstance(); - return ui == null || ui.isOperational(); - } - - @Override - public boolean stop() { - uiThread.stop(true); - Platform.exit(); - return true; - } - - @Override - public boolean terminate() { - uiThread.awaitTermination(5000); - return true; - } - - private void run() { - Application.launch(LauncherUI.class); + public static void main(String [] args) { + HolocoreSocket socket = new HolocoreSocket(InetAddress.getLoopbackAddress(), 44463); + socket.setStatusChangedCallback(((oldStatus, newStatus, reason) -> System.out.println(oldStatus + " -> " + newStatus + " || " + reason))); + socket.connect(10000); + System.out.println("Connected"); + Delay.sleepMilli(10000); + System.out.println("Disconnecting..."); + socket.disconnect(ConnectionStoppedReason.APPLICATION); + Delay.sleepMilli(2000); + System.out.println("Closing..."); + socket.close(); } } + diff --git a/src/main/java/com/projectswg/launcher/core/resources/data/LauncherData.java b/src/main/java/com/projectswg/launcher/core/resources/data/LauncherData.java index 411d16b..c36701d 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/data/LauncherData.java +++ b/src/main/java/com/projectswg/launcher/core/resources/data/LauncherData.java @@ -26,18 +26,19 @@ import com.projectswg.launcher.core.resources.data.forwarder.ForwarderData; import com.projectswg.launcher.core.resources.data.general.GeneralData; import com.projectswg.launcher.core.resources.data.login.LoginData; import com.projectswg.launcher.core.resources.data.update.UpdateData; +import javafx.application.Application; import javafx.stage.Stage; import java.util.concurrent.atomic.AtomicReference; import java.util.prefs.Preferences; -public class LauncherData { +public enum LauncherData { + INSTANCE; - public static final String VERSION = "1.1.7"; + public static final String VERSION = "1.1.13"; public static final String UPDATE_ADDRESS = "login1.projectswg.com"; - private static final LauncherData INSTANCE = new LauncherData(); - + private final AtomicReference application; private final AtomicReference stage; private final AnnouncementsData announcementsData; private final GeneralData generalData; @@ -45,7 +46,8 @@ public class LauncherData { private final UpdateData updateData; private final ForwarderData forwarderData; - public LauncherData() { + LauncherData() { + this.application = new AtomicReference<>(null); this.stage = new AtomicReference<>(null); this.announcementsData = new AnnouncementsData(); this.generalData = new GeneralData(); @@ -58,6 +60,10 @@ public class LauncherData { return Preferences.userNodeForPackage(Launcher.class); } + public Application getApplication() { + return application.get(); + } + public Stage getStage() { return stage.get(); } @@ -82,6 +88,10 @@ public class LauncherData { return forwarderData; } + public void setApplication(Application application) { + this.application.set(application); + } + public void setStage(Stage stage) { this.stage.set(stage); } @@ -89,4 +99,5 @@ public class LauncherData { public static LauncherData getInstance() { return INSTANCE; } + } diff --git a/src/main/java/com/projectswg/launcher/core/resources/data/announcements/AnnouncementsData.java b/src/main/java/com/projectswg/launcher/core/resources/data/announcements/AnnouncementsData.java index ef9104b..75e8881 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/data/announcements/AnnouncementsData.java +++ b/src/main/java/com/projectswg/launcher/core/resources/data/announcements/AnnouncementsData.java @@ -21,7 +21,7 @@ package com.projectswg.launcher.core.resources.data.announcements; import com.projectswg.launcher.core.resources.gui.Card; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentList; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentList; public class AnnouncementsData { diff --git a/src/main/java/com/projectswg/launcher/core/resources/data/forwarder/ForwarderData.java b/src/main/java/com/projectswg/launcher/core/resources/data/forwarder/ForwarderData.java index 3f424da..c2d43a6 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/data/forwarder/ForwarderData.java +++ b/src/main/java/com/projectswg/launcher/core/resources/data/forwarder/ForwarderData.java @@ -20,7 +20,7 @@ package com.projectswg.launcher.core.resources.data.forwarder; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentInteger; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentInteger; import org.jetbrains.annotations.NotNull; public class ForwarderData { diff --git a/src/main/java/com/projectswg/launcher/core/resources/data/general/GeneralData.java b/src/main/java/com/projectswg/launcher/core/resources/data/general/GeneralData.java index 624ce9e..3fbc93c 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/data/general/GeneralData.java +++ b/src/main/java/com/projectswg/launcher/core/resources/data/general/GeneralData.java @@ -20,9 +20,9 @@ package com.projectswg.launcher.core.resources.data.general; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentBoolean; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentReference; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentString; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentBoolean; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentReference; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentString; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,12 +34,14 @@ public class GeneralData { private final ConcurrentReference theme; private final ConcurrentReference locale; private final ConcurrentString wine; + private final ConcurrentBoolean admin; public GeneralData() { this.sound = new ConcurrentBoolean(); this.theme = new ConcurrentReference<>(LauncherTheme.DEFAULT); this.locale = new ConcurrentReference<>(Locale.getDefault()); this.wine = new ConcurrentString(); + this.admin = new ConcurrentBoolean(); } @NotNull @@ -62,6 +64,11 @@ public class GeneralData { return wine; } + @NotNull + public ConcurrentBoolean getAdminProperty() { + return admin; + } + public boolean isSound() { return sound.get(); } @@ -81,6 +88,10 @@ public class GeneralData { return wine.get(); } + public boolean isAdmin() { + return admin.get(); + } + public void setSound(boolean sound) { this.sound.set(sound); } @@ -97,4 +108,8 @@ public class GeneralData { this.wine.set(wine); } + public void setAdmin(boolean admin) { + this.admin.set(admin); + } + } diff --git a/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginData.java b/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginData.java index 296416e..a866e6e 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginData.java +++ b/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginData.java @@ -20,7 +20,7 @@ package com.projectswg.launcher.core.resources.data.login; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentSet; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentSet; import org.jetbrains.annotations.NotNull; import java.util.concurrent.CopyOnWriteArraySet; diff --git a/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginServer.java b/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginServer.java index a32ed14..57b2632 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginServer.java +++ b/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginServer.java @@ -22,10 +22,7 @@ package com.projectswg.launcher.core.resources.data.login; import com.projectswg.launcher.core.resources.data.update.UpdateServer; import com.projectswg.launcher.core.resources.data.update.UpdateServer.UpdateServerStatus; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentBase; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentInteger; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentReference; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentString; +import me.joshlarson.jlcommon.javafx.beans.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -37,6 +34,7 @@ public class LoginServer { private final ConcurrentString username; private final ConcurrentString password; private final ConcurrentReference updateServer; + private final ConcurrentBoolean verifyServer; private final LoginServerInstanceInfo instanceInfo; public LoginServer(@NotNull String name) { @@ -46,9 +44,10 @@ public class LoginServer { this.username = new ConcurrentString(""); this.password = new ConcurrentString(""); this.updateServer = new ConcurrentReference<>(null); + this.verifyServer = new ConcurrentBoolean(true); this.instanceInfo = new LoginServerInstanceInfo(); - updateServer.addListener("login-server-"+name, this::updateServerListener); + updateServer.addSimpleListener("login-server-"+name, this::updateServerListener); instanceInfo.setUpdateStatus(UpdateServerStatus.UNKNOWN.getFriendlyName()); updateServerListener(updateServer, null, null); } @@ -73,6 +72,11 @@ public class LoginServer { return password; } + @NotNull + public ConcurrentBoolean getVerifyServerProperty() { + return verifyServer; + } + @NotNull public ConcurrentReference getUpdateServerProperty() { return updateServer; @@ -112,6 +116,10 @@ public class LoginServer { return updateServer.get(); } + public boolean isVerifyServer() { + return verifyServer.get(); + } + public void setAddress(@NotNull String address) { this.address.set(address); } @@ -132,6 +140,10 @@ public class LoginServer { this.updateServer.set(server); } + public void setVerifyServer(boolean verifyServer) { + this.verifyServer.set(verifyServer); + } + @Override public String toString() { return name; @@ -143,7 +155,7 @@ public class LoginServer { prev.getStatusProperty().removeListener(listenerName); } if (next != null) { - next.getStatusProperty().addListener(listenerName, this::onUpdateServerStatusUpdated); + next.getStatusProperty().addSimpleListener(listenerName, this::onUpdateServerStatusUpdated); instanceInfo.setReadyToPlay(calculateReadyToPlay(next.getStatus())); } else { instanceInfo.setReadyToPlay(false); diff --git a/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginServerInstanceInfo.java b/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginServerInstanceInfo.java index 78ef29d..65b1910 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginServerInstanceInfo.java +++ b/src/main/java/com/projectswg/launcher/core/resources/data/login/LoginServerInstanceInfo.java @@ -20,8 +20,8 @@ package com.projectswg.launcher.core.resources.data.login; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentBoolean; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentString; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentBoolean; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentString; import org.jetbrains.annotations.NotNull; public class LoginServerInstanceInfo { diff --git a/src/main/java/com/projectswg/launcher/core/resources/data/update/UpdateData.java b/src/main/java/com/projectswg/launcher/core/resources/data/update/UpdateData.java index 9d0cc33..7f1c99e 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/data/update/UpdateData.java +++ b/src/main/java/com/projectswg/launcher/core/resources/data/update/UpdateData.java @@ -20,7 +20,7 @@ package com.projectswg.launcher.core.resources.data.update; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentSet; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentSet; import org.jetbrains.annotations.NotNull; import java.util.concurrent.CopyOnWriteArraySet; diff --git a/src/main/java/com/projectswg/launcher/core/resources/data/update/UpdateServer.java b/src/main/java/com/projectswg/launcher/core/resources/data/update/UpdateServer.java index 3105c50..f5e0fc6 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/data/update/UpdateServer.java +++ b/src/main/java/com/projectswg/launcher/core/resources/data/update/UpdateServer.java @@ -20,10 +20,10 @@ package com.projectswg.launcher.core.resources.data.update; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentInteger; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentList; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentReference; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentString; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentInteger; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentList; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentReference; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentString; import org.jetbrains.annotations.NotNull; import java.io.File; diff --git a/src/main/java/com/projectswg/launcher/core/resources/game/GameInstance.java b/src/main/java/com/projectswg/launcher/core/resources/game/GameInstance.java index feee9bc..1c5a566 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/game/GameInstance.java +++ b/src/main/java/com/projectswg/launcher/core/resources/game/GameInstance.java @@ -61,10 +61,11 @@ public class GameInstance { return; ForwarderData data = forwarder.getData(); data.setAddress(new InetSocketAddress(server.getAddress(), server.getPort())); + data.setVerifyServer(server.isVerifyServer()); data.setUsername(server.getUsername()); data.setPassword(server.getPassword()); - data.setOutboundTunerInterval(LauncherData.getInstance().getForwarderData().getSendInterval()); - data.setOutboundTunerMaxSend(LauncherData.getInstance().getForwarderData().getSendMax()); + data.setOutboundTunerInterval(LauncherData.INSTANCE.getForwarderData().getSendInterval()); + data.setOutboundTunerMaxSend(LauncherData.INSTANCE.getForwarderData().getSendMax()); forwarderThread.start(); } @@ -167,7 +168,17 @@ public class GameInstance { "autoConnectToLoginServer=" + !username.isEmpty(), "logReportFatals=true", "logStderr=true", - "0fd345d9=true"); + "0fd345d9=" + (LauncherData.INSTANCE.getGeneral().isAdmin() ? "true" : "false"), + "-s", + "SharedNetwork", + "useTcp=false", + "networkHandlerDispatchThrottle=false", + "maxRawPacketSize=16384", + "fragmentSize=16384", + "maxInstandingPackets=4096", + "useNetworkThread=false", + "processOnSend=true", + "networkHandlerDispatchQueueSize=2000"); } private static void reportWarning(String title, String message) { diff --git a/src/main/java/com/projectswg/launcher/core/resources/game/ProcessExecutor.java b/src/main/java/com/projectswg/launcher/core/resources/game/ProcessExecutor.java index 5b3c6b8..0dad686 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/game/ProcessExecutor.java +++ b/src/main/java/com/projectswg/launcher/core/resources/game/ProcessExecutor.java @@ -111,7 +111,7 @@ public enum ProcessExecutor { private File getWine() { { - String wineStr = LauncherData.getInstance().getGeneral().getWine(); + String wineStr = LauncherData.INSTANCE.getGeneral().getWine(); if (wineStr != null) { File wine = new File(wineStr); if (wine.isFile()) { diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/AnnouncementsController.java b/src/main/java/com/projectswg/launcher/core/resources/gui/AnnouncementsController.java index 767d0b8..48b687d 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/AnnouncementsController.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/AnnouncementsController.java @@ -20,7 +20,7 @@ package com.projectswg.launcher.core.resources.gui; -import com.projectswg.common.javafx.FXMLController; +import me.joshlarson.jlcommon.javafx.control.FXMLController; import com.projectswg.launcher.core.resources.data.LauncherData; import javafx.fxml.FXML; import javafx.scene.Parent; @@ -52,13 +52,13 @@ public class AnnouncementsController implements FXMLController { @Override public void initialize(URL location, ResourceBundle resources) { - LauncherData.getInstance().getAnnouncements().getAnnouncementCards().addCollectionChangedListener(LISTENER_KEY, this::updateAnnouncements); + LauncherData.INSTANCE.getAnnouncements().getAnnouncementCards().addCollectionChangedListener(LISTENER_KEY, this::updateAnnouncements); updateAnnouncements(); } private void updateAnnouncements() { cardContainer.clearCards(); - LauncherData.getInstance().getAnnouncements().getAnnouncementCards().forEach(cardContainer::addCard); + LauncherData.INSTANCE.getAnnouncements().getAnnouncementCards().forEach(cardContainer::addCard); } } diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/Card.java b/src/main/java/com/projectswg/launcher/core/resources/gui/Card.java index d5283af..9589546 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/Card.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/Card.java @@ -20,6 +20,7 @@ package com.projectswg.launcher.core.resources.gui; +import com.projectswg.launcher.core.resources.data.LauncherData; import javafx.scene.Cursor; import javafx.scene.control.Label; import javafx.scene.control.Separator; @@ -102,7 +103,7 @@ public class Card extends VBox { } private void gotoLink() { - LauncherUI.getInstance().getHostServices().showDocument(link); + LauncherData.INSTANCE.getApplication().getHostServices().showDocument(link); } private static Region createPaddedRegion() { diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/LauncherUI.java b/src/main/java/com/projectswg/launcher/core/resources/gui/LauncherUI.java deleted file mode 100644 index a0af926..0000000 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/LauncherUI.java +++ /dev/null @@ -1,73 +0,0 @@ -/*********************************************************************************** - * Copyright (C) 2018 /// Project SWG /// www.projectswg.com * - * * - * This file is part of the ProjectSWG Launcher. * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as published by * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with this program. If not, see . * - * * - ***********************************************************************************/ - -package com.projectswg.launcher.core.resources.gui; - -import com.projectswg.common.javafx.FXMLUtilities; -import com.projectswg.launcher.core.resources.data.LauncherData; -import javafx.application.Application; -import javafx.application.Platform; -import javafx.scene.Scene; -import javafx.stage.Stage; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; - -public class LauncherUI extends Application { - - private static final AtomicReference INSTANCE = new AtomicReference<>(null); - - private final AtomicBoolean operational; - - public LauncherUI() { - this.operational = new AtomicBoolean(true); - INSTANCE.set(this); - } - - public boolean isOperational() { - return operational.get(); - } - - @Override - public void start(Stage primaryStage) { - // TODO: Theme specific loading - LauncherData data = LauncherData.getInstance(); - NavigationController controller = (NavigationController) FXMLUtilities.loadFxmlAsClassResource("/theme/projectswg/fxml/navigation.fxml", data.getGeneral().getLocale()); - if (controller == null) { - operational.set(false); - throw new NullPointerException("Invalid navigation controller"); - } - primaryStage.setTitle("ProjectSWG Launcher"); - primaryStage.setScene(new Scene(controller.getRoot())); - primaryStage.setResizable(false); - primaryStage.setOnCloseRequest(e -> Platform.exit()); - primaryStage.show(); - } - - @Override - public void stop() { - operational.set(false); - } - - public static LauncherUI getInstance() { - return INSTANCE.get(); - } - -} diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/NavigationController.java b/src/main/java/com/projectswg/launcher/core/resources/gui/NavigationController.java index 4f33f1f..2c57933 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/NavigationController.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/NavigationController.java @@ -20,20 +20,26 @@ package com.projectswg.launcher.core.resources.gui; -import com.projectswg.common.javafx.FXMLController; +import com.projectswg.launcher.core.resources.data.LauncherData; import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon; import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView; +import javafx.application.Platform; import javafx.fxml.FXML; import javafx.scene.Parent; +import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import javafx.scene.paint.Color; +import javafx.stage.Stage; +import me.joshlarson.jlcommon.javafx.control.FXMLController; +import me.joshlarson.jlcommon.javafx.control.FXMLService; import java.net.URL; +import java.util.Locale; import java.util.ResourceBundle; -public class NavigationController implements FXMLController { +public class NavigationController extends FXMLService implements FXMLController { @FXML private TabPane tabPane; @@ -44,8 +50,11 @@ public class NavigationController implements FXMLController { @FXML private Parent root; + private Stage primaryStage; + public NavigationController() { - + this.primaryStage = LauncherData.INSTANCE.getStage(); + LauncherData.INSTANCE.getGeneral().getLocaleProperty().addSimpleListener("navigation-reinflate", this::updateLocale); } @Override @@ -61,6 +70,39 @@ public class NavigationController implements FXMLController { tabPane.getSelectionModel().selectedItemProperty().addListener((obs, prev, tab) -> selectedTabLabel.setText(tab.getText())); tabPane.getSelectionModel().select(serverListTab); + + setupStage(); + } + + @Override + public boolean stop() { + LauncherData.INSTANCE.getGeneral().getLocaleProperty().removeListener("navigation-reinflate"); + this.primaryStage = null; + return true; + } + + @Override + public boolean isOperational() { + return primaryStage == null || primaryStage.isShowing(); + } + + private void setupStage() { + if (this.primaryStage == null) { + Stage primaryStage = new Stage(); + primaryStage.setTitle("ProjectSWG Launcher"); + primaryStage.setScene(new Scene(root)); + primaryStage.setResizable(false); + primaryStage.show(); + LauncherData.INSTANCE.setApplication(getApplication()); + LauncherData.INSTANCE.setStage(primaryStage); + this.primaryStage = primaryStage; + } else { + this.primaryStage.setScene(new Scene(root)); + } + } + + private void updateLocale(Locale locale) { + new Thread(() -> reinflate(locale), "reinflator").start(); } private static FontAwesomeIconView createGlyph(FontAwesomeIcon icon) { diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/ServerListController.java b/src/main/java/com/projectswg/launcher/core/resources/gui/ServerListController.java index e80b85c..4f41e21 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/ServerListController.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/ServerListController.java @@ -20,7 +20,7 @@ package com.projectswg.launcher.core.resources.gui; -import com.projectswg.common.javafx.FXMLController; +import me.joshlarson.jlcommon.javafx.control.FXMLController; import com.projectswg.launcher.core.resources.data.LauncherData; import com.projectswg.launcher.core.resources.data.login.LoginServer; import com.projectswg.launcher.core.resources.data.update.UpdateServer; @@ -32,8 +32,8 @@ import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.image.ImageView; import javafx.scene.layout.Region; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentBase; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentString; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentBase; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentString; import java.net.URL; import java.util.Comparator; @@ -76,20 +76,20 @@ public class ServerListController implements FXMLController { addCenterAlignColumn(resources.getString("servers.column.localStatus"), COL_WIDTH_LARGE, resources::getString, s -> s.getInstanceInfo().getUpdateStatusProperty()); addPlayColumn(resources); - LauncherData.getInstance().getLogin().getServers().addCollectionChangedListener(LISTENER_KEY, this::updateServerTable); - LauncherData.getInstance().getAnnouncements().getServerListCards().addCollectionChangedListener(LISTENER_KEY, this::updateAnnouncements); + LauncherData.INSTANCE.getLogin().getServers().addCollectionChangedListener(LISTENER_KEY, this::updateServerTable); + LauncherData.INSTANCE.getAnnouncements().getServerListCards().addCollectionChangedListener(LISTENER_KEY, this::updateAnnouncements); updateServerTable(); updateAnnouncements(); } private void updateServerTable() { - serverTable.getItems().setAll(LauncherData.getInstance().getLogin().getServers()); + serverTable.getItems().setAll(LauncherData.INSTANCE.getLogin().getServers()); serverTable.getItems().sort(Comparator.comparing(LoginServer::getName)); } private void updateAnnouncements() { cardContainer.clearCards(); - LauncherData.getInstance().getAnnouncements().getServerListCards().forEach(cardContainer::addCard); + LauncherData.INSTANCE.getAnnouncements().getServerListCards().forEach(cardContainer::addCard); } private void addCenterAlignColumn(String name, double prefWidth, Function conv, Function> transform) { @@ -102,7 +102,7 @@ public class ServerListController implements FXMLController { col.setPrefWidth(prefWidth); col.setCellValueFactory(param -> { ConcurrentBase val = transform.apply(param.getValue()); - SimpleObjectProperty obj = new SimpleObjectProperty<>(conv.apply(val.get())); + SimpleObjectProperty obj = new SimpleObjectProperty<>(conv.apply(val.getValue())); val.addTransformListener(LISTENER_KEY, conv, obj::set); return obj; }); diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/SettingsController.java b/src/main/java/com/projectswg/launcher/core/resources/gui/SettingsController.java index dc42d6a..abff307 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/SettingsController.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/SettingsController.java @@ -20,9 +20,9 @@ package com.projectswg.launcher.core.resources.gui; -import com.projectswg.common.javafx.FXMLController; import javafx.fxml.FXML; import javafx.scene.Parent; +import me.joshlarson.jlcommon.javafx.control.FXMLController; import java.net.URL; import java.util.ResourceBundle; diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayButton.java b/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayButton.java index 42282fe..e2d25eb 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayButton.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayButton.java @@ -28,7 +28,7 @@ import com.projectswg.launcher.core.resources.intents.DownloadPatchIntent; import com.projectswg.launcher.core.resources.intents.LaunchGameIntent; import javafx.application.Platform; import javafx.scene.control.Button; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentDouble; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentDouble; import org.jetbrains.annotations.NotNull; import java.util.Objects; @@ -68,7 +68,7 @@ public class ServerPlayButton extends Button { private void setup(UpdateServer server) { if (server == null) return; - server.getStatusProperty().addListener(this, this::update); + server.getStatusProperty().addSimpleListener(this, this::update); update(server.getStatus()); } diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayCell.java b/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayCell.java index 3a575e5..8a23b56 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayCell.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayCell.java @@ -24,7 +24,7 @@ import com.projectswg.launcher.core.resources.data.login.LoginServer; import com.projectswg.launcher.core.resources.data.update.UpdateServer; import javafx.scene.control.TableCell; import javafx.scene.layout.VBox; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentDouble; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentDouble; import java.util.ResourceBundle; @@ -50,7 +50,7 @@ public class ServerPlayCell extends TableCell { } super.updateItem(item, empty); if (item != null) { - item.getUpdateServerProperty().addListener(this, updateServer -> update(item, updateServer)); + item.getUpdateServerProperty().addSimpleListener(this, updateServer -> update(item, updateServer)); } update(item, item==null?null:item.getUpdateServer()); if (empty) { diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayLabel.java b/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayLabel.java index 9b48136..57296db 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayLabel.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/servers/ServerPlayLabel.java @@ -25,7 +25,7 @@ import com.projectswg.launcher.core.resources.data.update.UpdateServer.RequiredF import com.projectswg.launcher.core.resources.data.update.UpdateServer.UpdateServerStatus; import javafx.application.Platform; import javafx.scene.control.Label; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentDouble; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentDouble; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -59,7 +59,7 @@ public class ServerPlayLabel extends Label { private void setup(UpdateServer server) { if (server == null) return; - server.getStatusProperty().addListener(this, status -> update(server, status)); + server.getStatusProperty().addSimpleListener(this, status -> update(server, status)); } private void teardown(UpdateServer server) { @@ -74,18 +74,18 @@ public class ServerPlayLabel extends Label { case UNKNOWN: case READY: case SCANNING: - progressBar.setValue(-1); + progressBar.set(-1); internalSetText(bundle.getString("servers.action_info.empty")); setManaged(false); break; case REQUIRES_DOWNLOAD: setManaged(true); - progressBar.setValue(-1); + progressBar.set(-1); internalSetText(calculateDownloadSize(server.getRequiredFiles()) + " " + bundle.getString("servers.action_info.required")); break; case DOWNLOADING: setManaged(true); - progressBar.addListener("server-play-label", p -> internalSetText(String.format("%.2f%% %s", p*100, bundle.getString("servers.action_info.progress")))); + progressBar.addSimpleListener("server-play-label", p -> internalSetText(String.format("%.2f%% %s", p*100, bundle.getString("servers.action_info.progress")))); if (progressBar.get() == -1) internalSetText(bundle.getString("servers.action_info.downloading")); else diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsForwarderController.java b/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsForwarderController.java index 639d8b8..f5b21fb 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsForwarderController.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsForwarderController.java @@ -20,7 +20,7 @@ package com.projectswg.launcher.core.resources.gui.settings; -import com.projectswg.common.javafx.FXMLController; +import me.joshlarson.jlcommon.javafx.control.FXMLController; import com.projectswg.launcher.core.resources.data.LauncherData; import com.projectswg.launcher.core.resources.data.forwarder.ForwarderData; import javafx.beans.value.ObservableValue; @@ -52,8 +52,8 @@ public class SettingsForwarderController implements FXMLController { @Override public void initialize(URL location, ResourceBundle resources) { - sendIntervalTextField.setText(Integer.toString(LauncherData.getInstance().getForwarderData().getSendInterval())); - sendMaxTextField.setText(Integer.toString(LauncherData.getInstance().getForwarderData().getSendMax())); + sendIntervalTextField.setText(Integer.toString(LauncherData.INSTANCE.getForwarderData().getSendInterval())); + sendMaxTextField.setText(Integer.toString(LauncherData.INSTANCE.getForwarderData().getSendMax())); sendIntervalTextField.textProperty().addListener(this::handleInterval); sendMaxTextField.textProperty().addListener(this::handleMax); @@ -69,7 +69,7 @@ public class SettingsForwarderController implements FXMLController { sendIntervalTextField.setText(filtered); next = filtered; } - LauncherData.getInstance().getForwarderData().setSendInterval(Integer.parseInt(next)); + LauncherData.INSTANCE.getForwarderData().setSendInterval(Integer.parseInt(next)); } private void handleMax(@SuppressWarnings("unused") ObservableValue prop, @SuppressWarnings("unused") String prev, String next) { @@ -78,7 +78,7 @@ public class SettingsForwarderController implements FXMLController { sendMaxTextField.setText(filtered); next = filtered; } - LauncherData.getInstance().getForwarderData().setSendMax(Integer.parseInt(next)); + LauncherData.INSTANCE.getForwarderData().setSendMax(Integer.parseInt(next)); } } diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsGeneralController.java b/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsGeneralController.java index 19d60fc..580757d 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsGeneralController.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsGeneralController.java @@ -20,7 +20,7 @@ package com.projectswg.launcher.core.resources.gui.settings; -import com.projectswg.common.javafx.FXMLController; +import me.joshlarson.jlcommon.javafx.control.FXMLController; import com.projectswg.launcher.core.resources.data.LauncherData; import com.projectswg.launcher.core.resources.data.general.GeneralData; import com.projectswg.launcher.core.resources.data.general.LauncherTheme; @@ -56,6 +56,8 @@ public class SettingsGeneralController implements FXMLController { private TextField wineTextField; @FXML private Button wineSelectionButton; + @FXML + private CheckBox adminCheckBox; @Override public Parent getRoot() { @@ -64,16 +66,10 @@ public class SettingsGeneralController implements FXMLController { @Override public void initialize(URL location, ResourceBundle resources) { - GeneralData data = LauncherData.getInstance().getGeneral(); + GeneralData data = LauncherData.INSTANCE.getGeneral(); wineSelectionButton.setGraphic(createFolderGlyph()); - soundCheckbox.selectedProperty().addListener((obs, prev, s) -> data.setSound(s)); - themeComboBox.valueProperty().addListener((obs, prev, v) -> data.setTheme(v)); - localeComboBox.valueProperty().addListener((obs, prev, v) -> data.setLocale(v)); - wineTextField.textProperty().addListener((obs, prev, t) -> data.setWine(t)); - wineSelectionButton.setOnAction(this::processWineSelectionButtonAction); - themeComboBox.getItems().setAll(LauncherTheme.values()); localeComboBox.getItems().setAll(Locale.ENGLISH, Locale.GERMAN); @@ -81,6 +77,14 @@ public class SettingsGeneralController implements FXMLController { themeComboBox.setValue(data.getTheme()); localeComboBox.setValue(data.getLocale()); wineTextField.setText(data.getWine()); + adminCheckBox.setSelected(data.isAdmin()); + + soundCheckbox.selectedProperty().addListener((obs, prev, s) -> data.setSound(s)); + themeComboBox.valueProperty().addListener((obs, prev, v) -> data.setTheme(v)); + localeComboBox.valueProperty().addListener((obs, prev, v) -> data.setLocale(v)); + wineTextField.textProperty().addListener((obs, prev, t) -> data.setWine(t)); + wineSelectionButton.setOnAction(this::processWineSelectionButtonAction); + adminCheckBox.selectedProperty().addListener((obs, prev, a) -> data.setAdmin(a)); } private static FontAwesomeIconView createFolderGlyph() { @@ -104,7 +108,7 @@ public class SettingsGeneralController implements FXMLController { private static File chooseOpenFile(String title) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(title); - File file = fileChooser.showOpenDialog(LauncherData.getInstance().getStage()); + File file = fileChooser.showOpenDialog(LauncherData.INSTANCE.getStage()); if (file == null || !file.isFile()) return null; return file; diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsLoginController.java b/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsLoginController.java index 8c4e90c..2b815e6 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsLoginController.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsLoginController.java @@ -20,7 +20,9 @@ package com.projectswg.launcher.core.resources.gui.settings; -import com.projectswg.common.javafx.FXMLController; +import javafx.scene.control.CheckBox; +import me.joshlarson.jlcommon.concurrency.ThreadPool; +import me.joshlarson.jlcommon.javafx.control.FXMLController; import com.projectswg.launcher.core.resources.data.LauncherData; import com.projectswg.launcher.core.resources.data.login.LoginServer; import com.projectswg.launcher.core.resources.data.update.UpdateServer; @@ -30,29 +32,28 @@ import javafx.scene.Parent; import javafx.scene.control.ComboBox; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; +import me.joshlarson.jlcommon.javafx.control.FXMLService; import java.net.URL; import java.util.ResourceBundle; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; -public class SettingsLoginController implements FXMLController { +public class SettingsLoginController extends FXMLService implements FXMLController { private final AtomicReference server; + private final ThreadPool executor; - @FXML - private Parent root; - @FXML - private ComboBox nameComboBox; - @FXML - private TextField addressTextField, portTextField, usernameTextField; - @FXML - private PasswordField passwordField; - @FXML - private ComboBox updateServerComboBox; + @FXML private Parent root; + @FXML private ComboBox nameComboBox; + @FXML private TextField addressTextField, portTextField, usernameTextField; + @FXML private PasswordField passwordField; + @FXML private ComboBox updateServerComboBox; + @FXML private CheckBox verifyServerCheckBox; public SettingsLoginController() { this.server = new AtomicReference<>(null); + this.executor = new ThreadPool(1, "settings-login"); } @Override @@ -62,34 +63,43 @@ public class SettingsLoginController implements FXMLController { @Override public void initialize(URL location, ResourceBundle resources) { + executor.start(); // TODO: Add/remove login servers addressTextField.textProperty().addListener((obs, prev, t) -> setIfPresent(s -> s.setAddress(t))); portTextField.textProperty().addListener((obs, prev, t) -> setIfPresent(s -> s.setPort(Integer.parseInt(t)))); usernameTextField.textProperty().addListener((obs, prev, t) -> setIfPresent(s -> s.setUsername(t))); passwordField.textProperty().addListener((obs, prev, t) -> setIfPresent(s -> s.setPassword(t))); updateServerComboBox.valueProperty().addListener((obs, prev, v) -> setIfPresent(s -> s.setUpdateServer(v))); + verifyServerCheckBox.selectedProperty().addListener((obs, prev, v) -> setIfPresent(s -> s.setVerifyServer(v))); nameComboBox.valueProperty().addListener((obs, prev, next) -> { server.set(next); updateFields(next); }); - nameComboBox.setItems(FXCollections.observableArrayList(LauncherData.getInstance().getLogin().getServers())); - updateServerComboBox.setItems(FXCollections.observableArrayList(LauncherData.getInstance().getUpdate().getServers())); + nameComboBox.setItems(FXCollections.observableArrayList(LauncherData.INSTANCE.getLogin().getServers())); + updateServerComboBox.setItems(FXCollections.observableArrayList(LauncherData.INSTANCE.getUpdate().getServers())); LoginServer def = nameComboBox.getItems().get(0); updateFields(def); nameComboBox.setValue(def); } + @Override + public boolean terminate() { + executor.stop(false); + return executor.awaitTermination(1000); + } + private void updateFields(LoginServer server) { addressTextField.setText(server.getAddress()); portTextField.setText(Integer.toString(server.getPort())); usernameTextField.setText(server.getUsername()); passwordField.setText(server.getPassword()); updateServerComboBox.setValue(server.getUpdateServer()); + verifyServerCheckBox.setSelected(server.isVerifyServer()); } private void setIfPresent(Consumer c) { LoginServer s = server.get(); if (s != null) - c.accept(s); + executor.execute(() -> c.accept(s)); } } diff --git a/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsUpdateController.java b/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsUpdateController.java index 6f2514c..85984e6 100644 --- a/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsUpdateController.java +++ b/src/main/java/com/projectswg/launcher/core/resources/gui/settings/SettingsUpdateController.java @@ -20,7 +20,7 @@ package com.projectswg.launcher.core.resources.gui.settings; -import com.projectswg.common.javafx.FXMLController; +import me.joshlarson.jlcommon.javafx.control.FXMLController; import com.projectswg.launcher.core.resources.data.LauncherData; import com.projectswg.launcher.core.resources.data.update.UpdateServer; import com.projectswg.launcher.core.resources.game.ProcessExecutor; @@ -80,7 +80,7 @@ public class SettingsUpdateController implements FXMLController { localPathSelectionButton.setOnAction(this::processLocalPathSelectionButtonAction); nameComboBox.valueProperty().addListener((obs, prev, next) -> { server.set(next); updateFields(next); }); - nameComboBox.setItems(FXCollections.observableArrayList(LauncherData.getInstance().getUpdate().getServers())); + nameComboBox.setItems(FXCollections.observableArrayList(LauncherData.INSTANCE.getUpdate().getServers())); UpdateServer def = nameComboBox.getItems().get(0); updateFields(def); @@ -150,7 +150,7 @@ public class SettingsUpdateController implements FXMLController { DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setTitle(title); directoryChooser.setInitialDirectory(currentDirectory); - File file = directoryChooser.showDialog(LauncherData.getInstance().getStage()); + File file = directoryChooser.showDialog(LauncherData.INSTANCE.getStage()); if (file == null || !file.isDirectory()) return null; return file; diff --git a/src/main/java/com/projectswg/launcher/core/services/data/AnnouncementService.java b/src/main/java/com/projectswg/launcher/core/services/data/AnnouncementService.java index 6f49cf9..f2c883f 100644 --- a/src/main/java/com/projectswg/launcher/core/services/data/AnnouncementService.java +++ b/src/main/java/com/projectswg/launcher/core/services/data/AnnouncementService.java @@ -83,7 +83,7 @@ public class AnnouncementService extends Service { List serverCards = parseCards(announcements.getArray("servers")).stream().map(this::downloadImage).collect(Collectors.toList()); Platform.runLater(() -> { - AnnouncementsData data = LauncherData.getInstance().getAnnouncements(); + AnnouncementsData data = LauncherData.INSTANCE.getAnnouncements(); data.getAnnouncementCards().clear(); data.getAnnouncementCards().addAll(announcementCards.stream().map(this::dataToCard).collect(Collectors.toList())); data.getServerListCards().clear(); @@ -146,13 +146,8 @@ public class AnnouncementService extends Service { if (destination.isFile()) return; Log.d("Downloading image '%s' to '%s'", url, destination); - try (ReadableByteChannel rbc = Channels.newChannel(new URL(url).openStream()); FileChannel fc = FileChannel.open(destination.toPath(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE)) { - ByteBuffer bb = ByteBuffer.allocateDirect(8*1024); - while (rbc.read(bb) >= 0) { - bb.flip(); - fc.write(bb); - bb.clear(); - } + try { + new URL(url).openStream().transferTo(new FileOutputStream(destination)); Log.t("Completed download of %s", destination); } catch (IOException e) { Log.e("Failed to download file %s from %s with error: %s: %s", destination, url, e.getClass().getName(), e.getMessage()); @@ -166,8 +161,7 @@ public class AnnouncementService extends Service { String os = filter.getString("os"); if (os != null) { String currentOs = System.getProperty("os.name").toLowerCase(Locale.US); - os = os.toLowerCase(Locale.US); - switch (os) { + switch (os.toLowerCase(Locale.US)) { case "windows": if (!currentOs.contains("win")) return false; @@ -213,7 +207,7 @@ public class AnnouncementService extends Service { Log.t("Retrieving latest announcements..."); JSONObject announcements; - try (JSONInputStream in = new JSONInputStream(new URL("http", LauncherData.UPDATE_ADDRESS, 80, "/launcher/announcements.json").openConnection().getInputStream())) { + try (JSONInputStream in = new JSONInputStream(new URL("http", LauncherData.UPDATE_ADDRESS, 80, "/launcher/announcements.json").openStream())) { announcements = in.readObject(); try (JSONOutputStream out = new JSONOutputStream(new FileOutputStream(localFileList))) { out.writeObject(announcements); diff --git a/src/main/java/com/projectswg/launcher/core/services/data/DownloadService.java b/src/main/java/com/projectswg/launcher/core/services/data/DownloadService.java index afb2895..5176480 100644 --- a/src/main/java/com/projectswg/launcher/core/services/data/DownloadService.java +++ b/src/main/java/com/projectswg/launcher/core/services/data/DownloadService.java @@ -27,9 +27,9 @@ import com.projectswg.launcher.core.resources.intents.CancelDownloadIntent; import com.projectswg.launcher.core.resources.intents.DownloadPatchIntent; import com.projectswg.launcher.core.resources.intents.RequestScanIntent; import me.joshlarson.jlcommon.concurrency.ThreadPool; -import me.joshlarson.jlcommon.concurrency.beans.ConcurrentLong; import me.joshlarson.jlcommon.control.IntentHandler; import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.javafx.beans.ConcurrentLong; import me.joshlarson.jlcommon.log.Log; import java.io.File; diff --git a/src/main/java/com/projectswg/launcher/core/services/data/PreferencesDataService.java b/src/main/java/com/projectswg/launcher/core/services/data/PreferencesDataService.java index f5b8def..8ae8048 100644 --- a/src/main/java/com/projectswg/launcher/core/services/data/PreferencesDataService.java +++ b/src/main/java/com/projectswg/launcher/core/services/data/PreferencesDataService.java @@ -42,19 +42,17 @@ import java.util.prefs.Preferences; public class PreferencesDataService extends Service { - private final LauncherData data; private final Preferences preferences; private final ScheduledThreadPool executor; public PreferencesDataService() { - this.data = LauncherData.getInstance(); - this.preferences = data.getPreferences(); + this.preferences = LauncherData.INSTANCE.getPreferences(); this.executor = new ScheduledThreadPool(1, 3, "data-executor-%d"); + loadPreferences(); } @Override - public boolean initialize() { - loadPreferences(); + public boolean start() { createDefaults(); executor.start(); executor.executeWithFixedDelay(5*60000, 5*60000, this::savePreferences); @@ -62,53 +60,52 @@ public class PreferencesDataService extends Service { } @Override - public boolean terminate() { - executor.stop(); - executor.awaitTermination(1000); + public boolean stop() { savePreferences(); - return true; + executor.stop(); + return executor.awaitTermination(1000); } private void createDefaults() { createPSWG(); createTeamSWG(); - if (data.getGeneral().getWine() == null || data.getGeneral().getWine().isEmpty()) - data.getGeneral().setWine(getWinePath()); + if (LauncherData.INSTANCE.getGeneral().getWine() == null || LauncherData.INSTANCE.getGeneral().getWine().isEmpty()) + LauncherData.INSTANCE.getGeneral().setWine(getWinePath()); } private void createPSWG() { - UpdateServer pswgUpdateServer = data.getUpdate().getServers().stream().filter(s -> s.getName().equals("ProjectSWG")).findFirst().orElse(null); + UpdateServer pswgUpdateServer = LauncherData.INSTANCE.getUpdate().getServers().stream().filter(s -> s.getName().equals("ProjectSWG")).findFirst().orElse(null); if (pswgUpdateServer == null) { pswgUpdateServer = new UpdateServer("ProjectSWG"); pswgUpdateServer.setAddress("login1.projectswg.com"); pswgUpdateServer.setPort(80); pswgUpdateServer.setBasePath("/launcher/patch"); pswgUpdateServer.setGameVersion("NGE"); - data.getUpdate().addServer(pswgUpdateServer); + LauncherData.INSTANCE.getUpdate().addServer(pswgUpdateServer); } else if (pswgUpdateServer.getGameVersion().isEmpty()) { // Migrate existing persisted update servers pswgUpdateServer.setGameVersion("NGE"); } - if (data.getLogin().getServers().stream().noneMatch(s -> s.getName().equals("ProjectSWG"))) { + if (LauncherData.INSTANCE.getLogin().getServers().stream().noneMatch(s -> s.getName().equals("ProjectSWG"))) { LoginServer defaultLive = new LoginServer("ProjectSWG"); defaultLive.setAddress("login1.projectswg.com"); defaultLive.setPort(44453); defaultLive.setUpdateServer(pswgUpdateServer); - data.getLogin().addServer(defaultLive); + LauncherData.INSTANCE.getLogin().addServer(defaultLive); } - if (data.getLogin().getServers().stream().noneMatch(s -> s.getName().equals("localhost"))) { + if (LauncherData.INSTANCE.getLogin().getServers().stream().noneMatch(s -> s.getName().equals("localhost"))) { LoginServer defaultLocalhost = new LoginServer("localhost"); defaultLocalhost.setAddress("localhost"); defaultLocalhost.setPort(44463); defaultLocalhost.setUpdateServer(pswgUpdateServer); - data.getLogin().addServer(defaultLocalhost); + LauncherData.INSTANCE.getLogin().addServer(defaultLocalhost); } } private void createTeamSWG() { - UpdateServer teamswgUpdateServer = data.getUpdate().getServers().stream().filter(s -> s.getName().equals("TeamSWG")).findFirst().orElse(null); + UpdateServer teamswgUpdateServer = LauncherData.INSTANCE.getUpdate().getServers().stream().filter(s -> s.getName().equals("TeamSWG")).findFirst().orElse(null); if (teamswgUpdateServer == null) { teamswgUpdateServer = new UpdateServer("TeamSWG"); @@ -116,35 +113,35 @@ public class PreferencesDataService extends Service { teamswgUpdateServer.setPort(80); teamswgUpdateServer.setBasePath("/launcher/patch"); teamswgUpdateServer.setGameVersion("CU"); - data.getUpdate().addServer(teamswgUpdateServer); + LauncherData.INSTANCE.getUpdate().addServer(teamswgUpdateServer); } - if (data.getLogin().getServers().stream().noneMatch(s -> s.getName().equals("Constrictor"))) { + if (LauncherData.INSTANCE.getLogin().getServers().stream().noneMatch(s -> s.getName().equals("Constrictor"))) { LoginServer constrictor = new LoginServer("Constrictor"); constrictor.setAddress("game.teamswg.com"); constrictor.setPort(44463); constrictor.setUpdateServer(teamswgUpdateServer); - data.getLogin().addServer(constrictor); + LauncherData.INSTANCE.getLogin().addServer(constrictor); } } - private void loadPreferences() { + private synchronized void loadPreferences() { try { - loadGeneralPreferences(data.getGeneral()); - loadUpdatePreferences(data.getUpdate()); - loadLoginPreferences(data.getLogin()); - loadForwarderPreferences(data.getForwarderData()); + loadGeneralPreferences(LauncherData.INSTANCE.getGeneral()); + loadUpdatePreferences(LauncherData.INSTANCE.getUpdate()); + loadLoginPreferences(LauncherData.INSTANCE.getLogin()); + loadForwarderPreferences(LauncherData.INSTANCE.getForwarderData()); } catch (BackingStoreException e) { Log.w(e); } } - private void savePreferences() { + private synchronized void savePreferences() { try { - saveGeneralPreferences(data.getGeneral()); - saveUpdatePreferences(data.getUpdate()); - saveLoginPreferences(data.getLogin()); - saveForwarderPreferences(data.getForwarderData()); + saveGeneralPreferences(LauncherData.INSTANCE.getGeneral()); + saveUpdatePreferences(LauncherData.INSTANCE.getUpdate()); + saveLoginPreferences(LauncherData.INSTANCE.getLogin()); + saveForwarderPreferences(LauncherData.INSTANCE.getForwarderData()); preferences.flush(); } catch (BackingStoreException e) { Log.w(e); @@ -157,6 +154,7 @@ public class PreferencesDataService extends Service { ifPresent(generalPreferences, "theme", LauncherTheme::forThemeTag, generalData::setTheme); ifPresent(generalPreferences, "locale", Locale::forLanguageTag, generalData::setLocale); ifPresent(generalPreferences, "wine", generalData::setWine); + ifPresent(generalPreferences, "admin", Boolean::valueOf, generalData::setAdmin); } private void saveGeneralPreferences(GeneralData generalData) { @@ -164,6 +162,7 @@ public class PreferencesDataService extends Service { generalPreferences.putBoolean("sound", generalData.isSound()); generalPreferences.put("theme", generalData.getTheme().getTag()); generalPreferences.put("locale", generalData.getLocale().toLanguageTag()); + generalPreferences.putBoolean("admin", generalData.isAdmin()); String wine = generalData.getWine(); if (wine != null) generalPreferences.put("wine", wine); @@ -178,7 +177,8 @@ public class PreferencesDataService extends Service { ifPresent(loginServerPreferences, "port", Integer::parseInt, server::setPort); ifPresent(loginServerPreferences, "username", server::setUsername); ifPresent(loginServerPreferences, "password", server::setPassword); - ifPresent(loginServerPreferences, "updateServer", name -> server.setUpdateServer(data.getUpdate().getServers().stream().filter(s -> s.getName().equals(name)).findFirst().orElse(null))); + ifPresent(loginServerPreferences, "updateServer", name -> server.setUpdateServer(LauncherData.INSTANCE.getUpdate().getServers().stream().filter(s -> s.getName().equals(name)).findFirst().orElse(null))); + ifPresent(loginServerPreferences, "verifyServer", Boolean::parseBoolean, server::setVerifyServer); loginData.getServers().add(server); } } @@ -192,6 +192,7 @@ public class PreferencesDataService extends Service { loginServerPreferences.putInt("port", server.getPort()); loginServerPreferences.put("username", server.getUsername()); loginServerPreferences.put("password", server.getPassword()); + loginServerPreferences.putBoolean("verifyServer", server.isVerifyServer()); UpdateServer updateServer = server.getUpdateServer(); if (updateServer != null) loginServerPreferences.put("updateServer", updateServer.getName()); diff --git a/src/main/java/com/projectswg/launcher/core/services/data/RemoteDataService.java b/src/main/java/com/projectswg/launcher/core/services/data/RemoteDataService.java index 40a1191..c48e137 100644 --- a/src/main/java/com/projectswg/launcher/core/services/data/RemoteDataService.java +++ b/src/main/java/com/projectswg/launcher/core/services/data/RemoteDataService.java @@ -20,7 +20,7 @@ package com.projectswg.launcher.core.services.data; -import com.projectswg.connection.HolocoreSocket; +import com.projectswg.holocore.client.HolocoreSocket; import com.projectswg.launcher.core.resources.data.LauncherData; import com.projectswg.launcher.core.resources.data.login.LoginData; import com.projectswg.launcher.core.resources.data.login.LoginServer; @@ -53,6 +53,12 @@ public class RemoteDataService extends Service { getLoginData().getServers().addCollectionChangedListener(LISTENER_KEY, loginServers::synchronize); } + @Override + public boolean initialize() { + loginServers.synchronize(getLoginData().getServers()); + return true; + } + @Override public boolean start() { executor.start(); @@ -66,8 +72,7 @@ public class RemoteDataService extends Service { @Override public boolean stop() { executor.stop(); - executor.awaitTermination(1000); - return true; + return executor.awaitTermination(1000); } @Override @@ -91,11 +96,11 @@ public class RemoteDataService extends Service { } private static LoginData getLoginData() { - return LauncherData.getInstance().getLogin(); + return LauncherData.INSTANCE.getLogin(); } private static UpdateData getUpdateData() { - return LauncherData.getInstance().getUpdate(); + return LauncherData.INSTANCE.getUpdate(); } private static class LoginServerUpdater { @@ -107,15 +112,15 @@ public class RemoteDataService extends Service { this.server = server; this.socket = null; - server.getAddressProperty().addListener(LISTENER_KEY, addr -> updateSocket()); - server.getPortProperty().addListener(LISTENER_KEY, port -> updateSocket()); + server.getAddressProperty().addSimpleListener(LISTENER_KEY, addr -> updateSocket()); + server.getPortProperty().addSimpleListener(LISTENER_KEY, port -> updateSocket()); updateSocket(); } public void terminate() { HolocoreSocket socket = this.socket; if (socket != null) - socket.terminate(); + socket.close(); } public void update() { diff --git a/src/main/java/com/projectswg/launcher/core/services/launcher/LauncherManager.java b/src/main/java/com/projectswg/launcher/core/services/launcher/LauncherManager.java index d70373c..50b9d23 100644 --- a/src/main/java/com/projectswg/launcher/core/services/launcher/LauncherManager.java +++ b/src/main/java/com/projectswg/launcher/core/services/launcher/LauncherManager.java @@ -25,7 +25,6 @@ import me.joshlarson.jlcommon.control.ManagerStructure; @ManagerStructure(children = { GameService.class, - UserInterfaceService.class }) public class LauncherManager extends Manager { diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000..bb367c5 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,27 @@ +module com.projectswg.launcher { + requires javafx.controls; + requires javafx.fxml; + requires me.joshlarson.jlcommon; + requires me.joshlarson.jlcommon.javafx; + requires fast.json; + requires zero.allocation.hashing; + requires de.jensd.fx.glyphs.fontawesome; + requires org.bouncycastle.provider; + + requires com.projectswg.common; + requires com.projectswg.forwarder; + requires com.projectswg.holocore.client; + + requires java.prefs; + + opens strings; + opens css; + opens graphics; + opens graphics.headers; + opens fxml; + opens com.projectswg.launcher.core.resources.gui; + opens com.projectswg.launcher.core.resources.gui.servers; + opens com.projectswg.launcher.core.resources.gui.settings; + opens com.projectswg.launcher.core.services.data; + opens com.projectswg.launcher.core.services.launcher; +} diff --git a/src/main/resources/theme/projectswg/css/theme.css b/src/main/resources/css/theme.css similarity index 100% rename from src/main/resources/theme/projectswg/css/theme.css rename to src/main/resources/css/theme.css diff --git a/src/main/resources/theme/projectswg/fxml/announcements.fxml b/src/main/resources/fxml/announcements.fxml similarity index 100% rename from src/main/resources/theme/projectswg/fxml/announcements.fxml rename to src/main/resources/fxml/announcements.fxml diff --git a/src/main/resources/theme/projectswg/fxml/navigation.fxml b/src/main/resources/fxml/navigation.fxml similarity index 93% rename from src/main/resources/theme/projectswg/fxml/navigation.fxml rename to src/main/resources/fxml/navigation.fxml index 4466db0..c65c02f 100644 --- a/src/main/resources/theme/projectswg/fxml/navigation.fxml +++ b/src/main/resources/fxml/navigation.fxml @@ -4,7 +4,7 @@ - + diff --git a/src/main/resources/theme/projectswg/fxml/servers.fxml b/src/main/resources/fxml/servers.fxml similarity index 89% rename from src/main/resources/theme/projectswg/fxml/servers.fxml rename to src/main/resources/fxml/servers.fxml index 2a32791..8a30909 100644 --- a/src/main/resources/theme/projectswg/fxml/servers.fxml +++ b/src/main/resources/fxml/servers.fxml @@ -7,7 +7,7 @@ - + diff --git a/src/main/resources/theme/projectswg/fxml/settings.fxml b/src/main/resources/fxml/settings.fxml similarity index 100% rename from src/main/resources/theme/projectswg/fxml/settings.fxml rename to src/main/resources/fxml/settings.fxml diff --git a/src/main/resources/theme/projectswg/fxml/settings/settings_forwarder.fxml b/src/main/resources/fxml/settings/settings_forwarder.fxml similarity index 100% rename from src/main/resources/theme/projectswg/fxml/settings/settings_forwarder.fxml rename to src/main/resources/fxml/settings/settings_forwarder.fxml diff --git a/src/main/resources/theme/projectswg/fxml/settings/settings_general.fxml b/src/main/resources/fxml/settings/settings_general.fxml similarity index 77% rename from src/main/resources/theme/projectswg/fxml/settings/settings_general.fxml rename to src/main/resources/fxml/settings/settings_general.fxml index 3a642a3..fb1c96d 100644 --- a/src/main/resources/theme/projectswg/fxml/settings/settings_general.fxml +++ b/src/main/resources/fxml/settings/settings_general.fxml @@ -20,4 +20,10 @@