forked from hex-agon/mastering-mixology
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a config section for picking an item goal and shows an infobox for the 3 components to show how much you have left to reach your goal
- Loading branch information
1 parent
b2dbe6c
commit d0c5ad6
Showing
6 changed files
with
333 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/work/fking/masteringmixology/RewardItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package work.fking.masteringmixology; | ||
|
||
import net.runelite.api.ItemID; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@SuppressWarnings("unused") // The items are used in the config | ||
public enum RewardItem { | ||
NONE("None", 0, 0, 0, 0), | ||
|
||
APPRENTICE_POTION_PACK("Apprentice Potion Pack", ItemID.APPRENTICE_POTION_PACK, 420, 70, 30), | ||
ADEPT_POTION_PACK("Adept Potion Pack", ItemID.ADEPT_POTION_PACK, 180, 440, 70), | ||
EXPERT_POTION_PACK("Expert Potion Pack", ItemID.EXPERT_POTION_PACK, 410, 320, 480), | ||
PRESCRIPTION_GOGGLES("Prescription Goggles", ItemID.PRESCRIPTION_GOGGLES, 8600, 7000, 9350), | ||
ALCHEMIST_LABCOAT("Alchemist Labcoat", ItemID.ALCHEMIST_LABCOAT, 2250, 2800, 3700), | ||
ALCHEMIST_PANTS("Alchemist Pants", ItemID.ALCHEMIST_PANTS, 2250, 2800, 3700), | ||
ALCHEMIST_GLOVES("Alchemist Gloves", ItemID.ALCHEMIST_GLOVES, 2250, 2800, 3700), | ||
REAGENT_POUCH("Reagent Pouch", ItemID.REAGENT_POUCH, 13800, 12200, 15100), | ||
POTION_STORAGE("Potion Storage", ItemID.POTION_STORAGE, 7750, 6300, 8950), | ||
CHUGGING_BARREL("Chugging Barrel", ItemID.PREPOT_DEVICE, 17250, 14000, 18600), | ||
ALCHEMISTS_AMULET("Alchemist's Amulet", ItemID.ALCHEMISTS_AMULET, 6900, 5650, 7400), | ||
ALDARIUM("Aldarium", ItemID.ALDARIUM, 80, 60, 90); | ||
|
||
private final String itemName; | ||
private final int itemId; | ||
private final Map<PotionComponent, Integer> componentCost = new HashMap<>(); | ||
|
||
RewardItem(String itemName, int itemId, int moxResinCost, int agaResinCost, int lyeResinCost) { | ||
this.itemName = itemName; | ||
this.itemId = itemId; | ||
this.componentCost.put(PotionComponent.MOX, moxResinCost); | ||
this.componentCost.put(PotionComponent.AGA, agaResinCost); | ||
this.componentCost.put(PotionComponent.LYE, lyeResinCost); | ||
} | ||
|
||
public String itemName() { | ||
return itemName; | ||
} | ||
|
||
public int itemId() { | ||
return itemId; | ||
} | ||
|
||
public Map<PotionComponent, Integer> componentCost() { | ||
return componentCost; | ||
} | ||
|
||
public int componentCost(PotionComponent component) { | ||
return componentCost.get(component); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
src/main/java/work/fking/masteringmixology/ui/GoalTrackingInfobox.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package work.fking.masteringmixology.ui; | ||
|
||
import net.runelite.client.ui.overlay.infobox.InfoBox; | ||
import net.runelite.client.util.QuantityFormatter; | ||
import work.fking.masteringmixology.MasteringMixologyPlugin; | ||
import work.fking.masteringmixology.PotionComponent; | ||
import work.fking.masteringmixology.RewardItem; | ||
|
||
import java.awt.Color; | ||
import java.awt.image.BufferedImage; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
|
||
public class GoalTrackingInfobox extends InfoBox { | ||
private RewardItem rewardItem; | ||
private final Map<PotionComponent, Integer> resinBalance = new HashMap<>(); | ||
|
||
public GoalTrackingInfobox(MasteringMixologyPlugin plugin, BufferedImage image, RewardItem rewardItem, | ||
int mox, int aga, int lye) { | ||
super(image, plugin); | ||
this.rewardItem = rewardItem; | ||
resinBalance.put(PotionComponent.MOX, mox); | ||
resinBalance.put(PotionComponent.AGA, aga); | ||
resinBalance.put(PotionComponent.LYE, lye); | ||
} | ||
|
||
@Override | ||
public String getText() { | ||
double percentageCompleted = getPercentageCompleted(); | ||
return (int) (percentageCompleted * 100) + "%"; | ||
} | ||
|
||
private double getPercentageCompleted() { | ||
int currentAmount = resinBalance.values().stream().mapToInt(Integer::intValue).sum(); | ||
int goalAmount = rewardItem.componentCost().values().stream().mapToInt(Integer::intValue).sum(); | ||
return currentAmount >= goalAmount ? 1 : ((double) currentAmount / goalAmount); | ||
} | ||
|
||
@Override | ||
public Color getTextColor() { | ||
double percentageCompleted = getPercentageCompleted(); | ||
if (percentageCompleted >= 1) { | ||
return Color.GREEN; | ||
} else { | ||
return Color.WHITE; | ||
} | ||
} | ||
|
||
@Override | ||
public String getTooltip() { | ||
StringBuilder goal = new StringBuilder(rewardItem.itemName() + "</br>"); | ||
for (PotionComponent component : PotionComponent.values()) { | ||
int current = resinBalance.get(component); | ||
int goalAmount = rewardItem.componentCost(component); | ||
goal.append(component.name()) | ||
.append(": ") | ||
.append(QuantityFormatter.quantityToRSDecimalStack(current)) | ||
.append("/") | ||
.append(QuantityFormatter.quantityToRSDecimalStack(goalAmount)) | ||
.append("</br>"); | ||
} | ||
int currentBalance = resinBalance.values().stream().mapToInt(Integer::intValue).sum(); | ||
int goalCost = rewardItem.componentCost().values().stream().mapToInt(Integer::intValue).sum(); | ||
// Round up | ||
int potionsLeft = (int) Math.ceil((double) (goalCost - currentBalance) / 30); | ||
if (potionsLeft > 0) { | ||
goal.append("~") | ||
.append(potionsLeft) | ||
.append(" potions left</br>"); | ||
} | ||
return goal.toString(); | ||
} | ||
|
||
public void setRewardItem(RewardItem rewardItem) { | ||
this.rewardItem = rewardItem; | ||
} | ||
|
||
public void setResinBalance(int mox, int aga, int lye) { | ||
resinBalance.put(PotionComponent.MOX, mox); | ||
resinBalance.put(PotionComponent.AGA, aga); | ||
resinBalance.put(PotionComponent.LYE, lye); | ||
} | ||
} |
Oops, something went wrong.