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.Guice;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import java.applet.Applet;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -56,7 +55,6 @@ import net.runelite.client.plugins.PluginManager;
|
|||||||
import net.runelite.client.rs.ClientUpdateCheckMode;
|
import net.runelite.client.rs.ClientUpdateCheckMode;
|
||||||
import net.runelite.client.ui.ClientUI;
|
import net.runelite.client.ui.ClientUI;
|
||||||
import net.runelite.client.ui.DrawManager;
|
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.OverlayManager;
|
||||||
import net.runelite.client.ui.overlay.OverlayRenderer;
|
import net.runelite.client.ui.overlay.OverlayRenderer;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
@@ -115,9 +113,6 @@ public class RuneLite
|
|||||||
@Inject
|
@Inject
|
||||||
private ClientUI clientUI;
|
private ClientUI clientUI;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private TitleToolbar titleToolbar;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Provider<ItemManager> itemManager;
|
private Provider<ItemManager> itemManager;
|
||||||
|
|
||||||
@@ -139,10 +134,6 @@ public class RuneLite
|
|||||||
@Inject
|
@Inject
|
||||||
private WorldMapOverlay worldMapOverlay;
|
private WorldMapOverlay worldMapOverlay;
|
||||||
|
|
||||||
@Inject
|
|
||||||
@Nullable
|
|
||||||
private Applet applet;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
@Nullable
|
||||||
private Client client;
|
private Client client;
|
||||||
@@ -228,9 +219,6 @@ public class RuneLite
|
|||||||
injector.injectMembers(client);
|
injector.injectMembers(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize UI
|
|
||||||
clientUI.init(applet);
|
|
||||||
|
|
||||||
// Initialize Discord service
|
// Initialize Discord service
|
||||||
discordService.init();
|
discordService.init();
|
||||||
|
|
||||||
@@ -271,6 +259,9 @@ public class RuneLite
|
|||||||
// Load the session, including saved configuration
|
// Load the session, including saved configuration
|
||||||
sessionManager.loadSession();
|
sessionManager.loadSession();
|
||||||
|
|
||||||
|
// Initialize UI
|
||||||
|
clientUI.open(this);
|
||||||
|
|
||||||
// Add core overlays after configuration has been loaded so their properties will be
|
// Add core overlays after configuration has been loaded so their properties will be
|
||||||
// loaded properly
|
// loaded properly
|
||||||
overlayManager.add(infoBoxOverlay);
|
overlayManager.add(infoBoxOverlay);
|
||||||
@@ -279,12 +270,6 @@ public class RuneLite
|
|||||||
|
|
||||||
// Start plugins
|
// Start plugins
|
||||||
pluginManager.startCorePlugins();
|
pluginManager.startCorePlugins();
|
||||||
|
|
||||||
// Refresh title toolbar
|
|
||||||
titleToolbar.refresh();
|
|
||||||
|
|
||||||
// Show UI after all plugins are loaded
|
|
||||||
clientUI.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown()
|
public void shutdown()
|
||||||
|
|||||||
@@ -125,13 +125,13 @@ public class ClientUI
|
|||||||
@Getter
|
@Getter
|
||||||
private TrayIcon trayIcon;
|
private TrayIcon trayIcon;
|
||||||
|
|
||||||
private final RuneLite runelite;
|
|
||||||
private final RuneLiteProperties properties;
|
private final RuneLiteProperties properties;
|
||||||
private final RuneLiteConfig config;
|
private final RuneLiteConfig config;
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
private final KeyManager keyManager;
|
private final KeyManager keyManager;
|
||||||
|
private final Applet client;
|
||||||
|
private final ConfigManager configManager;
|
||||||
private final CardLayout cardLayout = new CardLayout();
|
private final CardLayout cardLayout = new CardLayout();
|
||||||
private Applet client;
|
|
||||||
private ContainableFrame frame;
|
private ContainableFrame frame;
|
||||||
private JPanel navContainer;
|
private JPanel navContainer;
|
||||||
private PluginPanel pluginPanel;
|
private PluginPanel pluginPanel;
|
||||||
@@ -144,22 +144,21 @@ public class ClientUI
|
|||||||
private NavigationButton sidebarNavigationButton;
|
private NavigationButton sidebarNavigationButton;
|
||||||
private JButton sidebarNavigationJButton;
|
private JButton sidebarNavigationJButton;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ConfigManager configManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ClientUI(
|
private ClientUI(
|
||||||
RuneLite runelite,
|
|
||||||
RuneLiteProperties properties,
|
RuneLiteProperties properties,
|
||||||
RuneLiteConfig config,
|
RuneLiteConfig config,
|
||||||
EventBus eventBus,
|
EventBus eventBus,
|
||||||
KeyManager keyManager)
|
KeyManager keyManager,
|
||||||
|
@Nullable Applet client,
|
||||||
|
ConfigManager configManager)
|
||||||
{
|
{
|
||||||
this.runelite = runelite;
|
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.keyManager = keyManager;
|
this.keyManager = keyManager;
|
||||||
|
this.client = client;
|
||||||
|
this.configManager = configManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -337,13 +336,11 @@ public class ClientUI
|
|||||||
/**
|
/**
|
||||||
* Initialize UI.
|
* 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
|
* @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(() ->
|
SwingUtilities.invokeAndWait(() ->
|
||||||
{
|
{
|
||||||
// Set some sensible swing defaults
|
// Set some sensible swing defaults
|
||||||
@@ -373,9 +370,7 @@ public class ClientUI
|
|||||||
saveClientBoundsConfig();
|
saveClientBoundsConfig();
|
||||||
runelite.shutdown();
|
runelite.shutdown();
|
||||||
},
|
},
|
||||||
() -> client != null
|
this::showWarningOnExit
|
||||||
&& client instanceof Client
|
|
||||||
&& showWarningOnExit()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
container = new JPanel();
|
container = new JPanel();
|
||||||
@@ -401,6 +396,8 @@ public class ClientUI
|
|||||||
frame.addKeyListener(uiKeyListener);
|
frame.addKeyListener(uiKeyListener);
|
||||||
keyManager.registerKeyListener(uiKeyListener);
|
keyManager.registerKeyListener(uiKeyListener);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showWarningOnExit()
|
private boolean showWarningOnExit()
|
||||||
@@ -410,7 +407,7 @@ public class ClientUI
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.warningOnExit() == WarningOnExit.LOGGED_IN)
|
if (config.warningOnExit() == WarningOnExit.LOGGED_IN && client instanceof Client)
|
||||||
{
|
{
|
||||||
return ((Client) client).getGameState() != GameState.LOGIN_SCREEN;
|
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
|
* @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();
|
final boolean withTitleBar = config.enableCustomChrome();
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ package net.runelite.client.ui;
|
|||||||
|
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@@ -82,21 +81,4 @@ public class TitleToolbar
|
|||||||
eventBus.post(new TitleToolbarButtonRemoved(button, index));
|
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