ge plugin: add grand exchange total value
Co-authored-by: Adam <Adam@sigterm.info>
This commit is contained in:
@@ -74,4 +74,26 @@ public interface GrandExchangeConfig extends Config
|
|||||||
{
|
{
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ import net.runelite.api.events.MenuEntryAdded;
|
|||||||
import net.runelite.client.events.SessionClose;
|
import net.runelite.client.events.SessionClose;
|
||||||
import net.runelite.client.events.SessionOpen;
|
import net.runelite.client.events.SessionOpen;
|
||||||
import net.runelite.api.events.WidgetLoaded;
|
import net.runelite.api.events.WidgetLoaded;
|
||||||
|
import net.runelite.api.events.ScriptCallbackEvent;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetID;
|
import net.runelite.api.widgets.WidgetID;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
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
|
@Subscribe
|
||||||
public void onGameTick(GameTick event)
|
public void onGameTick(GameTick event)
|
||||||
{
|
{
|
||||||
|
|||||||
1
runelite-client/src/main/scripts/GELayout.hash
Normal file
1
runelite-client/src/main/scripts/GELayout.hash
Normal file
@@ -0,0 +1 @@
|
|||||||
|
03E202EADA91DB0D5EE9B98E360685149F29B10A1C565B9BE65C2A50BD262BC3
|
||||||
101
runelite-client/src/main/scripts/GELayout.rs2asm
Normal file
101
runelite-client/src/main/scripts/GELayout.rs2asm
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
.id 806
|
||||||
|
.int_stack_count 7
|
||||||
|
.string_stack_count 0
|
||||||
|
.int_var_count 9
|
||||||
|
.string_var_count 0
|
||||||
|
iload 6
|
||||||
|
invoke 41
|
||||||
|
get_varbit 4439
|
||||||
|
iconst 1
|
||||||
|
sub
|
||||||
|
istore 7
|
||||||
|
iconst 105
|
||||||
|
iconst 118
|
||||||
|
iconst 150
|
||||||
|
iload 7
|
||||||
|
enum
|
||||||
|
istore 8
|
||||||
|
iload 8
|
||||||
|
iconst -1
|
||||||
|
if_icmpeq LABEL16
|
||||||
|
jump LABEL37
|
||||||
|
LABEL16:
|
||||||
|
iconst 1
|
||||||
|
iload 2
|
||||||
|
if_sethide
|
||||||
|
iconst 0
|
||||||
|
iload 3
|
||||||
|
if_sethide
|
||||||
|
iconst 1
|
||||||
|
iload 4
|
||||||
|
if_sethide
|
||||||
|
iconst 1
|
||||||
|
iload 5
|
||||||
|
if_sethide
|
||||||
|
iload 0
|
||||||
|
iload 1
|
||||||
|
cc_find
|
||||||
|
iconst 1
|
||||||
|
if_icmpeq LABEL34
|
||||||
|
jump LABEL36
|
||||||
|
LABEL34:
|
||||||
|
sconst "Grand Exchange"
|
||||||
|
sconst "setGETitle" ;
|
||||||
|
runelite_callback ;
|
||||||
|
cc_settext
|
||||||
|
LABEL36:
|
||||||
|
return
|
||||||
|
LABEL37:
|
||||||
|
iconst 0
|
||||||
|
iload 2
|
||||||
|
if_sethide
|
||||||
|
iconst 0
|
||||||
|
iload 2
|
||||||
|
if_settrans
|
||||||
|
iload 7
|
||||||
|
stockmarket_isofferempty
|
||||||
|
iconst 1
|
||||||
|
if_icmpeq LABEL48
|
||||||
|
jump LABEL66
|
||||||
|
LABEL48:
|
||||||
|
iconst 1
|
||||||
|
iload 3
|
||||||
|
if_sethide
|
||||||
|
iconst 1
|
||||||
|
iload 4
|
||||||
|
if_sethide
|
||||||
|
iconst 0
|
||||||
|
iload 5
|
||||||
|
if_sethide
|
||||||
|
iload 0
|
||||||
|
iload 1
|
||||||
|
cc_find
|
||||||
|
iconst 1
|
||||||
|
if_icmpeq LABEL63
|
||||||
|
jump LABEL65
|
||||||
|
LABEL63:
|
||||||
|
sconst "Grand Exchange: Set up offer"
|
||||||
|
cc_settext
|
||||||
|
LABEL65:
|
||||||
|
return
|
||||||
|
LABEL66:
|
||||||
|
iconst 1
|
||||||
|
iload 3
|
||||||
|
if_sethide
|
||||||
|
iconst 0
|
||||||
|
iload 4
|
||||||
|
if_sethide
|
||||||
|
iconst 1
|
||||||
|
iload 5
|
||||||
|
if_sethide
|
||||||
|
iload 0
|
||||||
|
iload 1
|
||||||
|
cc_find
|
||||||
|
iconst 1
|
||||||
|
if_icmpeq LABEL81
|
||||||
|
jump LABEL83
|
||||||
|
LABEL81:
|
||||||
|
sconst "Grand Exchange: Offer status"
|
||||||
|
cc_settext
|
||||||
|
LABEL83:
|
||||||
|
return
|
||||||
Reference in New Issue
Block a user