Option to only recolor right click menu on ground

- Add option to only recolor right click menu for ground items (e.g
possibility to switch between Overlay, Right-click menu or Both)
- Merge highlight of option and item name in right click menu to 1
config option where you can choose between Option, Item name and Both

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-04-29 23:10:44 +02:00
parent 73c54db006
commit 144886aea1
5 changed files with 120 additions and 13 deletions

View File

@@ -30,6 +30,8 @@ import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import java.awt.Color;
import net.runelite.client.plugins.grounditems.config.ItemHighlightMode;
import net.runelite.client.plugins.grounditems.config.MenuHighlightMode;
@ConfigGroup(
keyName = "grounditems",
@@ -83,25 +85,25 @@ public interface GroundItemsConfig extends Config
}
@ConfigItem(
keyName = "highlightMenuOption",
name = "Highlight Menu Option",
description = "Configures whether or not to highlight the menu option",
keyName = "itemHighlightMode",
name = "Item Highlight Mode",
description = "Configures how ground items will be highlighted",
position = 5
)
default boolean highlightMenuOption()
default ItemHighlightMode itemHighlightMode()
{
return true;
return ItemHighlightMode.BOTH;
}
@ConfigItem(
keyName = "highlightMenuItemName",
name = "Highlight Menu Item Name",
description = "Configures whether or not to highlight the menu item name",
keyName = "menuHighlightMode",
name = "Menu Highlight Mode",
description = "Configures what to highlight in right-click menu",
position = 6
)
default boolean highlightMenuItemName()
default MenuHighlightMode menuHighlightMode()
{
return false;
return MenuHighlightMode.NAME;
}
@ConfigItem(

View File

@@ -40,6 +40,7 @@ import net.runelite.api.Point;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.client.game.ItemManager;
import static net.runelite.client.plugins.grounditems.config.ItemHighlightMode.MENU;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
@@ -83,6 +84,11 @@ public class GroundItemsOverlay extends Overlay
@Override
public Dimension render(Graphics2D graphics)
{
if (!plugin.isHotKeyPressed() && config.itemHighlightMode() == MENU)
{
return null;
}
final FontMetrics fm = graphics.getFontMetrics();
final Player player = client.getLocalPlayer();

View File

@@ -75,6 +75,11 @@ import net.runelite.client.input.KeyManager;
import net.runelite.client.input.MouseManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import static net.runelite.client.plugins.grounditems.config.ItemHighlightMode.OVERLAY;
import net.runelite.client.plugins.grounditems.config.MenuHighlightMode;
import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.BOTH;
import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.NAME;
import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.OPTION;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.http.api.item.ItemPrice;
@@ -338,7 +343,8 @@ public class GroundItemsPlugin extends Plugin
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
if ((config.highlightMenuOption() || config.highlightMenuItemName()) && event.getOption().equals("Take")
if (config.itemHighlightMode() != OVERLAY
&& event.getOption().equals("Take")
&& event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId())
{
int itemId = event.getIdentifier();
@@ -382,11 +388,14 @@ public class GroundItemsPlugin extends Plugin
{
String hexColor = Integer.toHexString(color.getRGB() & 0xFFFFFF);
String colTag = "<col=" + hexColor + ">";
if (config.highlightMenuOption())
final MenuHighlightMode mode = config.menuHighlightMode();
if (mode == BOTH || mode == OPTION)
{
lastEntry.setOption(colTag + "Take");
}
if (config.highlightMenuItemName())
if (mode == BOTH || mode == NAME)
{
String target = lastEntry.getTarget().substring(lastEntry.getTarget().indexOf(">") + 1);
lastEntry.setTarget(colTag + target);

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2018, Tomas Slusny <slusnucky@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.grounditems.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@Getter
@RequiredArgsConstructor
public enum ItemHighlightMode
{
OVERLAY("Overlay"),
MENU("Right-click menu"),
BOTH("Both");
private final String name;
@Override
public String toString()
{
return name;
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2018, Tomas Slusny <slusnucky@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.grounditems.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@Getter
@RequiredArgsConstructor
public enum MenuHighlightMode
{
OPTION("Menu option"),
NAME("Menu item name"),
BOTH("Both");
private final String name;
@Override
public String toString()
{
return name;
}
}