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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@
//@Mixin(GameGui.class)
public class Mixin_HudRenderEvent {

//~ if >= 26.1 'render' -> 'extractRenderState'
@Inject(method = "extractRenderState", at = @At("HEAD"), cancellable = true)
//~ if = 1.8.9 '(GuiGraphicsExtractor ctx, DeltaTracker deltaTracker' -> '(float partialTicks'
private void hideForMenu(GuiGraphicsExtractor ctx, DeltaTracker deltaTracker, CallbackInfo ci) {
if (!HudManager.isHiddenByMenu()) return;
//? if = 1.8.9
//OneConfig.render();
ci.cancel();
}

//~ if >= 26.1 'render' -> 'extractRenderState'
@Inject(method = "extractRenderState", at = @At("HEAD"))
private void beginVanillaFootprint(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.polyfrost.oneconfig.api.toggle.v1.ModToggle
import org.polyfrost.oneconfig.api.ui.v1.ModToggles
//? if > 1.8.9
import org.polyfrost.oneconfig.internal.compat.ArmorHudCompat
import org.polyfrost.oneconfig.internal.compat.ConfigEntrypoints
import org.polyfrost.oneconfig.internal.ui.api.ModToggleStore
import org.polyfrost.oneconfig.internal.ui.api.PropertyModToggle
import org.polyfrost.oneconfig.internal.ui.api.findMarkedSwitch
Expand Down Expand Up @@ -176,9 +177,13 @@ internal object ModGates {
it.getMetadata<Any>(Backend.UI_ONLY_METADATA) != true &&
it.getMetadata<Any>(CompatSnapshots.SNAPSHOT_METADATA) != true &&
it.findMarkedSwitch() != null
}.mapNotNullTo(HashSet()) { it.id?.removeSuffix(".json") }
}
val ids = switched.mapNotNullTo(HashSet()) { it.id?.removeSuffix(".json") }
return gates.filter { gate ->
gate.id in loaded && switched.any { it == gate.id || it in gate.cards }
gate.id in loaded && (
ids.any { it == gate.id || it in gate.cards } ||
ConfigEntrypoints.ownedTrees(gate.id).any(switched::contains)
)
}.mapTo(HashSet()) { it.id }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ class OneConfigUIScreen @JvmOverloads constructor(

HudManager.overrideShowInScreens = true
HudManager.isConfigUiOpen = true
HudManager.hideInMenu = OneConfigConfig.hideHudInMenu

closeRequested = false
closeRequestedAt = 0L
Expand Down Expand Up @@ -468,6 +469,7 @@ class OneConfigUIScreen @JvmOverloads constructor(
// tcdcommons-based screens like Better Statistics Screen render their parent by hand each frame
// and that would queue a fullscreen blur which smears over the popup so bail unless we are current
if (Platform.screen().current<Any?>() !== this) return
HudManager.hideInMenu = OneConfigConfig.hideHudInMenu
if (closeRequested && System.currentTimeMillis() - closeRequestedAt >= closeAnimationMs) {
markClosed()
//? if < 1.21.8 && > 1.8.9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object LegacyHudRenderer {
//~ if = 1.8.9 'renderLiveHuds(graphics)' -> 'renderLiveHuds()'
renderLiveHuds(graphics)
//~ if = 1.8.9 '.render(graphics)' -> '.render()'
if (CompatOverlayRenderer.oneConfigScreenOpen()) CompatOverlayRenderer.render(graphics)
if (CompatOverlayRenderer.oneConfigScreenOpen() && !HudManager.isHiddenByMenu) CompatOverlayRenderer.render(graphics)
}

//~ if = 1.8.9 '(graphics: GuiGraphicsExtractor)' -> '()'
Expand Down Expand Up @@ -128,6 +128,7 @@ object LegacyHudRenderer {
}

private fun passesFilters(hud: LegacyHud): Boolean {
if (HudManager.isHiddenByMenu) return false
if (HudManager.isPreviewing(hud)) return true
if (hud.effectivelyHidden && !hud.drawsWhileHidden()) return false
if (HudManager.isGuiHidden || HudManager.allHudsHiddenByKey) return false
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 @@ -84,6 +84,8 @@

"oneconfig.preferences.pause_game.title": "Pause Game",
"oneconfig.preferences.pause_game.description": "Pause singleplayer worlds while the OneConfig menu is open.",
"oneconfig.preferences.hide_hud_in_menu.title": "Hide HUD in Menu",
"oneconfig.preferences.hide_hud_in_menu.description": "Hide the HUD while the OneConfig menu is open.",

"oneconfig.preferences.ui_scale.title": "UI Scale",
"oneconfig.preferences.ui_scale.description": "Size of the OneConfig menu in percent. 100 fits it to the window.",
Expand Down
3 changes: 3 additions & 0 deletions modules/hud/api/hud.api
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ public final class org/polyfrost/oneconfig/api/hud/v1/HudManager {
public static field viewport Lorg/polyfrost/oneconfig/api/hud/v1/HudViewport;
public final fun getActiveInstances ()Ljava/util/ArrayList;
public static final fun getAllHudsHiddenByKey ()Z
public static final fun getHideInMenu ()Z
public final fun getHudsOfType (Ljava/lang/Class;)Ljava/util/ArrayList;
public static final fun getLayoutReferenceHeight ()F
public static final fun getLayoutReferenceWidth ()F
Expand All @@ -465,6 +466,7 @@ public final class org/polyfrost/oneconfig/api/hud/v1/HudManager {
public static final fun invalidate ()V
public final fun isEditing ()Z
public final fun isEditorOpen ()Z
public static final fun isHiddenByMenu ()Z
public static final fun isPreviewing (Lorg/polyfrost/oneconfig/api/hud/v1/Hud;)Z
public static final fun isSuppressed (Lorg/polyfrost/oneconfig/api/hud/v1/Hud;)Z
public static final fun isSystemPosition ()Z
Expand All @@ -483,6 +485,7 @@ public final class org/polyfrost/oneconfig/api/hud/v1/HudManager {
public static synthetic fun removeHud$default (Lorg/polyfrost/oneconfig/api/hud/v1/HudManager;Lorg/polyfrost/oneconfig/api/hud/v1/Hud;ZILjava/lang/Object;)V
public static final fun resetAllHudsKey ()V
public static final fun resetVisibilityKeys ()V
public static final fun setHideInMenu (Z)V
public static final fun suppressionReasons (Lorg/polyfrost/oneconfig/api/hud/v1/Hud;)Ljava/util/List;
public final fun toggleAllHuds (Lorg/polyfrost/oneconfig/api/hud/v1/Hud;Z)V
public final fun unregister (Lorg/polyfrost/oneconfig/api/hud/v1/Hud;ZZ)Ljava/util/ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ package org.polyfrost.oneconfig.api.hud.v1
import androidx.compose.runtime.MutableIntState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshots.Snapshot
import androidx.compose.runtime.snapshots.SnapshotStateObserver
Expand Down Expand Up @@ -124,6 +125,12 @@ public object HudManager {
@JvmStatic
public fun isPreviewing(hud: Hud): Boolean = isEditorOpen || isConfigUiOpen && hud.previewsBehindMenu

@JvmStatic
public var hideInMenu: Boolean by mutableStateOf(false)

@JvmStatic
public val isHiddenByMenu: Boolean get() = hideInMenu && isConfigUiOpen && !isEditorOpen

/** `true` only while the HUD editor screen itself is open */
@Volatile public var isEditorOpen: Boolean = false
private set
Expand Down Expand Up @@ -1206,9 +1213,14 @@ public object HudManager {
var volatileContent = false
val instances = activeInstances
var drawnKey = instances.size.toLong()
val hiddenByMenu = isHiddenByMenu
for (i in instances.indices) {
val hud = instances[i]
if (hud is LegacyHudMarker) continue
if (hiddenByMenu) {
hud.setVisible(false)
continue
}
val visible = shouldDraw(hud)
val backgroundOnly = !visible && keepsBackgroundOnly(hud)
if (visible || backgroundOnly) {
Expand Down Expand Up @@ -1713,9 +1725,14 @@ public object HudManager {
prepareFrame(screenWidth, screenHeight, {
prepareOrder.clear()
val instances = activeInstances
val hiddenByMenu = isHiddenByMenu
for (i in instances.indices) {
val hud = instances[i]
if (hud is LegacyHudMarker) continue
if (hiddenByMenu) {
hud.setVisible(false)
continue
}
val previewing = isPreviewing(hud)
val visible = previewing || inWorld && shouldDraw(hud)
val backgroundOnly = !visible && inWorld && keepsBackgroundOnly(hud)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ public class OneConfigConfig extends Config {
)
public static boolean pauseGame = false;

@Switch(
title = "oneconfig.preferences.hide_hud_in_menu.title",
subcategory = "oneconfig.preferences.category.gui",
description = "oneconfig.preferences.hide_hud_in_menu.description"
)
public static boolean hideHudInMenu = false;

@Dropdown(
title = "oneconfig.preferences.remember_last_page.title",
subcategory = "oneconfig.preferences.category.gui",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ internal fun alignHuds(units: List<Collection<Hud>>, align: HudAlign) {
}

private fun hudBounds(hud: Hud): HudBounds? {
if (HudManager.isHiddenByMenu) return null
if (!HudManager.isPreviewing(hud) && !hud.isVisible.value) return null
val scale = hud.effectiveScale
if (hud is LegacyHud) {
Expand Down