From 6b0f891094450e142b2604b70cdb174d6f94fd79 Mon Sep 17 00:00:00 2001 From: Saad Nadeem Date: Thu, 13 Aug 2026 17:51:23 -0400 Subject: [PATCH 1/2] fix(hud): use window bounds for action bar --- .../oneconfig/internal/ui/compose/impls/HudEditorUIScreen.kt | 2 +- .../oneconfig/internal/ui/compose/impls/OneConfigUIScreen.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/HudEditorUIScreen.kt b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/HudEditorUIScreen.kt index 337de4d9e..45e7be70a 100644 --- a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/HudEditorUIScreen.kt +++ b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/HudEditorUIScreen.kt @@ -110,7 +110,7 @@ class HudEditorUIScreen : ComposeScreen() { HudManager.guiScreenHeight = sh HudManager.prepare(sw, sh) } - HudEditorViewport.update(Platform.screen().viewportWidth(), Platform.screen().viewportHeight()) + HudEditorViewport.update(Platform.screen().windowWidth(), Platform.screen().windowHeight()) //~ if >= 26.1 'render' -> 'extractRenderState' super.extractRenderState(ctx, mouseX, mouseY, tickDelta) } diff --git a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/OneConfigUIScreen.kt b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/OneConfigUIScreen.kt index 1fb79392e..bcac29862 100644 --- a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/OneConfigUIScreen.kt +++ b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/compose/impls/OneConfigUIScreen.kt @@ -267,7 +267,7 @@ class OneConfigUIScreen @JvmOverloads constructor( HudManager.guiScreenHeight = sh HudManager.prepare(sw, sh) } - HudEditorViewport.update(Platform.screen().viewportWidth(), Platform.screen().viewportHeight()) + HudEditorViewport.update(Platform.screen().windowWidth(), Platform.screen().windowHeight()) if (OneConfigConfig.enableBackgroundBlur) { //? if >= 1.21.10 { if (SkiaCtx.isDeferredComposeBackend) { From b94112c26fc169b51add7ee67b58d935170a5557 Mon Sep 17 00:00:00 2001 From: Julian Chang Date: Sun, 16 Aug 2026 17:20:26 +0700 Subject: [PATCH 2/2] Rename HudEditorViewport to reflect actual usage --- .../ui/hud/screens/HudDesignStudio.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/hud/screens/HudDesignStudio.kt b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/hud/screens/HudDesignStudio.kt index 441a4d644..aa0403a89 100644 --- a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/hud/screens/HudDesignStudio.kt +++ b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/hud/screens/HudDesignStudio.kt @@ -127,22 +127,22 @@ enum class StudioCategory(val title: String, val icon: String) { } object HudEditorViewport { - var viewportWidth by mutableStateOf(0) + var screenWidth by mutableStateOf(0) private set - var viewportHeight by mutableStateOf(0) + var screenHeight by mutableStateOf(0) private set fun update(width: Int, height: Int) { - if (width == viewportWidth && height == viewportHeight) return + if (width == screenWidth && height == screenHeight) return Snapshot.withMutableSnapshot { - viewportWidth = width - viewportHeight = height + screenWidth = width + screenHeight = height } } fun observe() { - @Suppress("UNUSED_EXPRESSION") viewportWidth - @Suppress("UNUSED_EXPRESSION") viewportHeight + @Suppress("UNUSED_EXPRESSION") screenWidth + @Suppress("UNUSED_EXPRESSION") screenHeight } } @@ -489,9 +489,9 @@ private fun hudActionBarLayout( // the bar lives outside the HUD box because small HUDs swallow or overlap the icons when the // buttons are laid out inside the bounds - val screenW = HudEditorViewport.viewportWidth.toFloat() + val screenW = HudEditorViewport.screenWidth.toFloat() .takeIf { it > 0f } ?: (HudManager.guiScreenWidth * mcToScreen) - val screenH = HudEditorViewport.viewportHeight.toFloat() + val screenH = HudEditorViewport.screenHeight.toFloat() .takeIf { it > 0f } ?: (HudManager.guiScreenHeight * mcToScreen) val padPx = actionBarPadding(gapPx) @@ -972,7 +972,7 @@ fun HudDesignStudio(onReturnToOneConfig: (() -> Unit)? = null) { HudManager.pendingSelection = null HudManager.pendingAdd = null if (pendingAdd != null) { - snapshotFlow { HudEditorViewport.viewportWidth }.first { it > 0 } + snapshotFlow { HudEditorViewport.screenWidth }.first { it > 0 } val instance = placeHudCentered(pendingAdd) if (instance != null) { Snapshot.withMutableSnapshot {