fix[#454]: Open logs folder' option launches another instance of Magarena. See issue for full changes (http://code.google.com/p/magarena/issues/detail?id=454).
parent
89ef62c7b9
commit
9b37c18bbe
|
@ -24,3 +24,4 @@ release/lib/*
|
|||
release/Magarena/mods/
|
||||
release/Magarena/crash.png
|
||||
*.jpage
|
||||
release/Magarena/logs/crash.png
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
===
|
||||
=== Magarena Crash Reports ===
|
||||
===
|
||||
|
||||
If Magarena encounters an unexpected problem it records details about the error in the "<magarena installation>\Magarena\logs" directory. Magarena should have automatically opened this directory in your file explorer if you are reading this via the Magarena crash dialog.
|
||||
|
||||
"crash.log" contains a full trace of where and why the error occurred.
|
||||
"crash.png" is a screenshot of Magarena at the time the error occurred.
|
||||
|
||||
Please consider posting both of these files (or at least "crash.log") to the Magarena forum or Issue Tracker so that the development team can investigate further.
|
||||
|
||||
Magarena forum: http://www.slightlymagic.net/forum/viewforum.php?f=82
|
||||
Magarena issue tracker: http://code.google.com/p/magarena/issues
|
||||
|
||||
Thanks for your help.
|
|
@ -15,6 +15,10 @@ import javax.swing.UIManager;
|
|||
import javax.swing.UIManager.LookAndFeelInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class MagicMain {
|
||||
|
||||
|
@ -26,6 +30,7 @@ public class MagicMain {
|
|||
private static final String GAME_FOLDER = "Magarena";
|
||||
private static final String MODS_PATH = "mods";
|
||||
private static final String SCRIPTS_PATH = "scripts";
|
||||
private static final String LOGS_PATH = "logs";
|
||||
private static final String GAME_PATH =
|
||||
(System.getProperty("magarena.dir") != null ?
|
||||
System.getProperty("magarena.dir") :
|
||||
|
@ -73,7 +78,6 @@ public class MagicMain {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
public static String getGamePath() {
|
||||
return GAME_PATH;
|
||||
}
|
||||
|
@ -90,6 +94,19 @@ public class MagicMain {
|
|||
return getGamePath()+File.separatorChar+SCRIPTS_PATH;
|
||||
}
|
||||
|
||||
public static String getLogsPath() {
|
||||
final Path path = Paths.get(getGamePath()).resolve(LOGS_PATH);
|
||||
if (!Files.exists(path)) {
|
||||
try {
|
||||
Files.createDirectory(path);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return Paths.get(getGamePath()).toString();
|
||||
}
|
||||
}
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
static void initializeEngine() {
|
||||
CardDefinitions.loadCardDefinitions();
|
||||
if (Boolean.getBoolean("debug")) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Date;
|
|||
|
||||
public class MagicGameLog {
|
||||
|
||||
private static final String gameLog = MagicMain.getGamePath() + File.separator + "game.log";
|
||||
private static final String gameLog = MagicMain.getLogsPath() + File.separator + "game.log";
|
||||
private static PrintWriter writer;
|
||||
|
||||
private MagicGameLog() {}
|
||||
|
|
|
@ -2,9 +2,9 @@ package magic.model;
|
|||
|
||||
import magic.MagicMain;
|
||||
import magic.data.FileIO;
|
||||
import magic.data.URLUtils;
|
||||
import magic.model.action.MagicAction;
|
||||
import magic.model.stack.MagicItemOnStack;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Rectangle;
|
||||
|
@ -41,32 +41,23 @@ public class MagicGameReport implements Thread.UncaughtExceptionHandler {
|
|||
|
||||
// By specifying a frame the JOptionPane will be shown in the taskbar.
|
||||
// Otherwise if the dialog is hidden it is easy to forget it is still open.
|
||||
JFrame frame = new JFrame("Fatal Error");
|
||||
final JFrame frame = new JFrame("Fatal Error");
|
||||
frame.setUndecorated(true);
|
||||
frame.setVisible(true);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
// Custom option dialog.
|
||||
Object[] options = {"Open logs folder", "Issue Tracker", "Close"};
|
||||
int action = -1;
|
||||
do {
|
||||
action = JOptionPane.showOptionDialog(
|
||||
frame,
|
||||
"An unexpected error has occurred and Magarena will need to close.\n\n" +
|
||||
"Please consider posting the crash report (\"crash.log\") to the Magarena\n" +
|
||||
"forum or Issue Tracker so that the development team can investigate.\n\n",
|
||||
"Fatal Error",
|
||||
JOptionPane.YES_NO_CANCEL_OPTION,
|
||||
JOptionPane.ERROR_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[2]);
|
||||
String prompt = "An unexpected error has occurred and Magarena will need to close.";
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
prompt +=
|
||||
"\n\nPlease consider submitting a crash report so that the development team can investigate.\n" +
|
||||
"Would you like to open the crash logs directory in file explorer?";
|
||||
final int action = JOptionPane.showConfirmDialog(frame, prompt, "Fatal Error", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null);
|
||||
if (action == JOptionPane.YES_OPTION) {
|
||||
Desktop.getDesktop().open(new File(MagicMain.getGamePath()));
|
||||
} else if (action == JOptionPane.NO_OPTION) {
|
||||
URLUtils.openURL("http://code.google.com/p/magarena/issues/list");
|
||||
Desktop.getDesktop().open(new File(MagicMain.getLogsPath()));
|
||||
}
|
||||
} while (action != JOptionPane.CANCEL_OPTION && action != -1);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(frame, prompt, "Fatal Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// do nothing - crash report has already been generated and app is about to exit anyway.
|
||||
|
@ -196,7 +187,7 @@ public class MagicGameReport implements Thread.UncaughtExceptionHandler {
|
|||
System.err.println(sb.toString());
|
||||
|
||||
//save a copy to a crash log file
|
||||
final File clog = new File(MagicMain.getGamePath(), "crash.log");
|
||||
final File clog = new File(MagicMain.getLogsPath(), "crash.log");
|
||||
try {
|
||||
FileIO.toFile(clog, sb.toString(), true);
|
||||
} catch (final IOException ex3) {
|
||||
|
@ -213,7 +204,7 @@ public class MagicGameReport implements Thread.UncaughtExceptionHandler {
|
|||
Rectangle rec = container.getBounds();
|
||||
BufferedImage capture = new BufferedImage(rec.width, rec.height,BufferedImage.TYPE_INT_ARGB);
|
||||
container.paint(capture.getGraphics()); //capturing the components content in the capture object
|
||||
ImageIO.write(capture, "png", new File(MagicMain.getGamePath(), "crash.png"));
|
||||
ImageIO.write(capture, "png", new File(MagicMain.getLogsPath(), "crash.png"));
|
||||
} catch (Exception e) {
|
||||
System.err.println("grabScreenShot failed : " + e.toString());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue