Teamcapes plugin: Teamcape image instead of text (#5107)
Makes teamcape overlay a bit more fancier. Before:  After:  Closes #5074
This commit is contained in:
committed by
Tomas Slusny
parent
6eb34a752f
commit
9c4c4c0092
@@ -28,25 +28,31 @@ import java.awt.Dimension;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import net.runelite.api.ItemID;
|
||||||
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||||
import net.runelite.client.ui.overlay.components.LineComponent;
|
import net.runelite.client.ui.overlay.components.ImageComponent;
|
||||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||||
|
|
||||||
public class TeamCapesOverlay extends Overlay
|
public class TeamCapesOverlay extends Overlay
|
||||||
{
|
{
|
||||||
|
private final PanelComponent panelComponent = new PanelComponent();
|
||||||
private final TeamCapesPlugin plugin;
|
private final TeamCapesPlugin plugin;
|
||||||
private final TeamCapesConfig config;
|
private final TeamCapesConfig config;
|
||||||
private final PanelComponent panelComponent = new PanelComponent();
|
private final ItemManager manager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
TeamCapesOverlay(TeamCapesPlugin plugin, TeamCapesConfig config)
|
private TeamCapesOverlay(TeamCapesPlugin plugin, TeamCapesConfig config, ItemManager manager)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.TOP_LEFT);
|
setPosition(OverlayPosition.TOP_LEFT);
|
||||||
setPriority(OverlayPriority.LOW);
|
setPriority(OverlayPriority.LOW);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
this.manager = manager;
|
||||||
|
panelComponent.setOrientation(PanelComponent.Orientation.HORIZONTAL);
|
||||||
|
panelComponent.setWrapping(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -57,18 +63,32 @@ public class TeamCapesOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
panelComponent.getChildren().clear();
|
panelComponent.getChildren().clear();
|
||||||
|
|
||||||
for (Map.Entry<Integer, Integer> team : teams.entrySet())
|
for (Map.Entry<Integer, Integer> team : teams.entrySet())
|
||||||
{
|
{
|
||||||
// Only display team capes that have a count greater than the configured minimum.
|
// Only display team capes that have a count greater than the configured minimum
|
||||||
if (team.getValue() >= config.getMinimumCapeCount())
|
if (team.getValue() < config.getMinimumCapeCount())
|
||||||
{
|
{
|
||||||
panelComponent.getChildren().add(LineComponent.builder()
|
continue;
|
||||||
.left("Team-" + Integer.toString(team.getKey()))
|
|
||||||
.right(Integer.toString(team.getValue()))
|
|
||||||
.build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make the number 0 based
|
||||||
|
final int teamcapeNumber = team.getKey() - 1;
|
||||||
|
final int itemID;
|
||||||
|
if (teamcapeNumber < 50)
|
||||||
|
{
|
||||||
|
// The team cape is every 2nd item id based on tc number
|
||||||
|
itemID = 2 * teamcapeNumber + ItemID.TEAM1_CAPE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The team cape is every 3rd item id based on tc number starting from 0
|
||||||
|
itemID = 3 * (teamcapeNumber - 50) + ItemID.TEAM_CAPE_ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
panelComponent.getChildren().add(new ImageComponent(manager.getImage(itemID, team.getValue(), true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return panelComponent.render(graphics);
|
return panelComponent.render(graphics);
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ public class TeamCapesPlugin extends Plugin
|
|||||||
Comparator.comparing(Map.Entry<Integer, Integer>::getValue, Comparator.reverseOrder())
|
Comparator.comparing(Map.Entry<Integer, Integer>::getValue, Comparator.reverseOrder())
|
||||||
.thenComparingInt(Map.Entry::getKey)
|
.thenComparingInt(Map.Entry::getKey)
|
||||||
)
|
)
|
||||||
.limit(5)
|
|
||||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user