Merge branch 'master' into loot-tracker-reset

This commit is contained in:
PKLite
2019-07-03 11:30:28 -04:00
105 changed files with 1840 additions and 1138 deletions

View File

@@ -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<? extends Enum>) 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;

View File

@@ -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()

View File

@@ -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",

View File

@@ -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),

View File

@@ -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<Integer, String> playerMenuIndexMap = new HashMap<>();
@@ -95,15 +89,21 @@ public class MenuManager
private final Set<ComparableEntry> priorityEntries = new HashSet<>();
private final Set<MenuEntry> currentPriorityEntries = new HashSet<>();
private final Set<ComparableEntry> hiddenEntries = new HashSet<>();
private final Set<MenuEntry> currentHiddenEntries = new HashSet<>();
private final Map<ComparableEntry, ComparableEntry> swaps = new HashMap<>();
private EntryTypeMapping originalType;
private final Map<ComparableEntry, MenuEntry> currentSwaps = new HashMap<>();
private final LinkedHashSet<MenuEntry> 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<MenuEntry> 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<MenuEntry> 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<ComparableEntry, ComparableEntry> p : swaps.entrySet())
{
if (p.getValue().matches(entry))
{
currentSwaps.put(p.getKey(), entry);
return;
}
}
});
state.decrementAndGet();
}
};
}
}

View File

@@ -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;

View File

@@ -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()
{

View File

@@ -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.

View File

@@ -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<Item> 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;

View File

@@ -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};
}
}

View File

@@ -133,6 +133,6 @@ public class CipherClue extends ClueScroll implements TextClueScroll, NpcClueScr
public String[] getNpcs()
{
return new String[]{npc};
return new String[] {npc};
}
}

View File

@@ -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};
}
}

View File

@@ -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)

View File

@@ -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};
}
}

View File

@@ -204,6 +204,6 @@ public class MapClue extends ClueScroll implements ObjectClueScroll
public int[] getObjectIds()
{
return new int[]{objectId};
return new int[] {objectId};
}
}

View File

@@ -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)

View File

@@ -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<Item> 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<CrypticClue, Boolean> entry = clueSteps.get(index);

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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)

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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)
{

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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<Rectangle, GroundItem> textBoxBounds;

View File

@@ -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());

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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()
{

View File

@@ -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();
}
}

View File

@@ -37,7 +37,5 @@ enum ItemChargeType
BRACELET_OF_SLAUGHTER,
EXPEDITIOUS_BRACELET,
BINDING_NECKLACE,
EXPLORER_RING,
FRUIT_BASKET,
SACK
EXPLORER_RING
}

View File

@@ -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),

View File

@@ -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)

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 2019, gazivodag <https://github.com/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 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
{
@ConfigItem(
keyName = "overlayStub",
name = "Overlays",
description = "",
position = 0
)
default Stub overlayStub()
{
return new Stub();
}
@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;
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018 AWPH-I
* Copyright (c) 2019, gazivodag <https://github.com/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);
}
}
});
}
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 2019, gazivodag <https://github.com/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;
}
}
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}
}
}

View File

@@ -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"))

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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",

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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));

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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();

View File

@@ -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 = "<col=ef1020>Your magical charge fades away.</col>";
private static final String CHARGE_MESSAGE = "<col=ef1020>You feel charged with magic power.</col>";
private static final String DEADMAN_HALF_TELEBLOCK_MESSAGE = "<col=4f006f>A Tele Block spell has been cast on you. It will expire in 1 minute, 15 seconds.</col>";
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 = "<col=ef1020>You have been frozen!</col>";
private static final String FULL_TELEBLOCK_MESSAGE = "<col=4f006f>A Tele Block spell has been cast on you. It will expire in 5 minutes, 0 seconds.</col>";
private static final String GOD_WARS_ALTAR_MESSAGE = "you recharge your prayer.";
private static final String HALF_TELEBLOCK_MESSAGE = "<col=4f006f>A Tele Block spell has been cast on you. It will expire in 2 minutes, 30 seconds.</col>";
private static final String IMBUED_HEART_READY_MESSAGE = "<col=ef1020>Your imbued heart has regained its magical power.</col>";
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("<col=4f006f>A Tele Block spell has been cast on you by (.+). It will expire in 1 minute, 15 seconds.</col>");
private static final Pattern FULL_TELEBLOCK_PATTERN = Pattern.compile("<col=4f006f>A Tele Block spell has been cast on you by (.+). It will expire in 5 minutes, 0 seconds.</col>");
private static final Pattern HALF_TELEBLOCK_PATTERN = Pattern.compile("<col=4f006f>A Tele Block spell has been cast on you by (.+). It will expire in 2 minutes, 30 seconds.</col>");
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))

View File

@@ -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);

View File

@@ -67,10 +67,10 @@ public class TimeablePanel<T> 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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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++;

View File

@@ -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;

View File

@@ -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 ->

View File

@@ -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);

View File

@@ -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)),

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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<String, Font> fontMap;
private static final HashMap<Font, CachedFont> 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<String, Font> _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);
}
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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());
}
}