Removed lwjgl3 desktop module, sdl promoted to main module
This commit is contained in:
+74
-66
@@ -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()}"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<Runnable> dialog = r -> new Thread(r).start();
|
||||
Consumer<Runnable> 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=");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user