Skip to content

Commit

Permalink
Make overlays use OverlayPanel instead of Overlay
Browse files Browse the repository at this point in the history
Make overlays that were previously using PanelComponent use
OverlayPanel.

Signed-off-by: Tomas Slusny <[email protected]>
  • Loading branch information
deathbeam authored and Adam- committed Apr 13, 2020
1 parent 2647997 commit 35ebe5c
Show file tree
Hide file tree
Showing 32 changed files with 119 additions and 258 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,18 @@
import java.time.Instant;
import javax.inject.Inject;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPanel;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;

class LapCounterOverlay extends Overlay
class LapCounterOverlay extends OverlayPanel
{
private final AgilityPlugin plugin;
private final AgilityConfig config;

private final PanelComponent panelComponent = new PanelComponent();

@Inject
private LapCounterOverlay(AgilityPlugin plugin, AgilityConfig config)
{
Expand Down Expand Up @@ -79,7 +76,6 @@ public Dimension render(Graphics2D graphics)
return null;
}

panelComponent.getChildren().clear();
panelComponent.getChildren().add(LineComponent.builder()
.left("Total Laps:")
.right(Integer.toString(session.getTotalLaps()))
Expand All @@ -93,6 +89,6 @@ public Dimension render(Graphics2D graphics)
.build());
}

return panelComponent.render(graphics);
return super.render(graphics);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@
import java.awt.Graphics2D;
import javax.inject.Inject;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPanel;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;

class AttackStylesOverlay extends Overlay
class AttackStylesOverlay extends OverlayPanel
{
private final AttackStylesPlugin plugin;
private final AttackStylesConfig config;
private final PanelComponent panelComponent = new PanelComponent();

@Inject
private AttackStylesOverlay(AttackStylesPlugin plugin, AttackStylesConfig config)
Expand All @@ -55,7 +53,6 @@ private AttackStylesOverlay(AttackStylesPlugin plugin, AttackStylesConfig config
@Override
public Dimension render(Graphics2D graphics)
{
panelComponent.getChildren().clear();
boolean warnedSkillSelected = plugin.isWarnedSkillSelected();

if (warnedSkillSelected || config.alwaysShowStyle())
Expand All @@ -78,7 +75,7 @@ public Dimension render(Graphics2D graphics)
graphics.getFontMetrics().stringWidth(attackStyleString) + 10,
0));

return panelComponent.render(graphics);
return super.render(graphics);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@
import net.runelite.api.Varbits;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPanel;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;

public class BarrowsBrotherSlainOverlay extends Overlay
public class BarrowsBrotherSlainOverlay extends OverlayPanel
{
private final Client client;
private final PanelComponent panelComponent = new PanelComponent();

@Inject
private BarrowsBrotherSlainOverlay(BarrowsPlugin plugin, Client client)
Expand Down Expand Up @@ -74,8 +72,6 @@ public Dimension render(Graphics2D graphics)
potential.setHidden(true);
}

panelComponent.getChildren().clear();

for (BarrowsBrothers brother : BarrowsBrothers.values())
{
final boolean brotherSlain = client.getVar(brother.getKilledVarbit()) > 0;
Expand All @@ -94,6 +90,6 @@ public Dimension render(Graphics2D graphics)
.rightColor(rewardPercent >= 73.0f && rewardPercent <= 88.0f ? Color.GREEN : rewardPercent < 65.6f ? Color.WHITE : Color.YELLOW)
.build());

return panelComponent.render(graphics);
return super.render(graphics);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,21 @@
import static net.runelite.api.Varbits.BLAST_FURNACE_COFFER;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import static org.apache.commons.lang3.time.DurationFormatUtils.formatDuration;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPanel;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.util.QuantityFormatter;
import static org.apache.commons.lang3.time.DurationFormatUtils.formatDuration;

class BlastFurnaceCofferOverlay extends Overlay
class BlastFurnaceCofferOverlay extends OverlayPanel
{
private static final float COST_PER_HOUR = 72000.0f;

private final Client client;
private final BlastFurnacePlugin plugin;
private final BlastFurnaceConfig config;
private final PanelComponent panelComponent = new PanelComponent();

@Inject
private BlastFurnaceCofferOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config)
Expand All @@ -71,8 +69,6 @@ public Dimension render(Graphics2D graphics)

Widget sack = client.getWidget(WidgetInfo.BLAST_FURNACE_COFFER);

panelComponent.getChildren().clear();

if (sack != null)
{
final int coffer = client.getVar(BLAST_FURNACE_COFFER);
Expand All @@ -95,6 +91,6 @@ public Dimension render(Graphics2D graphics)
}
}

return panelComponent.render(graphics);
return super.render(graphics);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,17 @@
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPanel;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;

class BlastFurnaceOverlay extends Overlay
class BlastFurnaceOverlay extends OverlayPanel
{
private final Client client;
private final BlastFurnacePlugin plugin;
private final PanelComponent imagePanelComponent = new PanelComponent();

@Inject
private ItemManager itemManager;
Expand All @@ -55,7 +53,7 @@ class BlastFurnaceOverlay extends Overlay
this.plugin = plugin;
this.client = client;
setPosition(OverlayPosition.TOP_LEFT);
imagePanelComponent.setOrientation(ComponentOrientation.HORIZONTAL);
panelComponent.setOrientation(ComponentOrientation.HORIZONTAL);
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Blast furnace overlay"));
}

