Skip to content

Commit

Permalink
Update layout of the project config window
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Nov 26, 2023
1 parent 0e5d61f commit ebb92c3
Showing 1 changed file with 48 additions and 46 deletions.
94 changes: 48 additions & 46 deletions crates/ui/src/windows/config_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ impl Window {}

impl luminol_core::Window for Window {
fn name(&self) -> String {
"Local Luminol Config".to_string()
"Luminol Project Config".to_string()
}

fn id(&self) -> egui::Id {
egui::Id::new("Local Luminol Config")
egui::Id::new("Luminol Project Config")
}

fn show(
Expand All @@ -51,60 +51,62 @@ impl luminol_core::Window for Window {
};

egui::Window::new(self.name()).open(open).show(ctx, |ui| {
ui.label("Project name");
ui.text_edit_singleline(&mut config.project.project_name);
// FIXME something something redundancy
ui.label("Scripts path");
if ui
.text_edit_singleline(&mut config.project.scripts_path)
.changed()
{
config
.game_ini
.general_section_mut()
.insert("Scripts", config.project.scripts_path.clone());
}
ui.checkbox(
&mut config.project.use_ron,
"Use RON (Rusty Object Notation)",
);
egui::ComboBox::from_label("RGSS Version")
.selected_text(config.project.rgss_ver.to_string())
.show_ui(ui, |ui| {
for ver in luminol_config::RGSSVer::iter() {
ui.selectable_value(&mut config.project.rgss_ver, ver, ver.to_string());
}
});

ui.label("Playtest Executable");
ui.text_edit_singleline(&mut config.project.playtest_exe);

ui.separator();
ui.label("Editor Settings");

ui.group(|ui| {
ui.label("Project name");
ui.text_edit_singleline(&mut config.project.project_name);
ui.label("Scripts path (editor)");
ui.text_edit_singleline(&mut config.project.scripts_path);
ui.label("Playtest Executable");
ui.text_edit_singleline(&mut config.project.playtest_exe);

ui.separator();

ui.checkbox(
&mut config.project.use_ron,
"Use RON (Rusty Object Notation)",
);
ui.separator();

egui::ComboBox::from_label("RGSS Version")
.selected_text(config.project.rgss_ver.to_string())
.show_ui(ui, |ui| {
for ver in luminol_config::RGSSVer::iter() {
ui.selectable_value(&mut config.project.rgss_ver, ver, ver.to_string());
}
});
});

ui.label("Game.ini settings");
ui.separator();

// rust-ini doesn't provide any kind of API for mutably accessing properties, so this is the best we can do.
// we temporarily remove the properties from the game ini and then re-insert it after we're done editing it.
let general_section = config.game_ini.general_section_mut();
ui.group(|ui| {
// rust-ini doesn't provide any kind of API for mutably accessing properties, so this is the best we can do.
// we temporarily remove the properties from the game ini and then re-insert it after we're done editing it.
let general_section = config.game_ini.general_section_mut();

let mut game_title = general_section.remove("Title").unwrap_or_default();
ui.horizontal(|ui| {
let mut game_title = general_section.remove("Title").unwrap_or_default();
ui.label("Title");
ui.text_edit_singleline(&mut game_title);
});
general_section.insert("Title", game_title);
general_section.insert("Title", game_title);

ui.separator();
ui.separator();

for rtp in ["RTP1", "RTP2", "RTP3"] {
let mut rtp_name = general_section.remove(rtp).unwrap_or_default();
ui.horizontal(|ui| {
for rtp in ["RTP1", "RTP2", "RTP3"] {
let mut rtp_name = general_section.remove(rtp).unwrap_or_default();
ui.label(rtp);
ui.text_edit_singleline(&mut rtp_name);
});
general_section.insert(rtp, rtp_name);
}
general_section.insert(rtp, rtp_name);
}

ui.separator();

let mut scripts_path = general_section.remove("Scripts").unwrap_or_default();

ui.label("Scripts path (runtime)");
ui.text_edit_singleline(&mut scripts_path);
general_section.insert("Scripts", scripts_path);
});
});
}

Expand Down

0 comments on commit ebb92c3

Please sign in to comment.