Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions minecraft/src/main/resources/assets/oneconfig/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
1 change: 1 addition & 0 deletions modules/hud/api/hud.api
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ static class StaticSizeHud extends TextHud {
private float savedHeight;
private boolean savedGuiOpen;
private boolean savedConfigUiOpen;
private boolean savedPreviewInConfigUi;

@BeforeEach
void saveGlobals() {
savedWidth = HudManager.guiScreenWidth;
savedHeight = HudManager.guiScreenHeight;
savedGuiOpen = HudManager.isGuiScreenOpen;
savedConfigUiOpen = HudManager.isConfigUiOpen;
savedPreviewInConfigUi = HudManager.previewInConfigUi;
}

@AfterEach
Expand All @@ -60,6 +62,7 @@ void restoreGlobals() {
HudManager.guiScreenHeight = savedHeight;
HudManager.isGuiScreenOpen = savedGuiOpen;
HudManager.isConfigUiOpen = savedConfigUiOpen;
HudManager.previewInConfigUi = savedPreviewInConfigUi;
}

@Test
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down