Expand All @@ -67,8 +65,6 @@ public Dimension render(Graphics2D graphics)
return null;
}

imagePanelComponent.getChildren().clear();

for (BarsOres varbit : BarsOres.values())
{
int amount = client.getVar(varbit.getVarbit());
Expand All @@ -78,10 +74,10 @@ public Dimension render(Graphics2D graphics)
continue;
}

imagePanelComponent.getChildren().add(new ImageComponent(getImage(varbit.getItemID(), amount)));
panelComponent.getChildren().add(new ImageComponent(getImage(varbit.getItemID(), amount)));
}

return imagePanelComponent.render(graphics);
return super.render(graphics);
}

private BufferedImage getImage(int itemID, int amount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,18 @@
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPanel;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;

class BlastMineOreCountOverlay extends Overlay
class BlastMineOreCountOverlay extends OverlayPanel
{
private final Client client;
private final BlastMinePluginConfig config;
private final ItemManager itemManager;
private final PanelComponent panelComponent = new PanelComponent();

@Inject
private BlastMineOreCountOverlay(BlastMinePlugin plugin, Client client, BlastMinePluginConfig config, ItemManager itemManager)
Expand All @@ -72,8 +70,6 @@ public Dimension render(Graphics2D graphics)
return null;
}

panelComponent.getChildren().clear();

if (config.showOreOverlay())
{
blastMineWidget.setHidden(true);
Expand All @@ -88,7 +84,7 @@ public Dimension render(Graphics2D graphics)
blastMineWidget.setHidden(false);
}

return panelComponent.render(graphics);
return super.render(graphics);
}

private BufferedImage getImage(int itemID, int amount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,18 @@
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.api.Skill;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPanel;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.util.ColorUtil;

class BoostsOverlay extends Overlay
class BoostsOverlay extends OverlayPanel
{
private final Client client;
private final BoostsConfig config;
private final PanelComponent panelComponent = new PanelComponent();
private final BoostsPlugin plugin;

@Inject
Expand All @@ -68,8 +66,6 @@ public Dimension render(Graphics2D graphics)
return null;
}

panelComponent.getChildren().clear();

int nextChange = plugin.getChangeDownTicks();

if (nextChange != -1)
Expand All @@ -94,7 +90,7 @@ public Dimension render(Graphics2D graphics)

if (boostedSkills.isEmpty())
{
return panelComponent.render(graphics);
return super.render(graphics);
}

if (plugin.canShowBoosts())
Expand Down Expand Up @@ -129,7 +125,7 @@ public Dimension render(Graphics2D graphics)
}
}

return panelComponent.render(graphics);
return super.render(graphics);
}

private Color getTextColor(int boost)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@
import net.runelite.client.plugins.cluescrolls.clues.item.ItemRequirement;
import static net.runelite.client.plugins.cluescrolls.clues.item.ItemRequirements.item;
import net.runelite.client.plugins.cluescrolls.clues.item.SingleItemRequirement;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPanel;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.components.ComponentConstants;
import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;

public class ClueScrollOverlay extends Overlay
public class ClueScrollOverlay extends OverlayPanel
{
private static final ItemRequirement HAS_SPADE = new SingleItemRequirement(SPADE);
private static final ItemRequirement HAS_LIGHT = new AnyRequirementCollection("Light Source",
Expand Down Expand Up @@ -79,7 +77,6 @@ public class ClueScrollOverlay extends Overlay
public static final Color TITLED_CONTENT_COLOR = new Color(190, 190, 190);

private final ClueScrollPlugin plugin;
private final PanelComponent panelComponent = new PanelComponent();
private final Client client;

@Inject
Expand All @@ -103,9 +100,6 @@ public Dimension render(Graphics2D graphics)
return null;
}

panelComponent.getChildren().clear();
panelComponent.setPreferredSize(new Dimension(ComponentConstants.STANDARD_WIDTH, 0));

clue.makeOverlayHint(panelComponent, plugin);

final Item[] inventoryItems = plugin.getInventoryItems();
Expand All @@ -129,6 +123,6 @@ public Dimension render(Graphics2D graphics)
panelComponent.getChildren().add(LineComponent.builder().left("Requires Light Source!").leftColor(Color.RED).build());
}

return panelComponent.render(graphics);
return super.render(graphics);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
package net.runelite.client.plugins.cluescrolls.clues;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -59,7 +58,6 @@
@Slf4j
public class HotColdClue extends ClueScroll implements LocationClueScroll, LocationsClueScroll, TextClueScroll, NpcClueScroll
{
private static final int HOT_COLD_PANEL_WIDTH = 200;
private static final HotColdClue BEGINNER_CLUE = new HotColdClue("Buried beneath the ground, who knows where it's found. Lucky for you, A man called Reldo may have a clue.",
"Reldo",
"Speak to Reldo to receive a strange device.",
Expand Down Expand Up @@ -141,7 +139,6 @@ public void makeOverlayHint(PanelComponent panelComponent, ClueScrollPlugin plug
panelComponent.getChildren().add(TitleComponent.builder()
.text("Hot/Cold Clue")
.build());
panelComponent.setPreferredSize(new Dimension(HOT_COLD_PANEL_WIDTH, 0));

// strange device has not been tested yet, show how to get it
if (hotColdSolver.getLastWorldPoint() == null && location == null)
Expand Down
Loading

0 comments on commit 35ebe5c

Please sign in to comment.