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 rusty_spine;
28 pub use serde;
29 pub use spitfire_core;
30 pub use spitfire_draw;
31 pub use spitfire_fontdue;
32 pub use spitfire_glow;
33 pub use spitfire_gui;
34 pub use spitfire_input;
35 #[cfg(not(target_arch = "wasm32"))]
36 pub use std::time::Instant;
37 pub use toml;
38 pub use typid;
39 pub use vek;
40 #[cfg(target_arch = "wasm32")]
41 pub use winit as windowing;
42}
43
44pub mod animation;
45pub mod assets;
46pub mod audio;
47pub mod character;
48pub mod config;
49pub mod context;
50pub mod game;
51pub mod gamepad;
52pub mod grid_world;
53pub mod pcg;
54pub mod scripting;
55pub mod tag;
56
57use config::Config;
58use game::GameInstance;
59use spitfire_draw::utils::Vertex;
60use spitfire_glow::app::App;
61use std::{error::Error, path::Path};
62
63pub struct GameLauncher {
64 instance: GameInstance,
65 title: String,
66 config: Config,
67}
68
69impl GameLauncher {
70 pub fn new(instance: GameInstance) -> Self {
71 Self {
72 instance,
73 title: "MicroGamesKit".to_owned(),
74 config: Config::default(),
75 }
76 }
77
78 pub fn title(mut self, title: impl ToString) -> Self {
79 self.title = title.to_string();
80 self
81 }
82
83 pub fn config(mut self, config: Config) -> Self {
84 self.config = config;
85 self
86 }
87
88 pub fn load_config_from_file(
89 mut self,
90 config: impl AsRef<Path>,
91 ) -> Result<Self, Box<dyn Error>> {
92 self.config = Config::load_from_file(config)?;
93 Ok(self)
94 }
95
96 pub fn load_config_from_str(mut self, config: &str) -> Result<Self, Box<dyn Error>> {
97 self.config = Config::load_from_str(config)?;
98 Ok(self)
99 }
100
101 pub fn run(self) {
102 #[cfg(debug_assertions)]
103 spitfire_glow::console_log!("* Game {:#?}", self.config);
104 App::<Vertex>::new(self.config.to_app_config(self.title)).run(self.instance);
105 }
106}