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