Skip to content

Commit

Permalink
feat: Tooltip for unknown GameEffects
Browse files Browse the repository at this point in the history
  • Loading branch information
futile committed Jul 18, 2024
1 parent 3089f9d commit 6ed4070
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
21 changes: 11 additions & 10 deletions docs/notes.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
# Todos

## Next:
- [ ] fight-ui display for effects
- Probably using `OnAdd` for each effect in the UI to attach UI info/save it to an `EntityHashMap`/`HashMap` or sth.?
- [x] With remaining _total_ time (also remaining ticks?)
- [ ] With tooltip
- [ ] How to handle "unknown" (i.e., not modeled for UI) effects?
- Idea: "Unknown effect `TypeName`"
- Currently: `warn_once!()` in console; probably also want a warning-tooltip

- [ ] Resetting fights/fight selection menu

- [ ] Figure out what's next :) More complicated abilities? More units per side? AI/Enemy behavior :O?
- Cooldowns? Cast-Times? Icons for Slots/Abilities/Effects? :O

- [ ] Resetting fights/fight selection menu

## Possible Next
- [ ] 1 or 2 basic tests, also just to try out how well it works/how easy it is

Expand All @@ -38,6 +30,15 @@
---
# Done
---
- [x] fight-ui display for effects
- Probably using `OnAdd` for each effect in the UI to attach UI info/save it to an `EntityHashMap`/`HashMap` or sth.?
- For now just immediate re-render; probably a target for reactivity later on (but don't care yet :) )
- [x] With remaining _total_ time (also remaining ticks?)
- [x] With tooltip
- [x] How to handle "unknown" (i.e., not modeled for UI) effects?
- Idea: "Unknown effect `TypeName`"
- Currently: `warn_once!()` in console; probably also want a warning-tooltip <- added tooltip

- [x] Simple test(s) for `FiniteRepeatingTimer`

- [x] Let's build a basic DoT!
Expand Down
26 changes: 22 additions & 4 deletions src/fight_ui/render_fight_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub fn render_fight_windows(
for fight_window_e in fight_windows.into_iter() {
egui::Window::new("Fight")
.id(Id::new(fight_window_e))
.default_size((500.0, 500.0))
.show(&ui_ctx, |ui: &mut Ui| {
run_ui_system(
ui,
Expand Down Expand Up @@ -534,10 +535,6 @@ fn ui_abilities(
(ui, ui_column_state)
}

// #[expect(
// clippy::type_complexity,
// reason = "SystemState<..> big but ok, part of the ui-pattern (for now)"
// )]
fn ui_effects(
In((mut ui, (model_e,))): In<(Ui, (Entity,))>,
world: &mut World,
Expand Down Expand Up @@ -611,6 +608,27 @@ fn ui_effects(
"Component `{}` is ReflectGameEffect but not ReflectRenderGameEffectImmediate!",
component_info.name()
);

let short_name = component_info
.name()
.rsplit_once(':')
.map(|(_prefix, shortname)| shortname)
.unwrap_or(component_info.name());

let label = ui.label(format!("[UNKNOWN] {short_name}"));

if label.contains_pointer() {
egui::containers::popup::show_tooltip_at(
ui.ctx(),
ui.layer_id(),
Id::new("UnknownEffectTooltip").with(comp_as_reflect as *const _),
label.rect.right_top(),
|ui| {
ui.label(component_info.name());
},
);
}

continue;
};

Expand Down

0 comments on commit 6ed4070

Please sign in to comment.