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,24 +96,30 @@ impl eframe::App for PakExplorer {
"None".to_string() "None".to_string()
}; };
egui::ComboBox::from_id_source("my-combobox") ui.horizontal(|ui| {
.selected_text(selection) egui::ComboBox::from_id_source("my-combobox")
.truncate() .selected_text(selection.clone())
.show_ui(ui, |ui| { .truncate()
ui.selectable_value(&mut self.selected_entry, None, ""); .show_ui(ui, |ui| {
for entry in pak.entries() { ui.selectable_value(&mut self.selected_entry, None, "");
if ui for entry in pak.entries() {
.selectable_value( if ui
&mut self.selected_entry, .selectable_value(
Some(entry.clone()), &mut self.selected_entry,
entry.display_name(), Some(entry.clone()),
) format!("{} - {}", entry.display_name(), entry.id()),
.clicked() )
{ .clicked()
self.image_texture = None; {
}; self.image_texture = None;
} };
}); }
});
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"));
} }