Merge pull request #9 from Toofifty/1.0.4

1.0.4
This commit is contained in:
Patrick Watts
2022-06-27 17:08:18 +04:00
committed by GitHub
9 changed files with 338 additions and 67 deletions

View File

@@ -23,3 +23,9 @@ Helpful overlays for the Giant's Foundry minigame
* Highlight relevant tools with status colors * Highlight relevant tools with status colors
* Kovac, Crucible, and Mould Jig highlights * Kovac, Crucible, and Mould Jig highlights
* Highlight waterfall/lava pool when temperature is wrong * 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

View File

@@ -10,7 +10,7 @@ repositories {
mavenCentral() mavenCentral()
} }
def runeLiteVersion = '1.8.23' def runeLiteVersion = '1.8.24.3'
dependencies { dependencies {
compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion
@@ -24,7 +24,7 @@ dependencies {
} }
group = 'com.toofifty' group = 'com.toofifty'
version = '1.0.3' version = '1.0.4'
sourceCompatibility = '1.8' sourceCompatibility = '1.8'
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {

View File

@@ -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;
}
}

View File

@@ -3,31 +3,198 @@ package com.toofifty.easygiantsfoundry;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigSection;
@ConfigGroup(EasyGiantsFoundryConfig.GROUP) @ConfigGroup(EasyGiantsFoundryConfig.GROUP)
public interface EasyGiantsFoundryConfig extends Config { public interface EasyGiantsFoundryConfig extends Config {
String GROUP = "easygiantsfoundry"; String GROUP = "easygiantsfoundry";
String SOUND_ID = "soundID";
@ConfigSection(
name = "Notifications",
description = "Notifications",
position = 0
)
String notificationList = "notificationList";
@ConfigItem( @ConfigItem(
keyName = "giantsFoundryStageNotification", keyName = "giantsFoundryStageNotification",
name = "Enable stage notifications", name = "Notify stage changes",
description = "Configures whether to notify you when you are about to finish a stage.", description = "Notifies just before completing a stage",
position = 0 position = 0,
section = notificationList
) )
default boolean showGiantsFoundryStageNotifications() default boolean showGiantsFoundryStageNotifications() {
{ return true;
return false;
} }
@ConfigItem( @ConfigItem(
keyName = "giantsFoundryHeatNotification", keyName = "giantsFoundryHeatNotification",
name = "Enable heat notifications", name = "Notify heat changes",
description = "Configures whether to notify you when you are about to run out of heat.", description = "Notifies just before overheating/cooling when using tools",
position = 1 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; 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;
}
} }

View File

@@ -2,9 +2,6 @@ package com.toofifty.easygiantsfoundry;
import com.toofifty.easygiantsfoundry.enums.Heat; import com.toofifty.easygiantsfoundry.enums.Heat;
import com.toofifty.easygiantsfoundry.enums.Stage; 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.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;

View File

@@ -2,12 +2,22 @@ package com.toofifty.easygiantsfoundry;
import com.google.inject.Provides; import com.google.inject.Provides;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.GameObject; import net.runelite.api.GameObject;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.InventoryID; import net.runelite.api.InventoryID;
import net.runelite.api.Skill; 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.Notifier;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged; import net.runelite.client.events.ConfigChanged;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -43,6 +53,8 @@ public class EasyGiantsFoundryPlugin extends Plugin
private int lastBoost; private int lastBoost;
private boolean bonusNotified = false;
@Inject @Inject
private EasyGiantsFoundryState state; private EasyGiantsFoundryState state;
@@ -67,6 +79,12 @@ public class EasyGiantsFoundryPlugin extends Plugin
@Inject @Inject
private Notifier notifier; private Notifier notifier;
@Inject
private Client client;
@Inject
private ClientThread clientThread;
@Override @Override
protected void startUp() protected void startUp()
{ {
@@ -124,14 +142,14 @@ public class EasyGiantsFoundryPlugin extends Plugin
@Subscribe @Subscribe
public void onStatChanged(StatChanged statChanged) 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 the difference between current and last boost is != 0 then a stat boost (or drop) change occurred
if (!statChanged.getSkill().equals(Skill.SMITHING) || if (!statChanged.getSkill().equals(Skill.SMITHING) ||
currBoost - lastBoost != 0 || curBoost != lastBoost ||
!state.isEnabled() || !state.isEnabled() ||
state.getCurrentStage() == null) state.getCurrentStage() == null)
{ {
lastBoost = currBoost; lastBoost = curBoost;
return; 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 @Provides
EasyGiantsFoundryConfig provideConfig(ConfigManager configManager) EasyGiantsFoundryConfig provideConfig(ConfigManager configManager)

View File

@@ -2,28 +2,33 @@ package com.toofifty.easygiantsfoundry;
import com.toofifty.easygiantsfoundry.enums.Heat; import com.toofifty.easygiantsfoundry.enums.Heat;
import com.toofifty.easygiantsfoundry.enums.Stage; 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.ColorScheme;
import net.runelite.client.ui.components.ProgressBar;
import net.runelite.client.ui.overlay.OverlayPanel; 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.LineComponent;
import net.runelite.client.ui.overlay.components.TitleComponent; 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 @Singleton
public class FoundryOverlay2D extends OverlayPanel public class FoundryOverlay2D extends OverlayPanel
{ {
@Inject private final EasyGiantsFoundryState state;
private EasyGiantsFoundryState state; private final EasyGiantsFoundryHelper helper;
private final EasyGiantsFoundryConfig config;
@Inject @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) private Color getHeatColor(int actions, int heat)
{ {
@@ -51,23 +56,38 @@ public class FoundryOverlay2D extends OverlayPanel
Heat heat = state.getCurrentHeat(); Heat heat = state.getCurrentHeat();
Stage stage = state.getCurrentStage(); Stage stage = state.getCurrentStage();
panelComponent.getChildren().add(TitleComponent.builder().text("Easy Giant's Foundry").build()); if (config.drawTitle())
panelComponent.getChildren().add( {
LineComponent.builder().left("Heat").right(heat.getName() + " (" + state.getHeatAmount() / 10 + "%)").rightColor(heat.getColor()).build() panelComponent.getChildren().add(TitleComponent.builder().text("Easy Giant's Foundry").build());
); }
panelComponent.getChildren().add( if (config.drawHeatInfo())
LineComponent.builder().left("Stage").right(stage.getName() + " (" + state.getProgressAmount() / 10 + "%)").rightColor(stage.getHeat().getColor()).build() {
); 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 actionsLeft = helper.getActionsLeftInStage();
int heatLeft = helper.getActionsForHeatLevel(); int heatLeft = helper.getActionsForHeatLevel();
panelComponent.getChildren().add( if (config.drawActionsLeft())
LineComponent.builder().left("Actions left").right(actionsLeft + "").build() {
); panelComponent.getChildren().add(
panelComponent.getChildren().add( LineComponent.builder().left("Actions left").right(actionsLeft + "").build()
LineComponent.builder().left("Heat left").right(heatLeft + "").rightColor(getHeatColor(actionsLeft, heatLeft)).build() );
); }
if (config.drawHeatLeft())
{
panelComponent.getChildren().add(
LineComponent.builder().left("Heat left").right(heatLeft + "").rightColor(getHeatColor(actionsLeft, heatLeft)).build()
);
}
return super.render(graphics); return super.render(graphics);
} }

View File

@@ -16,11 +16,7 @@ import java.awt.*;
public class FoundryOverlay3D extends Overlay { 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 HAND_IN_WIDGET = 49414221;
private static final int FINISH_ANIM = 9457;
GameObject tripHammer; GameObject tripHammer;
GameObject grindstone; GameObject grindstone;
@@ -34,14 +30,17 @@ public class FoundryOverlay3D extends Overlay {
private final Client client; private final Client client;
private final EasyGiantsFoundryState state; private final EasyGiantsFoundryState state;
private final EasyGiantsFoundryHelper helper; private final EasyGiantsFoundryHelper helper;
private final EasyGiantsFoundryConfig config;
@Inject @Inject
private FoundryOverlay3D(Client client, EasyGiantsFoundryState state, EasyGiantsFoundryHelper helper) private FoundryOverlay3D(Client client, EasyGiantsFoundryState state, EasyGiantsFoundryHelper helper,
EasyGiantsFoundryConfig config)
{ {
setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
this.client = client; this.client = client;
this.state = state; this.state = state;
this.helper = helper; this.helper = helper;
this.config = config;
} }
private Color getObjectColor(Stage stage, Heat heat) private Color getObjectColor(Stage stage, Heat heat)
@@ -51,15 +50,11 @@ public class FoundryOverlay3D extends Overlay {
return ColorScheme.PROGRESS_ERROR_COLOR; return ColorScheme.PROGRESS_ERROR_COLOR;
} }
Widget bonusWidget = client.getWidget(BONUS_WIDGET); if (BonusWidget.isActive(client))
if (bonusWidget != null {
&& bonusWidget.getChildren() != null
&& bonusWidget.getChildren().length != 0
&& bonusWidget.getChild(0).getTextColor() == BONUS_COLOR) {
return Color.CYAN; return Color.CYAN;
} }
int actionsLeft = helper.getActionsLeftInStage(); int actionsLeft = helper.getActionsLeftInStage();
int heatLeft = helper.getActionsForHeatLevel(); int heatLeft = helper.getActionsForHeatLevel();
if (actionsLeft <= 1 || heatLeft <= 1) if (actionsLeft <= 1 || heatLeft <= 1)
@@ -92,27 +87,35 @@ public class FoundryOverlay3D extends Overlay {
return null; return null;
} }
drawKovacIfHandIn(graphics); if (config.highlightKovac())
{
drawKovacIfHandIn(graphics);
}
if (state.getCurrentStage() == null) if (state.getCurrentStage() == null)
{ {
drawMouldIfNotSet(graphics); if (config.highlightMould())
drawCrucibleIfMouldSet(graphics); {
drawMouldIfNotSet(graphics);
}
if (config.highlightCrucible())
{
drawCrucibleIfMouldSet(graphics);
}
return null; return null;
} }
Heat heat = state.getCurrentHeat();
Stage stage = state.getCurrentStage(); Stage stage = state.getCurrentStage();
GameObject stageObject = getStageObject(stage); GameObject stageObject = getStageObject(stage);
if (stageObject == null) if (stageObject == null)
{ {
return null; return null;
} }
Heat heat = state.getCurrentHeat();
Color color = getObjectColor(stage, heat); Color color = getObjectColor(stage, heat);
Shape objectClickbox = stageObject.getClickbox(); Shape objectClickbox = stageObject.getClickbox();
if (objectClickbox != null) if (objectClickbox != null && config.highlightTools())
{ {
Point mousePosition = client.getMouseCanvasPosition(); Point mousePosition = client.getMouseCanvasPosition();
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
@@ -128,7 +131,7 @@ public class FoundryOverlay3D extends Overlay {
graphics.fill(objectClickbox); graphics.fill(objectClickbox);
} }
if (color.equals(ColorScheme.PROGRESS_ERROR_COLOR)) if (color.equals(ColorScheme.PROGRESS_ERROR_COLOR) && config.highlightWaterAndLava())
{ {
drawHeatChangers(graphics); drawHeatChangers(graphics);
} }
@@ -209,8 +212,7 @@ public class FoundryOverlay3D extends Overlay {
private void drawKovacIfHandIn(Graphics2D graphics) private void drawKovacIfHandIn(Graphics2D graphics)
{ {
Widget handInWidget = client.getWidget(HAND_IN_WIDGET); Widget handInWidget = client.getWidget(HAND_IN_WIDGET);
if (handInWidget != null && !handInWidget.isHidden() if (handInWidget != null && !handInWidget.isHidden())
&& client.getLocalPlayer().getAnimation() != FINISH_ANIM)
{ {
Shape shape = kovac.getConvexHull(); Shape shape = kovac.getConvexHull();
if (shape != null) if (shape != null)

View File

@@ -1,9 +1,7 @@
package com.toofifty.easygiantsfoundry.enums; package com.toofifty.easygiantsfoundry.enums;
import java.awt.Color;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import net.runelite.client.ui.ColorScheme;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor