mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Fixed crashes not saving or displaying
This commit is contained in:
parent
2be3cc2f1e
commit
28ab2b3917
@ -2,12 +2,20 @@ package io.anuke.annotations;
|
||||
|
||||
import com.squareup.javapoet.*;
|
||||
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.tools.Diagnostic.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import javax.annotation.processing.AbstractProcessor;
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.tools.StandardLocation;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||
public class AssetsAnnotationProcessor extends AbstractProcessor{
|
||||
@ -30,8 +38,13 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
|
||||
if(round++ != 0) return false; //only process 1 round
|
||||
|
||||
try{
|
||||
process("Sounds", "core/assets/sounds", "io.anuke.arc.audio.Sound", "newSound");
|
||||
process("Musics", "core/assets/music", "io.anuke.arc.audio.Music", "newMusic");
|
||||
|
||||
String path = Paths.get(Utils.filer.createResource(StandardLocation.CLASS_OUTPUT, "no", "no")
|
||||
.toUri().toURL().toString().substring("file:/".length()))
|
||||
.getParent().getParent().getParent().getParent().getParent().getParent().toString();
|
||||
|
||||
process("Sounds", path + "/assets/sounds", "io.anuke.arc.audio.Sound", "newSound");
|
||||
process("Musics", path + "/assets/music", "io.anuke.arc.audio.Music", "newMusic");
|
||||
|
||||
return true;
|
||||
}catch(Exception e){
|
||||
@ -50,6 +63,7 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
|
||||
MethodSpec.Builder load = MethodSpec.methodBuilder("load").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
||||
MethodSpec.Builder dispose = MethodSpec.methodBuilder("dispose").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
||||
|
||||
|
||||
HashSet<String> names = new HashSet<>();
|
||||
Files.list(Paths.get(path)).forEach(p -> {
|
||||
String fname = p.getFileName().toString();
|
||||
|
@ -50,12 +50,12 @@ public class CrashSender{
|
||||
|
||||
try{
|
||||
File file = new File(OS.getAppDataDirectoryString(Vars.appName), "crashes/crash-report-" + DateTimeFormatter.ofPattern("MM_dd_yyyy_HH_mm_ss").format(LocalDateTime.now()) + ".txt");
|
||||
new File(OS.getAppDataDirectoryString(Vars.appName)).mkdir();
|
||||
Files.write(file.toPath(), parseException(exception).getBytes());
|
||||
Files.createDirectories(Paths.get(OS.getAppDataDirectoryString(Vars.appName), "crashes"));
|
||||
Files.write(file.toPath(), parseException(exception).getBytes());
|
||||
|
||||
writeListener.accept(file);
|
||||
}catch(Throwable ignored){
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
Log.err("Failed to save local crash report.");
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ 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 IKVM_DIR = "C:\\Users\\Anuke\\Documents\\ikvmbin-8.1.5717.0\\ikvm-8.1.5717.0\\bin"//System.env.IKVM_HOME
|
||||
def getTarget = { return project.hasProperty("target") ? project.properties["target"] : "windows" }
|
||||
|
||||
task run(dependsOn: classes, type: JavaExec) {
|
||||
@ -61,7 +61,8 @@ task ikdist{
|
||||
doLast{
|
||||
def filename = "$appName-windows-${version}"
|
||||
def folder = "build/libs/$filename"
|
||||
def args = ["mono", "$IKVM_DIR/ikvmc.exe", "-target:winexe", "-static", "-out:build/libs/${filename}.exe", "build/libs/${filename}.jar"]
|
||||
def baseArgs = System.properties['os.name'].toLowerCase().contains('windows') ? [] : ["mono"]
|
||||
def args = baseArgs + ["$IKVM_DIR/ikvmc.exe", "-target:winexe", "-static", "-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()){
|
||||
|
@ -41,7 +41,7 @@ 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"))){
|
||||
@ -58,7 +58,7 @@ public class DesktopPlatform extends Platform{
|
||||
|
||||
CrashSender.send(e, file -> {
|
||||
if(!fbgp){
|
||||
dialog.accept(() -> message("A crash has occured. It has been saved in:\n" + file.getAbsolutePath()));
|
||||
dialog.accept(() -> message("A crash has occured. It has been saved in:\n" + file.getAbsolutePath() + "\n" + (e.getMessage() == null ? "" : "\n" + e.getMessage())));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user