From 8aceecf04544c51f52469bb44885fad98678942b Mon Sep 17 00:00:00 2001 From: xomf Date: Thu, 16 Jan 2025 16:34:02 -0500 Subject: [PATCH] nyaaa~ :3 --- src/main.rs | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index e7a11a9..e63408f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,81 @@ -fn main() { - println!("Hello, world!"); +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +use eframe::egui; +use std::env; +use std::fs; +use std::path::PathBuf; + +fn main() -> eframe::Result { + env_logger::init(); + + 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()) + }), + ) +} + +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 = env::var("HOME").expect("HOME environment variable not set"); + + let steamapps_dir = 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) = 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); + } + }); + } }