Skip to content

Commit

Permalink
update localizations
Browse files Browse the repository at this point in the history
  • Loading branch information
KrLite committed Feb 24, 2024
1 parent b63ab97 commit 86bf1af
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 50 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
maven-group = "band.kessokuteatime"
archives-name = "splasher"
mod = "6.0.1"
mod = "6.0.2"

minecraft = "1.20"
yarn = "1.20+build.1"
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/band/kessokuteatime/splasher/Splasher.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void push() {
}

public static boolean shouldSplash() {
return CONFIG.randomRate == SplasherConfig.RandomRate.JEB || shouldSplash.getAndSet(false);
return CONFIG.texts.randomRate == SplasherConfig.RandomRate.JEB || shouldSplash.getAndSet(false);
}

// Splash text data
Expand All @@ -90,7 +90,7 @@ public void onInitializeClient() {
if (isBouncedLoaded)
mouseY -= Bounced.primaryPos();

if (isMouseHovering(scaledWidth, mouseX, mouseY) && CONFIG.randomRate.onClick()) {
if (isMouseHovering(scaledWidth, mouseX, mouseY) && CONFIG.texts.randomRate.onClick()) {
push();
playClickingSound();
}
Expand All @@ -106,14 +106,14 @@ public static void playClickingSound() {

public static boolean isMouseHovering(double width, double mouseX, double mouseY) {
// Public so other mods can use
return isMouseHovering(new Node(width / 2.0 + (CONFIG.lefty ? -123 : 123), 69 - 6), new Node(mouseX, mouseY));
return isMouseHovering(new Node(width / 2.0 + (CONFIG.texts.lefty ? -123 : 123), 69 - 6), new Node(mouseX, mouseY));
}

static boolean isMouseHovering(Node origin, Node mouse) {
return CONFIG.splashTextsEnabled && new Rect(
origin.append(new Node(-width / 2, -height / 2)),
origin.append(new Node(width / 2, height / 2))
).rotate(origin, CONFIG.lefty ? 20 : -20).contains(mouse);
).rotate(origin, CONFIG.texts.lefty ? 20 : -20).contains(mouse);
}

public static void updateSize(float width, float height) {
Expand All @@ -122,7 +122,7 @@ public static void updateSize(float width, float height) {
}

public static void updateFormatting(ArrayList<Formatting> formattings, int color) {
if (CONFIG.colorful) {
if (CONFIG.texts.colorful) {
Splasher.color = color;
if (formattings != null) {
Splasher.formattings.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ public class SplasherConfig implements ConfigData {
public boolean followsClientLanguage = false;
public boolean debugInfoEnabled = false;

@ConfigEntry.Gui.TransitiveObject
@ConfigEntry.Category("texts")
public boolean colorful = false;

@ConfigEntry.Category("texts")
public boolean lefty = false;

@ConfigEntry.Category("texts")
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public RandomRate randomRate = RandomRate.ON_RELOAD_AND_CLICK;

@ConfigEntry.Category("texts")
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public Source source = Source.VANILLA_AND_CUSTOM;
public Texts texts = new Texts();

public static class Texts {
public boolean colorful = false;
public boolean lefty = false;
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public RandomRate randomRate = RandomRate.ON_RELOAD_AND_CLICK;
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public Source source = Source.VANILLA_AND_CUSTOM;
}

public enum RandomRate implements SelectionListEntry.Translatable {
NEVER(false, false),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package band.kessokuteatime.splasher.config;
package band.kessokuteatime.splasher.config.modmenu;

import band.kessokuteatime.splasher.config.SplasherConfig;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import me.shedaniel.autoconfig.AutoConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private ArrayList<String> loadFromFile() throws FileNotFoundException {
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) result.add(scanner.nextLine());

if (result.isEmpty() && !(Splasher.CONFIG.randomRate == SplasherConfig.RandomRate.JEB)) Splasher.LOGGER.warn("Loaded empty custom splash text.");
if (result.isEmpty() && !(Splasher.CONFIG.texts.randomRate == SplasherConfig.RandomRate.JEB)) Splasher.LOGGER.warn("Loaded empty custom splash text.");
return result;
}

Expand All @@ -32,10 +32,10 @@ public List<String> load() {
try {
return loadFromFile();
} catch (Exception exception) {
if (!(Splasher.CONFIG.randomRate == SplasherConfig.RandomRate.JEB)) Splasher.LOGGER.debug("Failed to load custom splash texts: ", exception);
if (!(Splasher.CONFIG.texts.randomRate == SplasherConfig.RandomRate.JEB)) Splasher.LOGGER.debug("Failed to load custom splash texts: ", exception);
}
}
if (!(Splasher.CONFIG.randomRate == SplasherConfig.RandomRate.JEB)) Splasher.LOGGER.error("Failed to load custom splash texts: File " + file.getName() + " not found.");
if (!(Splasher.CONFIG.texts.randomRate == SplasherConfig.RandomRate.JEB)) Splasher.LOGGER.error("Failed to load custom splash texts: File " + file.getName() + " not found.");
return new ArrayList<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SplashTextColorer {
private void colorSplashText(DrawContext context, TextRenderer textRenderer, String text, int xCentered, int y, int color) {
context.drawCenteredTextWithShadow(
textRenderer, Splasher.getFormattedSplashText(text),
xCentered, y, Splasher.CONFIG.colorful ? Splasher.getColor() : color
xCentered, y, Splasher.CONFIG.texts.colorful ? Splasher.getColor() : color
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MinecraftClientTrigger {
@Inject(method = "setScreen", at = @At("TAIL"))
private void trigger(Screen screen, CallbackInfo ci) {
if (screen instanceof TitleScreen) {
if ((Splasher.CONFIG.randomRate.onReload() && Splasher.initialized)) Splasher.push();
if ((Splasher.CONFIG.texts.randomRate.onReload() && Splasher.initialized)) Splasher.push();
else if (!Splasher.initialized) Splasher.initialized = true;
}
}
Expand All @@ -45,12 +45,12 @@ public class SplashTextRendererMixin {

@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;translate(FFF)V"), index = 0)
private float translateX(float x) {
return Splasher.CONFIG.lefty ? MinecraftClient.getInstance().getWindow().getScaledWidth() - x : x;
return Splasher.CONFIG.texts.lefty ? MinecraftClient.getInstance().getWindow().getScaledWidth() - x : x;
}

@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/RotationAxis;rotationDegrees(F)Lorg/joml/Quaternionf;"))
private float rotate(float angle) {
return Splasher.CONFIG.lefty ? -angle : angle;
return Splasher.CONFIG.texts.lefty ? -angle : angle;
}

@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;scale(FFF)V"), index = 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private void get(CallbackInfoReturnable<SplashTextRenderer> cir) {
if (!Splasher.initialized) return;

boolean enabled = Splasher.CONFIG.splashTextsEnabled, localized = Splasher.CONFIG.followsClientLanguage;
SplasherConfig.Source source = Splasher.CONFIG.source;
SplasherConfig.Source source = Splasher.CONFIG.texts.source;

if (!enabled || (!source.vanilla() && !source.custom())) {
// Has nothing
Expand All @@ -43,7 +43,7 @@ private void get(CallbackInfoReturnable<SplashTextRenderer> cir) {
return;
}

if (Splasher.CONFIG.colorful) {
if (Splasher.CONFIG.texts.colorful) {
// Update color and formatting before everything
double formatting = new Random().nextDouble(1);
Splasher.updateFormatting(FormattingType.getFormatting(formatting), new Random().nextInt(0xFFFFFF));
Expand All @@ -59,7 +59,7 @@ private void get(CallbackInfoReturnable<SplashTextRenderer> cir) {
String splashText = SplashTextSupplier.getSplashes(session, splashTexts);
cir.setReturnValue(new SplashTextRenderer(splashText == null ? "" : splashText));

if (Splasher.CONFIG.debugInfoEnabled && !(Splasher.CONFIG.randomRate == SplasherConfig.RandomRate.JEB)) {
if (Splasher.CONFIG.debugInfoEnabled && !(Splasher.CONFIG.texts.randomRate == SplasherConfig.RandomRate.JEB)) {
if (localized) Splasher.LOGGER.info("Splash mode: " + source.name());
else Splasher.LOGGER.info("Splash mode: " + source.name() + " (raw)");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public class SplashTextSupplier {
String language = !Splasher.CONFIG.followsClientLanguage ? "en_us" : MinecraftClient.getInstance().getLanguageManager().getLanguage();
List<String> customSplashTexts = Lists.newArrayList();

if (Splasher.CONFIG.source.vanilla()) customSplashTexts.addAll(splashTexts);
if (Splasher.CONFIG.source.custom()) customSplashTexts.addAll(new SplashTextLoader(path.resolve(language + ".txt").toFile()).load());
if (Splasher.CONFIG.texts.source.vanilla()) customSplashTexts.addAll(splashTexts);
if (Splasher.CONFIG.texts.source.custom()) customSplashTexts.addAll(new SplashTextLoader(path.resolve(language + ".txt").toFile()).load());

if (customSplashTexts.isEmpty()) {
if (Splasher.CONFIG.source.vanilla()){
if (Splasher.CONFIG.texts.source.vanilla()){
Splasher.LOGGER.warn("Minecraft has no splash loaded. Check your data as if it may be broken.");
}
Splasher.LOGGER.error("Empty stack!");
Expand Down Expand Up @@ -56,12 +56,12 @@ public class SplashTextSupplier {
}
}

if (Splasher.CONFIG.source.vanilla() && random <= splashTexts.size()) {
if (Splasher.CONFIG.texts.source.vanilla() && random <= splashTexts.size()) {
if (Splasher.CONFIG.followsClientLanguage) return Text.translatable("splash.minecraft." + random).getString();
else return customSplashTexts.get(random);
}

if (Splasher.CONFIG.source.custom()) return customSplashTexts.get(random);
if (Splasher.CONFIG.texts.source.custom()) return customSplashTexts.get(random);

return null;
}
Expand Down
16 changes: 9 additions & 7 deletions src/main/resources/assets/splasher/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"config.splasher.texts.source.vanilla_and_custom": "Vanilla and Custom",
"config.splasher.texts.source.none" : "None",

"text.autoconfig.splasher.title" : "Splasher!",
"text.autoconfig.splasher.title": "Splasher!",

"text.autoconfig.splasher.category.default": "General",
"text.autoconfig.splasher.category.texts" : "Texts",

"text.autoconfig.splasher.option.splashTextsEnabled": "Splash Texts Enabled",

Expand All @@ -21,15 +21,17 @@
"text.autoconfig.splasher.option.followsClientLanguage" : "Follows Client Language",
"text.autoconfig.splasher.option.followsClientLanguage.@Tooltip": "Make splash texts localizable, otherwise they will always be English except for the greetings",

"text.autoconfig.splasher.option.debugInfoEnabled": "Print Debug Info",
"text.autoconfig.splasher.option.debugInfoEnabled": "Prints Debug Info",

"text.autoconfig.splasher.category.texts": "Texts",

"text.autoconfig.splasher.option.colorful": "Colorful Splash Texts",
"text.autoconfig.splasher.option.texts.colorful": "Colorful Splash Texts",

"text.autoconfig.splasher.option.lefty": "Stick to Left",
"text.autoconfig.splasher.option.texts.lefty": "Sticks to Left",

"text.autoconfig.splasher.option.randomRate": "Random Generation Rate",
"text.autoconfig.splasher.option.texts.randomRate": "Random Generation Rate",

"text.autoconfig.splasher.option.source": "Splash Texts Source",
"text.autoconfig.splasher.option.texts.source": "Splash Texts Source",

"festival.splasher.x_mas" : "Merry X-mas!",
"festival.splasher.new_year" : "Happy new year!",
Expand Down
14 changes: 7 additions & 7 deletions src/main/resources/assets/splasher/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"modmenu.descriptionTranslation.splasher": "为什么不闪烁呢?通过Splasher,你可以完全自定义Minecraft标题旁的闪烁文本。",

"config.splasher.texts.random_rate.never" : "从不",
"config.splasher.texts.random_rate.on_reload" : "重新加载页面时",
"config.splasher.texts.random_rate.on_click" : "点击时",
"config.splasher.texts.random_rate.on_reload_and_click": "重新加载页面和点击时",
"config.splasher.texts.random_rate.jeb" : "Jens Bergensten",

"config.splasher.texts.source.vanilla" : "仅原版",
"config.splasher.texts.source.custom" : "仅自定义",
"config.splasher.texts.source.vanilla_and_custom": "原版和自定义",
"config.splasher.texts.source.none" : "",

"text.autoconfig.splasher.category.default": "通用",
"text.autoconfig.splasher.category.texts" : "文字",

"text.autoconfig.splasher.option.splashTextsEnabled": "启用闪烁文本",

Expand All @@ -22,15 +22,15 @@

"text.autoconfig.splasher.option.debugInfoEnabled": "打印调试信息",

"text.autoconfig.splasher.option.colorful": "多彩的闪烁文本",
"text.autoconfig.splasher.category.texts": "文字",

"text.autoconfig.splasher.option.lefty": "放置在标题左侧",
"text.autoconfig.splasher.option.texts.colorful": "多彩的闪烁文本",

"text.autoconfig.splasher.option.randomRate": "随机生成闪烁文本的时机",
"text.autoconfig.splasher.option.texts.lefty": "放置在标题左侧",

"text.autoconfig.splasher.option.source": "闪烁文本来源",
"text.autoconfig.splasher.option.texts.randomRate": "随机生成闪烁文本的时机",

"modmenu.descriptionTranslation.splasher": "为什么不闪烁呢?通过Splasher,你可以完全自定义Minecraft标题旁的闪烁文本。",
"text.autoconfig.splasher.option.texts.source": "闪烁文本来源",

"festival.splasher.x_mas" : "圣诞快乐!",
"festival.splasher.new_year" : "新年快乐!",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "splasher",
"version": "${version}",

"name": "Splasher",
"name": "Splasher!",
"description": "Why don't splash? Splasher is a mod which makes splash texts fully customizable.",
"authors": [
"Kessoku Tea Time"
Expand All @@ -23,7 +23,7 @@
"band.kessokuteatime.splasher.Splasher"
],
"modmenu": [
"band.kessokuteatime.splasher.config.SplasherModMenuIntegration"
"band.kessokuteatime.splasher.config.modmenu.SplasherModMenuIntegration"
]
},
"mixins": [
Expand Down

0 comments on commit 86bf1af

Please sign in to comment.