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:
Lucwousin
2019-08-22 22:54:17 +02:00
committed by Ganom
parent 6e5bebe734
commit b57a682ce7
24 changed files with 605 additions and 459 deletions

View File

@@ -26,6 +26,18 @@ package net.runelite.api;
public final class ScriptID
{
/**
* Handles zoom input
*
* Updates the VarClientInts (73, 74) to this same value
* <ul>
* <li> int Reset zoom position </li>
* <li> int Reset zoom position </li>
* </ul>
*/
@ScriptArguments(integer = 2)
public static final int CAMERA_DO_ZOOM = 42;
/**
* Updates the scrollbar handle and container to the new height of the content container
* <ul>
@@ -47,12 +59,6 @@ public final class ScriptID
@ScriptArguments(integer = 1, string = 1)
public static final int CHATBOX_INPUT = 96;
/**
* Rebuilds the chatbox
*/
@ScriptArguments()
public static final int BUILD_CHATBOX = 216;
/**
* Opens the Private Message chat interface
*
@@ -64,6 +70,12 @@ public final class ScriptID
@ScriptArguments(string = 1)
public static final int OPEN_PRIVATE_MESSAGE_INTERFACE = 107;
/**
* Rebuilds the chatbox
*/
@ScriptArguments()
public static final int BUILD_CHATBOX = 216;
/**
* Rebuilds the text input widget inside the chat interface
* <ul>
@@ -73,6 +85,12 @@ public final class ScriptID
@ScriptArguments(string = 1)
public static final int CHAT_TEXT_INPUT_REBUILD = 222;
/**
* Builds the chatbox input widget
*/
@ScriptArguments()
public static final int CHAT_PROMPT_INIT = 223;
/**
* Closes the chatbox input
* <ul>
@@ -94,21 +112,10 @@ public final class ScriptID
public static final int MESSAGE_LAYER_OPEN = 677;
/**
* Builds the chatbox input widget
* Clicking bank pin buttons runs this
*/
@ScriptArguments()
public static final int CHAT_PROMPT_INIT = 223;
/**
* Displays the game messages when clicking on an item inside the Items Kept on Death interface
* <ul>
* <li> int (boolean) Item kept on death </li>
* <li> int Item Quantity </li>
* <li> String Item Name </li>
* </ul>
*/
@ScriptArguments(integer = 2, string = 1)
public static final int DEATH_KEEP_ITEM_EXAMINE = 1603;
@ScriptArguments(integer = 20)
public static final int BANK_PIN_OP = 685;
/**
* Checks the state of the given stash unit.
@@ -123,10 +130,31 @@ public final class ScriptID
*/
@ScriptArguments(integer = 4)
public static final int WATSON_STASH_UNIT_CHECK = 1479;
/**
* Displays the game messages when clicking on an item inside the Items Kept on Death interface
* <ul>
* <li> int (boolean) Item kept on death </li>
* <li> int Item Quantity </li>
* <li> String Item Name </li>
* </ul>
*/
@ScriptArguments(integer = 2, string = 1)
public static final int DEATH_KEEP_ITEM_EXAMINE = 1603;
/**
* Queries the completion state of a quest by its struct id
* Creates a disabled experience drop
*
* <ul>
* <li>int (Skill ordinal) Sets what icon to use</li>
* <li>int Amount of exp to drop</li>
* </ul>
*/
@ScriptArguments(integer = 2)
public static final int XPDROP_DISABLED = 2091;
/**
* <ul>
* Queries the completion state of a quest by its struct id
* <li> int (struct) The id of the quest
* </ul>
* Returns
@@ -148,16 +176,10 @@ public final class ScriptID
public static final int DIARY_QUEST_UPDATE_LINECOUNT = 2523;
/**
* Handles zoom input
*
* Updates the VarClientInts (73, 74) to this same value
* <ul>
* <li> int Reset zoom position </li>
* <li> int Reset zoom position </li>
* </ul>
* Rebuilds the Spellbook
*/
@ScriptArguments(integer = 2)
public static final int CAMERA_DO_ZOOM = 42;
@ScriptArguments(integer = 10, string = 2)
public static final int MAGIC_SPELLBOOK_REDRAW = 2611;
/**
* Does nothing
@@ -174,17 +196,6 @@ public final class ScriptID
@ScriptArguments(string = 2)
public static final int PRIVMSG = 10004;
/**
* Creates a disabled experience drop
*
* <ul>
* <li>int (Skill ordinal) Sets what icon to use</li>
* <li>int Amount of exp to drop</li>
* </ul>
*/
@ScriptArguments(integer = 2)
public static final int XPDROP_DISABLED = 2091;
/**
* Join a clan, duh
*/
@@ -196,10 +207,5 @@ public final class ScriptID
*/
@ScriptArguments(string = 1)
public static final int PUBLICMSG = 13337;
/**
* Clicking bank pin buttons runs this
*/
@ScriptArguments(integer = 20)
public static final int BANK_PIN_OP = 685;
}

View File

@@ -51,24 +51,10 @@ public enum VarClientInt
MEMBERSHIP_STATUS(103),
/**
* 0 = Combat
* 1 = Stats
* 2 = Quest
* 3 = Inventory
* 4 = Equipment
* 5 = Prayer
* 6 = Spellbook
* 7 = Clan
* 8 = Account Managment
* 9 = Friends
* 10 = Logout
* 11 = Options
* 12 = Emotes
* 13 = Music
* The currently open interface tab
* @see net.runelite.api.vars.InterfaceTab
*/
PLAYER_INTERFACE_CONTAINER_OPENED(171),
INVENTORY_TAB(171),
INTERFACE_TAB(171),
WORLD_MAP_SEARCH_FOCUSED(190);

