My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/games/rstnode/rst-client/src/main.rs

70 lines
1.5 KiB

//! RST Node game client
// Remove the warning spam
#![allow(warnings)]
#[macro_use]
extern crate tracing;
mod assets;
mod cli;
mod color;
mod constants;
mod ctx;
mod editor;
mod error;
mod event;
mod graphics;
mod input;
mod log;
mod settings;
mod state;
mod ui;
mod viewport;
mod window;
use crate::{assets::Assets, window::Window};
pub(crate) use editor::*;
pub(crate) use event::*;
pub(crate) use settings::{GameSettings, GraphicsSettings, WindowSettings};
pub(crate) use state::*;
#[async_std::main]
async fn main() {
// Initialise default game settings
let mut settings = settings::default();
// Parse commandline arguments
cli::parse(&mut settings);
// Initialise logging mechanism
log::initialise();
// Initialise window context
let mut win = window::create(&settings);
// Load assets tree
let assets = assets::load_tree(win.ctx(), &settings)
.unwrap_or_else(|e| fatal!("Asset tree failed to load: {}!", e));
// Event system setup
event::setup();
match settings.editor {
true => run_editor(win, settings, assets),
false => run_game(win, settings, assets),
}
}
fn run_editor(win: Window, settings: GameSettings, assets: Assets) {
let state = EventLayer::new(EditorState::new(settings, assets));
win.run(state);
}
fn run_game(mut win: Window, settings: GameSettings, assets: Assets) {
let mut state = ClientState::new(settings, assets);
state.viewport().init(win.ctx());
let mut layer = EventLayer::new(state);
win.run(layer)
}