72 lines
1.6 KiB
Rust
72 lines
1.6 KiB
Rust
use galactica_content::Content;
|
|
use galactica_system::{data::ShipState, phys::PhysSimShipHandle};
|
|
use glyphon::TextArea;
|
|
|
|
use super::{fpsindicator::FpsIndicator, planet::Planet, radar::Radar, status::Status};
|
|
use crate::{RenderInput, RenderState};
|
|
|
|
pub struct UiManager {
|
|
radar: Radar,
|
|
status: Status,
|
|
fps: FpsIndicator,
|
|
planet: Planet,
|
|
}
|
|
|
|
impl UiManager {
|
|
pub fn new(ct: &Content, state: &mut RenderState) -> Self {
|
|
Self {
|
|
planet: Planet::new(ct, state),
|
|
radar: Radar::new(),
|
|
status: Status::new(),
|
|
fps: FpsIndicator::new(state),
|
|
}
|
|
}
|
|
|
|
/// Draw all ui elements
|
|
pub fn draw(&mut self, input: &RenderInput, state: &mut RenderState) {
|
|
let ship_handle = input.player.ship.unwrap();
|
|
let ship = &input
|
|
.phys_img
|
|
.get_ship(&PhysSimShipHandle(ship_handle))
|
|
.unwrap()
|
|
.ship;
|
|
|
|
self.fps.update(input, state);
|
|
|
|
match ship.get_data().get_state() {
|
|
ShipState::Collapsing
|
|
| ShipState::Dead
|
|
| ShipState::Flying { .. }
|
|
| ShipState::Landing { .. }
|
|
| ShipState::UnLanding { .. } => {
|
|
self.radar.draw(input, state);
|
|
self.status.draw(input, state);
|
|
}
|
|
|
|
ShipState::Landed { .. } => {
|
|
self.planet.draw(input, state);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Textareas to show while player is flying
|
|
pub fn get_textareas_flying(
|
|
&self,
|
|
_input: &RenderInput,
|
|
_state: &RenderState,
|
|
) -> Vec<TextArea> {
|
|
let mut v = Vec::with_capacity(5);
|
|
v.push(self.fps.get_textarea());
|
|
|
|
return v;
|
|
}
|
|
|
|
/// Textareas to show when player is landed
|
|
pub fn get_textareas_landed(&self, input: &RenderInput, state: &RenderState) -> Vec<TextArea> {
|
|
let mut v = Vec::with_capacity(5);
|
|
v.extend(self.planet.get_textarea(input, state));
|
|
|
|
return v;
|
|
}
|
|
}
|