rl-client: show FatalErrorDialog when the client crashes
This commit is contained in:
@@ -575,7 +575,7 @@ public class ClientLoader implements Supplier<Applet>
|
||||
Class<?> clientClass = classLoader.loadClass(initialClass);
|
||||
|
||||
Applet rs = (Applet) clientClass.newInstance();
|
||||
rs.setStub(new RSAppletStub(config));
|
||||
rs.setStub(new RSAppletStub(config, runtimeConfigLoader));
|
||||
|
||||
if (rs instanceof Client)
|
||||
{
|
||||
|
||||
@@ -25,16 +25,28 @@
|
||||
*/
|
||||
package net.runelite.client.rs;
|
||||
|
||||
import java.applet.Applet;
|
||||
import java.applet.AppletContext;
|
||||
import java.applet.AppletStub;
|
||||
import java.applet.AudioClip;
|
||||
import java.awt.Image;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import javax.swing.SwingUtilities;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.runelite.client.RuntimeConfig;
|
||||
import net.runelite.client.RuntimeConfigLoader;
|
||||
import net.runelite.client.ui.FatalErrorDialog;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
class RSAppletStub implements AppletStub
|
||||
{
|
||||
private final RSConfig config;
|
||||
private final RuntimeConfigLoader runtimeConfigLoader;
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
@@ -70,7 +82,89 @@ class RSAppletStub implements AppletStub
|
||||
@Override
|
||||
public AppletContext getAppletContext()
|
||||
{
|
||||
return null;
|
||||
return new AppletContext()
|
||||
{
|
||||
@Override
|
||||
public AudioClip getAudioClip(URL url)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(URL url)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Applet getApplet(String name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<Applet> getApplets()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDocument(URL url)
|
||||
{
|
||||
if (url.getPath().startsWith("/error_game_"))
|
||||
{
|
||||
try
|
||||
{
|
||||
RuntimeConfig rtc = runtimeConfigLoader.get();
|
||||
if (rtc.showOutageMessage())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
String code = url.getPath()
|
||||
.replace("/", "")
|
||||
.replace(".ws", "");
|
||||
|
||||
SwingUtilities.invokeLater(() ->
|
||||
new FatalErrorDialog("OldSchool RuneScape has crashed with the message: " + code + "")
|
||||
.setTitle("RuneLite", "OldSchool RuneScape has crashed")
|
||||
.addHelpButtons()
|
||||
.open());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDocument(URL url, String target)
|
||||
{
|
||||
showDocument(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showStatus(String status)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStream(String key, InputStream stream) throws IOException
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getStream(String key)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<String> getStreamKeys()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,6 +61,7 @@ public class FatalErrorDialog extends JDialog
|
||||
|
||||
private final JPanel rightColumn = new JPanel();
|
||||
private final Font font = new Font(Font.DIALOG, Font.PLAIN, 12);
|
||||
private final JLabel title;
|
||||
|
||||
public FatalErrorDialog(String message)
|
||||
{
|
||||
@@ -114,7 +115,7 @@ public class FatalErrorDialog extends JDialog
|
||||
leftPane.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
leftPane.setLayout(new BorderLayout());
|
||||
|
||||
JLabel title = new JLabel("There was a fatal error starting RuneLite");
|
||||
title = new JLabel("There was a fatal error starting RuneLite");
|
||||
title.setForeground(Color.WHITE);
|
||||
title.setFont(font.deriveFont(16.f));
|
||||
title.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
@@ -186,6 +187,13 @@ public class FatalErrorDialog extends JDialog
|
||||
return this;
|
||||
}
|
||||
|
||||
public FatalErrorDialog setTitle(String windowTitle, String header)
|
||||
{
|
||||
super.setTitle(windowTitle);
|
||||
title.setText(header);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FatalErrorDialog addHelpButtons()
|
||||
{
|
||||
return addButton("Open logs folder", () -> LinkBrowser.open(RuneLite.LOGS_DIR.toString()))
|
||||
|
||||
Reference in New Issue
Block a user