diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursor.java b/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursor.java new file mode 100644 index 0000000000..1116ab10c2 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursor.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2018, Kruithne + * 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.plugins.customcursor; + +import java.awt.image.BufferedImage; +import lombok.Getter; +import net.runelite.client.util.ImageUtil; + +public enum CustomCursor +{ + RS3_GOLD("RS3 Gold", "cursor-rs3-gold.png"), + RS3_SILVER("RS3 Silver", "cursor-rs3-silver.png"), + DRAGON_DAGGER("Dragon Dagger", "cursor-dragon-dagger.png"), + TROUT("Trout", "cursor-trout.png"), + DRAGON_SCIMITAR("Dragon Scimitar", "cursor-dragon-scimitar.png"); + + private final String name; + @Getter + private final BufferedImage cursorImage; + + CustomCursor(String name, String icon) + { + this.name = name; + this.cursorImage = ImageUtil.getResourceStreamFromClass(CustomCursorPlugin.class, icon); + } + + @Override + public String toString() + { + return name; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursorConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursorConfig.java new file mode 100644 index 0000000000..cf7075a393 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursorConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018, Kruithne + * 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.plugins.customcursor; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("customcursor") +public interface CustomCursorConfig extends Config +{ + @ConfigItem( + keyName = "cursorStyle", + name = "Cursor", + description = "Select which cursor you wish to use" + ) + default CustomCursor selectedCursor() + { + return CustomCursor.RS3_GOLD; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursorPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursorPlugin.java new file mode 100644 index 0000000000..3025640cd2 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursorPlugin.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2018, Kruithne + * 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.plugins.customcursor; + +import com.google.inject.Provides; +import java.awt.Cursor; +import java.awt.Point; +import java.awt.Toolkit; +import javax.inject.Inject; +import javax.swing.JPanel; +import net.runelite.api.events.ConfigChanged; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.ui.ClientUI; + +@PluginDescriptor( + name = "Custom Cursor", + description = "Replaces your mouse cursor image", + enabledByDefault = false +) +public class CustomCursorPlugin extends Plugin +{ + @Inject + private ClientUI clientUI; + + @Inject + private CustomCursorConfig config; + + @Provides + CustomCursorConfig provideConfig(ConfigManager configManager) + { + return configManager.getConfig(CustomCursorConfig.class); + } + + @Override + protected void startUp() + { + updateCursor(); + } + + @Override + protected void shutDown() + { + clientUI.getContainer().setCursor(Cursor.getDefaultCursor()); + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("customcursor") && event.getKey().equals("cursorStyle")) + { + updateCursor(); + } + } + + private void updateCursor() + { + JPanel container = clientUI.getContainer(); + CustomCursor selectedCursor = config.selectedCursor(); + + Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(selectedCursor.getCursorImage(), + new Point(container.getX(), container.getY()), selectedCursor.toString()); + container.setCursor(cursor); + } +} \ No newline at end of file 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 96ba6c31e6..4f76d01a39 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 @@ -110,6 +110,9 @@ public class ClientUI @Getter private TrayIcon trayIcon; + @Getter + private JPanel container; + private final RuneLiteProperties properties; private final RuneLiteConfig config; private final KeyManager keyManager; @@ -130,7 +133,6 @@ public class ClientUI private JButton currentButton; private NavigationButton currentNavButton; private boolean sidebarOpen; - private JPanel container; private NavigationButton sidebarNavigationButton; private JButton sidebarNavigationJButton; private Dimension lastClientSize; diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-dragon-dagger.png b/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-dragon-dagger.png new file mode 100644 index 0000000000..9a59c1753c Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-dragon-dagger.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-dragon-scimitar.png b/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-dragon-scimitar.png new file mode 100644 index 0000000000..1db7d1a0bc Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-dragon-scimitar.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-rs3-gold.png b/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-rs3-gold.png new file mode 100644 index 0000000000..ee89a5b05a Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-rs3-gold.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-rs3-silver.png b/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-rs3-silver.png new file mode 100644 index 0000000000..7415625a2f Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-rs3-silver.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-trout.png b/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-trout.png new file mode 100644 index 0000000000..b32ddf0ea1 Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/customcursor/cursor-trout.png differ