Added display of ID and Index when viewing entry

This commit is contained in:
G2-Games 2024-09-17 14:22:00 -05:00
parent 6ab957c243
commit c6404f6a09

View file

@ -20,7 +20,9 @@ fn main() -> eframe::Result {
eframe::run_native( eframe::run_native(
"LUCA PAK Explorer", "LUCA PAK Explorer",
options, options,
Box::new(|_ctx| { Box::new(|ctx| {
let ppp = ctx.egui_ctx.pixels_per_point() * 1.5;
ctx.egui_ctx.set_pixels_per_point(ppp);
Ok(Box::<PakExplorer>::default()) Ok(Box::<PakExplorer>::default())
}), }),
) )
@ -29,6 +31,7 @@ fn main() -> eframe::Result {
struct PakExplorer { struct PakExplorer {
open_file: Option<Pak>, open_file: Option<Pak>,
selected_entry: Option<luca_pak::entry::Entry>, selected_entry: Option<luca_pak::entry::Entry>,
entry_text: String,
image_texture: Option<egui::TextureHandle>, image_texture: Option<egui::TextureHandle>,
hex_string: Option<Vec<String>>, hex_string: Option<Vec<String>>,
} }
@ -40,6 +43,7 @@ impl Default for PakExplorer {
selected_entry: None, selected_entry: None,
image_texture: None, image_texture: None,
hex_string: None, hex_string: None,
entry_text: String::new(),
} }
} }
} }
@ -47,7 +51,6 @@ impl Default for PakExplorer {
impl eframe::App for PakExplorer { impl eframe::App for PakExplorer {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
ctx.set_pixels_per_point(1.5);
ui.heading("PAK File Explorer"); ui.heading("PAK File Explorer");
ui.horizontal(|ui| { ui.horizontal(|ui| {
@ -93,8 +96,9 @@ impl eframe::App for PakExplorer {
"None".to_string() "None".to_string()
}; };
ui.horizontal(|ui| {
egui::ComboBox::from_id_source("my-combobox") egui::ComboBox::from_id_source("my-combobox")
.selected_text(selection) .selected_text(selection.clone())
.truncate() .truncate()
.show_ui(ui, |ui| { .show_ui(ui, |ui| {
ui.selectable_value(&mut self.selected_entry, None, ""); ui.selectable_value(&mut self.selected_entry, None, "");
@ -103,7 +107,7 @@ impl eframe::App for PakExplorer {
.selectable_value( .selectable_value(
&mut self.selected_entry, &mut self.selected_entry,
Some(entry.clone()), Some(entry.clone()),
entry.display_name(), format!("{} - {}", entry.display_name(), entry.id()),
) )
.clicked() .clicked()
{ {
@ -111,6 +115,11 @@ impl eframe::App for PakExplorer {
}; };
} }
}); });
if let Some(entry) = &self.selected_entry {
ui.label(format!("Index {}, ID {}", entry.index(), entry.id()));
}
});
} else { } else {
ui.centered_and_justified(|ui| ui.label("No File Opened")); ui.centered_and_justified(|ui| ui.label("No File Opened"));
} }