From 04df6cd1e97ee86d0a38878cc94f94c9619d0813 Mon Sep 17 00:00:00 2001 From: Kyleeld <48519776+Kyleeld@users.noreply.github.com> Date: Thu, 25 Apr 2019 23:36:59 +0100 Subject: [PATCH] Add files via upload --- .../spellbookiconresizeConfig.java | 101 ++++++ .../spellbookiconresizePlugin.java | 328 ++++++++++++++++++ 2 files changed, 429 insertions(+) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/spellbookiconresize/spellbookiconresizeConfig.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/spellbookiconresize/spellbookiconresizePlugin.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbookiconresize/spellbookiconresizeConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbookiconresize/spellbookiconresizeConfig.java new file mode 100644 index 0000000000..568339c64d --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spellbookiconresize/spellbookiconresizeConfig.java @@ -0,0 +1,101 @@ +package net.runelite.client.plugins.spellbookiconresize; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("spellbookfixer") +public interface spellbookiconresizeConfig extends Config +{ + @ConfigItem(position = 0, keyName = "shouldHideOthers", name = "Hide Others", description = "Toggle on to hide spells not useful for pking that cannot be filtered otherwise.") + default boolean shouldHideOthers() + { + return true; + } + + //ice blitz + @ConfigItem(position = 1, keyName = "shouldModifyBloodBarrage", name = "Blood Barrage", description = "Toggle on to Blood Barrage modifications.") + default boolean shouldModifyBloodBarrage() { return true; } + @ConfigItem(position = 2, keyName = "getBloodPositionX", name = "Blood Barrage Pos X", description = "Modifies the X-axis position of Blood Barrage.") + default int getBloodPositionX() + { + return 0; + } + @ConfigItem(position = 3, keyName = "getBloodPositionY", name = "Blood Barrage Pos Y", description = "Modifies the Y-axis position of Blood Barrage.") + default int getBloodPositionY() + { + return 0; + } + @ConfigItem(position = 4, keyName = "getBloodSize", name = "Blood Barrage Size", description = "Modifies the width of Blood Barrage.") + default int getBloodSize() { return 100; } + @ConfigItem(position = 6, keyName = "shouldHideBloodBarrage", name = "Hide Blood Barrage", description = "Enable this to hide blood barrage") + default boolean shouldHideBloodBarrage() + { + return false; + } + //ice barrage + @ConfigItem(position = 7, keyName = "shouldModifyIceBarrage", name = "Ice Barrage", description = "Toggle on to enable Ice Barrage modifications.") + default boolean shouldModifyIceBarrage() { return true; } + @ConfigItem(position = 8, keyName = "getBarragePositionX", name = "Ice Barrage Pos X", description = "Modifies the X-axis position of Ice Barrage.") + default int getBarragePositionX() + { + return 0; + } + @ConfigItem(position = 9, keyName = "getBarragePositionY", name = "Ice Barrage Pos y", description = "Modifies the X-axis position of Ice Barrage.") + default int getBarragePositionY() + { + return 75; + } + @ConfigItem(position = 10, keyName = "getBarrageSize", name = "Ice Barrage Size", description = "Modifies the width position of Ice Barrage.") + default int getBarrageSize() + { + return 100; + } + @ConfigItem(position = 12, keyName = "shouldHideIceBarrage", name = "Hide Ice Barrage", description = "Enable this to hide Ice barrage") + default boolean shouldHideIceBarrage() + { + return false; + } + + @ConfigItem(position = 13, keyName = "shouldModifyIceBlitz", name = "Ice Blitz", description = "Toggle on to enable Ice Blitz modifications.") + default boolean shouldModifyIceBlitz() { return true; } + @ConfigItem(position = 14, keyName = "getBlitzPositionX", name = "Ice Blitz Pos X", description = "Modifies the X-axis position of Ice Blitz.") + default int getBlitzPositionX() { return 0; } + @ConfigItem(position = 15, keyName = "getBlitzPositionY", name = "Ice Blitz Pos y", description = "Modifies the X-axis position of Ice Blitz.") + default int getBlitzPositionY() + { + return 0; + } + @ConfigItem(position = 16, keyName = "getBlitzeSize", name = "Ice Blitz Size", description = "Modifies the width position of Ice Blitz.") + default int getBlitzSize() + { + return 100; + } + @ConfigItem(position = 17, keyName = "shouldHideIceBlitz", name = "Hide Ice Blitz", description = "Enable this to hide Ice blitz") + default boolean shouldHideIceBlitz() + { + return false; + } + + @ConfigItem(position = 18, keyName = "shouldModifyBloodBlitz", name = "Blood Blitz", description = "Toggle on to enable Ice Blitz modifications.") + default boolean shouldModifyBloodBlitz() { return true; } + @ConfigItem(position = 19, keyName = "getBloodBlitzPositionX", name = "Blood Blitz Pos X", description = "Modifies the X-axis position of Blood Blitz.") + default int getBloodBlitzPositionX() { return 0; } + @ConfigItem(position = 20, keyName = "getBloodBlitzPositionY", name = "Blood Blitz Pos y", description = "Modifies the X-axis position of Blood Blitz.") + default int getBloodBlitzPositionY() + { + return 0; + } + @ConfigItem(position = 21, keyName = "getBloodBlitzSize", name = "Blood Blitz Size", description = "Modifies the width position of Blood Blitz.") + default int getBloodBlitzSize() + { + return 100; + } + @ConfigItem(position = 22, keyName = "shouldHideBLoodBlitz", name = "Hide Blood Blitz", description = "Enable this to hide Blood blitz") + default boolean shouldHideBloodBlitz() + { + return false; + } + + +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbookiconresize/spellbookiconresizePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbookiconresize/spellbookiconresizePlugin.java new file mode 100644 index 0000000000..6dfc9d1421 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spellbookiconresize/spellbookiconresizePlugin.java @@ -0,0 +1,328 @@ +package net.runelite.client.plugins.spellbookiconresize; + +import com.google.inject.Provides; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; +import net.runelite.api.GameState; +import net.runelite.api.Varbits; +import net.runelite.api.events.*; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetID; +import net.runelite.api.widgets.WidgetInfo; +import net.runelite.client.callback.ClientThread; +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.plugins.PluginType; +import javax.inject.Inject; + + +@PluginDescriptor( + name = "Spellbook IconResizer", + description = "Resize and filter spellbook for PKing", + tags = {"resize", "spellbook", "magic", "spell", "pk", "book", "filter"}, + type = PluginType.PVP +) +@Slf4j +public class spellbookiconresizePlugin extends Plugin { + public int spellbookID = -1; + //0 = standard + //1 = ancients + //2 = lunars + //3 = arrceus + @Inject + private Client client; + @Inject + private ClientThread clientThread; + @Inject + spellbookiconresizeConfig config; + + @Provides + spellbookiconresizeConfig provideConfig(ConfigManager configManager) { + return configManager.getConfig(spellbookiconresizeConfig.class); + } + + @Override + protected void startUp() throws Exception { + if(client.getGameState()!= GameState.LOGGED_IN){ + return; + } + + clientThread.invoke(()->{ + spellbookID = client.getVar(Varbits.SPELLBOOK_ID); + }); + + adjustSpellbook(); + } + + @Override + protected void shutDown() throws Exception { + resetSpellbook(); + } + + @Subscribe + public void onGameStateChanged(GameStateChanged event) { + if (event.getGameState() == GameState.LOGGED_IN) { + spellbookID = client.getVar(Varbits.SPELLBOOK_ID); + adjustSpellbook(); + } + } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("spellbookfixer")) + { + adjustSpellbook(); + } + } + @Subscribe + public void onWidgetLoaded(WidgetLoaded event) { + if (client.getGameState() == GameState.LOGGED_IN) { + if (event.getGroupId() == WidgetID.SPELLBOOK_GROUP_ID) + { + spellbookID = client.getVar(Varbits.SPELLBOOK_ID ); + adjustSpellbook(); + } + + } + } + + @Subscribe + public void onWidgetHiddenChanged(WidgetHiddenChanged event) { + if (client.getGameState() == GameState.LOGGED_IN) { + spellbookID = client.getVar(Varbits.SPELLBOOK_ID ); + adjustSpellbook(); + } + } + + @Subscribe + public void onVarbitChanged(VarbitChanged event) { + int oldid = spellbookID; + spellbookID = client.getVar(Varbits.SPELLBOOK_ID); + if (oldid != spellbookID) { + adjustSpellbook(); + } + } + + private void adjustSpellbook() { + clientThread.invoke(()-> { + if (client.getGameState() != GameState.LOGGED_IN) { + return; + } + try { + if (spellbookID == 1) { + if (config.shouldModifyIceBarrage()) { + modifySpell(WidgetInfo.SPELL_ICE_BARRAGE, config.getBarragePositionX()-20, config.getBarragePositionY(), config.getBarrageSize()); + } else { + if (client.getVar(Varbits.SPELLBOOK_HIDDEN) == 1) { + modifySpell(WidgetInfo.SPELL_ICE_BARRAGE, 0, 168, 24); + } else if (client.getVar(Varbits.SPELLBOOK_HIDDEN) == 0) { + modifySpell(WidgetInfo.SPELL_ICE_BARRAGE, 0, 216, 24); + } + } + if (config.shouldModifyBloodBarrage()) { + modifySpell(WidgetInfo.SPELL_BLOOD_BARRAGE, config.getBloodPositionX()-20, config.getBloodPositionY(), config.getBloodSize()); + } else { + if (client.getVar(Varbits.SPELLBOOK_HIDDEN) == 1) { + modifySpell(WidgetInfo.SPELL_BLOOD_BARRAGE, 132, 140, 24); + } else { + modifySpell(WidgetInfo.SPELL_BLOOD_BARRAGE, 144, 180, 24); + } + } + + if (config.shouldModifyIceBlitz()) { + modifySpell(WidgetInfo.SPELL_ICE_BLITZ, config.getBlitzPositionX()-20, config.getBlitzPositionY(), config.getBlitzSize()); + } else { + if (client.getVar(Varbits.SPELLBOOK_HIDDEN) == 1) { + modifySpell(WidgetInfo.SPELL_ICE_BLITZ, 44, 112, 24); + } else { + modifySpell(WidgetInfo.SPELL_ICE_BLITZ, 48, 144, 24); + } + } + + if (config.shouldModifyBloodBlitz()) { + modifySpell(WidgetInfo.SPELL_BLOOD_BLITZ, config.getBloodBlitzPositionX()-20, config.getBloodBlitzPositionY(), config.getBloodBlitzSize()); + } else { + if (client.getVar(Varbits.SPELLBOOK_HIDDEN) == 1) { + modifySpell(WidgetInfo.SPELL_BLOOD_BLITZ, 0, 112, 24); + } else { + modifySpell(WidgetInfo.SPELL_BLOOD_BLITZ, 0, 144, 24); + } + } + + setSpellHidden(WidgetInfo.SPELL_BLOOD_BARRAGE, config.shouldHideBloodBarrage()); + setSpellHidden(WidgetInfo.SPELL_ICE_BARRAGE, config.shouldHideIceBarrage()); + setSpellHidden(WidgetInfo.SPELL_ICE_BLITZ, config.shouldHideIceBlitz()); + setSpellHidden(WidgetInfo.SPELL_BLOOD_BLITZ, config.shouldHideBloodBlitz()); + setSpellHidden(WidgetInfo.SPELL_ICE_BURST, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_ICE_RUSH, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_BLOOD_RUSH, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_BLOOD_BURST, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_SMOKE_RUSH, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_SMOKE_BLITZ, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_SMOKE_BURST, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_SMOKE_BARRAGE, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_SHADOW_RUSH, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_SHADOW_BLITZ, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_SHADOW_BURST, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_SHADOW_BARRAGE, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_BOUNTY_TARGET_TELEPORT, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_PADDEWWA_TELEPORT, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_SENNTISTEN_TELEPORT, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_KHARYRLL_TELEPORT, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_LASSAR_TELEPORT, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_DAREEYAK_TELEPORT, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_CARRALLANGER_TELEPORT, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_ANNAKARL_TELEPORT, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_GHORROCK_TELEPORT, config.shouldHideOthers()); + setSpellHidden(WidgetInfo.SPELL_EDGEVILLE_HOME_TELEPORT, config.shouldHideOthers()); + + + } + // if (spellbookID == 2) { + // if (config.shouldModifyVengeance()) + /// modifySpell(WidgetInfo.SPELL_VENGEANCE, config.getVengeancePositionX(), config.getVengeancePositionY(), config.getVengeanceSize()); + // } + // if (spellbookID == 0) { + + // if (config.shouldModifyTeleBlock()) + // modifySpell(WidgetInfo.SPELL_TELE_BLOCK, config.getTeleBlockPositionX(), config.getTeleBlockPositionY(), config.getTeleBlockSize()); +// + // if (config.shouldModifyEntangle()) + // modifySpell(WidgetInfo.SPELL_ENTANGLE, config.getEntanglePositionX(), config.getEntanglePositionY(), config.getEntangleSize()); + // } + + + } catch (Exception e) { + //swallow + } + + }); + } + + + private void resetSpellbook() { + clientThread.invoke(()-> { + if (client.getGameState() != GameState.LOGGED_IN) + return; + + try { + if (spellbookID == 1) { + + if (client.getVar(Varbits.SPELLBOOK_HIDDEN) == 1) { + modifySpell(WidgetInfo.SPELL_ICE_BARRAGE, 0, 168, 24); + } else { + modifySpell(WidgetInfo.SPELL_ICE_BARRAGE, 0, 216, 24); + } + + if (client.getVar(Varbits.SPELLBOOK_HIDDEN) == 1) { + modifySpell(WidgetInfo.SPELL_BLOOD_BARRAGE, 132, 140, 24); + } else { + modifySpell(WidgetInfo.SPELL_BLOOD_BARRAGE, 144, 180, 24); + } + + if (client.getVar(Varbits.SPELLBOOK_HIDDEN) == 1) { + modifySpell(WidgetInfo.SPELL_ICE_BLITZ, 44, 112, 24); + } else { + modifySpell(WidgetInfo.SPELL_ICE_BLITZ, 48, 144, 24); + } + + if (client.getVar(Varbits.SPELLBOOK_HIDDEN) == 1) { + modifySpell(WidgetInfo.SPELL_BLOOD_BLITZ, 0, 112, 24); + } else { + modifySpell(WidgetInfo.SPELL_BLOOD_BLITZ, 0, 144, 24); + } + + if (config.shouldHideBloodBarrage()) { + setSpellHidden(WidgetInfo.SPELL_BLOOD_BARRAGE, false); + } + if (config.shouldHideIceBarrage()) { + setSpellHidden(WidgetInfo.SPELL_ICE_BARRAGE, false); + } + if (config.shouldHideIceBlitz()) { + setSpellHidden(WidgetInfo.SPELL_ICE_BLITZ, false); + } + if (config.shouldHideBloodBlitz()) { + setSpellHidden(WidgetInfo.SPELL_BLOOD_BLITZ, false); + } + setSpellHidden(WidgetInfo.SPELL_ICE_BURST, false); + setSpellHidden(WidgetInfo.SPELL_ICE_BURST, false); + setSpellHidden(WidgetInfo.SPELL_ICE_RUSH, false); + setSpellHidden(WidgetInfo.SPELL_BLOOD_RUSH, false); + setSpellHidden(WidgetInfo.SPELL_BLOOD_BLITZ, false); + setSpellHidden(WidgetInfo.SPELL_BLOOD_BURST, false); + setSpellHidden(WidgetInfo.SPELL_SMOKE_RUSH, false); + setSpellHidden(WidgetInfo.SPELL_SMOKE_BLITZ, false); + setSpellHidden(WidgetInfo.SPELL_SMOKE_BURST, false); + setSpellHidden(WidgetInfo.SPELL_SMOKE_BARRAGE, false); + setSpellHidden(WidgetInfo.SPELL_SHADOW_RUSH, false); + setSpellHidden(WidgetInfo.SPELL_SHADOW_BLITZ, false); + setSpellHidden(WidgetInfo.SPELL_SHADOW_BURST, false); + setSpellHidden(WidgetInfo.SPELL_SHADOW_BARRAGE, false); + setSpellHidden(WidgetInfo.SPELL_BOUNTY_TARGET_TELEPORT, false); + setSpellHidden(WidgetInfo.SPELL_PADDEWWA_TELEPORT, false); + setSpellHidden(WidgetInfo.SPELL_SENNTISTEN_TELEPORT, false); + setSpellHidden(WidgetInfo.SPELL_KHARYRLL_TELEPORT, false); + setSpellHidden(WidgetInfo.SPELL_LASSAR_TELEPORT, false); + setSpellHidden(WidgetInfo.SPELL_DAREEYAK_TELEPORT, false); + setSpellHidden(WidgetInfo.SPELL_CARRALLANGER_TELEPORT, false); + setSpellHidden(WidgetInfo.SPELL_ANNAKARL_TELEPORT, false); + setSpellHidden(WidgetInfo.SPELL_GHORROCK_TELEPORT, false); + setSpellHidden(WidgetInfo.SPELL_EDGEVILLE_HOME_TELEPORT, false); + } + } catch (Exception e) { + //swallow + } + }); + } + + private void modifySpell(WidgetInfo widgetInfo, int x, int y, int size) { + Widget widget = client.getWidget(widgetInfo); + + if (widget == null) + return; + + try { + boolean update = false; + //if (widget.getSpriteId() != icon) { + + //update = true; + // } + if (widget.getOriginalX() != x) { + widget.setOriginalX(x); + + update = true; + } + if (widget.getOriginalY() != y) { + widget.setOriginalY(y); + update = true; + } + //if (widget.getOriginalWidth() != size) { + widget.setOriginalWidth(size); + // update = true; + // } + //if (widget.getOriginalHeight() != size) { + widget.setOriginalHeight(size); + // update = true; + // } + //if (update) { + widget.revalidate(); + clientThread.invoke(widget::revalidate); + //} + } catch (Exception e) { + //swallow + } + + } + + private void setSpellHidden(WidgetInfo widgetInfo, boolean hidden) { + Widget widget = client.getWidget(widgetInfo); + + if (widget == null) + return; + + widget.setHidden(hidden); + } + +} \ No newline at end of file