WIP editor attempts (broken...)
This commit is contained in:
parent
946f8b7826
commit
4dd334d6a4
|
@ -10,6 +10,9 @@ keywords = ["game-engine", "smallgames", "pixel-art", "tracker-music"]
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
eframe = "^0.12.0"
|
||||
egui = "^0.12.0"
|
||||
epi = "^0.12.0"
|
||||
env_logger = "0.8.3"
|
||||
hex = "^0.4.3"
|
||||
image = "0.23.14"
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
use eframe::epi::Frame;
|
||||
use eframe::egui::CtxRef;
|
||||
use peachy::{Colour, Config, Game, Palette};
|
||||
|
||||
struct EditorState {
|
||||
game: Option<peachy::Game>,
|
||||
// selected_palette: Option<&Palette>,
|
||||
}
|
||||
|
||||
impl epi::App for EditorState {
|
||||
fn update(&mut self, ctx: &CtxRef, frame: &mut Frame<'_>) {
|
||||
egui::TopPanel::top("top_panel").show(ctx, |ui| {
|
||||
egui::menu::bar(ui, |ui| {
|
||||
egui::menu::menu(ui, "File", |ui| {
|
||||
if ui.button("Quit").clicked() {
|
||||
frame.quit();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
egui::SidePanel::left("side_panel", 200.0).show(ctx, |ui| {
|
||||
ui.heading("Side Panel");
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Blah blah…");
|
||||
});
|
||||
|
||||
// if let Some(game) = &mut self.game {
|
||||
// // todo colour picker
|
||||
// // todo tool picker
|
||||
// // todo collapsing panels for different things? buttons to launch browse windows?
|
||||
// }
|
||||
});
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
// todo if game is none, add a "load project" window?
|
||||
|
||||
if let Some(game) = &mut self.game {
|
||||
// for palette in &mut game.palettes {
|
||||
// }
|
||||
// todo store selected palette in application state
|
||||
// todo show palette window if selected
|
||||
let palette = game.find_palette("example palette".into());
|
||||
|
||||
if let Some(palette) = palette {
|
||||
egui::Window::new(&palette.name)
|
||||
.default_width(200.0)
|
||||
.collapsible(false)
|
||||
.show(ctx, |ui| {
|
||||
ui.label("palette name");
|
||||
ui.text_edit_singleline(&mut palette.name);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
"peachy"
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// testing…
|
||||
let state = EditorState {
|
||||
game: Some(Game {
|
||||
config: Config {
|
||||
name: Some("example".into()),
|
||||
width: 16,
|
||||
height: 9,
|
||||
tick: 400,
|
||||
starting_room: None,
|
||||
version: (0, 1)
|
||||
},
|
||||
entities: vec![],
|
||||
images: vec![],
|
||||
palettes: vec![
|
||||
Palette { name: "example palette".into(), colours: vec![
|
||||
Colour { red: 79, green: 30, blue: 69 },
|
||||
Colour { red: 150, green: 48, blue: 87 },
|
||||
Colour { red: 215, green: 68, blue: 89 },
|
||||
Colour { red: 235, green: 112, blue: 96 },
|
||||
Colour { red: 255, green: 179, blue: 131 },
|
||||
Colour { red: 255, green: 255, blue: 255 },
|
||||
Colour { red: 127, green: 227, blue: 187 },
|
||||
Colour { red: 92, green: 187, blue: 196 },
|
||||
Colour { red: 69, green: 126, blue: 163 },
|
||||
Colour { red: 56, green: 66, blue: 118 },
|
||||
Colour { red: 50, green: 36, blue: 81 }
|
||||
]},
|
||||
],
|
||||
scenes: vec![],
|
||||
tiles: vec![],
|
||||
music: vec![]
|
||||
})
|
||||
};
|
||||
|
||||
let native_options = eframe::NativeOptions::default();
|
||||
|
||||
eframe::run_native(Box::new(state), native_options);
|
||||
}
|
Loading…
Reference in New Issue