diff --git a/buildSrc/src/main/kotlin/BootstrapTask.kt b/buildSrc/src/main/kotlin/BootstrapTask.kt index 3eaf7dcebb..0e141ee23d 100644 --- a/buildSrc/src/main/kotlin/BootstrapTask.kt +++ b/buildSrc/src/main/kotlin/BootstrapTask.kt @@ -1,3 +1,4 @@ +import groovy.json.JsonOutput import org.gradle.api.DefaultTask import org.gradle.api.file.RegularFileProperty import org.gradle.api.tasks.* @@ -117,11 +118,13 @@ open class BootstrapTask @Inject constructor(@Input val type: String) : DefaultT "artifacts" to getArtifacts() ).toString() + val prettyJson = JsonOutput.prettyPrint(json) + val bootstrapDir = File("${project.buildDir}/bootstrap") bootstrapDir.mkdirs() File(bootstrapDir, "bootstrap-${type}.json").printWriter().use { out -> - out.println(json) + out.println(prettyJson) } } } diff --git a/runelite-api/src/main/java/net/runelite/api/AnimationID.java b/runelite-api/src/main/java/net/runelite/api/AnimationID.java index 45b2369f23..d86d33e89c 100644 --- a/runelite-api/src/main/java/net/runelite/api/AnimationID.java +++ b/runelite-api/src/main/java/net/runelite/api/AnimationID.java @@ -30,7 +30,7 @@ package net.runelite.api; * Note: This class is not complete and may not contain a specific animation * required. */ -public class AnimationID +public final class AnimationID { public static final int IDLE = -1; public static final int HERBLORE_PESTLE_AND_MORTAR = 364; @@ -251,4 +251,257 @@ public class AnimationID // POH Animations public static final int INCENSE_BURNER = 3687; -} + + //OPENOSRS + + // NPC animations + public static final int FISHING_TRAILBLAZER_HARPOON_2 = 8785; + + public static final int CRYSTALLINE_RAT_DEATH = 8334; + public static final int CRYSTALLINE_BAT_DEATH = 4917; + public static final int CRYSTALLINE_WOLF_DEATH = 8335; + public static final int CRYSTALLINE_SPIDER_DEATH = 8338; + public static final int CRYSTALLINE_UNICORN_DEATH = 6377; + public static final int CRYSTALLINE_DRAGON_DEATH = 92; + public static final int CRYSTALLINE_BEAR_DEATH = 4929; + public static final int CRYSTALLINE_DARK_BEAST_DEATH = 2733; + public static final int CORRUPTED_SCORPION_DEATH = 6256; + + public static final int TABLET_TELEPORT = 4069; + + public static final int THIEVING_STALL = 832; + public static final int PICKPOCKET_SUCCESS = 881; + public static final int PULL_LEVER = 2140; + public static final int STANDARD_PURPLE_TELEPORT = 714; + public static final int ECTOPHIAL_TELEPORT = 878; + public static final int FAIRY_RING_TELEPORT = 3265; + public static final int SCROLL_TELEPORT = 3864; + public static final int XERICS_TALISMAN_TELEPORT = 3865; + public static final int WILDERNESS_OBELISK_TELEPORT = 3945; + public static final int SEED_POD_TELEPORT = 4544; + + //block animations for players and perhaps npcs as well? + public static final int BLOCK_DEFENDER = 4177; + public static final int BLOCK_NO_SHIELD = 420; + public static final int BLOCK_SHIELD = 1156; + public static final int BLOCK_SWORD = 388; + public static final int BLOCK_UNARMED = 424; // Same Animation as failed pickpocked + + public static final int NIGHTMARE_DEATH = 8612; + public static final int LOW_LEVEL_MAGIC_ATTACK = 1162; + public static final int HIGH_LEVEL_MAGIC_ATTACK = 1167; + public static final int BLOWPIPE_ATTACK = 5061; + + // NPC animations + public static final int BLACKJACK_KO = 838; + + // Fight Caves + public static final int TZTOK_JAD_MELEE_ATTACK = 2655; + public static final int TOK_XIL_RANGE_ATTACK = 2633; + public static final int TOK_XIL_MELEE_ATTACK = 2628; + public static final int KET_ZEK_MELEE_ATTACK = 2644; + public static final int KET_ZEK_MAGE_ATTACK = 2647; + public static final int MEJ_KOT_MELEE_ATTACK = 2637; + public static final int MEJ_KOT_HEAL_ATTACK = 2639; + + // Vorkath + public static final int VORKATH_WAKE_UP = 7950; + public static final int VORKATH_DEATH = 7949; + public static final int VORKATH_SLASH_ATTACK = 7951; + public static final int VORKATH_ATTACK = 7952; + public static final int VORKATH_FIRE_BOMB_OR_SPAWN_ATTACK = 7960; + public static final int VORKATH_ACID_ATTACK = 7957; + + // Tekton + public static final int TEKTON_ANVIL = 7475; + public static final int TEKTON_AUTO1 = 7482; + public static final int TEKTON_AUTO2 = 7483; + public static final int TEKTON_AUTO3 = 7484; + public static final int TEKTON_FAST_AUTO1 = 7478; + public static final int TEKTON_FAST_AUTO2 = 7488; + public static final int TEKTON_ENRAGE_AUTO1 = 7492; + public static final int TEKTON_ENRAGE_AUTO2 = 7493; + public static final int TEKTON_ENRAGE_AUTO3 = 7494; + + // Hydra + public static final int HYDRA_WALKING = 8232; + public static final int HYDRA_IDLE = 8233; + public static final int HYDRA_POISON_1 = 8234; + public static final int HYDRA_RANGED_1 = 8235; + public static final int HYDRA_MAGIC_1 = 8236; + public static final int HYDRA_1_1 = 8237; + public static final int HYDRA_1_2 = 8238; + public static final int HYDRA_LIGHTNING = 8241; + public static final int HYDRA_RANGED_2 = 8242; + public static final int HYDRA_MAGIC_2 = 8243; + public static final int HYDRA_2_1 = 8244; + public static final int HYDRA_2_2 = 8245; + public static final int HYDRA_FIRE = 8248; + public static final int HYDRA_RANGED_3 = 8249; + public static final int HYDRA_MAGIC_3 = 8250; + public static final int HYDRA_3_1 = 8251; + public static final int HYDRA_3_2 = 8252; + public static final int HYDRA_MAGIC_4 = 8254; + public static final int HYDRA_POISON_4 = 8254; + public static final int HYDRA_RANGED_4 = 8255; + public static final int HYDRA_RANGED_OR_POISON_ATTACK = 8256; + public static final int HYDRA_4_1 = 8257; + public static final int HYDRA_4_2 = 8258; + + // Inferno animations + public static final int JAL_NIB = 7574; + public static final int JAL_MEJRAH = 7578; + public static final int JAL_MEJRAH_STAND = 7577; + public static final int JAL_AK_RANGE_ATTACK = 7581; + public static final int JAL_AK_MELEE_ATTACK = 7582; + public static final int JAL_AK_MAGIC_ATTACK = 7583; + public static final int JAL_IMKOT = 7597; + public static final int JAL_XIL_MELEE_ATTACK = 7604; + public static final int JAL_XIL_RANGE_ATTACK = 7605; + public static final int JAL_ZEK_MAGE_ATTACK = 7610; + public static final int JAL_ZEK_MELEE_ATTACK = 7612; + public static final int JALTOK_JAD_MELEE_ATTACK = 7590; + public static final int JALTOK_JAD_MAGE_ATTACK = 7592; + public static final int JALTOK_JAD_RANGE_ATTACK = 7593; + public static final int TZKAL_ZUK = 7566; + public static final int JAL_MEJJAK = 2858; + + // General Graardor + public static final int MINION_AUTO1 = 6154; + public static final int MINION_AUTO2 = 6156; + public static final int MINION_AUTO3 = 7071; + public static final int MINION_AUTO4 = 7073; + public static final int GENERAL_AUTO1 = 7018; + public static final int GENERAL_AUTO2 = 7020; + public static final int GENERAL_AUTO3 = 7021; + + // Kr'il Tsutsaroth + public static final int ZAMMY_GENERIC_AUTO = 64; + public static final int KRIL_AUTO = 6948; + public static final int KRIL_SPEC = 6950; + public static final int ZAKL_AUTO = 7077; + public static final int BALFRUG_AUTO = 4630; + + // Commander Zilyana + public static final int ZILYANA_MELEE_AUTO = 6964; + public static final int ZILYANA_AUTO = 6967; + public static final int ZILYANA_SPEC = 6970; + public static final int STARLIGHT_AUTO = 6376; + public static final int BREE_AUTO = 7026; + public static final int GROWLER_AUTO = 7037; + + // Kree'arra + public static final int KREE_RANGED = 6978; + public static final int SKREE_AUTO = 6955; + public static final int GEERIN_AUTO = 6956; + public static final int GEERIN_FLINCH = 6958; + public static final int KILISA_AUTO = 6957; + + // Vetion + public static final int VETION_EARTHQUAKE = 5507; + + // Zulrah + public static final int ZULRAH_DEATH = 5804; + public static final int ZULRAH_PHASE = 5072; + + //Dagannoth Kings + public static final int DAG_REX = 2853; + public static final int DAG_PRIME = 2854; + public static final int DAG_SUPREME = 2855; + + // Lizardman shaman + public static final int LIZARDMAN_SHAMAN_SPAWN = 7157; + public static final int LIZARDMAN_SHAMAN_SPAWN_EXPLOSION = 7159; + + // Cerberus + public static final int CERBERUS_MAGIC_ATTACK = 4489; + public static final int CERBERUS_RANGED_ATTACK = 4490; + public static final int CERBERUS_MELEE_ATTACK = 4491; + public static final int CERBERUS_LAVA_ATTACK = 4493; + public static final int CERBERUS_SUMMON_GHOSTS = 4494; + + // Gauntlet Hunleff + public static final int HUNLEFF_TRAMPLE = 8420; + public static final int HUNLEFF_ATTACK = 8419; + public static final int HUNLEFF_TORNADO = 8418; + public static final int HUNLLEF_SWITCH_TO_MAGIC = 8754; + public static final int HUNLLEF_SWITCH_TO_RANGED = 8755; + + //Zalcano + public static final int ZALCANO_KNOCKED_DOWN = 8437; + public static final int ZALCANO_WAKEUP = 8439; + public static final int ZALCANO_ROCK_GLOWING = 8448; + + // Theatre of Blood - Sugadinti Maiden + public static final int SUGADINTI_MAIDEN_BLOOD_SPLAT_ATTACK = 8091; + public static final int SUGADINTI_MAIDEN_MAGIC_ATTACK = 8092; + public static final int SUGADINTI_MAIDEN_DEATH = 8094; + + // Theatre of Blood - Pestilent Bloat + public static final int BLOAT_SLEEP = 8082; + + // Theatre of Blood - Sotetseg + public static final int SOTETSEG_MELEE_ATTACK = 8138; + public static final int SOTETSEG_REGULAR_PROJECTILE_ATTACK = 8139; + + // Theatre of Blood - Verzik Vitur + public static final int VERZIK_PHASE_1_MAGIC_ATTACK = 8109; + public static final int VERZIK_PHASE_1_MAGIC_ATTACK_CHANNEL = 8110; + public static final int VERZIK_CHANGE_TO_PHASE_2 = 8111; + public static final int VERZIK_PHASE_2_MAGIC_ATTACK = 8114; + public static final int VERZIK_PHASE_2_BELLY_FLOP_ATTACK_1 = 8116; + public static final int VERZIK_PHASE_2_HEALING_CHANNEL = 8117; + public static final int VERZIK_PHASE_2_BELLY_FLOP_ATTACK_2 = 8118; + public static final int VERZIK_CHANGE_TO_PHASE_3 = 8119; + public static final int VERZIK_PHASE_3_MELEE_ATTACK = 8123; + public static final int VERZIK_PHASE_3_MAGIC_ATTACK = 8124; + public static final int VERZIK_PHASE_3_RANGED_ATTACK = 8125; + public static final int VERZIK_PHASE_3_GREEN_POOL_ATTACK = 8126; + public static final int VERZIK_PHASE_3_WEB_ATTACK = 8127; + public static final int VERZIK_DEATH_1 = 8128; + public static final int VERZIK_DEATH_2 = 8129; + + // The Nightmare of Ashihama + public static final int NIGHTMARE_SPAWN_SLEEPWALKERS = 8572; + public static final int NIGHTMARE_FLOATY = 8592; + public static final int NIGHTMARE_WALKING = 8592; + public static final int NIGHTMARE_IDLE = 8593; + public static final int NIGHTMARE_MELEE_ATTACK = 8594; + public static final int NIGHTMARE_MAGIC_ATTACK = 8595; + public static final int NIGHTMARE_RANGED_ATTACK = 8596; + public static final int NIGHTMARE_SURGE_ATTACK = 8597; + public static final int NIGHTMARE_GHOST_AOE_ATTACK = 8598; + public static final int NIGHTMARE_CURSE_PRAYERS_ATTACK = 8599; + public static final int NIGHTMARE_SPAWN_INFECTIOUS_SPORES = 8600; + public static final int NIGHTMARE_SPAWN_ROOM_SECTION_FLOWERS = 8601; + public static final int NIGHTMARE_CHANNEL_DEVASTATING_ATTACK = 8604; + public static final int NIGHTMARE_SWITCH_TO_DEVIL_PHASE = 8605; + public static final int NIGHTMARE_PARASITE_ATTACK = 8606; + public static final int NIGHTMARE_JUMP_DOWN = 8607; + public static final int NIGHTMARE_SINK_DOWN = 8608; + public static final int NIGHTMARE_JUMP_UP = 8609; + public static final int NIGHTMARE_JUMP_UP_2 = 8610; + public static final int NIGHTMARE_WAKE_UP = 8611; + + //Supplies Tracker + public static final int ONEHAND_SLASH_SWORD_ANIMATION = 390; + public static final int ONEHAND_STAB_SWORD_ANIMATION = 386; + public static final int SCYTHE_OF_VITUR_ANIMATION = 8056; + public static final int LOW_LEVEL_STANDARD_SPELLS = 711; + public static final int WAVE_SPELL_ANIMATION = 727; + public static final int SURGE_SPELL_ANIMATION = 7855; + public static final int HIGH_ALCH_ANIMATION = 713; + public static final int LUNAR_HUMIDIFY = 6294; + public static final int PRAY_AT_ALTAR = 645; + public static final int ENSOULED_HEADS_ANIMATION = 7198; + + // Weapon attack animations + public static final int ONEHAND_SLASH_AXE_ANIMATION = 395; + public static final int ONEHAND_CRUSH_PICKAXE_ANIMATION = 400; + public static final int ONEHAND_CRUSH_AXE_ANIMATION = 401; + public static final int UNARMED_PUNCH_ANIMATION = 422; + public static final int UNARMED_KICK_ANIMATION = 423; + public static final int BOW_ATTACK_ANIMATION = 426; + public static final int ONEHAND_STAB_HALBERD_ANIMATION = 428; + public static final int ONEHAND_SLASH_HALBERD_ANIMATION = 440; +} \ No newline at end of file diff --git a/runelite-api/src/main/java/net/runelite/api/Varbits.java b/runelite-api/src/main/java/net/runelite/api/Varbits.java index f0901f473d..d9845f473d 100644 --- a/runelite-api/src/main/java/net/runelite/api/Varbits.java +++ b/runelite-api/src/main/java/net/runelite/api/Varbits.java @@ -571,7 +571,7 @@ public enum Varbits EXPLORER_RING_ALCHS(4554), EXPLORER_RING_RUNENERGY(4553), - + WINTERTODT_TIMER(7980), /** * League relics @@ -610,76 +610,102 @@ public enum Varbits PVP_SPEC_ORB(8121), //OPENOSRS + /* + * Kharedst's Memoirs Teleport Item + */ + KHAREDSTS_MEMOIRS_CHARGES(6035), /** * Grand Exchange */ GRAND_EXCHANGE_PRICE_PER_ITEM(4398), - /* - * Kharedst's Memoirs Teleport Item - */ - KHAREDSTS_MEMOIRS_CHARGES(6035), - - LMS_POISON_PROGRESS(5317), /** - * The y coordinate of the final safespace (world coord) + * Locked Prayers + * 0-7 = Locked + * 8 = Unlocked */ - LMS_SAFE_Y(5320), + CHIVPIETY_UNLOCKED(3909), /** - * 1 is true, 0 is false. + * Locked Prayers + * 0 = Locked + * 1 = Unlocked */ - GAUNTLET_FINAL_ROOM_ENTERED(9177), + + RIGOUR_UNLOCKED(5451), + AUGURY_UNLOCKED(5452), + PRESERVE_UNLOCKED(5453), /** - * 1 is true, 0 is false. + * Theatre of Blood 1=In Party, 2=Inside/Spectator, 3=Dead Spectating */ - GAUNTLET_ENTERED(9178), - - WITHDRAW_X_AMOUNT(3960), - - IN_PVP_AREA(8121), + BLOAT_DOOR(6447), /** - * Value of hotkey varbits can be 0-13 - * 0 corresponds to no hotkey set - * 1-12 correspond to F1-F12 respectively - * 13 corresponds to escape + * Theatre of Blood orb varbits each number stands for the player's health on a scale of 1-27 (I think), 0 hides the orb */ - COMBAT_TAB_HOTKEY(4675), - STATS_TAB_HOTKEY(4676), - QUESTS_TAB_HOTKEY(4677), - INVENTORY_TAB_HOTKEY(4678), - EQUIPMENT_TAB_HOTKEY(4679), - PRAYER_TAB_HOTKEY(4680), - SPELLBOOK_TAB_HOTKEY(4682), - FRIENDS_TAB_HOTKEY(4684), - ACCOUNT_MANAGEMENT_TAB_HOTKEY(6517), - LOGOUT_TAB_HOTKEY(4689), - OPTIONS_TAB_HOTKEY(4686), - EMOTES_TAB_HOTKEY(4687), - CLAN_TAB_HOTKEY(4683), - MUSIC_TAB_HOTKEY(4688), + THEATRE_OF_BLOOD_ORB_1(6442), + THEATRE_OF_BLOOD_ORB_2(6443), + THEATRE_OF_BLOOD_ORB_3(6444), + THEATRE_OF_BLOOD_ORB_4(6445), + THEATRE_OF_BLOOD_ORB_5(6446), /** - * Chat Notifications settings - *
- * LOOT_DROP_NOTIFICATIONS: 1 is true, 0 is false - * LOOT_DROP_NOTIFICATIONS_VALUE: gp value - * UNTRADEABLE_LOOT_NOTIFICATIONS: 1 is true, 0 is false - * BOSS_KILL_COUNT_UPDATES: 1 is filtered, 0 is unfiltered - * DROP_ITEM_WARNINGS: 1 is true, 0 is false - * DROP_ITEM_WARNINGS_VALUE: gp value + * Nightmare Zone */ - LOOT_DROP_NOTIFICATIONS(5399), - LOOT_DROP_NOTIFICATIONS_VALUE(5400), - UNTRADEABLE_LOOT_NOTIFICATIONS(5402), - BOSS_KILL_COUNT_UPDATES(4930), - DROP_ITEM_WARNINGS(5411), - DROP_ITEM_WARNINGS_VALUE(5412), - /** + NMZ_OVERLOAD(3955), + + /** + * Pyramid plunder + */ + PYRAMID_PLUNDER_SARCO_OPEN(2362), + PYRAMID_PLUNDER_CHEST_OPEN(2363), + + /** + * In the Wilderness + */ + IN_THE_WILDERNESS(5963), + + /** + * Kingdom Management + */ + KINGDOM_WORKERS_WOOD(81), + KINGDOM_WORKERS_HERBS(82), + KINGDOM_WORKERS_FISHING(83), + KINGDOM_WORKERS_MINING(84), + KINGDOM_WORKERS_FISH_COOKED_BUTTON(135), // 0 - Raw, 1 - Cooked + KINGDOM_WORKERS_HARDWOOD(2131), + KINGDOM_WORKERS_FARM(2132), + KINGDOM_WORKERS_HARDWOOD_BUTTON(2133), // 0 - Mahogany, 1 - Teak, 2 - Both + KINGDOM_WORKERS_HERBS_BUTTON(2134), // 0 - Herbs, 1 - Flax + + /** + * Varbit used for Slayer reward points + */ + SLAYER_REWARD_POINTS(4068), + + /** + * 0 = standard + * 1 = ancients + * 2 = lunars + * 3 = arrceus + **/ + SPELLBOOK(4070), + + /** + * Bank settings/flags + **/ + BANK_NOTE_FLAG(3958), + + + /** + * Spells being auto-casted + */ + AUTO_CAST_SPELL(276), + + /** * Temple Trekking */ TREK_POINTS(1955), @@ -796,8 +822,6 @@ public enum Varbits */ BUILDING_MODE(2176), - WINTERTODT_TIMER(7980), - /** * 1 if in game, 0 if not */ @@ -813,81 +837,64 @@ public enum Varbits */ LMS_SAFE_X(5316), + LMS_POISON_PROGRESS(5317), + /** - * Locked Prayers - * 0-7 = Locked - * 8 = Unlocked + * The y coordinate of the final safespace (world coord) */ - CHIVPIETY_UNLOCKED(3909), + LMS_SAFE_Y(5320), /** - * Locked Prayers - * 0 = Locked - * 1 = Unlocked + * 1 is true, 0 is false. */ + GAUNTLET_FINAL_ROOM_ENTERED(9177), - RIGOUR_UNLOCKED(5451), - AUGURY_UNLOCKED(5452), - PRESERVE_UNLOCKED(5453), - /** - * Spells being auto-casted + * 1 is true, 0 is false. */ - AUTO_CAST_SPELL(276), + GAUNTLET_ENTERED(9178), + + WITHDRAW_X_AMOUNT(3960), + + IN_PVP_AREA(8121), /** - * Theatre of Blood 1=In Party, 2=Inside/Spectator, 3=Dead Spectating + * Value of hotkey varbits can be 0-13 + * 0 corresponds to no hotkey set + * 1-12 correspond to F1-F12 respectively + * 13 corresponds to escape */ - BLOAT_DOOR(6447), + COMBAT_TAB_HOTKEY(4675), + STATS_TAB_HOTKEY(4676), + QUESTS_TAB_HOTKEY(4677), + INVENTORY_TAB_HOTKEY(4678), + EQUIPMENT_TAB_HOTKEY(4679), + PRAYER_TAB_HOTKEY(4680), + SPELLBOOK_TAB_HOTKEY(4682), + FRIENDS_TAB_HOTKEY(4684), + ACCOUNT_MANAGEMENT_TAB_HOTKEY(6517), + LOGOUT_TAB_HOTKEY(4689), + OPTIONS_TAB_HOTKEY(4686), + EMOTES_TAB_HOTKEY(4687), + CLAN_TAB_HOTKEY(4683), + MUSIC_TAB_HOTKEY(4688), /** - * Theatre of Blood orb varbits each number stands for the player's health on a scale of 1-27 (I think), 0 hides the orb + * Chat Notifications settings + *
+ * LOOT_DROP_NOTIFICATIONS: 1 is true, 0 is false + * LOOT_DROP_NOTIFICATIONS_VALUE: gp value + * UNTRADEABLE_LOOT_NOTIFICATIONS: 1 is true, 0 is false + * BOSS_KILL_COUNT_UPDATES: 1 is filtered, 0 is unfiltered + * DROP_ITEM_WARNINGS: 1 is true, 0 is false + * DROP_ITEM_WARNINGS_VALUE: gp value */ - THEATRE_OF_BLOOD_ORB_1(6442), - THEATRE_OF_BLOOD_ORB_2(6443), - THEATRE_OF_BLOOD_ORB_3(6444), - THEATRE_OF_BLOOD_ORB_4(6445), - THEATRE_OF_BLOOD_ORB_5(6446), - - //NMZ - NMZ_OVERLOAD(3955), - - //Pyramid Plunder - PYRAMID_PLUNDER_SARCO_OPEN(2362), - PYRAMID_PLUNDER_CHEST_OPEN(2363), - - /** - * Varbit used for Slayer reward points - */ - SLAYER_REWARD_POINTS(4068), - - /** - * 0 = standard - * 1 = ancients - * 2 = lunars - * 3 = arrceus - **/ - SPELLBOOK(4070), - - /** - * Bank settings/flags - **/ - BANK_NOTE_FLAG(3958), - - KINGDOM_WORKERS_WOOD(81), - KINGDOM_WORKERS_HERBS(82), - KINGDOM_WORKERS_FISHING(83), - KINGDOM_WORKERS_MINING(84), - KINGDOM_WORKERS_FISH_COOKED_BUTTON(135), // 0 - Raw, 1 - Cooked - KINGDOM_WORKERS_HARDWOOD(2131), - KINGDOM_WORKERS_FARM(2132), - KINGDOM_WORKERS_HARDWOOD_BUTTON(2133), // 0 - Mahogany, 1 - Teak, 2 - Both - KINGDOM_WORKERS_HERBS_BUTTON(2134), // 0 - Herbs, 1 - Flax - - /** - * In the Wilderness - */ - IN_THE_WILDERNESS(5963), + LOOT_DROP_NOTIFICATIONS(5399), + LOOT_DROP_NOTIFICATIONS_VALUE(5400), + UNTRADEABLE_LOOT_NOTIFICATIONS(5402), + BOSS_KILL_COUNT_UPDATES(4930), + DROP_ITEM_WARNINGS(5411), + DROP_ITEM_WARNINGS_VALUE(5412), ; /** diff --git a/runelite-api/src/main/java/net/runelite/api/events/WidgetHiddenChanged.java b/runelite-api/src/main/java/net/runelite/api/events/WidgetHiddenChanged.java new file mode 100644 index 0000000000..b66c05267f --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/events/WidgetHiddenChanged.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018, Adam + * 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.events; + +import net.runelite.api.widgets.Widget; +import lombok.Data; + +/** + * An event where the hidden state of a {@link Widget} has been modified. + */ +@Data +public class WidgetHiddenChanged implements Event +{ + /** + * The affected widget. + */ + private Widget widget; + /** + * The new hidden state of the widget. + */ + private boolean hidden; +} \ No newline at end of file diff --git a/runelite-client/src/main/java/com/openosrs/client/ui/overlay/OverlayUtil.java b/runelite-client/src/main/java/com/openosrs/client/ui/overlay/OverlayUtil.java index 0c4f611be5..47a6d2e716 100644 --- a/runelite-client/src/main/java/com/openosrs/client/ui/overlay/OverlayUtil.java +++ b/runelite-client/src/main/java/com/openosrs/client/ui/overlay/OverlayUtil.java @@ -138,4 +138,37 @@ public class OverlayUtil extends net.runelite.client.ui.overlay.OverlayUtil graphics.fill(poly); graphics.setStroke(originalStroke); } + + public static void renderAreaTilePolygon(Graphics2D graphics, Shape poly, Color color) + { + graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 10)); + graphics.fill(poly); + } + + public static void renderFullLine(Graphics2D graphics, int[][] line, Color color) + { + graphics.setColor(color); + final Stroke originalStroke = graphics.getStroke(); + graphics.setStroke(new BasicStroke(2)); + graphics.drawLine(line[0][0], line[0][1], line[1][0], line[1][1]); + graphics.setStroke(originalStroke); + } + + public static void renderDashedLine(Graphics2D graphics, int[][] line, Color color) + { + graphics.setColor(color); + final Stroke originalStroke = graphics.getStroke(); + graphics.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{9}, 0)); + graphics.drawLine(line[0][0], line[0][1], line[1][0], line[1][1]); + graphics.setStroke(originalStroke); + } + + public static void renderOutlinePolygon(Graphics2D graphics, Shape poly, Color color) + { + graphics.setColor(color); + final Stroke originalStroke = graphics.getStroke(); + graphics.setStroke(new BasicStroke(2)); + graphics.draw(poly); + graphics.setStroke(originalStroke); + } } diff --git a/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableAlignment.java b/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableAlignment.java new file mode 100644 index 0000000000..6061e639f8 --- /dev/null +++ b/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableAlignment.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019, TheStonedTurtle + * 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 com.openosrs.client.ui.overlay.components.table; + +public enum TableAlignment +{ + LEFT, + CENTER, + RIGHT +} diff --git a/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableComponent.java b/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableComponent.java new file mode 100644 index 0000000000..6f96434e6d --- /dev/null +++ b/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableComponent.java @@ -0,0 +1,465 @@ +/* + * Copyright (c) 2018, Jordan Atwood + * Copyright (c) 2019, TheStonedTurtle + * 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 com.openosrs.client.ui.overlay.components.table; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import lombok.Getter; +import lombok.NonNull; +import lombok.Setter; +import net.runelite.api.util.Text; +import net.runelite.client.ui.overlay.components.ComponentConstants; +import net.runelite.client.ui.overlay.components.LayoutableRenderableEntity; +import net.runelite.client.ui.overlay.components.TextComponent; + +@Setter +public class TableComponent implements LayoutableRenderableEntity +{ + private static final TableElement EMPTY_ELEMENT = TableElement.builder().build(); + + @Getter + private final List columns = new ArrayList<>(); + @Getter + private final List rows = new ArrayList<>(); + + @Getter + private final Rectangle bounds = new Rectangle(); + + private TableAlignment defaultAlignment = TableAlignment.LEFT; + private Color defaultColor = Color.WHITE; + private Dimension gutter = new Dimension(3, 0); + private Point preferredLocation = new Point(); + private Dimension preferredSize = new Dimension(ComponentConstants.STANDARD_WIDTH, 0); + + @Override + public Dimension render(final Graphics2D graphics) + { + final FontMetrics metrics = graphics.getFontMetrics(); + final TableRow colRow = TableRow.builder().elements(this.columns).build(); + final int[] columnWidths = getColumnWidths(metrics, colRow); + + graphics.translate(preferredLocation.x, preferredLocation.y); + + // Display the columns first + int height = displayRow(graphics, colRow, 0, columnWidths, metrics); + + for (TableRow row : this.rows) + { + height = displayRow(graphics, row, height, columnWidths, metrics); + } + + graphics.translate(-preferredLocation.x, -preferredLocation.y); + + final Dimension dimension = new Dimension(preferredSize.width, height); + bounds.setLocation(preferredLocation); + bounds.setSize(dimension); + + return dimension; + } + + private int displayRow(Graphics2D graphics, TableRow row, int height, int[] columnWidths, FontMetrics metrics) + { + int x = 0; + int startingRowHeight = height; + + final List elements = row.getElements(); + for (int i = 0; i < elements.size(); i++) + { + int y = startingRowHeight; + final TableElement cell = elements.get(i); + + final String content = cell.getContent(); + if (content == null) + { + continue; + } + + final String[] lines = lineBreakText(content, columnWidths[i], metrics); + final TableAlignment alignment = getCellAlignment(row, i); + final Color color = getCellColor(row, i); + + for (String line : lines) + { + final int alignmentOffset = getAlignedPosition(line, alignment, columnWidths[i], metrics); + final TextComponent leftLineComponent = new TextComponent(); + y += metrics.getHeight(); + + leftLineComponent.setPosition(new Point(x + alignmentOffset, y)); + leftLineComponent.setText(line); + leftLineComponent.setColor(color); + leftLineComponent.render(graphics); + } + height = Math.max(height, y); + x += columnWidths[i] + gutter.width; + } + + return height + gutter.height; + } + + /** + * Returns the width that each column should take up + * Based on https://stackoverflow.com/questions/22206825/algorithm-for-calculating-variable-column-widths-for-set-table-width + * + * @param metrics + * @return int[] of column width + */ + private int[] getColumnWidths(final FontMetrics metrics, final TableRow columnRow) + { + int numCols = columns.size(); + for (final TableRow r : rows) + { + numCols = Math.max(r.getElements().size(), numCols); + } + + int[] maxtextw = new int[numCols]; // max text width over all rows + int[] maxwordw = new int[numCols]; // max width of longest word + boolean[] flex = new boolean[numCols]; // is column flexible? + boolean[] wrap = new boolean[numCols]; // can column be wrapped? + int[] finalcolw = new int[numCols]; // final width of columns + + final List rows = new ArrayList<>(this.rows); + rows.add(columnRow); + + for (final TableRow r : rows) + { + final List elements = r.getElements(); + for (int col = 0; col < elements.size(); col++) + { + final TableElement ele = elements.get(col); + final String cell = ele.getContent(); + if (cell == null) + { + continue; + } + + final int cellWidth = getTextWidth(metrics, cell); + + maxtextw[col] = Math.max(maxtextw[col], cellWidth); + for (String word : cell.split(" ")) + { + maxwordw[col] = Math.max(maxwordw[col], getTextWidth(metrics, word)); + } + + if (maxtextw[col] == cellWidth) + { + wrap[col] = cell.contains(" "); + } + } + } + + int left = preferredSize.width - (numCols - 1) * gutter.width; + final double avg = left / numCols; + int nflex = 0; + + // Determine whether columns should be flexible and assign width of non-flexible cells + for (int col = 0; col < numCols; col++) + { + // This limit can be adjusted as needed + final double maxNonFlexLimit = 1.5 * avg; + + flex[col] = maxtextw[col] > maxNonFlexLimit; + if (flex[col]) + { + nflex++; + } + else + { + finalcolw[col] = maxtextw[col]; + left -= finalcolw[col]; + } + } + + // If there is not enough space, make columns that could be word-wrapped flexible too + if (left < nflex * avg) + { + for (int col = 0; col < numCols; col++) + { + if (!flex[col] && wrap[col]) + { + left += finalcolw[col]; + finalcolw[col] = 0; + flex[col] = true; + nflex++; + } + } + } + + // Calculate weights for flexible columns. The max width is capped at the table width to + // treat columns that have to be wrapped more or less equal + int tot = 0; + for (int col = 0; col < numCols; col++) + { + if (flex[col]) + { + maxtextw[col] = Math.min(maxtextw[col], preferredSize.width); + tot += maxtextw[col]; + } + } + + // Now assign the actual width for flexible columns. Make sure that it is at least as long + // as the longest word length + for (int col = 0; col < numCols; col++) + { + if (flex[col]) + { + finalcolw[col] = left * maxtextw[col] / tot; + finalcolw[col] = Math.max(finalcolw[col], maxwordw[col]); + left -= finalcolw[col]; + } + } + + // When the sum of column widths is less than the total space available, distribute the + // extra space equally across all columns + final int extraPerCol = left / numCols; + for (int col = 0; col < numCols; col++) + { + finalcolw[col] += extraPerCol; + left -= extraPerCol; + } + // Add any remainder to the right-most column + finalcolw[finalcolw.length - 1] += left; + + return finalcolw; + } + + private static int getTextWidth(final FontMetrics metrics, final String cell) + { + return metrics.stringWidth(Text.removeTags(cell)); + } + + private static String[] lineBreakText(final String text, final int maxWidth, final FontMetrics metrics) + { + final String[] words = text.split(" "); + + if (words.length == 0) + { + return new String[0]; + } + + final StringBuilder wrapped = new StringBuilder(words[0]); + int spaceLeft = maxWidth - getTextWidth(metrics, wrapped.toString()); + + for (int i = 1; i < words.length; i++) + { + final String word = words[i]; + final int wordLen = getTextWidth(metrics, word); + final int spaceWidth = metrics.stringWidth(" "); + + if (wordLen + spaceWidth > spaceLeft) + { + wrapped.append("\n").append(word); + spaceLeft = maxWidth - wordLen; + } + else + { + wrapped.append(" ").append(word); + spaceLeft -= spaceWidth + wordLen; + } + } + + return wrapped.toString().split("\n"); + } + + public boolean isEmpty() + { + return columns.size() == 0 || rows.size() == 0; + } + + private void ensureColumnSize(final int size) + { + while (size > columns.size()) + { + columns.add(TableElement.builder().build()); + } + } + + private static int getAlignedPosition(final String str, final TableAlignment alignment, final int columnWidth, final FontMetrics metrics) + { + final int stringWidth = getTextWidth(metrics, str); + int offset = 0; + + switch (alignment) + { + case LEFT: + break; + case CENTER: + offset = (columnWidth / 2) - (stringWidth / 2); + break; + case RIGHT: + offset = columnWidth - stringWidth; + break; + } + return offset; + } + + /** + * Returns the color for the specified table element. + * Priority order: cell->row->column->default + * + * @param row TableRow element + * @param colIndex column index + */ + private Color getCellColor(final TableRow row, final int colIndex) + { + final List rowElements = row.getElements(); + final TableElement cell = colIndex < rowElements.size() ? rowElements.get(colIndex) : EMPTY_ELEMENT; + final TableElement column = colIndex < columns.size() ? columns.get(colIndex) : EMPTY_ELEMENT; + + return firstNonNull( + cell.getColor(), + row.getRowColor(), + column.getColor(), + defaultColor); + } + + private void setColumnAlignment(final int col, final TableAlignment alignment) + { + assert columns.size() > col; + columns.get(col).setAlignment(alignment); + } + + public void setColumnAlignments(@Nonnull final TableAlignment... alignments) + { + ensureColumnSize(alignments.length); + for (int i = 0; i < alignments.length; i++) + { + setColumnAlignment(i, alignments[i]); + } + } + + /** + * Returns the alignment for the specified table element. + * Priority order: cell->row->column->default + * + * @param row TableRow element + * @param colIndex column index + */ + private TableAlignment getCellAlignment(final TableRow row, final int colIndex) + { + final List rowElements = row.getElements(); + final TableElement cell = colIndex < rowElements.size() ? rowElements.get(colIndex) : EMPTY_ELEMENT; + final TableElement column = colIndex < columns.size() ? columns.get(colIndex) : EMPTY_ELEMENT; + + return firstNonNull( + cell.getAlignment(), + row.getRowAlignment(), + column.getAlignment(), + defaultAlignment); + } + + @SafeVarargs + private static T firstNonNull(@Nullable T... elements) + { + if (elements == null || elements.length == 0) + { + return null; + } + + int i = 0; + T cur = elements[0]; + while (cur == null && i < elements.length) + { + cur = elements[i]; + i++; + } + + return cur; + } + + // Helper functions for cleaner overlay code + public void addRow(@Nonnull final String... cells) + { + final List elements = new ArrayList<>(); + for (final String cell : cells) + { + elements.add(TableElement.builder().content(cell).build()); + } + + final TableRow row = TableRow.builder().build(); + row.setElements(elements); + + this.rows.add(row); + } + + private void addRows(@Nonnull final String[]... rows) + { + for (String[] row : rows) + { + addRow(row); + } + } + + public void addRows(@NonNull final TableRow... rows) + { + this.rows.addAll(Arrays.asList(rows)); + } + + public void setRows(@Nonnull final String[]... elements) + { + this.rows.clear(); + addRows(elements); + } + + public void setRows(@Nonnull final TableRow... elements) + { + this.rows.clear(); + this.rows.addAll(Arrays.asList(elements)); + } + + private void addColumn(@Nonnull final String col) + { + this.columns.add(TableElement.builder().content(col).build()); + } + + public void addColumns(@NonNull final TableElement... columns) + { + this.columns.addAll(Arrays.asList(columns)); + } + + public void setColumns(@Nonnull final TableElement... elements) + { + this.columns.clear(); + this.columns.addAll(Arrays.asList(elements)); + } + + public void setColumns(@Nonnull final String... columns) + { + this.columns.clear(); + for (String col : columns) + { + addColumn(col); + } + } +} diff --git a/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableElement.java b/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableElement.java new file mode 100644 index 0000000000..daf7eb5790 --- /dev/null +++ b/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableElement.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2019, TheStonedTurtle + * 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 com.openosrs.client.ui.overlay.components.table; + +import java.awt.Color; +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class TableElement +{ + TableAlignment alignment; + Color color; + String content; +} diff --git a/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableRow.java b/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableRow.java new file mode 100644 index 0000000000..9451bba547 --- /dev/null +++ b/runelite-client/src/main/java/com/openosrs/client/ui/overlay/components/table/TableRow.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019, TheStonedTurtle + * 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 com.openosrs.client.ui.overlay.components.table; + +import java.awt.Color; +import java.util.Collections; +import java.util.List; +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class TableRow +{ + Color rowColor; + TableAlignment rowAlignment; + @Builder.Default + List elements = Collections.emptyList(); +} diff --git a/runelite-client/src/main/java/com/openosrs/client/util/Clipboard.java b/runelite-client/src/main/java/com/openosrs/client/util/Clipboard.java new file mode 100644 index 0000000000..5f9f236c16 --- /dev/null +++ b/runelite-client/src/main/java/com/openosrs/client/util/Clipboard.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018, Connor + * 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 com.openosrs.client.util; + +import java.awt.Toolkit; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.IOException; + +public class Clipboard +{ + public static String retrieve() + { + Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); + + if (contents == null || !contents.isDataFlavorSupported(DataFlavor.stringFlavor)) + { + return null; + } + + try + { + return (String) contents.getTransferData(DataFlavor.stringFlavor); + } + catch (UnsupportedFlavorException | IOException ex) + { + return null; + } + } + + public static void store(String contents) + { + final StringSelection selection = new StringSelection(contents); + + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, null); + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/Plugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/Plugin.java index 23a9dbf5ce..415b9d47b1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/Plugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/Plugin.java @@ -28,6 +28,7 @@ import com.google.inject.Binder; import com.google.inject.Injector; import com.google.inject.Module; import org.pf4j.ExtensionPoint; +import net.runelite.client.RuneLite; public abstract class Plugin implements Module, ExtensionPoint { @@ -50,8 +51,20 @@ public abstract class Plugin implements Module, ExtensionPoint { } + // This should never be null when we are using it public final Injector getInjector() { + if (injector == null) + { + Module pluginModule = (Binder binder) -> + { + binder.bind((Class) this.getClass()).toInstance(this); + binder.install(this); + }; + Injector pluginInjector = RuneLite.getInjector().createChildInjector(pluginModule); + pluginInjector.injectMembers(this); + injector = pluginInjector; + } return injector; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java index 500bd48000..3ab83b3fd4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java @@ -164,20 +164,7 @@ public class PluginManager try { Injector injector = plugin.getInjector(); - if (injector == null) - { - // Create injector for the module - Module pluginModule = (Binder binder) -> - { - // Since the plugin itself is a module, it won't bind itself, so we'll bind it here - binder.bind((Class) plugin.getClass()).toInstance(plugin); - binder.install(plugin); - }; - Injector pluginInjector = RuneLite.getInjector().createChildInjector(pluginModule); - pluginInjector.injectMembers(plugin); - plugin.injector = pluginInjector; - injector = pluginInjector; - } + for (Key key : injector.getBindings().keySet()) { Class type = key.getTypeLiteral().getRawType(); @@ -207,25 +194,7 @@ public class PluginManager plugins = getPlugins(); } plugins.forEach(pl -> - { - //TODO: Not sure why this is necessary but it is. The Injector isn't null when its handed off from our ExternalPluginManager. - // Hopefully we can figure out the root cause of the underlying issue. - if (pl.injector == null) - { - // Create injector for the module - Module pluginModule = (Binder binder) -> - { - // Since the plugin itself is a module, it won't bind itself, so we'll bind it here - binder.bind((Class) pl.getClass()).toInstance(pl); - binder.install(pl); - }; - Injector pluginInjector = RuneLite.getInjector().createChildInjector(pluginModule); - pluginInjector.injectMembers(pl); - pl.injector = pluginInjector; - } - - injectors.add(pl.getInjector()); - }); + injectors.add(pl.getInjector())); List list = new ArrayList<>(); for (Injector injector : injectors) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index b72c138391..6c9b6cd800 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -152,7 +152,7 @@ public class MenuEntrySwapperPlugin extends Plugin @Getter private boolean configuringShiftClick = false; - private final Multimap swaps = LinkedHashMultimap.create(); + private static final Multimap swaps = LinkedHashMultimap.create(); private final ArrayListMultimap optionIndexes = ArrayListMultimap.create(); @Provides @@ -361,7 +361,7 @@ public class MenuEntrySwapperPlugin extends Plugin swap("eat", "guzzle", config::swapRockCake); } - private void swap(String option, String swappedOption, Supplier enabled) + public static void swap(String option, String swappedOption, Supplier enabled) { swap(option, alwaysTrue(), swappedOption, enabled); } @@ -371,7 +371,7 @@ public class MenuEntrySwapperPlugin extends Plugin swap(option, equalTo(target), swappedOption, enabled); } - private void swap(String option, Predicate targetPredicate, String swappedOption, Supplier enabled) + private static void swap(String option, Predicate targetPredicate, String swappedOption, Supplier enabled) { swaps.put(option, new Swap(alwaysTrue(), targetPredicate, swappedOption, enabled, true)); } diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java index c940376ba4..3bc5fb52ef 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java @@ -28,6 +28,7 @@ import net.runelite.api.HashTable; import net.runelite.api.Node; import net.runelite.api.Point; import net.runelite.api.WidgetNode; +import net.runelite.api.events.WidgetHiddenChanged; import net.runelite.api.events.WidgetPositioned; import net.runelite.api.mixins.Copy; import net.runelite.api.mixins.FieldHook; @@ -74,6 +75,48 @@ public abstract class RSWidgetMixin implements RSWidget rl$y = -1; } + @Inject + @Override + public void broadcastHidden(boolean hidden) + { + WidgetHiddenChanged event = new WidgetHiddenChanged(); + event.setWidget(this); + event.setHidden(hidden); + + client.getCallbacks().post(event); + + RSWidget[] children = getChildren(); + + if (children != null) + { + // recursive through children + for (RSWidget child : children) + { + // if the widget is hidden it will not magically unhide from its parent changing + if (child == null || child.isSelfHidden()) + { + continue; + } + + child.broadcastHidden(hidden); + } + } + + // make sure we iterate nested children as well + // cannot be null + Widget[] nestedChildren = getNestedChildren(); + + for (Widget nestedChild : nestedChildren) + { + if (nestedChild == null || nestedChild.isSelfHidden()) + { + continue; + } + + ((RSWidget) nestedChild).broadcastHidden(hidden); + } + } + @Inject @Override public void setRenderParentId(int parentId) diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSWidget.java b/runescape-api/src/main/java/net/runelite/rs/api/RSWidget.java index ace10f8461..57546ccfe4 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSWidget.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSWidget.java @@ -588,4 +588,6 @@ public interface RSWidget extends Widget @Import("onVarTransmit") @Override void setOnVarTransmitListener(Object[] o); + + void broadcastHidden(boolean hidden); } \ No newline at end of file