Merge pull request #4507 from deathbeam/fix-toolbars
Use consistent API and order for title and sides
This commit is contained in:
@@ -28,8 +28,7 @@ import lombok.Value;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
|
||||
@Value
|
||||
public class TitleToolbarButtonAdded
|
||||
public class NavigationButtonAdded
|
||||
{
|
||||
private NavigationButton button;
|
||||
private int index;
|
||||
}
|
||||
@@ -28,8 +28,7 @@ import lombok.Value;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
|
||||
@Value
|
||||
public class PluginToolbarButtonAdded
|
||||
public class NavigationButtonRemoved
|
||||
{
|
||||
private NavigationButton button;
|
||||
private int index;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.events;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
|
||||
@Value
|
||||
public class PluginToolbarButtonRemoved
|
||||
{
|
||||
private NavigationButton button;
|
||||
private int index;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.events;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
|
||||
@Value
|
||||
public class TitleToolbarButtonRemoved
|
||||
{
|
||||
private NavigationButton button;
|
||||
private int index;
|
||||
}
|
||||
@@ -38,8 +38,8 @@ import net.runelite.client.account.AccountSession;
|
||||
import net.runelite.client.account.SessionManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.TitleToolbar;
|
||||
import net.runelite.client.util.RunnableExceptionLogger;
|
||||
|
||||
@PluginDescriptor(
|
||||
@@ -55,7 +55,7 @@ public class AccountPlugin extends Plugin
|
||||
private SessionManager sessionManager;
|
||||
|
||||
@Inject
|
||||
private TitleToolbar titleToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private ScheduledExecutorService executor;
|
||||
@@ -85,12 +85,14 @@ public class AccountPlugin extends Plugin
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
loginButton = NavigationButton.builder()
|
||||
.tab(false)
|
||||
.icon(LOGIN_IMAGE)
|
||||
.tooltip("Login to RuneLite")
|
||||
.onClick(this::loginClick)
|
||||
.build();
|
||||
|
||||
logoutButton = NavigationButton.builder()
|
||||
.tab(false)
|
||||
.icon(LOGOUT_IMAGE)
|
||||
.tooltip("Logout of RuneLite")
|
||||
.onClick(this::logoutClick)
|
||||
@@ -101,9 +103,9 @@ public class AccountPlugin extends Plugin
|
||||
|
||||
private void addAndRemoveButtons()
|
||||
{
|
||||
titleToolbar.removeNavigation(loginButton);
|
||||
titleToolbar.removeNavigation(logoutButton);
|
||||
titleToolbar.addNavigation(sessionManager.getAccountSession() == null
|
||||
clientToolbar.removeNavigation(loginButton);
|
||||
clientToolbar.removeNavigation(logoutButton);
|
||||
clientToolbar.addNavigation(sessionManager.getAccountSession() == null
|
||||
? loginButton
|
||||
: logoutButton);
|
||||
}
|
||||
@@ -111,8 +113,8 @@ public class AccountPlugin extends Plugin
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
titleToolbar.removeNavigation(loginButton);
|
||||
titleToolbar.removeNavigation(logoutButton);
|
||||
clientToolbar.removeNavigation(loginButton);
|
||||
clientToolbar.removeNavigation(logoutButton);
|
||||
}
|
||||
|
||||
private void loginClick()
|
||||
|
||||
@@ -38,7 +38,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginManager;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Configuration",
|
||||
@@ -48,7 +48,7 @@ import net.runelite.client.ui.PluginToolbar;
|
||||
public class ConfigPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private ConfigManager configManager;
|
||||
@@ -86,13 +86,13 @@ public class ConfigPlugin extends Plugin
|
||||
.panel(configPanel)
|
||||
.build();
|
||||
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
pluginToolbar.removeNavigation(navButton);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -49,7 +49,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class DevToolsPlugin extends Plugin
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
@@ -143,7 +143,7 @@ public class DevToolsPlugin extends Plugin
|
||||
.panel(panel)
|
||||
.build();
|
||||
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
|
||||
font = FontManager.getRunescapeFont()
|
||||
.deriveFont(Font.BOLD, 16);
|
||||
@@ -157,7 +157,7 @@ public class DevToolsPlugin extends Plugin
|
||||
overlayManager.remove(sceneOverlay);
|
||||
overlayManager.remove(cameraOverlay);
|
||||
overlayManager.remove(worldMapLocationOverlay);
|
||||
pluginToolbar.removeNavigation(navButton);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -49,8 +49,8 @@ import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.TitleToolbar;
|
||||
import net.runelite.client.util.LinkBrowser;
|
||||
|
||||
@PluginDescriptor(
|
||||
@@ -67,7 +67,7 @@ public class DiscordPlugin extends Plugin
|
||||
private DiscordConfig config;
|
||||
|
||||
@Inject
|
||||
private TitleToolbar titleToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private RuneLiteProperties properties;
|
||||
@@ -95,19 +95,20 @@ public class DiscordPlugin extends Plugin
|
||||
}
|
||||
|
||||
discordButton = NavigationButton.builder()
|
||||
.tab(false)
|
||||
.tooltip("Join Discord")
|
||||
.icon(icon)
|
||||
.onClick(() -> LinkBrowser.browse(properties.getDiscordInvite()))
|
||||
.build();
|
||||
|
||||
titleToolbar.addNavigation(discordButton);
|
||||
clientToolbar.addNavigation(discordButton);
|
||||
checkForGameStateUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
titleToolbar.removeNavigation(discordButton);
|
||||
clientToolbar.removeNavigation(discordButton);
|
||||
discordState.reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Farming Tracker",
|
||||
@@ -56,7 +56,7 @@ import net.runelite.client.ui.PluginToolbar;
|
||||
public class FarmingTrackerPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private ConfigManager configManager;
|
||||
@@ -103,7 +103,7 @@ public class FarmingTrackerPlugin extends Plugin
|
||||
.priority(4)
|
||||
.build();
|
||||
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
|
||||
updatePanel();
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class FarmingTrackerPlugin extends Plugin
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
pluginToolbar.removeNavigation(navButton);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -42,7 +42,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.http.api.feed.FeedClient;
|
||||
import net.runelite.http.api.feed.FeedResult;
|
||||
|
||||
@@ -56,7 +56,7 @@ import net.runelite.http.api.feed.FeedResult;
|
||||
public class FeedPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private FeedConfig config;
|
||||
@@ -99,14 +99,14 @@ public class FeedPlugin extends Plugin
|
||||
.panel(feedPanel)
|
||||
.build();
|
||||
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
executorService.submit(this::updateFeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
pluginToolbar.removeNavigation(navButton);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
|
||||
private void updateFeed()
|
||||
|
||||
@@ -65,7 +65,7 @@ import net.runelite.client.input.MouseManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.util.StackFormatter;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.http.api.osbuddy.GrandExchangeClient;
|
||||
@@ -111,7 +111,7 @@ public class GrandExchangePlugin extends Plugin
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private GrandExchangeConfig config;
|
||||
@@ -151,7 +151,7 @@ public class GrandExchangePlugin extends Plugin
|
||||
.panel(panel)
|
||||
.build();
|
||||
|
||||
pluginToolbar.addNavigation(button);
|
||||
clientToolbar.addNavigation(button);
|
||||
|
||||
if (config.quickLookup())
|
||||
{
|
||||
@@ -163,7 +163,7 @@ public class GrandExchangePlugin extends Plugin
|
||||
@Override
|
||||
protected void shutDown()
|
||||
{
|
||||
pluginToolbar.removeNavigation(button);
|
||||
clientToolbar.removeNavigation(button);
|
||||
mouseManager.unregisterMouseListener(inputListener);
|
||||
keyManager.unregisterKeyListener(inputListener);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ import net.runelite.client.menus.MenuManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.util.Text;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class HiscorePlugin extends Plugin
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private MenuManager menuManager;
|
||||
@@ -110,7 +110,7 @@ public class HiscorePlugin extends Plugin
|
||||
.panel(hiscorePanel)
|
||||
.build();
|
||||
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
|
||||
if (config.playerOption())
|
||||
{
|
||||
@@ -126,7 +126,7 @@ public class HiscorePlugin extends Plugin
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
hiscorePanel.removeInputKeyListener(autocompleter);
|
||||
pluginToolbar.removeNavigation(navButton);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
menuManager.removePlayerMenuItem(LOOKUP);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import javax.inject.Inject;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Info Panel",
|
||||
@@ -40,7 +40,7 @@ import net.runelite.client.ui.PluginToolbar;
|
||||
public class InfoPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
private NavigationButton navButton;
|
||||
|
||||
@@ -63,12 +63,12 @@ public class InfoPlugin extends Plugin
|
||||
.panel(panel)
|
||||
.build();
|
||||
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown()
|
||||
{
|
||||
pluginToolbar.removeNavigation(navButton);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
|
||||
@PluginDescriptor(
|
||||
@@ -67,7 +67,7 @@ public class KourendLibraryPlugin extends Plugin
|
||||
final static boolean debug = false;
|
||||
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
@@ -124,7 +124,7 @@ public class KourendLibraryPlugin extends Plugin
|
||||
|
||||
if (!config.hideButton())
|
||||
{
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class KourendLibraryPlugin extends Plugin
|
||||
{
|
||||
if (!config.hideButton())
|
||||
{
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -148,11 +148,11 @@ public class KourendLibraryPlugin extends Plugin
|
||||
boolean inRegion = lp != null && lp.getWorldLocation().getRegionID() == REGION;
|
||||
if (inRegion)
|
||||
{
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
pluginToolbar.removeNavigation(navButton);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -163,7 +163,7 @@ public class KourendLibraryPlugin extends Plugin
|
||||
{
|
||||
overlayManager.remove(overlay);
|
||||
|
||||
pluginToolbar.removeNavigation(navButton);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -211,11 +211,11 @@ public class KourendLibraryPlugin extends Plugin
|
||||
{
|
||||
if (inRegion)
|
||||
{
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
pluginToolbar.removeNavigation(navButton);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
});
|
||||
buttonAttached = inRegion;
|
||||
|
||||
@@ -35,7 +35,7 @@ import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Notes",
|
||||
@@ -47,7 +47,7 @@ import net.runelite.client.ui.PluginToolbar;
|
||||
public class NotesPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private NotesConfig config;
|
||||
@@ -80,13 +80,13 @@ public class NotesPlugin extends Plugin
|
||||
.panel(panel)
|
||||
.build();
|
||||
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown()
|
||||
{
|
||||
pluginToolbar.removeNavigation(navButton);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -51,7 +51,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.screenmarkers.ui.ScreenMarkerPluginPanel;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
|
||||
@PluginDescriptor(
|
||||
@@ -79,7 +79,7 @@ public class ScreenMarkerPlugin extends Plugin
|
||||
private MouseManager mouseManager;
|
||||
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
@@ -121,7 +121,7 @@ public class ScreenMarkerPlugin extends Plugin
|
||||
.panel(pluginPanel)
|
||||
.build();
|
||||
|
||||
pluginToolbar.addNavigation(navigationButton);
|
||||
clientToolbar.addNavigation(navigationButton);
|
||||
|
||||
mouseListener = new ScreenMarkerMouseListener(this);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class ScreenMarkerPlugin extends Plugin
|
||||
overlayManager.remove(overlay);
|
||||
overlayManager.removeIf(ScreenMarkerOverlay.class::isInstance);
|
||||
screenMarkers.clear();
|
||||
pluginToolbar.removeNavigation(navigationButton);
|
||||
clientToolbar.removeNavigation(navigationButton);
|
||||
setMouseListenerEnabled(false);
|
||||
creatingScreenMarker = false;
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
@@ -60,6 +59,7 @@ import net.runelite.api.GameState;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.WorldType;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import static net.runelite.api.widgets.WidgetID.BARROWS_REWARD_GROUP_ID;
|
||||
@@ -79,10 +79,10 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.screenshot.imgur.ImageUploadRequest;
|
||||
import net.runelite.client.plugins.screenshot.imgur.ImageUploadResponse;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.DrawManager;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.TitleToolbar;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.util.HotkeyListener;
|
||||
import net.runelite.client.util.Text;
|
||||
@@ -159,7 +159,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
private ClientUI clientUi;
|
||||
|
||||
@Inject
|
||||
private TitleToolbar titleToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private DrawManager drawManager;
|
||||
@@ -203,6 +203,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
}
|
||||
|
||||
titleBarButton = NavigationButton.builder()
|
||||
.tab(false)
|
||||
.tooltip("Take screenshot")
|
||||
.icon(iconImage)
|
||||
.onClick(() -> takeScreenshot(format(new Date())))
|
||||
@@ -223,7 +224,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
.build())
|
||||
.build();
|
||||
|
||||
titleToolbar.addNavigation(titleBarButton);
|
||||
clientToolbar.addNavigation(titleBarButton);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@@ -235,7 +236,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
overlayManager.remove(screenshotOverlay);
|
||||
titleToolbar.removeNavigation(titleBarButton);
|
||||
clientToolbar.removeNavigation(titleBarButton);
|
||||
keyManager.unregisterKeyListener(hotkeyListener);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Skill Calculator",
|
||||
@@ -61,7 +61,7 @@ public class SkillCalculatorPlugin extends Plugin
|
||||
private SpriteManager spriteManager;
|
||||
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
private NavigationButton uiNavigationButton;
|
||||
private SkillCalculatorPanel uiPanel;
|
||||
@@ -85,12 +85,12 @@ public class SkillCalculatorPlugin extends Plugin
|
||||
.priority(6)
|
||||
.panel(uiPanel)
|
||||
.build();
|
||||
pluginToolbar.addNavigation(uiNavigationButton);
|
||||
clientToolbar.addNavigation(uiNavigationButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
pluginToolbar.removeNavigation(uiNavigationButton);
|
||||
clientToolbar.removeNavigation(uiNavigationButton);
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
import static net.runelite.client.plugins.xptracker.XpWorldType.NORMAL;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.PluginToolbar;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.http.api.xp.XpClient;
|
||||
|
||||
@PluginDescriptor(
|
||||
@@ -64,7 +64,7 @@ import net.runelite.http.api.xp.XpClient;
|
||||
public class XpTrackerPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private PluginToolbar pluginToolbar;
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
@@ -115,14 +115,14 @@ public class XpTrackerPlugin extends Plugin
|
||||
.panel(xpPanel)
|
||||
.build();
|
||||
|
||||
pluginToolbar.addNavigation(navButton);
|
||||
clientToolbar.addNavigation(navButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
xpState.reset();
|
||||
pluginToolbar.removeNavigation(navButton);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -25,10 +25,11 @@
|
||||
*/
|
||||
package net.runelite.client.ui;
|
||||
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import javax.swing.JToolBar;
|
||||
|
||||
/**
|
||||
@@ -37,7 +38,13 @@ import javax.swing.JToolBar;
|
||||
public class ClientPluginToolbar extends JToolBar
|
||||
{
|
||||
private static final int TOOLBAR_WIDTH = 36, TOOLBAR_HEIGHT = 503;
|
||||
private final Map<NavigationButton, Component> componentMap = new HashMap<>();
|
||||
private final Map<NavigationButton, Component> componentMap = new TreeMap<>((a, b) ->
|
||||
ComparisonChain
|
||||
.start()
|
||||
.compareTrueFirst(a.isTab(), b.isTab())
|
||||
.compare(a.getPriority(), b.getPriority())
|
||||
.compare(a.getTooltip(), b.getTooltip())
|
||||
.result());
|
||||
|
||||
/**
|
||||
* Instantiates a new Client plugin toolbar.
|
||||
@@ -53,33 +60,38 @@ public class ClientPluginToolbar extends JToolBar
|
||||
addSeparator();
|
||||
}
|
||||
|
||||
public void addComponent(final int index, final NavigationButton button, final Component component)
|
||||
void addComponent(final NavigationButton button, final Component c)
|
||||
{
|
||||
if (componentMap.put(button, component) == null)
|
||||
if (componentMap.put(button, c) == null)
|
||||
{
|
||||
if (index < 0)
|
||||
{
|
||||
add(component);
|
||||
}
|
||||
else
|
||||
{
|
||||
add(component, index);
|
||||
}
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeComponent(final NavigationButton button)
|
||||
void removeComponent(final NavigationButton button)
|
||||
{
|
||||
final Component component = componentMap.remove(button);
|
||||
|
||||
if (component != null)
|
||||
if (componentMap.remove(button) != null)
|
||||
{
|
||||
remove(component);
|
||||
revalidate();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
private void update()
|
||||
{
|
||||
removeAll();
|
||||
boolean isDelimited = false;
|
||||
|
||||
for (final Map.Entry<NavigationButton, Component> entry : componentMap.entrySet())
|
||||
{
|
||||
if (!entry.getKey().isTab() && !isDelimited)
|
||||
{
|
||||
isDelimited = true;
|
||||
addSeparator();
|
||||
}
|
||||
|
||||
add(entry.getValue());
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,13 @@
|
||||
*/
|
||||
package net.runelite.client.ui;
|
||||
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.LayoutManager2;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
@@ -37,10 +38,14 @@ import javax.swing.JPanel;
|
||||
*/
|
||||
class ClientTitleToolbar extends JPanel
|
||||
{
|
||||
static final int TITLEBAR_SIZE = 23;
|
||||
private static final int TITLEBAR_SIZE = 23;
|
||||
private static final int ITEM_PADDING = 4;
|
||||
|
||||
private final Map<NavigationButton, Component> componentMap = new HashMap<>();
|
||||
private final Map<NavigationButton, Component> componentMap = new TreeMap<>((a, b) ->
|
||||
ComparisonChain
|
||||
.start()
|
||||
.compare(a.getPriority(), b.getPriority())
|
||||
.compare(a.getTooltip(), b.getTooltip())
|
||||
.result());
|
||||
|
||||
/**
|
||||
* Instantiates a new Client title toolbar.
|
||||
@@ -122,24 +127,26 @@ class ClientTitleToolbar extends JPanel
|
||||
});
|
||||
}
|
||||
|
||||
public void addComponent(NavigationButton button, Component c)
|
||||
void addComponent(final NavigationButton button, final Component c)
|
||||
{
|
||||
if (componentMap.put(button, c) == null)
|
||||
{
|
||||
add(c);
|
||||
revalidate();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeComponent(NavigationButton button)
|
||||
void removeComponent(final NavigationButton button)
|
||||
{
|
||||
final Component component = componentMap.remove(button);
|
||||
if (component != null)
|
||||
if (componentMap.remove(button) != null)
|
||||
{
|
||||
remove(component);
|
||||
revalidate();
|
||||
repaint();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
private void update()
|
||||
{
|
||||
removeAll();
|
||||
componentMap.values().forEach(this::add);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,29 +24,25 @@
|
||||
*/
|
||||
package net.runelite.client.ui;
|
||||
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import java.util.TreeSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.client.events.PluginToolbarButtonAdded;
|
||||
import net.runelite.client.events.PluginToolbarButtonRemoved;
|
||||
import net.runelite.client.events.NavigationButtonAdded;
|
||||
import net.runelite.client.events.NavigationButtonRemoved;
|
||||
|
||||
/**
|
||||
* Plugin toolbar buttons holder.
|
||||
*/
|
||||
@Singleton
|
||||
public class PluginToolbar
|
||||
public class ClientToolbar
|
||||
{
|
||||
private final EventBus eventBus;
|
||||
private final TreeSet<NavigationButton> buttons = new TreeSet<>((a, b) ->
|
||||
ComparisonChain.start()
|
||||
.compare(a.getPriority(), b.getPriority())
|
||||
.compare(a.getTooltip(), b.getTooltip())
|
||||
.result());
|
||||
private final Set<NavigationButton> buttons = new HashSet<>();
|
||||
|
||||
@Inject
|
||||
private PluginToolbar(final EventBus eventBus)
|
||||
private ClientToolbar(final EventBus eventBus)
|
||||
{
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
@@ -65,8 +61,7 @@ public class PluginToolbar
|
||||
|
||||
if (buttons.add(button))
|
||||
{
|
||||
int index = buttons.headSet(button).size();
|
||||
eventBus.post(new PluginToolbarButtonAdded(button, index));
|
||||
eventBus.post(new NavigationButtonAdded(button));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,11 +72,9 @@ public class PluginToolbar
|
||||
*/
|
||||
public void removeNavigation(final NavigationButton button)
|
||||
{
|
||||
int index = buttons.headSet(button).size();
|
||||
|
||||
if (buttons.remove(button))
|
||||
{
|
||||
eventBus.post(new PluginToolbarButtonRemoved(button, index));
|
||||
eventBus.post(new NavigationButtonRemoved(button));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,10 +66,8 @@ import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.config.ExpandResizeType;
|
||||
import net.runelite.client.config.RuneLiteConfig;
|
||||
import net.runelite.client.config.WarningOnExit;
|
||||
import net.runelite.client.events.PluginToolbarButtonAdded;
|
||||
import net.runelite.client.events.PluginToolbarButtonRemoved;
|
||||
import net.runelite.client.events.TitleToolbarButtonAdded;
|
||||
import net.runelite.client.events.TitleToolbarButtonRemoved;
|
||||
import net.runelite.client.events.NavigationButtonAdded;
|
||||
import net.runelite.client.events.NavigationButtonRemoved;
|
||||
import net.runelite.client.input.KeyManager;
|
||||
import net.runelite.client.ui.skin.SubstanceRuneLiteLookAndFeel;
|
||||
import net.runelite.client.util.OSType;
|
||||
@@ -171,19 +169,22 @@ public class ClientUI
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPluginToolbarButtonAdded(final PluginToolbarButtonAdded event)
|
||||
public void onNavigationButtonAdded(final NavigationButtonAdded event)
|
||||
{
|
||||
SwingUtilities.invokeLater(() ->
|
||||
{
|
||||
final NavigationButton navigationButton = event.getButton();
|
||||
final PluginPanel pluginPanel = navigationButton.getPanel();
|
||||
final boolean inTitle = !event.getButton().isTab() &&
|
||||
(config.enableCustomChrome() || SwingUtil.isCustomTitlePanePresent(frame));
|
||||
final int iconSize = 16;
|
||||
|
||||
if (pluginPanel != null)
|
||||
{
|
||||
navContainer.add(pluginPanel.getWrappedPanel(), navigationButton.getTooltip());
|
||||
}
|
||||
|
||||
final JButton button = SwingUtil.createSwingButton(navigationButton, 0, (navButton, jButton) ->
|
||||
final JButton button = SwingUtil.createSwingButton(navigationButton, iconSize, (navButton, jButton) ->
|
||||
{
|
||||
final PluginPanel panel = navButton.getPanel();
|
||||
|
||||
@@ -222,16 +223,24 @@ public class ClientUI
|
||||
}
|
||||
});
|
||||
|
||||
pluginToolbar.addComponent(event.getIndex(), event.getButton(), button);
|
||||
if (inTitle)
|
||||
{
|
||||
titleToolbar.addComponent(event.getButton(), button);
|
||||
}
|
||||
else
|
||||
{
|
||||
pluginToolbar.addComponent(event.getButton(), button);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPluginToolbarButtonRemoved(final PluginToolbarButtonRemoved event)
|
||||
public void onNavigationButtonRemoved(final NavigationButtonRemoved event)
|
||||
{
|
||||
SwingUtilities.invokeLater(() ->
|
||||
{
|
||||
pluginToolbar.removeComponent(event.getButton());
|
||||
titleToolbar.removeComponent(event.getButton());
|
||||
final PluginPanel pluginPanel = event.getButton().getPanel();
|
||||
|
||||
if (pluginPanel != null)
|
||||
@@ -241,39 +250,6 @@ public class ClientUI
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onTitleToolbarButtonAdded(final TitleToolbarButtonAdded event)
|
||||
{
|
||||
SwingUtilities.invokeLater(() ->
|
||||
{
|
||||
final int iconSize = ClientTitleToolbar.TITLEBAR_SIZE - 6;
|
||||
final JButton button = SwingUtil.createSwingButton(event.getButton(), iconSize, null);
|
||||
|
||||
if (config.enableCustomChrome() || SwingUtil.isCustomTitlePanePresent(frame))
|
||||
{
|
||||
titleToolbar.addComponent(event.getButton(), button);
|
||||
return;
|
||||
}
|
||||
|
||||
pluginToolbar.addComponent(-1, event.getButton(), button);
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onTitleToolbarButtonRemoved(final TitleToolbarButtonRemoved event)
|
||||
{
|
||||
SwingUtilities.invokeLater(() ->
|
||||
{
|
||||
if (config.enableCustomChrome() || SwingUtil.isCustomTitlePanePresent(frame))
|
||||
{
|
||||
titleToolbar.removeComponent(event.getButton());
|
||||
return;
|
||||
}
|
||||
|
||||
pluginToolbar.removeComponent(event.getButton());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize UI.
|
||||
*
|
||||
@@ -449,6 +425,7 @@ public class ClientUI
|
||||
// Create hide sidebar button
|
||||
sidebarNavigationButton = NavigationButton
|
||||
.builder()
|
||||
.priority(100)
|
||||
.icon(SIDEBAR_CLOSE)
|
||||
.onClick(this::toggleSidebar)
|
||||
.build();
|
||||
|
||||
@@ -44,10 +44,17 @@ public class NavigationButton
|
||||
*/
|
||||
private final BufferedImage icon;
|
||||
|
||||
/**
|
||||
* If the button is tab or not
|
||||
*/
|
||||
@Builder.Default
|
||||
private boolean tab = true;
|
||||
|
||||
/**
|
||||
* Tooltip to show when hovered.
|
||||
*/
|
||||
private final String tooltip;
|
||||
@Builder.Default
|
||||
private final String tooltip = "";
|
||||
|
||||
/**
|
||||
* Button selection state
|
||||
@@ -69,7 +76,6 @@ public class NavigationButton
|
||||
*/
|
||||
private PluginPanel panel;
|
||||
|
||||
|
||||
/**
|
||||
* The order in which the button should be displayed in the side bar. (from lower to higher)
|
||||
*/
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017-2018, Adam <Adam@sigterm.info>
|
||||
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.ui;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import java.util.Comparator;
|
||||
import java.util.TreeSet;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.client.events.TitleToolbarButtonAdded;
|
||||
import net.runelite.client.events.TitleToolbarButtonRemoved;
|
||||
|
||||
/**
|
||||
* Title toolbar buttons holder.
|
||||
*/
|
||||
@Singleton
|
||||
public class TitleToolbar
|
||||
{
|
||||
private final EventBus eventBus;
|
||||
private final TreeSet<NavigationButton> buttons = new TreeSet<>(Comparator.comparing(NavigationButton::getTooltip));
|
||||
|
||||
@Inject
|
||||
private TitleToolbar(final EventBus eventBus)
|
||||
{
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add navigation.
|
||||
*
|
||||
* @param button the button
|
||||
*/
|
||||
public void addNavigation(final NavigationButton button)
|
||||
{
|
||||
if (buttons.contains(button))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (buttons.add(button))
|
||||
{
|
||||
int index = buttons.headSet(button).size();
|
||||
eventBus.post(new TitleToolbarButtonAdded(button, index));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove navigation.
|
||||
*
|
||||
* @param button the button
|
||||
*/
|
||||
public void removeNavigation(final NavigationButton button)
|
||||
{
|
||||
int index = buttons.headSet(button).size();
|
||||
|
||||
if (buttons.remove(button))
|
||||
{
|
||||
eventBus.post(new TitleToolbarButtonRemoved(button, index));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user