summaryrefslogtreecommitdiffstats
path: root/src/window.rs
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-04-30 10:06:32 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-04-30 10:06:32 -0400
commit961f8c6d405c9c6fcf9aaf4fb6f199b0e5c60d88 (patch)
treea26797d6314fa8c193a459e988427c7bfe7f19a7 /src/window.rs
parent25255a8b9147d27aa40b28d6aadb62c0ab275d32 (diff)
downloadsystemic4x-961f8c6d405c9c6fcf9aaf4fb6f199b0e5c60d88.tar.gz
systemic4x-961f8c6d405c9c6fcf9aaf4fb6f199b0e5c60d88.tar.bz2
systemic4x-961f8c6d405c9c6fcf9aaf4fb6f199b0e5c60d88.zip
add orbit rendering for bodies
Diffstat (limited to 'src/window.rs')
-rw-r--r--src/window.rs36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/window.rs b/src/window.rs
index 3b090ff..ce1b555 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -67,24 +67,27 @@ impl GameWindow
game_state: &RefCell<GameState>,
dt: Duration)
{
- {
- let mut game_state = game_state.borrow_mut();
- if self.ui_state.do_auto_tick {
- game_state.timeman.auto_tick = self.ui_state.auto_time;
- }else{
- game_state.timeman.auto_tick = None;
- }
+ let mut game_state = game_state.borrow_mut();
+ if self.ui_state.do_auto_tick {
+ game_state.timeman.auto_tick = self.ui_state.auto_time;
+ }else{
+ game_state.timeman.auto_tick = None;
}
- self.tactical_map.update(game_state, &mut self.ui_state, dt);
+
+ let current_system = match self.ui_state.current_system {
+ Some(id) => &game_state.solar_systems()[id],
+ None => { return; }
+ };
+
+ self.tactical_map.update(current_system, &mut self.ui_state, dt);
}
pub fn keyboard_input(
&mut self,
- game_state: &RefCell<GameState>,
key_code: KeyCode,
key_state: ElementState)
{
- self.tactical_map.keyboard_input(game_state, key_code, key_state);
+ self.tactical_map.keyboard_input(key_code, key_state);
}
pub fn render(
@@ -95,10 +98,15 @@ impl GameWindow
return Ok(());
}
- self.tactical_map.draw(
- &self.wgpuctx,
- game_state,
- self.ui_state.current_system)?;
+ if self.ui_state.current_system.is_some() {
+ let game_state = game_state.borrow();
+ let current_system = &game_state.solar_systems()[self.ui_state.current_system.unwrap()];
+
+ self.tactical_map.draw(
+ &self.wgpuctx,
+ current_system,
+ game_state.timeman())?;
+ }
let view = self.wgpuctx.prepare_surface(&wgpu::TextureViewDescriptor::default())?;
let mut scene = SceneCtx::from_view_default(&self.wgpuctx, &view, Some("Systemic window scene"));