Removed lwjgl3 desktop module, sdl promoted to main module
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -21,8 +21,6 @@ logs/
|
|||||||
/server/build/
|
/server/build/
|
||||||
/test_files/
|
/test_files/
|
||||||
/annotations/build/
|
/annotations/build/
|
||||||
/desktop-sdl/build/
|
|
||||||
desktop-sdl/build/
|
|
||||||
/android/assets/mindustry-maps/
|
/android/assets/mindustry-maps/
|
||||||
/android/assets/mindustry-saves/
|
/android/assets/mindustry-saves/
|
||||||
/core/assets/gifexport/
|
/core/assets/gifexport/
|
||||||
|
|||||||
25
build.gradle
25
build.gradle
@@ -145,23 +145,6 @@ allprojects{
|
|||||||
project(":desktop"){
|
project(":desktop"){
|
||||||
apply plugin: "java"
|
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{
|
dependencies{
|
||||||
compile project(":core")
|
compile project(":core")
|
||||||
compile project(":net")
|
compile project(":net")
|
||||||
@@ -328,10 +311,10 @@ task deployAll{
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependsOn cleanDeployOutput
|
dependsOn cleanDeployOutput
|
||||||
dependsOn "desktop-sdl:packrLinux64"
|
dependsOn "desktop:packrLinux64"
|
||||||
dependsOn "desktop-sdl:packrWindows64"
|
dependsOn "desktop:packrWindows64"
|
||||||
dependsOn "desktop-sdl:packrWindows32"
|
dependsOn "desktop:packrWindows32"
|
||||||
dependsOn "desktop-sdl:packrMacOS"
|
dependsOn "desktop:packrMacOS"
|
||||||
dependsOn "server:deploy"
|
dependsOn "server:deploy"
|
||||||
dependsOn "android:deploy"
|
dependsOn "android:deploy"
|
||||||
}
|
}
|
||||||
@@ -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()}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<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(() -> 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<FileHandle> cons, boolean open, Predicate<String> 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<NetworkInterface> 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=");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +1,28 @@
|
|||||||
|
import com.badlogicgames.packr.Packr
|
||||||
|
import com.badlogicgames.packr.PackrConfig
|
||||||
|
|
||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
sourceSets.main.java.srcDirs = ["src/"]
|
sourceSets.main.java.srcDirs = [ "src/" ]
|
||||||
|
|
||||||
project.ext.mainClassName = "io.anuke.mindustry.desktop.DesktopLauncher"
|
project.ext.mainClassName = "io.anuke.mindustry.desktop.DesktopLauncher"
|
||||||
project.ext.assetsDir = new File("../core/assets")
|
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 JDK_DIR = "$System.env.PACKR_DIR"
|
||||||
def ICON_DIR = new File("core/assets/icons/icon.icns")
|
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){
|
task run(dependsOn: classes, type: JavaExec){
|
||||||
main = project.mainClassName
|
main = project.mainClassName
|
||||||
classpath = sourceSets.main.runtimeClasspath
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
standardInput = System.in
|
standardInput = System.in
|
||||||
workingDir = project.assetsDir
|
workingDir = project.assetsDir
|
||||||
if(System.getProperty("os.name").toLowerCase().contains("mac")){
|
|
||||||
jvmArgs "-XstartOnFirstThread"
|
|
||||||
}
|
|
||||||
ignoreExitValue = true
|
ignoreExitValue = true
|
||||||
|
|
||||||
|
if(System.getProperty("os.name").toLowerCase().contains("mac")){
|
||||||
|
jvmArgs("-XstartOnFirstThread", "-Djava.awt.headless=true")
|
||||||
|
}
|
||||||
|
|
||||||
if(project.hasProperty("args")){
|
if(project.hasProperty("args")){
|
||||||
args Eval.me(project.getProperties()["args"])
|
args Eval.me(project.getProperties()["args"])
|
||||||
}
|
}
|
||||||
@@ -48,43 +32,51 @@ task run(dependsOn: classes, type: JavaExec){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task debug(dependsOn: classes, type: JavaExec){
|
["Windows", "Linux", "Mac", "All"].each{ target ->
|
||||||
main = project.mainClassName
|
task "dist$target"(type: Jar, dependsOn: classes){
|
||||||
classpath = sourceSets.main.runtimeClasspath
|
|
||||||
standardInput = System.in
|
|
||||||
workingDir = project.assetsDir
|
|
||||||
ignoreExitValue = true
|
|
||||||
debug = true
|
|
||||||
}
|
|
||||||
|
|
||||||
task dist(type: Jar){
|
|
||||||
dependsOn classes
|
|
||||||
|
|
||||||
writeVersion()
|
|
||||||
|
|
||||||
from files(sourceSets.main.output.classesDirs)
|
from files(sourceSets.main.output.classesDirs)
|
||||||
from files(sourceSets.main.output.resourcesDir)
|
from files(sourceSets.main.output.resourcesDir)
|
||||||
from{ configurations.compile.collect{ zipTree(it) } }
|
from {configurations.compile.collect {zipTree(it)}}
|
||||||
from files(project.assetsDir)
|
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{
|
manifest{
|
||||||
attributes 'Main-Class': project.mainClassName
|
attributes 'Main-Class': project.mainClassName
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PackrConfig.Platform.values().each{ platform ->
|
PackrConfig.Platform.values().each{ platform ->
|
||||||
task "packr${platform.toString()}"{
|
task "packr${platform.toString()}"{
|
||||||
|
def platformName = platform.toString().replace('64', '').replace('32', '').replace('MacOS', 'Mac')
|
||||||
|
|
||||||
|
dependsOn "dist$platformName"
|
||||||
|
|
||||||
doLast{
|
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){
|
if(platform == PackrConfig.Platform.Windows32 || platform == PackrConfig.Platform.Windows64){
|
||||||
copy{
|
copy{
|
||||||
into "packr-out/"
|
into "build/packr/output"
|
||||||
from "${JDK_DIR}/templates/${platform.toString().toLowerCase()}"
|
from "${JDK_DIR}/templates/${platform.toString().toLowerCase()}"
|
||||||
}
|
}
|
||||||
|
|
||||||
copy{
|
copy{
|
||||||
into "packr-out/"
|
into "build/packr/output/jre"
|
||||||
rename("desktop-release.jar", "desktop.jar")
|
rename("$appName-${platformName}.jar", "desktop.jar")
|
||||||
from "../desktop-sdl/build/libs/desktop.jar"
|
from "build/libs/$appName-${platformName}.jar"
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
def config = new PackrConfig()
|
def config = new PackrConfig()
|
||||||
@@ -94,10 +86,10 @@ PackrConfig.Platform.values().each{ platform ->
|
|||||||
verbose = true
|
verbose = true
|
||||||
bundleIdentifier = getPackage() + ".mac"
|
bundleIdentifier = getPackage() + ".mac"
|
||||||
iconResource = ICON_DIR
|
iconResource = ICON_DIR
|
||||||
outDir = file("packr-out/")
|
outDir = file("build/packr/output")
|
||||||
mainClass = project.ext.mainClassName
|
mainClass = project.ext.mainClassName
|
||||||
classpath = ["desktop-sdl/build/libs/desktop.jar"]
|
classpath = ["desktop/build/packr/desktop.jar"]
|
||||||
removePlatformLibs = ["desktop-sdl/build/libs/desktop.jar"]
|
removePlatformLibs = ["desktop/build/packr/desktop.jar"]
|
||||||
|
|
||||||
vmArgs = ["Djava.net.preferIPv4Stack=true"]
|
vmArgs = ["Djava.net.preferIPv4Stack=true"]
|
||||||
minimizeJre = "desktop/packr_minimize.json"
|
minimizeJre = "desktop/packr_minimize.json"
|
||||||
@@ -110,28 +102,44 @@ PackrConfig.Platform.values().each{ platform ->
|
|||||||
|
|
||||||
new Packr().pack(config)
|
new Packr().pack(config)
|
||||||
|
|
||||||
if(platform == PackrConfig.Platform.MacOS){
|
if(platform == PackrConfig.Platform.Linux64){
|
||||||
copy{
|
copy{
|
||||||
into "packr-out/" + appName + ".app/Contents/"
|
into "build/packr/output/jre/"
|
||||||
from "packr-out/Contents/"
|
from "build/packr/output/desktop.jar"
|
||||||
}
|
}
|
||||||
|
|
||||||
delete{
|
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){
|
task "zip${platform.toString()}"(type: Zip){
|
||||||
from "packr-out/"
|
from "build/packr/output"
|
||||||
archiveName "${generateDeployName(platform.toString())}.zip"
|
archiveName "${generateDeployName(platform.toString())}.zip"
|
||||||
destinationDir(file("packr-export"))
|
destinationDir(file("../deploy"))
|
||||||
|
|
||||||
|
doLast{
|
||||||
|
delete{
|
||||||
|
delete "build/packr/"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finalizedBy 'rzip'
|
finalizedBy "zip${platform.toString()}"
|
||||||
|
|
||||||
delete "packr-out/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,28 @@
|
|||||||
package io.anuke.mindustry.desktop;
|
package io.anuke.mindustry.desktop;
|
||||||
|
import io.anuke.arc.Files.*;
|
||||||
import io.anuke.arc.backends.lwjgl3.Lwjgl3Application;
|
import io.anuke.arc.backends.sdl.*;
|
||||||
import io.anuke.arc.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
import io.anuke.mindustry.*;
|
||||||
import io.anuke.mindustry.Mindustry;
|
import io.anuke.mindustry.core.*;
|
||||||
import io.anuke.mindustry.core.Platform;
|
|
||||||
import io.anuke.mindustry.net.*;
|
import io.anuke.mindustry.net.*;
|
||||||
|
|
||||||
public class DesktopLauncher{
|
public class DesktopLauncher{
|
||||||
|
|
||||||
public static void main(String[] arg){
|
public static void main(String[] arg){
|
||||||
try{
|
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);
|
Platform.instance = new DesktopPlatform(arg);
|
||||||
|
|
||||||
Net.setClientProvider(new ArcNetClient());
|
Net.setClientProvider(new ArcNetClient());
|
||||||
Net.setServerProvider(new ArcNetServer());
|
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){
|
}catch(Throwable e){
|
||||||
DesktopPlatform.handleCrash(e);
|
DesktopPlatform.handleCrash(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
package io.anuke.mindustry.desktop;
|
package io.anuke.mindustry.desktop;
|
||||||
|
|
||||||
import club.minnced.discord.rpc.*;
|
import club.minnced.discord.rpc.*;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.backends.sdl.jni.SDL;
|
||||||
import io.anuke.arc.files.FileHandle;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.function.Consumer;
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.function.Predicate;
|
import io.anuke.arc.function.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.serialization.Base64Coder;
|
import io.anuke.arc.util.serialization.*;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.*;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.*;
|
||||||
import io.anuke.mindustry.net.CrashSender;
|
import io.anuke.mindustry.net.*;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.ui.dialogs.*;
|
||||||
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
|
||||||
import org.lwjgl.util.tinyfd.TinyFileDialogs;
|
|
||||||
|
|
||||||
import java.net.NetworkInterface;
|
import java.net.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
|
||||||
public class DesktopPlatform extends Platform{
|
public class DesktopPlatform extends Platform{
|
||||||
static boolean useDiscord = OS.is64Bit;
|
static boolean useDiscord = OS.is64Bit;
|
||||||
final static String applicationId = "610508934456934412";
|
final static String applicationId = "610508934456934412";
|
||||||
@@ -43,16 +42,16 @@ public class DesktopPlatform extends Platform{
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void handleCrash(Throwable e){
|
static void handleCrash(Throwable e){
|
||||||
Consumer<Runnable> dialog = r -> new Thread(r).start();
|
Consumer<Runnable> dialog = Runnable::run;
|
||||||
boolean badGPU = false;
|
boolean badGPU = false;
|
||||||
|
|
||||||
if(e.getMessage() != null && (e.getMessage().contains("Couldn't create window") || e.getMessage().contains("OpenGL 2.0 or higher"))){
|
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() :
|
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" +
|
"Your graphics card does not support OpenGL 2.0!\n" +
|
||||||
"Try to update your graphics drivers.\n\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;
|
badGPU = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +59,7 @@ public class DesktopPlatform extends Platform{
|
|||||||
|
|
||||||
CrashSender.send(e, file -> {
|
CrashSender.send(e, file -> {
|
||||||
if(!fbgp){
|
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));
|
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;
|
return str;
|
||||||
}catch(Exception e){
|
}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){
|
private boolean validAddress(byte[] bytes){
|
||||||
if(bytes == null) return false;
|
if(bytes == null) return false;
|
||||||
byte[] result = new byte[8];
|
byte[] result = new byte[8];
|
||||||
System.arraycopy(bytes, 0, result, 0, bytes.length);
|
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=");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 ->
|
def use = { String name ->
|
||||||
include(name)
|
include(name)
|
||||||
|
|||||||
Reference in New Issue
Block a user