Skip to content

Commit

Permalink
Tip scale support
Browse files Browse the repository at this point in the history
  • Loading branch information
KawaiiZapic committed Jul 7, 2022
1 parent feaaf9a commit 45ea639
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public static Screen getConfigScreen() {
.setSaveConsumer(v -> config.Scale = v)
.build()
);
category.addEntry(entry
.startIntSlider(new TranslatableText("text.autoconfig.clock-hud.option.TipScale"), config.TipScale, 100, 200)
.setDefaultValue(150)
.setTextGetter(v -> new TranslatableText("text.autoconfig.clock-hud.option.ScalePercent", v))
.setSaveConsumer(v -> config.TipScale = v)
.build()
);
category.addEntry(entry
.startIntSlider(new TranslatableText("text.autoconfig.clock-hud.option.Opacity"), config.Opacity, 0, 255)
.setDefaultValue(255)
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/moe/zapic/clockhud/config/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class ModConfig implements ConfigData {
@ConfigEntry.BoundedDiscrete(min = 25, max = 200)
public int Scale = 100;

@ConfigEntry.BoundedDiscrete(min = 100, max = 200)
public int TipScale = 150;

@ConfigEntry.BoundedDiscrete(min = 0, max = 255)
public int Opacity = 255;
}
6 changes: 3 additions & 3 deletions src/main/java/moe/zapic/clockhud/render/DayCountRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public static void render(MatrixStack matrices, float tickDelta, CallbackInfo ci
if (!isTextRendering) return;
var mc = MinecraftClient.getInstance();
matrices.push();
var scale = 1 + 0.25f * (renderTime / Duration);
matrices.translate(-mc.getWindow().getScaledWidth() * (scale - 1) / 2, - 40 * (scale - 1) / 2,0);
var scale = (Main.config.TipScale / 100.0f) * (1f + 0.25f * (renderTime / Duration));
matrices.translate(-mc.getWindow().getScaledWidth() * (scale - 1) / 2, - 30 * (scale - 1) / 2,0);
matrices.scale(scale, scale, 1);
setRenderStatus();
DrawableHelper.drawCenteredText(matrices, mc.textRenderer, new TranslatableText("text.clock-hud.new-day-tip", currentDay), mc.getWindow().getScaledWidth() / 2, 40, (TextOpacity << 24) + 0xffffff);
DrawableHelper.drawCenteredText(matrices, mc.textRenderer, new TranslatableText("text.clock-hud.new-day-tip", currentDay), mc.getWindow().getScaledWidth() / 2, 30, (TextOpacity << 24) + 0xffffff);
matrices.pop();
renderTime += tickDelta;
if (renderTime >= Duration) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/clock-hud/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"text.autoconfig.clock-hud.option.ScreenX": "X offset",
"text.autoconfig.clock-hud.option.ScreenY": "Y offset",
"text.autoconfig.clock-hud.option.Scale": "HUD scale",
"text.autoconfig.clock-hud.option.TipScale": "Day count tip scale",
"text.autoconfig.clock-hud.option.Opacity": "HUD opacity",
"text.autoconfig.clock-hud.option.ScalePercent": "%d%%",
"text.clock-hud.new-day-tip": "Day %d"
}
4 changes: 3 additions & 1 deletion src/main/resources/assets/clock-hud/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"text.autoconfig.clock-hud.option.showDayCount": "在新的一天显示天数",
"text.autoconfig.clock-hud.option.ScreenX": "X偏移",
"text.autoconfig.clock-hud.option.ScreenY": "Y偏移",
"text.autoconfig.clock-hud.option.Scale": "HUD大小缩放",
"text.autoconfig.clock-hud.option.Scale": "HUD大小",
"text.autoconfig.clock-hud.option.TipScale": "天数提示大小缩放",
"text.autoconfig.clock-hud.option.Opacity": "HUD不透明度",
"text.autoconfig.clock-hud.option.ScalePercent": "%d%%",
"text.clock-hud.new-day-tip": "第%d天"
}

0 comments on commit 45ea639

Please sign in to comment.