jevsnes.git / packages / panels / src / state.rs
1//! The game state, in words.
2
3use alttp::State;
4
5pub fn show(ui: &mut egui::Ui, state: &State) {
6    // Health is kept in eighths of a heart.
7    let hearts = |eighths: u8| f32::from(eighths) / 8.0;
8    egui::Grid::new("state").num_columns(2).show(ui, |ui| {
9        for (name, value) in [
10            ("mode", state.mode.to_string()),
11            ("doing", state.step.to_string()),
12            ("world", state.world.to_string()),
13            ("link", format!("{}, {}", state.link_x, state.link_y)),
14            (
15                "hearts",
16                format!("{} of {}", hearts(state.health), hearts(state.health_capacity)),
17            ),
18            ("rupees", state.rupees.to_string()),
19        ] {
20            ui.label(name);
21            ui.monospace(value);
22            ui.end_row();
23        }
24    });
25}