From 953e95d7b4261be43f0e827c89f0c3240efb57e9 Mon Sep 17 00:00:00 2001 From: rfuzzo Date: Sun, 4 Jun 2023 14:59:09 +0200 Subject: [PATCH] fixes, update tes3 lib closes #3 --- Cargo.lock | 41 +++++++++++--------- Cargo.toml | 2 +- src/lib.rs | 70 +++++++++++++++++----------------- src/views/records_list_view.rs | 52 ++++++++++++++----------- 4 files changed, 88 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7678135..31e2704 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,6 +34,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.8.3" @@ -247,13 +258,13 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "bytes_io" version = "0.0.1" -source = "git+https://github.com/rfuzzo/tes3?branch=egui_temp#1de8e9a776768d222e9bd1adfeff4380bd8f5367" +source = "git+https://github.com/rfuzzo/tes3?branch=egui_temp#7c3d9988084242ce2c5abfb05cdbd314772f7f0d" dependencies = [ "bstr", "bytemuck", "bytes_io_macros", "encoding_rs", - "hashbrown 0.13.2", + "hashbrown", "memchr", "smart-default 0.6.0", ] @@ -261,7 +272,7 @@ dependencies = [ [[package]] name = "bytes_io_macros" version = "0.0.1" -source = "git+https://github.com/rfuzzo/tes3?branch=egui_temp#1de8e9a776768d222e9bd1adfeff4380bd8f5367" +source = "git+https://github.com/rfuzzo/tes3?branch=egui_temp#7c3d9988084242ce2c5abfb05cdbd314772f7f0d" dependencies = [ "quote", "syn 2.0.18", @@ -630,7 +641,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3aef8ec3ae1b772f340170c65bf27d5b8c28f543a0116c844d2ac08d01123e7" dependencies = [ "accesskit", - "ahash", + "ahash 0.8.3", "epaint", "log", "nohash-hasher", @@ -721,7 +732,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09333964d4d57f40a85338ba3ca5ed4716070ab184dcfed966b35491c5c64f3b" dependencies = [ "ab_glyph", - "ahash", + "ahash 0.8.3", "atomic_refcell", "bytemuck", "ecolor", @@ -766,7 +777,7 @@ dependencies = [ [[package]] name = "esp" version = "0.0.1" -source = "git+https://github.com/rfuzzo/tes3?branch=egui_temp#1de8e9a776768d222e9bd1adfeff4380bd8f5367" +source = "git+https://github.com/rfuzzo/tes3?branch=egui_temp#7c3d9988084242ce2c5abfb05cdbd314772f7f0d" dependencies = [ "bitflags 2.3.1", "bstr", @@ -777,7 +788,7 @@ dependencies = [ "ecolor", "egui", "esp_macros", - "hashbrown 0.13.2", + "hashbrown", "itoa", "rayon", "smart-default 0.7.1", @@ -786,7 +797,7 @@ dependencies = [ [[package]] name = "esp_macros" version = "0.0.1" -source = "git+https://github.com/rfuzzo/tes3?branch=egui_temp#1de8e9a776768d222e9bd1adfeff4380bd8f5367" +source = "git+https://github.com/rfuzzo/tes3?branch=egui_temp#7c3d9988084242ce2c5abfb05cdbd314772f7f0d" dependencies = [ "quote", "syn 2.0.18", @@ -1093,14 +1104,8 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash", + "ahash 0.7.6", "rayon", ] @@ -1165,7 +1170,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown 0.12.3", + "hashbrown", ] [[package]] @@ -2074,14 +2079,14 @@ checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tes3" version = "0.0.1" -source = "git+https://github.com/rfuzzo/tes3?branch=egui_temp#1de8e9a776768d222e9bd1adfeff4380bd8f5367" +source = "git+https://github.com/rfuzzo/tes3?branch=egui_temp#7c3d9988084242ce2c5abfb05cdbd314772f7f0d" dependencies = [ "esp", ] [[package]] name = "tes3edit" -version = "0.2.0" +version = "1.0.0-RC2" dependencies = [ "catppuccin-egui", "console_error_panic_hook", diff --git a/Cargo.toml b/Cargo.toml index f56c52c..e2ce361 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tes3edit" -version = "0.2.0" +version = "1.0.0-RC2" authors = ["Moritz Baron "] edition = "2021" rust-version = "1.68" diff --git a/src/lib.rs b/src/lib.rs index 9b56d53..14ba871 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,48 +45,48 @@ impl From for f32 { #[derive(EnumIter, Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Display)] pub enum ERecordType { TES3, - GMST, - GLOB, - CLAS, - FACT, - RACE, - SOUN, - SNDG, - SKIL, - MGEF, - SCPT, - REGN, + ACTI, + ALCH, + APPA, + ARMO, + BODY, + BOOK, BSGN, - SSCR, - LTEX, - SPEL, - STAT, - DOOR, - MISC, - WEAP, + CELL, + CLAS, + CLOT, CONT, CREA, - BODY, - LIGH, + DIAL, + DOOR, ENCH, - NPC_, - ARMO, - CLOT, - REPA, - ACTI, - APPA, - LOCK, - PROB, + FACT, + GLOB, + GMST, + INFO, INGR, - BOOK, - ALCH, - LEVI, - LEVC, - CELL, LAND, + LEVC, + LEVI, + LIGH, + LOCK, + LTEX, + MGEF, + MISC, + NPC_, PGRD, - DIAL, - INFO, + PROB, + RACE, + REGN, + REPA, + SCPT, + SKIL, + SNDG, + SOUN, + SPEL, + SSCR, + STAT, + WEAP, } impl From<&str> for ERecordType { diff --git a/src/views/records_list_view.rs b/src/views/records_list_view.rs index 9064d29..432a9a4 100644 --- a/src/views/records_list_view.rs +++ b/src/views/records_list_view.rs @@ -36,7 +36,12 @@ impl TemplateApp { egui::ComboBox::from_label("") .selected_text(format!("{:?}", self.record_type)) .show_ui(ui, |ui| { - for t in ERecordType::iter() { + let tags = ERecordType::iter().collect::>(); + for t in tags { + // not allowed to create a header manually + if t == ERecordType::TES3 { + continue; + } ui.selectable_value(&mut self.record_type, t, t.to_string()); } }); @@ -140,38 +145,39 @@ impl TemplateApp { }); // context menu of tag header - tag_header.header_response.context_menu(|ui| { - // add record button - if ui.button("Add record").clicked() { - if let Some(instance) = create_from_tag(&tag.clone()) { - let new_id = get_unique_id(&instance); - data.edited_records.insert(new_id.clone(), instance); - data.clear_cache(); - data.selected_record_id = Some(new_id); - } else { - self.toasts.warning("Could not create record"); - } + if tag != "TES3" { + tag_header.header_response.context_menu(|ui| { + // add record button + if ui.button("Add record").clicked() { + if let Some(instance) = create_from_tag(&tag.clone()) { + let new_id = get_unique_id(&instance); + data.edited_records.insert(new_id.clone(), instance); + data.selected_record_id = Some(new_id); + } else { + self.toasts.warning("Could not create record"); + } - ui.close_menu(); - } + ui.close_menu(); + } - ui.separator(); + ui.separator(); - // delete all button - if ui.button("Delete all").clicked() { - for id in ids_by_tag.iter() { - record_ids_to_delete.push(id.clone()); + // delete all button + if ui.button("Delete all").clicked() { + for id in ids_by_tag.iter() { + record_ids_to_delete.push(id.clone()); + } + ui.close_menu(); } - ui.close_menu(); - } - }); + }); + } } ui.allocate_space(ui.available_size()); // put this LAST in your panel/window code }); // delete stuff - // TODO deleting actually removes + // TODO deleting actually removes, not undoable record_ids_to_delete.dedup(); if !record_ids_to_delete.is_empty() { for k in record_ids_to_delete {