messing around with egui editor prototype
This commit is contained in:
parent
75ca8c84ea
commit
fd0f6ddb21
|
@ -4,7 +4,6 @@ use peachy::{Colour, Config, Game, Palette};
|
|||
|
||||
struct EditorState {
|
||||
game: Option<peachy::Game>,
|
||||
// selected_palette: Option<&Palette>,
|
||||
}
|
||||
|
||||
impl epi::App for EditorState {
|
||||
|
@ -37,21 +36,40 @@ impl epi::App for EditorState {
|
|||
// 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());
|
||||
egui::Window::new("palettes")
|
||||
.default_width(200.0)
|
||||
.collapsible(false)
|
||||
.show(ctx, |ui| {
|
||||
for palette in game.palettes.iter_mut() {
|
||||
ui.columns(2, |columns | {
|
||||
columns[0].label(&palette.name);
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
if columns[1].button("edit").clicked() {
|
||||
egui::Window::new(&palette.name)
|
||||
.default_width(200.0)
|
||||
.collapsible(true)
|
||||
.show(ctx, |ui| {
|
||||
for (i, colour) in palette.colours.iter().enumerate() {
|
||||
ui.columns(2, |row| {
|
||||
// todo edit each colour... this is broken
|
||||
row[0].color_edit_button_rgb(&mut [
|
||||
colour.red as f32,
|
||||
colour.green as f32,
|
||||
colour.blue as f32
|
||||
]);
|
||||
|
||||
if row[1].button("delete").clicked() {
|
||||
// can't alter palettes while iterating... what to do?
|
||||
// palette.colours.remove(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
// todo "add colour" button
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -93,7 +111,7 @@ fn main() {
|
|||
scenes: vec![],
|
||||
tiles: vec![],
|
||||
music: vec![]
|
||||
})
|
||||
}),
|
||||
};
|
||||
|
||||
let native_options = eframe::NativeOptions::default();
|
||||
|
|
Loading…
Reference in New Issue