1pub mod third_party {
2 pub use anim8;
3 pub use anput;
4 pub use emergent;
5 pub use fontdue;
6 pub use getrandom;
7 pub use gilrs;
8 #[cfg(not(target_arch = "wasm32"))]
9 pub use glutin as windowing;
10 pub use image;
11 #[cfg(target_arch = "wasm32")]
12 pub use instant::Instant;
13 pub use intuicio_backend_vm;
14 pub use intuicio_core;
15 pub use intuicio_data;
16 pub use intuicio_derive;
17 pub use intuicio_frontend_simpleton;
18 pub use keket;
19 pub use kira;
20 pub use nodio;
21 pub use noise;
22 pub use rand;
23 pub use raui_core;
24 pub use raui_immediate;
25 pub use raui_immediate_widgets;
26 pub use rstar;
27 pub use serde;
28 pub use spitfire_core;
29 pub use spitfire_draw;
30 pub use spitfire_fontdue;
31 pub use spitfire_glow;
32 pub use spitfire_gui;
33 pub use spitfire_input;
34 #[cfg(not(target_arch = "wasm32"))]
35 pub use std::time::Instant;
36 pub use toml;
37 pub use typid;
38 pub use vek;
39 #[cfg(target_arch = "wasm32")]
40 pub use winit as windowing;
41}
42
43pub mod animation;
44pub mod assets;
45pub mod audio;
46pub mod character;
47pub mod config;
48pub mod context;
49pub mod game;
50pub mod gamepad;
51pub mod grid_world;
52pub mod pcg;
53pub mod scripting;
54pub mod tag;
55
56use config::Config;
57use game::GameInstance;
58use spitfire_draw::utils::Vertex;
59use spitfire_glow::app::App;
60use std::{error::Error, path::Path};
61
62pub struct GameLauncher {
63 instance: GameInstance,
64 title: String,
65 config: Config,
66}
67
68impl GameLauncher {
69 pub fn new(instance: GameInstance) -> Self {
70 Self {
71 instance,
72 title: "MicroGamesKit".to_owned(),
73 config: Config::default(),
74 }
75 }
76
77 pub fn title(mut self, title: impl ToString) -> Self {
78 self.title = title.to_string();
79 self
80 }
81
82 pub fn config(mut self, config: Config) -> Self {
83 self.config = config;
84 self
85 }
86
87 pub fn load_config_from_file(
88 mut self,
89 config: impl AsRef<Path>,
90 ) -> Result<Self, Box<dyn Error>> {
91 self.config = Config::load_from_file(config)?;
92 Ok(self)
93 }
94
95 pub fn load_config_from_str(mut self, config: &str) -> Result<Self, Box<dyn Error>> {
96 self.config = Config::load_from_str(config)?;
97 Ok(self)
98 }
99
100 pub fn run(self) {
101 #[cfg(debug_assertions)]
102 spitfire_glow::console_log!("* Game {:#?}", self.config);
103 App::<Vertex>::new(self.config.to_app_config(self.title)).run(self.instance);
104 }
105}