Preserve sleep when reopening LCDPet
This commit is contained in:
@@ -2577,17 +2577,14 @@ fun Greeting(name: String, modifier: Modifier = Modifier) {
|
|||||||
LaunchedEffect(saveLoaded, restoredAutoSleep) {
|
LaunchedEffect(saveLoaded, restoredAutoSleep) {
|
||||||
if (saveLoaded && restoredAutoSleep && isSleeping && sleepMode == "Auto") {
|
if (saveLoaded && restoredAutoSleep && isSleeping && sleepMode == "Auto") {
|
||||||
activityMood = "Asleep"
|
activityMood = "Asleep"
|
||||||
roughWakeDarkFlash = true
|
roughWakeDarkFlash = false
|
||||||
|
|
||||||
if (framePropAnimation != "Nap") {
|
if (framePropAnimation != "Nap") {
|
||||||
startFrameAnimation("Nap")
|
startFrameAnimation("Nap")
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(if (testingMode) 1_500L else 2_000L)
|
// Reopening LCDPet no longer wakes an exhausted sleeping pet.
|
||||||
|
restoredAutoSleep = false
|
||||||
if (isSleeping && sleepMode == "Auto") {
|
|
||||||
wakeFromAutoSleep()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2601,46 +2598,16 @@ fun Greeting(name: String, modifier: Modifier = Modifier) {
|
|||||||
return@LaunchedEffect
|
return@LaunchedEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
val wakeAtMs = autoSleepStartedAtMs
|
// Reopening during a Nap no longer wakes the pet.
|
||||||
val napStillActive =
|
// Release the restore gate so the original fixed wake deadline continues.
|
||||||
wakeAtMs <= 0L || System.currentTimeMillis() < wakeAtMs
|
roughWakeDarkFlash = false
|
||||||
|
|
||||||
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
|
|
||||||
activityMood = "Asleep"
|
activityMood = "Asleep"
|
||||||
frameProp = ""
|
|
||||||
framePropAnimation = ""
|
|
||||||
framePropStyle = 0
|
|
||||||
|
|
||||||
delay(if (testingMode) 1_500L else 1_200L)
|
if (framePropAnimation != "Nap") {
|
||||||
|
startFrameAnimation("Nap")
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restoredManualNap = false
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(
|
LaunchedEffect(
|
||||||
|
|||||||
Reference in New Issue
Block a user