Preserve current AVIF compression, local voice pipelines, practice workflows, UI API migration, locale updates, and packaging work. Native integration validation remains pending.
123 lines
4.6 KiB
Ziran
123 lines
4.6 KiB
Ziran
// The live practice clocks run in this bundle, and Practice's home draws
|
|
// here; the unified host performs audio, notification, session-save and
|
|
// mobile lifecycle effects.
|
|
#import, file "../../src/apps/practice_types.zi";
|
|
#import, file "../../src/core/breath_timing.zi";
|
|
#import, file "../../src/practices/meditation/meditation_timing.zi";
|
|
#import, file "../../src/practices/patterns/patterns_clock.zi";
|
|
#import, file "../../src/apps/module_types.zi";
|
|
#import "apps/node_types"
|
|
#import, file "../../src/core/types.zi";
|
|
#import, file "../../src/practices/sun_salutation/sun_salutation_rules.zi";
|
|
#import, file "practice_home_view.zi";
|
|
#import, file "manual_view.zi";
|
|
#import, file "settings_view.zi";
|
|
#import, file "results_view.zi";
|
|
#import, file "meditation_view.zi";
|
|
#import, file "patterns_view.zi";
|
|
#import, file "whm_view.zi";
|
|
#import, file "movement_view.zi";
|
|
#import, file "course_view.zi";
|
|
host_api :: #system_library "host_api";
|
|
ReadPracticeHost :: () -> PracticeMessage #foreign host_api;
|
|
WritePracticeHost :: (message: PracticeMessage) #foreign host_api;
|
|
SunSalutationStoredFrame :: (timeline_frame: s32) -> s32 #foreign host_api;
|
|
|
|
PracticeApply :: (message: PracticeMessage) -> PracticeMessage {
|
|
message.succeeded = true
|
|
if message.action == PRACTICE_ROUTE {
|
|
message.succeeded = message.screen == ScreenStart || message.screen == ScreenSession ||
|
|
message.screen == ScreenMeditation || message.screen == ScreenSunSalutation ||
|
|
message.screen == ScreenPatterns || message.screen == ScreenTaiChi || message.screen == ScreenAstralProjection ||
|
|
message.screen == ScreenWorkout ||
|
|
message.screen == ScreenResults || message.screen == ScreenPracticeConfig ||
|
|
message.screen == ScreenManual
|
|
return message
|
|
}
|
|
if message.paused {
|
|
return message
|
|
}
|
|
if message.action == PRACTICE_BREATH_STEP {
|
|
message.breathing = BreathSessionStep(message.breathing)
|
|
message.completed = message.breathing.completed != 0
|
|
} else if message.action == PRACTICE_MEDITATION_STEP {
|
|
next := AdvanceMeditationTime(message.remaining_seconds,
|
|
message.remainder_ms, message.elapsed_ms)
|
|
message.remaining_seconds = next.remaining_seconds
|
|
message.remainder_ms = next.remainder_ms
|
|
message.elapsed_seconds = next.elapsed_seconds
|
|
message.completed = next.completed
|
|
} else if message.action == PRACTICE_SALUTATION_STEP {
|
|
next := SalutationAdvance(message.salutation, message.elapsed)
|
|
message.salutation = next.state
|
|
message.completed = next.completed != 0
|
|
} else if message.action == PRACTICE_PATTERNS_STEP {
|
|
next := PatternsAdvance(message.patterns)
|
|
message.patterns = next.state
|
|
message.cue = next.cue
|
|
message.completed = next.completed
|
|
} else {
|
|
message.succeeded = false
|
|
}
|
|
return message
|
|
}
|
|
|
|
#program_export "PracticeMain"
|
|
Main :: () -> s32 {
|
|
message := ReadPracticeHost()
|
|
if message.abi != MODULE_ABI {
|
|
return -1
|
|
}
|
|
if message.action == MODULE_IDENTIFY {
|
|
// The smaller frame inventory needs the wrapper's frame mapping.
|
|
// Older wrappers reject this required capability before replacing
|
|
// their working package.
|
|
if SunSalutationStoredFrame(0) != 0 {
|
|
return -1
|
|
}
|
|
return MODULE_PRACTICE
|
|
}
|
|
if message.action == PRACTICE_HOME_VIEW {
|
|
WritePracticeHost(PracticeHomeView(message))
|
|
return 0
|
|
}
|
|
if message.action == PRACTICE_MANUAL_VIEW {
|
|
WritePracticeHost(PracticeManualView(message))
|
|
return 0
|
|
}
|
|
if message.action == PRACTICE_SETTINGS_VIEW {
|
|
WritePracticeHost(PracticeSettingsView(message))
|
|
return 0
|
|
}
|
|
if message.action == PRACTICE_AUDIO_VIEW {
|
|
WritePracticeHost(PracticeSessionAudioView(message))
|
|
return 0
|
|
}
|
|
if message.action == PRACTICE_RESULTS_VIEW {
|
|
WritePracticeHost(PracticeResultsView(message))
|
|
return 0
|
|
}
|
|
if message.action == PRACTICE_MEDITATION_VIEW {
|
|
WritePracticeHost(PracticeMeditationView(message))
|
|
return 0
|
|
}
|
|
if message.action == PRACTICE_PATTERNS_VIEW {
|
|
WritePracticeHost(PracticePatternsView(message))
|
|
return 0
|
|
}
|
|
if message.action == PRACTICE_WHM_VIEW {
|
|
WritePracticeHost(PracticeWhmView(message))
|
|
return 0
|
|
}
|
|
if message.action == PRACTICE_MOVEMENT_VIEW {
|
|
WritePracticeHost(PracticeMovementView(message))
|
|
return 0
|
|
}
|
|
if message.action == PRACTICE_COURSE_VIEW {
|
|
WritePracticeHost(PracticeCourseView(message))
|
|
return 0
|
|
}
|
|
WritePracticeHost(PracticeApply(message))
|
|
return 0
|
|
}
|