1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
//! Lifecycle of the loader for a windowed mission launch.
#[derive(Clone, Copy)]
pub(super) enum Stage {
Map = 1,
Scene,
Renderer,
}
#[derive(Default)]
pub(super) struct MissionLoading {
#[cfg(windows)]
window: Option<fparkan_platform_winit::startup_window::StartupWindow>,
#[cfg(not(windows))]
active: bool,
}
const STAGES: &[&str] = &[
"Чтение ресурсов миссии",
"Подготовка карты и материалов",
"Подготовка сцены и звука",
"Запуск Vulkan",
];
impl MissionLoading {
pub(super) fn start(mission: &str) -> Self {
#[cfg(windows)]
{
use fparkan_platform_winit::startup_window::StartupWindow;
let title = mission.parse::<usize>().map_or_else(
|_| mission.to_owned(),
|number| format!("FParkan · Миссия {number}"),
);
let window = StartupWindow::open(&title, STAGES)
.map_err(|error| eprintln!("startup window: {error}"))
.ok();
Self { window }
}
#[cfg(not(windows))]
{
eprintln!("{mission} — {}", STAGES[0]);
Self { active: true }
}
}
pub(super) fn stage(&self, stage: Stage) {
#[cfg(windows)]
if let Some(window) = &self.window {
window.set_stage(stage as usize);
}
#[cfg(not(windows))]
if self.active {
eprintln!("{}", STAGES[stage as usize]);
}
}
pub(super) fn window_visible(&self) -> bool {
#[cfg(windows)]
{
self.window.is_some()
}
#[cfg(not(windows))]
{
false
}
}
pub(super) fn finish(&mut self) {
*self = Self::default();
}
}
|