Search in sources :

Example 1 with WidgetHiddenChanged

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));
}
Also used : Consumer(java.util.function.Consumer) Widget(net.runelite.api.widgets.Widget) WidgetHiddenChanged(net.runelite.api.events.WidgetHiddenChanged) Test(org.junit.Test)

Example 2 with WidgetHiddenChanged

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));
}
Also used : Consumer(java.util.function.Consumer) Widget(net.runelite.api.widgets.Widget) WidgetHiddenChanged(net.runelite.api.events.WidgetHiddenChanged) Test(org.junit.Test)

Example 3 with WidgetHiddenChanged

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);
    }
}
Also used : RSWidget(net.runelite.rs.api.RSWidget) Widget(net.runelite.api.widgets.Widget) RSWidget(net.runelite.rs.api.RSWidget) WidgetHiddenChanged(net.runelite.api.events.WidgetHiddenChanged) Inject(net.runelite.api.mixins.Inject)

Example 4 with WidgetHiddenChanged

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));
}
Also used : Consumer(java.util.function.Consumer) Widget(net.runelite.api.widgets.Widget) WidgetHiddenChanged(net.runelite.api.events.WidgetHiddenChanged) Test(org.junit.Test)

Example 5 with WidgetHiddenChanged

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));
}
Also used : Consumer(java.util.function.Consumer) Widget(net.runelite.api.widgets.Widget) WidgetHiddenChanged(net.runelite.api.events.WidgetHiddenChanged) Test(org.junit.Test)

Aggregations

WidgetHiddenChanged (net.runelite.api.events.WidgetHiddenChanged)5 Widget (net.runelite.api.widgets.Widget)5 Consumer (java.util.function.Consumer)4 Test (org.junit.Test)4 Inject (net.runelite.api.mixins.Inject)1 RSWidget (net.runelite.rs.api.RSWidget)1