sinfar-installer/rust/src/ui/game_selection.rs
2025-04-23 16:34:35 -04:00

38 lines
1.3 KiB
Rust

pub mod game_selection {
use eframe::egui::Ui;
use crate::app::{SinfarInstallerApp, GameType};
use std::sync::Once;
static INIT: Once = Once::new();
pub fn render(ui: &mut Ui, app: &mut SinfarInstallerApp) {
INIT.call_once(|| {
print_selected_game_type(&app.game_type);
});
ui.heading("Select your game's version:");
ui.add_space(10.0);
ui.vertical(|ui| {
if ui.radio_value(&mut app.game_type, Some(GameType::Diamond), "Neverwinter Nights Diamond Edition").clicked() {
// Handle selection
print_selected_game_type(&app.game_type);
}
if ui.radio_value(&mut app.game_type, Some(GameType::EnhancedEdition), "Neverwinter Nights: Enhanced Edition").clicked() {
// Handle selection
print_selected_game_type(&app.game_type);
}
});
}
fn print_selected_game_type(game_type: &Option<GameType>){
match game_type {
Some(game_type_ref) => match game_type_ref {
GameType::Diamond => println!("Diamond Edition selected"),
GameType::EnhancedEdition => println!("Enhanced Edition selected"),
},
None => println!("No game selected. (If you see this.. you fucked up.)"),
}
}
}