flatland-client-ui 0.2.36

Engine-agnostic play client UI state (world grid, input, presentation)
Documentation
//! HUD view mode and per-frame play HUD snapshot.

/// Play-client HUD density: normal sidebar, compact essentials, or map-first.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum HudViewMode {
    #[default]
    Normal,
    Compact,
    Map,
}

impl HudViewMode {
    pub fn cycle(self) -> Self {
        match self {
            Self::Normal => Self::Compact,
            Self::Compact => Self::Map,
            Self::Map => Self::Normal,
        }
    }

    pub fn label(self) -> &'static str {
        match self {
            Self::Normal => "normal",
            Self::Compact => "compact",
            Self::Map => "map",
        }
    }

    /// Parse a persisted label from client config (`normal` / `compact` / `map`).
    pub fn from_label(s: &str) -> Option<Self> {
        match s.trim().to_ascii_lowercase().as_str() {
            "normal" => Some(Self::Normal),
            "compact" => Some(Self::Compact),
            "map" => Some(Self::Map),
            _ => None,
        }
    }
}

#[derive(Debug, Default)]
pub struct PlayHud<'a> {
    pub movement: &'a str,
    pub sprint_mode: bool,
    pub map_target: Option<(f32, f32)>,
    pub auto_nav_goal: Option<(f32, f32)>,
    /// Free-aim cast point (Shift+click). Drawn as a map X.
    pub ground_target: Option<(f32, f32)>,
    /// Optional blast preview radius (meters) around ground aim.
    pub ground_blast_radius_m: f32,
    /// Mouse hover world position (dim cursor on map).
    pub mouse_hover: Option<(f32, f32)>,
    pub view_mode: HudViewMode,
}