Search in sources :

Example 1 with VarbitChanged

use of net.runelite.api.events.VarbitChanged in project runelite by runelite.

the class RSClientMixin method settingsChanged.

@FieldHook("clientVarps")
@Inject
public static void settingsChanged(int idx) {
    VarbitChanged varbitChanged = new VarbitChanged();
    eventBus.post(varbitChanged);
}
Also used : VarbitChanged(net.runelite.api.events.VarbitChanged) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 2 with VarbitChanged

use of net.runelite.api.events.VarbitChanged in project runelite by runelite.

the class AttackIndicatorPluginTest method testWarning.

/*
	 * Verify that red text is displayed when attacking with a style that gains experience
	 * in one of the unwanted skills.
	 */
@Test
public void testWarning() {
    ConfigChanged warnForAttackEvent = new ConfigChanged();
    warnForAttackEvent.setGroup("attackIndicator");
    warnForAttackEvent.setKey("warnForAttack");
    warnForAttackEvent.setNewValue("true");
    attackPlugin.onConfigChanged(warnForAttackEvent);
    // Verify there is a warned skill
    Set<Skill> warnedSkills = attackPlugin.getWarnedSkills();
    assertTrue(warnedSkills.contains(Skill.ATTACK));
    // Set mock client to attack in style that gives attack xp
    when(client.getSetting(Setting.ATTACK_STYLE)).thenReturn(AttackStyle.ACCURATE.ordinal());
    // verify that earning xp in a warned skill will display red text on the widget
    attackPlugin.onAttackStyleChange(new VarbitChanged());
    assertTrue(attackPlugin.isWarnedSkillSelected());
    // Switch to attack style that doesn't give attack xp
    when(client.getSetting(Setting.ATTACK_STYLE)).thenReturn(AttackStyle.AGGRESSIVE.ordinal());
    // Verify the widget will now display white text
    attackPlugin.onAttackStyleChange(new VarbitChanged());
    warnedSkills = attackPlugin.getWarnedSkills();
    assertTrue(warnedSkills.contains(Skill.ATTACK));
    assertFalse(attackPlugin.isWarnedSkillSelected());
}
Also used : Skill(net.runelite.api.Skill) ConfigChanged(net.runelite.api.events.ConfigChanged) VarbitChanged(net.runelite.api.events.VarbitChanged) Test(org.junit.Test)

Example 3 with VarbitChanged

use of net.runelite.api.events.VarbitChanged 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));
}
Also used : Skill(net.runelite.api.Skill) ConfigChanged(net.runelite.api.events.ConfigChanged) Widget(net.runelite.api.widgets.Widget) VarbitChanged(net.runelite.api.events.VarbitChanged) Test(org.junit.Test)

Aggregations

VarbitChanged (net.runelite.api.events.VarbitChanged)3 Skill (net.runelite.api.Skill)2 ConfigChanged (net.runelite.api.events.ConfigChanged)2 Test (org.junit.Test)2 FieldHook (net.runelite.api.mixins.FieldHook)1 Inject (net.runelite.api.mixins.Inject)1 Widget (net.runelite.api.widgets.Widget)1