Skip to content
Merged
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 @@ -183,6 +183,7 @@ public static void render(GuiGraphicsExtractor graphics, float partial) {
HudManager.targetPixelWidth = Platform.screen().viewportWidth();
HudManager.targetPixelHeight = Platform.screen().viewportHeight();

//~ if < 1.21.8 '.suppressInGameHudRender' -> '.shouldSuppressInGameHudRender()'
if (!SkiaCtx.INSTANCE.suppressInGameHudRender) {
LegacyHudRenderer.INSTANCE.renderLive(graphics);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Mixin_HudRenderEvent {
@Inject(method = "extractRenderState", at = @At("TAIL"))
private void renderHudCallback(GuiGraphicsExtractor ctx, DeltaTracker deltaTracker, CallbackInfo ci) {
OneConfig.render(ctx, deltaTracker.getRealtimeDeltaTicks());
//~ if < 1.21.8 '.suppressInGameHudRender' -> '.shouldSuppressInGameHudRender()'
if (!SkiaCtx.INSTANCE.suppressInGameHudRender) {
SkiaCtx.INSTANCE.blitHud(ctx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ object SkiaCtx {
private var hudRealIsGeneral = false
private var composeRealIsGeneral = false

//? if < 1.21.8 {
/*@Volatile
private var clearComposeAfterDraw = false

@Volatile
private var hudBlitSuppressed = false
*///? }

@Volatile
private var composeActive = false
@Volatile
Expand All @@ -82,6 +90,8 @@ object SkiaCtx {
private var composeRender: (() -> Unit)? = null

fun submitComposeFrame(dirty: Boolean, render: Runnable) {
//? if < 1.21.8
//clearComposeAfterDraw = false
composeActive = true
if (dirty || composeRender == null) {
composeRender = { render.run() }
Expand All @@ -90,11 +100,34 @@ object SkiaCtx {
}

fun clearComposeFrame() {
//? if >= 1.21.8 {
composeActive = false
composeDirty = false
composeRender = null
//?} else {
/*// Screen removal calls this before the frame's final Skia draw.
// Clearing immediately would leave that frame without a HUD.
// Keep the cached Compose surface for that draw so the HUD remains visible.
clearComposeAfterDraw = true
composeDirty = false
*///?}
}

//? if < 1.21.8 {
/*fun discardComposeFrame() {
clearComposeAfterDraw = false
composeActive = false
composeDirty = false
composeRender = null
}

private fun finishComposeClear() {
clearComposeAfterDraw = false
composeActive = false
composeRender = null
}
*///? }

//? >= 1.21.5 {
private val HUD_TEXTURE_LOC = Identifier.fromNamespaceAndPath("oneconfig", "hud_skia")
private val COMPOSE_TEXTURE_LOC = Identifier.fromNamespaceAndPath("oneconfig", "compose_skia")
Expand Down Expand Up @@ -329,6 +362,20 @@ object SkiaCtx {
@JvmField
var suppressInGameHudRender = false

//? if < 1.21.8 {
/*// The HUD pass runs before the Compose surface exists, so keep the HUD visible until then.
fun shouldSuppressInGameHudRender(): Boolean {
val suppress = suppressInGameHudRender && composeSurface != null
hudBlitSuppressed = suppress
return suppress
}

fun prepareComposeSurface() {
if (!isReady || currentSurface != null) return
resolveComposeSurface()
}
*///? }

fun blitHud(guiGraphics: GuiGraphicsExtractor) {
val rt = hudTarget ?: return
val w = rt.width
Expand Down Expand Up @@ -439,6 +486,11 @@ object SkiaCtx {

fun draw() {
if (!this::directContext.isInitialized) return
//? if < 1.21.8 {
/*val composeStandsInForHud = hudBlitSuppressed
hudBlitSuppressed = false
if (clearComposeAfterDraw && !composeStandsInForHud) finishComposeClear()
*///? }
runWarmups()
val draws = queuedDraws.toList()
queuedDraws.clear()
Expand Down Expand Up @@ -504,6 +556,9 @@ object SkiaCtx {
}
} finally {
currentSurface = null
//? if < 1.21.8 {
/*if (clearComposeAfterDraw) finishComposeClear()
*///?}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.polyfrost.oneconfig.internal.ui.shell.ShellState
import org.polyfrost.oneconfig.internal.ui.sound.UiSoundEvent
import org.polyfrost.oneconfig.internal.ui.sound.UiSounds
import org.polyfrost.oneconfig.api.platform.v1.Platform
import org.polyfrost.oneconfig.internal.OneConfig
import kotlin.math.pow

class OneConfigUIScreen @JvmOverloads constructor(
Expand Down Expand Up @@ -111,7 +112,7 @@ class OneConfigUIScreen @JvmOverloads constructor(
}

override fun init() {
org.polyfrost.oneconfig.internal.OneConfig.dismissFirstLaunchToast()
OneConfig.dismissFirstLaunchToast()
ConfigRegistry.loadFrom(ConfigManager.active(), ConfigSource.OC)
initialTree?.let { ConfigRegistry.registerTree(it, ConfigSource.OC) }

Expand Down Expand Up @@ -163,6 +164,12 @@ class OneConfigUIScreen @JvmOverloads constructor(
ShellState.versionLabel = "OneConfig"
}

//? if < 1.21.8 {
/*// Compose normally creates its surface after the HUD pass.
// Create the surface now to avoid drawing the HUD twice.
SkiaCtx.prepareComposeSurface()
*///?}

SkiaCtx.suppressInGameHudRender = true
HudManager.overrideShowInScreens = true
HudManager.isConfigUiOpen = true
Expand Down Expand Up @@ -257,6 +264,18 @@ class OneConfigUIScreen @JvmOverloads constructor(
if (Platform.screen().current<Any?>() !== this) return
if (closeRequested && System.currentTimeMillis() - closeRequestedAt >= closeAnimationMs) {
Platform.screen().close()
//? if >= 1.21.8 {
// This frame skipped normal HUD rendering because OneConfig was open.
// Closing removes the Compose copy as well, so add the normal HUD back.
OneConfig.render(ctx, tickDelta)
SkiaCtx.blitHud(ctx)
//?} else {
/*if (closeAnimationMs <= 0L) {
SkiaCtx.discardComposeFrame()
OneConfig.render(ctx, tickDelta)
SkiaCtx.blitHud(ctx)
}
*///?}
return
}
if (client.level == null) {
Expand Down
Loading