Initial Commit

This commit is contained in:
2023-05-31 22:08:51 +01:00
commit 0ea24dd987
3 changed files with 64 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

9
Cargo.toml Normal file
View File

@@ -0,0 +1,9 @@
[package]
name = "rdl"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
eframe = "0.21.3"

54
src/main.rs Normal file
View File

@@ -0,0 +1,54 @@
use eframe::egui;
fn main() -> Result<(), eframe::Error> {
println!("Hello, world!");
let options = eframe::NativeOptions {
..Default::default()
};
eframe::run_native(
"Rust Doom Launcher",
options,
Box::new(|_cc| Box::<RustDoomLauncher>::default()),
)
}
struct RustDoomLauncher {
launchers: Vec<String>,
all_iwads: Vec<String>,
all_pwads: Vec<String>,
selected_iwad: Option<String>,
selected_pwads: Vec<String>,
}
impl Default for RustDoomLauncher {
fn default() -> Self {
Self {
launchers: Vec::new(),
all_iwads: vec!["DOOM2.WAD".to_string(), "DOOM.WAD".to_string(), "FREEDOOM.WAD".to_string()],
all_pwads: Vec::new(),
selected_iwad: None,
selected_pwads: Vec::new(),
}
}
}
impl eframe::App for RustDoomLauncher {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::containers::panel::CentralPanel::default().show(ctx, |ui| {
ui.heading("RustDoomLauncher");
ui.horizontal(|ui| {
ui.label("IWADs");
if ui.button("Add IWAD").clicked() {
// Open file selector
// Add to the IWADS list
// done?
}
});
for iwad in &self.all_iwads {
if ui.add(egui::SelectableLabel::new(self.selected_iwad.is_some() && self.selected_iwad.as_ref().unwrap() == iwad, iwad)).clicked() {
self.selected_iwad = Some(iwad.to_string());
}
}
});
}
}