From c39cbd6b4fa76eb5ee6e8970d0c937168433811e Mon Sep 17 00:00:00 2001 From: Aleksander Birkeland Date: Sun, 31 May 2020 18:05:48 +0200 Subject: [PATCH] ClientUI: Add support for changing window opacity. --- .../client/config/RuneLiteConfig.java | 21 ++++++++++++++++--- .../java/net/runelite/client/ui/ClientUI.java | 10 ++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java b/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java index b511a5e407..43e2a93ae6 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java @@ -105,11 +105,26 @@ public interface RuneLiteConfig extends Config return true; } + @Range( + min = 10, + max = 100 + ) + @ConfigItem( + keyName = "uiWindowOpacity", + name = "Window opacity", + description = "Set the windows opacity. Requires \"Enable custom window chrome\" to be enabled.", + position = 16 + ) + default int windowOpacity() + { + return 100; + } + @ConfigItem( keyName = "gameAlwaysOnTop", name = "Enable client always on top", description = "The game will always be on the top of the screen", - position = 16 + position = 17 ) default boolean gameAlwaysOnTop() { @@ -120,7 +135,7 @@ public interface RuneLiteConfig extends Config keyName = "warningOnExit", name = "Display warning on exit", description = "Toggles a warning popup when trying to exit the client", - position = 17 + position = 18 ) default WarningOnExit warningOnExit() { @@ -131,7 +146,7 @@ public interface RuneLiteConfig extends Config keyName = "usernameInTitle", name = "Show display name in title", description = "Toggles displaying of local player's display name in client title", - position = 18 + position = 19 ) default boolean usernameInTitle() { diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java index 5c6f2b8fe5..78fffa2128 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java @@ -161,7 +161,7 @@ public class ClientUI @Subscribe public void onConfigChanged(ConfigChanged event) { - if (!event.getGroup().equals("runelite") || + if (!event.getGroup().equals(CONFIG_GROUP) || event.getKey().equals(CONFIG_CLIENT_MAXIMIZED) || event.getKey().equals(CONFIG_CLIENT_BOUNDS)) { @@ -979,6 +979,14 @@ public class ClientUI return; } + // Update window opacity if the frame is undecorated, translucency capable and not fullscreen + if (frame.isUndecorated() && + frame.getGraphicsConfiguration().isTranslucencyCapable() && + frame.getGraphicsConfiguration().getDevice().getFullScreenWindow() == null) + { + frame.setOpacity(((float) config.windowOpacity()) / 100.0f); + } + if (config.usernameInTitle() && (client instanceof Client)) { final Player player = ((Client)client).getLocalPlayer();