use flatland_client_ui::{HudViewMode, MapTargetState, MovementState};
use crate::chat::ChatSession;
#[derive(Debug)]
pub struct PlayLocalState {
pub movement: MovementState,
pub map_target: MapTargetState,
pub auto_nav_goal: Option<(f32, f32)>,
pub chat: ChatSession,
pub hud_view: HudViewMode,
pub mouse_hover: Option<(f32, f32)>,
pub was_harvesting: bool,
}
impl PlayLocalState {
pub fn new(keys: flatland_client_lib::ClientKeyBindings) -> Self {
let hud_view = flatland_client_lib::ClientConfig::load()
.hud_view
.as_deref()
.and_then(HudViewMode::from_label)
.unwrap_or_default();
Self {
movement: MovementState::with_keys(keys),
map_target: MapTargetState::default(),
auto_nav_goal: None,
chat: ChatSession::default(),
hud_view,
mouse_hover: None,
was_harvesting: false,
}
}
pub fn cycle_hud_view(&mut self) {
self.hud_view = self.hud_view.cycle();
let mut cfg = flatland_client_lib::ClientConfig::load();
let _ = cfg.save_hud_view(self.hud_view.label());
}
pub fn clear_nav(&mut self) {
self.map_target.deactivate();
self.auto_nav_goal = None;
self.movement.reset();
}
}