Merge branch 'master' into GRADLE-WRAPPER-UPDATE-cf3aab28b

This commit is contained in:
Owain van Brakel
2020-01-26 17:54:00 +01:00
committed by GitHub
14 changed files with 263 additions and 34 deletions

View File

@@ -13,7 +13,7 @@ jobs:
with:
repository: open-osrs/runelite
ref: master
-
- uses: actions/checkout@v1
with:
repository: open-osrs/cache-client

View File

@@ -6,11 +6,11 @@
[![Build Status](https://github.com/open-osrs/runelite/workflows/OpenOSRS%20-%20CI%20(push)/badge.svg)](https://github.com/open-osrs/runelite/actions?query=workflow%3A%22OpenOSRS+-+CI+%28push%29%22)
[![HitCount](http://hits.dwyl.io/open-osrs/runelite.svg)](http://hits.dwyl.io/open-osrs/runelite)
[OpenOSRS](https://openosrs.com) is an extended version of [RuneLite](https://github.com/runelite/runelite) that provides more functionality and less restrictions while staying fully open-source. We are not affiliated with RuneLite.
[OpenOSRS](https://openosrs.com) is a fully open-source client with no restrictions. We are not affiliated with Jagex or RuneLite.
## Discord
[![Discord](https://img.shields.io/discord/373382904769675265.svg)](https://discord.gg/HN5gf3m)
[![Discord](https://img.shields.io/discord/373382904769675265.svg)](https://discord.gg/openosrs)
## Project Layout

View File

@@ -33,6 +33,7 @@ import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.runelite.api.annotations.VisibleForExternalPlugins;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.hooks.Callbacks;
@@ -703,6 +704,42 @@ public interface Client extends GameShell
*/
String getVar(VarClientStr varClientStr);
/**
* Gets the value of a given VarPlayer.
*
* @param varpId the VarPlayer id
* @return the value
*/
@VisibleForExternalPlugins
int getVarpValue(int varpId);
/**
* Gets the value of a given Varbit.
*
* @param varbitId the varbit id
* @return the value
*/
@VisibleForExternalPlugins
int getVarbitValue(int varbitId);
/**
* Gets the value of a given VarClientInt
*
* @param varcIntId the VarClientInt id
* @return the value
*/
@VisibleForExternalPlugins
int getVarcIntValue(int varcIntId);
/**
* Gets the value of a given VarClientStr
*
* @param varcStrId the VarClientStr id
* @return the value
*/
@VisibleForExternalPlugins
String getVarcStrValue(int varcStrId);
/**
* Sets a VarClientString to the passed value
*/

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
* 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.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Used to indicate a method is only visible for external plugins
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
public @interface VisibleForExternalPlugins
{
}

View File

@@ -29,6 +29,7 @@ import net.runelite.client.config.Alpha;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Keybind;
@ConfigGroup(InventorySetupPlugin.CONFIG_GROUP)
public interface InventorySetupConfig extends Config
@@ -99,4 +100,26 @@ public interface InventorySetupConfig extends Config
{
return Color.RED;
}
@ConfigItem(
keyName = "returnToSetupsHotkey",
name = "Return To Setups Hotkey",
description = "Configures the hotkey for returning to setups",
position = 6
)
default Keybind returnToSetupsHotkey()
{
return Keybind.NOT_SET;
}
@ConfigItem(
keyName = "filterBankHotkey",
name = "Filter Bank Hotkey",
description = "Configures the hotkey for filtering the bank",
position = 7
)
default Keybind filterBankHotkey()
{
return Keybind.NOT_SET;
}
}

View File

@@ -46,13 +46,13 @@ import net.runelite.api.Varbits;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.events.VarClientIntChanged;
import net.runelite.api.vars.InputType;
import net.runelite.api.widgets.WidgetID;
import net.runelite.client.account.AccountSession;
import net.runelite.client.account.SessionManager;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.Keybind;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.SessionClose;
import net.runelite.client.events.SessionOpen;
@@ -61,6 +61,7 @@ import net.runelite.client.game.ItemVariationMapping;
import net.runelite.client.game.chatbox.ChatboxItemSearch;
import net.runelite.client.game.chatbox.ChatboxPanelManager;
import net.runelite.client.game.chatbox.ChatboxTextInput;
import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.banktags.tabs.BankSearch;
@@ -68,6 +69,7 @@ import net.runelite.client.plugins.runepouch.Runes;
import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.components.colorpicker.ColorPickerManager;
import net.runelite.client.util.HotkeyListener;
import net.runelite.client.util.ImageUtil;
import javax.inject.Inject;
import javax.swing.JOptionPane;
@@ -79,6 +81,7 @@ import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@PluginDescriptor(
@@ -130,6 +133,8 @@ public class InventorySetupPlugin extends Plugin
@Inject
private BankSearch bankSearch;
@Inject
private KeyManager keyManager;
@Inject
private ChatboxItemSearch itemSearch;
@Inject
private ChatboxPanelManager chatboxPanelManager;
@@ -141,6 +146,41 @@ public class InventorySetupPlugin extends Plugin
private boolean highlightUnorderedDifference;
private boolean highlightDifference;
private Color highlightColor;
private Keybind returnToSetupsHotkey;
private Keybind filterBankHotkey;
private final HotkeyListener returnToSetupsHotkeyListener = new HotkeyListener(() -> this.returnToSetupsHotkey)
{
@Override
public void hotkeyPressed()
{
panel.returnToOverviewPanel();
}
};
private final HotkeyListener filterBankHotkeyListener = new HotkeyListener(() -> this.filterBankHotkey)
{
@Override
public void hotkeyPressed()
{
// you must wait at least one game tick otherwise
// the bank filter will work but then go back to the previous tab.
// For some reason this can still happen but it is very rare,
// and only when the user clicks a tab and the hot key extremely shortly after.
int gameTick = client.getTickCount();
clientThread.invokeLater(() ->
{
int gameTick2 = client.getTickCount();
if (gameTick2 <= gameTick)
{
return false;
}
doBankSearch();
return true;
});
}
};
@Provides
InventorySetupConfig getConfig(ConfigManager configManager)
@@ -164,6 +204,8 @@ public class InventorySetupPlugin extends Plugin
.build();
clientToolbar.addNavigation(navButton);
keyManager.registerKeyListener(returnToSetupsHotkeyListener);
keyManager.registerKeyListener(filterBankHotkeyListener);
// load all the inventory setups from the config file
clientThread.invokeLater(() ->
@@ -237,15 +279,12 @@ public class InventorySetupPlugin extends Plugin
updateConfig();
}
@Subscribe
public void onWidgetLoaded(WidgetLoaded event)
public List<InventorySetup> filterSetups(String textToFilter)
{
if (event.getGroupId() != WidgetID.BANK_GROUP_ID)
{
return;
}
doBankSearch();
final String textToFilterLower = textToFilter.toLowerCase();
return inventorySetups.stream()
.filter(i -> i.getName().toLowerCase().contains(textToFilterLower))
.collect(Collectors.toList());
}
public void doBankSearch()
@@ -258,6 +297,26 @@ public class InventorySetupPlugin extends Plugin
bankSearch.search(InputType.SEARCH, INV_SEARCH + currentSelectedSetup.getName(), true);
}
}
@Subscribe
public void onVarClientIntChanged(VarClientIntChanged event)
{
if (event.getIndex() != 386)
{
return;
}
// must be invoked later otherwise causes freezing.
clientThread.invokeLater(() ->
{
// checks to see if the hide worn items button was clicked or bank was opened
int value = client.getVarcIntValue(386);
if (value == 0)
{
doBankSearch();
}
});
}
public void resetBankSearch()
{
@@ -877,6 +936,8 @@ public class InventorySetupPlugin extends Plugin
this.highlightUnorderedDifference = config.highlightUnorderedDifference();
this.highlightDifference = config.highlightDifference();
this.highlightColor = config.highlightColor();
this.returnToSetupsHotkey = config.returnToSetupsHotkey();
this.filterBankHotkey = config.filterBankHotkey();
}
}

View File

@@ -138,7 +138,7 @@ public abstract class InventorySetupContainerPanel extends JPanel
break;
}
assert index < items.size() && index > 0 : "Index Off Array";
assert index < items.size() && index >= 0 : "Index Off Array";
containerSlot.setParentSetup(setup);

View File

@@ -212,6 +212,7 @@ public class InventorySetupPanel extends JPanel
nameInput.setEditable(false);
updateNameActions(false);
requestFocusInWindow();
panel.rebuild();
}
@Override

View File

@@ -32,6 +32,7 @@ import net.runelite.api.InventoryID;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.IconTextField;
import net.runelite.client.ui.components.PluginErrorPanel;
import net.runelite.client.util.ImageUtil;
import javax.swing.Box;
@@ -47,10 +48,13 @@ import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
public class InventorySetupPluginPanel extends PluginPanel
{
@@ -81,8 +85,8 @@ public class InventorySetupPluginPanel extends PluginPanel
UPDATE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(updateIcon, 0.53f));
final BufferedImage backIcon = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "back_arrow_icon.png");
BACK_ICON = new ImageIcon(ImageUtil.flipImage(backIcon, true, false));
BACK_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(ImageUtil.flipImage(backIcon, true, false), 0.53f));
BACK_ICON = new ImageIcon(backIcon);
BACK_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(backIcon, 0.53f));
MAIN_TITLE = "Inventory Setups";
}
@@ -98,6 +102,7 @@ public class InventorySetupPluginPanel extends PluginPanel
private final JLabel addImportMarker;
private final JLabel updateMarker;
private final JLabel backMarker;
private final IconTextField searchBar;
private final InventorySetupInventoryPanel invPanel;
private final InventorySetupEquipmentPanel eqpPanel;
private final InventorySetupRunePouchPanel rpPanel;
@@ -199,14 +204,7 @@ public class InventorySetupPluginPanel extends PluginPanel
@Override
public void mousePressed(MouseEvent e)
{
noSetupsPanel.setVisible(false);
invEqPanel.setVisible(false);
overviewPanel.setVisible(true);
overviewTopRightButtonsPanel.setVisible(true);
setupTopRightButtonsPanel.setVisible(false);
title.setText(MAIN_TITLE);
currentSelectedSetup = null;
plugin.resetBankSearch();
returnToOverviewPanel();
}
@Override
@@ -222,13 +220,15 @@ public class InventorySetupPluginPanel extends PluginPanel
}
});
this.overviewTopRightButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 8, 0));
this.overviewTopRightButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
overviewTopRightButtonsPanel.add(addImportMarker);
overviewTopRightButtonsPanel.add(addMarker);
addMarker.setBorder(new EmptyBorder(0, 8, 0, 0));
this.setupTopRightButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 8, 0));
this.setupTopRightButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
setupTopRightButtonsPanel.add(updateMarker);
setupTopRightButtonsPanel.add(backMarker);
backMarker.setBorder(new EmptyBorder(0, 8, 0, 0));
// the panel on the top right that holds the buttons
final JPanel markersPanel = new JPanel();
@@ -238,11 +238,36 @@ public class InventorySetupPluginPanel extends PluginPanel
overviewTopRightButtonsPanel.setVisible(true);
setupTopRightButtonsPanel.setVisible(false);
// the top panel that has the title and the buttons
// the top panel that has the title and the buttons, and search bar
final JPanel titleAndMarkersPanel = new JPanel();
titleAndMarkersPanel.setLayout(new BorderLayout());
titleAndMarkersPanel.add(title, BorderLayout.WEST);
titleAndMarkersPanel.add(markersPanel, BorderLayout.EAST);
this.searchBar = new IconTextField();
searchBar.setIcon(IconTextField.Icon.SEARCH);
searchBar.setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH - 20, 30));
searchBar.setBackground(ColorScheme.DARKER_GRAY_COLOR);
searchBar.setHoverBackgroundColor(ColorScheme.DARK_GRAY_HOVER_COLOR);
searchBar.setMinimumSize(new Dimension(0, 30));
searchBar.addKeyListener(new KeyListener()
{
@Override
public void keyTyped(KeyEvent e)
{
}
@Override
public void keyPressed(KeyEvent e)
{
}
@Override
public void keyReleased(KeyEvent e)
{
rebuild();
}
});
searchBar.addClearListener(actionEvent -> rebuild());
// the panel that stays at the top and doesn't scroll
// contains the title and buttons
@@ -250,7 +275,8 @@ public class InventorySetupPluginPanel extends PluginPanel
northAnchoredPanel.setLayout(new BoxLayout(northAnchoredPanel, BoxLayout.Y_AXIS));
northAnchoredPanel.setBorder(new EmptyBorder(0, 0, 10, 0));
northAnchoredPanel.add(titleAndMarkersPanel);
northAnchoredPanel.add(Box.createRigidArea(new Dimension(0, 10)));
northAnchoredPanel.add(Box.createRigidArea(new Dimension(0, 5)));
northAnchoredPanel.add(searchBar);
// the panel that holds the inventory and equipment panels
final BoxLayout invEqLayout = new BoxLayout(invEqPanel, BoxLayout.Y_AXIS);
@@ -292,7 +318,7 @@ public class InventorySetupPluginPanel extends PluginPanel
}
public void init()
public void init(List<InventorySetup> setups)
{
overviewPanel.setLayout(new GridBagLayout());
overviewPanel.setBackground(ColorScheme.DARK_GRAY_COLOR);
@@ -303,7 +329,7 @@ public class InventorySetupPluginPanel extends PluginPanel
constraints.gridx = 0;
constraints.gridy = 0;
for (final InventorySetup setup : plugin.getInventorySetups())
for (final InventorySetup setup : setups)
{
InventorySetupPanel newPanel = new InventorySetupPanel(plugin, this, setup);
overviewPanel.add(newPanel, constraints);
@@ -323,7 +349,9 @@ public class InventorySetupPluginPanel extends PluginPanel
public void rebuild()
{
overviewPanel.removeAll();
init();
final String text = searchBar.getText();
List<InventorySetup> setupsToAdd = searchBar.getText().isEmpty() ? plugin.getInventorySetups() : plugin.filterSetups(searchBar.getText());
init(setupsToAdd);
revalidate();
repaint();
}
@@ -351,6 +379,7 @@ public class InventorySetupPluginPanel extends PluginPanel
overviewPanel.setVisible(false);
title.setText(inventorySetup.getName());
searchBar.setVisible(false);
// only show the rune pouch if the setup has a rune pouch
rpPanel.setVisible(currentSelectedSetup.getRune_pouch() != null);
@@ -410,5 +439,17 @@ public class InventorySetupPluginPanel extends PluginPanel
final ArrayList<InventorySetupItem> eqp = plugin.getNormalizedContainer(InventoryID.EQUIPMENT);
eqpPanel.highlightSlotDifferences(eqp, currentSelectedSetup);
}
public void returnToOverviewPanel()
{
noSetupsPanel.setVisible(false);
invEqPanel.setVisible(false);
overviewPanel.setVisible(true);
overviewTopRightButtonsPanel.setVisible(true);
setupTopRightButtonsPanel.setVisible(false);
title.setText(MAIN_TITLE);
currentSelectedSetup = null;
searchBar.setVisible(true);
plugin.resetBankSearch();
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 B

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 188 B

View File

@@ -591,6 +591,13 @@ public abstract class RSClientMixin implements RSClient
return varps[varpId];
}
@Inject
@Override
public int getVarpValue(int varpId)
{
return getVarpValue(getVarps(), varpId);
}
@Inject
@Override
public void setVarpValue(int[] varps, int varpId, int value)

View File

@@ -37,6 +37,13 @@ public abstract class VarbitMixin implements RSClient
return getVarbitValue(getVarps(), varbitId);
}
@Inject
@Override
public int getVarbitValue(int varbitId)
{
return getVarbitValue(getVarps(), varbitId);
}
@Inject
@Override
public void setVarbit(Varbits varbit, int value)
@@ -94,18 +101,32 @@ public abstract class VarbitMixin implements RSClient
@Inject
@Override
public int getVar(VarClientInt varClientInt)
{
return getVarcIntValue(varClientInt.getIndex());
}
@Inject
@Override
public int getVarcIntValue(int varcIntId)
{
Map<Integer, Object> varcmap = getVarcMap();
Object object = varcmap.get(varClientInt.getIndex());
Object object = varcmap.get(varcIntId);
return object instanceof Integer ? (Integer) object : 0;
}
@Inject
@Override
public String getVar(VarClientStr varClientStr)
{
return getVarcStrValue(varClientStr.getIndex());
}
@Inject
@Override
public String getVarcStrValue(int varcStrId)
{
Map<Integer, Object> varcmap = getVarcMap();
Object var2 = varcmap.get(varClientStr.getIndex());
Object var2 = varcmap.get(varcStrId);
return var2 instanceof String ? (String) var2 : "";
}