Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme fixes #276

Merged
merged 9 commits into from
Sep 9, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public static void updateList() {
}

public static void updateFooter(Text f) {
footer = f.getString();
if (f == null) {
footer = null;
} else {
footer = f.getString();
}
}

public static String getFooter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ public AdvertisementWidget() {

@Override
public void updateContent() {
boolean added = false;
for (int i = 73; i < 80; i++) {
Text text = PlayerListMgr.textAt(i);
if (text != null)
if (text != null) {
this.addComponent(new PlainTextComponent(text));
added = true;
}
}

if (!added) {
this.addComponent(new PlainTextComponent(Text.literal("No Advertisements").formatted(Formatting.GRAY)));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,38 @@ public void updateContent() {
// that
// In beginning it only shows montezuma, then timecharms and enigma souls are
// added
Text pos49 = PlayerListMgr.textAt(49); // Can be times visited rift
Text pos51 = PlayerListMgr.textAt(51); // Can be lifetime motes or visited rift
Text pos53 = PlayerListMgr.textAt(53); // Can be lifetime motes

int headerPos = 0;
// this seems suboptimal, but I'm not sure if there's a way to do it better.
// search for the GTK header and offset the rest accordingly.
for (int i = 45; i <= 49; i++) {
String str = PlayerListMgr.strAt(i);
if (str != null && str.startsWith("Good to")) {
headerPos = i;
break;
}
}

Text posA = PlayerListMgr.textAt(headerPos + 2); // Can be times visited rift
Text posB = PlayerListMgr.textAt(headerPos + 4); // Can be lifetime motes or visited rift
Text posC = PlayerListMgr.textAt(headerPos + 6); // Can be lifetime motes

int visitedRiftPos = 0;
int lifetimeMotesPos = 0;

// Check each position to see what is or isn't there so we don't try adding
// invalid components
if (pos49.getString().contains("times"))
visitedRiftPos = 49;
if (pos51.getString().contains("Motes"))
lifetimeMotesPos = 51;
if (pos51.getString().contains("times"))
visitedRiftPos = 51;
if (pos53.getString().contains("Motes"))
lifetimeMotesPos = 53;

Text timesVisitedRift = (visitedRiftPos == 51) ? pos51 : (visitedRiftPos == 49) ? pos49 : null;
Text lifetimeMotesEarned = (lifetimeMotesPos == 53) ? pos53 : (lifetimeMotesPos == 51) ? pos51 : null;
if (posA != null && posA.getString().contains("times"))
visitedRiftPos = headerPos + 2;
if (posB != null && posB.getString().contains("Motes"))
lifetimeMotesPos = headerPos + 4;
if (posB != null && posB.getString().contains("times"))
visitedRiftPos = headerPos + 4;
if (posC != null && posC.getString().contains("Motes"))
lifetimeMotesPos = headerPos + 6;

Text timesVisitedRift = (visitedRiftPos == headerPos + 4) ? posB : (visitedRiftPos == headerPos + 2) ? posA : Text.literal("No Data").formatted(Formatting.GRAY);
Text lifetimeMotesEarned = (lifetimeMotesPos == headerPos + 6) ? posC : (lifetimeMotesPos == headerPos + 4) ? posB : Text.literal("No Data").formatted(Formatting.GRAY);

if (visitedRiftPos != 0) {
this.addComponent(new IcoTextComponent(Ico.EXPERIENCE_BOTTLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import net.minecraft.util.Formatting;

public class RiftProfileWidget extends Widget {

private static final MutableText TITLE = Text.literal("Profile").formatted(Formatting.DARK_AQUA, Formatting.BOLD);

public RiftProfileWidget() {
super(TITLE, Formatting.DARK_AQUA.getColorValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import me.xmrvizzy.skyblocker.skyblock.tabhud.util.Ico;
import me.xmrvizzy.skyblocker.skyblock.tabhud.util.PlayerListMgr;
import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.Widget;
import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent;
import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component.ProgressComponent;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
Expand All @@ -14,86 +15,109 @@

public class RiftProgressWidget extends Widget {

private static final MutableText TITLE = Text.literal("Rift Progress").formatted(Formatting.BLUE, Formatting.BOLD);
private static final MutableText TITLE = Text.literal("Rift Progress").formatted(Formatting.BLUE, Formatting.BOLD);

private static final Pattern TIMECHARMS_PATTERN = Pattern.compile("Timecharms: (?<current>[0-9]+)\\/(?<total>[0-9]+)");
private static final Pattern ENIGMA_SOULS_PATTERN = Pattern.compile("Enigma Souls: (?<current>[0-9]+)\\/(?<total>[0-9]+)");
private static final Pattern MONTEZUMA_PATTERN = Pattern.compile("Montezuma: (?<current>[0-9]+)\\/(?<total>[0-9]+)");
private static final Pattern TIMECHARMS_PATTERN = Pattern.compile("Timecharms: (?<current>[0-9]+)\\/(?<total>[0-9]+)");
private static final Pattern ENIGMA_SOULS_PATTERN = Pattern.compile("Enigma Souls: (?<current>[0-9]+)\\/(?<total>[0-9]+)");
private static final Pattern MONTEZUMA_PATTERN = Pattern.compile("Montezuma: (?<current>[0-9]+)\\/(?<total>[0-9]+)");

public RiftProgressWidget() {
super(TITLE, Formatting.BLUE.getColorValue());
public RiftProgressWidget() {
super(TITLE, Formatting.BLUE.getColorValue());
}

@Override
public void updateContent() {
// After you progress further the tab adds more info so we need to be careful of
// that
// In beginning it only shows montezuma, then timecharms and enigma souls are
// added
String pos45 = PlayerListMgr.strAt(45); // Can be Montezuma or Timecharms
String pos46 = PlayerListMgr.strAt(46); // Can be Enigma Souls or Empty
String pos47 = PlayerListMgr.strAt(47); // Can be Montezuma or "Good to know" heading
// After you progress further, the tab adds more info so we need to be careful
// of that.
// In beginning it only shows montezuma, then timecharms and enigma souls are
// added.

String pos44 = PlayerListMgr.strAt(44);

// LHS short-circuits, so the RHS won't be evaluated on pos44 == null
if (pos44 == null || !pos44.contains("Rift Progress")) {
this.addComponent(new PlainTextComponent(Text.literal("No Progress").formatted(Formatting.GRAY)));
return;
}

// let's try to be clever by assuming what progress item may appear where and
// when to skip testing every slot for every thing.

// always non-null, as this holds the topmost item.
// if there is none, there shouldn't be a header.
String pos45 = PlayerListMgr.strAt(45);

// Can be Montezuma, Enigma Souls or Timecharms.
// assume timecharms can only appear here and that they're the last thing to
// appear, so if this exists, we know the rest.
if (pos45.contains("Timecharms")) {
addTimecharmsComponent(45);
addEnigmaSoulsComponent(46);
addMontezumaComponent(47);
return;
}

// timecharms didn't appear at the top, so there's two or one entries.
// assume that if there's two, souls is always top.
String pos46 = PlayerListMgr.strAt(46);

if (pos45.contains("Enigma Souls")) {
addEnigmaSoulsComponent(45);
if (pos46 != null) {
// souls might appear alone.
// if there's a second entry, it has to be montezuma
addMontezumaComponent(46);
}
} else {
// first entry isn't souls, so it's just montezuma and nothing else.
addMontezumaComponent(45);
}

boolean hasTimecharms = false;
boolean hasEnigmaSouls = false;
int montezumaPos;

// Check each position to see what is or isn't there so we don't try adding
// invalid components
if (pos45.contains("Timecharms"))
hasTimecharms = true;
if (pos46.contains("Enigma Souls"))
hasEnigmaSouls = true;

// Small ternary to account for positions, defaults to -1 if it for some reason
// does not exist (which shouldn't be the case!)
montezumaPos = (pos47.contains("Montezuma")) ? 47 : (pos45.contains("Montezuma")) ? 45 : -1;

if (hasTimecharms) {
Matcher m = PlayerListMgr.regexAt(45, TIMECHARMS_PATTERN);
}

int current = Integer.parseInt(m.group("current"));
int total = Integer.parseInt(m.group("total"));
float pcnt = ((float) current / (float) total) * 100f;
Text progressText = Text.literal(current + "/" + total);
private static int pcntToCol(float pcnt) {
return MathHelper.hsvToRgb(pcnt / 300f, 0.9f, 0.9f);
}

ProgressComponent pc = new ProgressComponent(Ico.NETHER_STAR, Text.literal("Timecharms"), progressText,
pcnt, pcntToCol(pcnt));
private void addTimecharmsComponent(int pos) {
Matcher m = PlayerListMgr.regexAt(pos, TIMECHARMS_PATTERN);

this.addComponent(pc);
}
int current = Integer.parseInt(m.group("current"));
int total = Integer.parseInt(m.group("total"));
float pcnt = ((float) current / (float) total) * 100f;
Text progressText = Text.literal(current + "/" + total);

if (hasEnigmaSouls) {
Matcher m = PlayerListMgr.regexAt(46, ENIGMA_SOULS_PATTERN);
ProgressComponent pc = new ProgressComponent(Ico.NETHER_STAR, Text.literal("Timecharms"), progressText,
pcnt, pcntToCol(pcnt));

int current = Integer.parseInt(m.group("current"));
int total = Integer.parseInt(m.group("total"));
float pcnt = ((float) current / (float) total) * 100f;
Text progressText = Text.literal(current + "/" + total);
this.addComponent(pc);
}

ProgressComponent pc = new ProgressComponent(Ico.HEART_OF_THE_SEA, Text.literal("Enigma Souls"),
progressText, pcnt, pcntToCol(pcnt));
private void addEnigmaSoulsComponent(int pos) {
Matcher m = PlayerListMgr.regexAt(pos, ENIGMA_SOULS_PATTERN);

this.addComponent(pc);
}
int current = Integer.parseInt(m.group("current"));
int total = Integer.parseInt(m.group("total"));
float pcnt = ((float) current / (float) total) * 100f;
Text progressText = Text.literal(current + "/" + total);

if (montezumaPos != -1) {
Matcher m = PlayerListMgr.regexAt(montezumaPos, MONTEZUMA_PATTERN);
ProgressComponent pc = new ProgressComponent(Ico.HEART_OF_THE_SEA, Text.literal("Enigma Souls"),
progressText, pcnt, pcntToCol(pcnt));

int current = Integer.parseInt(m.group("current"));
int total = Integer.parseInt(m.group("total"));
float pcnt = ((float) current / (float) total) * 100f;
Text progressText = Text.literal(current + "/" + total);
this.addComponent(pc);
}

ProgressComponent pc = new ProgressComponent(Ico.BONE, Text.literal("Montezuma"), progressText, pcnt,
pcntToCol(pcnt));
private void addMontezumaComponent(int pos) {
Matcher m = PlayerListMgr.regexAt(pos, MONTEZUMA_PATTERN);

this.addComponent(pc);
}
int current = Integer.parseInt(m.group("current"));
int total = Integer.parseInt(m.group("total"));
float pcnt = ((float) current / (float) total) * 100f;
Text progressText = Text.literal(current + "/" + total);

}
ProgressComponent pc = new ProgressComponent(Ico.BONE, Text.literal("Montezuma"), progressText, pcnt,
pcntToCol(pcnt));

private static int pcntToCol(float pcnt) {
return MathHelper.hsvToRgb(pcnt / 300f, 0.9f, 0.9f);
}
this.addComponent(pc);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
*/
public class RiftServerInfoWidget extends Widget {

private static final MutableText TITLE = Text.literal("Server Info").formatted(Formatting.LIGHT_PURPLE, Formatting.BOLD);

public RiftServerInfoWidget() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ public RiftStatsWidget() {
public void updateContent() {
Text riftDamage = Widget.simpleEntryText(64, "RDG", Formatting.DARK_PURPLE);
IcoTextComponent rdg = new IcoTextComponent(Ico.DIASWORD, riftDamage);

Text speed = Widget.simpleEntryText(65, "SPD", Formatting.WHITE);
IcoTextComponent spd = new IcoTextComponent(Ico.SUGAR, speed);

Text intelligence = Widget.simpleEntryText(66, "INT", Formatting.AQUA);
IcoTextComponent intel = new IcoTextComponent(Ico.ENCHANTED_BOOK, intelligence);

Text manaRegen = Widget.simpleEntryText(67, "MRG", Formatting.AQUA);
IcoTextComponent mrg = new IcoTextComponent(Ico.DIAMOND, manaRegen);

TableComponent tc = new TableComponent(2, 2, Formatting.AQUA.getColorValue());
tc.addToCell(0, 0, rdg);
tc.addToCell(0, 1, spd);
tc.addToCell(1, 0, intel);
tc.addToCell(1, 1, mrg);

this.addComponent(tc);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.util.Formatting;

public class ShenWidget extends Widget {

private static final MutableText TITLE = Text.literal("Shen's Countdown").formatted(Formatting.DARK_AQUA, Formatting.BOLD);

public ShenWidget() {
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/assets/skyblocker/tabhud/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Grouped by themes (roughly)
- SkillsWidget: The player's skill levels and stats
- TrapperWidget: Trapper pelts on the farming island.
- UpgradeWidget: Currently running upgrades
- CameraPositionWidget: Shows orientation (pitch/yaw) of camera

#### Garden
- ComposterWidget: The composter in the garden.
Expand Down Expand Up @@ -96,12 +97,12 @@ Grouped by themes (roughly)

#### Rift
- AdvertisementWidget: Shows rift ads.
- GoodToKnowWidget:
- RiftProfileWidget:
- RiftProgressWidget:
- GoodToKnowWidget: Lifetime Motes earned and/or times you visited the rift.
- RiftProfileWidget: Info about your player profile while in the rift.
- RiftProgressWidget: Info about Montezuma, Timecharms and Enigma Souls.
- RiftServerInfoWidget: Server widget specialized for the rift.
- RiftStatsWidget: Server widget specialized for the rift.
- ShenWidget:
- ShenWidget: Shows Shen's countdown

#### Player lists
- PlayerListWidget: Generic list of players in the area.
Expand Down