Merge remote-tracking branch 'github/next'

This commit is contained in:
Adam
2018-05-03 10:00:49 -04:00
18 changed files with 392 additions and 82 deletions

View File

@@ -32,6 +32,7 @@ import javax.annotation.Nullable;
import net.runelite.api.annotations.VisibleForDevtools; import net.runelite.api.annotations.VisibleForDevtools;
import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.api.vars.AccountType;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
@@ -57,6 +58,11 @@ public interface Client extends GameEngine
void setUsername(String name); void setUsername(String name);
/**
* Gets the account type for the logged in player.
*/
AccountType getAccountType();
Canvas getCanvas(); Canvas getCanvas();
int getFPS(); int getFPS();

View File

@@ -28,5 +28,9 @@ public enum HeadIcon
{ {
MELEE, MELEE,
RANGED, RANGED,
MAGIC; MAGIC,
RETRIBUTION,
SMITE,
REDEMPTION,
RANGE_MAGE; //used by Kalphite Queen
} }

View File

@@ -339,7 +339,12 @@ public enum Varbits
/** /**
* Automatically weed farming patches * Automatically weed farming patches
*/ */
AUTOWEED(5557); AUTOWEED(5557),
/**
* The varbit that stores the players {@code AccountType}.
*/
ACCOUNT_TYPE(1777);
/** /**
* varbit id * varbit id

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018, Joshua Filby <joshua@filby.me>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api.vars;
/**
* An enumeration of possible account types.
*/
public enum AccountType
{
NORMAL,
IRONMAN,
ULTIMATE_IRONMAN,
HARDCORE_IRONMAN;
/**
* Check if the {@code AccountType} is any of the possible ironman types.
*
* @return {@code true} if the type is any of the ironman types.
*/
public boolean isIronman()
{
return this.ordinal() >= IRONMAN.ordinal() && this.ordinal() <= HARDCORE_IRONMAN.ordinal();
}
}

View File

@@ -28,33 +28,34 @@ import java.applet.Applet;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.updatecheck.UpdateCheckClient; import net.runelite.http.api.updatecheck.UpdateCheckClient;
@Slf4j @Slf4j
public class ClientLoader public class ClientLoader
{ {
public Optional<Applet> loadRs(boolean disableUpdateCheck) public Applet loadRs(UpdateCheckMode updateMode)
{ {
boolean isOutdated = false; if (updateMode == UpdateCheckMode.AUTO)
if (!disableUpdateCheck)
{ {
final UpdateCheckClient updateCheck = new UpdateCheckClient(); final UpdateCheckClient updateCheck = new UpdateCheckClient();
isOutdated = updateCheck.isOutdated(); updateMode = updateCheck.isOutdated() ?
UpdateCheckMode.VANILLA :
UpdateCheckMode.RUNELITE;
} }
try try
{ {
if (isOutdated) switch (updateMode)
{ {
log.info("RuneLite is outdated - fetching vanilla client"); case RUNELITE:
return Optional.of(loadVanilla()); return loadRuneLite();
default:
case VANILLA:
return loadVanilla();
case NONE:
return null;
} }
log.debug("RuneLite is up to date");
return Optional.of(loadRuneLite());
} }
catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e) catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e)
{ {
@@ -66,7 +67,8 @@ public class ClientLoader
} }
log.error("Error loading RS!", e); log.error("Error loading RS!", e);
return Optional.empty(); System.exit(-1);
return null;
} }
} }
@@ -102,9 +104,9 @@ public class ClientLoader
// Must set parent classloader to null, or it will pull from // Must set parent classloader to null, or it will pull from
// this class's classloader first // this class's classloader first
URLClassLoader classloader = new URLClassLoader(new URL[] URLClassLoader classloader = new URLClassLoader(new URL[]
{ {
url url
}, null); }, null);
Class<?> clientClass = classloader.loadClass(initialClass); Class<?> clientClass = classloader.loadClass(initialClass);
Applet rs = (Applet) clientClass.newInstance(); Applet rs = (Applet) clientClass.newInstance();

View File

