Merge pull request #27 from Toofifty/reputation-fix

Reputation fix and Color changes
This commit is contained in:
Patrick Watts
2023-08-15 01:12:09 +04:00
committed by GitHub
8 changed files with 162 additions and 134 deletions

View File

@@ -8,7 +8,7 @@ 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
- Highlights relevant tool with customizable status colors
* Red = Wrong temperature
* Green = Right temperature
* Orange = one action or temperature change remaining
@@ -26,6 +26,7 @@ Helpful overlays for the Giant's Foundry minigame
* Added Bonus sound/notifications
* Added overlay configs
* Added info panel configs
* Added color configuration
- [Vanillj](https://github.com/Vanillj "Vanillj's github")
* Added config
* Added notifications for heat/stage changes

View File

@@ -10,7 +10,7 @@ repositories {
mavenCentral()
}
def runeLiteVersion = '1.8.27'
def runeLiteVersion = 'latest.release'
dependencies {
compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion
@@ -24,9 +24,9 @@ dependencies {
}
group = 'com.toofifty'
version = '1.0.5'
sourceCompatibility = '1.8'
version = '1.0.6'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.release.set(11)
}

View File

@@ -1,9 +1,11 @@
package com.toofifty.easygiantsfoundry;
import java.awt.Color;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigSection;
import net.runelite.client.ui.ColorScheme;
@ConfigGroup(EasyGiantsFoundryConfig.GROUP)
public interface EasyGiantsFoundryConfig extends Config {
@@ -162,7 +164,7 @@ public interface EasyGiantsFoundryConfig extends Config {
@ConfigSection(
name = "Info Panel",
description = "Settings for the Info Panel overlay",
position = 1
position = 2
)
String infoPanelList = "infoPanelList";
@@ -232,4 +234,97 @@ public interface EasyGiantsFoundryConfig extends Config {
{
return false;
}
@ConfigSection(
name = "Colour",
description = "Colours",
position = 3
)
String colourList = "colourList";
@ConfigItem(
keyName = "mouldText",
name = "Mould Text",
description = "Colour for optimal mould text",
position = 0,
section = colourList
)
default Color mouldTextColour()
{
return new Color(0xdc10d);
}
@ConfigItem(
keyName = "generalColour",
name = "General",
description = "Colour for highlighting objects/npcs in general",
position = 1,
section = colourList
)
default Color generalHighlight()
{
return Color.CYAN;
}
@ConfigItem(
keyName = "lavaWaterColour",
name = "Lava/Waterfall",
description = "Colour for highlighting lava/waterfall",
position = 2,
section = colourList
)
default Color lavaWaterfallColour()
{
return ColorScheme.PROGRESS_COMPLETE_COLOR;
}
@ConfigItem(
keyName = "toolGood",
name = "Tool Good",
description = "Colour for highlighting current tool when they are usable",
position = 3,
section = colourList
)
default Color toolGood()
{
return ColorScheme.PROGRESS_COMPLETE_COLOR;
}
@ConfigItem(
keyName = "toolBad",
name = "Tool Bad",
description = "Colour for highlighting current tool when they are not usable",
position = 4,
section = colourList
)
default Color toolBad()
{
return ColorScheme.PROGRESS_ERROR_COLOR;
}
@ConfigItem(
keyName = "toolCaution",
name = "Tool Caution",
description = "Colour for highlighting current tool when they are about to be not usable",
position = 5,
section = colourList
)
default Color toolCaution()
{
return ColorScheme.PROGRESS_INPROGRESS_COLOR;
}
@ConfigItem(
keyName = "toolBonus",
name = "Tool Bonus",
description = "Colour for highlighting current tool when they have a bonus to click on",
position = 6,
section = colourList
)
default Color toolBonus()
{
return Color.CYAN;
}
}

View File

@@ -1,6 +1,8 @@
package com.toofifty.easygiantsfoundry;
import com.google.inject.Provides;
import com.toofifty.easygiantsfoundry.enums.Stage;
import javax.inject.Inject;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
@@ -8,18 +10,24 @@ 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.api.events.VarbitChanged;
import net.runelite.client.Notifier;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.config.ConfigManager;
import com.toofifty.easygiantsfoundry.enums.Stage;
import javax.inject.Inject;
@Slf4j
@PluginDescriptor(
@@ -42,12 +50,17 @@ public class EasyGiantsFoundryPlugin extends Plugin
private static final int PREFORM = 27010;
private static final int REPUTATION_VARBIT = 3436;
private Stage oldStage;
private int lastBoost;
private boolean bonusNotified = false;
@Getter
private int reputation;
@Inject
private EasyGiantsFoundryState state;
@@ -81,15 +94,15 @@ public class EasyGiantsFoundryPlugin extends Plugin
@Inject
private ConfigManager configManager;
@Getter
@Inject
private PointsTracker pointsTracker;
@Override
protected void startUp()
{
overlayManager.add(overlay2d);
overlayManager.add(overlay3d);
if (client.getGameState() == GameState.LOGGED_IN)
{
reputation = client.getVarpValue(REPUTATION_VARBIT);
}
}
@Override
@@ -140,7 +153,7 @@ public class EasyGiantsFoundryPlugin extends Plugin
if (event.getGameState().equals(GameState.LOGGED_IN))
{
pointsTracker.load();
reputation = client.getVarpValue(REPUTATION_VARBIT);
}
}
@@ -244,6 +257,15 @@ public class EasyGiantsFoundryPlugin extends Plugin
}
}
@Subscribe
public void onVarbitChanged(VarbitChanged event)
{
if (event.getVarpId() == REPUTATION_VARBIT)
{
reputation = client.getVarpValue(REPUTATION_VARBIT);
}
}
@Subscribe
protected void onConfigChanged(ConfigChanged configChanged)
{
@@ -264,12 +286,6 @@ public class EasyGiantsFoundryPlugin extends Plugin
checkBonus();
}
@Subscribe
public void onWidgetLoaded(WidgetLoaded event)
{
pointsTracker.onWidgetLoaded(event.getGroupId());
}
private void checkBonus()
{
if (!state.isEnabled() || state.getCurrentStage() == null

View File

@@ -2,6 +2,11 @@ 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 javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.overlay.OverlayPanel;
@@ -9,12 +14,6 @@ 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
{
@@ -98,12 +97,12 @@ public class FoundryOverlay2D extends OverlayPanel
);
}
}
int points = plugin.getPointsTracker().getShopPoints();
//
// int points = plugin.getPointsTracker().getShopPoints();
if (config.drawShopPoints())
{
panelComponent.getChildren().add(
LineComponent.builder().left("Reputation").right(points + "").build()
LineComponent.builder().left("Reputation").right(plugin.getReputation() + "").build()
);
}

View File

@@ -2,18 +2,19 @@ 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.Shape;
import javax.inject.Inject;
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 HAND_IN_WIDGET = 49414221;
@@ -47,22 +48,22 @@ public class FoundryOverlay3D extends Overlay {
{
if (stage.getHeat() != heat)
{
return ColorScheme.PROGRESS_ERROR_COLOR;
return config.toolBad();
}
if (BonusWidget.isActive(client))
{
return Color.CYAN;
return config.toolBonus();
}
int actionsLeft = helper.getActionsLeftInStage();
int heatLeft = helper.getActionsForHeatLevel();
if (actionsLeft <= 1 || heatLeft <= 1)
{
return ColorScheme.PROGRESS_INPROGRESS_COLOR;
return config.toolCaution();
}
return ColorScheme.PROGRESS_COMPLETE_COLOR;
return config.toolGood();
}
private GameObject getStageObject(Stage stage)
@@ -131,7 +132,7 @@ public class FoundryOverlay3D extends Overlay {
graphics.fill(objectClickbox);
}
if (color.equals(ColorScheme.PROGRESS_ERROR_COLOR) && config.highlightWaterAndLava())
if (stage.getHeat() != heat && config.highlightWaterAndLava())
{
drawHeatChangers(graphics);
}
@@ -153,7 +154,7 @@ public class FoundryOverlay3D extends Overlay {
if (shape != null)
{
Point mousePosition = client.getMouseCanvasPosition();
Color color = ColorScheme.PROGRESS_COMPLETE_COLOR;
Color color = config.lavaWaterfallColour();
if (shape.contains(mousePosition.getX(), mousePosition.getY()))
{
graphics.setColor(color.darker());
@@ -181,7 +182,7 @@ public class FoundryOverlay3D extends Overlay {
Shape shape = crucible.getConvexHull();
if (shape != null)
{
Color color = Color.CYAN;
Color color = config.generalHighlight();
graphics.setColor(color);
graphics.draw(shape);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
@@ -201,7 +202,7 @@ public class FoundryOverlay3D extends Overlay {
Shape shape = mouldJig.getConvexHull();
if (shape != null)
{
Color color = Color.CYAN;
Color color = config.generalHighlight();
graphics.setColor(color);
graphics.draw(shape);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
@@ -217,7 +218,7 @@ public class FoundryOverlay3D extends Overlay {
Shape shape = kovac.getConvexHull();
if (shape != null)
{
Color color = Color.CYAN;
Color color = config.generalHighlight();
graphics.setColor(color);
graphics.draw(shape);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));

View File

@@ -2,15 +2,14 @@ package com.toofifty.easygiantsfoundry;
import com.toofifty.easygiantsfoundry.enums.CommissionType;
import com.toofifty.easygiantsfoundry.enums.Mould;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.ScriptID;
import net.runelite.api.widgets.Widget;
import net.runelite.client.callback.ClientThread;
import javax.inject.Inject;
import java.util.LinkedHashMap;
import java.util.Map;
public class MouldHelper
{
static final int MOULD_LIST_PARENT = 47054857;
@@ -29,6 +28,9 @@ public class MouldHelper
@Inject
private ClientThread clientThread;
@Inject
private EasyGiantsFoundryConfig config;
public void selectBest(int scriptId)
{
Widget parent = client.getWidget(MOULD_LIST_PARENT);
@@ -52,7 +54,7 @@ public class MouldHelper
}
}
if (bestWidget != null) {
bestWidget.setTextColor(GREEN);
bestWidget.setTextColor(config.mouldTextColour().getRGB());
}
if (scriptId == DRAW_MOULD_LIST_SCRIPT || scriptId == REDRAW_MOULD_LIST_SCRIPT)

View File

@@ -1,86 +0,0 @@
package com.toofifty.easygiantsfoundry;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.widgets.Widget;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.util.Text;
import javax.inject.Inject;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PointsTracker
{
private static final int SHOP_WIDGET = 753;
private static final int CHAT_WIDGET = 229;
private static final int SHOP_POINTS_TEXT = 13;
private static final int CHAT_POINTS_TEXT = 1;
private static final Pattern pattern = Pattern.compile("quality: (?<points>\\d+) Best");
@Getter
private int shopPoints;
@Inject
private ConfigManager configManager;
@Inject
private Client client;
@Inject
ClientThread clientThread;
public void load()
{
Integer points = configManager.getRSProfileConfiguration(EasyGiantsFoundryConfig.GROUP, EasyGiantsFoundryConfig.POINTS_KEY, int.class);
if (points != null)
{
shopPoints = points;
}
}
private void save()
{
configManager.setRSProfileConfiguration(EasyGiantsFoundryConfig.GROUP, EasyGiantsFoundryConfig.POINTS_KEY, shopPoints);
}
public void onWidgetLoaded(int groupId)
{
if (groupId == SHOP_WIDGET)
{
clientThread.invokeLater(this::shopOpened);
}
else if (groupId == CHAT_WIDGET)
{
clientThread.invokeLater(this::chatBox);
}
}
private void chatBox()
{
Widget chat = client.getWidget(CHAT_WIDGET, CHAT_POINTS_TEXT);
if (chat == null)
{
return;
}
String chatText = Text.sanitizeMultilineText(chat.getText());
final Matcher matcher = pattern.matcher(chatText);
if (matcher.find())
{
shopPoints += Integer.parseInt(matcher.group("points"));
save();
}
}
private void shopOpened()
{
Widget shop = client.getWidget(SHOP_WIDGET, SHOP_POINTS_TEXT);
if (shop != null && shop.getText() != null && Integer.parseInt(shop.getText()) != shopPoints)
{
shopPoints = Integer.parseInt(shop.getText());
save();
}
}
}