This is going to be the last wad info window thingy
Going to remove it to focus on something more interesting Or at least more achievable
This commit is contained in:
25
src/main.rs
25
src/main.rs
@@ -1,4 +1,5 @@
|
||||
use config::{default_save_filename, load_config, save_config, Config};
|
||||
use wad::get_summary;
|
||||
use eframe::egui;
|
||||
use eframe::egui::Color32;
|
||||
use infos::{
|
||||
@@ -38,6 +39,7 @@ struct RustDoomLauncher {
|
||||
config_filename: PathBuf,
|
||||
config: Option<Config>,
|
||||
config_tried: bool,
|
||||
wad_summary: String,
|
||||
command_manager: CommandManager,
|
||||
display_command: bool,
|
||||
add_stuff_window_displayed: bool,
|
||||
@@ -58,6 +60,7 @@ impl Default for RustDoomLauncher {
|
||||
config_filename: default_save_filename(),
|
||||
config: None, // TODO: put the config_filename in the config stuct - or something
|
||||
config_tried: false,
|
||||
wad_summary: "".to_string(),
|
||||
display_command: false,
|
||||
add_stuff_window_displayed: false,
|
||||
selected_file_type: FileType::Pwad,
|
||||
@@ -79,11 +82,16 @@ impl RustDoomLauncher {
|
||||
if let Some(config) = &self.config {
|
||||
if let Some(iwads) = &config.iwads {
|
||||
for iwad in iwads {
|
||||
let mut iwad = iwad.clone();
|
||||
iwad.info_text = Some("I'm sure you know what's in that bloody IWAD".to_string());
|
||||
self.iwad_manager.add(&iwad);
|
||||
}
|
||||
}
|
||||
if let Some(pwads) = &config.pwads {
|
||||
for pwad in pwads {
|
||||
let mut pwad = pwad.clone();
|
||||
pwad.info_text = get_summary(&pwad.path);
|
||||
println!("{:?}", pwad);
|
||||
self.pwad_manager.add(&pwad.clone());
|
||||
}
|
||||
}
|
||||
@@ -205,15 +213,16 @@ impl eframe::App for RustDoomLauncher {
|
||||
ui.label("IWADs");
|
||||
let mut remove_pos: Option<usize> = None;
|
||||
let mut add_pos: Option<usize> = None;
|
||||
for (launcher, pos, selected) in
|
||||
for (iwad, pos, selected) in
|
||||
self.iwad_manager.iter_selectable_with_pos_and_selected()
|
||||
{
|
||||
ui.horizontal(|ui| {
|
||||
if ui
|
||||
.add(egui::SelectableLabel::new(selected, &launcher.name))
|
||||
.add(egui::SelectableLabel::new(selected, &iwad.name))
|
||||
.clicked()
|
||||
{
|
||||
add_pos = Some(pos);
|
||||
self.wad_summary = iwad.info_text.as_ref().unwrap().clone();
|
||||
}
|
||||
if ui.button("❌").clicked() {
|
||||
remove_pos = Some(pos);
|
||||
@@ -247,6 +256,9 @@ impl eframe::App for RustDoomLauncher {
|
||||
.clicked()
|
||||
{
|
||||
add_pos = Some(pos);
|
||||
if let Some(txt) = pwad.info_text.clone() {
|
||||
self.wad_summary = txt;
|
||||
}
|
||||
}
|
||||
if ui.button("❌").clicked() {
|
||||
remove_pos = Some(pos);
|
||||
@@ -264,12 +276,12 @@ impl eframe::App for RustDoomLauncher {
|
||||
.add_pwads(&self.pwad_manager.get_current())
|
||||
}
|
||||
});
|
||||
let mut text = "Placeholder for WAD info stuffs";
|
||||
let window_size = frame.info().window_info.size;
|
||||
ui.set_max_height(300.0);
|
||||
ui.add(
|
||||
egui::TextEdit::multiline(&mut text)
|
||||
egui::TextEdit::multiline(&mut self.wad_summary)
|
||||
.desired_width(window_size[0] / 1.6)
|
||||
.desired_rows(20),
|
||||
.desired_rows(20)
|
||||
);
|
||||
});
|
||||
ui.separator();
|
||||
@@ -465,17 +477,20 @@ impl eframe::App for RustDoomLauncher {
|
||||
if self.add_name.is_empty() || self.selected_file_path.as_os_str().is_empty() {
|
||||
return;
|
||||
}
|
||||
let info_text = get_summary(&self.selected_file_path);
|
||||
match self.selected_file_type {
|
||||
FileType::Iwad => {
|
||||
self.iwad_manager.add(&WadInfo {
|
||||
name: self.add_name.clone(),
|
||||
path: self.selected_file_path.clone(),
|
||||
info_text: Some("I'm sure you know what's in that bloody IWAD!".to_string()),
|
||||
});
|
||||
}
|
||||
FileType::Pwad => {
|
||||
self.pwad_manager.add(&WadInfo {
|
||||
name: self.add_name.clone(),
|
||||
path: self.selected_file_path.clone(),
|
||||
info_text: info_text,
|
||||
});
|
||||
}
|
||||
FileType::Launcher => {
|
||||
|
||||
Reference in New Issue
Block a user