Preserve sleep when reopening LCDPet

This commit is contained in:
Kris
2026-08-17 19:19:57 -04:00
parent 0e9dafa482
commit cb39e5482d
@@ -2577,17 +2577,14 @@ fun Greeting(name: String, modifier: Modifier = Modifier) {
LaunchedEffect(saveLoaded, restoredAutoSleep) {
if (saveLoaded && restoredAutoSleep && isSleeping && sleepMode == "Auto") {
activityMood = "Asleep"
roughWakeDarkFlash = true
roughWakeDarkFlash = false
if (framePropAnimation != "Nap") {
startFrameAnimation("Nap")
}
delay(if (testingMode) 1_500L else 2_000L)
if (isSleeping && sleepMode == "Auto") {
wakeFromAutoSleep()
}
// Reopening LCDPet no longer wakes an exhausted sleeping pet.
restoredAutoSleep = false
}
}
@@ -2601,46 +2598,16 @@ fun Greeting(name: String, modifier: Modifier = Modifier) {
return@LaunchedEffect
}
val wakeAtMs = autoSleepStartedAtMs
val napStillActive =
wakeAtMs <= 0L || System.currentTimeMillis() < wakeAtMs
if (!napStillActive) {
// The original Nap finished while LCDPet was closed.
// Release the gate so the normal Nap completion effect can finish it.
restoredManualNap = false
return@LaunchedEffect
}
// LCDPet was reopened before the manual Nap was finished.
roughWakeDarkFlash = true
// Reopening during a Nap no longer wakes the pet.
// Release the restore gate so the original fixed wake deadline continues.
roughWakeDarkFlash = false
activityMood = "Asleep"
frameProp = ""
framePropAnimation = ""
framePropStyle = 0
delay(if (testingMode) 1_500L else 1_200L)
if (
restoredManualNap &&
isSleeping &&
sleepMode == "Nap"
) {
isSleeping = false
sleepMode = ""
autoSleepStartedAtMs = 0L
restoredManualNap = false
roughWakeDarkFlash = false
roughWakeNervousHold = false
status = "Nervous"
activityMood = "RoughWake"
roughWakeAlert = true
frameProp = "!?!"
framePropAnimation = ""
framePropStyle = 0
happiness = (happiness - 1).coerceAtLeast(0)
if (framePropAnimation != "Nap") {
startFrameAnimation("Nap")
}
restoredManualNap = false
}
LaunchedEffect(