@@ -27,19 +27,28 @@ package net.runelite.client;
import com.google.common.escape.Escaper; import com.google.common.escape.Escaper;
import com.google.common.escape.Escapers; import com.google.common.escape.Escapers;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.TrayIcon; import java.awt.TrayIcon;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.inject.Provider; import javax.inject.Provider;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.ClientUI;
import net.runelite.client.util.OSType; import net.runelite.client.util.OSType;
@@ -48,6 +57,25 @@ import net.runelite.client.util.OSType;
@Slf4j @Slf4j
public class Notifier public class Notifier
{ {
@Getter
@RequiredArgsConstructor
public enum NotificationMode
{
TRAY("System tray"),
BEEP("System beep"),
MESSAGE("Game message"),
FLASH("Screen flash"),
OFF("Off");
private final String name;
@Override
public String toString()
{
return name;
}
}
// Default timeout of notification in milliseconds // Default timeout of notification in milliseconds
private static final int DEFAULT_TIMEOUT = 10000; private static final int DEFAULT_TIMEOUT = 10000;
private static final String DOUBLE_QUOTE = "\""; private static final String DOUBLE_QUOTE = "\"";
@@ -55,24 +83,32 @@ public class Notifier
.addEscape('"', "'") .addEscape('"', "'")
.build(); .build();
// Notifier properties
private static final Color FLASH_COLOR = new Color(255, 0, 0, 70);
private static final int FLASH_DURATION = 2000;
private static final String MESSAGE_COLOR = "FF0000";
private final Provider<Client> client;
private final String appName; private final String appName;
private final RuneLiteConfig runeLiteConfig; private final RuneLiteConfig runeLiteConfig;
private final Provider<ClientUI> clientUI; private final Provider<ClientUI> clientUI;
private final ScheduledExecutorService executorService; private final ScheduledExecutorService executorService;
private final Path notifyIconPath; private final Path notifyIconPath;
private Instant flashStart;
@Inject @Inject
private Notifier( private Notifier(
final Provider<ClientUI> clientUI, final Provider<ClientUI> clientUI,
final Provider<Client> client,
final RuneLiteConfig runeliteConfig, final RuneLiteConfig runeliteConfig,
final RuneLiteProperties runeLiteProperties, final RuneLiteProperties runeLiteProperties,
final ScheduledExecutorService executorService) final ScheduledExecutorService executorService)
{ {
this.client = client;
this.appName = runeLiteProperties.getTitle(); this.appName = runeLiteProperties.getTitle();
this.clientUI = clientUI; this.clientUI = clientUI;
this.runeLiteConfig = runeliteConfig; this.runeLiteConfig = runeliteConfig;
this.executorService = executorService; this.executorService = executorService;
this.notifyIconPath = RuneLite.RUNELITE_DIR.toPath().resolve("icon.png"); this.notifyIconPath = RuneLite.RUNELITE_DIR.toPath().resolve("icon.png");
storeIcon(); storeIcon();
} }
@@ -101,26 +137,63 @@ public class Notifier
clientUI.requestFocus(); clientUI.requestFocus();
} }
if (runeLiteConfig.enableTrayNotifications()) switch (runeLiteConfig.notificationMode())
{ {
sendNotification(appName, message, type, null); case TRAY:
sendNotification(appName, message, type);
break;
case BEEP:
Toolkit.getDefaultToolkit().beep();
break;
case MESSAGE:
final Client client = this.client.get();
if (client != null && client.getGameState() == GameState.LOGGED_IN)
{
client.addChatMessage(ChatMessageType.GAME, appName,
"<col=" + MESSAGE_COLOR + ">" + message + "</col>", "");
}
break;
case FLASH:
flashStart = Instant.now();
break;
}
}
public void processFlash(final Graphics2D graphics)
{
if (flashStart == null)
{
return;
} }
if (runeLiteConfig.enableNotificationSound()) final Client client = this.client.get();
if (client == null || client.getGameCycle() % 40 >= 20)
{ {
Toolkit.getDefaultToolkit().beep(); return;
}
final Color color = graphics.getColor();
graphics.setColor(FLASH_COLOR);
graphics.fill(new Rectangle(client.getCanvas().getSize()));
graphics.setColor(color);
if (Instant.now().minusMillis(FLASH_DURATION).isAfter(flashStart))
{
flashStart = null;
} }
} }
private void sendNotification( private void sendNotification(
final String title, final String title,
final String message, final String message,
final TrayIcon.MessageType type, final TrayIcon.MessageType type)
final String subtitle)
{ {
final String escapedTitle = SHELL_ESCAPE.escape(title); final String escapedTitle = SHELL_ESCAPE.escape(title);
final String escapedMessage = SHELL_ESCAPE.escape(message); final String escapedMessage = SHELL_ESCAPE.escape(message);
final String escapedSubtitle = subtitle != null ? SHELL_ESCAPE.escape(subtitle) : null; final String escapedSubtitle = null;
switch (OSType.getOSType()) switch (OSType.getOSType())
{ {

View File

@@ -34,10 +34,11 @@ import com.google.inject.Injector;
import com.google.inject.Provider; import com.google.inject.Provider;
import java.applet.Applet; import java.applet.Applet;
import java.io.File; import java.io.File;
import java.util.Optional;
import javax.inject.Singleton; import javax.inject.Singleton;
import joptsimple.ArgumentAcceptingOptionSpec;
import joptsimple.OptionParser; import joptsimple.OptionParser;
import joptsimple.OptionSet; import joptsimple.OptionSet;
import joptsimple.util.EnumConverter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.client.account.SessionManager; import net.runelite.client.account.SessionManager;
@@ -119,12 +120,29 @@ public class RuneLite
public static void main(String[] args) throws Exception public static void main(String[] args) throws Exception
{ {
OptionParser parser = new OptionParser(); OptionParser parser = new OptionParser();
parser.accepts("developer-mode"); parser.accepts("developer-mode", "Enable developer tools");
parser.accepts("no-rs"); parser.accepts("debug", "Show extra debugging output");
parser.accepts("debug"); ArgumentAcceptingOptionSpec<UpdateCheckMode> updateMode = parser.accepts("rs", "Select client type")
parser.accepts("disable-update-check"); .withRequiredArg()
.ofType(UpdateCheckMode.class)
.defaultsTo(UpdateCheckMode.AUTO)
.withValuesConvertedBy(new EnumConverter<UpdateCheckMode>(UpdateCheckMode.class)
{
@Override
public UpdateCheckMode convert(String v)
{
return super.convert(v.toUpperCase());
}
});
parser.accepts("help", "Show this text").forHelp();
setOptions(parser.parse(args)); setOptions(parser.parse(args));
if (getOptions().has("help"))
{
parser.printHelpOn(System.out);
System.exit(0);
}
PROFILES_DIR.mkdirs(); PROFILES_DIR.mkdirs();
// Setup logger // Setup logger
@@ -137,26 +155,15 @@ public class RuneLite
} }
setInjector(Guice.createInjector(new RuneLiteModule())); setInjector(Guice.createInjector(new RuneLiteModule()));
injector.getInstance(RuneLite.class).start(); injector.getInstance(RuneLite.class).start(getOptions().valueOf(updateMode));
} }
public void start() throws Exception public void start(UpdateCheckMode updateMode) throws Exception
{ {
// Load RuneLite or Vanilla client // Load RuneLite or Vanilla client
final boolean hasRs = !getOptions().has("no-rs"); final Applet client = new ClientLoader().loadRs(updateMode);
final boolean disableUpdateCheck = getOptions().has("disable-update-check");
final Optional<Applet> optionalClient = hasRs
? new ClientLoader().loadRs(disableUpdateCheck)
: Optional.empty();
if (!optionalClient.isPresent() && hasRs) final boolean isOutdated = !(client instanceof Client);
{
System.exit(-1);
return;
}
final Applet client = optionalClient.orElse(null);
final boolean isOutdated = client == null || !(client instanceof Client);
if (!isOutdated) if (!isOutdated)
{ {

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2018 Abex
* 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;
public enum UpdateCheckMode
{
AUTO,
NONE,
VANILLA,
RUNELITE
}

View File

@@ -64,6 +64,7 @@ import net.runelite.api.events.ProjectileMoved;
import net.runelite.api.events.SetMessage; import net.runelite.api.events.SetMessage;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import static net.runelite.api.widgets.WidgetID.WORLD_MAP; import static net.runelite.api.widgets.WidgetID.WORLD_MAP;
import net.runelite.client.Notifier;
import net.runelite.client.RuneLite; import net.runelite.client.RuneLite;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.input.KeyManager; import net.runelite.client.input.KeyManager;
@@ -98,6 +99,7 @@ public class Hooks
private static final ClientThread clientThread = injector.getInstance(ClientThread.class); private static final ClientThread clientThread = injector.getInstance(ClientThread.class);
private static final GameTick tick = new GameTick(); private static final GameTick tick = new GameTick();
private static final DrawManager renderHooks = injector.getInstance(DrawManager.class); private static final DrawManager renderHooks = injector.getInstance(DrawManager.class);
private static final Notifier notifier = injector.getInstance(Notifier.class);
private static Dimension lastStretchedDimensions; private static Dimension lastStretchedDimensions;
private static BufferedImage stretchedImage; private static BufferedImage stretchedImage;
@@ -267,6 +269,8 @@ public class Hooks
log.warn("Error during overlay rendering", ex); log.warn("Error during overlay rendering", ex);
} }
notifier.processFlash(graphics2d);
// Stretch the game image if the user has that enabled // Stretch the game image if the user has that enabled
if (!client.isResized() && client.isStretchedEnabled()) if (!client.isResized() && client.isStretchedEnabled())
{ {

View File

@@ -26,6 +26,7 @@ package net.runelite.client.config;
import java.awt.Dimension; import java.awt.Dimension;
import net.runelite.api.Constants; import net.runelite.api.Constants;
import net.runelite.client.Notifier;
@ConfigGroup( @ConfigGroup(
keyName = "runelite", keyName = "runelite",
@@ -80,32 +81,21 @@ public interface RuneLiteConfig extends Config
} }
@ConfigItem( @ConfigItem(
keyName = "notificationTray", keyName = "notificationMode",
name = "Enable tray notifications", name = "Notification mode",
description = "Enables tray notifications", description = "Determines mode of notifications",
position = 5 position = 5
) )
default boolean enableTrayNotifications() default Notifier.NotificationMode notificationMode()
{ {
return true; return Notifier.NotificationMode.TRAY;
}
@ConfigItem(
keyName = "notificationSound",
name = "Enable sound on notifications",
description = "Enables the playing of a beep sound when notifications are displayed",
position = 6
)
default boolean enableNotificationSound()
{
return true;
} }
@ConfigItem( @ConfigItem(
keyName = "notificationFocused", keyName = "notificationFocused",
name = "Send notifications when focused", name = "Send notifications when focused",
description = "Toggles idle notifications for when the client is focused", description = "Toggles idle notifications for when the client is focused",
position = 7 position = 6
) )
default boolean sendNotificationsWhenFocused() default boolean sendNotificationsWhenFocused()
{ {
@@ -116,7 +106,7 @@ public interface RuneLiteConfig extends Config
keyName = "notificationRequestFocus", keyName = "notificationRequestFocus",
name = "Request focus on notification", name = "Request focus on notification",
description = "Toggles window focus request", description = "Toggles window focus request",
position = 8 position = 7
) )
default boolean requestFocusOnNotification() default boolean requestFocusOnNotification()
{ {
@@ -127,7 +117,7 @@ public interface RuneLiteConfig extends Config
keyName = "fontType", keyName = "fontType",
name = "Dynamic Overlay Font", name = "Dynamic Overlay Font",
description = "Configures what font type is used for in-game overlays such as player name, ground items, etc.", description = "Configures what font type is used for in-game overlays such as player name, ground items, etc.",
position = 9 position = 8
) )
default FontType fontType() default FontType fontType()
{ {
@@ -138,7 +128,7 @@ public interface RuneLiteConfig extends Config
keyName = "infoBoxVertical", keyName = "infoBoxVertical",
name = "Display infoboxes vertically", name = "Display infoboxes vertically",
description = "Toggles the infoboxes to display vertically", description = "Toggles the infoboxes to display vertically",
position = 10 position = 9
) )
default boolean infoBoxVertical() default boolean infoBoxVertical()
{ {
@@ -149,7 +139,7 @@ public interface RuneLiteConfig extends Config
keyName = "infoBoxWrap", keyName = "infoBoxWrap",
name = "Infobox wrap count", name = "Infobox wrap count",
description = "Configures the amount of infoboxes shown before wrapping", description = "Configures the amount of infoboxes shown before wrapping",
position = 11 position = 10
) )
default int infoBoxWrap() default int infoBoxWrap()
{ {
@@ -160,7 +150,7 @@ public interface RuneLiteConfig extends Config
keyName = "containInScreen", keyName = "containInScreen",
name = "Contain in screen", name = "Contain in screen",
description = "Makes the client stay contained in the screen when attempted to move out of it.<br>Note: Only works if custom chrome is enabled.", description = "Makes the client stay contained in the screen when attempted to move out of it.<br>Note: Only works if custom chrome is enabled.",
position = 12 position = 11
) )
default boolean containInScreen() default boolean containInScreen()
{ {
@@ -171,7 +161,7 @@ public interface RuneLiteConfig extends Config
keyName = "rememberScreenBounds", keyName = "rememberScreenBounds",
name = "Remember client position", name = "Remember client position",
description = "Save the position and size of the client after exiting", description = "Save the position and size of the client after exiting",
position = 13 position = 12
) )
default boolean rememberScreenBounds() default boolean rememberScreenBounds()
{ {

View File

@@ -30,6 +30,8 @@ import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import java.awt.Color; import java.awt.Color;
import net.runelite.client.plugins.grounditems.config.ItemHighlightMode;
import net.runelite.client.plugins.grounditems.config.MenuHighlightMode;
@ConfigGroup( @ConfigGroup(
keyName = "grounditems", keyName = "grounditems",
@@ -83,25 +85,25 @@ public interface GroundItemsConfig extends Config
} }
@ConfigItem( @ConfigItem(
keyName = "highlightMenuOption", keyName = "itemHighlightMode",
name = "Highlight Menu Option", name = "Item Highlight Mode",
description = "Configures whether or not to highlight the menu option", description = "Configures how ground items will be highlighted",
position = 5 position = 5
) )
default boolean highlightMenuOption() default ItemHighlightMode itemHighlightMode()
{ {
return true; return ItemHighlightMode.BOTH;
} }
@ConfigItem( @ConfigItem(
keyName = "highlightMenuItemName", keyName = "menuHighlightMode",
name = "Highlight Menu Item Name", name = "Menu Highlight Mode",
description = "Configures whether or not to highlight the menu item name", description = "Configures what to highlight in right-click menu",
position = 6 position = 6
) )
default boolean highlightMenuItemName() default MenuHighlightMode menuHighlightMode()
{ {
return false; return MenuHighlightMode.NAME;
} }
@ConfigItem( @ConfigItem(

View File

@@ -40,6 +40,7 @@ import net.runelite.api.Point;
import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import static net.runelite.client.plugins.grounditems.config.ItemHighlightMode.MENU;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
@@ -83,6 +84,11 @@ public class GroundItemsOverlay extends Overlay
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
if (!plugin.isHotKeyPressed() && config.itemHighlightMode() == MENU)
{
return null;
}
final FontMetrics fm = graphics.getFontMetrics(); final FontMetrics fm = graphics.getFontMetrics();
final Player player = client.getLocalPlayer(); final Player player = client.getLocalPlayer();

View File

@@ -75,6 +75,11 @@ import net.runelite.client.input.KeyManager;
import net.runelite.client.input.MouseManager; import net.runelite.client.input.MouseManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import static net.runelite.client.plugins.grounditems.config.ItemHighlightMode.OVERLAY;
import net.runelite.client.plugins.grounditems.config.MenuHighlightMode;
import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.BOTH;
import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.NAME;
import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.OPTION;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.http.api.item.ItemPrice; import net.runelite.http.api.item.ItemPrice;
@@ -338,7 +343,8 @@ public class GroundItemsPlugin extends Plugin
@Subscribe @Subscribe
public void onMenuEntryAdded(MenuEntryAdded event) public void onMenuEntryAdded(MenuEntryAdded event)
{ {
if ((config.highlightMenuOption() || config.highlightMenuItemName()) && event.getOption().equals("Take") if (config.itemHighlightMode() != OVERLAY
&& event.getOption().equals("Take")
&& event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId()) && event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId())
{ {
int itemId = event.getIdentifier(); int itemId = event.getIdentifier();
@@ -382,11 +388,14 @@ public class GroundItemsPlugin extends Plugin
{ {
String hexColor = Integer.toHexString(color.getRGB() & 0xFFFFFF); String hexColor = Integer.toHexString(color.getRGB() & 0xFFFFFF);
String colTag = "<col=" + hexColor + ">"; String colTag = "<col=" + hexColor + ">";
if (config.highlightMenuOption()) final MenuHighlightMode mode = config.menuHighlightMode();
if (mode == BOTH || mode == OPTION)
{ {
lastEntry.setOption(colTag + "Take"); lastEntry.setOption(colTag + "Take");
} }
if (config.highlightMenuItemName())
if (mode == BOTH || mode == NAME)
{ {
String target = lastEntry.getTarget().substring(lastEntry.getTarget().indexOf(">") + 1); String target = lastEntry.getTarget().substring(lastEntry.getTarget().indexOf(">") + 1);
lastEntry.setTarget(colTag + target); lastEntry.setTarget(colTag + target);

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* 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.grounditems.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@Getter
@RequiredArgsConstructor
public enum ItemHighlightMode
{
OVERLAY("Overlay"),
MENU("Right-click menu"),
BOTH("Both");
private final String name;
@Override
public String toString()
{
return name;
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* 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.grounditems.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@Getter
@RequiredArgsConstructor
public enum MenuHighlightMode
{
OPTION("Menu option"),
NAME("Menu item name"),
BOTH("Both");
private final String name;
@Override
public String toString()
{
return name;
}
}

View File

@@ -27,6 +27,7 @@ package net.runelite.mixins;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.runelite.api.vars.AccountType;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.ClanMember; import net.runelite.api.ClanMember;
import net.runelite.api.GameState; import net.runelite.api.GameState;
@@ -160,6 +161,25 @@ public abstract class RSClientMixin implements RSClient
interpolateObjectAnimations = interpolate; interpolateObjectAnimations = interpolate;
} }
@Inject
@Override
public AccountType getAccountType()
{
int varbit = getVar(Varbits.ACCOUNT_TYPE);
switch (varbit)
{
case 1:
return AccountType.IRONMAN;
case 2:
return AccountType.ULTIMATE_IRONMAN;
case 3:
return AccountType.HARDCORE_IRONMAN;
}
return AccountType.NORMAL;
}
@Inject @Inject
@Override @Override
public Tile getSelectedRegionTile() public Tile getSelectedRegionTile()

View File

@@ -28,6 +28,7 @@ import net.runelite.api.HeadIcon;
import static net.runelite.api.HeadIcon.MAGIC; import static net.runelite.api.HeadIcon.MAGIC;
import static net.runelite.api.HeadIcon.MELEE; import static net.runelite.api.HeadIcon.MELEE;
import static net.runelite.api.HeadIcon.RANGED; import static net.runelite.api.HeadIcon.RANGED;
import static net.runelite.api.HeadIcon.RANGE_MAGE;
import net.runelite.api.events.NpcActionChanged; import net.runelite.api.events.NpcActionChanged;
import net.runelite.api.mixins.FieldHook; import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Inject;
@@ -50,6 +51,8 @@ public abstract class RSNpcCompositionMixin implements RSNPCComposition
return RANGED; return RANGED;
case 2: case 2:
return MAGIC; return MAGIC;
case 6:
return RANGE_MAGE;
default: default:
return null; return null;
} }

View File

@@ -31,6 +31,9 @@ import net.runelite.api.HeadIcon;
import static net.runelite.api.HeadIcon.MAGIC; import static net.runelite.api.HeadIcon.MAGIC;
import static net.runelite.api.HeadIcon.MELEE; import static net.runelite.api.HeadIcon.MELEE;
import static net.runelite.api.HeadIcon.RANGED; import static net.runelite.api.HeadIcon.RANGED;
import static net.runelite.api.HeadIcon.REDEMPTION;
import static net.runelite.api.HeadIcon.RETRIBUTION;
import static net.runelite.api.HeadIcon.SMITE;
import net.runelite.api.Model; import net.runelite.api.Model;
import net.runelite.api.Perspective; import net.runelite.api.Perspective;
import net.runelite.api.Point; import net.runelite.api.Point;
@@ -88,6 +91,12 @@ public abstract class RSPlayerMixin implements RSPlayer
return RANGED; return RANGED;
case 2: case 2:
return MAGIC; return MAGIC;
case 3:
return RETRIBUTION;
case 4:
return SMITE;
case 5:
return REDEMPTION;
default: default:
return null; return null;
} }