Skip to content

Commit

Permalink
fixes, update tes3 lib
Browse files Browse the repository at this point in the history
closes #3
  • Loading branch information
rfuzzo committed Jun 4, 2023
1 parent 56fda5b commit 953e95d
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 77 deletions.
41 changes: 23 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tes3edit"
version = "0.2.0"
version = "1.0.0-RC2"
authors = ["Moritz Baron <r.fuzzo@gmail.com>"]
edition = "2021"
rust-version = "1.68"
Expand Down
70 changes: 35 additions & 35 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,48 +45,48 @@ impl From<EScale> 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 {
Expand Down
52 changes: 29 additions & 23 deletions src/views/records_list_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();
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());
}
});
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 953e95d

Please sign in to comment.