summaryrefslogtreecommitdiffstats
path: root/src/ui/fleet_window.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/fleet_window.rs')
-rw-r--r--src/ui/fleet_window.rs80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/ui/fleet_window.rs b/src/ui/fleet_window.rs
new file mode 100644
index 0000000..67a0dd9
--- /dev/null
+++ b/src/ui/fleet_window.rs
@@ -0,0 +1,80 @@
+use std::cell::RefCell;
+
+use crate::{GameState, eguictx::EguiCtx, solar_system::{self, SolarSystem, fleet::Fleet}, ui};
+
+
+#[derive(Default, Clone)]
+pub struct FleetWindowState
+{
+
+}
+
+#[derive(Default, Clone)]
+pub struct FleetWindowAction
+{
+
+}
+
+impl FleetWindowState
+{
+ pub fn render(
+ &mut self,
+ game_state: &GameState,
+ eguictx: &EguiCtx)
+ -> FleetWindowAction
+ {
+ let mut action = FleetWindowAction::default();
+
+ let star_systems = game_state.solar_systems();
+
+ egui::Window::new("Fleet Manager")
+ .show(eguictx.context(), |ui| {
+
+ ui.horizontal(|ui| {
+ self.paint_systems_list(star_systems, ui);
+ ui.add(egui::Separator::default().vertical());
+ });
+ });
+ action
+ }
+
+ fn paint_systems_list(
+ &mut self,
+ star_systems: &[SolarSystem],
+ ui: &mut egui::Ui)
+ -> egui::InnerResponse<()>
+ {
+ ui.vertical(|ui| {
+ for system in star_systems {
+ let resp = self.paint_fleet_list(&system, ui);
+ if resp.header_response.secondary_clicked() {
+ resp.header_response.context_menu(|ui| {
+
+ });
+ }
+ }
+ })
+ }
+
+ fn paint_fleet_list(
+ &mut self,
+ star_system: &SolarSystem,
+ ui: &mut egui::Ui)
+ -> egui::CollapsingResponse<()>
+ {
+ let fleets = star_system.fleets();
+ ui.collapsing(star_system.name(), |ui| {
+ for fleet in fleets {
+ self.paint_fleet_entry(fleet, ui);
+ }
+ })
+ }
+
+ fn paint_fleet_entry(
+ &mut self,
+ fleet: &Fleet,
+ ui: &mut egui::Ui)
+ {
+ ui.label(fleet.name());
+ }
+}