View File

@@ -498,13 +498,7 @@ public enum Varbits
* 2 = lunars
* 3 = arrceus
**/
SPELLBOOK_ID(4070),
/**
* 0 = no
* 1 = yes
**/
SPELLBOOK_HIDDEN(6718),
SPELLBOOK(4070),
/**
* Amount of items in each bank tab
@@ -647,11 +641,6 @@ public enum Varbits
//TODO
QUEST_IN_SEARCH_OF_KNOWLEDGE(6067),
/**
* Active spellbook (see enumID)
*/
SPELLBOOK(4070),
/**
* Spellbook filtering (1 = unfiltered, 0 = filtered)
*/

View File

@@ -9,7 +9,7 @@ public interface WidgetNode extends Node
* The ID of the widget.
*
* @return the ID of the widget
* @see api.widgets.Widget
* @see net.runelite.api.widgets.Widget
*/
int getId();
}

View File

@@ -28,7 +28,7 @@ package net.runelite.api.events;
import lombok.Value;
/**
* An event where a varbit integer has changed.
* An event where a client int var has changed.
*/
@Value
public class VarClientIntChanged implements Event

View File

@@ -28,7 +28,7 @@ package net.runelite.api.events;
import lombok.Value;
/**
* An event where a varbit string has changed.
* An event where a client var string has changed.
*/
@Value
public class VarClientStrChanged implements Event

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 2019, Lucas <https://github.com/Lucwousin>
* 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.api.vars;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum InterfaceTab
{
COMBAT(0),
STATS(1),
QUEST(2),
INVENTORY(3),
EQUIPMENT(4),
PRAYER(5),
SPELLBOOK(6),
CLAN(7),
ACCOUNT_MANAGMENT(8),
FRIENDS(9),
LOGOUT(10),
OPTIONS(11),
EMOTES(12),
MUSIC(13);
private final int id;
}

View File

@@ -29,6 +29,7 @@ import java.util.Collection;
import net.runelite.api.FontTypeFace;
import net.runelite.api.Point;
import net.runelite.api.Sprite;
/**
* Represents an on-screen UI element that is drawn on the canvas.
@@ -845,4 +846,14 @@ public interface Widget
* Seems like this needs to set to true when creating new widgets
*/
void setIsIf3(boolean isIf3);
/**
* Returns yes if your mouse pointer is over this widget or any of it's children.
*/
boolean containsMouse();
/**
* Gets the image which is (or should be) drawn on this widget
*/
Sprite getSprite();
}

View File

@@ -817,6 +817,7 @@ public class WidgetID
static class SpellBook
{
static final int FILTERED_SPELLS_PARENT = 1;
static final int FILTERED_SPELLS_BOUNDS = 3;
// NORMAL SPELLS
@@ -968,6 +969,12 @@ public class WidgetID
// ARCEUUS SPELLS
static final int ARCEUUS_HOME_TELEPORT = 143;
static final int BATTLEFRONT_TELEPORT = 178;
static final int FILTER_SECTION_PARENT = 181;
static final int FILTER_BUTTONS_PARENT = 184;
static final int FILTER_BUTTON_PARENT = 185;
static final int FILTER_BUTTON = 187;
}
static class Pvp

View File

@@ -517,6 +517,8 @@ public enum WidgetInfo
PVP_BOUNTY_HUNTER_INFO(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.BOUNTY_HUNTER_INFO),
PVP_KILLDEATH_COUNTER(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.KILLDEATH_RATIO),
SPELLBOOK(WidgetID.SPELLBOOK_GROUP_ID, 0),
SPELLBOOK_FILTERED_SPELLS_PARENT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.SpellBook.FILTERED_SPELLS_PARENT),
SPELLBOOK_FILTERED_BOUNDS(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.SpellBook.FILTERED_SPELLS_BOUNDS),
/* STANDARD SPELL BOOK WIDGETS*/
@@ -671,7 +673,13 @@ public enum WidgetInfo
SPELL_TOOLTIP(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.SpellBook.TOOLTIP),
/* ARCEUUS SPELL BOOK WIDGETS*/
SPELL_ARCEUUS_HOME_TELEPORT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.SpellBook.ARCEUUS_HOME_TELEPORT),
SPELL_BATTLEFRONT_TELEPORT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.SpellBook.BATTLEFRONT_TELEPORT),
/* END OF ARCEUUS SPELL BOOK WIDGETS*/
SPELLBOOK_FILTER_SECTION_PARENT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.SpellBook.FILTER_SECTION_PARENT),
SPELLBOOK_FILTER_BUTTONS_PARENT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.SpellBook.FILTER_BUTTONS_PARENT),
SPELLBOOK_FILTER_BUTTON_PARENT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.SpellBook.FILTER_BUTTON_PARENT),
SPELLBOOK_FILTER_BUTTON(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.SpellBook.FILTER_BUTTON),
KOUREND_FAVOUR_OVERLAY(WidgetID.KOUREND_FAVOUR_GROUP_ID, WidgetID.KourendFavour.KOUREND_FAVOUR_OVERLAY),
ZEAH_MESS_HALL_COOKING_DISPLAY(WidgetID.ZEAH_MESS_HALL_GROUP_ID, WidgetID.Zeah.MESS_HALL_COOKING_DISPLAY),