diff options
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 => {} + } + + }); + }); + } +} |
