diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-04-22 10:51:13 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-04-22 10:51:13 -0400 |
| commit | 3d3864171785c589872bf23faaaa3a421f56ee4e (patch) | |
| tree | 4c4a927473ee1a58f23fff1e8ece8327a31d719a /src/ui/camera_info.rs | |
| parent | 3dc92fad981e28c760f3c6e95f5a8153ea6c9be4 (diff) | |
| download | systemic4x-3d3864171785c589872bf23faaaa3a421f56ee4e.tar.gz systemic4x-3d3864171785c589872bf23faaaa3a421f56ee4e.tar.bz2 systemic4x-3d3864171785c589872bf23faaaa3a421f56ee4e.zip | |
complete orbit camera. add most large solar bodies
Diffstat (limited to 'src/ui/camera_info.rs')
| -rw-r--r-- | src/ui/camera_info.rs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/ui/camera_info.rs b/src/ui/camera_info.rs new file mode 100644 index 0000000..35cd54b --- /dev/null +++ b/src/ui/camera_info.rs @@ -0,0 +1,74 @@ +use std::cell::RefCell; + +use crate::{GameState, eguictx::EguiCtx, solar_system, ui}; + + +#[derive(Default, Clone)] +pub struct CameraWindowState +{ + pub camera_scale: f32, + pub camera_pos: Option<cgmath::Vector3<f64>>, + pub camera_rot: Option<cgmath::Vector2<cgmath::Rad<f32>>>, + pub target: Option<solar_system::BodyId>, +} + +impl CameraWindowState +{ + pub fn render( + ui_state: &mut ui::State, + game_state: &RefCell<GameState>, + eguictx: &EguiCtx) + { + if ui_state.current_system.is_none() { + return; + } + + let camera_state = &mut ui_state.camera_info; + let game_state = game_state.borrow(); + + let current_system = &game_state.solar_systems()[ui_state.current_system.unwrap()]; + + egui::Window::new("Camera Info").show(eguictx.context(), |ui| { + ui.vertical(|ui| { + let selected_body_label = match camera_state.target { + Some(id) => current_system.bodies()[id].name(), + None => "" + }; + + ui.separator(); + + egui::ComboBox::from_label("Camera Target") + .selected_text(selected_body_label) + .show_ui(ui, |ui| { + + for (i, body) in current_system.bodies().iter().enumerate() { + ui.selectable_value( + &mut camera_state.target, + Some(i), + body.name()); + } + }); + + ui.label(format!("Scale: {}", camera_state.camera_scale)); + match camera_state.camera_pos { + Some(pos) => { ui.label(format!("Pos x:{:^10} y:{:^10} z:{:^10}", + pos.x, + pos.y, + pos.z + )); }, + None => {} + } + match camera_state.camera_rot { + Some(rot) => { + ui.label(format!("pitch:{:^10} yaw:{:^10}", + rot.y.0, + rot.x.0, + )); + }, + None => {} + } + + }); + }); + } +} |
