Update InfoPanel.java (#282)
This commit is contained in:
@@ -1,311 +1,311 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 Abex
|
* Copyright (c) 2018 Abex
|
||||||
* Copyright (c) 2018, Psikoi <https://github.com/psikoi>
|
* Copyright (c) 2018, Psikoi <https://github.com/psikoi>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
* list of conditions and the following disclaimer.
|
* list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* 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
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.info;
|
package net.runelite.client.plugins.info;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.HyperlinkEvent;
|
import javax.swing.event.HyperlinkEvent;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.client.RuneLiteProperties;
|
import net.runelite.client.RuneLiteProperties;
|
||||||
import net.runelite.client.account.SessionManager;
|
import net.runelite.client.account.SessionManager;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.events.SessionClose;
|
import net.runelite.client.events.SessionClose;
|
||||||
import net.runelite.client.events.SessionOpen;
|
import net.runelite.client.events.SessionOpen;
|
||||||
import net.runelite.client.ui.ColorScheme;
|
import net.runelite.client.ui.ColorScheme;
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.ui.PluginPanel;
|
import net.runelite.client.ui.PluginPanel;
|
||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
import net.runelite.client.util.LinkBrowser;
|
import net.runelite.client.util.LinkBrowser;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class InfoPanel extends PluginPanel
|
public class InfoPanel extends PluginPanel
|
||||||
{
|
{
|
||||||
private static final String RUNELITE_LOGIN = "https://runelite_login/";
|
private static final String RUNELITE_LOGIN = "https://runelite_login/";
|
||||||
|
|
||||||
private static final ImageIcon ARROW_RIGHT_ICON;
|
private static final ImageIcon ARROW_RIGHT_ICON;
|
||||||
private static final ImageIcon GITHUB_ICON;
|
private static final ImageIcon GITHUB_ICON;
|
||||||
private static final ImageIcon DISCORD_ICON;
|
private static final ImageIcon DISCORD_ICON;
|
||||||
private static final ImageIcon PATREON_ICON;
|
private static final ImageIcon PATREON_ICON;
|
||||||
private static final ImageIcon WIKI_ICON;
|
private static final ImageIcon WIKI_ICON;
|
||||||
private static final ImageIcon IMPORT_ICON;
|
private static final ImageIcon IMPORT_ICON;
|
||||||
|
|
||||||
private final JLabel loggedLabel = new JLabel();
|
private final JLabel loggedLabel = new JLabel();
|
||||||
private final JRichTextPane emailLabel = new JRichTextPane();
|
private final JRichTextPane emailLabel = new JRichTextPane();
|
||||||
private JPanel syncPanel;
|
private JPanel syncPanel;
|
||||||
private JPanel actionsContainer;
|
private JPanel actionsContainer;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
@Nullable
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RuneLiteProperties runeLiteProperties;
|
private RuneLiteProperties runeLiteProperties;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SessionManager sessionManager;
|
private SessionManager sessionManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ScheduledExecutorService executor;
|
private ScheduledExecutorService executor;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ConfigManager configManager;
|
private ConfigManager configManager;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "/util/arrow_right.png"));
|
ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "/util/arrow_right.png"));
|
||||||
GITHUB_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "github_icon.png"));
|
GITHUB_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "github_icon.png"));
|
||||||
DISCORD_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "discord_icon.png"));
|
DISCORD_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "discord_icon.png"));
|
||||||
PATREON_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "patreon_icon.png"));
|
PATREON_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "patreon_icon.png"));
|
||||||
WIKI_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "wiki_icon.png"));
|
WIKI_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "wiki_icon.png"));
|
||||||
IMPORT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "import_icon.png"));
|
IMPORT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "import_icon.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||||
setBorder(new EmptyBorder(10, 10, 10, 10));
|
setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||||
|
|
||||||
JPanel versionPanel = new JPanel();
|
JPanel versionPanel = new JPanel();
|
||||||
versionPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
versionPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||||
versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
|
versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||||
versionPanel.setLayout(new GridLayout(0, 1));
|
versionPanel.setLayout(new GridLayout(0, 1));
|
||||||
|
|
||||||
final Font smallFont = FontManager.getRunescapeSmallFont();
|
final Font smallFont = FontManager.getRunescapeSmallFont();
|
||||||
|
|
||||||
JLabel version = new JLabel(htmlLabel("RuneLite version: ", runeLiteProperties.getVersion()));
|
JLabel version = new JLabel(htmlLabel("RuneLite version: ", runeLiteProperties.getVersion()));
|
||||||
version.setFont(smallFont);
|
version.setFont(smallFont);
|
||||||
|
|
||||||
JLabel revision = new JLabel();
|
JLabel revision = new JLabel();
|
||||||
revision.setFont(smallFont);
|
revision.setFont(smallFont);
|
||||||
|
|
||||||
String engineVer = "Unknown";
|
String engineVer = "Unknown";
|
||||||
if (client != null)
|
if (client != null)
|
||||||
{
|
{
|
||||||
engineVer = String.format("Rev %d", client.getRevision());
|
engineVer = String.format("Rev %d", client.getRevision());
|
||||||
}
|
}
|
||||||
|
|
||||||
revision.setText(htmlLabel("Oldschool revision: ", engineVer));
|
revision.setText(htmlLabel("Oldschool revision: ", engineVer));
|
||||||
|
|
||||||
JLabel launcher = new JLabel(htmlLabel("Launcher version: ", MoreObjects
|
JLabel launcher = new JLabel(htmlLabel("Launcher version: ", MoreObjects
|
||||||
.firstNonNull(RuneLiteProperties.getLauncherVersion(), "Unknown")));
|
.firstNonNull(RuneLiteProperties.getLauncherVersion(), "Unknown")));
|
||||||
launcher.setFont(smallFont);
|
launcher.setFont(smallFont);
|
||||||
|
|
||||||
loggedLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
loggedLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||||
loggedLabel.setFont(smallFont);
|
loggedLabel.setFont(smallFont);
|
||||||
|
|
||||||
emailLabel.setForeground(Color.WHITE);
|
emailLabel.setForeground(Color.WHITE);
|
||||||
emailLabel.setFont(smallFont);
|
emailLabel.setFont(smallFont);
|
||||||
emailLabel.enableAutoLinkHandler(false);
|
emailLabel.enableAutoLinkHandler(false);
|
||||||
emailLabel.addHyperlinkListener(e ->
|
emailLabel.addHyperlinkListener(e ->
|
||||||
{
|
{
|
||||||
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType()) && e.getURL() != null)
|
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType()) && e.getURL() != null)
|
||||||
{
|
{
|
||||||
if (e.getURL().toString().equals(RUNELITE_LOGIN))
|
if (e.getURL().toString().equals(RUNELITE_LOGIN))
|
||||||
{
|
{
|
||||||
executor.execute(sessionManager::login);
|
executor.execute(sessionManager::login);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
versionPanel.add(version);
|
versionPanel.add(version);
|
||||||
versionPanel.add(revision);
|
versionPanel.add(revision);
|
||||||
versionPanel.add(launcher);
|
versionPanel.add(launcher);
|
||||||
versionPanel.add(Box.createGlue());
|
versionPanel.add(Box.createGlue());
|
||||||
versionPanel.add(loggedLabel);
|
versionPanel.add(loggedLabel);
|
||||||
versionPanel.add(emailLabel);
|
versionPanel.add(emailLabel);
|
||||||
|
|
||||||
actionsContainer = new JPanel();
|
actionsContainer = new JPanel();
|
||||||
actionsContainer.setBorder(new EmptyBorder(10, 0, 0, 0));
|
actionsContainer.setBorder(new EmptyBorder(10, 0, 0, 0));
|
||||||
actionsContainer.setLayout(new GridLayout(0, 1, 0, 10));
|
actionsContainer.setLayout(new GridLayout(0, 1, 0, 10));
|
||||||
|
|
||||||
syncPanel = buildLinkPanel(IMPORT_ICON, "Import local settings", "to remote RuneLite account", () ->
|
syncPanel = buildLinkPanel(IMPORT_ICON, "Import local settings", "to remote RuneLite account", () ->
|
||||||
{
|
{
|
||||||
final int result = JOptionPane.showOptionDialog(syncPanel,
|
final int result = JOptionPane.showOptionDialog(syncPanel,
|
||||||
"This will replace your current RuneLite account settings with settings from your local profile.",
|
"This will replace your current RuneLite account settings with settings from your local profile.",
|
||||||
"Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
|
"Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
|
||||||
null, new String[]{"Yes", "No"}, "No");
|
null, new String[]{"Yes", "No"}, "No");
|
||||||
|
|
||||||
if (result == JOptionPane.YES_OPTION)
|
if (result == JOptionPane.YES_OPTION)
|
||||||
{
|
{
|
||||||
configManager.importLocal();
|
configManager.importLocal();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
actionsContainer.add(buildLinkPanel(GITHUB_ICON, "License info", "for distribution", "https://github.com/runelite-extended/runelite/blob/master/LICENSE"));
|
actionsContainer.add(buildLinkPanel(GITHUB_ICON, "License info", "for distribution", "https://github.com/runelite-extended/runelite/blob/master/LICENSE"));
|
||||||
actionsContainer.add(buildLinkPanel(DISCORD_ICON, "Talk to us on our", "discord server", "https://discord.gg/s2fzu5U"));
|
actionsContainer.add(buildLinkPanel(DISCORD_ICON, "Talk to us on our", "discord server", "https://discord.gg/s2fzu5U"));
|
||||||
actionsContainer.add(buildLinkPanel(PATREON_ICON, "Patreon to support", "the RuneLite devs", runeLiteProperties.getPatreonLink()));
|
actionsContainer.add(buildLinkPanel(PATREON_ICON, "Patreon to support", "the RuneLitePlus devs", runeLiteProperties.getPatreonLink()));
|
||||||
/* actionsContainer.add(buildLinkPanel(WIKI_ICON, "Information about", "RuneLite and plugins", runeLiteProperties.getWikiLink()));*/
|
/* actionsContainer.add(buildLinkPanel(WIKI_ICON, "Information about", "RuneLite and plugins", runeLiteProperties.getWikiLink()));*/
|
||||||
|
|
||||||
add(versionPanel, BorderLayout.NORTH);
|
add(versionPanel, BorderLayout.NORTH);
|
||||||
add(actionsContainer, BorderLayout.CENTER);
|
add(actionsContainer, BorderLayout.CENTER);
|
||||||
|
|
||||||
updateLoggedIn();
|
updateLoggedIn();
|
||||||
eventBus.register(this);
|
eventBus.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a link panel with a given icon, text and url to redirect to.
|
* Builds a link panel with a given icon, text and url to redirect to.
|
||||||
*/
|
*/
|
||||||
private static JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, String url)
|
private static JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, String url)
|
||||||
{
|
{
|
||||||
return buildLinkPanel(icon, topText, bottomText, () -> LinkBrowser.browse(url));
|
return buildLinkPanel(icon, topText, bottomText, () -> LinkBrowser.browse(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a link panel with a given icon, text and callable to call.
|
* Builds a link panel with a given icon, text and callable to call.
|
||||||
*/
|
*/
|
||||||
private static JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, Runnable callback)
|
private static JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, Runnable callback)
|
||||||
{
|
{
|
||||||
JPanel container = new JPanel();
|
JPanel container = new JPanel();
|
||||||
container.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
container.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||||
container.setLayout(new BorderLayout());
|
container.setLayout(new BorderLayout());
|
||||||
container.setBorder(new EmptyBorder(10, 10, 10, 10));
|
container.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||||
|
|
||||||
final Color hoverColor = ColorScheme.DARKER_GRAY_HOVER_COLOR;
|
final Color hoverColor = ColorScheme.DARKER_GRAY_HOVER_COLOR;
|
||||||
final Color pressedColor = ColorScheme.DARKER_GRAY_COLOR.brighter();
|
final Color pressedColor = ColorScheme.DARKER_GRAY_COLOR.brighter();
|
||||||
|
|
||||||
JLabel iconLabel = new JLabel(icon);
|
JLabel iconLabel = new JLabel(icon);
|
||||||
container.add(iconLabel, BorderLayout.WEST);
|
container.add(iconLabel, BorderLayout.WEST);
|
||||||
|
|
||||||
JPanel textContainer = new JPanel();
|
JPanel textContainer = new JPanel();
|
||||||
textContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
textContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||||
textContainer.setLayout(new GridLayout(2, 1));
|
textContainer.setLayout(new GridLayout(2, 1));
|
||||||
textContainer.setBorder(new EmptyBorder(5, 10, 5, 10));
|
textContainer.setBorder(new EmptyBorder(5, 10, 5, 10));
|
||||||
|
|
||||||
container.addMouseListener(new MouseAdapter()
|
container.addMouseListener(new MouseAdapter()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent mouseEvent)
|
public void mousePressed(MouseEvent mouseEvent)
|
||||||
{
|
{
|
||||||
container.setBackground(pressedColor);
|
container.setBackground(pressedColor);
|
||||||
textContainer.setBackground(pressedColor);
|
textContainer.setBackground(pressedColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e)
|
public void mouseReleased(MouseEvent e)
|
||||||
{
|
{
|
||||||
callback.run();
|
callback.run();
|
||||||
container.setBackground(hoverColor);
|
container.setBackground(hoverColor);
|
||||||
textContainer.setBackground(hoverColor);
|
textContainer.setBackground(hoverColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e)
|
public void mouseEntered(MouseEvent e)
|
||||||
{
|
{
|
||||||
container.setBackground(hoverColor);
|
container.setBackground(hoverColor);
|
||||||
textContainer.setBackground(hoverColor);
|
textContainer.setBackground(hoverColor);
|
||||||
container.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
container.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e)
|
public void mouseExited(MouseEvent e)
|
||||||
{
|
{
|
||||||
container.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
container.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||||
textContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
textContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||||
container.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
container.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
JLabel topLine = new JLabel(topText);
|
JLabel topLine = new JLabel(topText);
|
||||||
topLine.setForeground(Color.WHITE);
|
topLine.setForeground(Color.WHITE);
|
||||||
topLine.setFont(FontManager.getRunescapeSmallFont());
|
topLine.setFont(FontManager.getRunescapeSmallFont());
|
||||||
|
|
||||||
JLabel bottomLine = new JLabel(bottomText);
|
JLabel bottomLine = new JLabel(bottomText);
|
||||||
bottomLine.setForeground(Color.WHITE);
|
bottomLine.setForeground(Color.WHITE);
|
||||||
bottomLine.setFont(FontManager.getRunescapeSmallFont());
|
bottomLine.setFont(FontManager.getRunescapeSmallFont());
|
||||||
|
|
||||||
textContainer.add(topLine);
|
textContainer.add(topLine);
|
||||||
textContainer.add(bottomLine);
|
textContainer.add(bottomLine);
|
||||||
|
|
||||||
container.add(textContainer, BorderLayout.CENTER);
|
container.add(textContainer, BorderLayout.CENTER);
|
||||||
|
|
||||||
JLabel arrowLabel = new JLabel(ARROW_RIGHT_ICON);
|
JLabel arrowLabel = new JLabel(ARROW_RIGHT_ICON);
|
||||||
container.add(arrowLabel, BorderLayout.EAST);
|
container.add(arrowLabel, BorderLayout.EAST);
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLoggedIn()
|
private void updateLoggedIn()
|
||||||
{
|
{
|
||||||
final String name = sessionManager.getAccountSession() != null
|
final String name = sessionManager.getAccountSession() != null
|
||||||
? sessionManager.getAccountSession().getUsername()
|
? sessionManager.getAccountSession().getUsername()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (name != null)
|
if (name != null)
|
||||||
{
|
{
|
||||||
emailLabel.setContentType("text/plain");
|
emailLabel.setContentType("text/plain");
|
||||||
emailLabel.setText(name);
|
emailLabel.setText(name);
|
||||||
loggedLabel.setText("Logged in as");
|
loggedLabel.setText("Logged in as");
|
||||||
actionsContainer.add(syncPanel, 0);
|
actionsContainer.add(syncPanel, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//emailLabel.setContentType("text/html");
|
//emailLabel.setContentType("text/html");
|
||||||
//emailLabel.setText("<a href=\"" + RUNELITE_LOGIN + "\">Login</a> to sync settings to the cloud.");
|
//emailLabel.setText("<a href=\"" + RUNELITE_LOGIN + "\">Login</a> to sync settings to the cloud.");
|
||||||
//loggedLabel.setText("Not logged in");
|
//loggedLabel.setText("Not logged in");
|
||||||
actionsContainer.remove(syncPanel);
|
actionsContainer.remove(syncPanel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String htmlLabel(String key, String value)
|
private static String htmlLabel(String key, String value)
|
||||||
{
|
{
|
||||||
return "<html><body style = 'color:#a5a5a5'>" + key + "<span style = 'color:white'>" + value + "</span></body></html>";
|
return "<html><body style = 'color:#a5a5a5'>" + key + "<span style = 'color:white'>" + value + "</span></body></html>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onSessionOpen(SessionOpen sessionOpen)
|
public void onSessionOpen(SessionOpen sessionOpen)
|
||||||
{
|
{
|
||||||
updateLoggedIn();
|
updateLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onSessionClose(SessionClose e)
|
public void onSessionClose(SessionClose e)
|
||||||
{
|
{
|
||||||
updateLoggedIn();
|
updateLoggedIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user