client: Add option to disable custom window chrome/style
This commit is contained in:
@@ -41,6 +41,7 @@ import net.runelite.api.Client;
|
|||||||
import net.runelite.client.account.SessionManager;
|
import net.runelite.client.account.SessionManager;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
import net.runelite.client.menus.MenuManager;
|
import net.runelite.client.menus.MenuManager;
|
||||||
import net.runelite.client.plugins.PluginManager;
|
import net.runelite.client.plugins.PluginManager;
|
||||||
import net.runelite.client.ui.ClientUI;
|
import net.runelite.client.ui.ClientUI;
|
||||||
@@ -84,6 +85,9 @@ public class RuneLite
|
|||||||
@Inject
|
@Inject
|
||||||
private SessionManager sessionManager;
|
private SessionManager sessionManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private RuneLiteConfig runeliteConfig;
|
||||||
|
|
||||||
Client client;
|
Client client;
|
||||||
ClientUI gui;
|
ClientUI gui;
|
||||||
Notifier notifier;
|
Notifier notifier;
|
||||||
@@ -157,6 +161,8 @@ public class RuneLite
|
|||||||
|
|
||||||
// Begin watching for new plugins
|
// Begin watching for new plugins
|
||||||
pluginManager.watch();
|
pluginManager.watch();
|
||||||
|
|
||||||
|
SwingUtilities.invokeAndWait(() -> gui.showWithChrome(runeliteConfig.enableCustomChrome()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGui(ClientUI gui)
|
public void setGui(ClientUI gui)
|
||||||
|
|||||||
@@ -41,6 +41,17 @@ public interface RuneLiteConfig extends Config
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "uiEnableCustomChrome",
|
||||||
|
name = "Enable custom window chrome",
|
||||||
|
description = "Use Runelite's custom window title and borders.",
|
||||||
|
confirmationWarining = "Please restart your client after changing this setting"
|
||||||
|
)
|
||||||
|
default boolean enableCustomChrome()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "enablePlugins",
|
keyName = "enablePlugins",
|
||||||
name = "Enable loading of external plugins",
|
name = "Enable loading of external plugins",
|
||||||
|
|||||||
@@ -42,11 +42,13 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JPopupMenu;
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JRootPane;
|
||||||
import javax.swing.ScrollPaneConstants;
|
import javax.swing.ScrollPaneConstants;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.ToolTipManager;
|
import javax.swing.ToolTipManager;
|
||||||
@@ -65,9 +67,8 @@ import org.pushingpixels.substance.internal.ui.SubstanceRootPaneUI;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ClientUI extends JFrame
|
public class ClientUI extends JFrame
|
||||||
{
|
{
|
||||||
private static final int CLIENT_WIDTH = 809;
|
|
||||||
private static final int SCROLLBAR_WIDTH = 17;
|
private static final int SCROLLBAR_WIDTH = 17;
|
||||||
private static final int EXPANDED_WIDTH = CLIENT_WIDTH + PluginPanel.PANEL_WIDTH + SCROLLBAR_WIDTH;
|
private static final int PANEL_EXPANDED_WIDTH = PluginPanel.PANEL_WIDTH + SCROLLBAR_WIDTH;
|
||||||
private static final BufferedImage ICON;
|
private static final BufferedImage ICON;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -111,9 +112,6 @@ public class ClientUI extends JFrame
|
|||||||
// the applet is resized.
|
// the applet is resized.
|
||||||
System.setProperty("sun.awt.noerasebackground", "true");
|
System.setProperty("sun.awt.noerasebackground", "true");
|
||||||
|
|
||||||
// Use custom window decorations
|
|
||||||
JFrame.setDefaultLookAndFeelDecorated(true);
|
|
||||||
|
|
||||||
// Use substance look and feel
|
// Use substance look and feel
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -138,15 +136,31 @@ public class ClientUI extends JFrame
|
|||||||
this.trayIcon = setupTrayIcon();
|
this.trayIcon = setupTrayIcon();
|
||||||
|
|
||||||
init();
|
init();
|
||||||
pack();
|
|
||||||
new TitleBarPane(this.getRootPane(), (SubstanceRootPaneUI)this.getRootPane().getUI()).editTitleBar(this);
|
|
||||||
setTitle(null);
|
setTitle(null);
|
||||||
setIconImage(ICON);
|
setIconImage(ICON);
|
||||||
// Prevent substance from using a resize cursor for pointing
|
// Prevent substance from using a resize cursor for pointing
|
||||||
getLayeredPane().setCursor(Cursor.getDefaultCursor());
|
getLayeredPane().setCursor(Cursor.getDefaultCursor());
|
||||||
setLocationRelativeTo(getOwner());
|
setLocationRelativeTo(getOwner());
|
||||||
setResizable(true);
|
setResizable(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showWithChrome(boolean customChrome)
|
||||||
|
{
|
||||||
|
setUndecorated(customChrome);
|
||||||
|
if (customChrome)
|
||||||
|
{
|
||||||
|
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
|
||||||
|
}
|
||||||
|
pack();
|
||||||
|
revalidateMinimumSize();
|
||||||
|
setLocationRelativeTo(getOwner());
|
||||||
|
if (customChrome)
|
||||||
|
{
|
||||||
|
new TitleBarPane(this.getRootPane(), (SubstanceRootPaneUI) this.getRootPane().getUI()).editTitleBar(this);
|
||||||
|
}
|
||||||
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
toFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setUIFont(FontUIResource f)
|
private static void setUIFont(FontUIResource f)
|
||||||
@@ -219,7 +233,6 @@ public class ClientUI extends JFrame
|
|||||||
assert SwingUtilities.isEventDispatchThread();
|
assert SwingUtilities.isEventDispatchThread();
|
||||||
|
|
||||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||||
setMinimumSize(new Dimension(CLIENT_WIDTH, 0));
|
|
||||||
addWindowListener(new WindowAdapter()
|
addWindowListener(new WindowAdapter()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -230,41 +243,53 @@ public class ClientUI extends JFrame
|
|||||||
});
|
});
|
||||||
|
|
||||||
container = new JPanel();
|
container = new JPanel();
|
||||||
container.setLayout(new BorderLayout(0, 0));
|
container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
|
||||||
container.add(new ClientPanel(client), BorderLayout.CENTER);
|
container.add(new ClientPanel(client));
|
||||||
|
|
||||||
navContainer = new JPanel();
|
navContainer = new JPanel();
|
||||||
navContainer.setLayout(new BorderLayout(0, 0));
|
navContainer.setLayout(new BorderLayout(0,0));
|
||||||
container.add(navContainer, BorderLayout.EAST);
|
navContainer.setMinimumSize(new Dimension(0,0));
|
||||||
|
navContainer.setMaximumSize(new Dimension(0,Integer.MAX_VALUE));
|
||||||
|
container.add(navContainer);
|
||||||
|
|
||||||
pluginToolbar = new PluginToolbar(this);
|
pluginToolbar = new PluginToolbar(this);
|
||||||
navContainer.add(pluginToolbar, BorderLayout.EAST);
|
container.add(pluginToolbar);
|
||||||
|
|
||||||
add(container);
|
add(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void revalidateMinimumSize()
|
||||||
|
{
|
||||||
|
// The JFrame only respects minimumSize if it was set by setMinimumSize, for some reason. (atleast on windows/native)
|
||||||
|
this.setMinimumSize(this.getLayout().minimumLayoutSize(this));
|
||||||
|
}
|
||||||
|
|
||||||
void expand(PluginPanel panel)
|
void expand(PluginPanel panel)
|
||||||
{
|
{
|
||||||
if (pluginPanel != null)
|
if (pluginPanel != null)
|
||||||
{
|
{
|
||||||
navContainer.remove(1);
|
navContainer.remove(0);
|
||||||
container.validate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginPanel = panel;
|
pluginPanel = panel;
|
||||||
navContainer.add(wrapPanel(pluginPanel), BorderLayout.WEST);
|
navContainer.setMinimumSize(new Dimension(PANEL_EXPANDED_WIDTH, 0));
|
||||||
container.validate();
|
navContainer.setMaximumSize(new Dimension(PANEL_EXPANDED_WIDTH, Integer.MAX_VALUE));
|
||||||
this.setMinimumSize(new Dimension(EXPANDED_WIDTH, 0));
|
navContainer.add(wrapPanel(pluginPanel));
|
||||||
|
navContainer.revalidate();
|
||||||
|
revalidateMinimumSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void contract()
|
void contract()
|
||||||
{
|
{
|
||||||
navContainer.remove(1);
|
boolean wasMinimumWidth = this.getWidth() == (int) this.getMinimumSize().getWidth();
|
||||||
container.validate();
|
navContainer.remove(0);
|
||||||
this.setMinimumSize(new Dimension(CLIENT_WIDTH, 0));
|
navContainer.setMinimumSize(new Dimension(0, 0));
|
||||||
if (this.getWidth() == EXPANDED_WIDTH)
|
navContainer.setMaximumSize(new Dimension(0, Integer.MAX_VALUE));
|
||||||
|
navContainer.revalidate();
|
||||||
|
revalidateMinimumSize();
|
||||||
|
if (wasMinimumWidth)
|
||||||
{
|
{
|
||||||
this.setSize(CLIENT_WIDTH, getHeight());
|
this.setSize((int) this.getMinimumSize().getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
pluginPanel = null;
|
pluginPanel = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public class PluginToolbar extends JToolBar
|
|||||||
super.setSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT));
|
super.setSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT));
|
||||||
super.setMinimumSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT));
|
super.setMinimumSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT));
|
||||||
super.setPreferredSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT));
|
super.setPreferredSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT));
|
||||||
|
super.setMaximumSize(new Dimension(TOOLBAR_WIDTH, Integer.MAX_VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNavigation(NavigationButton button)
|
public void addNavigation(NavigationButton button)
|
||||||
|
|||||||
Reference in New Issue
Block a user