diff --git a/src/sk_editor.rs b/src/sk_editor.rs index 04aa18e..e525077 100644 --- a/src/sk_editor.rs +++ b/src/sk_editor.rs @@ -19,6 +19,32 @@ */ +extern crate eframe; + +mod sk_editor_base; + +use eframe::egui; + +static SK_EDITOR_NAME: &str = "sparky::editor"; + fn main() { - println!("Hello, World!"); + println!("INFO: Initializing {}", SK_EDITOR_NAME); + let win_icon = image::open("assets/icon.png").expect("ERROR: Failed to open icon path").to_rgba8(); + let (win_icon_width, win_icon_height) = win_icon.dimensions(); + eframe::run_native( + SK_EDITOR_NAME, + eframe::NativeOptions { + viewport: egui::ViewportBuilder::default() + .with_inner_size([800.0, 600.0]) + .with_min_inner_size([800.0, 600.0]) + .with_icon(egui::IconData { + rgba: win_icon.into_raw(), + width: win_icon_width, + height: win_icon_height + }), + ..Default::default() + }, + Box::new(|_| Box::new(sk_editor_base::Editor::default()) as Box) + ).expect("Unexpected error. Shutting down..."); + println!("INFO: {} closed successfully", SK_EDITOR_NAME); } diff --git a/src/sk_editor_base.rs b/src/sk_editor_base.rs new file mode 100644 index 0000000..9870961 --- /dev/null +++ b/src/sk_editor_base.rs @@ -0,0 +1,46 @@ +/* + * GNU Sparky --- A 5v5 character-based libre tactical shooter + * Copyright (C) 2024 Wasym A. Alonso + * + * This file is part of Sparky. + * + * Sparky is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Sparky is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Sparky. If not, see . + */ + + +use egui; +use SK_EDITOR_NAME; + +pub struct Editor { + pub curr_tab: String +} + +impl Default for Editor { + fn default() -> Self { + Self { + curr_tab: "Map".to_owned() + } + } +} + +impl eframe::App for Editor { + fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { + egui::TopBottomPanel::top(SK_EDITOR_NAME).show(ctx, |ui| { + ui.horizontal(|ui| { + egui::widgets::global_dark_light_mode_switch(ui); + ui.separator(); + }); + }); + } +}