Merge pull request #785 from se7enAte9/menufixes

Menufixes
This commit is contained in:
Ganom
2019-06-28 01:11:40 -04:00
committed by GitHub
5 changed files with 29 additions and 98 deletions

View File

@@ -64,8 +64,8 @@ public class ComparableEntry
public ComparableEntry(String option, String target, int id, int type, boolean strictOption, boolean strictTarget)
{
this.option = option;
this.target = target;
this.option = Text.standardize(option);
this.target = Text.standardize(target);
this.id = id;
this.type = type;
this.strictOption = strictOption;
@@ -76,7 +76,7 @@ public class ComparableEntry
// target sometimes changes to option.
public ComparableEntry(MenuEntry e)
{
this.option = e.getOption();
this.option = Text.standardize(e.getOption());
this.id = e.getIdentifier();
this.type = e.getType();
this.strictOption = true;

View File

@@ -265,7 +265,7 @@ public class MenuManager
{
MenuEntry original = MenuEntry.copy(e);
e.setType(newType);
originalType = new EntryTypeMapping(new ComparableEntry(e), original);
originalType = new EntryTypeMapping(new ComparableEntry(leftClickEntry), original);
}
}
@@ -750,7 +750,7 @@ public class MenuManager
{
MenuEntry entry = event.getMenuEntry();
if (!entry.getTarget().equals(entry.getOption()) && !comparable.matches(entry))
if (event.getTarget().equals("do not edit") || !comparable.matches(entry))
{
return false;
}

View File

@@ -48,7 +48,6 @@ import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Actor;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.ItemID;
import net.runelite.api.MenuEntry;
import net.runelite.api.MessageNode;
@@ -262,10 +261,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
overlayManager.add(widgetsOverlay);
overlayManager.add(sceneOverlay);
keyManager.registerKeyListener(this);
if (client.getGameState() == GameState.LOGGED_IN)
{
clientThread.invoke(this::validateGame);
}
clientThread.invoke(this::validateGame);
}
@Override

View File

@@ -885,55 +885,29 @@ default CharterOption charterOption()
// Skilling
//------------------------------------------------------------//
/* @ConfigItem(
keyName = "easyConstruction",
name = "Easy Construction",
description = "Makes 'Remove'/'Build' the default option for listed item ID's in build mode.<br>Tip: Use dev tools \"'Game Objects\" to find out the ID!",
position = 59,
group = "Skilling"
)
default boolean getEasyConstruction()
{
return false;
}
@ConfigItem(
keyName = "constructionItems",
name = "Construction Items",
description = "Makes 'Remove'/'Build' the default option for listed item ID's in build mode.<br>Tip: Use dev tools \"Game Objects\" to find out the ID, and separate values with a ','",
position = 60,
group = "Skilling",
hidden = true,
unhide = "easyConstruction"
)
default String getConstructionItems()
{
return "";
}*/
@ConfigItem(
keyName = "getTempConstruction",
keyName = "getEasyConstruction",
name = "Easy Construction",
description = "Makes 'Remove'/'Build' the default option for listed items.",
position = 0,
group = "Skilling"
)
default boolean getTempConstruction()
default boolean getEasyConstruction()
{
return true;
}
@ConfigItem(
keyName = "getTempConstructionItems",
keyName = "getEasyConstructionItems",
name = "Build Items",
description = "",
position = 1,
group = "Skilling",
hidden = true,
unhide = "getTempConstruction"
unhide = "getEasyConstruction"
)
default String getTempConstructionItems()
default String getEasyConstructionItems()
{
return "";
}

View File

@@ -116,7 +116,7 @@ public class MenuEntrySwapperPlugin extends Plugin
}
private MenuEntry[] entries;
private final Set<Integer> leftClickConstructionIDs = new HashSet<>();
private final Set<String> leftClickConstructionItems = new HashSet<>();
private boolean buildingMode;
private static final WidgetMenuOption FIXED_INVENTORY_TAB_CONFIGURE = new WidgetMenuOption(CONFIGURE,
@@ -192,8 +192,7 @@ public class MenuEntrySwapperPlugin extends Plugin
public void startUp()
{
addSwaps();
//todo re-enable when fixed.
/*loadConstructionIDs(config.getConstructionItems());*/
loadConstructionItems(config.getEasyConstructionItems());
if (config.shiftClickCustomization())
{
@@ -207,8 +206,7 @@ public class MenuEntrySwapperPlugin extends Plugin
public void shutDown()
{
disableCustomization();
//todo re-enable when fixed.
/*loadConstructionIDs("");*/
loadConstructionItems("");
loadCustomSwaps(""); // Removes all custom swaps
removeSwaps();
}
@@ -220,9 +218,8 @@ public class MenuEntrySwapperPlugin extends Plugin
{
return;
}
//todo re-enable when fixed.
/*loadConstructionIDs(config.getConstructionItems());*/
loadConstructionItems(config.getEasyConstructionItems());
removeSwaps();
addSwaps();
@@ -317,9 +314,8 @@ public class MenuEntrySwapperPlugin extends Plugin
{
return;
}
//todo re-enable when fixed.
/*loadConstructionIDs(config.getConstructionItems());*/
loadConstructionItems(config.getEasyConstructionItems());
}
@Subscribe
@@ -1246,37 +1242,6 @@ public class MenuEntrySwapperPlugin extends Plugin
{
swap(client, "teleport menu", option, target, true);
}
if (config.getTempConstruction() && buildingMode && !Strings.isNullOrEmpty(config.getTempConstructionItems()))
{
if (event.getType() == WALK.getId())
{
MenuEntry[] menuEntries = client.getMenuEntries();
MenuEntry menuEntry = menuEntries[menuEntries.length - 1];
menuEntry.setType(MenuAction.WALK.getId() + MENU_ACTION_DEPRIORITIZE_OFFSET);
client.setMenuEntries(menuEntries);
}
swap(client, "Build", option, target);
MenuEntry[] entries = client.getMenuEntries();
for (int i = entries.length - 1; i >= 0; i--)
{
for (String temp : config.getTempConstructionItems().split(","))
{
if (temp.equalsIgnoreCase(Text.removeTags(entries[i].getTarget())))
{
if (!entries[i].getOption().equalsIgnoreCase("remove"))
{
entries = ArrayUtils.remove(entries, i);
i--;
}
}
}
}
client.setMenuEntries(entries);
}
}
@Subscribe
@@ -1520,25 +1485,24 @@ public class MenuEntrySwapperPlugin extends Plugin
return location.getRegionID() == PURO_PURO_REGION_ID;
}
}
//todo re-enable when fixed.
/* private void loadConstructionIDs(String from)
private void loadConstructionItems(String from)
{
if (client.getGameState() != GameState.LOGGED_IN
|| Strings.isNullOrEmpty(from) && leftClickConstructionIDs.isEmpty())
|| Strings.isNullOrEmpty(from) && leftClickConstructionItems.isEmpty())
{
return;
}
if (!leftClickConstructionIDs.isEmpty())
if (!leftClickConstructionItems.isEmpty())
{
for (int i : leftClickConstructionIDs)
for (String s : leftClickConstructionItems)
{
menuManager.toggleLeftClick("build", i, true);
menuManager.toggleLeftClick("remove", i, true);
menuManager.removePriorityEntry("build", s);
menuManager.removePriorityEntry("remove", s);
}
leftClickConstructionIDs.clear();
leftClickConstructionItems.clear();
}
if (config.getEasyConstruction() &&
@@ -1547,21 +1511,18 @@ public class MenuEntrySwapperPlugin extends Plugin
{
for (String s : Text.fromCSV(from))
{
int id = Integer.parseInt(s.replaceAll("[^0-9]", ""));
if (leftClickConstructionIDs.contains(id))
if (leftClickConstructionItems.contains(s))
{
continue;
}
if (menuManager.toggleLeftClick("build", id, false)
|| menuManager.toggleLeftClick("remove", id, false))
{
leftClickConstructionIDs.add(id);
}
menuManager.addPriorityEntry("build", s);
menuManager.addPriorityEntry("remove", s);
leftClickConstructionItems.add(s);
}
}
}*/
}
void startShift()
{