Skip to content

Commit

Permalink
Release v3.12.3+fabric-1.21.X
Browse files Browse the repository at this point in the history
# From TCDCommons API
- Removed the "Refresh current screen" key-binding. It was meant for testing purposes only.
- Resolved conflict with "Screenshot viewer". See #16.

# From Better Statistics Screen
- Hovering over stat widgets in BSS will now play a small on-hover sound, to make the UI feel more "lively".
- Added a key-binding that allows you to toggle the stats HUD screen visibility. See #141.
  • Loading branch information
TheCSDev committed Nov 2, 2024
1 parent f16f86d commit 39ec0de
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 12 deletions.
6 changes: 3 additions & 3 deletions betterstats-3-fabric-1.21.3/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ org.gradle.jvmargs=-Xmx1G
mod_name = Better Statistics Screen
mod_description = Improves the statistics screen and makes it more useful.
mod_author = TheCSDev
mod_version = 3.13.2+fabric-1.21.3
mod_version = 3.13.3+fabric-1.21.3

# Here you link the source code repository links:
mod_contact_homepage = https://github.com/TheCSMods
Expand Down Expand Up @@ -60,5 +60,5 @@ org.gradle.jvmargs=-Xmx1G
# to list them as dependencies in `fabric.mod.json`.
fabric_version=0.106.1+1.21.3
modmenu_version=12.0.0-beta.1
architectury_version=14.0.3
rei_version=16.0.783
architectury_version=14.0.4
rei_version=17.0.789
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
public class BetterStatsConfig extends AutoConfig
{
// ==================================================
public static @NonSerialized boolean DEBUG_MODE = false;
// Temporary configurations bound to the current game session
public static @NonSerialized boolean DEBUG_MODE = false;
public static @NonSerialized boolean SHOW_HUD_SCREEN = true; //client-sided
// --------------------------------------------------
public @SerializedAs("common-forceFullVersion") boolean forceFullVersion = false; //v3.11+
public @SerializedAs("client-guiSmoothScroll") boolean guiSmoothScroll = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.thecsdev.betterstats.api.client.gui.stats.widget;

import static io.github.thecsdev.betterstats.client.BetterStatsClient.MC_CLIENT;

import java.util.Objects;

import io.github.thecsdev.betterstats.api.util.stats.SUStat;
Expand All @@ -8,6 +10,8 @@
import io.github.thecsdev.tcdcommons.api.client.gui.util.TInputContext;
import io.github.thecsdev.tcdcommons.api.client.gui.widget.TClickableWidget;
import io.github.thecsdev.tcdcommons.api.util.annotations.Virtual;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.sound.SoundEvents;

/**
* A GUI widget that displays stats information from a given {@link SUStat}.
Expand Down Expand Up @@ -72,8 +76,16 @@ public AbstractStatWidget(int x, int y, int width, int height, S stat) throws Nu
public @Virtual @Override void render(TDrawContext pencil) { pencil.drawTFill(this.backgroundColor); }
public @Virtual @Override void postRender(TDrawContext pencil)
{
//render the borders
if(isFocusedOrHovered()) pencil.drawTBorder(this.focusOutlineColor);
else pencil.drawTBorder(this.outlineColor);

//a neat little on-hover sound
if(isHovered() && !isFocused() && !this.__wasHovered)
MC_CLIENT.getSoundManager().play(PositionedSoundInstance.master(
SoundEvents.BLOCK_NOTE_BLOCK_HAT.value(), 1.8f, 0.05f));
this.__wasHovered = isHovered();
}
private boolean __wasHovered = false;
// ==================================================
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,43 @@
import io.github.thecsdev.betterstats.api.client.registry.BSClientPlayerBadges;
import io.github.thecsdev.betterstats.api.client.registry.BSStatsTabs;
import io.github.thecsdev.betterstats.api.util.BSUtils;
import io.github.thecsdev.betterstats.util.BST;
import io.github.thecsdev.tcdcommons.api.client.gui.util.GuiUtils;
import io.github.thecsdev.tcdcommons.api.events.client.MinecraftClientEvent;
import io.github.thecsdev.tcdcommons.api.events.client.gui.screen.GameMenuScreenEvent;
import io.github.thecsdev.tcdcommons.api.events.item.ItemGroupEvent;
import io.github.thecsdev.tcdcommons.api.hooks.client.gui.widget.ButtonWidgetHooks;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;

public final class BetterStatsClient extends BetterStats
{
// ==================================================
public static final MinecraftClient MC_CLIENT = MinecraftClient.getInstance();
// --------------------------------------------------
public static final KeyBinding KEYBIND_TOGGLE_HUD;
// ==================================================
static
{
//register key-bindings
KEYBIND_TOGGLE_HUD = KeyBindingHelper.registerKeyBinding(new KeyBinding(
BST.keybind_toggleHud(),
InputUtil.UNKNOWN_KEY.getCode(),
getModID()));
}
// --------------------------------------------------
public BetterStatsClient()
{
//initialize and register stuff
BSStatsTabs.register();
BSClientPlayerBadges.register();

// ---------- modding the "Statistics" button
//an event handler that will handle the game menu screen (the "pause" screen)
GameMenuScreenEvent.INIT_WIDGETS_POST.register(gmScreen ->
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.github.thecsdev.betterstats.client.gui.screen.hud;

import static io.github.thecsdev.betterstats.BetterStats.getModID;
import static io.github.thecsdev.betterstats.BetterStatsConfig.SHOW_HUD_SCREEN;
import static io.github.thecsdev.betterstats.api.client.gui.panel.BSComponentPanel.BS_WIDGETS_TEXTURE;
import static io.github.thecsdev.betterstats.client.BetterStatsClient.KEYBIND_TOGGLE_HUD;
import static io.github.thecsdev.betterstats.client.BetterStatsClient.MC_CLIENT;
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.literal;
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.translatable;
Expand All @@ -21,8 +23,10 @@
import io.github.thecsdev.tcdcommons.api.client.util.interfaces.IParentScreenProvider;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket;
import net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket.Mode;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

Expand Down Expand Up @@ -65,6 +69,9 @@ public final class BetterStatsHudScreen extends TWidgetHudScreen implements IPar
//if the hud screen is opened, add some extra widgets to it
if(isOpen())
{
//reset the "show hud screen" flag here
SHOW_HUD_SCREEN = true;

//obtain the better-stats's client play network handler
final var bssCpnh = BetterStatsClientPlayNetworkHandler.of(MC_CLIENT.player);

Expand Down Expand Up @@ -108,6 +115,18 @@ public final class BetterStatsHudScreen extends TWidgetHudScreen implements IPar
// --------------------------------------------------
public final @Override void render(TDrawContext pencil)
{
// ---------- handle key-bindings
if(KEYBIND_TOGGLE_HUD.wasPressed() && !isOpen())
{
SHOW_HUD_SCREEN = !SHOW_HUD_SCREEN;
MC_CLIENT.getSoundManager().play(PositionedSoundInstance.master(
SoundEvents.BLOCK_NOTE_BLOCK_HAT,
SHOW_HUD_SCREEN ? 2 : 1.8f));
}

// ---------- handle rendering
if(!SHOW_HUD_SCREEN && !isOpen()) return;

//render super
super.render(pencil); //super must be called here

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public CreditsTabPersonWidget(int x, int y, int width, TcdWebApiPerson person, b
this.fetchGitHubInfo = fetchGitHubInfo;
}
// ==================================================
@SuppressWarnings("deprecation")
protected final @Override void init()
{
final var icon = new TTextureElement(2, 2, 16, 16);
Expand Down Expand Up @@ -121,7 +120,6 @@ public CreditsTabPersonWidget(int x, int y, int width, TcdWebApiPerson person, b
* Constructs a "display name" {@link Text} from a {@link RepositoryUserInfo}.
* @param userInfo The {@link RepositoryUserInfo}.
*/
@SuppressWarnings("deprecation")
public static final Text getDisplayNameFromGHUser(RepositoryUserInfo userInfo) throws NullPointerException
{
final @Nullable var name = userInfo.getAccountName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ private BST() {}
public static final MutableText stp_mc_killed() { return translatable("betterstats.stattype_phrase.minecraft.killed"); }
public static final MutableText stp_mc_killedBy() { return translatable("betterstats.stattype_phrase.minecraft.killed_by"); }
// --------------------------------------------------
public static final String keybind_toggleHud() { return "betterstats.key_binding.toggle_hud_screen"; }
// --------------------------------------------------
public static final MutableText menu_file() { return translatable("betterstats.gui.menu_bar.menu_file"); }
public static final MutableText menu_file_new() { return translatable("betterstats.gui.menu_bar.menu_file.new"); }
public static final MutableText menu_file_open() { return translatable("betterstats.gui.menu_bar.menu_file.open"); }
Expand Down Expand Up @@ -131,7 +133,7 @@ private BST() {}
public static final MutableText gui_qsscreen_upload_stage4(Text qsCode) { return translatable("betterstats.gui.qs_screen.upload.stage_4", qsCode); }
//
public static final MutableText gui_qsscreen_download_title() { return translatable("betterstats.gui.qs_screen.download.title"); }
public static final MutableText gui_qsscreen_download_stageN1() { return translatable("betterstats.gui.qs_screen.download.stage_n1"); }
public static final MutableText gui_qsscreen_download_stageN1() { return translatable("betterstats.gui.qs_screen.download.stage_n1"); }
public static final MutableText gui_qsscreen_download_stage0() { return translatable("betterstats.gui.qs_screen.download.stage_0"); }
public static final MutableText gui_qsscreen_download_stage1() { return translatable("betterstats.gui.qs_screen.download.stage_1"); }
public static final MutableText gui_qsscreen_download_stage2() { return translatable("betterstats.gui.qs_screen.download.stage_2"); }
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"betterstats.stattype_phrase.morestats.totem_popped_by": "Totems popped by",


"betterstats.key_binding.toggle_hud_screen": "Toggle statistics HUD",


"betterstats.gui.menu_bar.menu_file": "File",
"betterstats.gui.menu_bar.menu_file.new": "New",
"betterstats.gui.menu_bar.menu_file.open": "Open",
Expand Down
4 changes: 2 additions & 2 deletions betterstats-3-fabric-1.21/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ org.gradle.jvmargs=-Xmx1G
mod_name = Better Statistics Screen
mod_description = Improves the statistics screen and makes it more useful.
mod_author = TheCSDev
mod_version = 3.13.2+fabric-1.21
mod_version = 3.13.3+fabric-1.21

# Here you link the source code repository links:
mod_contact_homepage = https://github.com/TheCSMods
Expand All @@ -48,7 +48,7 @@ org.gradle.jvmargs=-Xmx1G
mod_icon = assets/betterstats/icon.png

# This is the name of the Minecraft version your mod depends on:
mod_depends_minecraft = >=1.21
mod_depends_minecraft = >=1.21 <1.21.2

# This is the resource pack format number of your mod's resource pack:
# ( More info at https://minecraft.wiki/w/Pack_format )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
public class BetterStatsConfig extends AutoConfig
{
// ==================================================
public static @NonSerialized boolean DEBUG_MODE = false;
// Temporary configurations bound to the current game session
public static @NonSerialized boolean DEBUG_MODE = false;
public static @NonSerialized boolean SHOW_HUD_SCREEN = true; //client-sided
// --------------------------------------------------
public @SerializedAs("common-forceFullVersion") boolean forceFullVersion = false; //v3.11+
public @SerializedAs("client-guiSmoothScroll") boolean guiSmoothScroll = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.thecsdev.betterstats.api.client.gui.stats.widget;

import static io.github.thecsdev.betterstats.client.BetterStatsClient.MC_CLIENT;

import java.util.Objects;

import io.github.thecsdev.betterstats.api.util.stats.SUStat;
Expand All @@ -8,6 +10,8 @@
import io.github.thecsdev.tcdcommons.api.client.gui.util.TInputContext;
import io.github.thecsdev.tcdcommons.api.client.gui.widget.TClickableWidget;
import io.github.thecsdev.tcdcommons.api.util.annotations.Virtual;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.sound.SoundEvents;

/**
* A GUI widget that displays stats information from a given {@link SUStat}.
Expand Down Expand Up @@ -72,8 +76,16 @@ public AbstractStatWidget(int x, int y, int width, int height, S stat) throws Nu
public @Virtual @Override void render(TDrawContext pencil) { pencil.drawTFill(this.backgroundColor); }
public @Virtual @Override void postRender(TDrawContext pencil)
{
//render the borders
if(isFocusedOrHovered()) pencil.drawTBorder(this.focusOutlineColor);
else pencil.drawTBorder(this.outlineColor);

//a neat little on-hover sound
if(isHovered() && !isFocused() && !this.__wasHovered)
MC_CLIENT.getSoundManager().play(PositionedSoundInstance.master(
SoundEvents.BLOCK_NOTE_BLOCK_HAT.value(), 1.8f, 0.05f));
this.__wasHovered = isHovered();
}
private boolean __wasHovered = false;
// ==================================================
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,43 @@
import io.github.thecsdev.betterstats.api.client.registry.BSClientPlayerBadges;
import io.github.thecsdev.betterstats.api.client.registry.BSStatsTabs;
import io.github.thecsdev.betterstats.api.util.BSUtils;
import io.github.thecsdev.betterstats.util.BST;
import io.github.thecsdev.tcdcommons.api.client.gui.util.GuiUtils;
import io.github.thecsdev.tcdcommons.api.events.client.MinecraftClientEvent;
import io.github.thecsdev.tcdcommons.api.events.client.gui.screen.GameMenuScreenEvent;
import io.github.thecsdev.tcdcommons.api.events.item.ItemGroupEvent;
import io.github.thecsdev.tcdcommons.api.hooks.client.gui.widget.ButtonWidgetHooks;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;

public final class BetterStatsClient extends BetterStats
{
// ==================================================
public static final MinecraftClient MC_CLIENT = MinecraftClient.getInstance();
// --------------------------------------------------
public static final KeyBinding KEYBIND_TOGGLE_HUD;
// ==================================================
static
{
//register key-bindings
KEYBIND_TOGGLE_HUD = KeyBindingHelper.registerKeyBinding(new KeyBinding(
BST.keybind_toggleHud(),
InputUtil.UNKNOWN_KEY.getCode(),
getModID()));
}
// --------------------------------------------------
public BetterStatsClient()
{
//initialize and register stuff
BSStatsTabs.register();
BSClientPlayerBadges.register();

// ---------- modding the "Statistics" button
//an event handler that will handle the game menu screen (the "pause" screen)
GameMenuScreenEvent.INIT_WIDGETS_POST.register(gmScreen ->
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.github.thecsdev.betterstats.client.gui.screen.hud;

import static io.github.thecsdev.betterstats.BetterStats.getModID;
import static io.github.thecsdev.betterstats.BetterStatsConfig.SHOW_HUD_SCREEN;
import static io.github.thecsdev.betterstats.api.client.gui.panel.BSComponentPanel.BS_WIDGETS_TEXTURE;
import static io.github.thecsdev.betterstats.client.BetterStatsClient.KEYBIND_TOGGLE_HUD;
import static io.github.thecsdev.betterstats.client.BetterStatsClient.MC_CLIENT;
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.literal;
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.translatable;
Expand All @@ -21,8 +23,10 @@
import io.github.thecsdev.tcdcommons.api.client.util.interfaces.IParentScreenProvider;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket;
import net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket.Mode;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

Expand Down Expand Up @@ -65,6 +69,9 @@ public final class BetterStatsHudScreen extends TWidgetHudScreen implements IPar
//if the hud screen is opened, add some extra widgets to it
if(isOpen())
{
//reset the "show hud screen" flag here
SHOW_HUD_SCREEN = true;

//obtain the better-stats's client play network handler
final var bssCpnh = BetterStatsClientPlayNetworkHandler.of(MC_CLIENT.player);

Expand Down Expand Up @@ -108,6 +115,18 @@ public final class BetterStatsHudScreen extends TWidgetHudScreen implements IPar
// --------------------------------------------------
public final @Override void render(TDrawContext pencil)
{
// ---------- handle key-bindings
if(KEYBIND_TOGGLE_HUD.wasPressed() && !isOpen())
{
SHOW_HUD_SCREEN = !SHOW_HUD_SCREEN;
MC_CLIENT.getSoundManager().play(PositionedSoundInstance.master(
SoundEvents.BLOCK_NOTE_BLOCK_HAT,
SHOW_HUD_SCREEN ? 2 : 1.8f));
}

// ---------- handle rendering
if(!SHOW_HUD_SCREEN && !isOpen()) return;

//render super
super.render(pencil); //super must be called here

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public CreditsTabPersonWidget(int x, int y, int width, TcdWebApiPerson person, b
this.fetchGitHubInfo = fetchGitHubInfo;
}
// ==================================================
@SuppressWarnings("deprecation")
protected final @Override void init()
{
final var icon = new TTextureElement(2, 2, 16, 16);
Expand Down Expand Up @@ -121,7 +120,6 @@ public CreditsTabPersonWidget(int x, int y, int width, TcdWebApiPerson person, b
* Constructs a "display name" {@link Text} from a {@link RepositoryUserInfo}.
* @param userInfo The {@link RepositoryUserInfo}.
*/
@SuppressWarnings("deprecation")
public static final Text getDisplayNameFromGHUser(RepositoryUserInfo userInfo) throws NullPointerException
{
final @Nullable var name = userInfo.getAccountName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ private BST() {}
public static final MutableText stp_mc_killed() { return translatable("betterstats.stattype_phrase.minecraft.killed"); }
public static final MutableText stp_mc_killedBy() { return translatable("betterstats.stattype_phrase.minecraft.killed_by"); }
// --------------------------------------------------
public static final String keybind_toggleHud() { return "betterstats.key_binding.toggle_hud_screen"; }
// --------------------------------------------------
public static final MutableText menu_file() { return translatable("betterstats.gui.menu_bar.menu_file"); }
public static final MutableText menu_file_new() { return translatable("betterstats.gui.menu_bar.menu_file.new"); }
public static final MutableText menu_file_open() { return translatable("betterstats.gui.menu_bar.menu_file.open"); }
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"betterstats.stattype_phrase.morestats.totem_popped_by": "Totems popped by",


"betterstats.key_binding.toggle_hud_screen": "Toggle statistics HUD",


"betterstats.gui.menu_bar.menu_file": "File",
"betterstats.gui.menu_bar.menu_file.new": "New",
"betterstats.gui.menu_bar.menu_file.open": "Open",
Expand Down

0 comments on commit 39ec0de

Please sign in to comment.