splashscreen: Show errors on the splashscreen (#1499)

This commit is contained in:
Owain van Brakel
2019-09-01 18:39:45 +02:00
committed by Ganom
parent 217c471a9e
commit 3e10c06bb1
5 changed files with 48 additions and 17 deletions

View File

@@ -264,15 +264,16 @@ public class RuneLite
Thread.setDefaultUncaughtExceptionHandler((thread, throwable) ->
{
log.error("Uncaught exception:", throwable);
if (throwable instanceof AbstractMethodError)
{
log.error("Classes are out of date; Build with Gradle again.");
RuneLiteSplashScreen.setError("Out of date!", "Classes are out of date; Build with Gradle again.");
return;
}
RuneLiteSplashScreen.setError("Error while loading!", "Please check your internet connection and your DNS settings.");
});
RuneLiteSplashScreen.stage(.2, "Starting RuneLitePlus injector");
RuneLiteSplashScreen.stage(0, "Starting RuneLitePlus injector");
final long start = System.currentTimeMillis();

View File

@@ -78,7 +78,6 @@ public class RuneLiteModule extends AbstractModule
bind(ItemManager.class);
bind(Scheduler.class);
bind(PluginManager.class);
bind(RuneLiteProperties.class);
bind(SessionManager.class);
bind(Callbacks.class).to(Hooks.class);

View File

@@ -26,40 +26,38 @@
*/
package net.runelite.client.rs;
import java.io.InputStream;
import java.net.URLClassLoader;
import com.google.common.io.ByteStreams;
import java.applet.Applet;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import com.google.common.io.ByteStreams;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.RuneLite;
import net.runelite.client.ui.RuneLiteSplashScreen;
@Slf4j
@Singleton
public class ClientLoader
{
private final ClientConfigLoader clientConfigLoader;
private final ClientUpdateCheckMode updateCheckMode;
@Inject
private ClientLoader(
@Named("updateCheckMode") final ClientUpdateCheckMode updateCheckMode,
final ClientConfigLoader clientConfigLoader)
@Named("updateCheckMode") final ClientUpdateCheckMode updateCheckMode)
{
this.updateCheckMode = updateCheckMode;
this.clientConfigLoader = clientConfigLoader;
}
public Applet load()
{
try
{
final RSConfig config = clientConfigLoader.fetch();
RuneLiteSplashScreen.stage(.2, "Fetching applet viewer config");
final RSConfig config = ClientConfigLoader.fetch();
switch (updateCheckMode)
{
@@ -82,8 +80,8 @@ public class ClientLoader
}
catch (ClassNotFoundException e)
{
log.error("Unable to load client - class not found. This means you"
+ " are not running RuneLite with Gradle as the injected client"
RuneLiteSplashScreen.setError("Unable to load client", "Class not found. This means you"
+ " are not running RuneLitePlus with Gradle as the injected client"
+ " is not in your classpath.");
log.error("Error loading RS!", e);
@@ -94,6 +92,8 @@ public class ClientLoader
private static Applet loadRLPlus(final RSConfig config)
throws ClassNotFoundException, InstantiationException, IllegalAccessException
{
RuneLiteSplashScreen.stage(.465, "Starting Old School RuneScape");
ClassLoader rsClassLoader = new ClassLoader(ClientLoader.class.getClassLoader())
{
@Override
@@ -113,6 +113,7 @@ public class ClientLoader
catch (IOException e)
{
e.printStackTrace();
RuneLiteSplashScreen.setError("Failed to load!", "Failed to load class: " + name + " " + path);
throw new RuntimeException("Failed to load class: " + name + " " + path);
}
return defineClass(name, data, 0, data.length);
@@ -125,6 +126,8 @@ public class ClientLoader
private static Applet loadVanilla(final RSConfig config)
throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
{
RuneLiteSplashScreen.stage(.465, "Starting Old School RuneScape");
final String codebase = config.getCodeBase();
final String initialJar = config.getInitialJar();
final String initialClass = config.getInitialClass();

View File

@@ -69,6 +69,27 @@ public class RuneLiteSplashScreen extends JFrame
this.setVisible(true);
}
public static void setError(String title, String content)
{
if (INSTANCE != null)
{
INSTANCE.setErrorInstance(title, content);
}
}
private void setErrorInstance(String title, String content)
{
messagePanel.setMessageContent(content);
messagePanel.setMessageTitle("Error!");
messagePanel.getBarLabel().setText(title);
messagePanel.getBar().setBackground(ColorScheme.PROGRESS_ERROR_COLOR.darker());
messagePanel.getBar().setForeground(ColorScheme.PROGRESS_ERROR_COLOR);
this.getContentPane().revalidate();
this.getContentPane().repaint();
}
private void setBarText(final String text)
{
final JProgressBar bar = messagePanel.getBar();

View File

@@ -145,11 +145,18 @@ public class MessagePanel extends JPanel
{
if (!content.startsWith("<html"))
{
content = "<html><div style='text-align:center;'>" + content + "</div></html>";
content = "<html><div style='width: 100%; text-align:center;'>" + content + "</div></html>";
}
messageArea.setText(content);
messageArea.revalidate();
messageArea.repaint();
}
public void setMessageTitle(String text)
{
titleLabel.setText(text);
titleLabel.revalidate();
titleLabel.repaint();
}
}