mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-21 22:38:41 -06:00
separate loading screen base
This commit is contained in:
parent
3d8307b124
commit
80614e8461
|
@ -1,7 +1,7 @@
|
|||
use hui::{
|
||||
element::{container::Container, progress_bar::ProgressBar, text::Text},
|
||||
element::{container::Container, progress_bar::ProgressBar, text::Text, UiElement},
|
||||
layout::{Alignment, UiDirection, UiSize},
|
||||
rectangle::{Corners, Sides}
|
||||
rectangle::{Corners, Sides}, UiInstance
|
||||
};
|
||||
use shipyard::{UniqueView, UniqueViewMut, Workload, NonSendSync, IntoWorkload};
|
||||
use winit::keyboard::KeyCode;
|
||||
|
@ -13,6 +13,25 @@ use crate::{
|
|||
hui_integration::UiState,
|
||||
};
|
||||
|
||||
pub fn loading_screen_base(elements: Vec<Box<dyn UiElement>>, bg_alpha: f32) -> Container {
|
||||
Container {
|
||||
size: (UiSize::Fraction(1.), UiSize::Fraction(1.)),
|
||||
background: (0.1, 0.1, 0.1, bg_alpha).into(),
|
||||
align: Alignment::Center.into(),
|
||||
elements: vec![
|
||||
Box::new(Container {
|
||||
padding: Sides::all(10.),
|
||||
gap: 10.,
|
||||
background: (0.2, 0.2, 0.2).into(),
|
||||
corner_radius: Corners::all(8.),
|
||||
elements,
|
||||
..Default::default()
|
||||
})
|
||||
],
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn render_loading_ui(
|
||||
mut ui: NonSendSync<UniqueViewMut<UiState>>,
|
||||
world: UniqueView<ChunkStorage>,
|
||||
|
@ -24,18 +43,7 @@ fn render_loading_ui(
|
|||
let total = world.chunks.len();
|
||||
let value = loaded as f32 / total as f32;
|
||||
let percentage = value * 100.;
|
||||
ui.hui.add(
|
||||
Container {
|
||||
size: (UiSize::Fraction(1.), UiSize::Fraction(1.)),
|
||||
background: (0.1, 0.1, 0.1, 1. - (value - 0.75).max(0.)).into(),
|
||||
align: Alignment::Center.into(),
|
||||
elements: vec![
|
||||
Box::new(Container {
|
||||
padding: Sides::all(10.),
|
||||
gap: 10.,
|
||||
background: (0.2, 0.2, 0.2).into(),
|
||||
corner_radius: Corners::all(8.),
|
||||
elements: vec![
|
||||
ui.hui.add(loading_screen_base(vec![
|
||||
Box::new(Text {
|
||||
text: "Loading...".into(),
|
||||
..Default::default()
|
||||
|
@ -57,15 +65,8 @@ fn render_loading_ui(
|
|||
})
|
||||
],
|
||||
..Default::default()
|
||||
})
|
||||
],
|
||||
..Default::default()
|
||||
})
|
||||
],
|
||||
..Default::default()
|
||||
},
|
||||
size.0.as_vec2()
|
||||
);
|
||||
}),
|
||||
], 1. - (value - 0.75).max(0.)), size.0.as_vec2());
|
||||
}
|
||||
|
||||
fn switch_to_ingame_if_loaded(
|
||||
|
|
Loading…
Reference in a new issue