client: add custom cursor plugin

Co-authored-by: Kruithne <kruithne@gmail.com>
Co-authored-by: Trevor <trevorguidry6@gmail.com>
This commit is contained in:
Adam
2019-04-29 13:28:17 -04:00
committed by Adam
parent 173dead8d3
commit 8d16c82377
9 changed files with 189 additions and 1 deletions

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2018, Kruithne <kruithne@gmail.com>
* 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;
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2018, Kruithne <kruithne@gmail.com>
* 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;
}
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright (c) 2018, Kruithne <kruithne@gmail.com>
* 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);
}
}

View File

@@ -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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB