Skip to content

Commit

Permalink
Release v2.9.1
Browse files Browse the repository at this point in the history
Needs some testing, just to 100% make sure it works. Was tested in development environment however. And of-course, took care of #55 (Resolved #55).
  • Loading branch information
TheCSDev committed Jun 14, 2023
1 parent f8da976 commit 9154307
Show file tree
Hide file tree
Showing 24 changed files with 215 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class BetterStats extends Object
public final ModContainer modInfo;
public final String contact_sources;
public final String contact_playerBadgeWebhook;
// --------------------------------------------------
protected final BetterStatsConfig config;
// ==================================================
/**
* Initializes this mod. This action may only be performed by the fabric-loader.
Expand All @@ -40,12 +42,17 @@ else if(!isInstanceValid(this))
//log stuff
LOGGER.info("Initializing '" + getModName() + "' as '" + getClass().getSimpleName() + "'.");

//try to load config (IOException-s should be harmless)
this.config = new BetterStatsConfig(getModID());
this.config.tryLoadFromFile(true);

//init stuff
BetterStatsNetworkHandler.init();
}
// --------------------------------------------------
/** Returns the Fabric {@link ModContainer} containing information about this mod. */
public ModContainer getModInfo() { return modInfo; }
public BetterStatsConfig getConfig() { return this.config; }
// ==================================================
/** Returns the instance of this mod. */
public static BetterStats getInstance() { return Instance; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.thecsdev.betterstats;

import io.github.thecsdev.tcdcommons.api.config.AutoConfig;
import io.github.thecsdev.tcdcommons.api.config.annotation.SerializedAs;

public class BetterStatsConfig extends AutoConfig
{
// ==================================================
@SerializedAs("guiMobsFollowCursor") //mitigate side-effects of field renaming
public boolean guiMobsFollowCursor;
// ==================================================
public BetterStatsConfig(String name)
{
super(name);
this.guiMobsFollowCursor = true;
}
// ==================================================
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import com.google.common.collect.Lists;

import io.github.thecsdev.betterstats.BetterStats;
import io.github.thecsdev.betterstats.api.registry.BetterStatsRegistry;
import io.github.thecsdev.betterstats.client.gui.panel.BSPanel;
import io.github.thecsdev.betterstats.client.gui.screen.BetterStatsScreen;
Expand Down Expand Up @@ -47,9 +48,19 @@ public static enum BSStatPanelMobs_SortBy
BSStatPanelMobs_SortBy(MutableText text) { this.text = text; }
public MutableText asText() { return text; }
}
// --------------------------------------------------
protected final boolean guiMobsFollowCursor;
// ==================================================
public BSStatPanel_Mobs(int x, int y, int width, int height) { super(x, y, width, height); }
public BSStatPanel_Mobs(TPanelElement parentToFill) { super(parentToFill); }
public BSStatPanel_Mobs(int x, int y, int width, int height)
{
super(x, y, width, height);
this.guiMobsFollowCursor = BetterStats.getInstance().getConfig().guiMobsFollowCursor;
}
public BSStatPanel_Mobs(TPanelElement parentToFill)
{
super(parentToFill);
this.guiMobsFollowCursor = BetterStats.getInstance().getConfig().guiMobsFollowCursor;
}
// ==================================================
@Override
public Predicate<StatUtilsStat> getStatPredicate()
Expand Down Expand Up @@ -232,12 +243,14 @@ protected class BSStatWidget_Mob extends BSStatWidget
{
// ----------------------------------------------
public final StatUtilsMobStat stat;
public final TEntityRendererElement entityRenderer;
// ----------------------------------------------
public BSStatWidget_Mob(StatUtilsMobStat stat, int x, int y, int size)
{
super(x, y, size, size);
this.stat = Objects.requireNonNull(stat, "stat must not be null.");
addTChild(new TEntityRendererElement(x, y, size, size, stat.entityType), false);
addTChild(this.entityRenderer = new TEntityRendererElement(x, y, size, size, stat.entityType), false);
this.entityRenderer.setFollowCursor(BSStatPanel_Mobs.this.guiMobsFollowCursor);

updateTooltip();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.fLiteral;
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.translatable;

import java.util.Objects;

import io.github.thecsdev.betterstats.BetterStats;
import io.github.thecsdev.betterstats.BetterStatsConfig;
import io.github.thecsdev.betterstats.client.gui.panel.BSPanel;
import io.github.thecsdev.betterstats.client.gui.widget.BSScrollBarWidget;
import io.github.thecsdev.tcdcommons.api.client.gui.other.TFillColorElement;
Expand All @@ -15,10 +18,11 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;

public class BetterStatsConfigScreen extends TScreen
public final class BetterStatsConfigScreen extends TScreen
{
// ==================================================
public final Screen parent;
public final BetterStatsConfig config;
// --------------------------------------------------
protected TFillColorElement panel_contentPane;
protected BSCSPanel panel_title;
Expand All @@ -30,6 +34,7 @@ public BetterStatsConfigScreen(Screen parent)
super(translatable(BetterStats.getModID())
.append(" - ").append(translatable("options.title")));
this.parent = parent;
this.config = Objects.requireNonNull(BetterStats.getInstance().getConfig());
}
public @Override boolean shouldRenderInGameHud() { return false; }
protected @Override void onClosed() { getClient().setScreen(this.parent); }
Expand Down Expand Up @@ -86,9 +91,13 @@ public BetterStatsConfigScreen(Screen parent)
translatable("betterstats.gui.config.debug_mode"),
DEBUG_MODE,
newVal -> DEBUG_MODE = newVal);
config_builder.addBoolean(translatable("betterstats.gui.config.gui_mob_follow_cursor"),
this.config.guiMobsFollowCursor,
newVal -> this.config.guiMobsFollowCursor = newVal);
config_builder.addButton(TConfigGuiBuilder.TXT_SAVE, btn ->
{
config_builder.applyAllConfigChanges();
this.config.trySaveToFile(true);
this.close();
});
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@
"betterstats.gui.network.badges.bss_translator.name": "Better Stats translator",
"betterstats.gui.network.badges.bss_translator.description": "You helped translate the 'Better Stats' mod to other languages.",

"betterstats.gui.config.debug_mode": "Debug mode"
"betterstats.gui.config.debug_mode": "Debug mode",
"betterstats.gui.config.gui_mob_follow_cursor": "GUI mobs follow cursor"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class BetterStats extends Object
public final ModContainer modInfo;
public final String contact_sources;
public final String contact_playerBadgeWebhook;
// --------------------------------------------------
protected final BetterStatsConfig config;
// ==================================================
/**
* Initializes this mod. This action may only be performed by the fabric-loader.
Expand All @@ -39,13 +41,18 @@ else if(!isInstanceValid(this))

//log stuff
LOGGER.info("Initializing '" + getModName() + "' as '" + getClass().getSimpleName() + "'.");

//try to load config (IOException-s should be harmless)
this.config = new BetterStatsConfig(getModID());
this.config.tryLoadFromFile(true);

//init stuff
BetterStatsNetworkHandler.init();
}
// --------------------------------------------------
/** Returns the Fabric {@link ModContainer} containing information about this mod. */
public ModContainer getModInfo() { return modInfo; }
public BetterStatsConfig getConfig() { return this.config; }
// ==================================================
/** Returns the instance of this mod. */
public static BetterStats getInstance() { return Instance; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.thecsdev.betterstats;

import io.github.thecsdev.tcdcommons.api.config.AutoConfig;
import io.github.thecsdev.tcdcommons.api.config.annotation.SerializedAs;

public class BetterStatsConfig extends AutoConfig
{
// ==================================================
@SerializedAs("guiMobsFollowCursor") //mitigate side-effects of field renaming
public boolean guiMobsFollowCursor;
// ==================================================
public BetterStatsConfig(String name)
{
super(name);
this.guiMobsFollowCursor = true;
}
// ==================================================
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import com.google.common.collect.Lists;

import io.github.thecsdev.betterstats.BetterStats;
import io.github.thecsdev.betterstats.api.registry.BetterStatsRegistry;
import io.github.thecsdev.betterstats.client.gui.panel.BSPanel;
import io.github.thecsdev.betterstats.client.gui.screen.BetterStatsScreen;
Expand Down Expand Up @@ -47,9 +48,19 @@ public static enum BSStatPanelMobs_SortBy
BSStatPanelMobs_SortBy(MutableText text) { this.text = text; }
public MutableText asText() { return text; }
}
// --------------------------------------------------
protected final boolean guiMobsFollowCursor;
// ==================================================
public BSStatPanel_Mobs(int x, int y, int width, int height) { super(x, y, width, height); }
public BSStatPanel_Mobs(TPanelElement parentToFill) { super(parentToFill); }
public BSStatPanel_Mobs(int x, int y, int width, int height)
{
super(x, y, width, height);
this.guiMobsFollowCursor = BetterStats.getInstance().getConfig().guiMobsFollowCursor;
}
public BSStatPanel_Mobs(TPanelElement parentToFill)
{
super(parentToFill);
this.guiMobsFollowCursor = BetterStats.getInstance().getConfig().guiMobsFollowCursor;
}
// ==================================================
@Override
public Predicate<StatUtilsStat> getStatPredicate()
Expand Down Expand Up @@ -232,12 +243,14 @@ protected class BSStatWidget_Mob extends BSStatWidget
{
// ----------------------------------------------
public final StatUtilsMobStat stat;
public final TEntityRendererElement entityRenderer;
// ----------------------------------------------
public BSStatWidget_Mob(StatUtilsMobStat stat, int x, int y, int size)
{
super(x, y, size, size);
this.stat = Objects.requireNonNull(stat, "stat must not be null.");
addTChild(new TEntityRendererElement(x, y, size, size, stat.entityType), false);
addTChild(this.entityRenderer = new TEntityRendererElement(x, y, size, size, stat.entityType), false);
this.entityRenderer.setFollowCursor(BSStatPanel_Mobs.this.guiMobsFollowCursor);

updateTooltip();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.fLiteral;
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.translatable;

import java.util.Objects;

import io.github.thecsdev.betterstats.BetterStats;
import io.github.thecsdev.betterstats.BetterStatsConfig;
import io.github.thecsdev.betterstats.client.gui.panel.BSPanel;
import io.github.thecsdev.betterstats.client.gui.widget.BSScrollBarWidget;
import io.github.thecsdev.tcdcommons.api.client.gui.other.TFillColorElement;
Expand All @@ -15,10 +18,11 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;

public class BetterStatsConfigScreen extends TScreen
public final class BetterStatsConfigScreen extends TScreen
{
// ==================================================
public final Screen parent;
public final BetterStatsConfig config;
// --------------------------------------------------
protected TFillColorElement panel_contentPane;
protected BSCSPanel panel_title;
Expand All @@ -30,9 +34,11 @@ public BetterStatsConfigScreen(Screen parent)
super(translatable(BetterStats.getModID())
.append(" - ").append(translatable("options.title")));
this.parent = parent;
this.config = Objects.requireNonNull(BetterStats.getInstance().getConfig());
}
public @Override boolean shouldRenderInGameHud() { return false; }
protected @Override void onClosed() { getClient().setScreen(this.parent); }
// --------------------------------------------------
public @Override void renderBackground(MatrixStack matrices)
{
if(this.parent != null)
Expand Down Expand Up @@ -85,9 +91,13 @@ public BetterStatsConfigScreen(Screen parent)
translatable("betterstats.gui.config.debug_mode"),
DEBUG_MODE,
newVal -> DEBUG_MODE = newVal);
config_builder.addBoolean(translatable("betterstats.gui.config.gui_mob_follow_cursor"),
this.config.guiMobsFollowCursor,
newVal -> this.config.guiMobsFollowCursor = newVal);
config_builder.addButton(TConfigGuiBuilder.TXT_SAVE, btn ->
{
config_builder.applyAllConfigChanges();
this.config.trySaveToFile(true);
this.close();
});
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@
"betterstats.gui.network.badges.bss_translator.name": "Better Stats translator",
"betterstats.gui.network.badges.bss_translator.description": "You helped translate the 'Better Stats' mod to other languages.",

"betterstats.gui.config.debug_mode": "Debug mode"
"betterstats.gui.config.debug_mode": "Debug mode",
"betterstats.gui.config.gui_mob_follow_cursor": "GUI mobs follow cursor"
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class BetterStats extends Object
public final ModContainer modInfo;
public final String contact_sources;
public final String contact_playerBadgeWebhook;
// --------------------------------------------------
protected final BetterStatsConfig config;
// ==================================================
/**
* Initializes this mod. This action may only be performed by the fabric-loader.
Expand All @@ -43,13 +45,18 @@ else if(!isInstanceValid(this))

//log stuff
LOGGER.info("Initializing '" + getModName() + "' as '" + getClass().getSimpleName() + "'.");

//try to load config (IOException-s should be harmless)
this.config = new BetterStatsConfig(getModID());
this.config.tryLoadFromFile(true);

//init stuff
BetterStatsNetworkHandler.init();
}
// --------------------------------------------------
/** Returns the Fabric {@link ModContainer} containing information about this mod. */
public ModContainer getModInfo() { return modInfo; }
public BetterStatsConfig getConfig() { return this.config; }
// ==================================================
/** Returns the instance of this mod. */
public static BetterStats getInstance() { return Instance; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.thecsdev.betterstats;

import io.github.thecsdev.tcdcommons.api.config.AutoConfig;
import io.github.thecsdev.tcdcommons.api.config.annotation.SerializedAs;

public class BetterStatsConfig extends AutoConfig
{
// ==================================================
@SerializedAs("guiMobsFollowCursor") //mitigate side-effects of field renaming
public boolean guiMobsFollowCursor;
// ==================================================
public BetterStatsConfig(String name)
{
super(name);
this.guiMobsFollowCursor = true;
}
// ==================================================
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import com.google.common.collect.Lists;

import io.github.thecsdev.betterstats.BetterStats;
import io.github.thecsdev.betterstats.api.registry.BetterStatsRegistry;
import io.github.thecsdev.betterstats.client.gui.panel.BSPanel;
import io.github.thecsdev.betterstats.client.gui.screen.BetterStatsScreen;
Expand Down Expand Up @@ -47,9 +48,19 @@ public static enum BSStatPanelMobs_SortBy
BSStatPanelMobs_SortBy(MutableText text) { this.text = text; }
public MutableText asText() { return text; }
}
// --------------------------------------------------
protected final boolean guiMobsFollowCursor;
// ==================================================
public BSStatPanel_Mobs(int x, int y, int width, int height) { super(x, y, width, height); }
public BSStatPanel_Mobs(TPanelElement parentToFill) { super(parentToFill); }
public BSStatPanel_Mobs(int x, int y, int width, int height)
{
super(x, y, width, height);
this.guiMobsFollowCursor = BetterStats.getInstance().getConfig().guiMobsFollowCursor;
}
public BSStatPanel_Mobs(TPanelElement parentToFill)
{
super(parentToFill);
this.guiMobsFollowCursor = BetterStats.getInstance().getConfig().guiMobsFollowCursor;
}
// ==================================================
@Override
public Predicate<StatUtilsStat> getStatPredicate()
Expand Down Expand Up @@ -232,12 +243,14 @@ protected class BSStatWidget_Mob extends BSStatWidget
{
// ----------------------------------------------
public final StatUtilsMobStat stat;
public final TEntityRendererElement entityRenderer;
// ----------------------------------------------
public BSStatWidget_Mob(StatUtilsMobStat stat, int x, int y, int size)
{
super(x, y, size, size);
this.stat = Objects.requireNonNull(stat, "stat must not be null.");
addTChild(new TEntityRendererElement(x, y, size, size, stat.entityType), false);
addTChild(this.entityRenderer = new TEntityRendererElement(x, y, size, size, stat.entityType), false);
this.entityRenderer.setFollowCursor(BSStatPanel_Mobs.this.guiMobsFollowCursor);

updateTooltip();
}
Expand Down
Loading

0 comments on commit 9154307

Please sign in to comment.