Merge pull request #2 from pwatts6060/tool-hightlight
Add relevant tool highlighting feature
This commit is contained in:
11
README.md
11
README.md
@@ -8,9 +8,18 @@ Helpful overlays for the Giant's Foundry minigame
|
||||
- Shows number of actions required to move to the next stage
|
||||
- Shows number of actions before gaining/losing too much heat
|
||||
- Shows best moulds to use
|
||||
|
||||
- Highlights relevant tool with status colors
|
||||
* Red = Wrong temperature
|
||||
* Green = Right temperature
|
||||
* Orange = one action or temperature change remaining
|
||||
* Cyan = Click tool again for bonus progress
|
||||
- Highlights Kovac, Crucible, and Mould Jig when relevant
|
||||
- Highlights waterfall/lava pool when temperature is wrong
|
||||
|
||||
## Contributors
|
||||
|
||||
- [Patrick](https://github.com/pwatts6060 "Patrick's github")
|
||||
* Best moulds interface feature
|
||||
* Highlight relevant tools with status colors
|
||||
* Kovac, Crucible, and Mould Jig highlights
|
||||
* Highlight waterfall/lava pool when temperature is wrong
|
||||
|
||||
@@ -24,7 +24,7 @@ dependencies {
|
||||
}
|
||||
|
||||
group = 'com.toofifty'
|
||||
version = '1.0.1'
|
||||
version = '1.0.2'
|
||||
sourceCompatibility = '1.8'
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
|
||||
@@ -66,7 +66,7 @@ public class EasyGiantsFoundryHelper
|
||||
{
|
||||
Heat heatStage = state.getCurrentHeat();
|
||||
Stage stage = state.getCurrentStage();
|
||||
if (heatStage.getColor() != stage.getColor())
|
||||
if (heatStage != stage.getHeat())
|
||||
{
|
||||
// not the right heat to start with
|
||||
return 0;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.events.GameObjectDespawned;
|
||||
import net.runelite.api.events.GameObjectSpawned;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.ScriptPostFired;
|
||||
import net.runelite.api.events.*;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
@@ -20,7 +19,18 @@ import javax.inject.Inject;
|
||||
)
|
||||
public class EasyGiantsFoundryPlugin extends Plugin
|
||||
{
|
||||
private static final int TRIP_HAMMER = 44619;
|
||||
private static final int GRINDSTONE = 44620;
|
||||
private static final int POLISHING_WHEEL = 44621;
|
||||
|
||||
private static final int LAVA_POOL = 44631;
|
||||
private static final int WATERFALL = 44632;
|
||||
|
||||
private static final int CRUCIBLE = 44776;
|
||||
private static final int MOULD_JIG = 44777;
|
||||
|
||||
private static final int KOVAC_NPC = 11472;
|
||||
|
||||
private static final int PREFORM = 27010;
|
||||
|
||||
@Inject
|
||||
@@ -33,7 +43,10 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
private EasyGiantsFoundryOverlay overlay;
|
||||
private FoundryOverlay2D overlay2d;
|
||||
|
||||
@Inject
|
||||
private FoundryOverlay3D overlay3d;
|
||||
|
||||
@Inject
|
||||
private MouldHelper mouldHelper;
|
||||
@@ -41,30 +54,103 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
@Override
|
||||
protected void startUp()
|
||||
{
|
||||
overlayManager.add(overlay);
|
||||
overlayManager.add(overlay2d);
|
||||
overlayManager.add(overlay3d);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown()
|
||||
{
|
||||
overlayManager.remove(overlay);
|
||||
overlayManager.remove(overlay2d);
|
||||
overlayManager.remove(overlay3d);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameObjectSpawned(GameObjectSpawned event)
|
||||
{
|
||||
if (event.getGameObject().getId() == POLISHING_WHEEL)
|
||||
GameObject gameObject = event.getGameObject();
|
||||
switch (gameObject.getId())
|
||||
{
|
||||
state.setEnabled(true);
|
||||
case POLISHING_WHEEL:
|
||||
state.setEnabled(true);
|
||||
overlay3d.polishingWheel = gameObject;
|
||||
break;
|
||||
case GRINDSTONE:
|
||||
overlay3d.grindstone = gameObject;
|
||||
break;
|
||||
case LAVA_POOL:
|
||||
overlay3d.lavaPool = gameObject;
|
||||
break;
|
||||
case WATERFALL:
|
||||
overlay3d.waterfall = gameObject;
|
||||
break;
|
||||
case TRIP_HAMMER:
|
||||
overlay3d.tripHammer = gameObject;
|
||||
break;
|
||||
case MOULD_JIG:
|
||||
overlay3d.mouldJig = gameObject;
|
||||
break;
|
||||
case CRUCIBLE:
|
||||
overlay3d.crucible = gameObject;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameStateChanged(GameStateChanged event)
|
||||
{
|
||||
if (event.getGameState().equals(GameState.LOADING))
|
||||
{
|
||||
state.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameObjectDespawned(GameObjectDespawned event)
|
||||
{
|
||||
if (event.getGameObject().getId() == POLISHING_WHEEL)
|
||||
GameObject gameObject = event.getGameObject();
|
||||
switch (gameObject.getId())
|
||||
{
|
||||
state.setEnabled(false);
|
||||
case POLISHING_WHEEL:
|
||||
state.setEnabled(false);
|
||||
overlay3d.polishingWheel = null;
|
||||
break;
|
||||
case GRINDSTONE:
|
||||
overlay3d.grindstone = null;
|
||||
break;
|
||||
case LAVA_POOL:
|
||||
overlay3d.lavaPool = null;
|
||||
break;
|
||||
case WATERFALL:
|
||||
overlay3d.waterfall = null;
|
||||
break;
|
||||
case TRIP_HAMMER:
|
||||
overlay3d.tripHammer = null;
|
||||
break;
|
||||
case MOULD_JIG:
|
||||
overlay3d.mouldJig = null;
|
||||
break;
|
||||
case CRUCIBLE:
|
||||
overlay3d.crucible = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onNpcSpawned(NpcSpawned event)
|
||||
{
|
||||
if (event.getNpc().getId() == KOVAC_NPC)
|
||||
{
|
||||
overlay3d.kovac = event.getNpc();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onNpcDespawned(NpcDespawned event)
|
||||
{
|
||||
if (event.getNpc().getId() == KOVAC_NPC)
|
||||
{
|
||||
overlay3d.kovac = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,17 +2,16 @@ package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import com.toofifty.easygiantsfoundry.enums.Heat;
|
||||
import com.toofifty.easygiantsfoundry.enums.Stage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class EasyGiantsFoundryState
|
||||
{
|
||||
@@ -29,14 +28,14 @@ public class EasyGiantsFoundryState
|
||||
// 1 - set mould
|
||||
// 2 - collect preform
|
||||
// 3 -
|
||||
private static final int VARBIT_GAME_STAGE = 13914;
|
||||
static final int VARBIT_GAME_STAGE = 13914;
|
||||
|
||||
private static final int WIDGET_HEAT_PARENT = 49414153;
|
||||
private static final int WIDGET_LOW_HEAT_PARENT = 49414163;
|
||||
private static final int WIDGET_MED_HEAT_PARENT = 49414164;
|
||||
private static final int WIDGET_HIGH_HEAT_PARENT = 49414165;
|
||||
|
||||
private static final int WIDGET_PROGRESS_PARENT = 49414219;
|
||||
static final int WIDGET_PROGRESS_PARENT = 49414219;
|
||||
// children with type 3 are stage boxes
|
||||
// every 11th child is a sprite
|
||||
|
||||
@@ -176,4 +175,33 @@ public class EasyGiantsFoundryState
|
||||
|
||||
return Heat.NONE;
|
||||
}
|
||||
|
||||
public int getHeatChangeNeeded()
|
||||
{
|
||||
Heat requiredHeat = getCurrentStage().getHeat();
|
||||
int heat = getHeatAmount();
|
||||
|
||||
int[] range;
|
||||
switch (requiredHeat)
|
||||
{
|
||||
case LOW:
|
||||
range = getLowHeatRange();
|
||||
break;
|
||||
case MED:
|
||||
range = getMedHeatRange();
|
||||
break;
|
||||
case HIGH:
|
||||
range = getHighHeatRange();
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (heat < range[0])
|
||||
return range[0] - heat;
|
||||
else if (heat > range[1])
|
||||
return range[1] - heat;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,22 @@ package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import com.toofifty.easygiantsfoundry.enums.Heat;
|
||||
import com.toofifty.easygiantsfoundry.enums.Stage;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
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.components.LineComponent;
|
||||
import net.runelite.client.ui.overlay.components.TitleComponent;
|
||||
|
||||
@Singleton
|
||||
public class EasyGiantsFoundryOverlay extends OverlayPanel
|
||||
public class FoundryOverlay2D extends OverlayPanel
|
||||
{
|
||||
@Inject
|
||||
private EasyGiantsFoundryState state;
|
||||
@@ -52,7 +56,7 @@ public class EasyGiantsFoundryOverlay extends OverlayPanel
|
||||
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.getColor()).build()
|
||||
LineComponent.builder().left("Stage").right(stage.getName() + " (" + state.getProgressAmount() / 10 + "%)").rightColor(stage.getHeat().getColor()).build()
|
||||
);
|
||||
|
||||
int actionsLeft = helper.getActionsLeftInStage();
|
||||
@@ -0,0 +1,226 @@
|
||||
package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import com.toofifty.easygiantsfoundry.enums.Heat;
|
||||
import com.toofifty.easygiantsfoundry.enums.Stage;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
|
||||
import javax.inject.Inject;
|
||||
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;
|
||||
GameObject polishingWheel;
|
||||
GameObject lavaPool;
|
||||
GameObject waterfall;
|
||||
GameObject mouldJig;
|
||||
GameObject crucible;
|
||||
NPC kovac;
|
||||
|
||||
private final Client client;
|
||||
private final EasyGiantsFoundryState state;
|
||||
private final EasyGiantsFoundryHelper helper;
|
||||
|
||||
@Inject
|
||||
private FoundryOverlay3D(Client client, EasyGiantsFoundryState state, EasyGiantsFoundryHelper helper)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
this.client = client;
|
||||
this.state = state;
|
||||
this.helper = helper;
|
||||
}
|
||||
|
||||
private Color getObjectColor(Stage stage, Heat heat)
|
||||
{
|
||||
if (stage.getHeat() != heat)
|
||||
{
|
||||
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) {
|
||||
return Color.CYAN;
|
||||
}
|
||||
|
||||
|
||||
int actionsLeft = helper.getActionsLeftInStage();
|
||||
int heatLeft = helper.getActionsForHeatLevel();
|
||||
if (actionsLeft <= 1 || heatLeft <= 1)
|
||||
{
|
||||
return ColorScheme.PROGRESS_INPROGRESS_COLOR;
|
||||
}
|
||||
|
||||
return ColorScheme.PROGRESS_COMPLETE_COLOR;
|
||||
}
|
||||
|
||||
private GameObject getStageObject(Stage stage)
|
||||
{
|
||||
switch (stage)
|
||||
{
|
||||
case TRIP_HAMMER:
|
||||
return tripHammer;
|
||||
case GRINDSTONE:
|
||||
return grindstone;
|
||||
case POLISHING_WHEEL:
|
||||
return polishingWheel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!state.isEnabled())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
drawKovacIfHandIn(graphics);
|
||||
|
||||
if (state.getCurrentStage() == null)
|
||||
{
|
||||
drawMouldIfNotSet(graphics);
|
||||
drawCrucibleIfMouldSet(graphics);
|
||||
return null;
|
||||
}
|
||||
|
||||
Heat heat = state.getCurrentHeat();
|
||||
Stage stage = state.getCurrentStage();
|
||||
|
||||
GameObject stageObject = getStageObject(stage);
|
||||
if (stageObject == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Color color = getObjectColor(stage, heat);
|
||||
Shape objectClickbox = stageObject.getClickbox();
|
||||
if (objectClickbox != null)
|
||||
{
|
||||
Point mousePosition = client.getMouseCanvasPosition();
|
||||
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
|
||||
{
|
||||
graphics.setColor(color.darker());
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.setColor(color);
|
||||
}
|
||||
graphics.draw(objectClickbox);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
|
||||
graphics.fill(objectClickbox);
|
||||
}
|
||||
|
||||
if (color.equals(ColorScheme.PROGRESS_ERROR_COLOR))
|
||||
{
|
||||
drawHeatChangers(graphics);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void drawHeatChangers(Graphics2D graphics)
|
||||
{
|
||||
int change = state.getHeatChangeNeeded();
|
||||
Shape shape = null;
|
||||
if (change < 0)
|
||||
{
|
||||
shape = waterfall.getClickbox();
|
||||
} else if (change > 0)
|
||||
{
|
||||
shape = lavaPool.getClickbox();
|
||||
}
|
||||
if (shape != null)
|
||||
{
|
||||
Point mousePosition = client.getMouseCanvasPosition();
|
||||
Color color = ColorScheme.PROGRESS_COMPLETE_COLOR;
|
||||
if (shape.contains(mousePosition.getX(), mousePosition.getY()))
|
||||
{
|
||||
graphics.setColor(color.darker());
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.setColor(color);
|
||||
}
|
||||
graphics.draw(shape);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
|
||||
graphics.fill(shape);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawCrucibleIfMouldSet(Graphics2D graphics)
|
||||
{
|
||||
if (client.getVarbitValue(MouldHelper.SWORD_TYPE_1_VARBIT) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (client.getVarbitValue(EasyGiantsFoundryState.VARBIT_GAME_STAGE) != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Shape shape = crucible.getConvexHull();
|
||||
if (shape != null)
|
||||
{
|
||||
Color color = Color.CYAN;
|
||||
graphics.setColor(color);
|
||||
graphics.draw(shape);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
|
||||
graphics.fill(shape);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawMouldIfNotSet(Graphics2D graphics)
|
||||
{
|
||||
if (client.getWidget(EasyGiantsFoundryState.WIDGET_PROGRESS_PARENT) != null
|
||||
|| client.getVarbitValue(MouldHelper.SWORD_TYPE_1_VARBIT) == 0
|
||||
|| (client.getVarbitValue(EasyGiantsFoundryState.VARBIT_GAME_STAGE) != 0
|
||||
&& client.getVarbitValue(EasyGiantsFoundryState.VARBIT_GAME_STAGE) != 2))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Shape shape = mouldJig.getConvexHull();
|
||||
if (shape != null)
|
||||
{
|
||||
Color color = Color.CYAN;
|
||||
graphics.setColor(color);
|
||||
graphics.draw(shape);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
|
||||
graphics.fill(shape);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawKovacIfHandIn(Graphics2D graphics)
|
||||
{
|
||||
Widget handInWidget = client.getWidget(HAND_IN_WIDGET);
|
||||
if (handInWidget != null && !handInWidget.isHidden()
|
||||
&& client.getLocalPlayer().getAnimation() != FINISH_ANIM)
|
||||
{
|
||||
Shape shape = kovac.getConvexHull();
|
||||
if (shape != null)
|
||||
{
|
||||
Color color = Color.CYAN;
|
||||
graphics.setColor(color);
|
||||
graphics.draw(shape);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
|
||||
graphics.fill(shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MouldHelper
|
||||
{
|
||||
@@ -17,8 +18,8 @@ public class MouldHelper
|
||||
static final int REDRAW_MOULD_LIST_SCRIPT = 6095;
|
||||
static final int RESET_MOULD_SCRIPT = 6108;
|
||||
public static final int SELECT_MOULD_SCRIPT = 6098;
|
||||
private static final int SWORD_TYPE_1_VARBIT = 13907; // 4=Broad
|
||||
private static final int SWORD_TYPE_2_VARBIT = 13908; // 3=Flat
|
||||
static final int SWORD_TYPE_1_VARBIT = 13907; // 4=Broad
|
||||
static final int SWORD_TYPE_2_VARBIT = 13908; // 3=Flat
|
||||
private static final int DISABLED_TEXT_COLOR = 0x9f9f9f;
|
||||
private static final int GREEN = 0xdc10d;
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ import net.runelite.client.ui.ColorScheme;
|
||||
@AllArgsConstructor
|
||||
public enum Stage
|
||||
{
|
||||
TRIP_HAMMER("Hammer", ColorScheme.PROGRESS_ERROR_COLOR, 20, -25),
|
||||
GRINDSTONE("Grind", ColorScheme.PROGRESS_INPROGRESS_COLOR, 10, 15),
|
||||
POLISHING_WHEEL("Polish", ColorScheme.PROGRESS_COMPLETE_COLOR, 10, -17);
|
||||
TRIP_HAMMER("Hammer", Heat.HIGH, 20, -25),
|
||||
GRINDSTONE("Grind", Heat.MED, 10, 15),
|
||||
POLISHING_WHEEL("Polish", Heat.LOW, 10, -17);
|
||||
|
||||
private final String name;
|
||||
private final Color color;
|
||||
private final Heat heat;
|
||||
private final int progressPerAction;
|
||||
private final int heatChange;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user