diff options
Diffstat (limited to 'src/ui.rs')
| -rw-r--r-- | src/ui.rs | 42 |
1 files changed, 36 insertions, 6 deletions
@@ -1,10 +1,12 @@ pub mod topbar; pub mod camera_info; +pub mod bodies_window; +pub mod fleet_window; -use std::cell::RefCell; +use std::{borrow::Borrow, cell::RefCell}; -use crate::{GameState, eguictx::EguiCtx, ui::{camera_info::CameraWindowState, topbar::TopBarState}}; +use crate::{GameState, eguictx::EguiCtx, ui::{bodies_window::BodiesWindowState, camera_info::CameraWindowState, fleet_window::FleetWindowState, topbar::TopBarState}}; mod ui { @@ -14,7 +16,10 @@ mod ui { pub struct State { pub topbar_sate: TopBarState, - pub camera_info: CameraWindowState + pub camera_info: CameraWindowState, + + pub bodies_window: BodiesWindowState, + pub fleet_window: FleetWindowState } impl State @@ -24,14 +29,39 @@ impl State game_state: &RefCell<GameState>, eguictx: &EguiCtx) { - TopBarState::render( + let mut game_state = game_state.borrow_mut(); + + let topbar_action = TopBarState::render( &mut self.topbar_sate, - game_state, + &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 + }; + CameraWindowState::render( self, - game_state, + &game_state, eguictx); + + if self.topbar_sate.bodies_window_visible { + let bodies_window_action = + self.bodies_window.render(current_system, eguictx); + + if let Some(body) = bodies_window_action.focus_body { + self.camera_info.target = Some(body); + } + } + + if self.topbar_sate.fleet_window_visible { + let fleet_window_action = + self.fleet_window.render(game_state.borrow(), eguictx); + } } } |
