From 7aa56544883e06c8a84ea44eb6480cf299aa123f Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Thu, 1 Nov 2018 16:33:57 -0700 Subject: [PATCH] Add JagexColors constants file, update Color uses Fixes runelite/runelite#4073 --- .../client/chat/ChatMessageManager.java | 17 ++--- .../client/config/ChatColorConfig.java | 5 +- .../client/menus/WidgetMenuOption.java | 3 +- .../plugins/banktags/tabs/TabInterface.java | 3 +- .../plugins/devtools/DevToolsPlugin.java | 5 +- .../plugins/wasdcamera/WASDCameraPlugin.java | 4 +- .../net/runelite/client/ui/JagexColors.java | 63 +++++++++++++++++++ .../ui/overlay/worldmap/WorldMapOverlay.java | 8 +-- 8 files changed, 87 insertions(+), 21 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/ui/JagexColors.java diff --git a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java index f9cd0d1658..cd9f07d900 100644 --- a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java +++ b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java @@ -50,6 +50,7 @@ import net.runelite.api.events.SetMessage; import net.runelite.api.events.VarbitChanged; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ChatColorConfig; +import net.runelite.client.ui.JagexColors; import net.runelite.client.util.ColorUtil; @Singleton @@ -206,18 +207,18 @@ public class ChatMessageManager { case PUBLIC: case PUBLIC_MOD: - return Color.decode("#0000FF"); + return JagexColors.CHAT_PUBLIC_TEXT_OPAQUE_BACKGROUND; case PRIVATE_MESSAGE_SENT: case PRIVATE_MESSAGE_RECEIVED_MOD: case PRIVATE_MESSAGE_RECEIVED: - return Color.decode("#00FFFF"); + return JagexColors.CHAT_PRIVATE_MESSAGE_TEXT_OPAQUE_BACKGROUND; case CLANCHAT: - return Color.decode("#7F0000"); + return JagexColors.CHAT_CLAN_TEXT_OPAQUE_BACKGROUND; case EXAMINE_ITEM: case EXAMINE_OBJECT: case EXAMINE_NPC: case GAME: - return Color.decode("#000000"); + return JagexColors.CHAT_GAME_EXAMINE_TEXT_OPAQUE_BACKGROUND; } } else @@ -226,18 +227,18 @@ public class ChatMessageManager { case PUBLIC: case PUBLIC_MOD: - return Color.decode("#9090FF"); + return JagexColors.CHAT_PUBLIC_TEXT_TRANSPARENT_BACKGROUND; case PRIVATE_MESSAGE_SENT: case PRIVATE_MESSAGE_RECEIVED_MOD: case PRIVATE_MESSAGE_RECEIVED: - return Color.decode("#00FFFF"); + return JagexColors.CHAT_PRIVATE_MESSAGE_TEXT_TRANSPARENT_BACKGROUND; case CLANCHAT: - return Color.decode("#7F0000"); + return JagexColors.CHAT_CLAN_TEXT_TRANSPARENT_BACKGROUND; case EXAMINE_ITEM: case EXAMINE_OBJECT: case EXAMINE_NPC: case GAME: - return Color.decode("#FFFFFF"); + return JagexColors.CHAT_GAME_EXAMINE_TEXT_TRANSPARENT_BACKGROUND; } } diff --git a/runelite-client/src/main/java/net/runelite/client/config/ChatColorConfig.java b/runelite-client/src/main/java/net/runelite/client/config/ChatColorConfig.java index 4aaa6cba41..0bcf67341c 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ChatColorConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ChatColorConfig.java @@ -25,6 +25,7 @@ package net.runelite.client.config; import java.awt.Color; +import net.runelite.client.ui.JagexColors; @ConfigGroup("textrecolor") public interface ChatColorConfig extends Config @@ -94,7 +95,7 @@ public interface ChatColorConfig extends Config ) default Color opaqueClanChatInfo() { - return Color.BLACK; + return JagexColors.CHAT_GAME_EXAMINE_TEXT_OPAQUE_BACKGROUND; } @ConfigItem( @@ -334,7 +335,7 @@ public interface ChatColorConfig extends Config ) default Color transparentClanChatInfo() { - return Color.WHITE; + return JagexColors.CHAT_GAME_EXAMINE_TEXT_TRANSPARENT_BACKGROUND; } @ConfigItem( diff --git a/runelite-client/src/main/java/net/runelite/client/menus/WidgetMenuOption.java b/runelite-client/src/main/java/net/runelite/client/menus/WidgetMenuOption.java index c0b24f12ba..307551542c 100644 --- a/runelite-client/src/main/java/net/runelite/client/menus/WidgetMenuOption.java +++ b/runelite-client/src/main/java/net/runelite/client/menus/WidgetMenuOption.java @@ -27,6 +27,7 @@ package net.runelite.client.menus; import net.runelite.api.widgets.WidgetInfo; import java.awt.Color; +import net.runelite.client.ui.JagexColors; import net.runelite.client.util.ColorUtil; public final class WidgetMenuOption @@ -42,7 +43,7 @@ public final class WidgetMenuOption /** * The color that the menuTarget should be. Defaults to the brownish color that most menu options have. */ - private Color color = Color.decode("#ff9040"); + private Color color = JagexColors.MENU_TARGET; /** * The widget to add the option to diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java index 18f712a5c2..0152f1c5fa 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java @@ -83,13 +83,14 @@ import static net.runelite.client.plugins.banktags.BankTagsPlugin.SPLITTER; import static net.runelite.client.plugins.banktags.BankTagsPlugin.TAG_SEARCH; import static net.runelite.client.plugins.banktags.BankTagsPlugin.VAR_TAG_SUFFIX; import net.runelite.client.plugins.banktags.TagManager; +import net.runelite.client.ui.JagexColors; import net.runelite.client.util.ColorUtil; import net.runelite.client.util.Text; @Singleton public class TabInterface { - private static final Color HILIGHT_COLOR = Color.decode("#ff9040"); + private static final Color HILIGHT_COLOR = JagexColors.MENU_TARGET; private static final String SCROLL_UP = "Scroll up"; private static final String SCROLL_DOWN = "Scroll down"; private static final String NEW_TAB = "New tag tab"; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java index a7f70c7fbe..e02192d5f9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java @@ -30,7 +30,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.inject.Provides; -import java.awt.Color; import java.awt.Font; import java.awt.image.BufferedImage; import static java.lang.Math.min; @@ -54,6 +53,7 @@ import net.runelite.client.config.ConfigManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.FontManager; +import net.runelite.client.ui.JagexColors; import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.overlay.OverlayManager; @@ -70,7 +70,6 @@ public class DevToolsPlugin extends Plugin { private static final List EXAMINE_MENU_ACTIONS = ImmutableList.of(MenuAction.EXAMINE_ITEM, MenuAction.EXAMINE_ITEM_GROUND, MenuAction.EXAMINE_NPC, MenuAction.EXAMINE_OBJECT); - private static final Color COLOR_ORANGE = new Color(255, 144, 64); @Inject private Client client; @@ -309,7 +308,7 @@ public class DevToolsPlugin extends Plugin } } - entry.setTarget(entry.getTarget() + " " + ColorUtil.prependColorTag("(" + info + ")", COLOR_ORANGE)); + entry.setTarget(entry.getTarget() + " " + ColorUtil.prependColorTag("(" + info + ")", JagexColors.MENU_TARGET)); client.setMenuEntries(entries); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wasdcamera/WASDCameraPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/wasdcamera/WASDCameraPlugin.java index 2ee953f150..e1aa7468ab 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wasdcamera/WASDCameraPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wasdcamera/WASDCameraPlugin.java @@ -27,7 +27,6 @@ package net.runelite.client.plugins.wasdcamera; import com.google.common.eventbus.Subscribe; import com.google.inject.Provides; -import java.awt.Color; import javax.inject.Inject; import lombok.AccessLevel; import lombok.Getter; @@ -44,6 +43,7 @@ import net.runelite.client.config.ConfigManager; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.ui.JagexColors; import net.runelite.client.util.ColorUtil; @PluginDescriptor( @@ -177,7 +177,7 @@ public class WASDCameraPlugin extends Plugin { if (client.getGameState() == GameState.LOGGED_IN) { - chatboxInput.setText(client.getLocalPlayer().getName() + ": " + ColorUtil.wrapWithColorTag(client.getVar(VarClientStr.CHATBOX_TYPED_TEXT) + "*", Color.BLUE)); + chatboxInput.setText(client.getLocalPlayer().getName() + ": " + ColorUtil.wrapWithColorTag(client.getVar(VarClientStr.CHATBOX_TYPED_TEXT) + "*", JagexColors.CHAT_TYPED_TEXT_OPAQUE_BACKGROUND)); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/JagexColors.java b/runelite-client/src/main/java/net/runelite/client/ui/JagexColors.java new file mode 100644 index 0000000000..7e2faadfad --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/ui/JagexColors.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018, Jordan Atwood + * 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 java.awt.Color; + +/** + * This class serves to hold colors used in Oldschool RuneScape that are also used in client code. + */ +public class JagexColors +{ + /* + * Colors of chat text when displayed on an opaque background. + */ + public static final Color CHAT_PUBLIC_TEXT_OPAQUE_BACKGROUND = Color.BLUE; + public static final Color CHAT_PRIVATE_MESSAGE_TEXT_OPAQUE_BACKGROUND = Color.CYAN; + public static final Color CHAT_CLAN_TEXT_OPAQUE_BACKGROUND = new Color(127, 0, 0); + public static final Color CHAT_GAME_EXAMINE_TEXT_OPAQUE_BACKGROUND = Color.BLACK; + public static final Color CHAT_TYPED_TEXT_OPAQUE_BACKGROUND = Color.BLUE; + + /* + * Colors of chat text when displayed on a transparent background. + */ + public static final Color CHAT_PUBLIC_TEXT_TRANSPARENT_BACKGROUND = new Color(144, 144, 255); + public static final Color CHAT_PRIVATE_MESSAGE_TEXT_TRANSPARENT_BACKGROUND = Color.CYAN; + public static final Color CHAT_CLAN_TEXT_TRANSPARENT_BACKGROUND = new Color(127, 0, 0); + public static final Color CHAT_GAME_EXAMINE_TEXT_TRANSPARENT_BACKGROUND = Color.WHITE; + public static final Color CHAT_TYPED_TEXT_TRANSPARENT_BACKGROUND = new Color(144, 144, 255); + + /* + * Colors relating to right-click menus. + */ + public static final Color MENU_TARGET = new Color(255, 144, 64); + + /* + * Colors relating to tooltips. + */ + public static final Color TOOLTIP_BACKGROUND = new Color(255, 255, 160); + public static final Color TOOLTIP_BORDER = Color.BLACK; + public static final Color TOOLTIP_TEXT = Color.BLACK; +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java index 9e2286bcaf..b436b19b94 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java @@ -24,7 +24,6 @@ */ package net.runelite.client.ui.overlay.worldmap; -import java.awt.Color; import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics2D; @@ -42,6 +41,7 @@ import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.input.MouseManager; import net.runelite.client.ui.FontManager; +import net.runelite.client.ui.JagexColors; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; @@ -50,7 +50,6 @@ import net.runelite.client.ui.overlay.OverlayPriority; @Singleton public class WorldMapOverlay extends Overlay { - private static final Color TOOLTIP_BACKGROUND = new Color(255, 255, 160); private static final int TOOLTIP_OFFSET_HEIGHT = 25; private static final int TOOLTIP_OFFSET_WIDTH = 5; private static final int TOOLTIP_PADDING_HEIGHT = 1; @@ -260,7 +259,7 @@ public class WorldMapOverlay extends Overlay drawPoint = new Point(drawPoint.getX() + TOOLTIP_OFFSET_WIDTH, drawPoint.getY() + TOOLTIP_OFFSET_HEIGHT); graphics.setClip(client.getCanvas().getBounds()); - graphics.setColor(TOOLTIP_BACKGROUND); + graphics.setColor(JagexColors.TOOLTIP_BACKGROUND); graphics.setFont(FontManager.getRunescapeFont()); FontMetrics fm = graphics.getFontMetrics(); int width = fm.stringWidth(tooltip); @@ -269,8 +268,9 @@ public class WorldMapOverlay extends Overlay Rectangle tooltipRect = new Rectangle(drawPoint.getX() - TOOLTIP_PADDING_WIDTH, drawPoint.getY() - TOOLTIP_PADDING_HEIGHT, width + TOOLTIP_PADDING_WIDTH * 2, height + TOOLTIP_PADDING_HEIGHT * 2); graphics.fillRect((int) tooltipRect.getX(), (int) tooltipRect.getY(), (int) tooltipRect.getWidth(), (int) tooltipRect.getHeight()); - graphics.setColor(Color.black); + graphics.setColor(JagexColors.TOOLTIP_BORDER); graphics.drawRect((int) tooltipRect.getX(), (int) tooltipRect.getY(), (int) tooltipRect.getWidth(), (int) tooltipRect.getHeight()); + graphics.setColor(JagexColors.TOOLTIP_TEXT); graphics.drawString(tooltip, drawPoint.getX(), drawPoint.getY() + height); }