From 9bf010e222ba58a3fe2a4a3e0845b2977edebdf8 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 21 Aug 2019 15:41:38 -0400 Subject: [PATCH] Removed lwjgl3 desktop module, sdl promoted to main module --- .gitignore | 2 - build.gradle | 25 +-- desktop-sdl/build.gradle | 189 ------------------ .../mindustry/desktopsdl/DesktopLauncher.java | 30 --- .../mindustry/desktopsdl/DesktopPlatform.java | 138 ------------- desktop/build.gradle | 140 +++++++------ .../mindustry/desktop/DesktopLauncher.java | 27 +-- .../mindustry/desktop/DesktopPlatform.java | 39 ++-- settings.gradle | 2 +- 9 files changed, 114 insertions(+), 478 deletions(-) delete mode 100644 desktop-sdl/build.gradle delete mode 100644 desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopLauncher.java delete mode 100644 desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopPlatform.java diff --git a/.gitignore b/.gitignore index 79cf5235d0..f665dbc65e 100644 --- a/.gitignore +++ b/.gitignore @@ -21,8 +21,6 @@ logs/ /server/build/ /test_files/ /annotations/build/ -/desktop-sdl/build/ -desktop-sdl/build/ /android/assets/mindustry-maps/ /android/assets/mindustry-saves/ /core/assets/gifexport/ diff --git a/build.gradle b/build.gradle index 3d1909bff5..736131c9e3 100644 --- a/build.gradle +++ b/build.gradle @@ -145,23 +145,6 @@ allprojects{ project(":desktop"){ apply plugin: "java" - dependencies{ - compile project(":core") - compile project(":net") - - if(debugged()) compile project(":debug") - - compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" - compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" - - compile arcModule("backends:backend-lwjgl3") - compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.2' - } -} - -project(":desktop-sdl"){ - apply plugin: "java" - dependencies{ compile project(":core") compile project(":net") @@ -328,10 +311,10 @@ task deployAll{ } dependsOn cleanDeployOutput - dependsOn "desktop-sdl:packrLinux64" - dependsOn "desktop-sdl:packrWindows64" - dependsOn "desktop-sdl:packrWindows32" - dependsOn "desktop-sdl:packrMacOS" + dependsOn "desktop:packrLinux64" + dependsOn "desktop:packrWindows64" + dependsOn "desktop:packrWindows32" + dependsOn "desktop:packrMacOS" dependsOn "server:deploy" dependsOn "android:deploy" } \ No newline at end of file diff --git a/desktop-sdl/build.gradle b/desktop-sdl/build.gradle deleted file mode 100644 index 66052c51bd..0000000000 --- a/desktop-sdl/build.gradle +++ /dev/null @@ -1,189 +0,0 @@ -import com.badlogicgames.packr.Packr -import com.badlogicgames.packr.PackrConfig - -apply plugin: "java" - -sourceCompatibility = 1.8 -sourceSets.main.java.srcDirs = [ "src/" ] - -project.ext.mainClassName = "io.anuke.mindustry.desktopsdl.DesktopLauncher" -project.ext.assetsDir = new File("../core/assets") - -def IKVM_DIR = System.env.IKVM_HOME -//def getTarget = { return project.hasProperty("target") ? project.properties["target"] : "windows" } - -def JDK_DIR = "$System.env.PACKR_DIR" -def ICON_DIR = new File("core/assets/icons/icon.icns") - -task run(dependsOn: classes, type: JavaExec){ - main = project.mainClassName - classpath = sourceSets.main.runtimeClasspath - standardInput = System.in - workingDir = project.assetsDir - ignoreExitValue = true - - if(System.getProperty("os.name").toLowerCase().contains("mac")){ - jvmArgs("-XstartOnFirstThread", "-Djava.awt.headless=true") - } - - if(project.hasProperty("args")){ - args Eval.me(project.getProperties()["args"]) - } - - if(args.contains("debug")){ - main = "io.anuke.mindustry.DebugLauncher" - } -} - - - -["Windows", "Linux", "Mac", "All"].each{ target -> - task "dist$target"(type: Jar, dependsOn: classes){ - from files(sourceSets.main.output.classesDirs) - from files(sourceSets.main.output.resourcesDir) - from {configurations.compile.collect {zipTree(it)}} - from files(project.assetsDir) - - if(target.contains("windows")) exclude('**.so', "**.dylib") - if(target == "mac") exclude('**.so', "**.dll") - if(target == "linux") exclude('**.dll', "**.dylib") - archiveName = "$appName-${target}.jar" - - manifest{ - attributes 'Main-Class': project.mainClassName - } - } -} - -/* -task ikZip(type: Zip){ - def filename = "$appName-${getTarget()}-${version}" - - from "build/libs/$filename" - archiveName = "${generateDeployName(getTarget())}.zip" -} - -task ikdist{ - dependsOn dist - finalizedBy ikZip - - doLast{ - def filename = "$appName-${getTarget()}-${version}" - def folder = "build/libs/$filename" - def baseArgs = System.properties['os.name'].toLowerCase().contains('windows') ? [] : ["mono"] - def args = baseArgs + ["$IKVM_DIR/ikvmc.exe", "-target:winexe", "-out:build/libs/${filename}.exe", "build/libs/${filename}.jar"] - if(file("../core/assets/sprites/icon.ico").exists()){ - args += ["-win32icon:../core/assets/sprites/icon.ico"] - }else if(file("../core/assets/icons/icon.ico").exists()){ - args += ["-win32icon:../core/assets/icons/icon.ico"] - } - - exec{ - commandLine args - } - - copy{ - from file("build/libs/${filename}.exe") - into file(folder) - } - - copy{ - from(getTarget().contains("32") ? "$IKVM_DIR/libraries_32" : "$IKVM_DIR/libraries") - into folder - } - } -}*/ - -PackrConfig.Platform.values().each{ platform -> - task "packr${platform.toString()}"{ - def platformName = platform.toString().replace('64', '').replace('32', '').replace('MacOS', 'Mac') - - dependsOn "dist$platformName" - - doLast{ - copy{ - into "build/packr/" - rename("$appName-${platformName}.jar", "desktop.jar") - from "build/libs/$appName-${platformName}.jar" - } - - delete{ - delete "build/packr/output/" - } - - if(platform == PackrConfig.Platform.Windows32 || platform == PackrConfig.Platform.Windows64){ - copy{ - into "build/packr/output" - from "${JDK_DIR}/templates/${platform.toString().toLowerCase()}" - } - - copy{ - into "build/packr/output/jre" - rename("$appName-${platformName}.jar", "desktop.jar") - from "build/libs/$appName-${platformName}.jar" - } - }else{ - def config = new PackrConfig() - config.with{ - config.executable = appName - config.platform = platform - verbose = true - bundleIdentifier = getPackage() + ".mac" - iconResource = ICON_DIR - outDir = file("build/packr/output") - mainClass = project.ext.mainClassName - classpath = ["desktop-sdl/build/packr/desktop.jar"] - removePlatformLibs = ["desktop-sdl/build/packr/desktop.jar"] - - vmArgs = ["Djava.net.preferIPv4Stack=true"] - minimizeJre = "desktop/packr_minimize.json" - jdk = JDK_DIR + "jdk-${platform.toString().toLowerCase()}.zip" - - if(platform == PackrConfig.Platform.MacOS){ - vmArgs += "XstartOnFirstThread" - } - } - - new Packr().pack(config) - - if(platform == PackrConfig.Platform.Linux64){ - copy{ - into "build/packr/output/jre/" - from "build/packr/output/desktop.jar" - } - - delete{ - delete "build/packr/output/desktop.jar" - } - - file("build/packr/output/config.json").text = file("build/packr/output/config.json").text.replace("desktop.jar", "jre/desktop.jar") - } - - if(platform == PackrConfig.Platform.MacOS){ - copy{ - into "build/packr/${appName}.app/Contents/" - from "build/packr/Contents/" - } - - delete{ - delete "build/packr/Contents/" - } - } - } - } - - task "zip${platform.toString()}"(type: Zip){ - from "build/packr/output" - archiveName "${generateDeployName(platform.toString())}.zip" - destinationDir(file("../deploy")) - - doLast{ - delete{ - delete "build/packr/" - } - } - } - - finalizedBy "zip${platform.toString()}" - } -} diff --git a/desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopLauncher.java b/desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopLauncher.java deleted file mode 100644 index f773f0e188..0000000000 --- a/desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopLauncher.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.anuke.mindustry.desktopsdl; -import io.anuke.arc.Files.*; -import io.anuke.arc.backends.sdl.*; -import io.anuke.mindustry.*; -import io.anuke.mindustry.core.*; -import io.anuke.mindustry.net.*; - -public class DesktopLauncher{ - - public static void main(String[] arg){ - try{ - Platform.instance = new DesktopPlatform(arg); - - Net.setClientProvider(new ArcNetClient()); - Net.setServerProvider(new ArcNetServer()); - - new SdlApplication(new Mindustry(), new SdlConfig(){{ - title = "Mindustry"; - maximized = true; - depth = 0; - stencil = 0; - width = 900; - height = 700; - setWindowIcon(FileType.Internal, "icons/icon_64.png"); - }}); - }catch(Throwable e){ - DesktopPlatform.handleCrash(e); - } - } -} diff --git a/desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopPlatform.java b/desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopPlatform.java deleted file mode 100644 index 420ef0260c..0000000000 --- a/desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopPlatform.java +++ /dev/null @@ -1,138 +0,0 @@ -package io.anuke.mindustry.desktopsdl; - -import club.minnced.discord.rpc.*; -import io.anuke.arc.backends.sdl.jni.SDL; -import io.anuke.arc.collection.*; -import io.anuke.arc.files.*; -import io.anuke.arc.function.*; -import io.anuke.arc.util.*; -import io.anuke.arc.util.serialization.*; -import io.anuke.mindustry.core.GameState.*; -import io.anuke.mindustry.core.*; -import io.anuke.mindustry.net.*; -import io.anuke.mindustry.ui.dialogs.*; - -import java.net.*; -import java.util.*; - -import static io.anuke.mindustry.Vars.*; - - -public class DesktopPlatform extends Platform{ - static boolean useDiscord = OS.is64Bit; - final static String applicationId = "610508934456934412"; - String[] args; - - public DesktopPlatform(String[] args){ - this.args = args; - - testMobile = Array.with(args).contains("-testMobile"); - - if(useDiscord){ - try{ - DiscordEventHandlers handlers = new DiscordEventHandlers(); - DiscordRPC.INSTANCE.Discord_Initialize(applicationId, handlers, true, ""); - - Runtime.getRuntime().addShutdownHook(new Thread(DiscordRPC.INSTANCE::Discord_Shutdown)); - }catch(Throwable t){ - useDiscord = false; - Log.err("Failed to initialize discord.", t); - } - } - } - - static void handleCrash(Throwable e){ - Consumer dialog = Runnable::run; - boolean badGPU = false; - - if(e.getMessage() != null && (e.getMessage().contains("Couldn't create window") || e.getMessage().contains("OpenGL 2.0 or higher"))){ - - dialog.accept(() -> message( - e.getMessage().contains("Couldn't create window") ? "A graphics initialization error has occured! Try to update your graphics drivers:\n" + e.getMessage() : - "Your graphics card does not support OpenGL 2.0!\n" + - "Try to update your graphics drivers.\n\n" + - "(If that doesn't work, your computer just doesn't support Mindustry.)")); - badGPU = true; - } - - boolean fbgp = badGPU; - - CrashSender.send(e, file -> { - if(!fbgp){ - dialog.accept(() -> message("A crash has occured. It has been saved in:\n" + file.getAbsolutePath() + "\n" + (e.getMessage() == null ? "" : "\n" + e.getMessage()))); - } - }); - } - - @Override - public void showFileChooser(String text, String content, Consumer cons, boolean open, Predicate filetype){ - new FileChooser(text, file -> filetype.test(file.extension().toLowerCase()), open, cons).show(); - } - - @Override - public void updateRPC(){ - - if(!useDiscord) return; - - DiscordRichPresence presence = new DiscordRichPresence(); - - if(!state.is(State.menu)){ - String map = world.getMap() == null ? "Unknown Map" : world.isZone() ? world.getZone().localizedName : Strings.capitalize(world.getMap().name()); - String mode = state.rules.pvp ? "PvP" : state.rules.attackMode ? "Attack" : "Survival"; - String players = Net.active() && playerGroup.size() > 1 ? " | " + playerGroup.size() + " Players" : ""; - - presence.state = mode + players; - - if(!state.rules.waves){ - presence.details = map; - }else{ - presence.details = map + " | Wave " + state.wave; - presence.largeImageText = "Wave " + state.wave; - } - }else{ - if(ui.editor != null && ui.editor.isShown()){ - presence.state = "In Editor"; - }else if(ui.deploy != null && ui.deploy.isShown()){ - presence.state = "In Launch Selection"; - }else{ - presence.state = "In Menu"; - } - } - - presence.largeImageKey = "logo"; - - DiscordRPC.INSTANCE.Discord_UpdatePresence(presence); - } - - @Override - public String getUUID(){ - try{ - Enumeration e = NetworkInterface.getNetworkInterfaces(); - NetworkInterface out; - for(out = e.nextElement(); (out.getHardwareAddress() == null || !validAddress(out.getHardwareAddress())) && e.hasMoreElements(); out = e.nextElement()); - - byte[] bytes = out.getHardwareAddress(); - byte[] result = new byte[8]; - System.arraycopy(bytes, 0, result, 0, bytes.length); - - String str = new String(Base64Coder.encode(result)); - - if(str.equals("AAAAAAAAAOA=") || str.equals("AAAAAAAAAAA=")) throw new RuntimeException("Bad UUID."); - - return str; - }catch(Exception e){ - return super.getUUID(); - } - } - - private static void message(String message){ - SDL.SDL_ShowSimpleMessageBox(SDL.SDL_MESSAGEBOX_ERROR, "oh no", message); - } - - private boolean validAddress(byte[] bytes){ - if(bytes == null) return false; - byte[] result = new byte[8]; - System.arraycopy(bytes, 0, result, 0, bytes.length); - return !new String(Base64Coder.encode(result)).equals("AAAAAAAAAOA=") && !new String(Base64Coder.encode(result)).equals("AAAAAAAAAAA="); - } -} diff --git a/desktop/build.gradle b/desktop/build.gradle index d0d542bdb1..26392656d2 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -1,44 +1,28 @@ +import com.badlogicgames.packr.Packr +import com.badlogicgames.packr.PackrConfig + apply plugin: "java" sourceCompatibility = 1.8 -sourceSets.main.java.srcDirs = ["src/"] +sourceSets.main.java.srcDirs = [ "src/" ] project.ext.mainClassName = "io.anuke.mindustry.desktop.DesktopLauncher" project.ext.assetsDir = new File("../core/assets") -def IKVM_DIR = System.env.IKVM_HOME - -import com.badlogicgames.packr.Packr -import com.badlogicgames.packr.PackrConfig - def JDK_DIR = "$System.env.PACKR_DIR" def ICON_DIR = new File("core/assets/icons/icon.icns") -/* -ext.getPlatform = { - def lc = project.hasProperty("platform") ? platform.toLowerCase() : "" - if(lc == "windows64"){ - return PackrConfig.Platform.Windows64 - }else if(lc == "windows32"){ - return PackrConfig.Platform.Windows32 - }else if(lc == "linux"){ - return PackrConfig.Platform.Linux64 - }else if(lc == "mac"){ - return PackrConfig.Platform.MacOS - }else{ - throw new InvalidUserDataException("Invalid platform. Set platform with -Pplatform=windows64/windows32/linux/mac") - } -}*/ - task run(dependsOn: classes, type: JavaExec){ main = project.mainClassName classpath = sourceSets.main.runtimeClasspath standardInput = System.in workingDir = project.assetsDir - if(System.getProperty("os.name").toLowerCase().contains("mac")){ - jvmArgs "-XstartOnFirstThread" - } ignoreExitValue = true + + if(System.getProperty("os.name").toLowerCase().contains("mac")){ + jvmArgs("-XstartOnFirstThread", "-Djava.awt.headless=true") + } + if(project.hasProperty("args")){ args Eval.me(project.getProperties()["args"]) } @@ -48,43 +32,51 @@ task run(dependsOn: classes, type: JavaExec){ } } -task debug(dependsOn: classes, type: JavaExec){ - main = project.mainClassName - classpath = sourceSets.main.runtimeClasspath - standardInput = System.in - workingDir = project.assetsDir - ignoreExitValue = true - debug = true -} +["Windows", "Linux", "Mac", "All"].each{ target -> + task "dist$target"(type: Jar, dependsOn: classes){ + from files(sourceSets.main.output.classesDirs) + from files(sourceSets.main.output.resourcesDir) + from {configurations.compile.collect {zipTree(it)}} + from files(project.assetsDir) -task dist(type: Jar){ - dependsOn classes + if(target.contains("windows")) exclude('**.so', "**.dylib") + if(target == "mac") exclude('**.so', "**.dll") + if(target == "linux") exclude('**.dll', "**.dylib") + archiveName = "$appName-${target}.jar" - writeVersion() - - from files(sourceSets.main.output.classesDirs) - from files(sourceSets.main.output.resourcesDir) - from{ configurations.compile.collect{ zipTree(it) } } - from files(project.assetsDir) - - manifest{ - attributes 'Main-Class': project.mainClassName + manifest{ + attributes 'Main-Class': project.mainClassName + } } } PackrConfig.Platform.values().each{ platform -> task "packr${platform.toString()}"{ + def platformName = platform.toString().replace('64', '').replace('32', '').replace('MacOS', 'Mac') + + dependsOn "dist$platformName" + doLast{ + copy{ + into "build/packr/" + rename("$appName-${platformName}.jar", "desktop.jar") + from "build/libs/$appName-${platformName}.jar" + } + + delete{ + delete "build/packr/output/" + } + if(platform == PackrConfig.Platform.Windows32 || platform == PackrConfig.Platform.Windows64){ copy{ - into "packr-out/" + into "build/packr/output" from "${JDK_DIR}/templates/${platform.toString().toLowerCase()}" } copy{ - into "packr-out/" - rename("desktop-release.jar", "desktop.jar") - from "../desktop-sdl/build/libs/desktop.jar" + into "build/packr/output/jre" + rename("$appName-${platformName}.jar", "desktop.jar") + from "build/libs/$appName-${platformName}.jar" } }else{ def config = new PackrConfig() @@ -94,10 +86,10 @@ PackrConfig.Platform.values().each{ platform -> verbose = true bundleIdentifier = getPackage() + ".mac" iconResource = ICON_DIR - outDir = file("packr-out/") + outDir = file("build/packr/output") mainClass = project.ext.mainClassName - classpath = ["desktop-sdl/build/libs/desktop.jar"] - removePlatformLibs = ["desktop-sdl/build/libs/desktop.jar"] + classpath = ["desktop/build/packr/desktop.jar"] + removePlatformLibs = ["desktop/build/packr/desktop.jar"] vmArgs = ["Djava.net.preferIPv4Stack=true"] minimizeJre = "desktop/packr_minimize.json" @@ -110,28 +102,44 @@ PackrConfig.Platform.values().each{ platform -> new Packr().pack(config) - if(platform == PackrConfig.Platform.MacOS){ + if(platform == PackrConfig.Platform.Linux64){ copy{ - into "packr-out/" + appName + ".app/Contents/" - from "packr-out/Contents/" + into "build/packr/output/jre/" + from "build/packr/output/desktop.jar" } delete{ - delete "packr-out/Contents/" + delete "build/packr/output/desktop.jar" + } + + file("build/packr/output/config.json").text = file("build/packr/output/config.json").text.replace("desktop.jar", "jre/desktop.jar") + } + + if(platform == PackrConfig.Platform.MacOS){ + copy{ + into "build/packr/${appName}.app/Contents/" + from "build/packr/Contents/" + } + + delete{ + delete "build/packr/Contents/" } } } - - task "zip${platform.toString()}"(type: Zip){ - from "packr-out/" - archiveName "${generateDeployName(platform.toString())}.zip" - destinationDir(file("packr-export")) - } - - finalizedBy 'rzip' - - delete "packr-out/" } + + task "zip${platform.toString()}"(type: Zip){ + from "build/packr/output" + archiveName "${generateDeployName(platform.toString())}.zip" + destinationDir(file("../deploy")) + + doLast{ + delete{ + delete "build/packr/" + } + } + } + + finalizedBy "zip${platform.toString()}" } } - diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java index d87a547712..3fcd880bf1 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java @@ -1,27 +1,28 @@ package io.anuke.mindustry.desktop; - -import io.anuke.arc.backends.lwjgl3.Lwjgl3Application; -import io.anuke.arc.backends.lwjgl3.Lwjgl3ApplicationConfiguration; -import io.anuke.mindustry.Mindustry; -import io.anuke.mindustry.core.Platform; +import io.anuke.arc.Files.*; +import io.anuke.arc.backends.sdl.*; +import io.anuke.mindustry.*; +import io.anuke.mindustry.core.*; import io.anuke.mindustry.net.*; public class DesktopLauncher{ public static void main(String[] arg){ try{ - Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); - config.setTitle("Mindustry"); - config.setMaximized(true); - config.setBackBufferConfig(8, 8, 8, 8, 0, 0, 0); - config.setWindowedMode(900, 600); - config.setWindowIcon("icons/icon_64.png"); - Platform.instance = new DesktopPlatform(arg); Net.setClientProvider(new ArcNetClient()); Net.setServerProvider(new ArcNetServer()); - new Lwjgl3Application(new Mindustry(), config); + + new SdlApplication(new Mindustry(), new SdlConfig(){{ + title = "Mindustry"; + maximized = true; + depth = 0; + stencil = 0; + width = 900; + height = 700; + setWindowIcon(FileType.Internal, "icons/icon_64.png"); + }}); }catch(Throwable e){ DesktopPlatform.handleCrash(e); } diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java index 92da3ecb1c..ec202d3c78 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java @@ -1,24 +1,23 @@ package io.anuke.mindustry.desktop; import club.minnced.discord.rpc.*; -import io.anuke.arc.collection.Array; -import io.anuke.arc.files.FileHandle; -import io.anuke.arc.function.Consumer; -import io.anuke.arc.function.Predicate; +import io.anuke.arc.backends.sdl.jni.SDL; +import io.anuke.arc.collection.*; +import io.anuke.arc.files.*; +import io.anuke.arc.function.*; import io.anuke.arc.util.*; -import io.anuke.arc.util.serialization.Base64Coder; -import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.core.Platform; -import io.anuke.mindustry.net.CrashSender; -import io.anuke.mindustry.net.Net; -import io.anuke.mindustry.ui.dialogs.FileChooser; -import org.lwjgl.util.tinyfd.TinyFileDialogs; +import io.anuke.arc.util.serialization.*; +import io.anuke.mindustry.core.GameState.*; +import io.anuke.mindustry.core.*; +import io.anuke.mindustry.net.*; +import io.anuke.mindustry.ui.dialogs.*; -import java.net.NetworkInterface; +import java.net.*; import java.util.*; import static io.anuke.mindustry.Vars.*; + public class DesktopPlatform extends Platform{ static boolean useDiscord = OS.is64Bit; final static String applicationId = "610508934456934412"; @@ -43,16 +42,16 @@ public class DesktopPlatform extends Platform{ } static void handleCrash(Throwable e){ - Consumer dialog = r -> new Thread(r).start(); + Consumer dialog = Runnable::run; boolean badGPU = false; if(e.getMessage() != null && (e.getMessage().contains("Couldn't create window") || e.getMessage().contains("OpenGL 2.0 or higher"))){ - dialog.accept(() -> TinyFileDialogs.tinyfd_messageBox("oh no", + dialog.accept(() -> message( e.getMessage().contains("Couldn't create window") ? "A graphics initialization error has occured! Try to update your graphics drivers:\n" + e.getMessage() : "Your graphics card does not support OpenGL 2.0!\n" + "Try to update your graphics drivers.\n\n" + - "(If that doesn't work, your computer just doesn't support Mindustry.)", "ok", "error", true)); + "(If that doesn't work, your computer just doesn't support Mindustry.)")); badGPU = true; } @@ -60,7 +59,7 @@ public class DesktopPlatform extends Platform{ CrashSender.send(e, file -> { if(!fbgp){ - dialog.accept(() -> TinyFileDialogs.tinyfd_messageBox("oh no", "A crash has occured. It has been saved in:\n" + file.getAbsolutePath(), "ok", "error", true)); + dialog.accept(() -> message("A crash has occured. It has been saved in:\n" + file.getAbsolutePath() + "\n" + (e.getMessage() == null ? "" : "\n" + e.getMessage()))); } }); } @@ -118,7 +117,7 @@ public class DesktopPlatform extends Platform{ String str = new String(Base64Coder.encode(result)); - if(str.equals("AAAAAAAAAOA=")) throw new RuntimeException("Bad UUID."); + if(str.equals("AAAAAAAAAOA=") || str.equals("AAAAAAAAAAA=")) throw new RuntimeException("Bad UUID."); return str; }catch(Exception e){ @@ -126,10 +125,14 @@ public class DesktopPlatform extends Platform{ } } + private static void message(String message){ + SDL.SDL_ShowSimpleMessageBox(SDL.SDL_MESSAGEBOX_ERROR, "oh no", message); + } + private boolean validAddress(byte[] bytes){ if(bytes == null) return false; byte[] result = new byte[8]; System.arraycopy(bytes, 0, result, 0, bytes.length); - return !new String(Base64Coder.encode(result)).equals("AAAAAAAAAOA="); + return !new String(Base64Coder.encode(result)).equals("AAAAAAAAAOA=") && !new String(Base64Coder.encode(result)).equals("AAAAAAAAAAA="); } } diff --git a/settings.gradle b/settings.gradle index 20085aa2fb..41b5080058 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -include 'desktop', 'desktop-sdl', 'core', 'net', 'server', 'ios', 'annotations', 'tools', 'tests' +include 'desktop', 'core', 'net', 'server', 'ios', 'annotations', 'tools', 'tests' def use = { String name -> include(name)