Skip to content

Commit

Permalink
view stats
Browse files Browse the repository at this point in the history
  • Loading branch information
faluhub committed May 6, 2024
1 parent 9cbfa3f commit c81da5f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ yarn_mappings=1.16.1+build.21
loader_version=0.15.7

# Mod Properties
mod_version=2.2-pre2
mod_version=2.2-pre3
maven_group=me.falu
archives_base_name=peepopractice

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import me.falu.peepopractice.core.writer.PracticeWriter;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
Expand Down Expand Up @@ -189,19 +192,34 @@ public String getName(boolean showPb) {
return text.toString();
}

public String getPbText() {
public Text getPbText() {
if (this.hasSplitEvent()) {
PreferenceTypes.CompareType compareType = CategoryPreferences.COMPARE_TYPE.getValue();
boolean comparePb = compareType.equals(PreferenceTypes.CompareType.PB);
boolean hasTime = comparePb ? this.getSplitEvent().hasPb() : this.getSplitEvent().hasCompletedTimes();
if (hasTime) {
String timeString = comparePb ? this.getSplitEvent().getPbString() : this.getSplitEvent().getAverageString();
return (comparePb ? Formatting.GREEN : Formatting.AQUA) + " (" + timeString + ")";
return new LiteralText("(" + timeString + ")").formatted(comparePb ? Formatting.GREEN : Formatting.AQUA);
} else {
return Formatting.GRAY + " " + new TranslatableText("peepopractice.text.no_pb_or_avg", CategoryPreferences.COMPARE_TYPE.getValueLabel(this)).getString();
return new TranslatableText("peepopractice.text.no_pb_or_avg", CategoryPreferences.COMPARE_TYPE.getValueLabel(this)).formatted(Formatting.GRAY);
}
}
return "";
return new LiteralText("");
}

public Text getStatsText() {
if (this.hasSplitEvent()) {
SplitEvent event = this.getSplitEvent();
MutableText text = new LiteralText("(").formatted(Formatting.GRAY);
text.append(new LiteralText("" + event.getAttempts()).formatted(Formatting.WHITE));
text.append(new LiteralText("/").formatted(Formatting.GRAY));
text.append(new LiteralText("" + event.getCompletionCount()).formatted(Formatting.GREEN));
text.append(new LiteralText("/").formatted(Formatting.GRAY));
text.append(new LiteralText("" + event.getFailCount()).formatted(Formatting.RED));
text.append(new LiteralText(")").formatted(Formatting.GRAY));
return text;
}
return new LiteralText("");
}

public boolean isAA() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public class CategoryPreferences {
public static final CategoryPreference<PreferenceTypes.SelectedInventoryType> SELECTED_INVENTORY = new CategoryPreference<PreferenceTypes.SelectedInventoryType>()
.setId("selected_inventory")
.setDefaultValue(PreferenceTypes.SelectedInventoryType.ONE);
public static final CategoryPreference<PreferenceTypes.BooleanType> RANDOM_INVENTORY = new CategoryPreference<PreferenceTypes.BooleanType>()
.setId("random_inventory")
.setDefaultValue(PreferenceTypes.BooleanType.DISABLED);
public static final CategoryPreference<PreferenceTypes.BooleanType> SCRAMBLE_INVENTORY = new CategoryPreference<PreferenceTypes.BooleanType>()
.setId("scramble_inventory")
.setDefaultValue(PreferenceTypes.BooleanType.DISABLED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,38 @@ protected void init() {
b -> this.onClose()
)
);
this.addButton(
ButtonWidget scrambleButton = this.addButton(
new LimitlessButtonWidget(
null,
EGG_TEXTURE,
null,
(this.width - rowWidth) / 2 + rowWidth + paddingX,
this.height - containerHeight,
otherButtonWidth,
rowButtonSize * 3 + paddingY * 2,
(rowButtonSize * 3 + paddingY * 2) / 2,
CategoryPreferencesScreen.getFormattedText(this.category, CategoryPreferences.SCRAMBLE_INVENTORY),
b -> {
CategoryPreferences.SCRAMBLE_INVENTORY.advanceValue(this.category);
b.setMessage(CategoryPreferencesScreen.getFormattedText(this.category, CategoryPreferences.SCRAMBLE_INVENTORY));
}
)
);
this.addButton(
new LimitlessButtonWidget(
null,
EGG_TEXTURE,
null,
scrambleButton.x,
scrambleButton.y + scrambleButton.getHeight(),
scrambleButton.getWidth(),
scrambleButton.getHeight(),
CategoryPreferencesScreen.getFormattedText(this.category, CategoryPreferences.RANDOM_INVENTORY),
b -> {
CategoryPreferences.RANDOM_INVENTORY.advanceValue(this.category);
b.setMessage(CategoryPreferencesScreen.getFormattedText(this.category, CategoryPreferences.RANDOM_INVENTORY));
}
)
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float del
this.y + this.height - this.height / 4 - client.textRenderer.fontHeight - 2 + 4,
0xFFFFFF
);
this.drawCenteredString(
this.drawCenteredText(
matrices,
client.textRenderer,
this.category.getPbText(),
this.isHovered() ? this.category.getStatsText() : this.category.getPbText(),
this.x + this.width / 2,
this.y + this.height - this.height / 4 + 4,
0xFFFFFF
Expand Down

0 comments on commit c81da5f

Please sign in to comment.