├── .gitignore ├── LICENSE.txt ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src └── main ├── java └── lumien │ └── custommainmenu │ ├── CustomMainMenu.java │ ├── configuration │ ├── Alignment.java │ ├── Config.java │ ├── ConfigurationLoader.java │ ├── GuiConfig.java │ ├── GuiEntry.java │ └── elements │ │ ├── Background.java │ │ ├── Button.java │ │ ├── Element.java │ │ ├── Image.java │ │ ├── Label.java │ │ ├── Panorama.java │ │ ├── Slideshow.java │ │ └── SplashText.java │ ├── gui │ ├── GuiCustom.java │ ├── GuiCustomButton.java │ ├── GuiCustomConfirmOpenLink.java │ ├── GuiCustomLabel.java │ ├── GuiCustomWrappedButton.java │ └── GuiFakeMain.java │ ├── handler │ ├── CMMEventHandler.java │ ├── LoadStringURL.java │ └── LoadTextureURL.java │ ├── lib │ ├── ANCHOR.java │ ├── MODE.java │ ├── Reference.java │ ├── StringReplacer.java │ ├── actions │ │ ├── ActionConnectToServer.java │ │ ├── ActionLoadWorld.java │ │ ├── ActionOpenFolder.java │ │ ├── ActionOpenGUI.java │ │ ├── ActionOpenLink.java │ │ ├── ActionOpenModConfig.java │ │ ├── ActionQuit.java │ │ ├── ActionRefresh.java │ │ └── IAction.java │ ├── texts │ │ ├── IText.java │ │ ├── TextResourceLocation.java │ │ ├── TextString.java │ │ └── TextURL.java │ └── textures │ │ ├── ITexture.java │ │ ├── TextureApng.java │ │ ├── TextureResourceLocation.java │ │ └── TextureURL.java │ └── util │ ├── LogicUtil.java │ ├── MathUtil.java │ └── RenderUtil.java └── resources ├── META-INF └── CustomMainMenu_At.cfg ├── assets └── custommainmenu │ ├── mainmenu_default.json │ └── textures │ └── gui │ ├── buttons.png │ ├── edition.png │ ├── minecraft.png │ └── transparent.png ├── mcmod.info └── pack.mcmeta /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | bin 3 | *.launch 4 | .settings 5 | .metadata 6 | .classpath 7 | .project 8 | 9 | # idea 10 | out 11 | *.ipr 12 | *.iws 13 | *.iml 14 | .idea 15 | 16 | # gradle 17 | build 18 | .gradle 19 | 20 | # other 21 | eclipse 22 | run 23 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT 2 | 3 | Copyright 2019 lumien 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Source Code for the Custom Main Menu Minecraft Mod 2 | ================ -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven { url = "https://files.minecraftforge.net/maven" } 5 | } 6 | dependencies { 7 | classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' 8 | } 9 | } 10 | apply plugin: 'net.minecraftforge.gradle.forge' 11 | //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. 12 | 13 | 14 | version = "2.0.9" 15 | group = "lumien.custommainmenu" // http://maven.apache.org/guides/mini/guide-naming-conventions.html 16 | 17 | sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. 18 | compileJava { 19 | sourceCompatibility = targetCompatibility = '1.8' 20 | } 21 | 22 | minecraft { 23 | version = "1.12.2-14.23.5.2847" 24 | runDir = "run" 25 | 26 | replaceIn "CustomMainMenu.java" 27 | replace "@VERSION@",project.version 28 | 29 | // the mappings can be changed at any time, and must be in the following format. 30 | // snapshot_YYYYMMDD snapshot are built nightly. 31 | // stable_# stables are built at the discretion of the MCP team. 32 | // Use non-default mappings at your own risk. they may not always work. 33 | // simply re-run your setup task after changing the mappings to update your workspace. 34 | mappings = "snapshot_20171003" 35 | // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. 36 | } 37 | 38 | archivesBaseName = "CustomMainMenu-MC" + minecraft.version 39 | 40 | dependencies { 41 | // you may put jars on which you depend on in ./libs 42 | // or you may define them like so.. 43 | //compile "some.group:artifact:version:classifier" 44 | //compile "some.group:artifact:version" 45 | 46 | // real examples 47 | //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env 48 | //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env 49 | 50 | // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime. 51 | //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev' 52 | 53 | // the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided, 54 | // except that these dependencies get remapped to your current MCP mappings 55 | //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev' 56 | //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev' 57 | 58 | // for more info... 59 | // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html 60 | // http://www.gradle.org/docs/current/userguide/dependency_management.html 61 | 62 | } 63 | 64 | processResources { 65 | // this will ensure that this task is redone when the versions change. 66 | inputs.property "version", project.version 67 | inputs.property "mcversion", project.minecraft.version 68 | 69 | // replace stuff in mcmod.info, nothing else 70 | from(sourceSets.main.resources.srcDirs) { 71 | include 'mcmod.info' 72 | 73 | // replace version and mcversion 74 | expand 'version':project.version, 'mcversion':project.minecraft.version 75 | } 76 | 77 | // copy everything else except the mcmod.info 78 | from(sourceSets.main.resources.srcDirs) { 79 | exclude 'mcmod.info' 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Sets default memory used for gradle commands. Can be overridden by user or command line properties. 2 | # This is required to provide enough memory for the Minecraft decompilation process. 3 | org.gradle.jvmargs=-Xmx3G 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lumien231/Custom-Main-Menu/cc934c1d96691190d7479927735d58dac4c263a9/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Sep 14 12:28:28 PDT 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /src/main/java/lumien/custommainmenu/CustomMainMenu.java: -------------------------------------------------------------------------------- 1 | package lumien.custommainmenu; 2 | 3 | import java.io.File; 4 | 5 | import lumien.custommainmenu.configuration.Config; 6 | import lumien.custommainmenu.configuration.ConfigurationLoader; 7 | import lumien.custommainmenu.handler.CMMEventHandler; 8 | import net.minecraft.client.Minecraft; 9 | import net.minecraft.nbt.NBTTagCompound; 10 | import net.minecraft.util.ResourceLocation; 11 | import net.minecraftforge.common.MinecraftForge; 12 | import net.minecraftforge.fml.common.FMLCommonHandler; 13 | import net.minecraftforge.fml.common.Mod; 14 | import net.minecraftforge.fml.common.Mod.EventHandler; 15 | import net.minecraftforge.fml.common.Mod.Instance; 16 | import net.minecraftforge.fml.common.event.FMLInterModComms; 17 | import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; 18 | import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; 19 | 20 | import org.apache.logging.log4j.Level; 21 | import org.apache.logging.log4j.Logger; 22 | 23 | @Mod(modid = CustomMainMenu.MOD_ID, name = CustomMainMenu.MOD_NAME, version = CustomMainMenu.MOD_VERSION, clientSideOnly = true) 24 | public class CustomMainMenu 25 | { 26 | public static final String MOD_ID = "custommainmenu"; 27 | public static final String MOD_NAME = "Custom Main Menu"; 28 | public static final String MOD_VERSION = "@VERSION@"; 29 | 30 | @Instance(value = MOD_ID) 31 | public static CustomMainMenu INSTANCE; 32 | 33 | public static CMMEventHandler EVENT_HANDLER; 34 | 35 | private ConfigurationLoader configLoader; 36 | public Config config; 37 | 38 | public Logger logger; 39 | public File configFolder; 40 | 41 | static ResourceLocation transparentTexture; 42 | 43 | public static void bindTransparent() 44 | { 45 | Minecraft.getMinecraft().renderEngine.bindTexture(transparentTexture); 46 | } 47 | 48 | @EventHandler 49 | public void preInit(FMLPreInitializationEvent event) 50 | { 51 | configFolder = event.getModConfigurationDirectory(); 52 | config = new Config(); 53 | // Load Transparent 54 | transparentTexture = new ResourceLocation("custommainmenu:textures/gui/transparent.png"); 55 | 56 | EVENT_HANDLER = new CMMEventHandler(); 57 | MinecraftForge.EVENT_BUS.register(EVENT_HANDLER); 58 | FMLCommonHandler.instance().bus().register(EVENT_HANDLER); 59 | 60 | logger = event.getModLog(); 61 | 62 | configLoader = new ConfigurationLoader(config); 63 | 64 | try 65 | { 66 | configLoader.load(); 67 | } 68 | catch (Exception e) 69 | { 70 | logger.log(Level.ERROR, "Error while loading config file. Will have to crash here :(."); 71 | throw new RuntimeException(e); 72 | } 73 | } 74 | 75 | @EventHandler 76 | public void postInit(FMLPostInitializationEvent event) 77 | { 78 | 79 | } 80 | 81 | public void reload() 82 | { 83 | Config backup = config; 84 | config = new Config(); 85 | configLoader = new ConfigurationLoader(config); 86 | try 87 | { 88 | configLoader.load(); 89 | EVENT_HANDLER.displayMs = -1; 90 | } 91 | catch (Exception e) 92 | { 93 | e.printStackTrace(); 94 | 95 | EVENT_HANDLER.displayMs = System.currentTimeMillis(); 96 | logger.log(Level.ERROR, "Error while loading new config file, trying to keep the old one loaded."); 97 | config = backup; 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/lumien/custommainmenu/configuration/Alignment.java: -------------------------------------------------------------------------------- 1 | package lumien.custommainmenu.configuration; 2 | 3 | public class Alignment 4 | { 5 | public float factorX; 6 | public float factorY; 7 | 8 | public Alignment(float factorX, float factorY) 9 | { 10 | this.factorX = factorX; 11 | this.factorY = factorY; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/lumien/custommainmenu/configuration/Config.java: -------------------------------------------------------------------------------- 1 | package lumien.custommainmenu.configuration; 2 | 3 | import java.util.HashMap; 4 | 5 | import lumien.custommainmenu.gui.GuiCustom; 6 | 7 | public class Config 8 | { 9 | HashMap guis; 10 | 11 | public Config() 12 | { 13 | guis = new HashMap(); 14 | } 15 | 16 | public void addGui(String name, GuiCustom gc) 17 | { 18 | GuiEntry entry = guis.get(name); 19 | 20 | if (entry == null) 21 | { 22 | entry = new GuiEntry(); 23 | guis.put(name, entry); 24 | } 25 | 26 | int scale = gc.guiConfig.guiScale; 27 | 28 | if (scale == -1) 29 | { 30 | entry.standard = gc; 31 | } 32 | else if (scale == 0) 33 | { 34 | entry.auto = gc; 35 | } 36 | else if (scale == 1) 37 | { 38 | entry.small = gc; 39 | } 40 | else if (scale == 2) 41 | { 42 | entry.normal = gc; 43 | } 44 | else if (scale == 3) 45 | { 46 | entry.large = gc; 47 | } 48 | } 49 | 50 | public GuiCustom getGUI(String name) 51 | { 52 | return guis.get(name).getCurrentGUI(); 53 | } 54 | 55 | public void tick() 56 | { 57 | guis.values().forEach((ge) -> ge.getCurrentGUI().tick()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/lumien/custommainmenu/configuration/ConfigurationLoader.java: -------------------------------------------------------------------------------- 1 | package lumien.custommainmenu.configuration; 2 | 3 | import java.io.File; 4 | import java.io.FileNotFoundException; 5 | import java.io.FileOutputStream; 6 | import java.io.FileReader; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | 11 | import lumien.custommainmenu.CustomMainMenu; 12 | import lumien.custommainmenu.gui.GuiCustom; 13 | 14 | import org.apache.commons.io.IOUtils; 15 | 16 | import com.google.common.io.ByteStreams; 17 | import com.google.common.io.Files; 18 | import com.google.gson.JsonElement; 19 | import com.google.gson.JsonObject; 20 | import com.google.gson.JsonParser; 21 | import com.google.gson.stream.JsonReader; 22 | 23 | public class ConfigurationLoader 24 | { 25 | Config config; 26 | 27 | public ConfigurationLoader(Config config) 28 | { 29 | this.config = config; 30 | } 31 | 32 | public void load() throws Exception 33 | { 34 | JsonParser jsonParser = new JsonParser(); 35 | 36 | File configFolder = new File(CustomMainMenu.INSTANCE.configFolder, "CustomMainMenu"); 37 | if (!configFolder.exists()) 38 | { 39 | configFolder.mkdir(); 40 | } 41 | 42 | File mainmenuConfig = new File(configFolder, "mainmenu.json"); 43 | if (!mainmenuConfig.exists()) 44 | { 45 | InputStream input = null; 46 | 47 | OutputStream output = null; 48 | try 49 | { 50 | output = new FileOutputStream(mainmenuConfig); 51 | input = getClass().getResourceAsStream("/assets/custommainmenu/mainmenu_default.json"); 52 | ByteStreams.copy(input, output); 53 | } 54 | catch (FileNotFoundException e1) 55 | { 56 | e1.printStackTrace(); 57 | } 58 | catch (IOException e) 59 | { 60 | e.printStackTrace(); 61 | } 62 | finally 63 | { 64 | IOUtils.closeQuietly(output); 65 | IOUtils.closeQuietly(input); 66 | } 67 | } 68 | 69 | File[] jsonFiles = configFolder.listFiles(); 70 | 71 | 72 | // Preload Main Menu so that other menus can rely on it 73 | 74 | for (File guiFile : jsonFiles) 75 | { 76 | if (guiFile.getName().equals("mainmenu.json")) 77 | { 78 | GuiConfig guiConfig = new GuiConfig(); 79 | String name = guiFile.getName().replace(".json", ""); 80 | 81 | JsonReader reader = null; 82 | try 83 | { 84 | reader = new JsonReader(new FileReader(guiFile)); 85 | } 86 | catch (FileNotFoundException e) 87 | { 88 | e.printStackTrace(); 89 | } 90 | try 91 | { 92 | JsonElement jsonElement = jsonParser.parse(reader); 93 | JsonObject jsonObject = jsonElement.getAsJsonObject(); 94 | 95 | guiConfig.load(name, jsonObject); 96 | } 97 | catch (Exception e) 98 | { 99 | try 100 | { 101 | reader.close(); 102 | } 103 | catch (IOException io) 104 | { 105 | io.printStackTrace(); 106 | } 107 | throw e; 108 | } 109 | 110 | try 111 | { 112 | reader.close(); 113 | } 114 | catch (IOException io) 115 | { 116 | io.printStackTrace(); 117 | } 118 | 119 | this.config.addGui(guiConfig.name, new GuiCustom(guiConfig)); 120 | } 121 | } 122 | 123 | for (File guiFile : jsonFiles) 124 | { 125 | if (!guiFile.getName().equals("mainmenu.json") && guiFile.getName().endsWith(".json")) 126 | { 127 | GuiConfig guiConfig = new GuiConfig(); 128 | String name = guiFile.getName().replace(".json", ""); 129 | 130 | JsonReader reader = null; 131 | try 132 | { 133 | reader = new JsonReader(new FileReader(guiFile)); 134 | } 135 | catch (FileNotFoundException e) 136 | { 137 | e.printStackTrace(); 138 | } 139 | try 140 | { 141 | JsonElement jsonElement = jsonParser.parse(reader); 142 | JsonObject jsonObject = jsonElement.getAsJsonObject(); 143 | 144 | guiConfig.load(name, jsonObject); 145 | } 146 | catch (Exception e) 147 | { 148 | try 149 | { 150 | reader.close(); 151 | } 152 | catch (IOException io) 153 | { 154 | io.printStackTrace(); 155 | } 156 | throw e; 157 | } 158 | 159 | try 160 | { 161 | reader.close(); 162 | } 163 | catch (IOException io) 164 | { 165 | io.printStackTrace(); 166 | } 167 | 168 | this.config.addGui(guiConfig.name, new GuiCustom(guiConfig)); 169 | } 170 | } 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/main/java/lumien/custommainmenu/configuration/GuiConfig.java: -------------------------------------------------------------------------------- 1 | package lumien.custommainmenu.configuration; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.HashSet; 6 | import java.util.List; 7 | import java.util.Map.Entry; 8 | import java.util.Random; 9 | import java.util.Set; 10 | 11 | import lumien.custommainmenu.CustomMainMenu; 12 | import lumien.custommainmenu.configuration.elements.Background; 13 | import lumien.custommainmenu.configuration.elements.Button; 14 | import lumien.custommainmenu.configuration.elements.Image; 15 | import lumien.custommainmenu.configuration.elements.Panorama; 16 | import lumien.custommainmenu.configuration.elements.Slideshow; 17 | import lumien.custommainmenu.configuration.elements.SplashText; 18 | import lumien.custommainmenu.configuration.elements.Label; 19 | import lumien.custommainmenu.gui.GuiCustom; 20 | import lumien.custommainmenu.lib.ANCHOR; 21 | import lumien.custommainmenu.lib.actions.ActionConnectToServer; 22 | import lumien.custommainmenu.lib.actions.ActionLoadWorld; 23 | import lumien.custommainmenu.lib.actions.ActionOpenFolder; 24 | import lumien.custommainmenu.lib.actions.ActionOpenGUI; 25 | import lumien.custommainmenu.lib.actions.ActionOpenLink; 26 | import lumien.custommainmenu.lib.actions.ActionOpenModConfig; 27 | import lumien.custommainmenu.lib.actions.ActionQuit; 28 | import lumien.custommainmenu.lib.actions.ActionRefresh; 29 | import lumien.custommainmenu.lib.actions.IAction; 30 | import lumien.custommainmenu.lib.texts.IText; 31 | import lumien.custommainmenu.lib.texts.TextResourceLocation; 32 | import lumien.custommainmenu.lib.texts.TextString; 33 | import lumien.custommainmenu.lib.texts.TextURL; 34 | import lumien.custommainmenu.lib.textures.ITexture; 35 | import lumien.custommainmenu.lib.textures.TextureApng; 36 | import lumien.custommainmenu.lib.textures.TextureResourceLocation; 37 | import lumien.custommainmenu.lib.textures.TextureURL; 38 | 39 | import net.minecraft.util.ResourceLocation; 40 | 41 | import org.apache.logging.log4j.Level; 42 | 43 | import com.google.gson.JsonArray; 44 | import com.google.gson.JsonElement; 45 | import com.google.gson.JsonObject; 46 | 47 | public class GuiConfig 48 | { 49 | public String name; 50 | public int guiScale; 51 | 52 | public ArrayList