summaryrefslogtreecommitdiffstats
path: root/src/ui/topbar.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/topbar.rs')
-rw-r--r--src/ui/topbar.rs29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/ui/topbar.rs b/src/ui/topbar.rs
index a5d92c5..ba26d7c 100644
--- a/src/ui/topbar.rs
+++ b/src/ui/topbar.rs
@@ -1,6 +1,6 @@
use std::cell::RefCell;
-use crate::{GameState, eguictx::EguiCtx, solar_system::SystemId, timeman::{self, Second, TimeMan}};
+use crate::{GameState, eguictx::EguiCtx, solar_system::SystemId, timeman::{self, Second, TimeMan}, ui::{self, bodies_window::BodiesWindowState, fleet_window::FleetWindowState}};
#[derive(Default, Clone)]
pub struct TopBarState
@@ -8,23 +8,24 @@ pub struct TopBarState
pub current_system: Option<SystemId>,
pub auto_tick: Option<Second>,
pub do_auto_tick: bool,
-
- pub bodies_window_visible: bool,
- pub fleet_window_visible: bool,
}
#[derive(Default, Clone)]
pub struct TopBarAction
{
pub advance_tick: Option<Second>,
+ pub toggle_bodies_window: bool,
+ pub toggle_fleets_window: bool,
}
impl TopBarState
{
- pub fn render(
+ pub fn paint(
&mut self,
+ eguictx: &EguiCtx,
game_state: &GameState,
- eguictx: &EguiCtx)
+ bodies_window_state: &BodiesWindowState,
+ fleets_window_state: &FleetWindowState)
-> TopBarAction
{
let mut action: TopBarAction = TopBarAction::default();
@@ -57,7 +58,7 @@ impl TopBarState
});
ui.horizontal(|ui| {
- self.paint_empire_buttons(ui);
+ self.paint_empire_buttons(ui, &mut action, bodies_window_state, fleets_window_state);
});
});
@@ -77,13 +78,17 @@ impl TopBarState
pub fn paint_empire_buttons(
&mut self,
- ui: &mut egui::Ui)
+ ui: &mut egui::Ui,
+ action: &mut TopBarAction,
+ bodies_window_state: &BodiesWindowState,
+ fleets_window_state: &FleetWindowState
+ )
{
- if ui.add(egui::Button::new("Bodies").selected(self.bodies_window_visible)).clicked() {
- self.bodies_window_visible = !self.bodies_window_visible;
+ if ui.add(egui::Button::new("Bodies").selected(bodies_window_state.open)).clicked() {
+ action.toggle_bodies_window = true;
}
- if ui.add(egui::Button::new("Fleets").selected(self.fleet_window_visible)).clicked() {
- self.fleet_window_visible = !self.fleet_window_visible;
+ if ui.add(egui::Button::new("Fleets").selected(fleets_window_state.open)).clicked() {
+ action.toggle_fleets_window = true;
}
}