Skip to content

Commit 34c0cae

Browse files
committed
Show log when game crashes
1 parent 663441f commit 34c0cae

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

launcher-gui/src/main/java/org/taumc/launcher/gui/screens/home/HomeView.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,13 @@ public void refreshSidebar() {
399399
JOptionPane.showMessageDialog(null, error.toString(), "Error launching game", JOptionPane.ERROR_MESSAGE);
400400
}
401401
SwingUtilities.invokeLater(this::refreshSidebar);
402-
handler.exitFuture().whenCompleteAsync((p2, t2) -> this.refreshSidebar(), SwingUtilities::invokeLater);
402+
handler.exitFuture().whenCompleteAsync((p2, t2) -> {
403+
if (p2 != null && p2.exitValue() != 0) {
404+
var view = InstanceEditView.createOrShow(this, selectedInstance);
405+
view.setCurrentPage("Logs");
406+
}
407+
this.refreshSidebar();
408+
}, SwingUtilities::invokeLater);
403409
});
404410
refreshSidebar();
405411
});

launcher-gui/src/main/java/org/taumc/launcher/gui/screens/instance/InstanceEditView.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ private InstanceEditView(HomeView owner, String instance) {
113113
sidebar.addListSelectionListener(e -> {
114114
if (!e.getValueIsAdjusting()) {
115115
String selected = sidebar.getSelectedValue();
116-
CardLayout cl = (CardLayout) cardPanel.getLayout();
117-
cl.show(cardPanel, selected);
116+
setCurrentPage(selected);
118117
}
119118
});
120119

@@ -143,15 +142,24 @@ public static boolean isLocked(String instance) {
143142
return OPEN_EDIT_VIEWS.containsKey(instance);
144143
}
145144

146-
public static void createOrShow(HomeView owner, String instance) {
145+
public static InstanceEditView createOrShow(HomeView owner, String instance) {
147146
var view = OPEN_EDIT_VIEWS.get(instance);
148147
if (view != null) {
149148
view.toFront();
149+
return view;
150150
} else {
151-
new InstanceEditView(owner, instance);
151+
return new InstanceEditView(owner, instance);
152152
}
153153
}
154154

155+
public void setCurrentPage(String page) {
156+
if (!PAGES.containsKey(page)) {
157+
throw new IllegalArgumentException();
158+
}
159+
CardLayout cl = (CardLayout) cardPanel.getLayout();
160+
cl.show(cardPanel, page);
161+
}
162+
155163
private void readCurrentConfig() throws IOException {
156164
var mapper = new ObjectMapper();
157165
var mmcPack = mapper.readValue(this.mmcPackJson.toFile(), MMCPack.class);

0 commit comments

Comments
 (0)