pub mod topbar; pub mod bodies_window; pub mod fleet_window; use std::{borrow::Borrow, cell::RefCell}; use crate::GameState; use crate::eguictx::EguiCtx; use crate::solar_system::body::BodyId; use crate::ui::bodies_window::BodiesWindowState; use crate::ui::fleet_window::FleetWindowState; use crate::ui::topbar::TopBarState; #[derive(Default, Clone)] pub struct State { pub camera_target: Option, pub topbar_sate: TopBarState, pub bodies_window: BodiesWindowState, pub fleet_window: FleetWindowState } impl State { pub fn render( &mut self, game_state: &RefCell, eguictx: &EguiCtx) { let mut game_state = game_state.borrow_mut(); let topbar_action = TopBarState::render( &mut self.topbar_sate, &game_state, eguictx); if let Some(by) = topbar_action.advance_tick { game_state.timeman_mut().advance(by) } let current_system = match self.topbar_sate.current_system { Some(id) => &game_state.solar_systems()[id], None => return }; if self.topbar_sate.bodies_window_visible { let bodies_window_action = self.bodies_window.render(current_system, eguictx); if bodies_window_action.focus_body.is_some() { self.camera_target = bodies_window_action.focus_body; } } if self.topbar_sate.fleet_window_visible { let fleet_window_action = self.fleet_window.render(game_state.borrow(), eguictx); } } }