use of net.runelite.api.events.WidgetHiddenChanged in project runelite by runelite.
the class ScreenshotPluginTest method testFiremaking.
@Test
public void testFiremaking() {
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 a Firemaking level.");
when(levelChild.getText()).thenReturn("Your Firemaking level is now 9.");
assertEquals("Firemaking(9)", 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.events.WidgetHiddenChanged in project runelite by runelite.
the class ScreenshotPluginTest method testHunter.
@Test
public void testHunter() {
Widget widget = mock(Widget.class);
when(widget.getId()).thenReturn(PACK(DIALOG_SPRITE_GROUP_ID, 0));
Widget skillChild = mock(Widget.class);
when(client.getWidget(Matchers.eq(DIALOG_SPRITE_SPRITE))).thenReturn(skillChild);
Widget levelChild = mock(Widget.class);
when(client.getWidget(Matchers.eq(DIALOG_SPRITE_TEXT))).thenReturn(levelChild);
when(skillChild.getText()).thenReturn("Congratulations, you just advanced a Hunter level.");
when(levelChild.getText()).thenReturn("Your Hunter level is now 2.");
assertEquals("Hunter(2)", screenshotPlugin.parseLevelUpWidget(DIALOG_SPRITE_SPRITE, DIALOG_SPRITE_TEXT));
WidgetHiddenChanged event = new WidgetHiddenChanged();
event.setWidget(widget);
screenshotPlugin.hideWidgets(event);
verify(overlayRenderer).requestScreenshot(Matchers.any(Consumer.class));
}
use of net.runelite.api.events.WidgetHiddenChanged in project runelite by runelite.
the class RSWidgetMixin method broadcastHidden.
@Inject
@Override
public void broadcastHidden(boolean hidden) {
WidgetHiddenChanged event = new WidgetHiddenChanged();
event.setWidget(this);
event.setHidden(hidden);
eventBus.post(event);
RSWidget[] children = getChildren();
if (children != null) {
// recursive through children
for (RSWidget child : children) {
// if the widget is hidden it will not magically unhide from its parent changing
if (child == null || child.isSelfHidden())
continue;
child.broadcastHidden(hidden);
}
}
// make sure we iterate nested children as well
// cannot be null
Widget[] nestedChildren = getNestedChildren();
for (Widget nestedChild : nestedChildren) {
if (nestedChild == null || nestedChild.isSelfHidden())
continue;
((RSWidget) nestedChild).broadcastHidden(hidden);
}
}
use of net.runelite.api.events.WidgetHiddenChanged in project runelite by runelite.
the class ScreenshotPluginTest method testHitpoints.
@Test
public void testHitpoints() {
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 a Hitpoints level.");
when(levelChild.getText()).thenReturn("Your Hitpoints are now 99.");
assertEquals("Hitpoints(99)", 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.events.WidgetHiddenChanged 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));
}