Skip to content

Commit

Permalink
Basic egui window for the sk_editor
Browse files Browse the repository at this point in the history
  • Loading branch information
iWas-Coder committed May 18, 2024
1 parent c7b1507 commit da1468f
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/sk_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn eframe::App>)
).expect("Unexpected error. Shutting down...");
println!("INFO: {} closed successfully", SK_EDITOR_NAME);
}
46 changes: 46 additions & 0 deletions src/sk_editor_base.rs
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/


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();
});
});
}
}

0 comments on commit da1468f

Please sign in to comment.