use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class OverlayRenderer method shouldInvalidateBounds.
private boolean shouldInvalidateBounds() {
final Client client = clientProvider.get();
final Widget chatbox = client.getWidget(WidgetInfo.CHATBOX_MESSAGES);
final boolean resizeableChanged = isResizeable != client.isResized();
boolean changed = false;
if (resizeableChanged) {
isResizeable = client.isResized();
changed = true;
}
final boolean chatboxBoundsChanged = chatbox == null || !chatbox.getBounds().equals(chatboxBounds);
if (chatboxBoundsChanged) {
chatboxBounds = chatbox != null ? chatbox.getBounds() : new Rectangle();
changed = true;
}
final boolean chatboxHiddenChanged = chatboxHidden != (chatbox == null || chatbox.isHidden());
if (chatboxHiddenChanged) {
chatboxHidden = chatbox == null || chatbox.isHidden();
changed = true;
}
final boolean viewportChanged = !client.getViewportWidget().getBounds().equals(viewportBounds);
if (viewportChanged) {
viewportBounds = client.getViewportWidget().getBounds();
changed = true;
}
return changed;
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class XpGlobesOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
// if this is null there is no reason to draw e.g. switching between resizable and fixed
Widget viewportWidget = client.getViewportWidget();
if (viewportWidget == null) {
return null;
}
// check the width of the client if we can draw properly
int clientWidth;
switch(config.centerOrbs()) {
case MIDDLE_CANVAS:
clientWidth = client.getViewportWidth();
break;
case MIDDLE_VIEWPORT:
clientWidth = viewportWidget.getWidth();
break;
case DYNAMIC:
clientWidth = (viewportWidget.getWidth() + client.getViewportWidth()) / 2;
break;
default:
clientWidth = client.getViewportWidth();
break;
}
if (clientWidth <= 0) {
return null;
}
int queueSize = plugin.getXpGlobesSize();
if (queueSize > 0) {
List<XpGlobe> xpChangedQueue = plugin.getXpGlobes();
int markersLength = (queueSize * (config.xpOrbSize())) + ((MINIMUM_STEP) * (queueSize - 1));
int startDrawX = (clientWidth - markersLength) / 2;
for (XpGlobe xpGlobe : xpChangedQueue) {
renderProgressCircle(graphics, xpGlobe, startDrawX, DEFAULT_START_Y);
startDrawX += MINIMUM_STEP + config.xpOrbSize();
}
}
return null;
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class RSWidgetMixin method getDynamicChildren.
@Inject
@Override
public Widget[] getDynamicChildren() {
RSWidget[] children = getChildren();
if (children == null) {
return new Widget[0];
}
List<Widget> widgets = new ArrayList<Widget>();
for (Widget widget : children) {
if (widget != null && widget.getParentId() == getId()) {
widgets.add(widget);
}
}
return widgets.toArray(new Widget[widgets.size()]);
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class AttackIndicatorPluginTest method testHiddenWidget.
/*
* Verify that attack style widgets are hidden when filtered with the AttackIndicatorPlugin.
*/
@Test
public void testHiddenWidget() {
ConfigChanged warnForAttackEvent = new ConfigChanged();
warnForAttackEvent.setGroup("attackIndicator");
warnForAttackEvent.setKey("warnForAttack");
warnForAttackEvent.setNewValue("true");
attackPlugin.onConfigChanged(warnForAttackEvent);
// Set up mock widgets for atk and str attack styles
Widget atkWidget = mock(Widget.class);
Widget strWidget = mock(Widget.class);
when(client.getWidget(WidgetInfo.COMBAT_STYLE_ONE)).thenReturn(atkWidget);
when(client.getWidget(WidgetInfo.COMBAT_STYLE_TWO)).thenReturn(strWidget);
// Set widgets to return their hidden value in widgetsToHide when isHidden() is called
when(atkWidget.isHidden()).thenAnswer(x -> isAtkHidden());
when(strWidget.isHidden()).thenAnswer(x -> isStrHidden());
// equip type_4 weapon type on player
when(client.getSetting(Varbits.EQUIPPED_WEAPON_TYPE)).thenReturn(WeaponType.TYPE_4.ordinal());
attackPlugin.onEquippedWeaponTypeChange(new VarbitChanged());
// Verify there is a warned skill
Set<Skill> warnedSkills = attackPlugin.getWarnedSkills();
assertTrue(warnedSkills.contains(Skill.ATTACK));
// Enable hiding widgets
ConfigChanged hideWidgetEvent = new ConfigChanged();
hideWidgetEvent.setGroup("attackIndicator");
hideWidgetEvent.setKey("removeWarnedStyles");
hideWidgetEvent.setNewValue("true");
attackPlugin.onConfigChanged(hideWidgetEvent);
when(attackConfig.removeWarnedStyles()).thenReturn(true);
// verify that the accurate attack style widget is hidden
assertTrue(atkWidget.isHidden());
// add another warned skill
ConfigChanged warnForStrengthEvent = new ConfigChanged();
warnForStrengthEvent.setGroup("attackIndicator");
warnForStrengthEvent.setKey("warnForStrength");
warnForStrengthEvent.setNewValue("true");
attackPlugin.onConfigChanged(warnForStrengthEvent);
// verify that the aggressive attack style widget is now hidden
assertTrue(strWidget.isHidden());
// disable hiding attack style widgets
hideWidgetEvent.setGroup("attackIndicator");
hideWidgetEvent.setKey("removeWarnedStyles");
hideWidgetEvent.setNewValue("false");
attackPlugin.onConfigChanged(hideWidgetEvent);
when(attackConfig.removeWarnedStyles()).thenReturn(false);
// verify that the aggressive and accurate attack style widgets are no longer hidden
assertFalse(attackPlugin.getHiddenWidgets().get(WeaponType.TYPE_4, WidgetInfo.COMBAT_STYLE_ONE));
assertFalse(attackPlugin.getHiddenWidgets().get(WeaponType.TYPE_4, WidgetInfo.COMBAT_STYLE_THREE));
}
use of net.runelite.api.widgets.Widget 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));
}
Aggregations