diff --git a/README.md b/README.md index 3cb6ccc..f731fef 100644 --- a/README.md +++ b/README.md @@ -23,3 +23,9 @@ Helpful overlays for the Giant's Foundry minigame * Highlight relevant tools with status colors * Kovac, Crucible, and Mould Jig highlights * Highlight waterfall/lava pool when temperature is wrong + * Added Bonus sound/notifications + * Added overlay configs + * Added info panel configs +- [Vanillj](https://github.com/Vanillj "Vanillj's github") + * Added config + * Added notifications for heat/stage changes \ No newline at end of file diff --git a/build.gradle b/build.gradle index 01d2eba..b69c935 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ repositories { mavenCentral() } -def runeLiteVersion = '1.8.23' +def runeLiteVersion = '1.8.24.3' dependencies { compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion @@ -24,7 +24,7 @@ dependencies { } group = 'com.toofifty' -version = '1.0.3' +version = '1.0.4' sourceCompatibility = '1.8' tasks.withType(JavaCompile) { diff --git a/src/main/java/com/toofifty/easygiantsfoundry/BonusWidget.java b/src/main/java/com/toofifty/easygiantsfoundry/BonusWidget.java new file mode 100644 index 0000000..5bf7f19 --- /dev/null +++ b/src/main/java/com/toofifty/easygiantsfoundry/BonusWidget.java @@ -0,0 +1,17 @@ +package com.toofifty.easygiantsfoundry; + +import net.runelite.api.Client; +import net.runelite.api.widgets.Widget; + +public class BonusWidget { + private static final int BONUS_WIDGET = 49414148; + private static final int BONUS_COLOR = 0xfcd703; + + static boolean isActive(Client client) { + Widget bonusWidget = client.getWidget(BONUS_WIDGET); + return bonusWidget != null + && bonusWidget.getChildren() != null + && bonusWidget.getChildren().length != 0 + && bonusWidget.getChild(0).getTextColor() == BONUS_COLOR; + } +} diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java index 6b31224..433cfdd 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryConfig.java @@ -3,31 +3,198 @@ package com.toofifty.easygiantsfoundry; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.ConfigSection; @ConfigGroup(EasyGiantsFoundryConfig.GROUP) public interface EasyGiantsFoundryConfig extends Config { String GROUP = "easygiantsfoundry"; + String SOUND_ID = "soundID"; + + @ConfigSection( + name = "Notifications", + description = "Notifications", + position = 0 + ) + String notificationList = "notificationList"; @ConfigItem( keyName = "giantsFoundryStageNotification", - name = "Enable stage notifications", - description = "Configures whether to notify you when you are about to finish a stage.", - position = 0 + name = "Notify stage changes", + description = "Notifies just before completing a stage", + position = 0, + section = notificationList ) - default boolean showGiantsFoundryStageNotifications() - { - return false; + default boolean showGiantsFoundryStageNotifications() { + return true; } @ConfigItem( keyName = "giantsFoundryHeatNotification", - name = "Enable heat notifications", - description = "Configures whether to notify you when you are about to run out of heat.", - position = 1 + name = "Notify heat changes", + description = "Notifies just before overheating/cooling when using tools", + position = 1, + section = notificationList ) - default boolean showGiantsFoundryHeatNotifications() - { + default boolean showGiantsFoundryHeatNotifications() { + return true; + } + + @ConfigItem( + keyName = "bonusNotification", + name = "Notify bonus", + description = "Notifies when bonus appears", + position = 2, + section = notificationList + ) + default boolean bonusNotification() { return false; } + @ConfigItem( + keyName = "bonusSound", + name = "Bonus sound", + description = "Plays a sound when bonus appears", + position = 3, + section = notificationList + ) + default boolean bonusSoundNotify() { + return true; + } + + @ConfigItem( + keyName = SOUND_ID, + name = "Bonus sound ID", + description = "Sound Effect ID to play when bonus appears", + position = 4, + section = notificationList + ) + default int soundId() { + return 4212; + } + + + @ConfigSection( + name = "Highlights", + description = "3D npc/object highlights", + position = 1 + ) + String highlightList = "highlightList"; + + @ConfigItem( + keyName = "toolsHighlight", + name = "Highlight Tools", + description = "Highlights current tool with symbolic colors", + position = 0, + section = highlightList + ) + default boolean highlightTools() { + return true; + } + + @ConfigItem( + keyName = "waterLavaHighlight", + name = "Highlight Waterfall/Lava Pool", + description = "Highlight Lava Pool / Waterfall when heat change required", + position = 1, + section = highlightList + ) + default boolean highlightWaterAndLava() { + return true; + } + + @ConfigItem( + keyName = "mouldHighlight", + name = "Highlight Mould", + description = "Highlight Mould when it should be clicked", + position = 2, + section = highlightList + ) + default boolean highlightMould() { + return true; + } + + @ConfigItem( + keyName = "crucibleHighlight", + name = "Highlight Crucible", + description = "Highlight Crucible when it should be filled/poured", + position = 3, + section = highlightList + ) + default boolean highlightCrucible() { + return true; + } + + @ConfigItem( + keyName = "kovacHighlight", + name = "Highlight Kovac for hand in", + description = "Highlight Kovac when sword can be handed in", + position = 4, + section = highlightList + ) + default boolean highlightKovac() { + return true; + } + + + @ConfigSection( + name = "Info Panel", + description = "Settings for the Info Panel overlay", + position = 1 + ) + String infoPanelList = "infoPanelList"; + + @ConfigItem( + keyName = "infoTitle", + name = "Title", + description = "Toggle for \"Easy Giant's Foundry\" text", + position = 0, + section = infoPanelList + ) + default boolean drawTitle() { + return true; + } + + @ConfigItem( + keyName = "heatInfo", + name = "Heat", + description = "Toggle for Heat text", + position = 1, + section = infoPanelList + ) + default boolean drawHeatInfo() { + return true; + } + + @ConfigItem( + keyName = "stageInfo", + name = "Stage", + description = "Toggle for Stage text", + position = 2, + section = infoPanelList + ) + default boolean drawStageInfo() { + return true; + } + + @ConfigItem( + keyName = "actionsLeft", + name = "Actions Left", + description = "Toggle for Actions left text", + position = 3, + section = infoPanelList + ) + default boolean drawActionsLeft() { + return true; + } + + @ConfigItem( + keyName = "heatLeft", + name = "Heat Left", + description = "Toggle for Heat left text", + position = 4, + section = infoPanelList + ) + default boolean drawHeatLeft() { + return true; + } } diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryHelper.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryHelper.java index 2b3648f..8041aaf 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryHelper.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryHelper.java @@ -2,9 +2,6 @@ package com.toofifty.easygiantsfoundry; import com.toofifty.easygiantsfoundry.enums.Heat; import com.toofifty.easygiantsfoundry.enums.Stage; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java index 16462cb..e1dd487 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java @@ -2,12 +2,22 @@ package com.toofifty.easygiantsfoundry; import com.google.inject.Provides; import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; import net.runelite.api.GameObject; import net.runelite.api.GameState; import net.runelite.api.InventoryID; import net.runelite.api.Skill; -import net.runelite.api.events.*; +import net.runelite.api.events.GameObjectDespawned; +import net.runelite.api.events.GameObjectSpawned; +import net.runelite.api.events.GameStateChanged; +import net.runelite.api.events.GameTick; +import net.runelite.api.events.ItemContainerChanged; +import net.runelite.api.events.NpcDespawned; +import net.runelite.api.events.NpcSpawned; +import net.runelite.api.events.ScriptPostFired; +import net.runelite.api.events.StatChanged; import net.runelite.client.Notifier; +import net.runelite.client.callback.ClientThread; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; import net.runelite.client.plugins.Plugin; @@ -43,6 +53,8 @@ public class EasyGiantsFoundryPlugin extends Plugin private int lastBoost; + private boolean bonusNotified = false; + @Inject private EasyGiantsFoundryState state; @@ -67,6 +79,12 @@ public class EasyGiantsFoundryPlugin extends Plugin @Inject private Notifier notifier; + @Inject + private Client client; + + @Inject + private ClientThread clientThread; + @Override protected void startUp() { @@ -124,14 +142,14 @@ public class EasyGiantsFoundryPlugin extends Plugin @Subscribe public void onStatChanged(StatChanged statChanged) { - final int currBoost = statChanged.getBoostedLevel(); + final int curBoost = statChanged.getBoostedLevel(); // if the difference between current and last boost is != 0 then a stat boost (or drop) change occurred if (!statChanged.getSkill().equals(Skill.SMITHING) || - currBoost - lastBoost != 0 || + curBoost != lastBoost || !state.isEnabled() || state.getCurrentStage() == null) { - lastBoost = currBoost; + lastBoost = curBoost; return; } @@ -220,6 +238,52 @@ public class EasyGiantsFoundryPlugin extends Plugin } } + @Subscribe + protected void onConfigChanged(ConfigChanged configChanged) + { + if (!EasyGiantsFoundryConfig.GROUP.equals(configChanged.getGroup())) + { + return; + } + + if (EasyGiantsFoundryConfig.SOUND_ID.equals(configChanged.getKey())) + { + clientThread.invoke(() -> client.playSoundEffect(config.soundId())); + } + } + + @Subscribe + public void onGameTick(GameTick event) + { + checkBonus(); + } + + private void checkBonus() + { + if (!state.isEnabled() || state.getCurrentStage() == null + || state.getCurrentStage().getHeat() != state.getCurrentHeat() + || !BonusWidget.isActive(client)) + { + bonusNotified = false; + return; + } + + if (bonusNotified) + { + return; + } + + if (config.bonusNotification()) + { + notifier.notify("Bonus - Click tool"); + } + if (config.bonusSoundNotify()) + { + client.playSoundEffect(config.soundId()); + } + + bonusNotified = true; + } @Provides EasyGiantsFoundryConfig provideConfig(ConfigManager configManager) diff --git a/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay2D.java b/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay2D.java index da7b620..e41643c 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay2D.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay2D.java @@ -2,28 +2,33 @@ package com.toofifty.easygiantsfoundry; import com.toofifty.easygiantsfoundry.enums.Heat; import com.toofifty.easygiantsfoundry.enums.Stage; - -import java.awt.*; -import javax.inject.Inject; -import javax.inject.Singleton; - -import net.runelite.api.Client; -import net.runelite.api.GameObject; -import net.runelite.api.Point; import net.runelite.client.ui.ColorScheme; -import net.runelite.client.ui.components.ProgressBar; 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.TitleComponent; +import javax.inject.Inject; +import javax.inject.Singleton; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; + @Singleton public class FoundryOverlay2D extends OverlayPanel { - @Inject - private EasyGiantsFoundryState state; + private final EasyGiantsFoundryState state; + private final EasyGiantsFoundryHelper helper; + private final EasyGiantsFoundryConfig config; @Inject - private EasyGiantsFoundryHelper helper; + private FoundryOverlay2D(EasyGiantsFoundryState state, EasyGiantsFoundryHelper helper, EasyGiantsFoundryConfig config) + { + this.state = state; + this.helper = helper; + this.config = config; + this.setPosition(OverlayPosition.BOTTOM_LEFT); + } private Color getHeatColor(int actions, int heat) { @@ -51,23 +56,38 @@ public class FoundryOverlay2D extends OverlayPanel Heat heat = state.getCurrentHeat(); Stage stage = state.getCurrentStage(); - panelComponent.getChildren().add(TitleComponent.builder().text("Easy Giant's Foundry").build()); - panelComponent.getChildren().add( - LineComponent.builder().left("Heat").right(heat.getName() + " (" + state.getHeatAmount() / 10 + "%)").rightColor(heat.getColor()).build() - ); - panelComponent.getChildren().add( - LineComponent.builder().left("Stage").right(stage.getName() + " (" + state.getProgressAmount() / 10 + "%)").rightColor(stage.getHeat().getColor()).build() - ); + if (config.drawTitle()) + { + panelComponent.getChildren().add(TitleComponent.builder().text("Easy Giant's Foundry").build()); + } + if (config.drawHeatInfo()) + { + panelComponent.getChildren().add( + LineComponent.builder().left("Heat").right(heat.getName() + " (" + state.getHeatAmount() / 10 + "%)").rightColor(heat.getColor()).build() + ); + } + if (config.drawStageInfo()) + { + panelComponent.getChildren().add( + LineComponent.builder().left("Stage").right(stage.getName() + " (" + state.getProgressAmount() / 10 + "%)").rightColor(stage.getHeat().getColor()).build() + ); + } int actionsLeft = helper.getActionsLeftInStage(); int heatLeft = helper.getActionsForHeatLevel(); - panelComponent.getChildren().add( - LineComponent.builder().left("Actions left").right(actionsLeft + "").build() - ); - panelComponent.getChildren().add( - LineComponent.builder().left("Heat left").right(heatLeft + "").rightColor(getHeatColor(actionsLeft, heatLeft)).build() - ); + if (config.drawActionsLeft()) + { + panelComponent.getChildren().add( + LineComponent.builder().left("Actions left").right(actionsLeft + "").build() + ); + } + if (config.drawHeatLeft()) + { + panelComponent.getChildren().add( + LineComponent.builder().left("Heat left").right(heatLeft + "").rightColor(getHeatColor(actionsLeft, heatLeft)).build() + ); + } return super.render(graphics); } diff --git a/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java b/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java index 16a22c8..b434633 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java @@ -16,11 +16,7 @@ import java.awt.*; public class FoundryOverlay3D extends Overlay { - private static final int BONUS_COLOR = 0xfcd703; - private static final int BONUS_WIDGET = 49414148; - private static final int HAND_IN_WIDGET = 49414221; - private static final int FINISH_ANIM = 9457; GameObject tripHammer; GameObject grindstone; @@ -34,14 +30,17 @@ public class FoundryOverlay3D extends Overlay { private final Client client; private final EasyGiantsFoundryState state; private final EasyGiantsFoundryHelper helper; + private final EasyGiantsFoundryConfig config; @Inject - private FoundryOverlay3D(Client client, EasyGiantsFoundryState state, EasyGiantsFoundryHelper helper) + private FoundryOverlay3D(Client client, EasyGiantsFoundryState state, EasyGiantsFoundryHelper helper, + EasyGiantsFoundryConfig config) { setPosition(OverlayPosition.DYNAMIC); this.client = client; this.state = state; this.helper = helper; + this.config = config; } private Color getObjectColor(Stage stage, Heat heat) @@ -51,15 +50,11 @@ public class FoundryOverlay3D extends Overlay { return ColorScheme.PROGRESS_ERROR_COLOR; } - Widget bonusWidget = client.getWidget(BONUS_WIDGET); - if (bonusWidget != null - && bonusWidget.getChildren() != null - && bonusWidget.getChildren().length != 0 - && bonusWidget.getChild(0).getTextColor() == BONUS_COLOR) { + if (BonusWidget.isActive(client)) + { return Color.CYAN; } - int actionsLeft = helper.getActionsLeftInStage(); int heatLeft = helper.getActionsForHeatLevel(); if (actionsLeft <= 1 || heatLeft <= 1) @@ -92,27 +87,35 @@ public class FoundryOverlay3D extends Overlay { return null; } - drawKovacIfHandIn(graphics); + if (config.highlightKovac()) + { + drawKovacIfHandIn(graphics); + } if (state.getCurrentStage() == null) { - drawMouldIfNotSet(graphics); - drawCrucibleIfMouldSet(graphics); + if (config.highlightMould()) + { + drawMouldIfNotSet(graphics); + } + if (config.highlightCrucible()) + { + drawCrucibleIfMouldSet(graphics); + } return null; } - Heat heat = state.getCurrentHeat(); Stage stage = state.getCurrentStage(); - GameObject stageObject = getStageObject(stage); if (stageObject == null) { return null; } + Heat heat = state.getCurrentHeat(); Color color = getObjectColor(stage, heat); Shape objectClickbox = stageObject.getClickbox(); - if (objectClickbox != null) + if (objectClickbox != null && config.highlightTools()) { Point mousePosition = client.getMouseCanvasPosition(); if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) @@ -128,7 +131,7 @@ public class FoundryOverlay3D extends Overlay { graphics.fill(objectClickbox); } - if (color.equals(ColorScheme.PROGRESS_ERROR_COLOR)) + if (color.equals(ColorScheme.PROGRESS_ERROR_COLOR) && config.highlightWaterAndLava()) { drawHeatChangers(graphics); } @@ -209,8 +212,7 @@ public class FoundryOverlay3D extends Overlay { private void drawKovacIfHandIn(Graphics2D graphics) { Widget handInWidget = client.getWidget(HAND_IN_WIDGET); - if (handInWidget != null && !handInWidget.isHidden() - && client.getLocalPlayer().getAnimation() != FINISH_ANIM) + if (handInWidget != null && !handInWidget.isHidden()) { Shape shape = kovac.getConvexHull(); if (shape != null) diff --git a/src/main/java/com/toofifty/easygiantsfoundry/enums/Stage.java b/src/main/java/com/toofifty/easygiantsfoundry/enums/Stage.java index 60f48a1..633fad3 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/enums/Stage.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/enums/Stage.java @@ -1,9 +1,7 @@ package com.toofifty.easygiantsfoundry.enums; -import java.awt.Color; import lombok.AllArgsConstructor; import lombok.Getter; -import net.runelite.client.ui.ColorScheme; @Getter @AllArgsConstructor