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
#[macro_use]
extern crate anyhow;
#[macro_use]
extern crate log;

mod after_level;
mod animation;
mod before_level;
mod buildings;
mod controls;
mod game;
mod levels;
mod meters;
mod music;
mod player;
mod session;
mod title;
mod vehicles;

type App = map_gui::SimpleApp<session::Session>;
type Transition = widgetry::Transition<App>;

pub fn main() {
    widgetry::run(
        widgetry::Settings::new("15-minute Santa").read_svg(Box::new(abstio::slurp_bytes)),
        |ctx| {
            let mut opts = map_gui::options::Options::default();
            opts.color_scheme = map_gui::colors::ColorSchemeChoice::NightMode;
            let session = session::Session::load();
            session.save();

            map_gui::SimpleApp::new(ctx, opts, session, |ctx, app| {
                if app.opts.dev {
                    app.session.unlock_all();
                }
                app.session.music =
                    music::Music::start(ctx, app.session.play_music, "jingle_bells");
                app.session.music.specify_volume(music::OUT_OF_GAME);

                vec![title::TitleScreen::new(ctx, app)]
            })
        },
    );
}

#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen(start)]
pub fn run() {
    main();
}