Compare commits

...
4 Commits
Author SHA1 Message Date
selimaj-dev e8f686b2d3 Merge pull request 'Remove the upgrade of opaque theme colors from before 0.1.3' (#14) from drop-color-upgrade into master
Reviewed-on: #14
2026-09-30 19:49:03 +00:00
selimaj-devandclaude df5afe99e3 Remove the upgrade of opaque theme colors from before 0.1.3
Configs saved before 0.1.3 (without a menu blur) had their preset
background and primary colors made translucent on load. It's no longer
needed, so Theme drops it, along with ConfigManager.isSaved, which only
it used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-30 21:47:45 +02:00
selimaj-dev 653738568a Merge pull request 'Rename the Ref methods that share a name with vanilla methods' (#13) from explicit-refs into master
Reviewed-on: #13
2026-09-30 16:03:45 +00:00
selimaj-devandclaude a6a324a61a Rename the Ref methods that share a name with vanilla methods
WindowRef.getWidth/getHeight and ItemStackRef.isEmpty/getMaxDamage
match methods of the classes they're mixed into, so the mixins can't
implement them explicitly. With Mojang's names, Window.getWidth is
also the framebuffer's width rather than the window's. They're now
getWindowWidth/getWindowHeight and isEmptyStack/getMaxItemDamage
(with getItemDamage to match).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-30 17:42:48 +02:00
6 changed files with 24 additions and 45 deletions
@@ -1,7 +1,11 @@
package org.saturnclient.common.ref.game; package org.saturnclient.common.ref.game;
/**
* An item stack. Its methods are implemented in ItemStackMixin, so their names must not match any of
* ItemStack's own methods.
*/
public interface ItemStackRef { public interface ItemStackRef {
public boolean isEmpty(); public boolean isEmptyStack();
public int getMaxDamage(); public int getMaxItemDamage();
public int getDamage(); public int getItemDamage();
} }
@@ -1,9 +1,15 @@
package org.saturnclient.common.ref.render; package org.saturnclient.common.ref.render;
/**
* The game window. Its methods are implemented in WindowMixin, so their names must not match any of
* Window's own methods.
*/
public interface WindowRef { public interface WindowRef {
public int getWidth(); /** The window's width in screen coordinates */
public int getWindowWidth();
public int getHeight(); /** The window's height in screen coordinates */
public int getWindowHeight();
public int getFramebufferWidth(); public int getFramebufferWidth();
@@ -163,14 +163,6 @@ public class ConfigManager {
} }
} }
/**
* Whether the config file has a value for {@code name} in this namespace,
* which tells which version last saved it.
*/
public boolean isSaved(String name) {
return getSaved(name) != null;
}
private JsonNode getSaved(String name) { private JsonNode getSaved(String name) {
JsonNode source = cachedJson != null ? cachedJson : loadAndCache(); JsonNode source = cachedJson != null ? cachedJson : loadAndCache();
if (source == null || !source.isObject()) if (source == null || !source.isObject())
@@ -81,29 +81,6 @@ public class Theme {
config.property("Widget Radius", WIDGET_RADIUS, "Corner rounding of buttons and cards"); config.property("Widget Radius", WIDGET_RADIUS, "Corner rounding of buttons and cards");
config.property("Font", FONT, "Font of every Saturn screen"); config.property("Font", FONT, "Font of every Saturn screen");
if (!parent.isSaved(Config.MENU_BLUR)) {
upgradeOpaqueColors();
}
}
/**
* Before 0.1.3 panels and cards were made translucent in code, and the
* background and primary colors were saved fully opaque. Saved colors that
* are an old default or preset get the translucency the colors now carry
* themselves; colors the player picked are left as they are. Runs only on
* configs from older versions, so a preset color later set opaque on
* purpose stays opaque.
*/
private static void upgradeOpaqueColors() {
for (Preset preset : PRESETS) {
if (BACKGROUND.value == (preset.background() | 0xFF000000)) {
BACKGROUND.value = preset.background();
}
if (PRIMARY.value == (preset.primary() | 0xFF000000)) {
PRIMARY.value = preset.primary();
}
}
} }
/** /**
@@ -75,16 +75,16 @@ public class ArmorDisplayMod extends Mod implements HudMod {
int row = 0; int row = 0;
if (useMainHand.value && !mainHand.isEmpty()) { if (useMainHand.value && !mainHand.isEmptyStack()) {
row = renderSlot(scope, mainHand, row); row = renderSlot(scope, mainHand, row);
} }
if (!helmet.isEmpty()) if (!helmet.isEmptyStack())
row = renderSlot(scope, helmet, row); row = renderSlot(scope, helmet, row);
if (!chestplate.isEmpty()) if (!chestplate.isEmptyStack())
row = renderSlot(scope, chestplate, row); row = renderSlot(scope, chestplate, row);
if (!leggings.isEmpty()) if (!leggings.isEmptyStack())
row = renderSlot(scope, leggings, row); row = renderSlot(scope, leggings, row);
if (!boots.isEmpty()) if (!boots.isEmptyStack())
row = renderSlot(scope, boots, row); row = renderSlot(scope, boots, row);
} }
@@ -94,8 +94,8 @@ public class ArmorDisplayMod extends Mod implements HudMod {
private int renderSlot(RenderScope scope, ItemStackRef item, int row) { private int renderSlot(RenderScope scope, ItemStackRef item, int row) {
scope.drawItem(item, 0, 15 * row); scope.drawItem(item, 0, 15 * row);
if (item.getMaxDamage() > 0) { if (item.getMaxItemDamage() > 0) {
int remaining = item.getMaxDamage() - item.getDamage(); int remaining = item.getMaxItemDamage() - item.getItemDamage();
scope.drawText(0.5f, String.valueOf(remaining), scope.drawText(0.5f, String.valueOf(remaining),
17, (15 * row) + 3, 17, (15 * row) + 3,
layout.font.value, layout.fgColor.value); layout.font.value, layout.fgColor.value);
@@ -20,9 +20,9 @@ public class ImageTexture extends Element {
if (sprite.toString().endsWith(".svg")) { if (sprite.toString().endsWith(".svg")) {
MinecraftClientRef client = Providers.saturn.getClient(); MinecraftClientRef client = Providers.saturn.getClient();
int renderWidth = (int) (width * client.getWindow().getFramebufferWidth() / client.getWindow().getWidth()); int renderWidth = (int) (width * client.getWindow().getFramebufferWidth() / client.getWindow().getWindowWidth());
int renderHeight = (int) (height * client.getWindow().getFramebufferHeight() int renderHeight = (int) (height * client.getWindow().getFramebufferHeight()
/ client.getWindow().getHeight()); / client.getWindow().getWindowHeight());
IdentifierRef pngId = SvgTexture.getSvg(sprite, renderWidth * 2, renderHeight * 2); IdentifierRef pngId = SvgTexture.getSvg(sprite, renderWidth * 2, renderHeight * 2);