Skip to content

Commit

Permalink
Add global config window
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Nov 24, 2023
1 parent 6fd75f6 commit d46ac12
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions crates/ui/src/windows/global_config_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@
// terms of the Steamworks API by Valve Corporation, the licensors of this
// Program grant you additional permission to convey the resulting work.

use std::ops::Not;

#[derive(Default)]
pub struct Window {}
pub struct Window {
edit_rtp_path_name: String,
edit_rtp_path_path: String,
}

impl luminol_core::Window for Window {
fn name(&self) -> String {
Expand All @@ -40,6 +45,46 @@ impl luminol_core::Window for Window {
open: &mut bool,
update_state: &mut luminol_core::UpdateState<'_>,
) {
egui::Window::new(self.name()).open(open).show(ctx, |ui| {});
egui::Window::new(self.name()).open(open).show(ctx, |ui| {
ui.label("RTP Paths");
ui.separator();

ui.columns(2, |columns| {
let mut new_rtp_paths = update_state
.global_config
.rtp_paths
.drain()
.filter_map(|(mut rtp_name, mut rtp_path)| {
columns[0].text_edit_singleline(&mut rtp_name);
columns[1]
.horizontal(|ui| {
ui.text_edit_singleline(&mut rtp_path);
ui.button(egui::RichText::new("-").color(egui::Color32::RED))
.clicked()
.not()
.then_some((rtp_name, rtp_path))
})
.inner
})
.collect::<std::collections::HashMap<_, _>>();

columns[0].text_edit_singleline(&mut self.edit_rtp_path_name);
columns[1].horizontal(|ui| {
ui.text_edit_singleline(&mut self.edit_rtp_path_path);

if ui
.button(egui::RichText::new("+").color(egui::Color32::GREEN))
.clicked()
{
new_rtp_paths.insert(
std::mem::take(&mut self.edit_rtp_path_name),
std::mem::take(&mut self.edit_rtp_path_path),
);
}
});

update_state.global_config.rtp_paths = new_rtp_paths;
});
});
}
}

0 comments on commit d46ac12

Please sign in to comment.