diff --git a/mp2.xml b/mp2.xml index 511d9e0..807bf9d 100644 --- a/mp2.xml +++ b/mp2.xml @@ -1,7 +1,7 @@ - 1970-01-01T03:00:00+03:00 - - - + 1970-01-01T03:00:00+03:00 + + + diff --git a/src/gui/mod.rs b/src/gui/mod.rs index e69de29..a29e4e7 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -0,0 +1,76 @@ + + +struct MyApp { + selected: String, + presets: Vec, +} + +impl Default for MyApp { + fn default() -> Self { + Self { + selected: String::new(), + presets: Vec::new(), + } + } +} + +impl eframe::App for MyApp { + fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { + egui::CentralPanel::default().show(ctx, |ui| { + + if self.presets.is_empty() { + let home_dir = std::env::var("HOME").expect("HOME environment variable not set"); + + let steamapps_dir = std::path::PathBuf::from(home_dir).join(".steam/debian-installation/steamapps"); + let preset_dir = steamapps_dir + .join("compatdata") + .join("107410") + .join("pfx") + .join("drive_c") + .join("users") + .join("steamuser") + .join("AppData") + .join("Local") + .join("Arma 3 Launcher") + .join("Presets"); + + if let Ok(entries) = std::fs::read_dir(preset_dir) { + self.presets = entries + .filter_map(|entry| entry.ok()) + .filter_map(|entry| entry.file_name().into_string().ok()) + .collect(); + } + } + + egui::ComboBox::from_label("Select Preset") + .selected_text(&self.selected) + .show_ui(ui, |ui| { + for preset in &self.presets { + ui.selectable_value(&mut self.selected, preset.clone(), preset); + } + }); + + if ui.button("skibidi").clicked() { + println!("Selected preset: {}", self.selected); + } + }); + } +} + +pub fn gui_start() -> anyhow::Result<()> { + let options = eframe::NativeOptions { + viewport: egui::ViewportBuilder::default().with_inner_size([900.0, 540.0]), + ..Default::default() + }; + + eframe::run_native( + "a3lrs", + options, + Box::new(|cc| { + egui_extras::install_image_loaders(&cc.egui_ctx); + Ok(Box::::default()) + }), + ).unwrap(); + + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index ec2139b..a8ab9bd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,10 @@ use std::path::Path; -fn main() { +fn main() -> anyhow::Result<()> { a3l_rs::modpack::internal::MPInt::default().write(Path::new("./mp2.xml")); let mp = a3l_rs::modpack::internal::MPInt::parse(Path::new("./mp.xml")); dbg!(mp); + + a3l_rs::gui::gui_start()?; + Ok(()) }