spellbook: bugfixes/improvements (#1427)
* Add InterfaceTab enum, remove duplicate varbit * Add widget.containsMouse rs-api method, sort scriptids, add various wids * Refactor/improve/fix spellbook I even made everything I could final to please goban * Fix bugs/cleanup/improvements * Update SpellbookPlugin.java
This commit is contained in:
@@ -59,7 +59,7 @@ public final class WidgetMenuOption
|
||||
public WidgetMenuOption(String menuOption, String menuTarget, WidgetInfo widget)
|
||||
{
|
||||
this.menuOption = menuOption;
|
||||
setMenuTarget(menuTarget);
|
||||
this.menuTarget = menuTarget;
|
||||
this.widget = widget;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemDefinition;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.VarClientInt;
|
||||
import net.runelite.api.vars.InterfaceTab;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import static net.runelite.client.plugins.lootingbagviewer.LootingBagViewerOverlay.PLACEHOLDER_WIDTH;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
@@ -98,7 +99,7 @@ class InventoryViewerOverlay extends Overlay
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (plugin.isHideWhenInvOpen()
|
||||
&& client.getVar(VarClientInt.PLAYER_INTERFACE_CONTAINER_OPENED) == 3)
|
||||
&& client.getVar(VarClientInt.INTERFACE_TAB) == InterfaceTab.INVENTORY.getId())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import net.runelite.api.VarClientInt;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.VarClientIntChanged;
|
||||
import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.vars.InterfaceTab;
|
||||
import net.runelite.api.widgets.JavaScriptCallback;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
@@ -182,7 +183,7 @@ public class MusicListPlugin extends Plugin
|
||||
|
||||
private boolean isOnMusicTab()
|
||||
{
|
||||
return client.getVar(VarClientInt.INVENTORY_TAB) == 13;
|
||||
return client.getVar(VarClientInt.INTERFACE_TAB) == InterfaceTab.MUSIC.getId();
|
||||
}
|
||||
|
||||
private boolean isChatboxOpen()
|
||||
|
||||
@@ -47,6 +47,7 @@ import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.ScriptCallbackEvent;
|
||||
import net.runelite.api.events.VarClientIntChanged;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.api.vars.InterfaceTab;
|
||||
import net.runelite.api.widgets.JavaScriptCallback;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
@@ -192,7 +193,7 @@ public class QuestListPlugin extends Plugin
|
||||
|
||||
private void onVarClientIntChanged(VarClientIntChanged varClientIntChanged)
|
||||
{
|
||||
if (varClientIntChanged.getIndex() == VarClientInt.INVENTORY_TAB.getIndex() && isChatboxOpen() && isNotOnQuestTab())
|
||||
if (varClientIntChanged.getIndex() == VarClientInt.INTERFACE_TAB.getIndex() && isChatboxOpen() && isNotOnQuestTab())
|
||||
{
|
||||
chatboxPanelManager.close();
|
||||
}
|
||||
@@ -218,7 +219,7 @@ public class QuestListPlugin extends Plugin
|
||||
|
||||
private boolean isNotOnQuestTab()
|
||||
{
|
||||
return client.getVar(Varbits.QUEST_TAB) != 0 || client.getVar(VarClientInt.INVENTORY_TAB) != 2;
|
||||
return client.getVar(Varbits.QUEST_TAB) != 0 || client.getVar(VarClientInt.INTERFACE_TAB) != InterfaceTab.QUEST.getId();
|
||||
}
|
||||
|
||||
private boolean isChatboxOpen()
|
||||
|
||||
@@ -67,7 +67,7 @@ public interface SpellbookConfig extends Config
|
||||
@ConfigItem(
|
||||
keyName = "size",
|
||||
name = "Spell size",
|
||||
description = "Size (in px) of spells. Normal mobile size is 40px, use common sense for this setting please",
|
||||
description = "Size (in px) of spells. Normal mobile size is 40px, use common sense for this setting",
|
||||
position = 4
|
||||
)
|
||||
default int size()
|
||||
@@ -78,7 +78,7 @@ public interface SpellbookConfig extends Config
|
||||
@ConfigItem(
|
||||
keyName = "filter",
|
||||
name = "Unfiltered spells",
|
||||
description = "Spells you don't want to filter, seperated with a comma. <br> \"'s can be used in front and behind spells (eg: '\"c' matches all spells starting with a c"
|
||||
description = "Spells you don't want to filter, seperated by a comma. <br> \"'s can be used in front and behind spells (eg: '\"c' matches all spells starting with a c"
|
||||
) // ^ JAJAJJAJAJAJAJA BRAZIL
|
||||
default String filter()
|
||||
{
|
||||
@@ -103,4 +103,51 @@ public interface SpellbookConfig extends Config
|
||||
hidden = true
|
||||
)
|
||||
void canDrag(boolean canDrag);
|
||||
|
||||
// Next 4 methods have to be here, or the reset configuration
|
||||
// button won't reset em like it should.
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "standard",
|
||||
name = "",
|
||||
description = "",
|
||||
hidden = true
|
||||
)
|
||||
default String standard()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "ancient",
|
||||
name = "",
|
||||
description = "",
|
||||
hidden = true
|
||||
)
|
||||
default String ancient()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "lunar",
|
||||
name = "",
|
||||
description = "",
|
||||
hidden = true
|
||||
)
|
||||
default String lunar()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "arceuus",
|
||||
name = "",
|
||||
description = "",
|
||||
hidden = true
|
||||
)
|
||||
default String arceuus()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,10 @@ package net.runelite.client.plugins.spellbook;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.client.game.SpriteManager;
|
||||
import net.runelite.api.Sprite;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
@@ -43,21 +41,19 @@ public class SpellbookDragOverlay extends Overlay
|
||||
{
|
||||
private final SpellbookPlugin plugin;
|
||||
private final Client client;
|
||||
private final SpriteManager spriteManager;
|
||||
|
||||
@Inject
|
||||
private SpellbookDragOverlay(final SpellbookPlugin plugin, final Client client, final SpriteManager spriteManager)
|
||||
private SpellbookDragOverlay(final SpellbookPlugin plugin, final Client client)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
this.client = client;
|
||||
this.spriteManager = spriteManager;
|
||||
setPosition(OverlayPosition.TOOLTIP);
|
||||
setPriority(OverlayPriority.HIGHEST);
|
||||
setPriority(OverlayPriority.HIGH);
|
||||
setLayer(OverlayLayer.ALWAYS_ON_TOP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D g)
|
||||
public Dimension render(final Graphics2D g)
|
||||
{
|
||||
if (!plugin.isDragging())
|
||||
{
|
||||
@@ -66,16 +62,14 @@ public class SpellbookDragOverlay extends Overlay
|
||||
|
||||
final net.runelite.api.Point mouseCanvasPosition = client.getMouseCanvasPosition();
|
||||
final net.runelite.api.Point draggingLocation = plugin.getDraggingLocation();
|
||||
final Sprite sprite = plugin.getDraggingWidget().getSprite();
|
||||
final Point drawPos = new Point(mouseCanvasPosition.getX() - draggingLocation.getX(), mouseCanvasPosition.getY() - draggingLocation.getY());
|
||||
|
||||
final int size = plugin.getDraggingWidget().getWidth();
|
||||
final int sprite = plugin.getDraggingWidget().getSpriteId();
|
||||
final BufferedImage image = spriteManager.getSprite(sprite, 0);
|
||||
if (sprite != null)
|
||||
{
|
||||
sprite.drawAt(drawPos.x, drawPos.y);
|
||||
}
|
||||
|
||||
final Point mousePosition = new Point(mouseCanvasPosition.getX() - draggingLocation.getX(), mouseCanvasPosition.getY() - draggingLocation.getY());
|
||||
final Rectangle bounds = new Rectangle(mousePosition.x, mousePosition.y, size, size);
|
||||
|
||||
g.drawImage(image, mousePosition.x, mousePosition.y, size, size, null);
|
||||
|
||||
return bounds.getSize();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,16 +42,16 @@ class SpellbookMouseListener extends MouseAdapter implements MouseWheelListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public MouseEvent mouseClicked(MouseEvent event)
|
||||
public MouseEvent mouseClicked(final MouseEvent event)
|
||||
{
|
||||
if (plugin.isNotOnSpellWidget(event.getPoint()))
|
||||
if (plugin.isNotOnSpellWidget())
|
||||
{
|
||||
return event;
|
||||
}
|
||||
|
||||
if (SwingUtilities.isMiddleMouseButton(event))
|
||||
{
|
||||
plugin.resetZoom(event.getPoint());
|
||||
plugin.resetSize();
|
||||
}
|
||||
|
||||
event.consume();
|
||||
@@ -59,21 +59,24 @@ class SpellbookMouseListener extends MouseAdapter implements MouseWheelListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public MouseEvent mousePressed(MouseEvent event)
|
||||
public MouseEvent mousePressed(final MouseEvent event)
|
||||
{
|
||||
if (!SwingUtilities.isLeftMouseButton(event) || plugin.isNotOnSpellWidget(event.getPoint()) || plugin.isDragging())
|
||||
if (SwingUtilities.isRightMouseButton(event))
|
||||
{
|
||||
plugin.resetLocation();
|
||||
return event;
|
||||
}
|
||||
else if (SwingUtilities.isLeftMouseButton(event) && !plugin.isNotOnSpellWidget() && !plugin.isDragging())
|
||||
{
|
||||
plugin.startDragging(event.getPoint());
|
||||
event.consume();
|
||||
}
|
||||
|
||||
plugin.startDragging(event.getPoint());
|
||||
|
||||
event.consume();
|
||||
return event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MouseEvent mouseReleased(MouseEvent event)
|
||||
public MouseEvent mouseReleased(final MouseEvent event)
|
||||
{
|
||||
if (!SwingUtilities.isLeftMouseButton(event) || !plugin.isDragging())
|
||||
{
|
||||
@@ -87,22 +90,22 @@ class SpellbookMouseListener extends MouseAdapter implements MouseWheelListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public MouseWheelEvent mouseWheelMoved(MouseWheelEvent event)
|
||||
public MouseWheelEvent mouseWheelMoved(final MouseWheelEvent event)
|
||||
{
|
||||
if (plugin.isNotOnSpellWidget(event.getPoint()))
|
||||
if (plugin.isNotOnSpellWidget())
|
||||
{
|
||||
return event;
|
||||
}
|
||||
|
||||
int direction = event.getWheelRotation();
|
||||
final int direction = event.getWheelRotation();
|
||||
|
||||
if (direction > 0)
|
||||
{
|
||||
plugin.increaseSize(event.getPoint());
|
||||
plugin.increaseSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.decreaseSize(event.getPoint());
|
||||
plugin.decreaseSize();
|
||||
}
|
||||
|
||||
event.consume();
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@@ -42,15 +41,18 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Point;
|
||||
import static net.runelite.api.ScriptID.MAGIC_SPELLBOOK_REDRAW;
|
||||
import net.runelite.api.VarClientInt;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.ScriptCallbackEvent;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.api.events.VarClientIntChanged;
|
||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
||||
import net.runelite.api.vars.InterfaceTab;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import static net.runelite.api.widgets.WidgetInfo.*;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
@@ -63,6 +65,7 @@ import net.runelite.client.plugins.PluginType;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import static net.runelite.client.util.MiscUtils.clamp;
|
||||
import net.runelite.client.util.Text;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Spellbook",
|
||||
@@ -88,6 +91,8 @@ public class SpellbookPlugin extends Plugin
|
||||
private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_MAGIC_TAB_LOCK = new WidgetMenuOption(LOCK, MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_MAGIC_TAB);
|
||||
private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_MAGIC_TAB_UNLOCK = new WidgetMenuOption(UNLOCK, MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_MAGIC_TAB);
|
||||
private final Map<Integer, Spell> spells = new HashMap<>();
|
||||
private final SpellbookMouseListener mouseListener = new SpellbookMouseListener(this);
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@@ -123,78 +128,14 @@ public class SpellbookPlugin extends Plugin
|
||||
|
||||
@Getter
|
||||
private Point draggingLocation;
|
||||
private Map<Integer, Spell> tmp = null;
|
||||
|
||||
private ImmutableSet<String> notFilteredSpells;
|
||||
private Spellbook spellbook;
|
||||
private SpellbookMouseListener mouseListener;
|
||||
private boolean mageTabOpen;
|
||||
private boolean enableMobile;
|
||||
private boolean dragSpells;
|
||||
private boolean scroll;
|
||||
private int size;
|
||||
private String filter;
|
||||
|
||||
private static boolean isUnfiltered(String spell, Set<String> unfiltereds)
|
||||
{
|
||||
for (String str : unfiltereds)
|
||||
{
|
||||
WordFilterMode mode = getFilterMode(str);
|
||||
str = removeFlyingComma(str).toLowerCase();
|
||||
spell = spell.toLowerCase();
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case CONTAINS:
|
||||
if (spell.contains(str))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case STARTSWITH:
|
||||
if (spell.startsWith(str))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case ENDSWITH:
|
||||
if (spell.endsWith(str))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case EQUALS:
|
||||
if (spell.equals(str))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static WordFilterMode getFilterMode(String s)
|
||||
{
|
||||
if (!s.contains("\""))
|
||||
{
|
||||
return WordFilterMode.CONTAINS;
|
||||
}
|
||||
if (s.startsWith("\""))
|
||||
{
|
||||
return s.endsWith("\"") ? WordFilterMode.EQUALS : WordFilterMode.STARTSWITH;
|
||||
}
|
||||
else if (s.endsWith("\""))
|
||||
{
|
||||
return WordFilterMode.ENDSWITH;
|
||||
}
|
||||
|
||||
return WordFilterMode.CONTAINS; // but probably null soz
|
||||
}
|
||||
|
||||
private static String removeFlyingComma(String s)
|
||||
{
|
||||
return s.replaceAll("\"", "");
|
||||
}
|
||||
|
||||
@Provides
|
||||
SpellbookConfig getConfig(ConfigManager configManager)
|
||||
@@ -205,12 +146,9 @@ public class SpellbookPlugin extends Plugin
|
||||
@Override
|
||||
protected void startUp()
|
||||
{
|
||||
updateConfig();
|
||||
addSubscriptions();
|
||||
|
||||
updateConfig();
|
||||
refreshMagicTabOption();
|
||||
loadFilter();
|
||||
mouseListener = new SpellbookMouseListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -222,60 +160,105 @@ public class SpellbookPlugin extends Plugin
|
||||
config.canDrag(false);
|
||||
mouseManager.unregisterMouseListener(mouseListener);
|
||||
mouseManager.unregisterMouseWheelListener(mouseListener);
|
||||
mouseListener = null;
|
||||
}
|
||||
|
||||
private void addSubscriptions()
|
||||
{
|
||||
eventBus.subscribe(VarClientIntChanged.class, this, this::onVarCIntChanged);
|
||||
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
|
||||
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
|
||||
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
|
||||
eventBus.subscribe(WidgetMenuOptionClicked.class, this, this::onWidgetMenuOptionClicked);
|
||||
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
|
||||
}
|
||||
|
||||
private void onGameStateChanged(GameStateChanged event)
|
||||
private void updateConfig()
|
||||
{
|
||||
if (event.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
refreshMagicTabOption();
|
||||
}
|
||||
loadFilter();
|
||||
this.enableMobile = config.enableMobile();
|
||||
this.dragSpells = config.dragSpells();
|
||||
this.scroll = config.scroll();
|
||||
this.size = config.size();
|
||||
}
|
||||
|
||||
private void onConfigChanged(ConfigChanged event)
|
||||
private void onConfigChanged(final ConfigChanged event)
|
||||
{
|
||||
if (!"spellbook".equals(event.getGroup()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
updateConfig();
|
||||
|
||||
String key = event.getKey();
|
||||
|
||||
if ("filter".equals(key))
|
||||
switch (event.getKey())
|
||||
{
|
||||
loadFilter();
|
||||
case "filter":
|
||||
loadFilter();
|
||||
break;
|
||||
case "enableMobile":
|
||||
enableMobile = config.enableMobile();
|
||||
break;
|
||||
case "dragSpells":
|
||||
dragSpells = config.dragSpells();
|
||||
break;
|
||||
case "scroll":
|
||||
scroll = config.scroll();
|
||||
break;
|
||||
case "size":
|
||||
size = config.size();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
clientThread.invokeLater(this::runRebuild);
|
||||
runRebuild();
|
||||
refreshMagicTabOption();
|
||||
}
|
||||
|
||||
public void onVarbitChanged(VarbitChanged event)
|
||||
private void loadFilter()
|
||||
{
|
||||
if (client.getGameState() != GameState.LOGGED_IN)
|
||||
notFilteredSpells = ImmutableSet.copyOf(Text.fromCSV(config.filter().toLowerCase()));
|
||||
saveSpells();
|
||||
loadSpells();
|
||||
}
|
||||
|
||||
private void onGameStateChanged(final GameStateChanged event)
|
||||
{
|
||||
if (event.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
mageTabOpen = client.getVar(VarClientInt.INTERFACE_TAB) == InterfaceTab.SPELLBOOK.getId();
|
||||
refreshMagicTabOption();
|
||||
}
|
||||
}
|
||||
|
||||
private void onVarCIntChanged(final VarClientIntChanged event)
|
||||
{
|
||||
if (event.getIndex() != VarClientInt.INTERFACE_TAB.getIndex())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.canDrag())
|
||||
final boolean intfTab = client.getVar(VarClientInt.INTERFACE_TAB) == InterfaceTab.SPELLBOOK.getId();
|
||||
if (intfTab != mageTabOpen)
|
||||
{
|
||||
config.canDrag(client.getVar(Varbits.FILTER_SPELLBOOK) == 1 && client.getVar(VarClientInt.INVENTORY_TAB) == 6);
|
||||
mageTabOpen = intfTab;
|
||||
refreshMagicTabOption();
|
||||
}
|
||||
|
||||
if (!config.canDrag() || client.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean shouldBeAbleToDrag = mageTabOpen && client.getVar(Varbits.FILTER_SPELLBOOK) == 0;
|
||||
if (shouldBeAbleToDrag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mouseManager.unregisterMouseListener(mouseListener);
|
||||
mouseManager.unregisterMouseWheelListener(mouseListener);
|
||||
config.canDrag(false);
|
||||
}
|
||||
|
||||
private void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event)
|
||||
private void onWidgetMenuOptionClicked(final WidgetMenuOptionClicked event)
|
||||
{
|
||||
if (event.getWidget() != WidgetInfo.FIXED_VIEWPORT_MAGIC_TAB
|
||||
&& event.getWidget() != WidgetInfo.RESIZABLE_VIEWPORT_MAGIC_TAB
|
||||
@@ -284,12 +267,16 @@ public class SpellbookPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
saveSpells();
|
||||
loadSpells();
|
||||
|
||||
if (event.getMenuOption().equals(UNLOCK))
|
||||
{
|
||||
config.canDrag(true);
|
||||
|
||||
overlayManager.add(overlay);
|
||||
|
||||
mouseManager.registerMouseListener(mouseListener);
|
||||
tmp = new HashMap<>();
|
||||
|
||||
if (this.scroll)
|
||||
{
|
||||
@@ -299,12 +286,14 @@ public class SpellbookPlugin extends Plugin
|
||||
else if (event.getMenuOption().equals(LOCK))
|
||||
{
|
||||
config.canDrag(false);
|
||||
|
||||
overlayManager.remove(overlay);
|
||||
|
||||
mouseManager.unregisterMouseListener(mouseListener);
|
||||
mouseManager.unregisterMouseWheelListener(mouseListener);
|
||||
saveSpells();
|
||||
tmp = null;
|
||||
}
|
||||
|
||||
refreshMagicTabOption();
|
||||
}
|
||||
|
||||
private void clearMagicTabMenus()
|
||||
@@ -320,7 +309,8 @@ public class SpellbookPlugin extends Plugin
|
||||
private void refreshMagicTabOption()
|
||||
{
|
||||
clearMagicTabMenus();
|
||||
if (client.getGameState() != GameState.LOGGED_IN || !this.dragSpells)
|
||||
|
||||
if (!this.dragSpells || !mageTabOpen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -339,7 +329,7 @@ public class SpellbookPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private void onScriptCallbackEvent(ScriptCallbackEvent event)
|
||||
private void onScriptCallbackEvent(final ScriptCallbackEvent event)
|
||||
{
|
||||
if (client.getVar(Varbits.FILTER_SPELLBOOK) != 0
|
||||
|| !this.enableMobile
|
||||
@@ -348,129 +338,135 @@ public class SpellbookPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
int[] iStack = client.getIntStack();
|
||||
int iStackSize = client.getIntStackSize();
|
||||
final int[] iStack = client.getIntStack();
|
||||
final int iStackSize = client.getIntStackSize();
|
||||
|
||||
String[] sStack = client.getStringStack();
|
||||
int sStackSize = client.getStringStackSize();
|
||||
final String[] sStack = client.getStringStack();
|
||||
final int sStackSize = client.getStringStackSize();
|
||||
|
||||
if ("startSpellRedraw".equals(event.getEventName()))
|
||||
switch (event.getEventName())
|
||||
{
|
||||
if (config.canDrag())
|
||||
{
|
||||
return;
|
||||
}
|
||||
case "startSpellRedraw":
|
||||
final Spellbook pook = Spellbook.getByID(client.getVar(Varbits.SPELLBOOK));
|
||||
|
||||
spellbook = Spellbook.getByID(client.getVar(Varbits.SPELLBOOK));
|
||||
loadSpells();
|
||||
}
|
||||
else if ("shouldFilterSpell".equals(event.getEventName()))
|
||||
{
|
||||
String spell = sStack[sStackSize - 1].toLowerCase();
|
||||
int widget = iStack[iStackSize - 1];
|
||||
|
||||
// Add the spell to spells
|
||||
if (!spells.containsKey(widget))
|
||||
{
|
||||
Spell s = new Spell();
|
||||
s.setWidget(widget);
|
||||
s.setX(-1);
|
||||
s.setY(-1);
|
||||
s.setSize(0);
|
||||
s.setName(spell);
|
||||
|
||||
spells.put(widget, s);
|
||||
}
|
||||
|
||||
if (notFilteredSpells.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImmutableSet<String> tmp = ImmutableSet.copyOf(notFilteredSpells);
|
||||
|
||||
iStack[iStackSize - 2] = isUnfiltered(spell, tmp) ? 1 : 0;
|
||||
}
|
||||
else if ("isMobileSpellbookEnabled".equals(event.getEventName()))
|
||||
{
|
||||
iStack[iStackSize - 1] = 1;
|
||||
}
|
||||
else if ("resizeSpell".equals(event.getEventName()))
|
||||
{
|
||||
int size = this.size;
|
||||
int columns = clamp(FULL_WIDTH / size, 2, 3);
|
||||
|
||||
iStack[iStackSize - 2] = size;
|
||||
iStack[iStackSize - 1] = columns;
|
||||
}
|
||||
else if ("setSpellAreaSize".equals(event.getEventName()))
|
||||
{
|
||||
if (!this.dragSpells)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iStack[iStackSize - 2] = FULL_WIDTH;
|
||||
iStack[iStackSize - 1] = FULL_HEIGHT;
|
||||
}
|
||||
else if ("resizeIndividualSpells".equals(event.getEventName()))
|
||||
{
|
||||
int widget = iStack[iStackSize - 1];
|
||||
|
||||
int visibleCount = 0;
|
||||
for (Spell spell1 : spells.values())
|
||||
{
|
||||
String s = spell1.getName();
|
||||
if (isUnfiltered(s, notFilteredSpells))
|
||||
if (pook != spellbook)
|
||||
{
|
||||
visibleCount++;
|
||||
saveSpells();
|
||||
spellbook = pook;
|
||||
loadSpells();
|
||||
}
|
||||
}
|
||||
|
||||
if (visibleCount > 20 || visibleCount == 0)
|
||||
break;
|
||||
case "shouldFilterSpell":
|
||||
{
|
||||
return;
|
||||
final String spell = sStack[sStackSize - 1].toLowerCase();
|
||||
final int widget = iStack[iStackSize - 1];
|
||||
|
||||
if (!spells.containsKey(widget))
|
||||
{
|
||||
final Spell s = new Spell();
|
||||
s.setWidget(widget);
|
||||
s.setX(-1);
|
||||
s.setY(-1);
|
||||
s.setSize(0);
|
||||
s.setName(spell);
|
||||
|
||||
spells.put(widget, s);
|
||||
}
|
||||
|
||||
if (notFilteredSpells.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iStack[iStackSize - 2] = isUnfiltered(spell, notFilteredSpells) ? 1 : 0;
|
||||
break;
|
||||
}
|
||||
case "isMobileSpellbookEnabled":
|
||||
iStack[iStackSize - 1] = 1;
|
||||
break;
|
||||
case "resizeSpell":
|
||||
final int size = this.size;
|
||||
final int columns = clamp(FULL_WIDTH / size, 2, 3);
|
||||
|
||||
Spell spell = spells.get(widget);
|
||||
iStack[iStackSize - 2] = size;
|
||||
iStack[iStackSize - 1] = columns;
|
||||
break;
|
||||
case "setSpellAreaSize":
|
||||
if (!this.dragSpells)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int newSize = clamp(trueSize(spell), 0, FULL_WIDTH);
|
||||
|
||||
iStack[iStackSize - 3] = newSize;
|
||||
iStack[iStackSize - 2] = newSize;
|
||||
}
|
||||
else if ("setSpellPosition".equals(event.getEventName()))
|
||||
{
|
||||
if (!this.dragSpells)
|
||||
iStack[iStackSize - 2] = FULL_WIDTH;
|
||||
iStack[iStackSize - 1] = FULL_HEIGHT;
|
||||
break;
|
||||
case "resizeIndividualSpells":
|
||||
{
|
||||
return;
|
||||
final int widget = iStack[iStackSize - 1];
|
||||
|
||||
int visibleCount = 0;
|
||||
for (Spell spell : spells.values())
|
||||
{
|
||||
final String s = spell.getName();
|
||||
if (isUnfiltered(s, notFilteredSpells))
|
||||
{
|
||||
visibleCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (visibleCount > 20 || visibleCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Spell spell = spells.get(widget);
|
||||
final int newSize = clamp(trueSize(spell), 0, FULL_WIDTH);
|
||||
|
||||
iStack[iStackSize - 3] = newSize;
|
||||
iStack[iStackSize - 2] = newSize;
|
||||
break;
|
||||
}
|
||||
|
||||
int widget = iStack[iStackSize - 1];
|
||||
Spell s = spells.get(widget);
|
||||
int x = s.getX();
|
||||
int y = s.getY();
|
||||
|
||||
if (x == -1 || y == -1)
|
||||
case "setSpellPosition":
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!this.dragSpells)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iStack[iStackSize - 5] = x;
|
||||
iStack[iStackSize - 4] = y;
|
||||
final int widget = iStack[iStackSize - 1];
|
||||
final Spell s = spells.get(widget);
|
||||
final int x = s.getX();
|
||||
final int y = s.getY();
|
||||
|
||||
if (x == -1 || y == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iStack[iStackSize - 5] = x;
|
||||
iStack[iStackSize - 4] = y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSpells()
|
||||
{
|
||||
if (client.getGameState() != GameState.LOGGED_IN || spellbook == null)
|
||||
spells.clear();
|
||||
|
||||
if (client.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spells.clear();
|
||||
if (spellbook == null)
|
||||
{
|
||||
log.debug("Spellbook is null?");
|
||||
return;
|
||||
}
|
||||
|
||||
String cfg = configManager.getConfiguration("spellbook", spellbook.getConfigKey());
|
||||
final String cfg = configManager.getConfiguration("spellbook", spellbook.getConfigKey());
|
||||
|
||||
if (Strings.isNullOrEmpty(cfg))
|
||||
{
|
||||
@@ -478,151 +474,147 @@ public class SpellbookPlugin extends Plugin
|
||||
}
|
||||
|
||||
// CHECKSTYLE:OFF
|
||||
Collection<Spell> gson = GSON.fromJson(cfg, new TypeToken<List<Spell>>()
|
||||
final Collection<Spell> gson = GSON.fromJson(cfg, new TypeToken<List<Spell>>()
|
||||
{
|
||||
}.getType());
|
||||
}
|
||||
.getType());
|
||||
// CHECKSTYLE:ON
|
||||
gson.stream().filter(Objects::nonNull).forEach(s -> spells.put(s.getWidget(), s));
|
||||
|
||||
if (tmp != null)
|
||||
for (final Spell s : gson)
|
||||
{
|
||||
for (Map.Entry<Integer, Spell> entry : tmp.entrySet())
|
||||
{
|
||||
spells.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
spells.put(s.getWidget(), s);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveSpells()
|
||||
{
|
||||
if (spells.isEmpty() || tmp == null || tmp.isEmpty())
|
||||
if (spells.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, Spell> entry : tmp.entrySet())
|
||||
{
|
||||
spells.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
String key = spellbook.getConfigKey();
|
||||
|
||||
configManager.setConfiguration("spellbook", key, GSON.toJson(spells.values()));
|
||||
configManager.setConfiguration("spellbook", spellbook.getConfigKey(), GSON.toJson(spells.values()));
|
||||
}
|
||||
|
||||
private void runRebuild()
|
||||
{
|
||||
if (client.getGameState() != GameState.LOGGED_IN)
|
||||
if (client.getGameState() != GameState.LOGGED_IN || !mageTabOpen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Runs magic_spellbook_rebuild
|
||||
// The magic numbers probably are mobile specific widgetids
|
||||
// runeliteplus mobile when?
|
||||
clientThread.invoke(() ->
|
||||
client.runScript(2611, 14286851, 14287027, 14287036, 14286849, 14287033, 14287034, 14287035, 14286850, 14287029, 14287032, "Info", "Filters", false)
|
||||
client.runScript(
|
||||
MAGIC_SPELLBOOK_REDRAW,
|
||||
SPELLBOOK_FILTERED_BOUNDS.getId(),
|
||||
0x00da00b3,
|
||||
SPELL_TOOLTIP.getId(),
|
||||
SPELLBOOK_FILTERED_SPELLS_PARENT.getId(),
|
||||
SPELLBOOK_FILTER_BUTTON_PARENT.getId(),
|
||||
0x00da00ba,
|
||||
SPELLBOOK_FILTER_BUTTON.getId(),
|
||||
0x00da0002,
|
||||
SPELLBOOK_FILTER_SECTION_PARENT.getId(),
|
||||
SPELLBOOK_FILTER_BUTTONS_PARENT.getId(),
|
||||
"Info",
|
||||
"Filters",
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
boolean isNotOnSpellWidget(java.awt.Point point)
|
||||
boolean isNotOnSpellWidget()
|
||||
{
|
||||
Widget boundsWidget = client.getWidget(WidgetInfo.SPELLBOOK_FILTERED_BOUNDS);
|
||||
if (client.getVar(VarClientInt.INVENTORY_TAB) != 6
|
||||
|| client.isMenuOpen()
|
||||
|| boundsWidget == null
|
||||
|| !boundsWidget.getBounds().contains(point))
|
||||
if (client.isMenuOpen() || !mageTabOpen)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return currentWidget(point) == null;
|
||||
return currentWidget() == null;
|
||||
}
|
||||
|
||||
private void loadFilter()
|
||||
private Widget currentWidget()
|
||||
{
|
||||
notFilteredSpells = ImmutableSet.copyOf(Text.fromCSV(this.filter.toLowerCase()));
|
||||
final Widget parent = client.getWidget(SPELLBOOK_FILTERED_BOUNDS);
|
||||
if (parent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for (final Widget w : parent.getStaticChildren())
|
||||
{
|
||||
if (w.containsMouse())
|
||||
{
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void startDragging(java.awt.Point point)
|
||||
void startDragging(final java.awt.Point point)
|
||||
{
|
||||
draggingWidget = currentWidget(point);
|
||||
draggingWidget = currentWidget();
|
||||
|
||||
if (draggingWidget == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Point widgetPos = draggingWidget.getCanvasLocation();
|
||||
final Point widgetPos = draggingWidget.getCanvasLocation();
|
||||
|
||||
int x = point.x - widgetPos.getX();
|
||||
int y = point.y - widgetPos.getY();
|
||||
final int x = point.x - widgetPos.getX();
|
||||
final int y = point.y - widgetPos.getY();
|
||||
|
||||
draggingLocation = new Point(x, y);
|
||||
draggingWidget.setHidden(true);
|
||||
dragging = true;
|
||||
}
|
||||
|
||||
void completeDragging(java.awt.Point point)
|
||||
void completeDragging(final java.awt.Point point)
|
||||
{
|
||||
Point parentPos = client.getWidget(WidgetInfo.SPELLBOOK_FILTERED_BOUNDS).getCanvasLocation();
|
||||
final Point parentPos = client.getWidget(SPELLBOOK_FILTERED_BOUNDS).getCanvasLocation();
|
||||
|
||||
int x = point.x - draggingLocation.getX() - parentPos.getX();
|
||||
int y = point.y - draggingLocation.getY() - parentPos.getY();
|
||||
int size = draggingWidget.getWidth();
|
||||
final int size = draggingWidget.getWidth();
|
||||
|
||||
x = clamp(x, 0, FULL_WIDTH - size);
|
||||
y = clamp(y, 0, FULL_HEIGHT - size);
|
||||
|
||||
int draggedID = draggingWidget.getId();
|
||||
Spell n = spells.get(draggedID);
|
||||
final int draggedID = draggingWidget.getId();
|
||||
final Spell n = spells.get(draggedID);
|
||||
|
||||
n.setX(x);
|
||||
n.setY(y);
|
||||
|
||||
tmp.put(draggedID, n);
|
||||
|
||||
draggingWidget.setHidden(false);
|
||||
dragging = false;
|
||||
|
||||
runRebuild();
|
||||
}
|
||||
|
||||
private Widget currentWidget(java.awt.Point point)
|
||||
void increaseSize()
|
||||
{
|
||||
ImmutableSet<String> tmp = ImmutableSet.copyOf(notFilteredSpells);
|
||||
|
||||
for (Map.Entry<Integer, Spell> spell : spells.entrySet())
|
||||
{
|
||||
Widget w = client.getWidget(WidgetInfo.TO_GROUP(spell.getKey()), WidgetInfo.TO_CHILD(spell.getKey())); // y tho let me just plop in id
|
||||
|
||||
if (w == null || !w.getBounds().contains(point) || !isUnfiltered(spell.getValue().getName(), tmp))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void increaseSize(java.awt.Point point)
|
||||
{
|
||||
Widget scrolledWidget = currentWidget(point);
|
||||
final Widget scrolledWidget = currentWidget();
|
||||
|
||||
if (scrolledWidget == null || dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int scrolledWidgetId = scrolledWidget.getId();
|
||||
final int scrolledWidgetId = scrolledWidget.getId();
|
||||
final Spell scrolledSpell = spells.get(scrolledWidgetId);
|
||||
|
||||
if (!spells.containsKey(scrolledWidgetId))
|
||||
if (scrolledSpell.getX() == -1 || scrolledSpell.getY() == -1)
|
||||
{
|
||||
return;
|
||||
scrolledSpell.setX(scrolledWidget.getRelativeX());
|
||||
scrolledSpell.setY(scrolledWidget.getRelativeY());
|
||||
}
|
||||
|
||||
Spell scrolledSpell = spells.get(scrolledWidgetId);
|
||||
|
||||
if (trueSize(scrolledSpell) > FULL_WIDTH - 2)
|
||||
{
|
||||
scrolledSpell.setX(0);
|
||||
@@ -635,63 +627,20 @@ public class SpellbookPlugin extends Plugin
|
||||
scrolledSpell.setX(clamp(scrolledSpell.getX() - 1, 0, FULL_WIDTH - trueSize(scrolledSpell)));
|
||||
scrolledSpell.setY(clamp(scrolledSpell.getY() - 1, 0, FULL_HEIGHT - trueSize(scrolledSpell)));
|
||||
|
||||
tmp.put(scrolledWidgetId, scrolledSpell);
|
||||
|
||||
runRebuild();
|
||||
}
|
||||
|
||||
void resetZoom(java.awt.Point point)
|
||||
void decreaseSize()
|
||||
{
|
||||
Widget clickedWidget = currentWidget(point);
|
||||
|
||||
if (clickedWidget == null || dragging || !this.scroll)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int clickedWidgetId = clickedWidget.getId();
|
||||
|
||||
if (!spells.containsKey(clickedWidgetId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Spell clickedSpell = spells.get(clickedWidgetId);
|
||||
|
||||
int oldSize = clickedSpell.getSize();
|
||||
int tmpSize = tmp.get(clickedWidgetId).getSize();
|
||||
|
||||
if (tmpSize == 0 && oldSize == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
clickedSpell.setX(clickedSpell.getX() + oldSize);
|
||||
clickedSpell.setY(clickedSpell.getY() + oldSize);
|
||||
clickedSpell.setSize(0);
|
||||
|
||||
tmp.put(clickedWidgetId, clickedSpell);
|
||||
|
||||
runRebuild();
|
||||
}
|
||||
|
||||
void decreaseSize(java.awt.Point point)
|
||||
{
|
||||
Widget scrolledWidget = currentWidget(point);
|
||||
final Widget scrolledWidget = currentWidget();
|
||||
|
||||
if (scrolledWidget == null || dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int scrolledWidgetId = scrolledWidget.getId();
|
||||
|
||||
if (!spells.containsKey(scrolledWidgetId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Spell scrolledSpell = spells.get(scrolledWidgetId);
|
||||
final int scrolledWidgetId = scrolledWidget.getId();
|
||||
final Spell scrolledSpell = spells.get(scrolledWidgetId);
|
||||
|
||||
// People probably don't want to scroll on a single pixel
|
||||
if (trueSize(scrolledSpell) <= 5)
|
||||
@@ -700,33 +649,110 @@ public class SpellbookPlugin extends Plugin
|
||||
}
|
||||
|
||||
scrolledSpell.setSize(scrolledSpell.getSize() - 1);
|
||||
|
||||
if (scrolledSpell.getX() == -1 || scrolledSpell.getY() == -1)
|
||||
{
|
||||
scrolledSpell.setX(scrolledWidget.getRelativeX());
|
||||
scrolledSpell.setY(scrolledWidget.getRelativeY());
|
||||
}
|
||||
|
||||
scrolledSpell.setX(scrolledSpell.getX() + 1);
|
||||
scrolledSpell.setY(scrolledSpell.getY() + 1);
|
||||
|
||||
tmp.put(scrolledWidgetId, scrolledSpell);
|
||||
|
||||
runRebuild();
|
||||
}
|
||||
|
||||
private int trueSize(Spell s)
|
||||
void resetSize()
|
||||
{
|
||||
final Widget clickedWidget = currentWidget();
|
||||
|
||||
if (clickedWidget == null || dragging || !this.scroll)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int clickedWidgetId = clickedWidget.getId();
|
||||
final Spell clickedSpell = spells.get(clickedWidgetId);
|
||||
|
||||
final int oldSize = clickedSpell.getSize();
|
||||
|
||||
if (oldSize == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (clickedSpell.getX() == -1 || clickedSpell.getY() == -1)
|
||||
{
|
||||
clickedSpell.setX(clickedWidget.getRelativeX());
|
||||
clickedSpell.setY(clickedWidget.getRelativeY());
|
||||
}
|
||||
|
||||
clickedSpell.setX(clickedSpell.getX() + oldSize);
|
||||
clickedSpell.setY(clickedSpell.getY() + oldSize);
|
||||
|
||||
clickedSpell.setSize(0);
|
||||
|
||||
runRebuild();
|
||||
}
|
||||
|
||||
// I know this still opens menu but else you
|
||||
// wouldn't be able to get out of the spellbook
|
||||
// mode thing lol
|
||||
void resetLocation()
|
||||
{
|
||||
final Widget clickedWidget = currentWidget();
|
||||
|
||||
if (clickedWidget == null || dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int clickedWidgetId = clickedWidget.getId();
|
||||
final Spell clickedSpell = spells.get(clickedWidgetId);
|
||||
|
||||
clickedSpell.setX(-1);
|
||||
clickedSpell.setY(-1);
|
||||
|
||||
runRebuild();
|
||||
}
|
||||
|
||||
private int trueSize(final Spell s)
|
||||
{
|
||||
return s.getSize() * 2 + this.size;
|
||||
}
|
||||
|
||||
private void updateConfig()
|
||||
private static boolean isUnfiltered(final String spell, final Set<String> unfiltereds)
|
||||
{
|
||||
this.enableMobile = config.enableMobile();
|
||||
this.dragSpells = config.dragSpells();
|
||||
this.scroll = config.scroll();
|
||||
this.size = config.size();
|
||||
this.filter = config.filter();
|
||||
}
|
||||
for (final String str : unfiltereds)
|
||||
{
|
||||
boolean b;
|
||||
|
||||
private enum WordFilterMode
|
||||
{
|
||||
CONTAINS,
|
||||
EQUALS,
|
||||
STARTSWITH,
|
||||
ENDSWITH
|
||||
if (str.charAt(0) == '\"')
|
||||
{
|
||||
if (str.charAt(str.length() - 1) == '\"')
|
||||
{
|
||||
b = spell.equalsIgnoreCase(str.substring(1, str.length() - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
b = StringUtils.startsWithIgnoreCase(spell, str.substring(1));
|
||||
}
|
||||
}
|
||||
else if (str.charAt(str.length() - 1) == '\"')
|
||||
{
|
||||
b = StringUtils.endsWithIgnoreCase(spell, StringUtils.chop(str));
|
||||
}
|
||||
else
|
||||
{
|
||||
b = StringUtils.containsIgnoreCase(spell, str);
|
||||
}
|
||||
|
||||
if (b)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import net.runelite.api.VarClientInt;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldArea;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.vars.InterfaceTab;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
|
||||
|
||||
@@ -349,7 +350,7 @@ public class OverlayUtil
|
||||
{
|
||||
Widget widget = client.getWidget(prayer.getWidgetInfo());
|
||||
|
||||
if (widget == null || client.getVar(VarClientInt.PLAYER_INTERFACE_CONTAINER_OPENED) != 5)
|
||||
if (widget == null || client.getVar(VarClientInt.INTERFACE_TAB) != InterfaceTab.PRAYER.getId())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user