aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index a72b172..11cdcfe 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,5 @@
+pub mod button;
+pub mod config;
pub mod editor;
pub mod grid;
pub mod map_data;
@@ -6,15 +8,39 @@ pub mod svg;
pub mod tool;
pub mod transform;
+use config::Config;
use editor::Editor;
use raylib::prelude::*;
+use std::io;
use transform::Transform;
+pub const CONFIG_FILE: &str = "config.ron";
+
fn main() {
let (mut rl, thread) = raylib::init().resizable().title("Hello there!").build();
rl.set_target_fps(120);
- let mut editor = Editor::new(&mut rl, &thread);
+ // Load the configuration file, if available.
+ let config = match Config::from_file(CONFIG_FILE) {
+ Ok(config) => config,
+ Err(err) => {
+ /* Create a default config file if it doesn't exist, otherwise leave the incorrectly
+ * formatted/corrupted or otherwise unreadable file alone.
+ */
+ let config = Config::default();
+ if err.kind() == io::ErrorKind::NotFound {
+ println!("Could not find a configuration file. Creating default.");
+ config.write_file(CONFIG_FILE);
+ } else {
+ println!("Could not read configuration file: {}", err);
+ println!("Using defaults for this run.");
+ }
+
+ config
+ }
+ };
+
+ let mut editor = Editor::new(&mut rl, &thread, config);
let mut transform = Transform::new();
let mut last_mouse_pos = rl.get_mouse_position();