Skip to content

Commit

Permalink
Allow seeing goal trackers in the area before the labs
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueSoapTurtle committed Oct 29, 2024
1 parent 020122c commit d864b64
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.runelite.api.FontID;
import net.runelite.api.GameState;
import net.runelite.api.InventoryID;
import net.runelite.api.Player;
import net.runelite.api.ItemID;
import net.runelite.api.TileObject;
import net.runelite.api.coords.LocalPoint;
Expand Down Expand Up @@ -96,6 +97,9 @@ public class MasteringMixologyPlugin extends Plugin {
private static final int COMPONENT_POTION_ORDERS_GROUP_ID = 882;
private static final int COMPONENT_POTION_ORDERS = COMPONENT_POTION_ORDERS_GROUP_ID << 16 | 2;

private static final int LABS_REGION_ID = 5521;
private static final int LABS_REGION_PLANE = 0;

@Inject
private Client client;

Expand Down Expand Up @@ -149,6 +153,16 @@ public boolean isInLab() {
return inLab;
}

/**
* @return true if the player is in the labs region (the area where the minigame takes place)
* the isInlab method only checks if they are inside the actual lab room where the UI is active
*/
public boolean isInLabRegion() {
Player player = client.getLocalPlayer();
return player != null && player.getWorldLocation().getRegionID() == LABS_REGION_ID
&& player.getWorldLocation().getPlane() == LABS_REGION_PLANE;
}

@Provides
MasteringMixologyConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(MasteringMixologyConfig.class);
Expand All @@ -170,7 +184,6 @@ protected void shutDown() {
overlayManager.remove(potionOverlay);
inLab = false;

// TODO Test this works, maybe we need invokeLater
updateInfoboxes();
}

Expand All @@ -179,6 +192,10 @@ public void onGameStateChanged(GameStateChanged event) {
if (event.getGameState() == GameState.LOGIN_SCREEN || event.getGameState() == GameState.HOPPING) {
highlightedObjects.clear();
}

if (event.getGameState() == GameState.LOGGED_IN) {
updateInfoboxes();
}
}

@Subscribe
Expand Down Expand Up @@ -663,7 +680,7 @@ private PotionModifier getPotionModifier(int orderIdx) {

private void updateInfoboxes() {
// Setup the orders fulfilled infobox
if (inLab && config.showOrdersFulfilledInfobox()) {
if (isInLabRegion() && config.showOrdersFulfilledInfobox()) {
int ordersFulfilled = client.getVarpValue(VARP_ORDERS_FULFILLED);
if (ordersFulfilledInfoBox == null) {
BufferedImage image = itemManager.getImage(ItemID.ALDARIUM);
Expand All @@ -677,7 +694,7 @@ private void updateInfoboxes() {
}

// Setup the goal tracking infobox
if (inLab && config.showGoalTrackingInfobox() && config.selectedReward() != RewardItem.NONE) {
if (isInLabRegion() && config.showGoalTrackingInfobox() && config.selectedReward() != RewardItem.NONE) {
RewardItem rewardItem = config.selectedReward();
int moxResin = client.getVarpValue(VARP_MOX_RESIN);
int agaResin = client.getVarpValue(VARP_AGA_RESIN);
Expand All @@ -704,7 +721,7 @@ private void updateInfoboxes() {
}

// Setup an infobox for each resin to track progress towards a goal
if (inLab && config.showResinInfoboxes() && config.selectedReward() != RewardItem.NONE) {
if (isInLabRegion() && config.showResinInfoboxes() && config.selectedReward() != RewardItem.NONE) {
RewardItem rewardItem = config.selectedReward();
MasteringMixologyConfig.ResinInfoboxDisplayType displayType = config.resinInfoboxDisplayType();
Map<PotionComponent, Integer> resinBalance = new HashMap<>();
Expand Down

0 comments on commit d864b64

Please sign in to comment.