Remove recursive dependency on RuneLite
- Merge ClientUI.show and ClientUI.init as now applet can be properly injected - Change RuneLite to be autocloseable and send it when opening ClientUI Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -31,7 +31,6 @@ import com.google.common.eventbus.EventBus;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import java.applet.Applet;
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -56,7 +55,6 @@ import net.runelite.client.plugins.PluginManager;
|
||||
import net.runelite.client.rs.ClientUpdateCheckMode;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.DrawManager;
|
||||
import net.runelite.client.ui.TitleToolbar;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.ui.overlay.OverlayRenderer;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
@@ -115,9 +113,6 @@ public class RuneLite
|
||||
@Inject
|
||||
private ClientUI clientUI;
|
||||
|
||||
@Inject
|
||||
private TitleToolbar titleToolbar;
|
||||
|
||||
@Inject
|
||||
private Provider<ItemManager> itemManager;
|
||||
|
||||
@@ -139,10 +134,6 @@ public class RuneLite
|
||||
@Inject
|
||||
private WorldMapOverlay worldMapOverlay;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
private Applet applet;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
private Client client;
|
||||
@@ -228,9 +219,6 @@ public class RuneLite
|
||||
injector.injectMembers(client);
|
||||
}
|
||||
|
||||
// Initialize UI
|
||||
clientUI.init(applet);
|
||||
|
||||
// Initialize Discord service
|
||||
discordService.init();
|
||||
|
||||
@@ -271,6 +259,9 @@ public class RuneLite
|
||||
// Load the session, including saved configuration
|
||||
sessionManager.loadSession();
|
||||
|
||||
// Initialize UI
|
||||
clientUI.open(this);
|
||||
|
||||
// Add core overlays after configuration has been loaded so their properties will be
|
||||
// loaded properly
|
||||
overlayManager.add(infoBoxOverlay);
|
||||
@@ -279,12 +270,6 @@ public class RuneLite
|
||||
|
||||
// Start plugins
|
||||
pluginManager.startCorePlugins();
|
||||
|
||||
// Refresh title toolbar
|
||||
titleToolbar.refresh();
|
||||
|
||||
// Show UI after all plugins are loaded
|
||||
clientUI.show();
|
||||
}
|
||||
|
||||
public void shutdown()
|
||||
|
||||
@@ -125,13 +125,13 @@ public class ClientUI
|
||||
@Getter
|
||||
private TrayIcon trayIcon;
|
||||
|
||||
private final RuneLite runelite;
|
||||
private final RuneLiteProperties properties;
|
||||
private final RuneLiteConfig config;
|
||||
private final EventBus eventBus;
|
||||
private final KeyManager keyManager;
|
||||
private final Applet client;
|
||||
private final ConfigManager configManager;
|
||||
private final CardLayout cardLayout = new CardLayout();
|
||||
private Applet client;
|
||||
private ContainableFrame frame;
|
||||
private JPanel navContainer;
|
||||
private PluginPanel pluginPanel;
|
||||
@@ -144,22 +144,21 @@ public class ClientUI
|
||||
private NavigationButton sidebarNavigationButton;
|
||||
private JButton sidebarNavigationJButton;
|
||||
|
||||
@Inject
|
||||
private ConfigManager configManager;
|
||||
|
||||
@Inject
|
||||
private ClientUI(
|
||||
RuneLite runelite,
|
||||
RuneLiteProperties properties,
|
||||
RuneLiteConfig config,
|
||||
EventBus eventBus,
|
||||
KeyManager keyManager)
|
||||
KeyManager keyManager,
|
||||
@Nullable Applet client,
|
||||
ConfigManager configManager)
|
||||
{
|
||||
this.runelite = runelite;
|
||||
this.properties = properties;
|
||||
this.config = config;
|
||||
this.eventBus = eventBus;
|
||||
this.keyManager = keyManager;
|
||||
this.client = client;
|
||||
this.configManager = configManager;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -337,13 +336,11 @@ public class ClientUI
|
||||
/**
|
||||
* Initialize UI.
|
||||
*
|
||||
* @param client the client
|
||||
* @param runelite runelite instance that will be shut down on exit
|
||||
* @throws Exception exception that can occur during creation of the UI
|
||||
*/
|
||||
public void init(@Nullable final Applet client) throws Exception
|
||||
public void open(final RuneLite runelite) throws Exception
|
||||
{
|
||||
this.client = client;
|
||||
|
||||
SwingUtilities.invokeAndWait(() ->
|
||||
{
|
||||
// Set some sensible swing defaults
|
||||
@@ -373,9 +370,7 @@ public class ClientUI
|
||||
saveClientBoundsConfig();
|
||||
runelite.shutdown();
|
||||
},
|
||||
() -> client != null
|
||||
&& client instanceof Client
|
||||
&& showWarningOnExit()
|
||||
this::showWarningOnExit
|
||||
);
|
||||
|
||||
container = new JPanel();
|
||||
@@ -401,6 +396,8 @@ public class ClientUI
|
||||
frame.addKeyListener(uiKeyListener);
|
||||
keyManager.registerKeyListener(uiKeyListener);
|
||||
});
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
private boolean showWarningOnExit()
|
||||
@@ -410,7 +407,7 @@ public class ClientUI
|
||||
return true;
|
||||
}
|
||||
|
||||
if (config.warningOnExit() == WarningOnExit.LOGGED_IN)
|
||||
if (config.warningOnExit() == WarningOnExit.LOGGED_IN && client instanceof Client)
|
||||
{
|
||||
return ((Client) client).getGameState() != GameState.LOGIN_SCREEN;
|
||||
}
|
||||
@@ -423,7 +420,7 @@ public class ClientUI
|
||||
*
|
||||
* @throws Exception exception that can occur during modification of the UI
|
||||
*/
|
||||
public void show() throws Exception
|
||||
private void show() throws Exception
|
||||
{
|
||||
final boolean withTitleBar = config.enableCustomChrome();
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ package net.runelite.client.ui;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.TreeSet;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@@ -82,21 +81,4 @@ public class TitleToolbar
|
||||
eventBus.post(new TitleToolbarButtonRemoved(button, index));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh all buttons
|
||||
*/
|
||||
public void refresh()
|
||||
{
|
||||
final Iterator<NavigationButton> iterator = buttons.iterator();
|
||||
int index = 0;
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final NavigationButton button = iterator.next();
|
||||
eventBus.post(new TitleToolbarButtonRemoved(button, index));
|
||||
eventBus.post(new TitleToolbarButtonAdded(button, index));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user