Skip to content

Commit

Permalink
Add delete option (closes #44)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerthox committed Dec 14, 2023
1 parent 0df2924 commit 9b44d61
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

21 changes: 19 additions & 2 deletions src/tracking/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ impl Tracker {
colors: &exports::Colors,
entry: TableEntry,
show_sub: bool,
) {
allow_delete: bool,
) -> bool {
let mut delete = false;
let TableEntry { buffs, .. } = entry;
let sub_color = colors
.sub_base(entry.subgroup)
Expand Down Expand Up @@ -129,6 +131,9 @@ impl Tracker {
if ui.small_button("Reset buffs") {
buffs.reset_buffs();
}
if allow_delete && ui.small_button("Delete entry") {
delete = true;
}
});

// render food cell
Expand Down Expand Up @@ -236,6 +241,8 @@ impl Tracker {
}
});
}

delete
}

/// Renders the tracker tab for the squad.
Expand Down Expand Up @@ -321,6 +328,7 @@ impl Tracker {
&colors,
TableEntry::from_entry(entry.player.id, entry),
show_sub,
false,
);
}
}
Expand Down Expand Up @@ -358,10 +366,12 @@ impl Tracker {
&colors,
TableEntry::from_entry(usize::MAX, entry),
false,
false,
);
}
let mut delete = None;
for (i, (player, buffs)) in self.players.cache_iter_mut().enumerate() {
Self::render_table_entry(
let should_delete = Self::render_table_entry(
ui,
props,
&self.settings,
Expand All @@ -375,7 +385,14 @@ impl Tracker {
subgroup: 0,
},
false,
true,
);
if should_delete {
delete = Some(player.character.clone());
}
}
if let Some(name) = delete {
self.players.remove_cache_entry(name);
}
}
}
Expand Down

0 comments on commit 9b44d61

Please sign in to comment.