fix(mac): stop critter animation when paused
This commit is contained in:
@@ -429,50 +429,43 @@ private struct CritterStatusLabel: View {
|
|||||||
private let ticker = Timer.publish(every: 0.35, on: .main, in: .common).autoconnect()
|
private let ticker = Timer.publish(every: 0.35, on: .main, in: .common).autoconnect()
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Image(nsImage: CritterIconRenderer.makeIcon(
|
Group {
|
||||||
blink: blinkAmount,
|
if isPaused {
|
||||||
legWiggle: legWiggle,
|
Image(nsImage: CritterIconRenderer.makeIcon(blink: 0))
|
||||||
earWiggle: earWiggle
|
.frame(width: 18, height: 16)
|
||||||
))
|
} else {
|
||||||
.frame(width: 18, height: 16)
|
Image(nsImage: CritterIconRenderer.makeIcon(
|
||||||
.rotationEffect(.degrees(wiggleAngle), anchor: .center)
|
blink: blinkAmount,
|
||||||
.offset(x: wiggleOffset)
|
legWiggle: legWiggle,
|
||||||
.onReceive(ticker) { now in
|
earWiggle: earWiggle
|
||||||
guard !isPaused else {
|
))
|
||||||
resetMotion()
|
.frame(width: 18, height: 16)
|
||||||
return
|
.rotationEffect(.degrees(wiggleAngle), anchor: .center)
|
||||||
}
|
.offset(x: wiggleOffset)
|
||||||
|
.onReceive(ticker) { now in
|
||||||
|
if now >= nextBlink {
|
||||||
|
blink()
|
||||||
|
nextBlink = now.addingTimeInterval(Double.random(in: 3.5 ... 8.5))
|
||||||
|
}
|
||||||
|
|
||||||
if now >= nextBlink {
|
if now >= nextWiggle {
|
||||||
blink()
|
wiggle()
|
||||||
nextBlink = now.addingTimeInterval(Double.random(in: 3.5 ... 8.5))
|
nextWiggle = now.addingTimeInterval(Double.random(in: 6.5 ... 14))
|
||||||
}
|
}
|
||||||
|
|
||||||
if now >= nextWiggle {
|
if now >= nextLegWiggle {
|
||||||
wiggle()
|
wiggleLegs()
|
||||||
nextWiggle = now.addingTimeInterval(Double.random(in: 6.5 ... 14))
|
nextLegWiggle = now.addingTimeInterval(Double.random(in: 5.0 ... 11.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
if now >= nextLegWiggle {
|
if now >= nextEarWiggle {
|
||||||
wiggleLegs()
|
wiggleEars()
|
||||||
nextLegWiggle = now.addingTimeInterval(Double.random(in: 5.0 ... 11.0))
|
nextEarWiggle = now.addingTimeInterval(Double.random(in: 7.0 ... 14.0))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if now >= nextEarWiggle {
|
.onChange(of: isPaused) { _, _ in resetMotion() }
|
||||||
wiggleEars()
|
|
||||||
nextEarWiggle = now.addingTimeInterval(Double.random(in: 7.0 ... 14.0))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.onChange(of: isPaused) { _, paused in
|
|
||||||
if paused {
|
|
||||||
resetMotion()
|
|
||||||
} else {
|
|
||||||
nextBlink = Date().addingTimeInterval(Double.random(in: 1.5 ... 3.5))
|
|
||||||
nextWiggle = Date().addingTimeInterval(Double.random(in: 4.5 ... 9.5))
|
|
||||||
nextLegWiggle = Date().addingTimeInterval(Double.random(in: 4.0 ... 8.0))
|
|
||||||
nextEarWiggle = Date().addingTimeInterval(Double.random(in: 5.5 ... 10.5))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func resetMotion() {
|
private func resetMotion() {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ log "==> Killing existing Clawdis instances"
|
|||||||
kill_all_clawdis
|
kill_all_clawdis
|
||||||
|
|
||||||
# 2) Rebuild into the same path the packager consumes (.build).
|
# 2) Rebuild into the same path the packager consumes (.build).
|
||||||
run_step "clean build cache" bash -lc "rm -rf '${ROOT_DIR}/apps/macos/.build'"
|
run_step "clean build cache" bash -lc "cd '${ROOT_DIR}/apps/macos' && rm -rf .build .build-swift .swiftpm"
|
||||||
run_step "swift build" bash -lc "cd '${ROOT_DIR}/apps/macos' && swift build -q --product Clawdis"
|
run_step "swift build" bash -lc "cd '${ROOT_DIR}/apps/macos' && swift build -q --product Clawdis"
|
||||||
|
|
||||||
# 3) Package + relaunch the app (script also stops any stragglers).
|
# 3) Package + relaunch the app (script also stops any stragglers).
|
||||||
|
|||||||
Reference in New Issue
Block a user