Adding custom cursor support to anti-drag. (#483)

* Adding custom cursor support to anti-drag.

* Remove unused import.
This commit is contained in:
Ganom
2019-06-03 16:41:50 -04:00
committed by Kyleeld
parent 69087ae33e
commit e51072d2cc
3 changed files with 106 additions and 1 deletions

View File

@@ -78,7 +78,7 @@ public interface AntiDragConfig extends Config
) )
default boolean overlay() default boolean overlay()
{ {
return true; return false;
} }
@Alpha @Alpha
@@ -86,10 +86,36 @@ public interface AntiDragConfig extends Config
keyName = "color", keyName = "color",
name = "Overlay color", name = "Overlay color",
description = "Change the overlay color, duh", description = "Change the overlay color, duh",
hidden = true,
unhide = "overlay",
position = 5 position = 5
) )
default Color color() default Color color()
{ {
return new Color(255, 0, 0, 30); return new Color(255, 0, 0, 30);
} }
@ConfigItem(
keyName = "changeCursor",
name = "Change Cursor",
description = "Change cursor when you have anti-drag enabled.",
position = 6
)
default boolean changeCursor()
{
return false;
}
@ConfigItem(
keyName = "cursorStyle",
name = "Cursor",
description = "Select which cursor you wish to use",
hidden = true,
unhide = "changeCursor",
position = 7
)
default CustomCursor selectedCursor()
{
return CustomCursor.DRAGON_SCIMITAR;
}
} }

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2018, DennisDeV <https://github.com/DevDennis> * Copyright (c) 2018, DennisDeV <https://github.com/DevDennis>
* Copyright (c) 2019, ganom <https://github.com/ganom>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -34,6 +35,8 @@ import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
import net.runelite.client.plugins.customcursor.CustomCursorConfig;
import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.HotkeyListener; import net.runelite.client.util.HotkeyListener;
@@ -52,6 +55,9 @@ public class AntiDragPlugin extends Plugin
@Inject @Inject
private Client client; private Client client;
@Inject
private ClientUI clientUI;
@Inject @Inject
private AntiDragConfig config; private AntiDragConfig config;
@@ -61,6 +67,9 @@ public class AntiDragPlugin extends Plugin
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@Inject
private ConfigManager configManager;
@Inject @Inject
private KeyManager keyManager; private KeyManager keyManager;
@@ -99,6 +108,11 @@ public class AntiDragPlugin extends Plugin
{ {
overlayManager.add(overlay); overlayManager.add(overlay);
} }
if (config.changeCursor())
{
CustomCursor selectedCursor = config.selectedCursor();
clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString());
}
client.setInventoryDragDelay(config.dragDelay()); client.setInventoryDragDelay(config.dragDelay());
} }
@@ -106,6 +120,11 @@ public class AntiDragPlugin extends Plugin
{ {
overlayManager.remove(overlay); overlayManager.remove(overlay);
client.setInventoryDragDelay(DEFAULT_DELAY); client.setInventoryDragDelay(DEFAULT_DELAY);
if (config.changeCursor())
{
net.runelite.client.plugins.customcursor.CustomCursor selectedCursor = configManager.getConfig(CustomCursorConfig.class).selectedCursor();
clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString());
}
} }
} }
}; };

View File

@@ -0,0 +1,60 @@
/*
* 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.antidrag;
import java.awt.image.BufferedImage;
import lombok.Getter;
import net.runelite.client.plugins.customcursor.CustomCursorPlugin;
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"),
ARMADYL_GODSWORD("Armadyl Godsword", "cursor-armadyl-godsword.png"),
BANDOS_GODSWORD("Bandos Godsword", "cursor-bandos-godsword.png"),
MOUSE("Mouse", "cursor-mouse.png"),
SARADOMIN_GODSWORD("Saradomin Godsword", "cursor-saradomin-godsword.png"),
ZAMORAK_GODSWORD("Zamorak Godsword", "cursor-zamorak-godsword.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;
}
}