From 11a5dc18f4442b57ba5176a55d3a98cafb623126 Mon Sep 17 00:00:00 2001 From: Zoobooo <245741181+Zoobooo@users.noreply.github.com> Date: Sun, 22 Nov 2026 00:34:21 +0100 Subject: [PATCH 1/2] feat(hud): add an option to keep HUD previews out of the main menu Adds an "Edit HUDs From the Menu" switch to the HUD editor preferences. It is on by default and keeps the current behavior. When turned off, HUDs behind the main OneConfig menu render live like behind any other screen, without previews, outlines or the drag layer, and editing only happens in the HUD editor. --- .../oneconfig/internal/OneConfig.java | 8 ++++---- .../ui/compose/impls/OneConfigUIScreen.kt | 2 +- .../resources/assets/oneconfig/lang/en_us.json | 2 ++ modules/hud/api/hud.api | 1 + .../oneconfig/api/hud/v1/HudManager.kt | 16 ++++++++++++---- .../api/hud/v1/HudFrameCacheTest.java | 18 ++++++++++++++++++ .../oneconfig/internal/OneConfigConfig.java | 14 ++++++++++++++ .../internal/ui/OneConfigInterface.kt | 2 +- 8 files changed, 53 insertions(+), 10 deletions(-) diff --git a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java index 9a027c00e..931f2bd77 100644 --- a/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java +++ b/minecraft/src/main/java/org/polyfrost/oneconfig/internal/OneConfig.java @@ -247,7 +247,7 @@ public static void prepareHud() { HudManager.targetPixelWidth = Platform.screen().viewportWidth(); HudManager.targetPixelHeight = Platform.screen().viewportHeight(); - if (HudManager.isConfigUiOpen) { + if (HudManager.INSTANCE.isConfigUiPreviewing()) { HudManager.INSTANCE.prepare(sw, sh); HudManager.invalidate(); return; @@ -264,14 +264,14 @@ public static void prepareHud() { *///?} } - /** Submits the legacy HUDs (unless the OneConfig menu draws them) and the GlHost HUD blit into the vanilla HUD */ + /** Submits the legacy HUDs (unless the OneConfig menu draws them as previews) and the GlHost HUD blit into the vanilla HUD */ //~ if = 1.8.9 '(GuiGraphicsExtractor graphics)' -> '()' public static void submitHud(GuiGraphicsExtractor graphics) { - if (!HudManager.isConfigUiOpen || !GlHost.INSTANCE.getDrawsGuiOverScreen()) { + if (!HudManager.INSTANCE.isConfigUiPreviewing() || !GlHost.INSTANCE.getDrawsGuiOverScreen()) { //~ if = 1.8.9 '(graphics)' -> '()' LegacyHudRenderer.INSTANCE.renderLive(graphics); } - if (GlHost.INSTANCE.unavailableReason() != null || HudManager.isConfigUiOpen) return; + if (GlHost.INSTANCE.unavailableReason() != null || HudManager.INSTANCE.isConfigUiPreviewing()) return; //? if >= 1.21.11 { BlazeHud.render(graphics, OneConfigComposeHooks.drawHuds); //?} else { 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 3c35a2f8d..28fcb99d4 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 @@ -97,7 +97,7 @@ class OneConfigUIScreen @JvmOverloads constructor( override val retainsScene: Boolean get() = this === sharedScreen // over the blur, legacy HUDs stay as sharp as the HUD previews next to them - override val underlay get() = LegacyHudRenderer.liveDraw.takeIf { client.level != null } + override val underlay get() = LegacyHudRenderer.liveDraw.takeIf { client.level != null && HudManager.isConfigUiPreviewing } override fun blurAlpha(): Float { if (!ThemeConfig.enableBackgroundBlur || ThemeConfig.reduceTransparency) return 0f diff --git a/minecraft/src/main/resources/assets/oneconfig/lang/en_us.json b/minecraft/src/main/resources/assets/oneconfig/lang/en_us.json index 76a25e0f8..72c902c41 100644 --- a/minecraft/src/main/resources/assets/oneconfig/lang/en_us.json +++ b/minecraft/src/main/resources/assets/oneconfig/lang/en_us.json @@ -47,6 +47,8 @@ "oneconfig.preferences.hud_shortcuts_alt_keybind.description": "A second shortcut for opening the list of keyboard shortcuts in the HUD editor.", "oneconfig.preferences.hud_show_keybind_hints.title": "Show Keybind Hints", "oneconfig.preferences.hud_show_keybind_hints.description": "Shows the keyboard shortcut next to each action in the HUD editor context menu.", + "oneconfig.preferences.hud_previews_in_menu.title": "Edit HUDs From the Menu", + "oneconfig.preferences.hud_previews_in_menu.description": "Shows HUDs behind the OneConfig menu as previews you can move. Turn off to show them live, and only edit them in the HUD editor.", "oneconfig.preferences.hud_marquee_anim.title": "Selection Box Animation", "oneconfig.preferences.hud_marquee_anim.description": "Fades the selection rectangle in and out when drag-selecting HUDs in the editor.", "oneconfig.preferences.hud_marquee_anim_duration.title": "Selection Box Animation Duration (ms)", diff --git a/modules/hud/api/hud.api b/modules/hud/api/hud.api index 59fc889bb..0e2834df3 100644 --- a/modules/hud/api/hud.api +++ b/modules/hud/api/hud.api @@ -421,6 +421,7 @@ public final class org/polyfrost/oneconfig/api/hud/v1/HudManager { public final fun instanceById (Ljava/lang/String;)Lorg/polyfrost/oneconfig/api/hud/v1/Hud; public static final fun instances ()Ljava/util/List; public static final fun invalidate ()V + public final fun isConfigUiPreviewing ()Z public final fun isEditing ()Z public final fun isEditorOpen ()Z public static final fun isSuppressed (Lorg/polyfrost/oneconfig/api/hud/v1/Hud;)Z diff --git a/modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/HudManager.kt b/modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/HudManager.kt index 9d9f48fc7..83c676861 100644 --- a/modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/HudManager.kt +++ b/modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/HudManager.kt @@ -98,12 +98,12 @@ public object HudManager { /** * `true` while HUDs are being shown for editing or preview * - * That is while either the HUD editor or the main OneConfig UI is open + * That is while the HUD editor is open, or the main OneConfig UI while [previewInConfigUi] is on * * HUDs should render example content when this is set */ @get:JvmName("isEditing") - public val isEditing: Boolean get() = isEditorOpen || isConfigUiOpen + public val isEditing: Boolean get() = isEditorOpen || isConfigUiPreviewing /** `true` only while the HUD editor screen itself is open */ @Volatile public var isEditorOpen: Boolean = false @@ -112,9 +112,17 @@ public object HudManager { /** `true` while OneConfig draws vanilla HUD elements off-screen to measure them for the HUD editor */ @Volatile @JvmField public var isSamplingVanilla: Boolean = false - /** Set by the OneConfig UI screen while it is open so HUDs behind it still render as previews */ + /** Set by the OneConfig UI screen while it is open, HUDs behind it render as previews while [previewInConfigUi] is on */ @Volatile @JvmField public var isConfigUiOpen: Boolean = false + /** Whether the main OneConfig UI shows HUDs behind it as editable previews, synced from the OneConfig preferences */ + @ApiStatus.Internal + @Volatile @JvmField public var previewInConfigUi: Boolean = true + + /** `true` while the main OneConfig UI is open and shows HUDs behind it as editable previews */ + @get:JvmName("isConfigUiPreviewing") + public val isConfigUiPreviewing: Boolean get() = isConfigUiOpen && previewInConfigUi + @ExperimentalOneConfigUiApi @Volatile @JvmField public var partialTick: Float = 1f @@ -181,7 +189,7 @@ public object HudManager { private var wasEditing = false - private val showingPreviews get() = isConfigUiOpen || isEditorOpen + private val showingPreviews get() = isConfigUiPreviewing || isEditorOpen @ApiStatus.Internal public val previewRevision: MutableIntState = mutableIntStateOf(0) diff --git a/modules/hud/src/test/java/org/polyfrost/oneconfig/api/hud/v1/HudFrameCacheTest.java b/modules/hud/src/test/java/org/polyfrost/oneconfig/api/hud/v1/HudFrameCacheTest.java index 8997ae453..bafa9350d 100644 --- a/modules/hud/src/test/java/org/polyfrost/oneconfig/api/hud/v1/HudFrameCacheTest.java +++ b/modules/hud/src/test/java/org/polyfrost/oneconfig/api/hud/v1/HudFrameCacheTest.java @@ -45,6 +45,7 @@ static class StaticSizeHud extends TextHud { private float savedHeight; private boolean savedGuiOpen; private boolean savedConfigUiOpen; + private boolean savedPreviewInConfigUi; @BeforeEach void saveGlobals() { @@ -52,6 +53,7 @@ void saveGlobals() { savedHeight = HudManager.guiScreenHeight; savedGuiOpen = HudManager.isGuiScreenOpen; savedConfigUiOpen = HudManager.isConfigUiOpen; + savedPreviewInConfigUi = HudManager.previewInConfigUi; } @AfterEach @@ -60,6 +62,7 @@ void restoreGlobals() { HudManager.guiScreenHeight = savedHeight; HudManager.isGuiScreenOpen = savedGuiOpen; HudManager.isConfigUiOpen = savedConfigUiOpen; + HudManager.previewInConfigUi = savedPreviewInConfigUi; } @Test @@ -122,10 +125,25 @@ void cacheStaysOnWithScreenOpenUntilEditing() { assertNotEquals(stamp, hud.getGeometryStamp$hud(), "a move still invalidates it"); assertEquals(hud.getX(), hud.getFrameX()); + HudManager.previewInConfigUi = true; HudManager.isConfigUiOpen = true; assertEquals(-1, hud.getGeometryStamp$hud(), "editing turns the cache off"); } + @Test + void menuWithoutPreviewsKeepsCacheOn() { + ConfigManager.active(); + HudManager.guiScreenWidth = 960f; + HudManager.guiScreenHeight = 540f; + HudManager.isGuiScreenOpen = true; + HudManager.isConfigUiOpen = true; + HudManager.previewInConfigUi = false; + CacheHud hud = new CacheHud(); + + assertFalse(HudManager.INSTANCE.isEditing(), "the menu alone is not editing with previews turned off"); + assertNotEquals(-1, hud.getGeometryStamp$hud(), "so the cache stays on like behind any other screen"); + } + @Test void overriddenGeometryIsReadLive() { ConfigManager.active(); diff --git a/modules/internal/src/main/java/org/polyfrost/oneconfig/internal/OneConfigConfig.java b/modules/internal/src/main/java/org/polyfrost/oneconfig/internal/OneConfigConfig.java index 008b6c40e..83049a50f 100644 --- a/modules/internal/src/main/java/org/polyfrost/oneconfig/internal/OneConfigConfig.java +++ b/modules/internal/src/main/java/org/polyfrost/oneconfig/internal/OneConfigConfig.java @@ -12,6 +12,7 @@ import org.polyfrost.oneconfig.api.config.v1.annotations.Number; import org.polyfrost.oneconfig.api.config.v1.annotations.Slider; import org.polyfrost.oneconfig.api.config.v1.annotations.Switch; +import org.polyfrost.oneconfig.api.hud.v1.HudManager; import org.polyfrost.oneconfig.api.platform.v1.Keys; import org.polyfrost.oneconfig.api.platform.v1.Platform; import org.polyfrost.oneconfig.api.ui.v1.keybind.KeyModifiers; @@ -183,6 +184,13 @@ public class OneConfigConfig extends Config { ) public static boolean showKeybindHints = true; + @Switch( + title = "oneconfig.preferences.hud_previews_in_menu.title", + subcategory = "oneconfig.preferences.category.hud_editor", + description = "oneconfig.preferences.hud_previews_in_menu.description" + ) + public static boolean hudPreviewsInMenu = true; + @Switch( title = "oneconfig.preferences.hud_marquee_anim.title", subcategory = "oneconfig.preferences.category.hud_editor", @@ -466,6 +474,12 @@ protected void initialize(boolean byConfigManager) { hideIf("uiAmbienceVolume", "enableUIAmbience"); hideIf("marqueeSelectionAnimDuration", "marqueeSelectionAnim"); for (String option : KEYBINDS_PAGE_ONLY) getProperty(option).addMetadata("keybindsPageOnly", true); + addCallback( + "hudPreviewsInMenu", (Boolean v) -> { + HudManager.previewInConfigUi = v; + return false; + }); + HudManager.previewInConfigUi = hudPreviewsInMenu; addCallback( "enableUIAmbience", (Boolean v) -> { UiSounds.refreshAmbience(); diff --git a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt index 7b8a92664..cfb47f88b 100644 --- a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt +++ b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt @@ -161,7 +161,7 @@ fun OneConfigInterface( modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center ) { - if (!shell.warming) HudDragLayer() + if (!shell.warming && OneConfigConfig.hudPreviewsInMenu) HudDragLayer() val currentDensity = LocalDensity.current val scaleFactor = run { From 210d2cd6d5f3903dfcbebff756b4d961ab2d6100 Mon Sep 17 00:00:00 2001 From: Zoobooo <245741181+Zoobooo@users.noreply.github.com> Date: Sun, 22 Nov 2026 00:36:43 +0100 Subject: [PATCH 2/2] docs: add the Edit HUDs From the Menu option to the changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20230e8fb..3b694148d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to OneConfig are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added +- Edit HUDs From the Menu option under Preferences > HUD Editor. Turn it off to show HUDs live behind the OneConfig menu and only edit them in the HUD editor. It is on by default, which keeps the current behavior +- API: `HudManager.isConfigUiPreviewing`, which is `true` while the OneConfig menu is open and shows HUDs behind it as previews + ## [1.9.1] - 2026-11-22 ### Added