From ce39c7e00d0303ba95ef5515b6a0f5d75cc7998f Mon Sep 17 00:00:00 2001 From: Shoxcie Date: Wed, 17 Jul 2024 23:38:44 +0300 Subject: [PATCH 1/2] Add offset config options - Change anchor point to the bottom left corner - Add x and y offset to the config - Add rightToLeft boolean to the config - Set default pos to the left of the hotbar --- common/src/main/java/vice/sol_valheim/FoodHUD.java | 8 ++++---- common/src/main/java/vice/sol_valheim/ModConfig.java | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/vice/sol_valheim/FoodHUD.java b/common/src/main/java/vice/sol_valheim/FoodHUD.java index 7afa5fb..5973207 100644 --- a/common/src/main/java/vice/sol_valheim/FoodHUD.java +++ b/common/src/main/java/vice/sol_valheim/FoodHUD.java @@ -60,10 +60,10 @@ public void renderHud(#if PRE_CURRENT_MC_1_19_2 PoseStack #elif POST_CURRENT_MC_ boolean useLargeIcons = SOLValheim.Config.client.useLargeIcons; - int width = client.getWindow().getGuiScaledWidth() / 2 + 91; - int height = client.getWindow().getGuiScaledHeight() - 39 - (useLargeIcons ? 6 : 0); + int width = SOLValheim.Config.client.x_offset; + int height = client.getWindow().getGuiScaledHeight() - (useLargeIcons ? 14 : 9) - SOLValheim.Config.client.y_offset; - int offset = 1; + int offset = 0; int size = useLargeIcons ? 14 : 9; for (var food : foodData.ItemEntries) { @@ -85,7 +85,7 @@ private static void renderFoodSlot(#if PRE_CURRENT_MC_1_19_2 PoseStack #elif POS int bgColor = isDrink ? FastColor.ARGB32.color(96, 52, 104, 163) : FastColor.ARGB32.color(96, 0, 0, 0); int yellow = FastColor.ARGB32.color(255, 255, 191, 0); - int startWidth = width - (size * offset) - offset + 1; + int startWidth = SOLValheim.Config.client.rightToLeft ? (width - size * offset - offset) : (width + size * offset + offset); float ticksLeftPercent = Float.min(1.0F, (float) food.ticksLeft / foodConfig.getTime()); int barHeight = Integer.max(1, (int)((size + 2f) * ticksLeftPercent)); int barColor = ticksLeftPercent < SOLValheim.Config.common.eatAgainPercentage ? diff --git a/common/src/main/java/vice/sol_valheim/ModConfig.java b/common/src/main/java/vice/sol_valheim/ModConfig.java index c54bd9a..bd7ea1c 100644 --- a/common/src/main/java/vice/sol_valheim/ModConfig.java +++ b/common/src/main/java/vice/sol_valheim/ModConfig.java @@ -175,5 +175,9 @@ public static final class Client implements ConfigData { @ConfigEntry.Gui.Tooltip @Comment("Enlarge the currently eaten food icons") public boolean useLargeIcons = true; + @Comment("Anchor point is the bottom left corner") + public int x_offset = 212; + public int y_offset = 1; + public boolean rightToLeft = true; } } \ No newline at end of file From 912b0daace32a5cd9ddfa5e77ed75cc79225b591 Mon Sep 17 00:00:00 2001 From: Shoxcie Date: Thu, 18 Jul 2024 11:34:51 +0300 Subject: [PATCH 2/2] Increase the size of Large Icons - [Increase the size of Large Icons](https://github.com/anthxnymc/sol_valheim/pull/5) - Change `barColor` to green for better visibility --- common/src/main/java/vice/sol_valheim/FoodHUD.java | 12 ++++++------ common/src/main/java/vice/sol_valheim/ModConfig.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/vice/sol_valheim/FoodHUD.java b/common/src/main/java/vice/sol_valheim/FoodHUD.java index 5973207..f896638 100644 --- a/common/src/main/java/vice/sol_valheim/FoodHUD.java +++ b/common/src/main/java/vice/sol_valheim/FoodHUD.java @@ -61,10 +61,10 @@ public void renderHud(#if PRE_CURRENT_MC_1_19_2 PoseStack #elif POST_CURRENT_MC_ boolean useLargeIcons = SOLValheim.Config.client.useLargeIcons; int width = SOLValheim.Config.client.x_offset; - int height = client.getWindow().getGuiScaledHeight() - (useLargeIcons ? 14 : 9) - SOLValheim.Config.client.y_offset; + int height = client.getWindow().getGuiScaledHeight() - (useLargeIcons ? 18 : 9) - SOLValheim.Config.client.y_offset; int offset = 0; - int size = useLargeIcons ? 14 : 9; + int size = useLargeIcons ? 18 : 9; for (var food : foodData.ItemEntries) { renderFoodSlot(graphics, food, width, size, offset, height, useLargeIcons); @@ -90,10 +90,10 @@ private static void renderFoodSlot(#if PRE_CURRENT_MC_1_19_2 PoseStack #elif POS int barHeight = Integer.max(1, (int)((size + 2f) * ticksLeftPercent)); int barColor = ticksLeftPercent < SOLValheim.Config.common.eatAgainPercentage ? FastColor.ARGB32.color(180, 255, 10, 10) : - FastColor.ARGB32.color(96, 0, 0, 0); + FastColor.ARGB32.color(96, 0, 255, 0); var time = (float) food.ticksLeft / (20 * 60); - var scale = useLargeIcons ? 0.75f : 0.5f; + var scale = useLargeIcons ? 1f : 0.5f; var isSeconds = false; var minutes = String.format("%.0f", time); @@ -110,7 +110,7 @@ private static void renderFoodSlot(#if PRE_CURRENT_MC_1_19_2 PoseStack #elif POS pose.pushPose(); pose.scale(scale, scale, scale); - pose.translate(startWidth * (useLargeIcons ? 0.3333f : 1f), height * (useLargeIcons ? 0.3333f : 1f), 0f); + pose.translate(startWidth * (useLargeIcons ? 0f : 1f), height * (useLargeIcons ? 0f : 1f), 0f); if (food.item == Items.CAKE && Platform.isModLoaded("farmersdelight")) { @@ -162,7 +162,7 @@ private static void renderGUIItem(#if PRE_CURRENT_MC_1_19_2 PoseStack #elif POST poseStack.scale(16.0F, 16.0F, 16.0F); var useLargeIcons = true; - var scale = useLargeIcons ? 0.75f : 0.5f; + var scale = useLargeIcons ? 1f : 0.5f; poseStack.scale(scale, scale, scale); poseStack.translate(-0.15, 0.15, 0f); diff --git a/common/src/main/java/vice/sol_valheim/ModConfig.java b/common/src/main/java/vice/sol_valheim/ModConfig.java index bd7ea1c..22faacc 100644 --- a/common/src/main/java/vice/sol_valheim/ModConfig.java +++ b/common/src/main/java/vice/sol_valheim/ModConfig.java @@ -176,7 +176,7 @@ public static final class Client implements ConfigData { @Comment("Enlarge the currently eaten food icons") public boolean useLargeIcons = true; @Comment("Anchor point is the bottom left corner") - public int x_offset = 212; + public int x_offset = 200; public int y_offset = 1; public boolean rightToLeft = true; }