attackstyles: Add a toggle to Always show style

This commit is contained in:
SoyChai
2018-04-09 11:48:43 +10:00
parent b9b8b52fff
commit 972cca410b
2 changed files with 26 additions and 6 deletions

View File

@@ -35,6 +35,17 @@ import net.runelite.client.config.ConfigItem;
)
public interface AttackStylesConfig extends Config
{
@ConfigItem(
keyName = "alwaysShowStyle",
name = "Always show style",
description = "Show attack style indicator at all times",
position = 1
)
default boolean alwaysShowStyle()
{
return true;
}
@ConfigItem(
keyName = "warnForDefensive",
name = "Warn for defensive",

View File

@@ -37,24 +37,33 @@ public class AttackStylesOverlay extends Overlay
private static final int COMPONENT_WIDTH = 80;
private final AttackStylesPlugin plugin;
private final AttackStylesConfig config;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
public AttackStylesOverlay(AttackStylesPlugin plugin)
public AttackStylesOverlay(AttackStylesPlugin plugin, AttackStylesConfig config)
{
setPosition(OverlayPosition.ABOVE_CHATBOX_RIGHT);
this.plugin = plugin;
this.config = config;
}
@Override
public Dimension render(Graphics2D graphics)
{
final String attackStyleString = plugin.getAttackStyle().getName();
boolean warnedSkillSelected = plugin.isWarnedSkillSelected();
panelComponent.setTitleColor(plugin.isWarnedSkillSelected() ? Color.RED : Color.WHITE);
panelComponent.setTitle(attackStyleString);
panelComponent.setWidth(COMPONENT_WIDTH);
if (warnedSkillSelected || config.alwaysShowStyle())
{
final String attackStyleString = plugin.getAttackStyle().getName();
return panelComponent.render(graphics);
panelComponent.setTitleColor(warnedSkillSelected ? Color.RED : Color.WHITE);
panelComponent.setTitle(attackStyleString);
panelComponent.setWidth(COMPONENT_WIDTH);
return panelComponent.render(graphics);
}
return null;
}
}