diff --git a/README.md b/README.md index a1edf80b7e..c1e6723a8b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ - [http-api](http-api/src/main/java/net/runelite/http/api) - API for runelite and runeliteplus - [http-service](http-service/src/main/java/net/runelite/http/service) - Service for https://api.runelitepl.us - [runelite-api](runelite-api/src/main/java/net/runelite/api) - RuneLite API, interfaces for accessing the client -- [runelite-mixins](runelite-mixins/src/main/java/net/runelite) - Mixins which are injected into the injected client's classes +- [runelite-mixins](runelite-mixins/src/main/java/net/runelite) - Mixins which are injected into the vanilla client's classes - [runescape-api](runescape-api/src/main/java/net/runelite) - Mappings correspond to these interfaces, runelite-api is a subset of this - [runelite-client](runelite-client/src/main/java/net/runelite/client) - Game client with plugins diff --git a/cache/src/main/java/net/runelite/cache/item/SpritePixels.java b/cache/src/main/java/net/runelite/cache/item/SpritePixels.java index a1b3c026b9..ed8be85a18 100644 --- a/cache/src/main/java/net/runelite/cache/item/SpritePixels.java +++ b/cache/src/main/java/net/runelite/cache/item/SpritePixels.java @@ -108,7 +108,7 @@ class Sprite } - public void drawAtOn(Rasterizer2D graphics, int x, int y) + public void drawAtOn(Rasterizer2D graphics, int x, int y) { x += this.offsetX; y += this.offsetY; diff --git a/cache/src/test/java/net/runelite/cache/AreaDumper.java b/cache/src/test/java/net/runelite/cache/AreaDumper.java index 0b276fcce1..2aab1db48b 100644 --- a/cache/src/test/java/net/runelite/cache/AreaDumper.java +++ b/cache/src/test/java/net/runelite/cache/AreaDumper.java @@ -64,7 +64,7 @@ public class AreaDumper for (AreaDefinition area : areaManager.getAreas()) { - Files.asCharSink(new File(outDir, area.id + ".json"), Charset.defaultCharset()).write(gson.toJson(area)); + Files.asCharSink(new File(outDir, area.id + ".json"), Charset.defaultCharset()).write(gson.toJson(area)); ++count; } } diff --git a/http-api/src/main/java/net/runelite/http/api/RuneLiteAPI.java b/http-api/src/main/java/net/runelite/http/api/RuneLiteAPI.java index 7d256096b6..de2b1d469c 100644 --- a/http-api/src/main/java/net/runelite/http/api/RuneLiteAPI.java +++ b/http-api/src/main/java/net/runelite/http/api/RuneLiteAPI.java @@ -103,6 +103,8 @@ public class RuneLiteAPI CLIENT = new OkHttpClient.Builder() .pingInterval(30, TimeUnit.SECONDS) + .connectTimeout(5655, TimeUnit.MILLISECONDS) + .writeTimeout(5655, TimeUnit.MILLISECONDS) .addNetworkInterceptor(new Interceptor() { @Override @@ -119,6 +121,8 @@ public class RuneLiteAPI RLP_CLIENT = new OkHttpClient.Builder() .pingInterval(30, TimeUnit.SECONDS) + .writeTimeout(5655, TimeUnit.MILLISECONDS) + .connectTimeout(2655, TimeUnit.MILLISECONDS) .addNetworkInterceptor(new Interceptor() { @Override diff --git a/http-service/src/main/java/net/runelite/http/service/animation/AnimationController.java b/http-service/src/main/java/net/runelite/http/service/animation/AnimationController.java new file mode 100644 index 0000000000..c588b8193d --- /dev/null +++ b/http-service/src/main/java/net/runelite/http/service/animation/AnimationController.java @@ -0,0 +1,92 @@ +/* + * 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.http.service.animation; + +import java.util.List; +import java.util.stream.Collectors; +import net.runelite.http.api.animation.AnimationKey; +import net.runelite.http.api.animation.AnimationRequest; +import net.runelite.http.service.util.exception.NotFoundException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import static org.springframework.web.bind.annotation.RequestMethod.POST; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/animation") +public class AnimationController +{ + @Autowired + private AnimationEndpoint animationService; + + @RequestMapping(method = POST) + public void submit(@RequestBody AnimationRequest animationRequest) + { + animationService.submit(animationRequest); + } + + @GetMapping + public List get() + { + return animationService.get().stream() + .map(AnimationController::entryToKey) + .collect(Collectors.toList()); + } + + @GetMapping("/{npcid}") + public AnimationKey getRegion(@PathVariable int npcid) + { + AnimationEntry animationEntry = animationService.getNPC(npcid); + if (animationEntry == null) + { + throw new NotFoundException(); + } + + return entryToKey(animationEntry); + } + + private static AnimationKey entryToKey(AnimationEntry xe) + { + AnimationKey animationKey = new AnimationKey(); + animationKey.setNPCId(xe.getNPCId()); + animationKey.setAnimations(new int[] + { + xe.getAnimations()[0], + xe.getAnimations()[1], + xe.getAnimations()[2], + xe.getAnimations()[3], + xe.getAnimations()[4], + xe.getAnimations()[5], + xe.getAnimations()[6], + xe.getAnimations()[7], + xe.getAnimations()[8], + xe.getAnimations()[9], + }); + return animationKey; + } +} diff --git a/pom.xml b/pom.xml index 6a41755b67..6a3fe52405 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ 1.10.19 1.5.4 3.0.6 - 3.7.0 + 4.0.0 0.7 3.0.2 diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java index c81c25bd0e..a9adb43b62 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java @@ -29,6 +29,7 @@ import com.google.common.collect.ComparisonChain; import com.google.common.collect.ImmutableMap; import java.awt.Color; import java.awt.Dimension; +import java.awt.Font; import java.awt.Point; import java.awt.Rectangle; import java.io.File; @@ -66,6 +67,7 @@ import net.runelite.client.RuneLite; import static net.runelite.client.RuneLite.PROFILES_DIR; import net.runelite.client.eventbus.EventBus; import net.runelite.client.util.ColorUtil; +import net.runelite.client.ui.FontManager; @Singleton @Slf4j @@ -508,6 +510,10 @@ public class ConfigManager { return Enum.valueOf((Class) type, str); } + if (type == Font.class) + { + return FontManager.getFontOrDefault(FontManager.lookupFont(str)); + } if (type == Instant.class) { return Instant.parse(str); @@ -564,6 +570,10 @@ public class ConfigManager { return ((Enum) object).name(); } + if (object instanceof Font) + { + return FontManager.getFontName((Font)object); + } if (object instanceof Dimension) { Dimension d = (Dimension) object; diff --git a/runelite-client/src/main/java/net/runelite/client/config/FontType.java b/runelite-client/src/main/java/net/runelite/client/config/FontType.java index 8cf3dcbad8..df1044de5c 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/FontType.java +++ b/runelite-client/src/main/java/net/runelite/client/config/FontType.java @@ -24,21 +24,18 @@ */ package net.runelite.client.config; -import java.awt.Font; import lombok.Getter; import lombok.RequiredArgsConstructor; -import net.runelite.client.ui.FontManager; @Getter @RequiredArgsConstructor public enum FontType { - REGULAR("Regular", FontManager.getRunescapeFont()), - BOLD("Bold", FontManager.getRunescapeBoldFont()), - SMALL("Small", FontManager.getRunescapeSmallFont()); + REGULAR("Regular"), + BOLD("Bold"), + SMALL("Small"); private final String name; - private final Font font; @Override public String toString() diff --git a/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java b/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java index fea5ab1734..f57df0c6f0 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java @@ -25,7 +25,9 @@ package net.runelite.client.config; import java.awt.Dimension; +import java.awt.Font; import net.runelite.api.Constants; +import net.runelite.client.ui.FontManager; @ConfigGroup("runelite") public interface RuneLiteConfig extends Config @@ -207,6 +209,17 @@ public interface RuneLiteConfig extends Config return false; } + @ConfigItem( + keyName = "clientFont", + name = "Font", + description = "Configure what font is used for the client and runelite added overlays", + position = 29 + ) + default Font clientFont() + { + return FontManager.getRunescapeFont(); + } + @ConfigItem( keyName = "fontType", name = "Dynamic Overlay Font", diff --git a/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java b/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java index 9c20fb9b8f..96a55f3e86 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java +++ b/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java @@ -288,7 +288,7 @@ public enum AgilityShortcut GOBLIN_VILLAGE_WALL(14, "Wall", new WorldPoint(2925, 3523, 0), TIGHTGAP), CORSAIR_COVE_DUNGEON_PILLAR(15, "Pillar Jump", new WorldPoint(1980, 8996, 0), PILLAR_31809), EDGEVILLE_DUNGEON_MONKEYBARS(15, "Monkey Bars", null, MONKEYBARS_23566), - TROLLHEIM_ROCKS(15, "Rocks", null, new WorldPoint(2838, 3614, 0), ROCKS_3748), // No fixed world map location, but rocks near death plateau have a requirement of 15 + TROLLHEIM_ROCKS(15, "Rocks", null, new WorldPoint(2838, 3614, 0), ROCKS_3748), // No fixed world map location, but rocks near death plateau have a requirement of 15 YANILLE_UNDERWALL_TUNNEL(16, "Underwall Tunnel", new WorldPoint(2574, 3109, 0), HOLE_16520, CASTLE_WALL), YANILLE_WATCHTOWER_TRELLIS(18, "Trellis", null, TRELLIS_20056), COAL_TRUCKS_LOG_BALANCE(20, "Log Balance", new WorldPoint(2598, 3475, 0), LOG_BALANCE_23274), diff --git a/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java b/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java index 6c674c1d14..4e4f9fb847 100644 --- a/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java +++ b/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java @@ -27,28 +27,34 @@ package net.runelite.client.menus; import com.google.common.base.Preconditions; import com.google.common.collect.HashMultimap; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; + import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Pattern; import javax.inject.Inject; import javax.inject.Singleton; -import lombok.AllArgsConstructor; + +import com.google.common.collect.Sets; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.MenuAction; -import static net.runelite.api.MenuAction.GAME_OBJECT_FIRST_OPTION; -import static net.runelite.api.MenuAction.WIDGET_DEFAULT; +import static net.runelite.api.MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET; import net.runelite.api.MenuEntry; import net.runelite.api.NPCDefinition; -import net.runelite.api.events.ClientTick; +import net.runelite.api.events.BeforeRender; import net.runelite.api.events.MenuEntryAdded; +import net.runelite.api.events.MenuOpened; import net.runelite.api.events.MenuOptionClicked; import net.runelite.api.events.NpcActionChanged; import net.runelite.api.events.PlayerMenuOptionClicked; @@ -70,21 +76,9 @@ public class MenuManager private static final int IDX_UPPER = 8; static final Pattern LEVEL_PATTERN = Pattern.compile("\\(level-[0-9]*\\)"); - private static MenuEntry CANCEL() - { - MenuEntry cancel = new MenuEntry(); - cancel.setOption("Cancel"); - cancel.setTarget(""); - cancel.setIdentifier(0); - cancel.setType(MenuAction.CANCEL.getId()); - cancel.setParam0(0); - cancel.setParam1(0); - - return cancel; - } - private final Client client; private final EventBus eventBus; + private final Prioritizer prioritizer; //Maps the indexes that are being used to the menu option. private final Map playerMenuIndexMap = new HashMap<>(); @@ -95,15 +89,21 @@ public class MenuManager private final Set priorityEntries = new HashSet<>(); private final Set currentPriorityEntries = new HashSet<>(); private final Set hiddenEntries = new HashSet<>(); - + private final Set currentHiddenEntries = new HashSet<>(); private final Map swaps = new HashMap<>(); - private EntryTypeMapping originalType; + private final Map currentSwaps = new HashMap<>(); + + private final LinkedHashSet entries = Sets.newLinkedHashSet(); + + private MenuEntry leftClickEntry = null; + private int leftClickType = -1; @Inject private MenuManager(Client client, EventBus eventBus) { this.client = client; this.eventBus = eventBus; + this.prioritizer = new Prioritizer(); } /** @@ -143,6 +143,121 @@ public class MenuManager return false; } + @Subscribe + public void onMenuOpened(MenuOpened event) + { + currentPriorityEntries.clear(); + currentHiddenEntries.clear(); + + // Need to reorder the list to normal, then rebuild with swaps + MenuEntry[] oldEntries = event.getMenuEntries(); + + for (MenuEntry entry : oldEntries) + { + if (entry == leftClickEntry) + { + entry.setType(leftClickType); + break; + } + } + + leftClickEntry = null; + leftClickType = -1; + + client.sortMenuEntries(); + + List newEntries = Lists.newArrayList(oldEntries); + + boolean shouldDeprioritize = false; + + prioritizer: for (MenuEntry entry : oldEntries) + { + // Remove hidden entries from menus + for (ComparableEntry p : hiddenEntries) + { + if (p.matches(entry)) + { + newEntries.remove(entry); + continue prioritizer; + } + } + + for (ComparableEntry p : priorityEntries) + { + // Create list of priority entries, and remove from menus + if (p.matches(entry)) + { + // Other entries need to be deprioritized if their types are lower than 1000 + if (entry.getType() >= 1000 && !shouldDeprioritize) + { + shouldDeprioritize = true; + } + currentPriorityEntries.add(entry); + newEntries.remove(entry); + continue prioritizer; + } + } + + if (newEntries.size() > 0) + { + // Swap first matching entry to top + for (ComparableEntry src : swaps.keySet()) + { + if (!src.matches(entry)) + { + continue; + } + + MenuEntry swapFrom = null; + + ComparableEntry from = swaps.get(src); + + for (MenuEntry e : newEntries) + { + if (from.matches(e)) + { + swapFrom = e; + break; + } + } + + // Do not need to swap with itself + if (swapFrom != null && swapFrom != entry) + { + // Deprioritize entries if the swaps are not in similar type groups + if ((swapFrom.getType() >= 1000 && entry.getType() < 1000) || (entry.getType() >= 1000 && swapFrom.getType() < 1000) && !shouldDeprioritize) + { + shouldDeprioritize = true; + } + + int indexFrom = newEntries.indexOf(swapFrom); + int indexTo = newEntries.indexOf(entry); + + Collections.swap(newEntries, indexFrom, indexTo); + } + } + } + } + + if (shouldDeprioritize) + { + for (MenuEntry entry : newEntries) + { + if (entry.getType() <= MENU_ACTION_DEPRIORITIZE_OFFSET) + { + entry.setType(entry.getType() + MENU_ACTION_DEPRIORITIZE_OFFSET); + } + } + } + + if (!priorityEntries.isEmpty()) + { + newEntries.addAll(currentPriorityEntries); + } + + event.setMenuEntries(newEntries.toArray(new MenuEntry[0])); + } + @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { @@ -167,116 +282,78 @@ public class MenuManager } } + + @Subscribe - private void onClientTick(ClientTick event) + public void onBeforeRender(BeforeRender event) { - originalType = null; + leftClickEntry = null; + leftClickType = -1; + + if (client.isMenuOpen()) + { + return; + } + + entries.clear(); + + entries.addAll(Arrays.asList(client.getMenuEntries())); + + if (entries.size() < 2) + { + return; + } + currentPriorityEntries.clear(); - client.sortMenuEntries(); + currentHiddenEntries.clear(); + currentSwaps.clear(); - MenuEntry[] oldEntries = client.getMenuEntries(); - List newEntries = Lists.newArrayList(oldEntries); + prioritizer.prioritize(); - for (MenuEntry entry : oldEntries) + while (prioritizer.isRunning()) { - for (ComparableEntry p : priorityEntries) + // wait + } + + entries.removeAll(currentHiddenEntries); + + + for (MenuEntry entry : currentPriorityEntries) + { + if (entries.contains(entry)) { - if (p.matches(entry)) - { - currentPriorityEntries.add(entry); - } - } - - // If there are entries we want to prioritize, we have to remove the rest - if (!currentPriorityEntries.isEmpty() && !client.isMenuOpen()) - { - newEntries.retainAll(currentPriorityEntries); - - // This is because players existing changes walk-here target - // so without this we lose track of em - if (newEntries.size() != currentPriorityEntries.size()) - { - for (MenuEntry e : currentPriorityEntries) - { - if (newEntries.contains(e)) - { - continue; - } - - for (MenuEntry e2 : client.getMenuEntries()) - { - if (e.getType() == e2.getType()) - { - e.setTarget(e2.getTarget()); - newEntries.add(e); - } - } - } - } - } - - boolean isHidden = false; - for (ComparableEntry p : hiddenEntries) - { - if (p.matches(entry)) - { - isHidden = true; - break; - } - } - - if (isHidden) - { - newEntries.remove(entry); + leftClickEntry = entry; + leftClickType = entry.getType(); + entries.remove(leftClickEntry); + leftClickEntry.setType(MenuAction.WIDGET_DEFAULT.getId()); + entries.add(leftClickEntry); + break; } } - if (!currentPriorityEntries.isEmpty() && !client.isMenuOpen()) + + if (leftClickEntry == null) { - newEntries.add(0, CANCEL()); - } + MenuEntry first = Iterables.getLast(entries); - MenuEntry leftClickEntry = newEntries.get(newEntries.size() - 1); - - for (ComparableEntry src : swaps.keySet()) - { - if (!src.matches(leftClickEntry)) + for (ComparableEntry swap : currentSwaps.keySet()) { - continue; - } - - ComparableEntry tgt = swaps.get(src); - - for (int i = newEntries.size() - 2; i > 0; i--) - { - MenuEntry e = newEntries.get(i); - - if (tgt.matches(e)) + if (swap.matches(first)) { - newEntries.set(newEntries.size() - 1, e); - newEntries.set(i, leftClickEntry); - - int type = e.getType(); - - if (type >= 1000) - { - int newType = getLeftClickType(type); - if (newType != -1 && newType != type) - { - MenuEntry original = MenuEntry.copy(e); - e.setType(newType); - originalType = new EntryTypeMapping(new ComparableEntry(leftClickEntry), original); - } - } - + leftClickEntry = currentSwaps.get(swap); + leftClickType = leftClickEntry.getType(); + entries.remove(leftClickEntry); + leftClickEntry.setType(MenuAction.WIDGET_DEFAULT.getId()); + entries.add(leftClickEntry); break; } } } - client.setMenuEntries(newEntries.toArray(new MenuEntry[0])); + client.setMenuEntries(entries.toArray(new MenuEntry[0])); } + public void addPlayerMenuItem(String menuText) { Preconditions.checkNotNull(menuText); @@ -338,24 +415,6 @@ public class MenuManager } } - private int getLeftClickType(int oldType) - { - if (oldType > 2000) - { - oldType -= 2000; - } - - switch (MenuAction.of(oldType)) - { - case GAME_OBJECT_FIFTH_OPTION: - return GAME_OBJECT_FIRST_OPTION.getId(); - case EXAMINE_ITEM_BANK_EQ: - return WIDGET_DEFAULT.getId(); - default: - return oldType; - } - } - private void addNpcOption(NPCDefinition composition, String npcOption) { String[] actions = composition.getActions(); @@ -399,21 +458,11 @@ public class MenuManager @Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { - // Type is changed in check - if (originalType != null && originalType.check(event)) + if (leftClickEntry != null && leftClickType != -1) { - event.consume(); - - client.invokeMenuAction( - event.getActionParam0(), - event.getActionParam1(), - event.getType(), - event.getIdentifier(), - "do not edit", - event.getTarget(), - client.getMouseCanvasPosition().getX(), - client.getMouseCanvasPosition().getY() - ); + leftClickEntry.setType(leftClickType); + event.setMenuEntry(leftClickEntry); + leftClickEntry = null; } if (event.getMenuAction() != MenuAction.RUNELITE) @@ -740,23 +789,115 @@ public class MenuManager hiddenEntries.remove(entry); } - @AllArgsConstructor - private class EntryTypeMapping + private class Prioritizer { - private final ComparableEntry comparable; - private final MenuEntry target; + private MenuEntry[] entries; + private AtomicInteger state = new AtomicInteger(0); - private boolean check(MenuOptionClicked event) + boolean isRunning() { - MenuEntry entry = event.getMenuEntry(); + return state.get() != 0; + } - if (event.getTarget().equals("do not edit") || !comparable.matches(entry)) + void prioritize() + { + if (state.get() != 0) { - return false; + return; } - event.setMenuEntry(target); - return true; + entries = client.getMenuEntries(); + + state.set(3); + + if (!hiddenEntries.isEmpty()) + { + hiddenFinder.run(); + } + else + { + state.decrementAndGet(); + } + + if (!priorityEntries.isEmpty()) + { + priorityFinder.run(); + } + else + { + state.decrementAndGet(); + } + + if (!swaps.isEmpty()) + { + swapFinder.run(); + } + else + { + state.decrementAndGet(); + } } + + private Thread hiddenFinder = new Thread() + { + @Override + public void run() + { + Arrays.stream(entries).parallel().forEach(entry -> + { + for (ComparableEntry p : hiddenEntries) + { + if (p.matches(entry)) + { + currentHiddenEntries.add(entry); + return; + } + } + }); + state.decrementAndGet(); + } + }; + + private Thread priorityFinder = new Thread() + { + @Override + public void run() + { + Arrays.stream(entries).parallel().forEach(entry -> + { + for (ComparableEntry p : priorityEntries) + { + if (p.matches(entry)) + { + currentPriorityEntries.add(entry); + return; + } + } + }); + + state.decrementAndGet(); + } + }; + + private Thread swapFinder = new Thread() + { + @Override + public void run() + { + Arrays.stream(entries).parallel().forEach(entry -> + { + for (Map.Entry p : swaps.entrySet()) + { + if (p.getValue().matches(entry)) + { + currentSwaps.put(p.getKey(), entry); + return; + } + } + }); + + state.decrementAndGet(); + } + }; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrotherSlainOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrotherSlainOverlay.java index 58760d7c96..a72d2dfccf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrotherSlainOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrotherSlainOverlay.java @@ -84,7 +84,7 @@ public class BarrowsBrotherSlainOverlay extends Overlay { final boolean brotherSlain = client.getVar(brother.getKilledVarbit()) > 0; String slain = brotherSlain ? "\u2713" : "\u2717"; - tableComponent.addRow(brother.getName(), ColorUtil.prependColorTag(slain, brotherSlain ? Color.RED : Color.GREEN)); + tableComponent.addRow(brother.getName(), ColorUtil.prependColorTag(slain, brotherSlain ? Color.GREEN : Color.RED)); } float rewardPercent = client.getVar(Varbits.BARROWS_REWARD_POTENTIAL) / 10.0f; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationConfig.java index 32e8481c7c..b0c4a1f580 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationConfig.java @@ -9,11 +9,11 @@ public interface ChatTranslationConfig extends Config { @ConfigItem( - keyName = "translateOptionVisable", - name = "Show 'Translate' menu option", - description = "Adds 'Translate' to the right-click menu in the Chatbox.", - position = 0, - group = "Public Chat Translation" + keyName = "translateOptionVisable", + name = "Show 'Translate' menu option", + description = "Adds 'Translate' to the right-click menu in the Chatbox.", + position = 0, + group = "Chat Translation" ) default boolean translateOptionVisable() { @@ -21,13 +21,13 @@ public interface ChatTranslationConfig extends Config } @ConfigItem( - keyName = "publicChat", - name = "Translate incoming Messages", - description = "Would you like to Translate Public Chat?", - position = 1, - group = "Public Chat Translation", - hidden = true, - unhide = "translateOptionVisable" + keyName = "publicChat", + name = "Translate incoming Messages", + description = "Would you like to Translate Chat?", + position = 1, + group = "Chat Translation", + hidden = true, + unhide = "translateOptionVisable" ) default boolean publicChat() { @@ -35,13 +35,13 @@ public interface ChatTranslationConfig extends Config } @ConfigItem( - keyName = "playerNames", - name = "Translated Player list:", - description = "Players you add to this list will be Translated in Public chat.", - position = 2, - group = "Public Chat Translation", - hidden = true, - unhide = "translateOptionVisable" + keyName = "playerNames", + name = "Translated Player list:", + description = "Players you add to this list will be Translated in chat.", + position = 2, + group = "Chat Translation", + hidden = true, + unhide = "translateOptionVisable" ) default String getPlayerNames() { @@ -49,13 +49,13 @@ public interface ChatTranslationConfig extends Config } @ConfigItem( - keyName = "publicTargetLanguage", - name = "Target Language", - description = "Language to translate messages too.", - position = 2, - group = "Public Chat Translation", - hidden = true, - unhide = "publicChat" + keyName = "publicTargetLanguage", + name = "Target Language", + description = "Language to translate messages too.", + position = 2, + group = "Chat Translation", + hidden = true, + unhide = "publicChat" ) default Languages publicTargetLanguage() { @@ -63,11 +63,11 @@ public interface ChatTranslationConfig extends Config } @ConfigItem( - keyName = "playerChat", - name = "Translate outgoing Messages", - description = "Would you like to Translate your Messages?", - position = 3, - group = "Player Message Translation" + keyName = "playerChat", + name = "Translate outgoing Messages", + description = "Would you like to Translate your Messages?", + position = 3, + group = "Player Message Translation" ) default boolean playerChat() { @@ -75,13 +75,13 @@ public interface ChatTranslationConfig extends Config } @ConfigItem( - keyName = "playerTargetLanguage", - name = "Target Language", - description = "Language to translate messages too.", - position = 4, - group = "Player Message Translation", - hidden = true, - unhide = "playerChat" + keyName = "playerTargetLanguage", + name = "Target Language", + description = "Language to translate messages too.", + position = 4, + group = "Player Message Translation", + hidden = true, + unhide = "playerChat" ) default Languages playerTargetLanguage() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationPlugin.java index 65668483e2..034dfa2647 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationPlugin.java @@ -29,10 +29,10 @@ import java.awt.event.KeyEvent; import java.util.ArrayList; @PluginDescriptor( - name = "Chat Translator", - description = "Translates messages from one Language to another.", - tags = {"translate", "language", "english", "spanish", "dutch", "french"}, - type = PluginType.UTILITY + name = "Chat Translator", + description = "Translates messages from one Language to another.", + tags = {"translate", "language", "english", "spanish", "dutch", "french"}, + type = PluginType.UTILITY ) public class ChatTranslationPlugin extends Plugin implements KeyListener { @@ -180,6 +180,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener { case PUBLICCHAT: case MODCHAT: + case FRIENDSCHAT: if (!config.publicChat()) { return; @@ -237,11 +238,24 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener { if (event.getKeyCode() == 0xA) { - event.consume(); - Translator translator = new Translator(); String message = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT); + if (message.startsWith("/")) + { + try + { + client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translator.translate("auto", config.playerTargetLanguage().toString(), message)); + } + catch (Exception e) + { + e.printStackTrace(); + } + return; + } + + event.consume(); + try { //Automatically check language of message and translate to selected language. diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java index b1bd8ddbc2..742decdd0d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java @@ -36,8 +36,10 @@ import java.awt.Rectangle; import java.awt.geom.Area; import java.awt.image.BufferedImage; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.stream.Stream; import javax.inject.Inject; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -98,7 +100,6 @@ import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.components.TextComponent; import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager; import net.runelite.client.util.ImageUtil; -import net.runelite.client.util.ItemUtil; import net.runelite.client.util.Text; @PluginDescriptor( @@ -225,9 +226,9 @@ public class ClueScrollPlugin extends Plugin @Subscribe public void onMenuOptionClicked(final MenuOptionClicked event) { - if (event.getOption() != null && event.getOption().equals("Read")) + if (event.getMenuAction() != null && event.getMenuAction().equals("Read")) { - final ItemDefinition itemComposition = itemManager.getItemDefinition(event.getIdentifier()); + final ItemDefinition itemComposition = itemManager.getItemDefinition(event.hashCode()); if (itemComposition != null && itemComposition.getName().startsWith("Clue scroll")) { @@ -256,8 +257,10 @@ public class ClueScrollPlugin extends Plugin // Check if item was removed from inventory if (clue != null && clueItemId != null) { + final Stream items = Arrays.stream(event.getItemContainer().getItems()); + // Check if clue was removed from inventory - if (!ItemUtil.containsItemId(event.getItemContainer().getItems(), clueItemId)) + if (items.noneMatch(item -> itemManager.getItemDefinition(item.getId()).getId() == clueItemId)) { resetClue(true); } @@ -761,7 +764,7 @@ public class ClueScrollPlugin extends Plugin textComponent.render(graphics); } - void scrollToWidget(WidgetInfo list, WidgetInfo scrollbar, Widget... toHighlight) + void scrollToWidget(WidgetInfo list, WidgetInfo scrollbar, Widget ... toHighlight) { final Widget parent = client.getWidget(list); int averageCentralY = 0; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java index 1289bf9dc4..a8b59775e5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java @@ -267,12 +267,12 @@ public class AnagramClue extends ClueScroll implements TextClueScroll, NpcClueSc @Override public String[] getNpcs() { - return new String[]{npc}; + return new String[] {npc}; } @Override public int[] getObjectIds() { - return new int[]{objectId}; + return new int[] {objectId}; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CipherClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CipherClue.java index a4aa491c32..404ce70eae 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CipherClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CipherClue.java @@ -133,6 +133,6 @@ public class CipherClue extends ClueScroll implements TextClueScroll, NpcClueScr public String[] getNpcs() { - return new String[]{npc}; + return new String[] {npc}; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java index 3d71281cd7..18124aae0d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java @@ -116,7 +116,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc new CrypticClue("Probably filled with wizards socks.", "Wizard", DRAWERS_350, new WorldPoint(3116, 9562, 0), "Search the drawers in the basement of the Wizard's Tower south of Draynor Village. Kill one of the Wizards for the key. Fairy ring DIS"), new CrypticClue("Even the seers say this clue goes right over their heads.", CRATE_14934, new WorldPoint(2707, 3488, 2), "Search the crate on the Seers Agility Course in Seers Village"), new CrypticClue("Speak to a Wyse man.", "Wyson the gardener", new WorldPoint(3026, 3378, 0), "Talk to Wyson the gardener at Falador Park."), - new CrypticClue("You'll need to look for a town with a central fountain. Look for a locked chest in the town's chapel.", "Monk", CLOSED_CHEST_5108, new WorldPoint(3256, 3487, 0), "Search the chest by the stairs in the Varrock church. Kill a Monk in Ardougne Monastery to obtain the key."), + new CrypticClue("You'll need to look for a town with a central fountain. Look for a locked chest in the town's chapel.", "Monk" , CLOSED_CHEST_5108, new WorldPoint(3256, 3487, 0), "Search the chest by the stairs in the Varrock church. Kill a Monk in Ardougne Monastery to obtain the key."), new CrypticClue("Talk to Ambassador Spanfipple in the White Knights Castle.", "Ambassador Spanfipple", new WorldPoint(2979, 3340, 0), "Ambassador Spanfipple can be found roaming on the first floor of the White Knights Castle."), new CrypticClue("Mine was the strangest birth under the sun. I left the crimson sack, yet life had not begun. Entered the world, and yet was seen by none.", new WorldPoint(2832, 9586, 0), "Inside Karamja Volcano, dig directly underneath the Red spiders' eggs respawn."), new CrypticClue("Search for a crate in Varrock Castle.", CRATE_5113, new WorldPoint(3224, 3492, 0), "Search the crate in the corner of the kitchen in Varrock Castle."), @@ -202,7 +202,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc new CrypticClue("Search the drawers on the first floor of a building overlooking Ardougne's Market.", DRAWERS_352, new WorldPoint(2657, 3322, 1), "Climb the ladder in the house north of the market."), new CrypticClue("'A bag belt only?', he asked his balding brothers.", "Abbot Langley", new WorldPoint(3058, 3487, 0), "Talk-to Abbot Langley in Monastery west of Edgeville"), new CrypticClue("Search the drawers upstairs in Falador's shield shop.", DRAWERS, new WorldPoint(2971, 3386, 1), "Cassie's Shield Shop at the northern Falador entrance."), - new CrypticClue("Go to this building to be illuminated, and check the drawers while you are there.", "Market Guard", DRAWERS_350, new WorldPoint(2512, 3641, 1), "Search the drawers in the first floor of the Lighthouse. Kill a Rellekka marketplace guard to obtain the key."), + new CrypticClue("Go to this building to be illuminated, and check the drawers while you are there.", "Market Guard", DRAWERS_350 , new WorldPoint(2512, 3641, 1), "Search the drawers in the first floor of the Lighthouse. Kill a Rellekka marketplace guard to obtain the key."), new CrypticClue("Dig near some giant mushrooms, behind the Grand Tree.", new WorldPoint(2458, 3504, 0), "Dig near the red mushrooms northwest of the Grand Tree."), new CrypticClue("Pentagrams and demons, burnt bones and remains, I wonder what the blood contains.", new WorldPoint(3297, 3890, 0), "Dig under the blood rune spawn next the the Demonic Ruins."), new CrypticClue("Search the drawers above Varrock's shops.", DRAWERS_7194, new WorldPoint(3206, 3419, 1), "Located upstairs in Thessalia's Fine Clothes shop in Varrock."), @@ -428,7 +428,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc for (TileObject gameObject : plugin.getObjectsToMark()) { OverlayUtil.renderHoverableArea(graphics, gameObject.getClickbox(), mousePosition, - CLICKBOX_FILL_COLOR, CLICKBOX_BORDER_COLOR, CLICKBOX_HOVER_BORDER_COLOR); + CLICKBOX_FILL_COLOR, CLICKBOX_BORDER_COLOR, CLICKBOX_HOVER_BORDER_COLOR); OverlayUtil.renderImageLocation(plugin.getClient(), graphics, gameObject.getLocalLocation(), plugin.getClueScrollImage(), IMAGE_Z_OFFSET); } @@ -452,12 +452,12 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc @Override public int[] getObjectIds() { - return new int[]{objectId}; + return new int[] {objectId}; } @Override public String[] getNpcs() { - return new String[]{npc}; + return new String[] {npc}; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/FaloTheBardClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/FaloTheBardClue.java index 001a2e0947..1770e06423 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/FaloTheBardClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/FaloTheBardClue.java @@ -184,7 +184,7 @@ public class FaloTheBardClue extends ClueScroll implements TextClueScroll, NpcCl @Override public String[] getNpcs() { - return new String[]{FALO_THE_BARD}; + return new String[] {FALO_THE_BARD}; } public static FaloTheBardClue forText(String text) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java index 8136d00117..5fad4e4207 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java @@ -322,7 +322,6 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat { isBeginner = false; } - else { log.warn("Hot cold solver could not be initialized, clue type is unknown; text: {}, npc: {}, solution: {}", @@ -345,6 +344,6 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat public String[] getNpcs() { - return new String[]{npc}; + return new String[] {npc}; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/MapClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/MapClue.java index 0d1793d656..e3b6a3d098 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/MapClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/MapClue.java @@ -204,6 +204,6 @@ public class MapClue extends ClueScroll implements ObjectClueScroll public int[] getObjectIds() { - return new int[]{objectId}; + return new int[] {objectId}; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/MusicClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/MusicClue.java index ad552f841f..6ed7ce176f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/MusicClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/MusicClue.java @@ -91,7 +91,7 @@ public class MusicClue extends ClueScroll implements NpcClueScroll @Override public String[] getNpcs() { - return new String[]{CECILIA}; + return new String[] {CECILIA}; } public static MusicClue forText(String text) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/ThreeStepCrypticClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/ThreeStepCrypticClue.java index 34d036ae5a..ae9a1bdf7f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/ThreeStepCrypticClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/ThreeStepCrypticClue.java @@ -28,12 +28,15 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.util.AbstractMap; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import lombok.Getter; import lombok.RequiredArgsConstructor; import net.runelite.api.Client; import net.runelite.api.InventoryID; +import net.runelite.api.Item; import static net.runelite.api.ItemID.TORN_CLUE_SCROLL_PART_1; import static net.runelite.api.ItemID.TORN_CLUE_SCROLL_PART_2; import static net.runelite.api.ItemID.TORN_CLUE_SCROLL_PART_3; @@ -45,7 +48,6 @@ import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin; import net.runelite.client.ui.overlay.components.LineComponent; import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TitleComponent; -import net.runelite.client.util.ItemUtil; import net.runelite.client.util.Text; @Getter @@ -125,19 +127,21 @@ public class ThreeStepCrypticClue extends ClueScroll implements TextClueScroll, if (event.getItemContainer() == client.getItemContainer(InventoryID.INVENTORY)) { boolean success = false; - success |= checkForPart(event, TORN_CLUE_SCROLL_PART_1, 0); - success |= checkForPart(event, TORN_CLUE_SCROLL_PART_2, 1); - success |= checkForPart(event, TORN_CLUE_SCROLL_PART_3, 2); + success |= checkForPart(event, itemManager, TORN_CLUE_SCROLL_PART_1, 0); + success |= checkForPart(event, itemManager, TORN_CLUE_SCROLL_PART_2, 1); + success |= checkForPart(event, itemManager, TORN_CLUE_SCROLL_PART_3, 2); return success; } return false; } - private boolean checkForPart(final ItemContainerChanged event, int clueScrollPart, int index) + private boolean checkForPart(final ItemContainerChanged event, ItemManager itemManager, int clueScrollPart, int index) { + final Stream items = Arrays.stream(event.getItemContainer().getItems()); + // If we have the part then that step is done - if (ItemUtil.containsItemId(event.getItemContainer().getItems(), clueScrollPart)) + if (items.anyMatch(item -> itemManager.getItemDefinition(item.getId()).getId() == clueScrollPart)) { final Map.Entry entry = clueSteps.get(index); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/emote/Emote.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/emote/Emote.java index 3110fab866..67019d58d0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/emote/Emote.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/emote/Emote.java @@ -25,33 +25,7 @@ package net.runelite.client.plugins.cluescrolls.clues.emote; import lombok.Getter; -import static net.runelite.api.SpriteID.EMOTE_ANGRY; -import static net.runelite.api.SpriteID.EMOTE_BECKON; -import static net.runelite.api.SpriteID.EMOTE_BLOW_KISS; -import static net.runelite.api.SpriteID.EMOTE_BOW; -import static net.runelite.api.SpriteID.EMOTE_CHEER; -import static net.runelite.api.SpriteID.EMOTE_CLAP; -import static net.runelite.api.SpriteID.EMOTE_CRY; -import static net.runelite.api.SpriteID.EMOTE_DANCE; -import static net.runelite.api.SpriteID.EMOTE_FLAP; -import static net.runelite.api.SpriteID.EMOTE_GOBLIN_SALUTE; -import static net.runelite.api.SpriteID.EMOTE_HEADBANG; -import static net.runelite.api.SpriteID.EMOTE_JIG; -import static net.runelite.api.SpriteID.EMOTE_JUMP_FOR_JOY; -import static net.runelite.api.SpriteID.EMOTE_LAUGH; -import static net.runelite.api.SpriteID.EMOTE_NO; -import static net.runelite.api.SpriteID.EMOTE_PANIC; -import static net.runelite.api.SpriteID.EMOTE_PUSH_UP; -import static net.runelite.api.SpriteID.EMOTE_RASPBERRY; -import static net.runelite.api.SpriteID.EMOTE_SALUTE; -import static net.runelite.api.SpriteID.EMOTE_SHRUG; -import static net.runelite.api.SpriteID.EMOTE_SLAP_HEAD; -import static net.runelite.api.SpriteID.EMOTE_SPIN; -import static net.runelite.api.SpriteID.EMOTE_STOMP; -import static net.runelite.api.SpriteID.EMOTE_THINK; -import static net.runelite.api.SpriteID.EMOTE_WAVE; -import static net.runelite.api.SpriteID.EMOTE_YAWN; -import static net.runelite.api.SpriteID.EMOTE_YES; +import static net.runelite.api.SpriteID.*; @Getter public enum Emote diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java index 4a4aec4bb8..b80d912bc4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java @@ -33,6 +33,7 @@ import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Insets; import java.awt.Rectangle; +import java.awt.Font; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; @@ -99,6 +100,7 @@ import net.runelite.client.plugins.PluginManager; import net.runelite.client.plugins.PluginType; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.DynamicGridLayout; +import net.runelite.client.ui.FontManager; import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.components.ComboBoxListRenderer; import net.runelite.client.ui.components.IconButton; @@ -999,6 +1001,36 @@ public class ConfigPanel extends PluginPanel item.add(button, BorderLayout.EAST); } + if (cid.getType() == Font.class) + { + JComboBox box = new JComboBox(FontManager.getAvailableFontNames()); + box.setPreferredSize(new Dimension(150, 25)); + box.setRenderer(new ComboBoxListRenderer()); + box.setForeground(Color.WHITE); + box.setFocusable(false); + String currentlyConfigured = configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName()); + if (FontManager.lookupFont(currentlyConfigured) != null) + { + box.setSelectedItem(currentlyConfigured); + box.setToolTipText(currentlyConfigured); + } + else + { + log.debug("Selected font wasn't found on this system, resetting font back to runescape regular"); + configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), FontManager.getRunescapeFont()); + } + box.addItemListener(e -> + { + if (e.getStateChange() == ItemEvent.SELECTED && box.getSelectedItem() != null) + { + final Font selected = FontManager.lookupFont(box.getSelectedItem().toString()); + configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), selected); + box.setToolTipText(box.getSelectedItem().toString()); + } + }); + item.add(box, BorderLayout.EAST); + } + mainPanel.add(item); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpDamageOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpDamageOverlay.java index abc6d7578e..f76feec525 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpDamageOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpDamageOverlay.java @@ -43,8 +43,10 @@ import net.runelite.client.ui.overlay.OverlayMenuEntry; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.components.ComponentConstants; -import net.runelite.client.ui.overlay.components.LineComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.table.TableAlignment; +import net.runelite.client.ui.overlay.components.table.TableComponent; +import net.runelite.client.util.ColorUtil; class CorpDamageOverlay extends Overlay { @@ -90,6 +92,8 @@ class CorpDamageOverlay extends Overlay int damageForKill = players != 0 ? totalDamage / players : 0; panelComponent.getChildren().clear(); + TableComponent tableComponent = new TableComponent(); + tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT); NPC core = corpPlugin.getCore(); if (core != null) @@ -114,27 +118,17 @@ class CorpDamageOverlay extends Overlay int textWidth = Math.max(ComponentConstants.STANDARD_WIDTH, fontMetrics.stringWidth(text)); panelComponent.setPreferredSize(new Dimension(textWidth, 0)); - panelComponent.getChildren().add(LineComponent.builder() - .left(text) - .leftColor(Color.RED) - .build()); + tableComponent.addRow(ColorUtil.prependColorTag(text, Color.RED), ""); } } if (config.showDamage()) { - panelComponent.getChildren().add(LineComponent.builder() - .left("Your damage") - .right(Integer.toString(myDamage)) - .rightColor(damageForKill > 0 && myDamage >= damageForKill ? Color.GREEN : Color.RED) - .build()); - - panelComponent.getChildren().add(LineComponent.builder() - .left("Total damage") - .right(Integer.toString(totalDamage)) - .build()); + tableComponent.addRow("Your damage", ColorUtil.prependColorTag(Integer.toString(myDamage), damageForKill > 0 && myDamage >= damageForKill ? Color.GREEN : Color.RED)); + tableComponent.addRow("Total damage:", Integer.toString(totalDamage)); } + panelComponent.getChildren().add(tableComponent); return panelComponent.render(graphics); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java index a770bf8b85..08e9df8e5b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java @@ -27,7 +27,6 @@ package net.runelite.client.plugins.devtools; import java.awt.Color; import java.awt.Dimension; -import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Polygon; @@ -63,7 +62,6 @@ import net.runelite.api.coords.LocalPoint; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetItem; -import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; @@ -77,7 +75,6 @@ class DevToolsOverlay extends Overlay private static final int ITEM_EMPTY = 6512; private static final int ITEM_FILLED = 20594; - private static final Font FONT = FontManager.getRunescapeFont().deriveFont(Font.BOLD, 16); private static final Color RED = new Color(221, 44, 0); private static final Color GREEN = new Color(0, 200, 83); private static final Color TURQOISE = new Color(0, 200, 157); @@ -115,7 +112,6 @@ class DevToolsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - graphics.setFont(FONT); if (plugin.getPlayers().isActive()) { @@ -398,7 +394,7 @@ class DevToolsOverlay extends Overlay Rectangle2D textBounds = fm.getStringBounds(idText, graphics); int textX = (int) (slotBounds.getX() + (slotBounds.getWidth() / 2) - (textBounds.getWidth() / 2)); - int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (textBounds.getHeight() / 2)); + int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (fm.getHeight() / 2) - fm.getMaxDescent()); graphics.setColor(new Color(255, 255, 255, 65)); graphics.fill(slotBounds); @@ -540,7 +536,7 @@ class DevToolsOverlay extends Overlay Rectangle2D textBounds = fm.getStringBounds(text, graphics); int textX = (int) (bounds.getX() + (bounds.getWidth() / 2) - (textBounds.getWidth() / 2)); - int textY = (int) (bounds.getY() + (bounds.getHeight() / 2) + (textBounds.getHeight() / 2)); + int textY = (int) (bounds.getY() + (bounds.getHeight() / 2) + (fm.getHeight() / 2) - fm.getMaxDescent()); graphics.setColor(Color.BLACK); graphics.drawString(text, textX + 1, textY + 1); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java index ef8454b712..74e75d23df 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java @@ -193,7 +193,7 @@ class VarInspector extends JFrame { lastTick = tick; JLabel header = new JLabel("Tick " + tick); - header.setFont(FontManager.getRunescapeSmallFont()); + header.setFont(FontManager.getSmallFont(getFont())); header.setBorder(new CompoundBorder( BorderFactory.createMatteBorder(0, 0, 1, 0, ColorScheme.LIGHT_GRAY_COLOR), BorderFactory.createEmptyBorder(3, 6, 0, 0) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java index acace3fe33..b6eb858b72 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java @@ -221,14 +221,14 @@ class FeedPanel extends PluginPanel Color darkerForeground = UIManager.getColor("Label.foreground").darker(); JLabel titleLabel = new JLabel(item.getTitle()); - titleLabel.setFont(FontManager.getRunescapeSmallFont()); + titleLabel.setFont(FontManager.getSmallFont(getFont())); titleLabel.setBackground(null); titleLabel.setForeground(darkerForeground); titleLabel.setPreferredSize(new Dimension(CONTENT_WIDTH - TIME_WIDTH, 0)); Duration duration = Duration.between(Instant.ofEpochMilli(item.getTimestamp()), Instant.now()); JLabel timeLabel = new JLabel(durationToString(duration)); - timeLabel.setFont(FontManager.getRunescapeSmallFont()); + timeLabel.setFont(FontManager.getSmallFont(getFont())); timeLabel.setForeground(darkerForeground); titleAndTime.add(titleLabel, BorderLayout.WEST); @@ -237,9 +237,9 @@ class FeedPanel extends PluginPanel JPanel content = new JPanel(new BorderLayout()); content.setBackground(null); - JLabel contentLabel = new JLabel(lineBreakText(item.getContent(), FontManager.getRunescapeSmallFont())); + JLabel contentLabel = new JLabel(lineBreakText(item.getContent(), FontManager.getSmallFont(getFont()))); contentLabel.setBorder(new EmptyBorder(2, 0, 0, 0)); - contentLabel.setFont(FontManager.getRunescapeSmallFont()); + contentLabel.setFont(FontManager.getSmallFont(getFont())); contentLabel.setForeground(darkerForeground); content.add(contentLabel, BorderLayout.CENTER); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeConfig.java index 3d484d381e..b1eb1e212c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeConfig.java @@ -74,4 +74,26 @@ public interface GrandExchangeConfig extends Config { return true; } + + @ConfigItem( + position = 5, + keyName = "showTotal", + name = "Show grand exchange total", + description = "Show grand exchange total" + ) + default boolean showTotal() + { + return true; + } + + @ConfigItem( + position = 6, + keyName = "showExact", + name = "Show exact total value", + description = "Show exact total value" + ) + default boolean showExact() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java index e368e8d5b9..0f2f75b0de 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java @@ -131,11 +131,11 @@ public class GrandExchangeOfferSlot extends JPanel itemName.setForeground(Color.WHITE); itemName.setVerticalAlignment(JLabel.BOTTOM); - itemName.setFont(FontManager.getRunescapeSmallFont()); + itemName.setFont(FontManager.getSmallFont(getFont())); offerInfo.setForeground(ColorScheme.LIGHT_GRAY_COLOR); offerInfo.setVerticalAlignment(JLabel.TOP); - offerInfo.setFont(FontManager.getRunescapeSmallFont()); + offerInfo.setFont(FontManager.getSmallFont(getFont())); JLabel switchFaceViewIcon = new JLabel(); switchFaceViewIcon.setIcon(RIGHT_ARROW_ICON); @@ -162,11 +162,11 @@ public class GrandExchangeOfferSlot extends JPanel itemPrice.setForeground(Color.WHITE); itemPrice.setVerticalAlignment(JLabel.BOTTOM); - itemPrice.setFont(FontManager.getRunescapeSmallFont()); + itemPrice.setFont(FontManager.getSmallFont(getFont())); offerSpent.setForeground(Color.WHITE); offerSpent.setVerticalAlignment(JLabel.TOP); - offerSpent.setFont(FontManager.getRunescapeSmallFont()); + offerSpent.setFont(FontManager.getSmallFont(getFont())); JLabel switchDetailsViewIcon = new JLabel(); switchDetailsViewIcon.setIcon(LEFT_ARROW_ICON); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java index bcdaa20abe..1cec9f64f1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java @@ -58,6 +58,7 @@ import net.runelite.api.events.GameTick; import net.runelite.api.events.GrandExchangeOfferChanged; import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.WidgetLoaded; +import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetID; import net.runelite.api.widgets.WidgetInfo; @@ -428,6 +429,49 @@ public class GrandExchangePlugin extends Plugin } } + @Subscribe + public void onScriptCallbackEvent(ScriptCallbackEvent event) + { + if (!event.getEventName().equals("setGETitle") || !config.showTotal()) + { + return; + } + + long total = 0; + GrandExchangeOffer[] offers = client.getGrandExchangeOffers(); + for (GrandExchangeOffer offer : offers) + { + if (offer != null) + { + total += offer.getPrice() * offer.getTotalQuantity(); + } + } + + if (total == 0L) + { + return; + } + + StringBuilder titleBuilder = new StringBuilder(" ("); + + if (config.showExact()) + { + titleBuilder.append(StackFormatter.formatNumber(total)); + } + else + { + titleBuilder.append(StackFormatter.quantityToStackSize(total)); + } + + titleBuilder.append(')'); + + // Append to title + String[] stringStack = client.getStringStack(); + int stringStackSize = client.getStringStackSize(); + + stringStack[stringStackSize - 1] += titleBuilder.toString(); + } + @Subscribe public void onGameTick(GameTick event) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java index 60b984f66d..3d6fae9bd7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.grounditems; import java.awt.Color; +import net.runelite.client.config.Alpha; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; @@ -57,6 +58,7 @@ public interface GroundItemsConfig extends Config position = 2, parent = "colorsStub" ) + @Alpha default Color defaultColor() { return Color.WHITE; @@ -69,6 +71,7 @@ public interface GroundItemsConfig extends Config position = 3, parent = "colorsStub" ) + @Alpha default Color highlightedColor() { return Color.decode("#AA00FF"); @@ -81,6 +84,7 @@ public interface GroundItemsConfig extends Config position = 4, parent = "colorsStub" ) + @Alpha default Color hiddenColor() { return Color.GRAY; @@ -319,6 +323,7 @@ public interface GroundItemsConfig extends Config position = 23, parent = "lowValueStub" ) + @Alpha default Color lowValueColor() { return Color.decode("#66B2FF"); @@ -366,6 +371,7 @@ public interface GroundItemsConfig extends Config position = 27, parent = "mediumValueStub" ) + @Alpha default Color mediumValueColor() { return Color.decode("#99FF99"); @@ -413,6 +419,7 @@ public interface GroundItemsConfig extends Config position = 31, parent = "highValueStub" ) + @Alpha default Color highValueColor() { return Color.decode("#FF9600"); @@ -460,6 +467,7 @@ public interface GroundItemsConfig extends Config position = 35, parent = "insaneValueStub" ) + @Alpha default Color insaneValueColor() { return Color.decode("#FF66B2"); @@ -618,4 +626,16 @@ public interface GroundItemsConfig extends Config { return false; } + + @Alpha + @ConfigItem( + keyName = "bordercolor", + name = "Border color", + description = "Change the border color", + position = 49 + ) + default Color bordercolor() + { + return new Color(0, 0, 0, 150); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java index 09ad99417c..f9ce93dad6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java @@ -109,8 +109,6 @@ public class GroundItemsOverlay extends Overlay { return null; } - - final FontMetrics fm = graphics.getFontMetrics(); final Player player = client.getLocalPlayer(); if (player == null || client.getViewportWidget() == null) @@ -118,6 +116,8 @@ public class GroundItemsOverlay extends Overlay return null; } + final FontMetrics fm = graphics.getFontMetrics(); + offsetMap.clear(); final LocalPoint localLocation = player.getLocalLocation(); final Point mousePos = client.getMouseCanvasPosition(); @@ -319,14 +319,14 @@ public class GroundItemsOverlay extends Overlay // Item bounds int x = textX - 2; - int y = textY - stringHeight - 2; + int y = textY - stringHeight - 2 + fm.getMaxDescent(); int width = stringWidth + 4; int height = stringHeight + 4; final Rectangle itemBounds = new Rectangle(x, y, width, height); // Hidden box x += width + 2; - y = textY - (RECTANGLE_SIZE + stringHeight) / 2; + y = textY - (fm.getMaxAscent() + RECTANGLE_SIZE) / 2; width = height = RECTANGLE_SIZE; final Rectangle itemHiddenBox = new Rectangle(x, y, width, height); @@ -376,7 +376,8 @@ public class GroundItemsOverlay extends Overlay if (config.toggleOutline()) { - graphics.setColor(Color.BLACK); + final Color bordercolor = config.bordercolor(); + graphics.setColor(bordercolor); graphics.drawString(itemString, textX + 1, textY + 1); graphics.drawString(itemString, textX - 1, textY - 1); graphics.drawString(itemString, textX - 1, textY + 1); @@ -388,7 +389,6 @@ public class GroundItemsOverlay extends Overlay textComponent.setPosition(new java.awt.Point(textX, textY)); textComponent.render(graphics); } - return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index 41c24e5c0a..0754a4616f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -124,6 +124,7 @@ public class GroundItemsPlugin extends Plugin private static final int EXAMINE_ITEM = MenuAction.EXAMINE_ITEM_GROUND.getId(); private static final int WALK = MenuAction.WALK.getId(); + @Getter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE) private Map.Entry textBoxBounds; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java index c667fca463..cf2de858e9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java @@ -295,7 +295,7 @@ public class HiscorePanel extends PluginPanel private JPanel makeSkillPanel(HiscoreSkill skill) { JLabel label = new JLabel(); - label.setFont(FontManager.getRunescapeSmallFont()); + label.setFont(FontManager.getSmallFont(getFont())); label.setText("--"); String skillName = (skill == null ? "combat" : skill.getName().toLowerCase()); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java index 43a4b09437..c3157b9b85 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java @@ -115,7 +115,7 @@ public class InfoPanel extends PluginPanel versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); versionPanel.setLayout(new GridLayout(0, 1)); - final Font smallFont = FontManager.getRunescapeSmallFont(); + final Font smallFont = FontManager.getSmallFont(getFont()); JLabel version = new JLabel(htmlLabel("RuneLite version: ", runeLiteProperties.getVersion())); version.setFont(smallFont); @@ -191,7 +191,7 @@ public class InfoPanel extends PluginPanel /** * Builds a link panel with a given icon, text and url to redirect to. */ - private static JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, String url) + private JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, String url) { return buildLinkPanel(icon, topText, bottomText, () -> LinkBrowser.browse(url)); } @@ -199,7 +199,7 @@ public class InfoPanel extends PluginPanel /** * Builds a link panel with a given icon, text and callable to call. */ - private static JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, Runnable callback) + private JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, Runnable callback) { JPanel container = new JPanel(); container.setBackground(ColorScheme.DARKER_GRAY_COLOR); @@ -253,11 +253,11 @@ public class InfoPanel extends PluginPanel JLabel topLine = new JLabel(topText); topLine.setForeground(Color.WHITE); - topLine.setFont(FontManager.getRunescapeSmallFont()); + topLine.setFont(FontManager.getSmallFont(getFont())); JLabel bottomLine = new JLabel(bottomText); bottomLine.setForeground(Color.WHITE); - bottomLine.setFont(FontManager.getRunescapeSmallFont()); + bottomLine.setFont(FontManager.getSmallFont(getFont())); textContainer.add(topLine); textContainer.add(bottomLine); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridConfig.java index 33c6868c4d..9eefb67cee 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridConfig.java @@ -24,6 +24,8 @@ */ package net.runelite.client.plugins.inventorygrid; +import java.awt.Color; +import net.runelite.client.config.Alpha; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; @@ -35,7 +37,8 @@ public interface InventoryGridConfig extends Config @ConfigItem( keyName = "showItem", name = "Show item", - description = "Show a preview of the item in the new slot" + description = "Show a preview of the item in the new slot", + position = 1 ) default boolean showItem() { @@ -45,7 +48,8 @@ public interface InventoryGridConfig extends Config @ConfigItem( keyName = "showGrid", name = "Show grid", - description = "Show a grid on the inventory while dragging" + description = "Show a grid on the inventory while dragging", + position = 2 ) default boolean showGrid() { @@ -55,7 +59,8 @@ public interface InventoryGridConfig extends Config @ConfigItem( keyName = "showHighlight", name = "Highlight background", - description = "Show a green background highlight on the new slot" + description = "Show a background highlight on the new slot", + position = 3 ) default boolean showHighlight() { @@ -65,11 +70,36 @@ public interface InventoryGridConfig extends Config @ConfigItem( keyName = "dragDelay", name = "Drag Delay", - description = "Time in ms to wait after item press before showing grid" + description = "Time in ms to wait after item press before showing grid", + position = 4 ) @Range(min = 100) default int dragDelay() { return 100; } + + @Alpha + @ConfigItem( + keyName = "gridColor", + name = "Grid color", + description = "The color of the grid", + position = 5 + ) + default Color gridColor() + { + return new Color(255, 255, 255, 45); + } + + @Alpha + @ConfigItem( + keyName = "highlightColor", + name = "Highlight color", + description = "The color of the new inventory slot highlight", + position = 6 + ) + default Color highlightColor() + { + return new Color(0, 255, 0, 45); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridOverlay.java index e7395f299d..f9f66e10b8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridOverlay.java @@ -27,7 +27,6 @@ package net.runelite.client.plugins.inventorygrid; import com.google.inject.Inject; import java.awt.AlphaComposite; -import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Point; @@ -47,9 +46,6 @@ class InventoryGridOverlay extends Overlay { private static final int INVENTORY_SIZE = 28; - private static final Color HIGHLIGHT = new Color(0, 255, 0, 45); - private static final Color GRID = new Color(255, 255, 255, 45); - private final InventoryGridConfig config; private final Client client; private final ItemManager itemManager; @@ -101,12 +97,12 @@ class InventoryGridOverlay extends Overlay if (config.showHighlight() && inBounds) { - graphics.setColor(HIGHLIGHT); + graphics.setColor(config.highlightColor()); graphics.fill(bounds); } else if (config.showGrid()) { - graphics.setColor(GRID); + graphics.setColor(config.gridColor()); graphics.fill(bounds); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java index a822cf74a8..18b9d6386b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java @@ -173,10 +173,10 @@ public interface ItemChargeConfig extends Config } @ConfigItem( - keyName = "showBellowCharges", - name = "Show Bellow Charges", - description = "Configures if ogre bellow item charge is shown", - position = 12 + keyName = "showBellowCharges", + name = "Show Bellow Charges", + description = "Configures if ogre bellow item charge is shown", + position = 12 ) default boolean showBellowCharges() { @@ -184,32 +184,10 @@ public interface ItemChargeConfig extends Config } @ConfigItem( - keyName = "showBasketCharges", - name = "Show Basket Charges", - description = "Configures if fruit basket item charge is shown", - position = 13 - ) - default boolean showBasketCharges() - { - return true; - } - - @ConfigItem( - keyName = "showSackCharges", - name = "Show Sack Charges", - description = "Configures if sack item charge is shown", - position = 14 - ) - default boolean showSackCharges() - { - return true; - } - - @ConfigItem( - keyName = "showAbyssalBraceletCharges", - name = "Show Abyssal Bracelet Charges", - description = "Configures if abyssal bracelet item charge is shown", - position = 15 + keyName = "showAbyssalBraceletCharges", + name = "Show Abyssal Bracelet Charges", + description = "Configures if abyssal bracelet item charge is shown", + position = 13 ) default boolean showAbyssalBraceletCharges() { @@ -220,7 +198,7 @@ public interface ItemChargeConfig extends Config keyName = "recoilNotification", name = "Ring of Recoil Notification", description = "Configures if the ring of recoil breaking notification is shown", - position = 16 + position = 14 ) default boolean recoilNotification() { @@ -231,7 +209,7 @@ public interface ItemChargeConfig extends Config keyName = "showBindingNecklaceCharges", name = "Show Binding Necklace Charges", description = "Configures if binding necklace item charge is shown", - position = 17 + position = 15 ) default boolean showBindingNecklaceCharges() { @@ -260,7 +238,7 @@ public interface ItemChargeConfig extends Config keyName = "bindingNotification", name = "Binding Necklace Notification", description = "Configures if the binding necklace breaking notification is shown", - position = 18 + position = 16 ) default boolean bindingNotification() { @@ -271,7 +249,7 @@ public interface ItemChargeConfig extends Config keyName = "showExplorerRingCharges", name = "Show Explorer's Ring Alch Charges", description = "Configures if explorer's ring alchemy charges are shown", - position = 19 + position = 17 ) default boolean showExplorerRingCharges() { @@ -300,7 +278,7 @@ public interface ItemChargeConfig extends Config keyName = "showInfoboxes", name = "Show Infoboxes", description = "Configures whether to show an infobox equipped charge items", - position = 20 + position = 18 ) default boolean showInfoboxes() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java index ec140e2749..31db7daad1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java @@ -38,8 +38,6 @@ import static net.runelite.client.plugins.itemcharges.ItemChargeType.IMPBOX; import static net.runelite.client.plugins.itemcharges.ItemChargeType.TELEPORT; import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN; import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.FRUIT_BASKET; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.SACK; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.WidgetItemOverlay; import net.runelite.client.ui.overlay.components.TextComponent; @@ -154,8 +152,6 @@ class ItemChargeOverlay extends WidgetItemOverlay || (type == WATERCAN && !config.showWateringCanCharges()) || (type == WATERSKIN && !config.showWaterskinCharges()) || (type == BELLOWS && !config.showBellowCharges()) - || (type == FRUIT_BASKET && !config.showBasketCharges()) - || (type == SACK && !config.showSackCharges()) || (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges())) { return; @@ -166,7 +162,7 @@ class ItemChargeOverlay extends WidgetItemOverlay final Rectangle bounds = itemWidget.getCanvasBounds(); final TextComponent textComponent = new TextComponent(); - textComponent.setPosition(new Point(bounds.x - 1, bounds.y + 15)); + textComponent.setPosition(new Point(bounds.x, bounds.y + 1 + graphics.getFontMetrics().getMaxAscent() - graphics.getFontMetrics().getMaxDescent())); textComponent.setText(charges < 0 ? "?" : String.valueOf(charges)); textComponent.setColor(itemChargePlugin.getColor(charges)); textComponent.render(graphics); @@ -176,7 +172,6 @@ class ItemChargeOverlay extends WidgetItemOverlay { return config.showTeleportCharges() || config.showDodgyCount() || config.showFungicideCharges() || config.showImpCharges() || config.showWateringCanCharges() || config.showWaterskinCharges() - || config.showBellowCharges() || config.showBasketCharges() || config.showSackCharges() - || config.showAbyssalBraceletCharges() || config.showExplorerRingCharges(); + || config.showBellowCharges() || config.showAbyssalBraceletCharges() || config.showExplorerRingCharges(); } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java index e219bae493..3d131aec20 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java @@ -37,7 +37,5 @@ enum ItemChargeType BRACELET_OF_SLAUGHTER, EXPEDITIOUS_BRACELET, BINDING_NECKLACE, - EXPLORER_RING, - FRUIT_BASKET, - SACK + EXPLORER_RING } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java index 9e3113b85c..2f2fe76469 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java @@ -29,8 +29,133 @@ import java.util.Map; import javax.annotation.Nullable; import lombok.AllArgsConstructor; import lombok.Getter; - -import static net.runelite.api.ItemID.*; +import static net.runelite.api.ItemID.ABYSSAL_BRACELET1; +import static net.runelite.api.ItemID.ABYSSAL_BRACELET2; +import static net.runelite.api.ItemID.ABYSSAL_BRACELET3; +import static net.runelite.api.ItemID.ABYSSAL_BRACELET4; +import static net.runelite.api.ItemID.ABYSSAL_BRACELET5; +import static net.runelite.api.ItemID.AMULET_OF_GLORY1; +import static net.runelite.api.ItemID.AMULET_OF_GLORY2; +import static net.runelite.api.ItemID.AMULET_OF_GLORY3; +import static net.runelite.api.ItemID.AMULET_OF_GLORY4; +import static net.runelite.api.ItemID.AMULET_OF_GLORY5; +import static net.runelite.api.ItemID.AMULET_OF_GLORY6; +import static net.runelite.api.ItemID.AMULET_OF_GLORY_T1; +import static net.runelite.api.ItemID.AMULET_OF_GLORY_T2; +import static net.runelite.api.ItemID.AMULET_OF_GLORY_T3; +import static net.runelite.api.ItemID.AMULET_OF_GLORY_T4; +import static net.runelite.api.ItemID.AMULET_OF_GLORY_T5; +import static net.runelite.api.ItemID.AMULET_OF_GLORY_T6; +import static net.runelite.api.ItemID.BURNING_AMULET1; +import static net.runelite.api.ItemID.BURNING_AMULET2; +import static net.runelite.api.ItemID.BURNING_AMULET3; +import static net.runelite.api.ItemID.BURNING_AMULET4; +import static net.runelite.api.ItemID.BURNING_AMULET5; +import static net.runelite.api.ItemID.COMBAT_BRACELET1; +import static net.runelite.api.ItemID.COMBAT_BRACELET2; +import static net.runelite.api.ItemID.COMBAT_BRACELET3; +import static net.runelite.api.ItemID.COMBAT_BRACELET4; +import static net.runelite.api.ItemID.COMBAT_BRACELET5; +import static net.runelite.api.ItemID.COMBAT_BRACELET6; +import static net.runelite.api.ItemID.DIGSITE_PENDANT_1; +import static net.runelite.api.ItemID.DIGSITE_PENDANT_2; +import static net.runelite.api.ItemID.DIGSITE_PENDANT_3; +import static net.runelite.api.ItemID.DIGSITE_PENDANT_4; +import static net.runelite.api.ItemID.DIGSITE_PENDANT_5; +import static net.runelite.api.ItemID.ENCHANTED_LYRE1; +import static net.runelite.api.ItemID.ENCHANTED_LYRE2; +import static net.runelite.api.ItemID.ENCHANTED_LYRE3; +import static net.runelite.api.ItemID.ENCHANTED_LYRE4; +import static net.runelite.api.ItemID.ENCHANTED_LYRE5; +import static net.runelite.api.ItemID.FUNGICIDE_SPRAY_0; +import static net.runelite.api.ItemID.FUNGICIDE_SPRAY_1; +import static net.runelite.api.ItemID.FUNGICIDE_SPRAY_10; +import static net.runelite.api.ItemID.FUNGICIDE_SPRAY_2; +import static net.runelite.api.ItemID.FUNGICIDE_SPRAY_3; +import static net.runelite.api.ItemID.FUNGICIDE_SPRAY_4; +import static net.runelite.api.ItemID.FUNGICIDE_SPRAY_5; +import static net.runelite.api.ItemID.FUNGICIDE_SPRAY_6; +import static net.runelite.api.ItemID.FUNGICIDE_SPRAY_7; +import static net.runelite.api.ItemID.FUNGICIDE_SPRAY_8; +import static net.runelite.api.ItemID.FUNGICIDE_SPRAY_9; +import static net.runelite.api.ItemID.GAMES_NECKLACE1; +import static net.runelite.api.ItemID.GAMES_NECKLACE2; +import static net.runelite.api.ItemID.GAMES_NECKLACE3; +import static net.runelite.api.ItemID.GAMES_NECKLACE4; +import static net.runelite.api.ItemID.GAMES_NECKLACE5; +import static net.runelite.api.ItemID.GAMES_NECKLACE6; +import static net.runelite.api.ItemID.GAMES_NECKLACE7; +import static net.runelite.api.ItemID.GAMES_NECKLACE8; +import static net.runelite.api.ItemID.IMPINABOX1; +import static net.runelite.api.ItemID.IMPINABOX2; +import static net.runelite.api.ItemID.NECKLACE_OF_PASSAGE1; +import static net.runelite.api.ItemID.NECKLACE_OF_PASSAGE2; +import static net.runelite.api.ItemID.NECKLACE_OF_PASSAGE3; +import static net.runelite.api.ItemID.NECKLACE_OF_PASSAGE4; +import static net.runelite.api.ItemID.NECKLACE_OF_PASSAGE5; +import static net.runelite.api.ItemID.OGRE_BELLOWS; +import static net.runelite.api.ItemID.OGRE_BELLOWS_1; +import static net.runelite.api.ItemID.OGRE_BELLOWS_2; +import static net.runelite.api.ItemID.OGRE_BELLOWS_3; +import static net.runelite.api.ItemID.PHARAOHS_SCEPTRE_1; +import static net.runelite.api.ItemID.PHARAOHS_SCEPTRE_2; +import static net.runelite.api.ItemID.PHARAOHS_SCEPTRE_3; +import static net.runelite.api.ItemID.PHARAOHS_SCEPTRE_4; +import static net.runelite.api.ItemID.PHARAOHS_SCEPTRE_5; +import static net.runelite.api.ItemID.PHARAOHS_SCEPTRE_6; +import static net.runelite.api.ItemID.PHARAOHS_SCEPTRE_7; +import static net.runelite.api.ItemID.PHARAOHS_SCEPTRE_8; +import static net.runelite.api.ItemID.RING_OF_DUELING1; +import static net.runelite.api.ItemID.RING_OF_DUELING2; +import static net.runelite.api.ItemID.RING_OF_DUELING3; +import static net.runelite.api.ItemID.RING_OF_DUELING4; +import static net.runelite.api.ItemID.RING_OF_DUELING5; +import static net.runelite.api.ItemID.RING_OF_DUELING6; +import static net.runelite.api.ItemID.RING_OF_DUELING7; +import static net.runelite.api.ItemID.RING_OF_DUELING8; +import static net.runelite.api.ItemID.RING_OF_RETURNING1; +import static net.runelite.api.ItemID.RING_OF_RETURNING2; +import static net.runelite.api.ItemID.RING_OF_RETURNING3; +import static net.runelite.api.ItemID.RING_OF_RETURNING4; +import static net.runelite.api.ItemID.RING_OF_RETURNING5; +import static net.runelite.api.ItemID.RING_OF_WEALTH_1; +import static net.runelite.api.ItemID.RING_OF_WEALTH_2; +import static net.runelite.api.ItemID.RING_OF_WEALTH_3; +import static net.runelite.api.ItemID.RING_OF_WEALTH_4; +import static net.runelite.api.ItemID.RING_OF_WEALTH_5; +import static net.runelite.api.ItemID.SKILLS_NECKLACE1; +import static net.runelite.api.ItemID.SKILLS_NECKLACE2; +import static net.runelite.api.ItemID.SKILLS_NECKLACE3; +import static net.runelite.api.ItemID.SKILLS_NECKLACE4; +import static net.runelite.api.ItemID.SKILLS_NECKLACE5; +import static net.runelite.api.ItemID.SKILLS_NECKLACE6; +import static net.runelite.api.ItemID.SLAYER_RING_1; +import static net.runelite.api.ItemID.SLAYER_RING_2; +import static net.runelite.api.ItemID.SLAYER_RING_3; +import static net.runelite.api.ItemID.SLAYER_RING_4; +import static net.runelite.api.ItemID.SLAYER_RING_5; +import static net.runelite.api.ItemID.SLAYER_RING_6; +import static net.runelite.api.ItemID.SLAYER_RING_7; +import static net.runelite.api.ItemID.SLAYER_RING_8; +import static net.runelite.api.ItemID.TELEPORT_CRYSTAL_1; +import static net.runelite.api.ItemID.TELEPORT_CRYSTAL_2; +import static net.runelite.api.ItemID.TELEPORT_CRYSTAL_3; +import static net.runelite.api.ItemID.TELEPORT_CRYSTAL_4; +import static net.runelite.api.ItemID.TELEPORT_CRYSTAL_5; +import static net.runelite.api.ItemID.WATERING_CAN; +import static net.runelite.api.ItemID.WATERING_CAN1; +import static net.runelite.api.ItemID.WATERING_CAN2; +import static net.runelite.api.ItemID.WATERING_CAN3; +import static net.runelite.api.ItemID.WATERING_CAN4; +import static net.runelite.api.ItemID.WATERING_CAN5; +import static net.runelite.api.ItemID.WATERING_CAN6; +import static net.runelite.api.ItemID.WATERING_CAN7; +import static net.runelite.api.ItemID.WATERING_CAN8; +import static net.runelite.api.ItemID.WATERSKIN0; +import static net.runelite.api.ItemID.WATERSKIN1; +import static net.runelite.api.ItemID.WATERSKIN2; +import static net.runelite.api.ItemID.WATERSKIN3; +import static net.runelite.api.ItemID.WATERSKIN4; import static net.runelite.client.plugins.itemcharges.ItemChargeType.ABYSSAL_BRACELET; import static net.runelite.client.plugins.itemcharges.ItemChargeType.BELLOWS; import static net.runelite.client.plugins.itemcharges.ItemChargeType.FUNGICIDE_SPRAY; @@ -38,8 +163,6 @@ import static net.runelite.client.plugins.itemcharges.ItemChargeType.IMPBOX; import static net.runelite.client.plugins.itemcharges.ItemChargeType.TELEPORT; import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN; import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.FRUIT_BASKET; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.SACK; @AllArgsConstructor @Getter @@ -50,31 +173,6 @@ enum ItemWithCharge ABRACE3(ABYSSAL_BRACELET, ABYSSAL_BRACELET3, 3), ABRACE4(ABYSSAL_BRACELET, ABYSSAL_BRACELET4, 4), ABRACE5(ABYSSAL_BRACELET, ABYSSAL_BRACELET5, 5), - BASKET_APPLES1(FRUIT_BASKET, APPLES1, 1), - BASKET_APPLES2(FRUIT_BASKET, APPLES2, 2), - BASKET_APPLES3(FRUIT_BASKET, APPLES3, 3), - BASKET_APPLES4(FRUIT_BASKET, APPLES4, 4), - BASKET_APPLES5(FRUIT_BASKET, APPLES5, 5), - BASKET_BANANAS1(FRUIT_BASKET, BANANAS1, 1), - BASKET_BANANAS2(FRUIT_BASKET, BANANAS2, 2), - BASKET_BANANAS3(FRUIT_BASKET, BANANAS3, 3), - BASKET_BANANAS4(FRUIT_BASKET, BANANAS4, 4), - BASKET_BANANAS5(FRUIT_BASKET, BANANAS5, 5), - BASKET_ORANGES1(FRUIT_BASKET, ORANGES1, 1), - BASKET_ORANGES2(FRUIT_BASKET, ORANGES2, 2), - BASKET_ORANGES3(FRUIT_BASKET, ORANGES3, 3), - BASKET_ORANGES4(FRUIT_BASKET, ORANGES4, 4), - BASKET_ORANGES5(FRUIT_BASKET, ORANGES5, 5), - BASKET_STRAWBERRIES1(FRUIT_BASKET, STRAWBERRIES1, 1), - BASKET_STRAWBERRIES2(FRUIT_BASKET, STRAWBERRIES2, 2), - BASKET_STRAWBERRIES3(FRUIT_BASKET, STRAWBERRIES3, 3), - BASKET_STRAWBERRIES4(FRUIT_BASKET, STRAWBERRIES4, 4), - BASKET_STRAWBERRIES5(FRUIT_BASKET, STRAWBERRIES5, 5), - BASKET_TOMATOES1(FRUIT_BASKET, TOMATOES1, 1), - BASKET_TOMATOES2(FRUIT_BASKET, TOMATOES2, 2), - BASKET_TOMATOES3(FRUIT_BASKET, TOMATOES3, 3), - BASKET_TOMATOES4(FRUIT_BASKET, TOMATOES4, 4), - BASKET_TOMATOES5(FRUIT_BASKET, TOMATOES5, 5), BELLOWS0(BELLOWS, OGRE_BELLOWS, 0), BELLOWS1(BELLOWS, OGRE_BELLOWS_1, 1), BELLOWS2(BELLOWS, OGRE_BELLOWS_2, 2), @@ -172,36 +270,6 @@ enum ItemWithCharge ROW3(TELEPORT, RING_OF_WEALTH_3, 3), ROW4(TELEPORT, RING_OF_WEALTH_4, 4), ROW5(TELEPORT, RING_OF_WEALTH_5, 5), - SACK_CABBAGES1(SACK, CABBAGES1, 1), - SACK_CABBAGES2(SACK, CABBAGES2, 2), - SACK_CABBAGES3(SACK, CABBAGES3, 3), - SACK_CABBAGES4(SACK, CABBAGES4, 4), - SACK_CABBAGES5(SACK, CABBAGES5, 5), - SACK_CABBAGES6(SACK, CABBAGES6, 6), - SACK_CABBAGES7(SACK, CABBAGES7, 7), - SACK_CABBAGES8(SACK, CABBAGES8, 8), - SACK_CABBAGES9(SACK, CABBAGES9, 9), - SACK_CABBAGES10(SACK, CABBAGES10, 10), - SACK_ONIONS1(SACK, ONIONS1, 1), - SACK_ONIONS2(SACK, ONIONS2, 2), - SACK_ONIONS3(SACK, ONIONS3, 3), - SACK_ONIONS4(SACK, ONIONS4, 4), - SACK_ONIONS5(SACK, ONIONS5, 5), - SACK_ONIONS6(SACK, ONIONS6, 6), - SACK_ONIONS7(SACK, ONIONS7, 7), - SACK_ONIONS8(SACK, ONIONS8, 8), - SACK_ONIONS9(SACK, ONIONS9, 9), - SACK_ONIONS10(SACK, ONIONS10, 10), - SACK_POTATOES1(SACK, POTATOES1, 1), - SACK_POTATOES2(SACK, POTATOES2, 2), - SACK_POTATOES3(SACK, POTATOES3, 3), - SACK_POTATOES4(SACK, POTATOES4, 4), - SACK_POTATOES5(SACK, POTATOES5, 5), - SACK_POTATOES6(SACK, POTATOES6, 6), - SACK_POTATOES7(SACK, POTATOES7, 7), - SACK_POTATOES8(SACK, POTATOES8, 8), - SACK_POTATOES9(SACK, POTATOES9, 9), - SACK_POTATOES10(SACK, POTATOES10, 10), SKILLS1(TELEPORT, SKILLS_NECKLACE1, 1), SKILLS2(TELEPORT, SKILLS_NECKLACE2, 2), SKILLS3(TELEPORT, SKILLS_NECKLACE3, 3), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java index a82cee5814..29976bc0bb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java @@ -47,7 +47,7 @@ class BookPanel extends JPanel JLabel image = new JLabel(); b.getIcon().addTo(image); JLabel name = new JLabel(b.getShortName()); - location.setFont(FontManager.getRunescapeSmallFont()); + location.setFont(FontManager.getSmallFont(getFont())); layout.setVerticalGroup(layout.createParallelGroup() .addComponent(image) diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/BeginnerHotColdLocationTest.java b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerConfig.java similarity index 56% rename from runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/BeginnerHotColdLocationTest.java rename to runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerConfig.java index d67a00b989..6f216c47df 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/BeginnerHotColdLocationTest.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Jordan Atwood + * Copyright (c) 2019, gazivodag * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -10,7 +10,6 @@ * 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 @@ -22,29 +21,49 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.cluescrolls.clues.hotcold; -import java.util.Arrays; -import java.util.Set; -import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +package net.runelite.client.plugins.lootingbagviewer; -public class BeginnerHotColdLocationTest +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.Stub; + +@ConfigGroup("lootingbagviewer") +public interface LootingBagViewerConfig extends Config { - private static final Set BEGINNER_HOT_COLD_LOCATIONS = Arrays.stream(HotColdLocation.values()) - .filter(HotColdLocation::isBeginnerClue) - .collect(Collectors.toSet()); - private static final int EXPECTED_DIMENSION_SIZE = 7; - - @Test - public void beginnerHotColdLocationAreaTest() + @ConfigItem( + keyName = "overlayStub", + name = "Overlays", + description = "", + position = 0 + ) + default Stub overlayStub() { + return new Stub(); + } - for (final HotColdLocation location : BEGINNER_HOT_COLD_LOCATIONS) - { - assertEquals(EXPECTED_DIMENSION_SIZE, location.getRect().height); - assertEquals(EXPECTED_DIMENSION_SIZE, location.getRect().width); - } + @ConfigItem( + keyName = "renderViewer", + name = "Render Viewer", + description = "Shows second inventory on screen with looting bag items.", + position = 1, + parent = "overlayStub" + ) + default boolean renderViewer() + { + return true; + } + + @ConfigItem( + keyName = "renderLootingBag", + name = "Render Looting Bag Worth", + description = "Shows current amount of GP over the looting bag.", + position = 2, + parent = "overlayStub" + ) + default boolean renderLootingBag() + { + return true; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java index aea700c292..69563ab2c4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2018 AWPH-I + * Copyright (c) 2019, gazivodag * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,37 +26,150 @@ package net.runelite.client.plugins.lootingbagviewer; +import com.google.common.base.Strings; +import com.google.inject.Provides; import javax.inject.Inject; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.WidgetHiddenChanged; +import net.runelite.api.widgets.Widget; +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 net.runelite.client.ui.overlay.OverlayManager; @PluginDescriptor( - name = "PvP Looting Bag Viewer", - description = "Add an overlay showing the contents of your looting bag", - tags = {"alternate", "items", "overlay", "second"}, - type = PluginType.PVP, - enabledByDefault = false + name = "PvP Looting Bag Viewer", + description = "Add an overlay showing the contents of your looting bag", + tags = {"alternate", "items", "overlay", "second"}, + type = PluginType.PVP, + enabledByDefault = false ) - +/** + * TODO: Remember current looting bag value when client restarts + * TODO: Write an event for picking up an item (with opened looting bag) and add its price to the current looting bag value + * TODO: Write something to capture adding items to a looting bag and add its price to the current looting bag value + */ +@Slf4j public class LootingBagViewerPlugin extends Plugin { @Inject - private net.runelite.client.plugins.lootingbagviewer.LootingBagViewerOverlay overlay; + private Client client; + + @Inject + private ClientThread clientThread; + + @Inject + private LootingBagViewerOverlay overlay; + + @Inject + private LootingBagViewerWidgetOverlay widgetOverlay; @Inject private OverlayManager overlayManager; + @Inject + private LootingBagViewerConfig config; + + @Getter + @Setter + private int valueToShow = -1; + + @Provides + LootingBagViewerConfig getConfig(ConfigManager configManager) + { + return configManager.getConfig(LootingBagViewerConfig.class); + } + @Override public void startUp() { - overlayManager.add(overlay); + if (config.renderViewer()) + { + overlayManager.add(overlay); + } + + if (config.renderLootingBag()) + { + overlayManager.add(widgetOverlay); + } } @Override public void shutDown() { overlayManager.remove(overlay); + overlayManager.remove(widgetOverlay); } + + @Subscribe + public void onConfigChanged(ConfigChanged configChanged) + { + if (configChanged.getKey().equals("renderViewer")) + { + if (Boolean.parseBoolean(configChanged.getNewValue())) + { + overlayManager.add(overlay); + } + else + { + overlayManager.remove(overlay); + } + } + if (configChanged.getKey().equals("renderLootingBag")) + { + if (Boolean.parseBoolean(configChanged.getNewValue())) + { + overlayManager.add(widgetOverlay); + } + else + { + overlayManager.remove(widgetOverlay); + } + } + } + + + /** + * @param widgetHiddenChanged + */ + @Subscribe + public void onWidgetHiddenChanged(WidgetHiddenChanged widgetHiddenChanged) + { + Widget widget = widgetHiddenChanged.getWidget(); + if (widget.getParentId() == 5308416 && !widget.isHidden()) + { + clientThread.invokeLater(() -> + { + Widget value = client.getWidget(81, 6); + log.debug("val: {}", value.getText()); + + if (!Strings.isNullOrEmpty(value.getText())) + { + if (value.getText().equals("Value: -")) + { + setValueToShow(-1); + } + else + { + String str = value.getText(); + str = str.replace("Bag value: ", "") + .replace("Value: ", "") + .replace(" coins", "") + .replace(",", ""); + + int val = Integer.parseInt(str); + setValueToShow(Math.round(val) / 1000); + } + } + }); + } + } + } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerWidgetOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerWidgetOverlay.java new file mode 100644 index 0000000000..00c716f2fb --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerWidgetOverlay.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2019, gazivodag + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.runelite.client.plugins.lootingbagviewer; + +import java.awt.Color; +import java.awt.Graphics2D; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.ItemID; +import net.runelite.api.Point; +import net.runelite.api.widgets.WidgetItem; +import net.runelite.client.ui.overlay.OverlayUtil; +import net.runelite.client.ui.overlay.WidgetItemOverlay; + +public class LootingBagViewerWidgetOverlay extends WidgetItemOverlay +{ + private Client client; + private LootingBagViewerPlugin plugin; + + @Inject + LootingBagViewerWidgetOverlay(Client client, LootingBagViewerPlugin plugin) + { + this.client = client; + this.plugin = plugin; + showOnInventory(); + } + + @Override + public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget) + { + if (plugin.getValueToShow() != -1) + { + switch (itemId) + { + case ItemID.LOOTING_BAG: + case ItemID.LOOTING_BAG_22586: + Point point = new Point(itemWidget.getCanvasLocation().getX() + lineX(plugin.getValueToShow()), itemWidget.getCanvasLocation().getY() + 25); + OverlayUtil.renderTextLocation(graphics, point, (plugin.getValueToShow() + "K"), Color.WHITE); + break; + } + } + } + + /** + * To align 16k (gp) or 4213k (gp) correctly between the looting bag without looking off + * + * @return + */ + private static int lineX(int lootingBagValue) + { + switch ((int) (Math.log10(lootingBagValue) + 1)) + { + case 1: + case 2: + return 8; + case 3: + case 4: + return 6; + default: + return 8; + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java index 0e10bcd1d1..c6596ab2ff 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java @@ -96,12 +96,12 @@ class LootTrackerBox extends JPanel logTitle.setBackground(ColorScheme.DARKER_GRAY_COLOR.darker()); final JLabel titleLabel = new JLabel(Text.removeTags(id)); - titleLabel.setFont(FontManager.getRunescapeSmallFont()); + titleLabel.setFont(FontManager.getSmallFont(getFont())); titleLabel.setForeground(Color.WHITE); logTitle.add(titleLabel, BorderLayout.WEST); - subTitleLabel.setFont(FontManager.getRunescapeSmallFont()); + subTitleLabel.setFont(FontManager.getSmallFont(getFont())); subTitleLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR); logTitle.add(subTitleLabel, BorderLayout.CENTER); @@ -119,7 +119,7 @@ class LootTrackerBox extends JPanel subTitleLabel.setText(subtitle); } - priceLabel.setFont(FontManager.getRunescapeSmallFont()); + priceLabel.setFont(FontManager.getSmallFont(getFont())); priceLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR); logTitle.add(priceLabel, BorderLayout.EAST); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java index b6b7684eeb..c12f095c01 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java @@ -348,8 +348,8 @@ class LootTrackerPanel extends PluginPanel overallInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR); overallInfo.setLayout(new GridLayout(2, 1)); overallInfo.setBorder(new EmptyBorder(2, 10, 2, 0)); - overallKillsLabel.setFont(FontManager.getRunescapeSmallFont()); - overallGpLabel.setFont(FontManager.getRunescapeSmallFont()); + overallKillsLabel.setFont(FontManager.getSmallFont(getFont())); + overallGpLabel.setFont(FontManager.getSmallFont(getFont())); overallInfo.add(overallKillsLabel); overallInfo.add(overallGpLabel); overallPanel.add(overallIcon, BorderLayout.WEST); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java index e90c97acdc..5e2ec78add 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java @@ -1671,7 +1671,8 @@ default CharterOption charterOption() keyName = "removeFreezePlayerToB", name = "Remove freeze in ToB", description = "Removes the freeze option for ice barrage, ice blitz, entangle etc. in ToB", - position = 0 + position = 0, + group = "PVM" ) default boolean getRemoveFreezePlayerToB() @@ -1683,11 +1684,12 @@ default CharterOption charterOption() keyName = "removeFreezePlayerCoX", name = "Remove freeze in CoX", description = "Removes the freeze option for ice barrage, ice blitz, entangle etc. in CoX", - position = 1 + position = 1, + group = "PVM" ) default boolean getRemoveFreezePlayerCoX() { return true; } -} \ No newline at end of file +} 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 f7f04ddef9..4e8490a4c4 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 @@ -1044,10 +1044,21 @@ public class MenuEntrySwapperPlugin extends Plugin swap(client, "stun", option, target, true); } - else if (config.swapTravel() && (option.equals("pass") || option.equals("open"))) + else if (config.swapTravel() && option.equals("pass") && target.equals("energy barrier")) { - swap(client, "pay-toll", option, target, false); + swap(client, "pay-toll(2-ecto)", option, target, true); } + + else if (config.swapTravel() && option.equals("open") && target.equals("gate")) + { + swap(client, "pay-toll(10gp)", option, target, true); + } + + else if (config.swapHardWoodGrove() && option.equals("open") && target.equals("hardwood grove doors")) + { + swap(client, "quick-pay(100)", option, target, true); + } + else if (config.swapTravel() && option.equals("inspect") && target.equals("trapdoor")) { swap(client, "travel", option, target, true); @@ -1160,7 +1171,6 @@ public class MenuEntrySwapperPlugin extends Plugin else if (config.swapQuick() && option.equals("pass")) { swap(client, "quick-pass", option, target, true); - swap(client, "quick pass", option, target, true); } else if (config.swapQuick() && option.equals("open")) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java index 3ce12efcf7..fc673f2784 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java @@ -51,6 +51,7 @@ class MiningOverlay extends Overlay private static final int ORE_VEIN_MIN_RESPAWN_TIME = 90; private static final float ORE_VEIN_RANDOM_PERCENT_THRESHOLD = (float) ORE_VEIN_MIN_RESPAWN_TIME / ORE_VEIN_MAX_RESPAWN_TIME; private static final Color DARK_GREEN = new Color(0, 100, 0); + private static final int MOTHERLODE_UPPER_FLOOR_HEIGHT = -500; private final Client client; private final MiningPlugin plugin; @@ -95,8 +96,17 @@ class MiningOverlay extends Overlay continue; } + Rock rock = rockRespawn.getRock(); + + // Only draw timer for veins on the same level in motherlode mine + LocalPoint localLocation = client.getLocalPlayer().getLocalLocation(); + if (rock == Rock.ORE_VEIN && isUpstairsMotherlode(localLocation) != isUpstairsMotherlode(loc)) + { + continue; + } + // Recolour pie on motherlode veins during the portion of the timer where they may respawn - if (rockRespawn.getRock() == Rock.ORE_VEIN && percent > ORE_VEIN_RANDOM_PERCENT_THRESHOLD) + if (rock == Rock.ORE_VEIN && percent > ORE_VEIN_RANDOM_PERCENT_THRESHOLD) { pieFillColor = Color.GREEN; pieBorderColor = DARK_GREEN; @@ -111,4 +121,19 @@ class MiningOverlay extends Overlay } return null; } + + /** + * Checks if the given point is "upstairs" in the mlm. + * The upper floor is actually on z=0. + * + * This method assumes that the given point is already in the mlm + * and is not meaningful when outside the mlm. + * + * @param localPoint the LocalPoint to be tested + * @return true if localPoint is at same height as mlm upper floor + */ + private boolean isUpstairsMotherlode(LocalPoint localPoint) + { + return Perspective.getTileHeight(client, localPoint, 0) < MOTHERLODE_UPPER_FLOOR_HEIGHT; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAInventoryOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAInventoryOverlay.java index 590b0ff65e..ea99cf7f00 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAInventoryOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAInventoryOverlay.java @@ -51,7 +51,7 @@ public class MTAInventoryOverlay extends Overlay { if (room.inside()) { - graphics.setFont(FontManager.getRunescapeBoldFont()); + graphics.setFont(FontManager.getSmallFont(graphics.getFont())); room.over(graphics); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTASceneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTASceneOverlay.java index 717bd86060..5ed9a7e6b1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTASceneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTASceneOverlay.java @@ -51,7 +51,7 @@ public class MTASceneOverlay extends Overlay { if (room.inside()) { - graphics.setFont(FontManager.getRunescapeFont()); + graphics.setFont(FontManager.getSmallFont(graphics.getFont())); room.under(graphics); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneConfig.java index 227ccf4066..900b73fa62 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneConfig.java @@ -36,13 +36,24 @@ public interface NightmareZoneConfig extends Config keyName = "moveoverlay", name = "Override NMZ overlay", description = "Overrides the overlay so it doesn't conflict with other RuneLite plugins", - position = 1 + position = 0 ) default boolean moveOverlay() { return true; } + @ConfigItem( + keyName = "showtotalpoints", + name = "total points NMZ overlay", + description = "shows total points to overlay", + position = 1 + ) + default boolean showtotalpoints() + { + return false; + } + @ConfigItem( keyName = "powersurgenotification", name = "Power surge notification", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java index c297ce0866..5a0a58e9da 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java @@ -107,7 +107,13 @@ class NightmareZoneOverlay extends Overlay TableComponent tableComponent = new TableComponent(); tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT); tableComponent.addRow("Points:", StackFormatter.formatNumber(client.getVar(Varbits.NMZ_POINTS))); - tableComponent.addRow("Total:", StackFormatter.formatNumber(client.getVar(VarPlayer.NMZ_REWARD_POINTS) + client.getVar(Varbits.NMZ_POINTS))); + + if (config.showtotalpoints()) + { + tableComponent.addRow("Total:", StackFormatter.formatNumber(client.getVar(VarPlayer.NMZ_REWARD_POINTS) + client.getVar(Varbits.NMZ_POINTS))); + } + + panelComponent.getChildren().add(tableComponent); return panelComponent.render(graphics); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java index 63ec966f6d..2e1d0cdfa4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java @@ -584,7 +584,16 @@ public class NpcIndicatorsPlugin extends Plugin if (mn.getDiedOnTick() != -1) { - mn.setRespawnTime(client.getTickCount() + 1 - mn.getDiedOnTick()); + final int respawnTime = client.getTickCount() + 1 - mn.getDiedOnTick(); + + // By killing a monster and leaving the area before seeing it again, an erroneously lengthy + // respawn time can be recorded. Thus, if the respawn time is already set and is greater than + // the observed time, assume that the lower observed respawn time is correct. + if (mn.getRespawnTime() == -1 || respawnTime < mn.getRespawnTime()) + { + mn.setRespawnTime(respawnTime); + } + mn.setDiedOnTick(-1); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java index 18d28da696..5798698621 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java @@ -28,6 +28,7 @@ package net.runelite.client.plugins.prayer; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; +import java.awt.image.BufferedImage; import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.Client; @@ -35,11 +36,13 @@ import net.runelite.api.Perspective; import net.runelite.api.Player; import net.runelite.api.Point; import net.runelite.api.Skill; +import net.runelite.api.SpriteID; import net.runelite.api.coords.LocalPoint; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; +import net.runelite.client.util.ImageUtil; @Singleton class PrayerBarOverlay extends Overlay @@ -48,6 +51,9 @@ class PrayerBarOverlay extends Overlay private static final Color BAR_BG_COLOR = Color.black; private static final Color FLICK_HELP_COLOR = Color.white; private static final Dimension PRAYER_BAR_SIZE = new Dimension(30, 5); + private static final int HD_PRAYER_BAR_PADDING = 1; + private static final BufferedImage HD_FRONT_BAR = ImageUtil.getResourceStreamFromClass(PrayerPlugin.class, "front.png"); + private static final BufferedImage HD_BACK_BAR = ImageUtil.getResourceStreamFromClass(PrayerPlugin.class, "back.png"); private final Client client; private final PrayerConfig config; @@ -79,12 +85,44 @@ class PrayerBarOverlay extends Overlay final LocalPoint localLocation = client.getLocalPlayer().getLocalLocation(); final Point canvasPoint = Perspective.localToCanvas(client, localLocation, client.getPlane(), height); + final float ratio = (float) client.getBoostedSkillLevel(Skill.PRAYER) / client.getRealSkillLevel(Skill.PRAYER); + + // Draw HD bar + if (client.getSpriteOverrides().containsKey(SpriteID.HEALTHBAR_DEFAULT_FRONT_30PX)) + { + final int barWidth = HD_FRONT_BAR.getWidth(); + final int barHeight = HD_FRONT_BAR.getHeight(); + final int barX = canvasPoint.getX() - barWidth / 2; + final int barY = canvasPoint.getY(); + + // Include padding so the bar doesn't show empty at very low prayer values + final int progressFill = (int) Math.ceil(Math.max(HD_PRAYER_BAR_PADDING * 2, Math.min((barWidth * ratio), barWidth))); + + graphics.drawImage(HD_BACK_BAR, barX, barY, barWidth, barHeight, null); + // Use a sub-image to create the same effect the HD Health Bar has + graphics.drawImage(HD_FRONT_BAR.getSubimage(0, 0, progressFill, barHeight), barX, barY, progressFill, barHeight, null); + + if ((plugin.isPrayersActive() || config.prayerFlickAlwaysOn()) + && (config.prayerFlickLocation().equals(PrayerFlickLocation.PRAYER_BAR) + || config.prayerFlickLocation().equals(PrayerFlickLocation.BOTH))) + { + final double t = plugin.getTickProgress(); + final int halfBarWidth = (barWidth / 2) - HD_PRAYER_BAR_PADDING; + + final int xOffset = (int) (-Math.cos(t) * halfBarWidth) + ((barWidth / 2) - halfBarWidth); + + graphics.setColor(FLICK_HELP_COLOR); + graphics.fillRect(barX + xOffset + HD_PRAYER_BAR_PADDING, barY + HD_PRAYER_BAR_PADDING, 1, barHeight - HD_PRAYER_BAR_PADDING * 2); + } + + return new Dimension(barWidth, barHeight); + } + // Draw bar final int barX = canvasPoint.getX() - 15; final int barY = canvasPoint.getY(); final int barWidth = PRAYER_BAR_SIZE.width; final int barHeight = PRAYER_BAR_SIZE.height; - final float ratio = (float) client.getBoostedSkillLevel(Skill.PRAYER) / client.getRealSkillLevel(Skill.PRAYER); // Restricted by the width to prevent the bar from being too long while you are boosted above your real prayer level. final int progressFill = (int) Math.ceil(Math.min((barWidth * ratio), barWidth)); @@ -100,7 +138,7 @@ class PrayerBarOverlay extends Overlay { double t = plugin.getTickProgress(); - int xOffset = (int) (-Math.cos(t) * barWidth / 2) + barWidth / 2; + final int xOffset = (int) (-Math.cos(t) * barWidth / 2) + barWidth / 2; graphics.setColor(FLICK_HELP_COLOR); graphics.fillRect(barX + xOffset, barY, 1, barHeight); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java index 91b4e9c6fa..deec35072a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java @@ -88,6 +88,10 @@ public class RunepouchOverlay extends WidgetItemOverlay Point location = itemWidget.getCanvasLocation(); StringBuilder tooltipBuilder = new StringBuilder(); + // location.getY() + graphics.getFontMetrics().getMaxAscent() - graphics.getFontMetrics().getMaxDescent() + // this will draw the character exactly on the border + int yLocation = location.getY() + 1 + + graphics.getFontMetrics().getMaxAscent() - graphics.getFontMetrics().getMaxDescent(); for (int i = 0; i < AMOUNT_VARBITS.length; i++) { Varbits amountVarbit = AMOUNT_VARBITS[i]; @@ -117,9 +121,18 @@ public class RunepouchOverlay extends WidgetItemOverlay continue; } + // the reason this is not split up in maxascent and maxdescent to equal the height of the text like it should + // be is because numbers (afaik) dont use font descent so a 1 pixel seperator should be good and give + // consistent results across fonts + int yOffset = (1 + (graphics.getFontMetrics().getMaxAscent()) * i); + graphics.setColor(Color.black); + graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 13 : 6), + yLocation + yOffset); + + graphics.setColor(config.fontColor()); graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 12 : 5), - location.getY() + 13 + (graphics.getFontMetrics().getHeight() - 1) * i); + yLocation + yOffset); graphics.setColor(config.fontColor()); graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 11 : 4), @@ -134,7 +147,13 @@ public class RunepouchOverlay extends WidgetItemOverlay if (image != null) { OverlayUtil.renderImageLocation(graphics, - new Point(location.getX() - 1, location.getY() + graphics.getFontMetrics().getHeight() * i - 1), + //TODO :: SEE WHAT ONE IS RIGHT? + //new Point(location.getX() - 1, location.getY() + graphics.getFontMetrics().getMaxAscent() * i - 1), + //image); + //or + //new Point(location.getX(), location.getY() + (1 + graphics.getFontMetrics().getMaxAscent()) * i), + //image); + new Point(location.getX(), location.getY() + (1 + graphics.getFontMetrics().getMaxAscent()) * i), image); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerCreationPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerCreationPanel.java index 51567dd2dc..0ad6b73d4e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerCreationPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerCreationPanel.java @@ -69,7 +69,7 @@ public class ScreenMarkerCreationPanel extends JPanel setBorder(new EmptyBorder(8, 8, 8, 8)); setLayout(new BorderLayout()); - instructionsLabel.setFont(FontManager.getRunescapeSmallFont()); + instructionsLabel.setFont(FontManager.getSmallFont(getFont())); instructionsLabel.setForeground(Color.WHITE); JPanel actionsContainer = new JPanel(new GridLayout(1, 2, 8, 0)); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java index 23b6cad174..e934bff8b8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java @@ -29,8 +29,6 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; @@ -164,14 +162,19 @@ class ScreenMarkerPanel extends JPanel nameActions.setBackground(ColorScheme.DARKER_GRAY_COLOR); save.setVisible(false); - save.setFont(FontManager.getRunescapeSmallFont()); + save.setFont(FontManager.getSmallFont(getFont())); save.setForeground(ColorScheme.PROGRESS_COMPLETE_COLOR); save.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { - save(); + marker.getMarker().setName(nameInput.getText()); + plugin.updateConfig(); + + nameInput.setEditable(false); + updateNameActions(false); + requestFocusInWindow(); } @Override @@ -188,14 +191,17 @@ class ScreenMarkerPanel extends JPanel }); cancel.setVisible(false); - cancel.setFont(FontManager.getRunescapeSmallFont()); + cancel.setFont(FontManager.getSmallFont(getFont())); cancel.setForeground(ColorScheme.PROGRESS_ERROR_COLOR); cancel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { - cancel(); + nameInput.setEditable(false); + nameInput.setText(marker.getMarker().getName()); + updateNameActions(false); + requestFocusInWindow(); } @Override @@ -211,7 +217,7 @@ class ScreenMarkerPanel extends JPanel } }); - rename.setFont(FontManager.getRunescapeSmallFont()); + rename.setFont(FontManager.getSmallFont(getFont())); rename.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker()); rename.addMouseListener(new MouseAdapter() { @@ -246,35 +252,6 @@ class ScreenMarkerPanel extends JPanel nameInput.setPreferredSize(new Dimension(0, 24)); nameInput.getTextField().setForeground(Color.WHITE); nameInput.getTextField().setBorder(new EmptyBorder(0, 8, 0, 0)); - nameInput.addKeyListener(new KeyAdapter() - { - @Override - public void keyPressed(KeyEvent e) - { - if (e.getKeyCode() == KeyEvent.VK_ENTER) - { - save(); - } - else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) - { - cancel(); - } - } - }); - nameInput.getTextField().addMouseListener(new MouseAdapter() - { - @Override - public void mouseEntered(MouseEvent mouseEvent) - { - preview(true); - } - - @Override - public void mouseExited(MouseEvent mouseEvent) - { - preview(false); - } - }); nameWrapper.add(nameInput, BorderLayout.CENTER); nameWrapper.add(nameActions, BorderLayout.EAST); @@ -382,7 +359,10 @@ class ScreenMarkerPanel extends JPanel @Override public void mousePressed(MouseEvent mouseEvent) { - toggle(!visible); + visible = !visible; + marker.getMarker().setVisible(visible); + plugin.updateConfig(); + updateVisibility(); } @Override @@ -444,42 +424,6 @@ class ScreenMarkerPanel extends JPanel } - private void preview(boolean on) - { - if (visible) - { - return; - } - - marker.getMarker().setVisible(on); - } - - private void toggle(boolean on) - { - visible = on; - marker.getMarker().setVisible(visible); - plugin.updateConfig(); - updateVisibility(); - } - - private void save() - { - marker.getMarker().setName(nameInput.getText()); - plugin.updateConfig(); - - nameInput.setEditable(false); - updateNameActions(false); - requestFocusInWindow(); - } - - private void cancel() - { - nameInput.setEditable(false); - nameInput.setText(marker.getMarker().getName()); - updateNameActions(false); - requestFocusInWindow(); - } - private void updateNameActions(boolean saveAndCancel) { save.setVisible(saveAndCancel); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java index 32bda79122..709fdff390 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java @@ -252,7 +252,7 @@ class SkillCalculator extends JPanel JCheckBox uiCheckbox = new JCheckBox(); uiLabel.setForeground(Color.WHITE); - uiLabel.setFont(FontManager.getRunescapeSmallFont()); + uiLabel.setFont(FontManager.getSmallFont(getFont())); uiOption.setBorder(BorderFactory.createEmptyBorder(3, 7, 3, 0)); uiOption.setBackground(ColorScheme.DARKER_GRAY_COLOR); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java index 2051a0ddcd..696fa2dfdc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java @@ -125,7 +125,7 @@ class UIActionSlot extends JPanel uiLabelName.setForeground(Color.WHITE); uiLabelActions = new JShadowedLabel("Unknown"); - uiLabelActions.setFont(FontManager.getRunescapeSmallFont()); + uiLabelActions.setFont(FontManager.getSmallFont(getFont())); uiLabelActions.setForeground(ColorScheme.LIGHT_GRAY_COLOR); uiInfo.add(uiLabelName); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICalculatorInputArea.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICalculatorInputArea.java index 3aa1bff236..b1d9af5665 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICalculatorInputArea.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICalculatorInputArea.java @@ -123,7 +123,7 @@ class UICalculatorInputArea extends JPanel uiInput.setHoverBackgroundColor(ColorScheme.DARK_GRAY_HOVER_COLOR); uiInput.setBorder(new EmptyBorder(5, 7, 5, 7)); - uiLabel.setFont(FontManager.getRunescapeSmallFont()); + uiLabel.setFont(FontManager.getSmallFont(getFont())); uiLabel.setBorder(new EmptyBorder(0, 0, 4, 0)); uiLabel.setForeground(Color.WHITE); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICombinedActionSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICombinedActionSlot.java index fa1614c91b..a6bc9c0d52 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICombinedActionSlot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICombinedActionSlot.java @@ -68,7 +68,7 @@ class UICombinedActionSlot extends JPanel uiLabelTitle.setForeground(Color.WHITE); uiLabelActions = new JShadowedLabel("Shift-click to select multiple"); - uiLabelActions.setFont(FontManager.getRunescapeSmallFont()); + uiLabelActions.setFont(FontManager.getSmallFont(getFont())); uiLabelActions.setForeground(ColorScheme.LIGHT_GRAY_COLOR); uiInfo.add(uiLabelTitle); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java index 0d970b43ea..b27925fade 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java @@ -117,7 +117,7 @@ class SlayerOverlay extends WidgetItemOverlay return; } - graphics.setFont(FontManager.getRunescapeSmallFont()); + graphics.setFont(FontManager.getSmallFont(graphics.getFont())); final Rectangle bounds = itemWidget.getCanvasBounds(); final TextComponent textComponent = new TextComponent(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java index db7048c094..8ddf85f6a9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java @@ -28,6 +28,7 @@ package net.runelite.client.plugins.timers; import com.google.inject.Provides; import java.awt.image.BufferedImage; +import java.util.regex.Pattern; import javax.inject.Inject; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Actor; @@ -126,13 +127,10 @@ public class TimersPlugin extends Plugin private static final String CANNON_REPAIR_MESSAGE = "You repair your cannon, restoring it to working order."; private static final String CHARGE_EXPIRED_MESSAGE = "Your magical charge fades away."; private static final String CHARGE_MESSAGE = "You feel charged with magic power."; - private static final String DEADMAN_HALF_TELEBLOCK_MESSAGE = "A Tele Block spell has been cast on you. It will expire in 1 minute, 15 seconds."; private static final String EXTENDED_ANTIFIRE_DRINK_MESSAGE = "You drink some of your extended antifire potion."; private static final String EXTENDED_SUPER_ANTIFIRE_DRINK_MESSAGE = "You drink some of your extended super antifire potion."; private static final String FROZEN_MESSAGE = "You have been frozen!"; - private static final String FULL_TELEBLOCK_MESSAGE = "A Tele Block spell has been cast on you. It will expire in 5 minutes, 0 seconds."; private static final String GOD_WARS_ALTAR_MESSAGE = "you recharge your prayer."; - private static final String HALF_TELEBLOCK_MESSAGE = "A Tele Block spell has been cast on you. It will expire in 2 minutes, 30 seconds."; private static final String IMBUED_HEART_READY_MESSAGE = "Your imbued heart has regained its magical power."; private static final String IMBUED_HEART_NOTREADY_MESSAGE = "The heart is still drained of its power."; private static final String MAGIC_IMBUE_EXPIRED_MESSAGE = "Your Magic Imbue charge has ended."; @@ -147,6 +145,10 @@ public class TimersPlugin extends Plugin private static final int VENOM_VALUE_CUTOFF = -40; // Antivenom < -40 =< Antipoison < 0 private static final int POISON_TICK_LENGTH = 30; + private static final Pattern DEADMAN_HALF_TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you by (.+). It will expire in 1 minute, 15 seconds."); + private static final Pattern FULL_TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you by (.+). It will expire in 5 minutes, 0 seconds."); + private static final Pattern HALF_TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you by (.+). It will expire in 2 minutes, 30 seconds."); + private TimerTimer freezeTimer; private int freezeTime = -1; // time frozen, in game ticks @@ -537,28 +539,29 @@ public class TimersPlugin extends Plugin removeGameTimer(MAGICIMBUE); } - if (config.showTeleblock() && event.getMessage().equals(FULL_TELEBLOCK_MESSAGE)) + if (config.showTeleblock()) { - createGameTimer(FULLTB); - } - - if (config.showTeleblock() && event.getMessage().equals(HALF_TELEBLOCK_MESSAGE)) - { - if (client.getWorldType().contains(WorldType.DEADMAN) - && !client.getWorldType().contains(WorldType.SEASONAL_DEADMAN) - && !client.getWorldType().contains(WorldType.DEADMAN_TOURNAMENT)) + if (FULL_TELEBLOCK_PATTERN.matcher(event.getMessage()).find()) { - createGameTimer(DMM_FULLTB); + createGameTimer(FULLTB); } - else + else if (HALF_TELEBLOCK_PATTERN.matcher(event.getMessage()).find()) { - createGameTimer(HALFTB); + if (client.getWorldType().contains(WorldType.DEADMAN) + && !client.getWorldType().contains(WorldType.SEASONAL_DEADMAN) + && !client.getWorldType().contains(WorldType.DEADMAN_TOURNAMENT)) + { + createGameTimer(DMM_FULLTB); + } + else + { + createGameTimer(HALFTB); + } + } + else if (DEADMAN_HALF_TELEBLOCK_PATTERN.matcher(event.getMessage()).find()) + { + createGameTimer(DMM_HALFTB); } - } - - if (config.showTeleblock() && event.getMessage().equals(DEADMAN_HALF_TELEBLOCK_MESSAGE)) - { - createGameTimer(DMM_HALFTB); } if (config.showAntiFire() && event.getMessage().contains(SUPER_ANTIFIRE_DRINK_MESSAGE)) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewItemPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewItemPanel.java index 973eec5eaa..c1b8d5a211 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewItemPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewItemPanel.java @@ -106,11 +106,11 @@ class OverviewItemPanel extends JPanel JLabel titleLabel = new JLabel(title); titleLabel.setForeground(Color.WHITE); - titleLabel.setFont(FontManager.getRunescapeSmallFont()); + titleLabel.setFont(FontManager.getSmallFont(getFont())); statusLabel = new JLabel(); statusLabel.setForeground(Color.GRAY); - statusLabel.setFont(FontManager.getRunescapeSmallFont()); + statusLabel.setFont(FontManager.getSmallFont(getFont())); textContainer.add(titleLabel); textContainer.add(statusLabel); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeablePanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeablePanel.java index c01f770063..81693a2ea3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeablePanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeablePanel.java @@ -67,10 +67,10 @@ public class TimeablePanel extends JPanel infoPanel.setBorder(new EmptyBorder(4, 4, 4, 0)); final JLabel location = new JShadowedLabel(title); - location.setFont(FontManager.getRunescapeSmallFont()); + location.setFont(FontManager.getSmallFont(getFont())); location.setForeground(Color.WHITE); - estimate.setFont(FontManager.getRunescapeSmallFont()); + estimate.setFont(FontManager.getSmallFont(getFont())); estimate.setForeground(Color.GRAY); infoPanel.add(location); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/ClockTabPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/ClockTabPanel.java index 79578a3b79..14722f4b4a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/ClockTabPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/ClockTabPanel.java @@ -40,6 +40,7 @@ import net.runelite.client.plugins.timetracking.TimeTrackingPlugin; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.DynamicGridLayout; import net.runelite.client.ui.FontManager; +import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.components.IconButton; import net.runelite.client.ui.components.shadowlabel.JShadowedLabel; import net.runelite.client.util.ImageUtil; @@ -97,6 +98,13 @@ public class ClockTabPanel extends TabContentPanel rebuild(); } + // The max panel width is 225 but the + sign gets cut off at 225 so we set it at 223 + @Override + public Dimension getPreferredSize() + { + return new Dimension(PluginPanel.PANEL_WIDTH - 2, super.getPreferredSize().height); + } + /** * Clears and recreates the components of this panel. * This should be done whenever a clock is added or removed. @@ -147,7 +155,7 @@ public class ClockTabPanel extends TabContentPanel JLabel headerLabel = new JLabel(title); headerLabel.setForeground(Color.WHITE); - headerLabel.setFont(FontManager.getRunescapeSmallFont()); + headerLabel.setFont(FontManager.getSmallFont(getFont())); panel.add(headerLabel, BorderLayout.CENTER); IconButton addButton = new IconButton(ADD_ICON, ADD_ICON_HOVER); @@ -167,7 +175,7 @@ public class ClockTabPanel extends TabContentPanel JLabel infoLabel = new JShadowedLabel(text); infoLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker()); - infoLabel.setFont(FontManager.getRunescapeSmallFont()); + infoLabel.setFont(FontManager.getSmallFont(getFont())); panel.add(infoLabel); return panel; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/StopwatchPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/StopwatchPanel.java index 99bb8def81..bf285be9e9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/StopwatchPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/StopwatchPanel.java @@ -129,7 +129,7 @@ class StopwatchPanel extends ClockPanel private JLabel createSmallLabel(String text) { JLabel label = new JLabel(text, SwingConstants.CENTER); - label.setFont(FontManager.getRunescapeSmallFont()); + label.setFont(FontManager.getSmallFont(getFont())); label.setForeground(LAP_DATA_COLOR); return label; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/farming/FarmingTabPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/farming/FarmingTabPanel.java index 2c262111e2..e4dcf97508 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/farming/FarmingTabPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/farming/FarmingTabPanel.java @@ -94,7 +94,7 @@ public class FarmingTabPanel extends TabContentPanel groupLabel.setBorder(new EmptyBorder(15, 0, 0, 0)); } - groupLabel.setFont(FontManager.getRunescapeSmallFont()); + groupLabel.setFont(FontManager.getSmallFont(getFont())); add(groupLabel, c); c.gridy++; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java index 0dce1c78b5..84abfcf9f5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java @@ -97,7 +97,7 @@ public class WorldHopperPlugin extends Plugin { private static final int WORLD_FETCH_TIMER = 10; private static final int WORLD_PING_TIMER = 10; - private static final int REFRESH_THROTTLE = 60_000; // ms + private static final int REFRESH_THROTTLE = 60_000; // ms private static final int TICK_THROTTLE = (int) Duration.ofMinutes(10).toMillis(); private static final int DISPLAY_SWITCHER_MAX_ATTEMPTS = 3; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableHeader.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableHeader.java index 451351c877..25d0cc9f9a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableHeader.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableHeader.java @@ -102,7 +102,7 @@ class WorldTableHeader extends JPanel }); textLabel.setText(title); - textLabel.setFont(FontManager.getRunescapeSmallFont()); + textLabel.setFont(FontManager.getSmallFont(getFont())); final JMenuItem refresh = new JMenuItem("Refresh worlds"); refresh.addActionListener(e -> diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java index a664d6536c..3133a81a4f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java @@ -271,7 +271,7 @@ class WorldTableRow extends JPanel column.setBorder(new EmptyBorder(0, 5, 0, 5)); playerCountField = new JLabel(world.getPlayers() + ""); - playerCountField.setFont(FontManager.getRunescapeSmallFont()); + playerCountField.setFont(FontManager.getSmallFont(getFont())); column.add(playerCountField, BorderLayout.WEST); @@ -300,7 +300,7 @@ class WorldTableRow extends JPanel column.setBorder(new EmptyBorder(0, 5, 0, 5)); activityField = new JLabel(world.getActivity()); - activityField.setFont(FontManager.getRunescapeSmallFont()); + activityField.setFont(FontManager.getSmallFont(getFont())); column.add(activityField, BorderLayout.WEST); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java index 43f2f73a8a..cfa3d9fb12 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java @@ -49,7 +49,8 @@ enum QuestStartLocation THE_RESTLESS_GHOST(Quest.THE_RESTLESS_GHOST, new WorldPoint(3240, 3210, 0)), RUNE_MYSTERIES(Quest.RUNE_MYSTERIES, new WorldPoint(3210, 3220, 0)), SHEEP_SHEARER(Quest.SHEEP_SHEARER, new WorldPoint(3190, 3272, 0)), - SHIELD_OF_ARRAV(Quest.SHIELD_OF_ARRAV, new WorldPoint(3208, 3495, 0)), + SHIELD_OF_ARRAV_PHOENIX_GANG(Quest.SHIELD_OF_ARRAV, new WorldPoint(3208, 3495, 0)), + SHIELD_OF_ARRAV_BLACK_ARM_GANG(Quest.SHIELD_OF_ARRAV, new WorldPoint(3208, 3392, 0)), VAMPIRE_SLAYER(Quest.VAMPIRE_SLAYER, new WorldPoint(3096, 3266, 0)), WITCHS_POTION(Quest.WITCHS_POTION, new WorldPoint(2967, 3203, 0)), X_MARKS_THE_SPOT(Quest.X_MARKS_THE_SPOT, new WorldPoint(3227, 3242, 0)), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java index c7e4b1610b..942ccd2988 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java @@ -187,7 +187,7 @@ public class XpGlobesOverlay extends Overlay final FontMetrics metrics = graphics.getFontMetrics(); int drawX = x + (config.xpOrbSize() / 2) - (metrics.stringWidth(progress) / 2); - int drawY = y + (config.xpOrbSize() / 2) + (metrics.getHeight() / 2); + int drawY = y + (config.xpOrbSize() / 2) + (metrics.getHeight() / 2) - metrics.getMaxDescent(); OverlayUtil.renderTextLocation(graphics, new Point(drawX, drawY), progress, Color.WHITE); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java index c2e2284797..d0d157c480 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java @@ -175,10 +175,10 @@ class XpInfoBox extends JPanel statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); statsPanel.setBorder(new EmptyBorder(6, 5, 0, 2)); - expGained.setFont(FontManager.getRunescapeSmallFont()); - expHour.setFont(FontManager.getRunescapeSmallFont()); - expLeft.setFont(FontManager.getRunescapeSmallFont()); - actionsLeft.setFont(FontManager.getRunescapeSmallFont()); + expGained.setFont(FontManager.getSmallFont(getFont())); + expHour.setFont(FontManager.getSmallFont(getFont())); + expLeft.setFont(FontManager.getSmallFont(getFont())); + actionsLeft.setFont(FontManager.getSmallFont(getFont())); statsPanel.add(expGained); statsPanel.add(expLeft); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpPanel.java index c7bf7c3876..d716f12630 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpPanel.java @@ -113,8 +113,8 @@ class XpPanel extends PluginPanel overallInfo.setLayout(new GridLayout(2, 1)); overallInfo.setBorder(new EmptyBorder(0, 10, 0, 0)); - overallExpGained.setFont(FontManager.getRunescapeSmallFont()); - overallExpHour.setFont(FontManager.getRunescapeSmallFont()); + overallExpGained.setFont(FontManager.getSmallFont(getFont())); + overallExpHour.setFont(FontManager.getSmallFont(getFont())); overallInfo.add(overallExpGained); overallInfo.add(overallExpHour); diff --git a/runelite-client/src/main/java/net/runelite/client/ui/FontManager.java b/runelite-client/src/main/java/net/runelite/client/ui/FontManager.java index 5f703bb002..91a1a658ab 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/FontManager.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/FontManager.java @@ -24,11 +24,18 @@ */ package net.runelite.client.ui; +import com.google.common.collect.ImmutableBiMap; +import java.awt.Canvas; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.awt.Font; import java.awt.FontFormatException; import java.awt.GraphicsEnvironment; import java.io.IOException; -import javax.swing.text.StyleContext; +import lombok.Getter; +import net.runelite.client.config.FontType; public class FontManager { @@ -36,37 +43,59 @@ public class FontManager private static final Font runescapeSmallFont; private static final Font runescapeBoldFont; + @Getter + private static class CachedFont + { + private final Font reg; + private final Font small; + private final Font bold; + + private CachedFont(Font f) + { + reg = f.deriveFont(14.0f); + small = getFontOffCorrectSize(f); + bold = f.deriveFont(Font.BOLD, 14.0f); + } + } + + private static final ImmutableBiMap fontMap; + private static final HashMap derivedFontMap = new HashMap<>(); + static { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { - Font font = Font.createFont(Font.TRUETYPE_FONT, + runescapeFont = Font.createFont(Font.TRUETYPE_FONT, FontManager.class.getResourceAsStream("runescape.ttf")) .deriveFont(Font.PLAIN, 16); - ge.registerFont(font); - runescapeFont = StyleContext.getDefaultStyleContext() - .getFont(font.getName(), Font.PLAIN, 16); - ge.registerFont(runescapeFont); - - Font smallFont = Font.createFont(Font.TRUETYPE_FONT, + runescapeSmallFont = Font.createFont(Font.TRUETYPE_FONT, FontManager.class.getResourceAsStream("runescape_small.ttf")) .deriveFont(Font.PLAIN, 16); - ge.registerFont(smallFont); - runescapeSmallFont = StyleContext.getDefaultStyleContext() - .getFont(smallFont.getName(), Font.PLAIN, 16); - ge.registerFont(runescapeSmallFont); - - Font boldFont = Font.createFont(Font.TRUETYPE_FONT, + runescapeBoldFont = Font.createFont(Font.TRUETYPE_FONT, FontManager.class.getResourceAsStream("runescape_bold.ttf")) .deriveFont(Font.PLAIN, 16); - ge.registerFont(boldFont); - runescapeBoldFont = StyleContext.getDefaultStyleContext() - .getFont(boldFont.getName(), Font.PLAIN, 16); + final LinkedHashMap _fontMap = new LinkedHashMap<>(); + _fontMap.put("Runescape", runescapeFont); + + // Get all available fonts on the system + Font[] availableFonts = ge.getAllFonts(); + // build bidirectional map + Arrays.stream(availableFonts).sorted(Comparator.comparing(Font::getFontName)).forEach(f -> + { + if (!_fontMap.containsKey(f.getFontName())) + { + _fontMap.put(f.getFontName(), f); + } + }); + fontMap = ImmutableBiMap.copyOf(_fontMap); + + ge.registerFont(runescapeFont); + ge.registerFont(runescapeSmallFont); ge.registerFont(runescapeBoldFont); } catch (FontFormatException ex) @@ -79,6 +108,25 @@ public class FontManager } } + public static Font getFontOffCorrectSize(Font f) + { + // Size of the font is already set + if (f.getSize2D() > 1) + { + return f; + } + + // Dummy canvas for font metrics + Canvas c = new Canvas(); + + f = f.deriveFont(12f); + if (c.getFontMetrics(f).getMaxAscent() > 11) + { + f = f.deriveFont(11f); + } + return f; + } + public static Font getRunescapeFont() { return runescapeFont; @@ -93,4 +141,93 @@ public class FontManager { return runescapeBoldFont; } -} + + private static boolean isRunescapeFont(Font f) + { + return f.equals(runescapeFont) || f.equals(runescapeSmallFont) || f.equals(runescapeBoldFont); + } + + public static Font getSmallFont(Font f) + { + if (isRunescapeFont(f)) + { + return runescapeSmallFont; + } + + if (derivedFontMap.containsKey(f)) + { + return derivedFontMap.get(f).getSmall(); + } + + // cache and return + CachedFont cachedFont = new CachedFont(f); + derivedFontMap.put(f, cachedFont); + return cachedFont.getSmall(); + } + + public static Font getFontFromType(Font f, FontType type) + { + switch (type) + { + case SMALL: + return getSmallFont(f); + case BOLD: + if (isRunescapeFont(f)) + { + return runescapeBoldFont; + } + if (derivedFontMap.containsKey(f)) + { + return derivedFontMap.get(f).getBold(); + } + + // cache and return + CachedFont cachedBoldFont = new CachedFont(f); + derivedFontMap.put(f, cachedBoldFont); + return cachedBoldFont.getBold(); + default: //in this case regular + if (isRunescapeFont(f)) + { + return runescapeFont; + } + if (derivedFontMap.containsKey(f)) + { + return derivedFontMap.get(f).getReg(); + } + + // cache and return + CachedFont cachedFont = new CachedFont(f); + derivedFontMap.put(f, cachedFont); + return cachedFont.getReg(); + } + } + + public static Font lookupFont(String fontName) + { + return fontMap.get(fontName); + } + + public static String getFontName(Font font) + { + return fontMap.inverse().get(font); + } + + public static String[] getAvailableFontNames() + { + return fontMap.keySet().toArray(new String[fontMap.keySet().size()]); + } + + public static boolean isAvailable(Font font) + { + return fontMap.containsKey(font.getFontName()); + } + + public static Font getFontOrDefault(Font font) + { + if (font == null || !fontMap.containsKey(font.getFontName())) + { + return getRunescapeFont(); + } + return getFontOffCorrectSize(font); + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/ui/components/PluginErrorPanel.java b/runelite-client/src/main/java/net/runelite/client/ui/components/PluginErrorPanel.java index e7b2fad971..92f48a6993 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/components/PluginErrorPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/components/PluginErrorPanel.java @@ -52,7 +52,7 @@ public class PluginErrorPanel extends JPanel noResultsTitle.setForeground(Color.WHITE); noResultsTitle.setHorizontalAlignment(SwingConstants.CENTER); - noResultsDescription.setFont(FontManager.getRunescapeSmallFont()); + noResultsDescription.setFont(FontManager.getSmallFont(getFont())); noResultsDescription.setForeground(Color.GRAY); noResultsDescription.setHorizontalAlignment(SwingConstants.CENTER); diff --git a/runelite-client/src/main/java/net/runelite/client/ui/components/ProgressBar.java b/runelite-client/src/main/java/net/runelite/client/ui/components/ProgressBar.java index 2093585126..dc340613d6 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/components/ProgressBar.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/components/ProgressBar.java @@ -69,18 +69,26 @@ public class ProgressBar extends DimmableJPanel setPreferredSize(new Dimension(100, 16)); - leftLabel.setFont(FontManager.getRunescapeSmallFont()); + int topIndent = 0; + if (getFont().equals(FontManager.getRunescapeSmallFont()) + || getFont().equals(FontManager.getRunescapeFont()) + || getFont().equals(FontManager.getRunescapeBoldFont())) + { + topIndent = 2; + } + + leftLabel.setFont(FontManager.getSmallFont(getFont())); leftLabel.setForeground(Color.WHITE); - leftLabel.setBorder(new EmptyBorder(2, 5, 0, 0)); + leftLabel.setBorder(new EmptyBorder(topIndent, 5, 0, 0)); - rightLabel.setFont(FontManager.getRunescapeSmallFont()); + rightLabel.setFont(FontManager.getSmallFont(getFont())); rightLabel.setForeground(Color.WHITE); - rightLabel.setBorder(new EmptyBorder(2, 0, 0, 5)); + rightLabel.setBorder(new EmptyBorder(topIndent, 0, 0, 5)); - centerLabel.setFont(FontManager.getRunescapeSmallFont()); + centerLabel.setFont(FontManager.getSmallFont(getFont())); centerLabel.setForeground(Color.WHITE); centerLabel.setHorizontalAlignment(SwingConstants.CENTER); - centerLabel.setBorder(new EmptyBorder(2, 0, 0, 0)); + centerLabel.setBorder(new EmptyBorder(topIndent, 0, 0, 0)); // Adds components to be automatically redrawn when paintComponents is called add(leftLabel, BorderLayout.WEST); diff --git a/runelite-client/src/main/java/net/runelite/client/ui/components/shadowlabel/JShadowedLabel.java b/runelite-client/src/main/java/net/runelite/client/ui/components/shadowlabel/JShadowedLabel.java index 35ccf12374..79b7200f7b 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/components/shadowlabel/JShadowedLabel.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/components/shadowlabel/JShadowedLabel.java @@ -25,7 +25,11 @@ package net.runelite.client.ui.components.shadowlabel; import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.Point; +import java.awt.Toolkit; +import java.util.Map; import javax.swing.JLabel; import lombok.Getter; @@ -61,4 +65,17 @@ public class JShadowedLabel extends JLabel revalidate(); repaint(); } + + @Override + public void paint(Graphics g) + { + // Set font rendering properties like the OS's font rendering + Toolkit tk = Toolkit.getDefaultToolkit(); + Map desktopHints = (Map)(tk.getDesktopProperty("awt.font.desktophints")); + if (desktopHints != null) + { + ((Graphics2D)g).addRenderingHints(desktopHints); + } + super.paint(g); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java index 813240f9a1..38677410f2 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java @@ -30,9 +30,11 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; +import java.awt.Toolkit; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.util.List; +import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; import javax.swing.SwingUtilities; @@ -53,6 +55,7 @@ import net.runelite.client.input.MouseAdapter; import net.runelite.client.input.MouseManager; import net.runelite.client.ui.JagexColors; import net.runelite.client.util.ColorUtil; +import net.runelite.client.ui.FontManager; import net.runelite.client.util.MiscUtils; @Singleton @@ -165,6 +168,14 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener return; } + // Set font rendering properties like the OS's font rendering + Toolkit tk = Toolkit.getDefaultToolkit(); + Map desktopHints = (Map)(tk.getDesktopProperty("awt.font.desktophints")); + if (desktopHints != null) + { + graphics.addRenderingHints(desktopHints); + } + if (shouldInvalidateBounds()) { snapCorners = buildSnapCorners(); @@ -446,15 +457,15 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener // Set font based on configuration if (position == OverlayPosition.DYNAMIC || position == OverlayPosition.DETACHED) { - subGraphics.setFont(runeLiteConfig.fontType().getFont()); + subGraphics.setFont(FontManager.getFontFromType(runeLiteConfig.clientFont(), runeLiteConfig.fontType())); } else if (position == OverlayPosition.TOOLTIP) { - subGraphics.setFont(runeLiteConfig.tooltipFontType().getFont()); + subGraphics.setFont(FontManager.getFontFromType(runeLiteConfig.clientFont(), runeLiteConfig.tooltipFontType())); } else { - subGraphics.setFont(runeLiteConfig.interfaceFontType().getFont()); + subGraphics.setFont(FontManager.getFontFromType(runeLiteConfig.clientFont(), runeLiteConfig.interfaceFontType())); } subGraphics.translate(point.x, point.y); diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/InfoBoxComponent.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/InfoBoxComponent.java index d8f7841099..3a433ffb15 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/InfoBoxComponent.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/InfoBoxComponent.java @@ -39,7 +39,7 @@ import net.runelite.client.ui.FontManager; @Setter public class InfoBoxComponent implements LayoutableRenderableEntity { - private static final int SEPARATOR = 3; + private static final int SEPARATOR = 2; private static final int DEFAULT_SIZE = 32; @Getter @@ -63,7 +63,14 @@ public class InfoBoxComponent implements LayoutableRenderableEntity return new Dimension(); } - graphics.setFont(getSize() < DEFAULT_SIZE ? FontManager.getRunescapeSmallFont() : FontManager.getRunescapeFont()); + if (graphics.getFont().equals(FontManager.getRunescapeFont()) && getSize() > DEFAULT_SIZE) + { + graphics.setFont(FontManager.getRunescapeFont()); + } + else + { + graphics.setFont(FontManager.getSmallFont(graphics.getFont())); + } final int baseX = preferredLocation.x; final int baseY = preferredLocation.y; @@ -92,7 +99,7 @@ public class InfoBoxComponent implements LayoutableRenderableEntity final TextComponent textComponent = new TextComponent(); textComponent.setColor(color); textComponent.setText(text); - textComponent.setPosition(new Point(baseX + ((size - metrics.stringWidth(text)) / 2), baseY + size - SEPARATOR)); + textComponent.setPosition(new Point(baseX + ((size - metrics.stringWidth(text)) / 2), baseY + size - metrics.getMaxDescent() - SEPARATOR)); textComponent.render(graphics); } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/LineComponent.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/LineComponent.java index f6c2f5e77c..03b8c0a71d 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/LineComponent.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/LineComponent.java @@ -68,7 +68,7 @@ public class LineComponent implements LayoutableRenderableEntity final FontMetrics metrics = graphics.getFontMetrics(); final int baseX = preferredLocation.x; - final int baseY = preferredLocation.y + metrics.getHeight(); + final int baseY = preferredLocation.y; int x = baseX; int y = baseY; final int leftFullWidth = getLineWidth(left, metrics); @@ -92,6 +92,7 @@ public class LineComponent implements LayoutableRenderableEntity for (int i = 0; i < lineCount; i++) { + y += metrics.getMaxAscent(); String leftText = ""; String rightText = ""; @@ -116,7 +117,7 @@ public class LineComponent implements LayoutableRenderableEntity rightLineComponent.setText(rightText); rightLineComponent.setColor(rightColor); rightLineComponent.render(graphics); - y += metrics.getHeight(); + y += metrics.getMaxDescent(); } final Dimension dimension = new Dimension(preferredSize.width, y - baseY); @@ -124,6 +125,7 @@ public class LineComponent implements LayoutableRenderableEntity bounds.setSize(dimension); return dimension; } + y += metrics.getMaxAscent(); final TextComponent leftLineComponent = new TextComponent(); leftLineComponent.setPosition(new Point(x, y)); @@ -136,7 +138,7 @@ public class LineComponent implements LayoutableRenderableEntity rightLineComponent.setText(right); rightLineComponent.setColor(rightColor); rightLineComponent.render(graphics); - y += metrics.getHeight(); + y += metrics.getMaxDescent(); final Dimension dimension = new Dimension(preferredSize.width, y - baseY); bounds.setLocation(preferredLocation); diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/ProgressBarComponent.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/ProgressBarComponent.java index 01f52d6ad0..226c3da270 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/ProgressBarComponent.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/ProgressBarComponent.java @@ -109,7 +109,7 @@ public class ProgressBarComponent implements LayoutableRenderableEntity final int width = preferredSize.width; final int height = Math.max(preferredSize.height, 16); final int progressTextX = barX + (width - metrics.stringWidth(textToWrite)) / 2; - final int progressTextY = barY + ((height - metrics.getHeight()) / 2) + metrics.getHeight(); + final int progressTextY = barY + ((height - metrics.getHeight()) / 2) + metrics.getMaxAscent(); final int progressFill = (int) (width * Math.min(1, pc)); // Draw bar diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java index 98532a8d7c..fba19f5013 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java @@ -24,11 +24,15 @@ */ package net.runelite.client.ui.overlay.components; +import java.awt.AlphaComposite; import java.awt.Color; +import java.awt.Composite; import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Point; +import java.awt.Shape; +import java.awt.font.GlyphVector; import java.util.regex.Pattern; import lombok.Setter; import net.runelite.client.ui.overlay.RenderableEntity; @@ -43,6 +47,7 @@ public class TextComponent implements RenderableEntity private String text; private Point position = new Point(); private Color color = Color.WHITE; + private Color borderColor = Color.BLACK; public static String textWithoutColTags(String text) { @@ -64,28 +69,43 @@ public class TextComponent implements RenderableEntity final String textWithoutCol = textWithoutColTags(textSplitOnCol); final String colColor = textSplitOnCol.substring(textSplitOnCol.indexOf("=") + 1, textSplitOnCol.indexOf(">")); - // shadow - graphics.setColor(Color.BLACK); - graphics.drawString(textWithoutCol, x + 1, position.y + 1); - - // actual text - graphics.setColor(Color.decode("#" + colColor)); - graphics.drawString(textWithoutCol, x, position.y); + renderText(graphics, x, position.y, textWithoutCol, Color.decode("#" + colColor), borderColor); x += fontMetrics.stringWidth(textWithoutCol); } } else { - // shadow - graphics.setColor(Color.BLACK); - graphics.drawString(text, position.x + 1, position.y + 1); - - // actual text - graphics.setColor(color); - graphics.drawString(text, position.x, position.y); + renderText(graphics, position.x, position.y, text, color, borderColor); } - return new Dimension(fontMetrics.stringWidth(text), fontMetrics.getHeight()); } + + private void renderText(Graphics2D graphics, int x, int y, String text, Color color, Color border) + { + // remember previous composite + Composite originalComposite = graphics.getComposite(); + + // create a vector of the text + GlyphVector vector = graphics.getFont().createGlyphVector(graphics.getFontRenderContext(), text); + + // compute the text shape + Shape stroke = vector.getOutline(x + 1, y + 1); + Shape shape = vector.getOutline(x, y); + + // draw text border + graphics.setColor(border); + graphics.fill(stroke); + + // replace the pixels instead of overlaying + graphics.setComposite(AlphaComposite.Src); + + // draw actual text + graphics.setColor(color); + graphics.fill(shape); + + // reset composite to original + graphics.setComposite(originalComposite); + } + } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TitleComponent.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TitleComponent.java index fa4c9bc3bb..9c9793be66 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TitleComponent.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TitleComponent.java @@ -64,7 +64,7 @@ public class TitleComponent implements LayoutableRenderableEntity titleComponent.setColor(color); titleComponent.setPosition(new Point( baseX + ((preferredSize.width - metrics.stringWidth(text)) / 2), - baseY + metrics.getHeight())); + baseY + metrics.getMaxAscent())); final Dimension rendered = titleComponent.render(graphics); final Dimension dimension = new Dimension(preferredSize.width, rendered.height); bounds.setLocation(preferredLocation); diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TooltipComponent.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TooltipComponent.java index 34c7cefce1..6cd707ecfe 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TooltipComponent.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TooltipComponent.java @@ -104,7 +104,7 @@ public class TooltipComponent implements RenderableEntity textComponent.setColor(nextColor); String text = line.substring(begin, j); textComponent.setText(text); - textComponent.setPosition(new Point(lineX, textY + (i + 1) * textHeight - textDescent)); + textComponent.setPosition(new Point(lineX, textY + (i + 1) * metrics.getMaxAscent() + i * metrics.getMaxDescent())); textComponent.render(graphics); lineX += metrics.stringWidth(text); @@ -141,7 +141,7 @@ public class TooltipComponent implements RenderableEntity textComponent.setColor(nextColor); String text = line.substring(begin, j + 1); textComponent.setText(text); - textComponent.setPosition(new Point(lineX, textY + (i + 1) * textHeight - textDescent)); + textComponent.setPosition(new Point(lineX, textY + (i + 1) * metrics.getMaxAscent() + i * metrics.getMaxDescent())); textComponent.render(graphics); lineX += metrics.stringWidth(text); @@ -155,7 +155,7 @@ public class TooltipComponent implements RenderableEntity final TextComponent textComponent = new TextComponent(); textComponent.setColor(nextColor); textComponent.setText(line.substring(begin)); - textComponent.setPosition(new Point(lineX, textY + (i + 1) * textHeight - textDescent)); + textComponent.setPosition(new Point(lineX, textY + (i + 1) * metrics.getMaxAscent() + i * metrics.getMaxDescent())); textComponent.render(graphics); } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java index fef98b9f84..919b31882c 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java @@ -278,7 +278,7 @@ public class WorldMapOverlay extends Overlay graphics.setColor(JagexColors.TOOLTIP_BORDER); graphics.drawRect((int) tooltipRect.getX(), (int) tooltipRect.getY(), (int) tooltipRect.getWidth(), (int) tooltipRect.getHeight()); graphics.setColor(JagexColors.TOOLTIP_TEXT); - graphics.drawString(tooltip, drawPoint.getX(), drawPoint.getY() + height); + graphics.drawString(tooltip, drawPoint.getX(), drawPoint.getY() + fm.getMaxAscent()); } private Point clipToRectangle(Point drawPoint, Rectangle mapDisplayRectangle) diff --git a/runelite-client/src/main/java/net/runelite/client/util/SwingUtil.java b/runelite-client/src/main/java/net/runelite/client/util/SwingUtil.java index e8aaef79a6..021de4dc10 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/SwingUtil.java +++ b/runelite-client/src/main/java/net/runelite/client/util/SwingUtil.java @@ -309,6 +309,8 @@ public class SwingUtil // Use substance look and feel SwingUtil.setTheme(new SubstanceRuneLiteLookAndFeel()); // Use custom UI font + //TODO : SUPPORT CUSTOM FONT? + //SwingUtil.setFont(FontManager.getFontOrDefault(config.clientFont())); SwingUtil.setFont(FontManager.getRunescapeFont()); } } diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/prayer/back.png b/runelite-client/src/main/resources/net/runelite/client/plugins/prayer/back.png new file mode 100644 index 0000000000..76773682c4 Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/prayer/back.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/prayer/front.png b/runelite-client/src/main/resources/net/runelite/client/plugins/prayer/front.png new file mode 100644 index 0000000000..d8df9d8bfe Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/prayer/front.png differ diff --git a/runelite-client/src/main/scripts/GELayout.hash b/runelite-client/src/main/scripts/GELayout.hash new file mode 100644 index 0000000000..dba0bed2f5 --- /dev/null +++ b/runelite-client/src/main/scripts/GELayout.hash @@ -0,0 +1 @@ +03E202EADA91DB0D5EE9B98E360685149F29B10A1C565B9BE65C2A50BD262BC3 \ No newline at end of file diff --git a/runelite-client/src/main/scripts/GELayout.rs2asm b/runelite-client/src/main/scripts/GELayout.rs2asm new file mode 100644 index 0000000000..5a75b20ffc --- /dev/null +++ b/runelite-client/src/main/scripts/GELayout.rs2asm @@ -0,0 +1,101 @@ +.id 806 +.int_stack_count 7 +.string_stack_count 0 +.int_var_count 9 +.string_var_count 0 + iload 6 + invoke 41 + get_varbit 4439 + iconst 1 + sub + istore 7 + iconst 105 + iconst 118 + iconst 150 + iload 7 + enum + istore 8 + iload 8 + iconst -1 + if_icmpeq LABEL16 + jump LABEL37 +LABEL16: + iconst 1 + iload 2 + if_sethide + iconst 0 + iload 3 + if_sethide + iconst 1 + iload 4 + if_sethide + iconst 1 + iload 5 + if_sethide + iload 0 + iload 1 + cc_find + iconst 1 + if_icmpeq LABEL34 + jump LABEL36 +LABEL34: + sconst "Grand Exchange" + sconst "setGETitle" ; + runelite_callback ; + cc_settext +LABEL36: + return +LABEL37: + iconst 0 + iload 2 + if_sethide + iconst 0 + iload 2 + if_settrans + iload 7 + stockmarket_isofferempty + iconst 1 + if_icmpeq LABEL48 + jump LABEL66 +LABEL48: + iconst 1 + iload 3 + if_sethide + iconst 1 + iload 4 + if_sethide + iconst 0 + iload 5 + if_sethide + iload 0 + iload 1 + cc_find + iconst 1 + if_icmpeq LABEL63 + jump LABEL65 +LABEL63: + sconst "Grand Exchange: Set up offer" + cc_settext +LABEL65: + return +LABEL66: + iconst 1 + iload 3 + if_sethide + iconst 0 + iload 4 + if_sethide + iconst 1 + iload 5 + if_sethide + iload 0 + iload 1 + cc_find + iconst 1 + if_icmpeq LABEL81 + jump LABEL83 +LABEL81: + sconst "Grand Exchange: Offer status" + cc_settext +LABEL83: + return diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdSolverTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdSolverTest.java deleted file mode 100644 index a5c4cc4e31..0000000000 --- a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdSolverTest.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) 2019, Jordan Atwood - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.cluescrolls.clues.hotcold; - -import com.google.common.collect.Sets; -import java.awt.Rectangle; -import java.util.EnumSet; -import java.util.Set; -import java.util.stream.Collectors; -import static junit.framework.TestCase.assertTrue; -import net.runelite.api.coords.WorldPoint; -import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdSolver.isFirstPointCloser; -import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdSolver.isFirstPointCloserRect; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import org.junit.Test; - -public class HotColdSolverTest -{ - private static final String RESPONSE_TEXT_ICE_COLD_COLDER = "The device is ice cold, but colder than last time."; - private static final String RESPONSE_TEXT_VERY_COLD_WARMER = "The device is very cold, and warmer than last time."; - private static final String RESPONSE_TEXT_COLD = "The device is cold."; - private static final String RESPONSE_TEXT_COLD_COLDER = "The device is cold, but colder than last time."; - private static final String RESPONSE_TEXT_COLD_WARMER = "The device is cold, and warmer than last time."; - private static final String RESPONSE_TEXT_COLD_SAME_TEMP = "The device is cold, and the same temperature as last time."; - private static final String RESPONSE_TEXT_VERY_HOT = "The device is very hot."; - private static final String RESPONSE_TEXT_VERY_HOT_COLDER = "The device is very hot, but colder than last time."; - private static final String RESPONSE_TEXT_VERY_HOT_WARMER = "The device is very hot, and warmer than last time."; - private static final String RESPONSE_TEXT_VERY_HOT_SAME_TEMP = "The device is very hot, and the same temperature as last time."; - - @Test - public void testOneStepSolution() - { - final Set foundLocation = Sets.immutableEnumSet(HotColdLocation.KARAMJA_KHARAZI_NE); - - testSolver(createHotColdSolver(), new WorldPoint(2852, 2992, 0), RESPONSE_TEXT_VERY_HOT, foundLocation); - } - - @Test - public void testIgnoreStartingTemperatureDifference() - { - final WorldPoint testedPoint = new WorldPoint(2852, 2992, 0); - final Set foundLocations = Sets.immutableEnumSet(HotColdLocation.KARAMJA_KHARAZI_NE); - - testSolver(createHotColdSolver(), testedPoint, RESPONSE_TEXT_VERY_HOT, foundLocations); - testSolver(createHotColdSolver(), testedPoint, RESPONSE_TEXT_VERY_HOT_COLDER, foundLocations); - testSolver(createHotColdSolver(), testedPoint, RESPONSE_TEXT_VERY_HOT_WARMER, foundLocations); - testSolver(createHotColdSolver(), testedPoint, RESPONSE_TEXT_VERY_HOT_SAME_TEMP, foundLocations); - } - - @Test - public void testSameTempNoChanges() - { - final HotColdSolver solver = createHotColdSolver(); - final WorldPoint testedPoint = new WorldPoint(2851, 2955, 0); - final Set foundLocations = Sets.immutableEnumSet( - HotColdLocation.KARAMJA_KHARAZI_NE, - HotColdLocation.KARAMJA_KHARAZI_SW); - - testSolver(solver, testedPoint, RESPONSE_TEXT_VERY_HOT, foundLocations); - testSolver(solver, testedPoint, RESPONSE_TEXT_VERY_HOT_SAME_TEMP, foundLocations); - } - - @Test - public void testNoChangesAfterSolutionFound() - { - final HotColdSolver solver = createHotColdSolver(); - final Set intermediateFoundLocations = Sets.immutableEnumSet( - HotColdLocation.KARAMJA_KHARAZI_NE, - HotColdLocation.KARAMJA_KHARAZI_SW); - final Set finalLocation = Sets.immutableEnumSet(HotColdLocation.KARAMJA_KHARAZI_NE); - - testSolver(solver, new WorldPoint(2851, 2955, 0), RESPONSE_TEXT_VERY_HOT, intermediateFoundLocations); - testSolver(solver, new WorldPoint(2852, 2955, 0), RESPONSE_TEXT_VERY_HOT_WARMER, finalLocation); - testSolver(solver, new WorldPoint(2851, 2955, 0), RESPONSE_TEXT_VERY_HOT_COLDER, finalLocation); - testSolver(solver, new WorldPoint(2465, 3495, 0), RESPONSE_TEXT_ICE_COLD_COLDER, finalLocation); - testSolver(solver, new WorldPoint(3056, 3291, 0), RESPONSE_TEXT_VERY_COLD_WARMER, finalLocation); - testSolver(solver, new WorldPoint(2571, 2956, 0), RESPONSE_TEXT_VERY_COLD_WARMER, finalLocation); - } - - @Test - public void testNarrowToFindSolutions() - { - final HotColdSolver solver = createHotColdSolver(); - final Set firstLocationsSet = Sets.immutableEnumSet( - HotColdLocation.FELDIP_HILLS_GNOME_GLITER, - HotColdLocation.FELDIP_HILLS_RED_CHIN, - HotColdLocation.KARAMJA_KHARAZI_NE, - HotColdLocation.KARAMJA_CRASH_ISLAND); - final Set secondLocationsSet = firstLocationsSet.stream() - .filter(location -> location != HotColdLocation.FELDIP_HILLS_RED_CHIN) - .collect(Collectors.toSet()); - final Set thirdLocationSet = secondLocationsSet.stream() - .filter(location -> location != HotColdLocation.FELDIP_HILLS_GNOME_GLITER) - .collect(Collectors.toSet()); - final Set finalLocation = thirdLocationSet.stream() - .filter(location -> location != HotColdLocation.KARAMJA_CRASH_ISLAND) - .collect(Collectors.toSet()); - - testSolver(solver, new WorldPoint(2711, 2803, 0), RESPONSE_TEXT_COLD, firstLocationsSet); - testSolver(solver, new WorldPoint(2711, 2802, 0), RESPONSE_TEXT_COLD_SAME_TEMP, firstLocationsSet); - testSolver(solver, new WorldPoint(2716, 2802, 0), RESPONSE_TEXT_COLD_WARMER, secondLocationsSet); - testSolver(solver, new WorldPoint(2739, 2808, 0), RESPONSE_TEXT_COLD_WARMER, thirdLocationSet); - testSolver(solver, new WorldPoint(2810, 2757, 0), RESPONSE_TEXT_COLD_COLDER, finalLocation); - } - - @Test - public void testSomewhatDistantLocations() - { - // Activate device on Ape Atoll when solution point is HotColdLocation.KARAMJA_KHARAZI_NE - testSolver(createHotColdSolver(), new WorldPoint(2723, 2743, 0), RESPONSE_TEXT_COLD, - Sets.immutableEnumSet( - HotColdLocation.KARAMJA_KHARAZI_NE, - HotColdLocation.KARAMJA_KHARAZI_SW, - HotColdLocation.KARAMJA_CRASH_ISLAND, - HotColdLocation.FELDIP_HILLS_SW, - HotColdLocation.FELDIP_HILLS_RANTZ, - HotColdLocation.FELDIP_HILLS_RED_CHIN, - HotColdLocation.FELDIP_HILLS_SE)); - - // Activate device near fairy ring DKP when solution point is HotColdLocation.KARAMJA_KHARAZI_NE - testSolver(createHotColdSolver(), new WorldPoint(2900, 3111, 0), RESPONSE_TEXT_COLD, - Sets.immutableEnumSet( - HotColdLocation.KARAMJA_WEST_BRIMHAVEN, - HotColdLocation.KARAMJA_KHARAZI_NE, - HotColdLocation.ASGARNIA_COW, - HotColdLocation.ASGARNIA_CRAFT_GUILD, - HotColdLocation.KANDARIN_WITCHHAVEN, - HotColdLocation.MISTHALIN_DRAYNOR_BANK)); - - // Activate device on Mudskipper Point when solution point is HotColdLocation.KARAMJA_KHARAZI_NE - testSolver(createHotColdSolver(), new WorldPoint(2985, 3106, 0), RESPONSE_TEXT_COLD, - Sets.immutableEnumSet( - HotColdLocation.KARAMJA_BRIMHAVEN_FRUIT_TREE, - HotColdLocation.KARAMJA_KHARAZI_NE, - HotColdLocation.ASGARNIA_COW, - HotColdLocation.ASGARNIA_CRAFT_GUILD, - HotColdLocation.MISTHALIN_LUMBRIDGE_2, - HotColdLocation.DESERT_BEDABIN_CAMP)); - } - - @Test - public void testIsFirstPointCloserRect() - { - assertFalse(isFirstPointCloserRect(new WorldPoint(0, 0, 0), new WorldPoint(0, 0, 0), new Rectangle(0, 0, 1, 1))); - assertFalse(isFirstPointCloserRect(new WorldPoint(1, 0, 0), new WorldPoint(5, 0, 0), new Rectangle(2, 1, 5, 5))); - assertFalse(isFirstPointCloserRect(new WorldPoint(1, 0, 0), new WorldPoint(0, 0, 0), new Rectangle(2, 0, 1, 2))); - assertFalse(isFirstPointCloserRect(new WorldPoint(0, 0, 0), new WorldPoint(1, 1, 1), new Rectangle(2, 2, 2, 2))); - assertFalse(isFirstPointCloserRect(new WorldPoint(0, 0, 0), new WorldPoint(4, 4, 4), new Rectangle(1, 1, 2, 2))); - assertFalse(isFirstPointCloserRect(new WorldPoint(3, 2, 0), new WorldPoint(1, 5, 0), new Rectangle(0, 0, 4, 4))); - - assertTrue(isFirstPointCloserRect(new WorldPoint(1, 1, 0), new WorldPoint(0, 1, 0), new Rectangle(2, 0, 3, 2))); - assertTrue(isFirstPointCloserRect(new WorldPoint(4, 4, 0), new WorldPoint(1, 1, 0), new Rectangle(3, 3, 2, 2))); - assertTrue(isFirstPointCloserRect(new WorldPoint(3, 2, 0), new WorldPoint(7, 0, 0), new Rectangle(1, 3, 4, 2))); - - } - - @Test - public void testIsFirstPointCloser() - { - assertFalse(isFirstPointCloser(new WorldPoint(0, 0, 0), new WorldPoint(0, 0, 0), new WorldPoint(0, 0, 0))); - assertFalse(isFirstPointCloser(new WorldPoint(0, 0, 0), new WorldPoint(0, 0, 1), new WorldPoint(0, 0, 0))); - assertFalse(isFirstPointCloser(new WorldPoint(1, 0, 0), new WorldPoint(0, 0, 0), new WorldPoint(1, 1, 0))); - assertFalse(isFirstPointCloser(new WorldPoint(2, 2, 0), new WorldPoint(0, 0, 0), new WorldPoint(1, 1, 0))); - - assertTrue(isFirstPointCloser(new WorldPoint(1, 0, 0), new WorldPoint(0, 0, 0), new WorldPoint(2, 0, 0))); - assertTrue(isFirstPointCloser(new WorldPoint(1, 1, 0), new WorldPoint(1, 0, 0), new WorldPoint(2, 2, 0))); - assertTrue(isFirstPointCloser(new WorldPoint(1, 1, 1), new WorldPoint(0, 1, 0), new WorldPoint(1, 1, 0))); - } - - /** - * Tests a hot-cold solver by signalling a test point, temperature, and temperature change to it and asserting the - * resulting possible location set is equal to that of a given set of expected locations. - * - * @param solver The hot-cold solver to signal to. - *
- * Note: This will mutate the passed solver, which is helpful for testing - * multiple sequential steps. - * @param testPoint The {@link WorldPoint} where the signal occurs. - * @param deviceResponse The string containing the temperature and temperature change which is - * given when the hot-cold checking device is activated. - * @param expectedRemainingPossibleLocations A {@link Set} of {@link HotColdLocation}s which is expected to be - * given by {@link HotColdSolver#getPossibleLocations()} after it receives - * the signal formed by the other given arguments. - */ - private static void testSolver(final HotColdSolver solver, final WorldPoint testPoint, final String deviceResponse, final Set expectedRemainingPossibleLocations) - { - final HotColdTemperature temperature = HotColdTemperature.getFromTemperatureSet(HotColdTemperature.MASTER_HOT_COLD_TEMPERATURES, deviceResponse); - final HotColdTemperatureChange temperatureChange = HotColdTemperatureChange.of(deviceResponse); - - assertNotNull(temperature); - assertEquals(expectedRemainingPossibleLocations, solver.signal(testPoint, temperature, temperatureChange)); - } - - /** - * @return A hot-cold solver with a starting set of master hot-cold locations nearby the KARAMJA_KHARAZI_NE - * location. {@link HotColdLocation#values()} is not used as it may change with future game updates, and - * such changes would break this test suite. - */ - private static HotColdSolver createHotColdSolver() - { - final Set hotColdLocations = EnumSet.of( - HotColdLocation.KARAMJA_KHARAZI_NE, - HotColdLocation.KARAMJA_KHARAZI_SW, - HotColdLocation.KARAMJA_GLIDER, - HotColdLocation.KARAMJA_MUSA_POINT, - HotColdLocation.KARAMJA_BRIMHAVEN_FRUIT_TREE, - HotColdLocation.KARAMJA_WEST_BRIMHAVEN, - HotColdLocation.KARAMJA_CRASH_ISLAND, - HotColdLocation.DESERT_BEDABIN_CAMP, - HotColdLocation.DESERT_MENAPHOS_GATE, - HotColdLocation.DESERT_POLLNIVNEACH, - HotColdLocation.DESERT_SHANTY, - HotColdLocation.MISTHALIN_LUMBRIDGE, - HotColdLocation.MISTHALIN_LUMBRIDGE_2, - HotColdLocation.MISTHALIN_DRAYNOR_BANK, - HotColdLocation.ASGARNIA_COW, - HotColdLocation.ASGARNIA_PARTY_ROOM, - HotColdLocation.ASGARNIA_CRAFT_GUILD, - HotColdLocation.ASGARNIA_RIMMINGTON, - HotColdLocation.ASGARNIA_MUDSKIPPER, - HotColdLocation.KANDARIN_WITCHHAVEN, - HotColdLocation.KANDARIN_NECRO_TOWER, - HotColdLocation.KANDARIN_FIGHT_ARENA, - HotColdLocation.KANDARIN_TREE_GNOME_VILLAGE, - HotColdLocation.FELDIP_HILLS_GNOME_GLITER, - HotColdLocation.FELDIP_HILLS_JIGGIG, - HotColdLocation.FELDIP_HILLS_RANTZ, - HotColdLocation.FELDIP_HILLS_RED_CHIN, - HotColdLocation.FELDIP_HILLS_SE, - HotColdLocation.FELDIP_HILLS_SOUTH, - HotColdLocation.FELDIP_HILLS_SW - ); - return new HotColdSolver(hotColdLocations); - } -} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdTemperatureChangeTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdTemperatureChangeTest.java deleted file mode 100644 index 9b7cdcaf3c..0000000000 --- a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdTemperatureChangeTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2019, Jordan Atwood - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.cluescrolls.clues.hotcold; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import org.junit.Test; - -public class HotColdTemperatureChangeTest -{ - private static final String[] VALID_MESSAGES = { - "The device is warm, and warmer than last time.", - "The device is cold, but colder than last time.", - "The device is very hot, and the same temperature as last time.", - }; - private static final String[] INVALID_MESSAGES = { - "The device is cold.", - "The device is ice cold.", - "The device is very cold.", - "The device is hot.", - "The device is incredibly hot.", - "The device is an octopus, and is wetter than last time", - "foobar", - "a q p w", - "My feet are cold, I should put them in some lukewarm water, or run hot water over them.", - "and warmer than and colder than and the same temperature", - }; - - @Test - public void testValidTemperatureChangeMessages() - { - for (final String message : VALID_MESSAGES) - { - assertNotNull(message, HotColdTemperatureChange.of(message)); - } - } - - @Test - public void testInvalidTemperatureChangeMessages() - { - for (final String message : INVALID_MESSAGES) - { - assertNull(message, HotColdTemperatureChange.of(message)); - } - } -} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdTemperatureTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdTemperatureTest.java deleted file mode 100644 index e9711dc433..0000000000 --- a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdTemperatureTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2019, Jordan Atwood - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.cluescrolls.clues.hotcold; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import org.junit.Test; - -public class HotColdTemperatureTest -{ - private static final String[] VALID_MESSAGES = { - "The device is warm, and warmer than last time.", - "The device is visibly shaking and burns to the touch. This must be the spot.", - "The device is cold.", - "The device is ice cold.", - "The device is very cold.", - "The device is hot.", - "The device is incredibly hot.", - }; - private static final String[] INVALID_MESSAGES = { - "The device is an octopus, and is wetter than last time.", - "foobar", - "a q p w", - "My feet are cold, I should put them in some lukewarm water, or run hot water over them.", - }; - - @Test - public void testValidTemperatureMessages() - { - for (final String message : VALID_MESSAGES) - { - assertNotNull(message, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.BEGINNER_HOT_COLD_TEMPERATURES, message)); - assertNotNull(message, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.MASTER_HOT_COLD_TEMPERATURES, message)); - } - } - - @Test - public void testInvalidTemperatureMessages() - { - for (final String message : INVALID_MESSAGES) - { - assertNull(message, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.BEGINNER_HOT_COLD_TEMPERATURES, message)); - assertNull(message, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.MASTER_HOT_COLD_TEMPERATURES, message)); - } - } - - @Test - public void testAmbiguousTemperatureMessages() - { - assertEquals(HotColdTemperature.ICE_COLD, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.MASTER_HOT_COLD_TEMPERATURES, "The device is ice cold.")); - assertEquals(HotColdTemperature.VERY_COLD, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.MASTER_HOT_COLD_TEMPERATURES, "The device is very cold.")); - assertEquals(HotColdTemperature.VERY_HOT, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.MASTER_HOT_COLD_TEMPERATURES, "The device is very hot.")); - } -} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/MasterHotColdLocationTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/MasterHotColdLocationTest.java deleted file mode 100644 index abda26549d..0000000000 --- a/runelite-client/src/test/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/MasterHotColdLocationTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2019, Jordan Atwood - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.cluescrolls.clues.hotcold; - -import java.util.Arrays; -import java.util.Set; -import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -public class MasterHotColdLocationTest -{ - private static final Set MASTER_HOT_COLD_LOCATIONS = Arrays.stream(HotColdLocation.values()) - .filter(l -> !l.isBeginnerClue()) - .collect(Collectors.toSet()); - private static final int EXPECTED_DIMENSION_SIZE = 9; - - @Test - public void beginnerHotColdLocationAreaTest() - { - for (final HotColdLocation location : MASTER_HOT_COLD_LOCATIONS) - { - assertEquals(EXPECTED_DIMENSION_SIZE, location.getRect().height); - assertEquals(EXPECTED_DIMENSION_SIZE, location.getRect().width); - } - } -} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/timers/TimersPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/timers/TimersPluginTest.java new file mode 100644 index 0000000000..f9ba35154d --- /dev/null +++ b/runelite-client/src/test/java/net/runelite/client/plugins/timers/TimersPluginTest.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2019, 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.client.plugins.timers; + +import com.google.inject.Guice; +import com.google.inject.Inject; +import com.google.inject.testing.fieldbinder.Bind; +import com.google.inject.testing.fieldbinder.BoundFieldModule; +import java.util.EnumSet; +import net.runelite.api.ChatMessageType; +import net.runelite.api.Client; +import net.runelite.api.WorldType; +import net.runelite.api.events.ChatMessage; +import net.runelite.client.game.ItemManager; +import net.runelite.client.game.SpriteManager; +import net.runelite.client.ui.overlay.infobox.InfoBox; +import net.runelite.client.ui.overlay.infobox.InfoBoxManager; +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import org.mockito.runners.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class TimersPluginTest +{ + private static final String DMM_HALF_TELEBLOCK_MESSAGE = "A Tele Block spell has been cast on you by Runelite. It will expire in 1 minute, 15 seconds."; + private static final String FULL_TELEBLOCK_MESSAGE = "A Tele Block spell has been cast on you by Runelite. It will expire in 5 minutes, 0 seconds."; + private static final String HALF_TELEBLOCK_MESSAGE = "A Tele Block spell has been cast on you by Runelite. It will expire in 2 minutes, 30 seconds."; + + @Inject + private TimersPlugin timersPlugin; + + @Mock + @Bind + private TimersConfig timersConfig; + + @Mock + @Bind + private Client client; + + @Mock + @Bind + private ItemManager itemManager; + + @Mock + @Bind + private SpriteManager spriteManager; + + @Mock + @Bind + private InfoBoxManager infoBoxManager; + + @Before + public void before() + { + Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); + } + + @Test + public void testHalfTeleblock() + { + when(timersConfig.showTeleblock()).thenReturn(true); + when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.MEMBERS)); + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", HALF_TELEBLOCK_MESSAGE, "", 0); + timersPlugin.onChatMessage(chatMessage); + + ArgumentCaptor captor = ArgumentCaptor.forClass(InfoBox.class); + verify(infoBoxManager).addInfoBox(captor.capture()); + TimerTimer infoBox = (TimerTimer) captor.getValue(); + assertEquals(GameTimer.HALFTB, infoBox.getTimer()); + } + + @Test + public void testFullTeleblock() + { + when(timersConfig.showTeleblock()).thenReturn(true); + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", FULL_TELEBLOCK_MESSAGE, "", 0); + timersPlugin.onChatMessage(chatMessage); + + ArgumentCaptor captor = ArgumentCaptor.forClass(InfoBox.class); + verify(infoBoxManager).addInfoBox(captor.capture()); + TimerTimer infoBox = (TimerTimer) captor.getValue(); + assertEquals(GameTimer.FULLTB, infoBox.getTimer()); + } + + @Test + public void testDmmHalfTb() + { + when(timersConfig.showTeleblock()).thenReturn(true); + when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.DEADMAN)); + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", DMM_HALF_TELEBLOCK_MESSAGE, "", 0); + timersPlugin.onChatMessage(chatMessage); + + ArgumentCaptor captor = ArgumentCaptor.forClass(InfoBox.class); + verify(infoBoxManager).addInfoBox(captor.capture()); + TimerTimer infoBox = (TimerTimer) captor.getValue(); + assertEquals(GameTimer.DMM_HALFTB, infoBox.getTimer()); + } + + @Test + public void testDmmFullTb() + { + when(timersConfig.showTeleblock()).thenReturn(true); + when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.DEADMAN)); + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", HALF_TELEBLOCK_MESSAGE, "", 0); + timersPlugin.onChatMessage(chatMessage); + + ArgumentCaptor captor = ArgumentCaptor.forClass(InfoBox.class); + verify(infoBoxManager).addInfoBox(captor.capture()); + TimerTimer infoBox = (TimerTimer) captor.getValue(); + assertEquals(GameTimer.DMM_FULLTB, infoBox.getTimer()); + } +} \ No newline at end of file diff --git a/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java b/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java index 45c859a4a7..f1677daa4b 100644 --- a/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java +++ b/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java @@ -25,33 +25,24 @@ package net.runelite.client.ui.overlay.components; import java.awt.Color; -import java.awt.FontMetrics; import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.eq; -import org.mockito.Mock; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import org.mockito.runners.MockitoJUnitRunner; -@RunWith(MockitoJUnitRunner.class) public class TextComponentTest { - @Mock private Graphics2D graphics; - + private BufferedImage dest; + @Before public void before() { - when(graphics.getFontMetrics()).thenReturn(mock(FontMetrics.class)); + dest = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + graphics = (Graphics2D) dest.getGraphics(); } - + @Test public void testRender() { @@ -59,29 +50,29 @@ public class TextComponentTest textComponent.setText("test"); textComponent.setColor(Color.RED); textComponent.render(graphics); - verify(graphics, times(2)).drawString(eq("test"), anyInt(), anyInt()); - verify(graphics, atLeastOnce()).setColor(Color.RED); } - + @Test public void testRender2() { TextComponent textComponent = new TextComponent(); textComponent.setText("test"); textComponent.render(graphics); - verify(graphics, times(2)).drawString(eq("test"), anyInt(), anyInt()); - verify(graphics, atLeastOnce()).setColor(Color.BLUE); } - + @Test public void testRender3() { TextComponent textComponent = new TextComponent(); textComponent.setText("test test"); textComponent.render(graphics); - verify(graphics, atLeastOnce()).drawString(eq("test"), anyInt(), anyInt()); - verify(graphics, atLeastOnce()).drawString(eq(" test"), anyInt(), anyInt()); - verify(graphics, atLeastOnce()).setColor(Color.BLUE); - verify(graphics, atLeastOnce()).setColor(Color.GREEN); } + + @After + public void after() + { + graphics.dispose(); + dest.flush(); + } + } diff --git a/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/table/TableComponentTest.java b/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/table/TableComponentTest.java index 1c7e95d37a..a10bd03d80 100644 --- a/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/table/TableComponentTest.java +++ b/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/table/TableComponentTest.java @@ -25,32 +25,28 @@ package net.runelite.client.ui.overlay.components.table; import java.awt.Color; -import java.awt.FontMetrics; +import java.awt.image.BufferedImage; +import org.junit.After; import java.awt.Graphics2D; import java.util.List; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.eq; import org.mockito.Mock; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import org.mockito.runners.MockitoJUnitRunner; -@RunWith(MockitoJUnitRunner.class) + + public class TableComponentTest { @Mock private Graphics2D graphics; + private BufferedImage dest; + @Before public void before() { - when(graphics.getFontMetrics()).thenReturn(mock(FontMetrics.class)); + dest = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + graphics = (Graphics2D) dest.getGraphics(); } @Test @@ -61,8 +57,6 @@ public class TableComponentTest tableComponent.setDefaultAlignment(TableAlignment.CENTER); tableComponent.setDefaultColor(Color.RED); tableComponent.render(graphics); - verify(graphics, times(2)).drawString(eq("test"), anyInt(), anyInt()); - verify(graphics, atLeastOnce()).setColor(Color.RED); } @Test @@ -76,10 +70,13 @@ public class TableComponentTest elements.get(1).setColor(Color.GREEN); elements.get(2).setColor(Color.BLUE); tableComponent.render(graphics); - verify(graphics, atLeastOnce()).setColor(Color.RED); - verify(graphics, atLeastOnce()).setColor(Color.GREEN); - verify(graphics, atLeastOnce()).setColor(Color.BLUE); - verify(graphics, atLeastOnce()).setColor(Color.YELLOW); - verify(graphics, atLeastOnce()).setColor(Color.WHITE); } + + @After + public void after() + { + graphics.dispose(); + dest.flush(); + } + } diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java index 069c9a99d4..ee569abca0 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java @@ -1264,7 +1264,8 @@ public abstract class RSClientMixin implements RSClient return; } - rs$menuAction(actionParam, widgetId, menuAction, id, menuOption, menuTarget, var6, var7); + rs$menuAction(menuOptionClicked.getActionParam0(), menuOptionClicked.getActionParam1(), menuOptionClicked.getType(), + menuOptionClicked.getIdentifier(), menuOptionClicked.getOption(), menuOptionClicked.getTarget(), var6, var7); } @FieldHook("Login_username") @@ -1303,6 +1304,7 @@ public abstract class RSClientMixin implements RSClient final MenuOpened event = new MenuOpened(); event.setMenuEntries(getMenuEntries()); callbacks.post(event); + client.setMenuEntries(event.getMenuEntries()); } @Inject diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/WorldHoppingMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/WorldHoppingMixin.java index 0b29dfbe61..f230fa8b45 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/WorldHoppingMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/WorldHoppingMixin.java @@ -23,6 +23,6 @@ public abstract class WorldHoppingMixin implements RSClient public void hopToWorld(World world) { final int worldId = world.getId(); - invokeMenuAction(worldId, WidgetInfo.WORLD_SWITCHER_LIST.getId(), MenuAction.WIDGET_DEFAULT.getId(), 1, "Switch", "" + (worldId - 300) + "", 683, 244); + invokeMenuAction(worldId, WidgetInfo.WORLD_SWITCHER_LIST.getId(), MenuAction.WIDGET_DEFAULT.getId(), 1, "Switch", "" + (worldId - 300) + "", 683, 244); } }