From d46ac1223f4a6c33ef53b699be7dbb3c1052442b Mon Sep 17 00:00:00 2001 From: Lily Lyons Date: Thu, 23 Nov 2023 23:34:21 -0800 Subject: [PATCH] Add global config window --- crates/ui/src/windows/global_config_window.rs | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/crates/ui/src/windows/global_config_window.rs b/crates/ui/src/windows/global_config_window.rs index e8fa7ddd..b33fb998 100644 --- a/crates/ui/src/windows/global_config_window.rs +++ b/crates/ui/src/windows/global_config_window.rs @@ -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 { @@ -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::>(); + + 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; + }); + }); } }