1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use crate::{widgets::two_col_row, SelectedEntityInfo};
use common::{
    comp::CharacterState,
    states::{charged_melee, dash_melee, leap_melee},
};
use egui::{Grid, Ui};

pub fn draw_char_state_group(
    ui: &mut Ui,
    _selected_entity_info: &SelectedEntityInfo,
    character_state: &CharacterState,
) {
    ui.horizontal(|ui| {
        ui.label("Current State: ");
        ui.label(character_state.to_string());
    });
    match character_state {
        CharacterState::DashMelee(data) => dash_melee_grid(ui, data),
        CharacterState::ChargedMelee(data) => charged_melee_grid(ui, data),
        // Character states with no associated data to display
        CharacterState::Dance
        | CharacterState::Idle(_)
        | CharacterState::Sit
        | CharacterState::GlideWield(_)
        | CharacterState::Talk
        | CharacterState::Wielding(_) => {},
        CharacterState::LeapMelee(data) => leap_melee_grid(ui, data),
        _ => {
            ui.label("<Rendering not yet implemented for this state>");
        },
    };
}

fn charged_melee_grid(ui: &mut Ui, data: &charged_melee::Data) {
    Grid::new("selected_entity_charged_melee_grid")
        .spacing([40.0, 4.0])
        .max_col_width(100.0)
        .striped(true)
        .show(ui, |ui| #[rustfmt::skip] {
                two_col_row(ui, "Stage Section", data.stage_section.to_string());
                two_col_row(ui, "Timer", format!("{}ms", data.timer.as_millis()));
                two_col_row(ui, "Charge Amount", format!("{:.1}", data.charge_amount));
                two_col_row(ui, "Exhausted", if data.exhausted { "True" } else { "False" });
            });
}

fn dash_melee_grid(ui: &mut Ui, data: &dash_melee::Data) {
    Grid::new("selected_entity_dash_melee_grid")
        .spacing([40.0, 4.0])
        .max_col_width(100.0)
        .striped(true)
        .show(ui, |ui| #[rustfmt::skip] {
                two_col_row(ui, "Auto Charge", if data.auto_charge { "True" } else { "False " });
                two_col_row(ui, "Timer", format!("{}ms", data.timer.as_millis()));
                two_col_row(ui, "Stage Section", data.stage_section.to_string());
            });
}

fn leap_melee_grid(ui: &mut Ui, data: &leap_melee::Data) {
    Grid::new("selected_entity_leap_melee_grid")
        .spacing([40.0, 4.0])
        .max_col_width(100.0)
        .striped(true)
        .show(ui, |ui| #[rustfmt::skip] {
                two_col_row(ui, "Stage Section", data.stage_section.to_string());
                two_col_row(ui, "Timer", format!("{}ms", data.timer.as_millis()));
                two_col_row(ui, "Exhausted", if data.exhausted { "True" } else { "False " });
            });
}