use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class ScreenshotPluginTest method testAttack.
@Test
public void testAttack() {
Widget widget = mock(Widget.class);
when(widget.getId()).thenReturn(PACK(LEVEL_UP_GROUP_ID, 0));
Widget skillChild = mock(Widget.class);
when(client.getWidget(Matchers.eq(LEVEL_UP_SKILL))).thenReturn(skillChild);
Widget levelChild = mock(Widget.class);
when(client.getWidget(Matchers.eq(LEVEL_UP_LEVEL))).thenReturn(levelChild);
when(skillChild.getText()).thenReturn("Congratulations, you just advanced an Attack level.");
when(levelChild.getText()).thenReturn("Your Attack level is now 70.");
assertEquals("Attack(70)", screenshotPlugin.parseLevelUpWidget(LEVEL_UP_SKILL, LEVEL_UP_LEVEL));
WidgetHiddenChanged event = new WidgetHiddenChanged();
event.setWidget(widget);
screenshotPlugin.hideWidgets(event);
verify(overlayRenderer).requestScreenshot(Matchers.any(Consumer.class));
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class BankTagsPlugin method onMenuOptionClicked.
@Subscribe
public void onMenuOptionClicked(MenuOptionClicked event) {
if (event.getWidgetId() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && event.getMenuAction() == MenuAction.EXAMINE_ITEM_BANK_EQ && event.getId() == EDIT_TAGS_MENU_INDEX) {
int inventoryIndex = event.getActionParam();
ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
if (bankContainer == null) {
return;
}
Item[] items = bankContainer.getItems();
if (inventoryIndex < 0 || inventoryIndex >= items.length) {
return;
}
Item item = bankContainer.getItems()[inventoryIndex];
if (item == null) {
return;
}
int itemId = item.getId();
String itemName = itemManager.getItemComposition(itemId).getName();
String initialValue = getTags(itemId);
chatboxInputManager.openInputWindow(itemName + " Tags", initialValue, (newTags) -> {
if (newTags == null) {
return;
}
setTags(itemId, newTags);
Widget bankContainerWidget = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
if (bankContainerWidget == null) {
return;
}
Widget[] bankItemWidgets = bankContainerWidget.getDynamicChildren();
if (bankItemWidgets == null || inventoryIndex >= bankItemWidgets.length) {
return;
}
Widget bankItemWidget = bankItemWidgets[inventoryIndex];
String[] actions = bankItemWidget.getActions();
if (actions == null || EDIT_TAGS_MENU_INDEX - 1 >= actions.length) {
return;
}
int tagCount = getTagCount(itemId);
actions[EDIT_TAGS_MENU_INDEX - 1] = EDIT_TAGS_MENU_OPTION;
if (tagCount > 0) {
actions[EDIT_TAGS_MENU_INDEX - 1] += " (" + tagCount + ")";
}
});
}
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class BankTitle method update.
void update(long gePrice, long haPrice) {
Widget widgetBankTitleBar = client.getWidget(WidgetInfo.BANK_TITLE_BAR);
// Don't update on a search because rs seems to constantly update the title
if (widgetBankTitleBar == null || widgetBankTitleBar.isHidden() || widgetBankTitleBar.getText().contains("Showing") || widgetBankTitleBar.getText().contains("(")) {
return;
}
String strCurrentTab = "";
if (config.showGE() && gePrice != 0) {
strCurrentTab += " (EX: " + StackFormatter.quantityToStackSize(gePrice) + ")";
}
if (config.showHA() && haPrice != 0) {
strCurrentTab += " (HA: " + StackFormatter.quantityToStackSize(haPrice) + ")";
}
log.debug("Setting bank title: {}", bankTitle + strCurrentTab);
widgetBankTitleBar.setText(bankTitle + strCurrentTab);
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class BankTitle method save.
void save() {
Widget widgetBankTitleBar = client.getWidget(WidgetInfo.BANK_TITLE_BAR);
// Don't update on a search because rs seems to constantly update the title
if (widgetBankTitleBar == null || widgetBankTitleBar.isHidden() || widgetBankTitleBar.getText().contains("(") || widgetBankTitleBar.getText().contains("Showing")) {
return;
}
bankTitle = widgetBankTitleBar.getText();
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class BankValuePlugin method onGameTick.
@Subscribe
public void onGameTick(GameTick event) {
Widget widgetBankTitleBar = client.getWidget(WidgetInfo.BANK_TITLE_BAR);
if (widgetBankTitleBar == null || widgetBankTitleBar.isHidden()) {
return;
}
bankTitle.save();
bankCalculation.calculate();
if (bankCalculation.isFinished()) {
bankTitle.update(bankCalculation.getGePrice(), bankCalculation.getHaPrice());
}
}
Aggregations