infoplugin: Fix info panel
This commit is contained in:
@@ -34,23 +34,17 @@ import java.awt.GridLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import net.runelite.api.Client;
|
||||
import static net.runelite.client.RuneLite.LOGS_DIR;
|
||||
import net.runelite.client.RuneLiteProperties;
|
||||
import net.runelite.client.account.SessionManager;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.events.SessionClose;
|
||||
import net.runelite.client.events.SessionOpen;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
@@ -58,10 +52,8 @@ import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.LinkBrowser;
|
||||
|
||||
@Singleton
|
||||
public class InfoPanel extends PluginPanel
|
||||
class InfoPanel extends PluginPanel
|
||||
{
|
||||
private static final String RUNELITE_LOGIN = "https://runelite_login/";
|
||||
|
||||
private static final ImageIcon ARROW_RIGHT_ICON;
|
||||
private static final ImageIcon GITHUB_ICON;
|
||||
private static final ImageIcon FOLDER_ICON;
|
||||
@@ -69,21 +61,12 @@ public class InfoPanel extends PluginPanel
|
||||
private static final ImageIcon PATREON_ICON;
|
||||
private static final ImageIcon IMPORT_ICON;
|
||||
|
||||
private final JLabel loggedLabel = new JLabel();
|
||||
private final JRichTextPane emailLabel = new JRichTextPane();
|
||||
private JPanel syncPanel;
|
||||
private JPanel actionsContainer;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private SessionManager sessionManager;
|
||||
|
||||
@Inject
|
||||
private ScheduledExecutorService executor;
|
||||
|
||||
@Inject
|
||||
private ConfigManager configManager;
|
||||
|
||||
@@ -127,28 +110,11 @@ public class InfoPanel extends PluginPanel
|
||||
|
||||
revision.setText(htmlLabel("Oldschool revision: ", engineVer));
|
||||
|
||||
loggedLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||
loggedLabel.setFont(smallFont);
|
||||
|
||||
emailLabel.setForeground(Color.WHITE);
|
||||
emailLabel.setFont(smallFont);
|
||||
emailLabel.enableAutoLinkHandler(false);
|
||||
emailLabel.addHyperlinkListener(e ->
|
||||
{
|
||||
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType()) && e.getURL() != null && e.getURL().toString().equals(RUNELITE_LOGIN))
|
||||
{
|
||||
executor.execute(sessionManager::login);
|
||||
}
|
||||
});
|
||||
|
||||
versionPanel.add(version);
|
||||
versionPanel.add(plusVersion);
|
||||
versionPanel.add(revision);
|
||||
versionPanel.add(Box.createGlue());
|
||||
versionPanel.add(loggedLabel);
|
||||
versionPanel.add(emailLabel);
|
||||
|
||||
actionsContainer = new JPanel();
|
||||
JPanel actionsContainer = new JPanel();
|
||||
actionsContainer.setBorder(new EmptyBorder(10, 0, 0, 0));
|
||||
actionsContainer.setLayout(new GridLayout(5, 1, 0, 10));
|
||||
|
||||
@@ -173,8 +139,6 @@ public class InfoPanel extends PluginPanel
|
||||
|
||||
add(versionPanel, BorderLayout.NORTH);
|
||||
add(actionsContainer, BorderLayout.CENTER);
|
||||
|
||||
updateLoggedIn();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,40 +231,8 @@ public class InfoPanel extends PluginPanel
|
||||
return container;
|
||||
}
|
||||
|
||||
private void updateLoggedIn()
|
||||
{
|
||||
final String name = sessionManager.getAccountSession() != null
|
||||
? sessionManager.getAccountSession().getUsername()
|
||||
: null;
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
emailLabel.setContentType("text/plain");
|
||||
emailLabel.setText(name);
|
||||
loggedLabel.setText("Logged in as");
|
||||
actionsContainer.add(syncPanel, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//emailLabel.setContentType("text/html");
|
||||
//emailLabel.setText("<a href=\"" + RUNELITE_LOGIN + "\">Login</a> to sync settings to the cloud.");
|
||||
//loggedLabel.setText("Not logged in");
|
||||
actionsContainer.remove(syncPanel);
|
||||
}
|
||||
}
|
||||
|
||||
private static String htmlLabel(String key, String value)
|
||||
{
|
||||
return "<html><body style = 'color:#a5a5a5'>" + key + "<span style = 'color:white'>" + value + "</span></body></html>";
|
||||
}
|
||||
|
||||
public void onSessionOpen(SessionOpen sessionOpen)
|
||||
{
|
||||
updateLoggedIn();
|
||||
}
|
||||
|
||||
public void onSessionClose(SessionClose e)
|
||||
{
|
||||
updateLoggedIn();
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,6 @@ import java.awt.image.BufferedImage;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.events.SessionClose;
|
||||
import net.runelite.client.events.SessionOpen;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
@@ -53,12 +51,10 @@ public class InfoPlugin extends Plugin
|
||||
private NavigationButton navButton;
|
||||
|
||||
|
||||
private InfoPanel panel;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
panel = injector.getInstance(InfoPanel.class);
|
||||
InfoPanel panel = injector.getInstance(InfoPanel.class);
|
||||
panel.init();
|
||||
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "info_icon.png");
|
||||
@@ -71,8 +67,6 @@ public class InfoPlugin extends Plugin
|
||||
.build();
|
||||
|
||||
clientToolbar.addNavigation(navButton);
|
||||
|
||||
addSubscriptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,10 +76,4 @@ public class InfoPlugin extends Plugin
|
||||
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
|
||||
private void addSubscriptions()
|
||||
{
|
||||
eventbus.subscribe(SessionOpen.class, this, event -> panel.onSessionOpen(event));
|
||||
eventbus.subscribe(SessionClose.class, this, event -> panel.onSessionClose(event));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user