mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-26 05:38:20 -06:00
upgrade to hui = "0.1.0-alpha.4"
This commit is contained in:
parent
d63966e618
commit
3006640be5
106
Cargo.lock
generated
106
Cargo.lock
generated
|
@ -382,6 +382,12 @@ dependencies = [
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "convert_case"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation"
|
name = "core-foundation"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
@ -489,7 +495,7 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"strsim",
|
"strsim",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -500,7 +506,7 @@ checksum = "c5a91391accf613803c2a9bf9abccdbaa07c54b4244a5b64883f9c3c137c86be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling_core",
|
"darling_core",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -513,6 +519,31 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "derive_more"
|
||||||
|
version = "0.99.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
|
||||||
|
dependencies = [
|
||||||
|
"convert_case",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"rustc_version",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "derive_setters"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4e8ef033054e131169b8f0f9a7af8f5533a9436fadf3c500ed547f730f07090d"
|
||||||
|
dependencies = [
|
||||||
|
"darling",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.49",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dispatch"
|
name = "dispatch"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
@ -649,7 +680,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -747,9 +778,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glam"
|
name = "glam"
|
||||||
version = "0.25.0"
|
version = "0.27.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3"
|
checksum = "9e05e7e6723e3455f4818c7b26e855439f7546cf617ef669d1adedb8669e5cb9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
@ -897,23 +928,36 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hui"
|
name = "hui"
|
||||||
version = "0.1.0-alpha.3"
|
version = "0.1.0-alpha.4"
|
||||||
source = "git+https://github.com/griffi-gh/hui?rev=9bb95b3baff#9bb95b3baff69b0ddee67ee28c1d271e79668468"
|
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"derive_more",
|
||||||
|
"derive_setters",
|
||||||
"document-features",
|
"document-features",
|
||||||
"fontdue",
|
"fontdue",
|
||||||
"glam",
|
"glam",
|
||||||
"hashbrown 0.14.3",
|
"hashbrown 0.14.3",
|
||||||
|
"hui-derive",
|
||||||
|
"image 0.25.0",
|
||||||
"log",
|
"log",
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
"nz",
|
|
||||||
"rect_packer",
|
"rect_packer",
|
||||||
|
"tinyset",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hui-derive"
|
||||||
|
version = "0.1.0-alpha.4"
|
||||||
|
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.49",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hui-glium"
|
name = "hui-glium"
|
||||||
version = "0.1.0-alpha.3"
|
version = "0.1.0-alpha.4"
|
||||||
source = "git+https://github.com/griffi-gh/hui?rev=9bb95b3baff#9bb95b3baff69b0ddee67ee28c1d271e79668468"
|
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glam",
|
"glam",
|
||||||
"glium",
|
"glium",
|
||||||
|
@ -980,6 +1024,17 @@ dependencies = [
|
||||||
"png",
|
"png",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "image"
|
||||||
|
version = "0.25.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a9b4f005360d32e9325029b38ba47ebd7a56f3316df09249368939562d518645"
|
||||||
|
dependencies = [
|
||||||
|
"bytemuck",
|
||||||
|
"byteorder",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.9.3"
|
version = "1.9.3"
|
||||||
|
@ -1110,7 +1165,7 @@ dependencies = [
|
||||||
"hashbrown 0.14.3",
|
"hashbrown 0.14.3",
|
||||||
"hui",
|
"hui",
|
||||||
"hui-glium",
|
"hui-glium",
|
||||||
"image",
|
"image 0.24.8",
|
||||||
"kubi-logging",
|
"kubi-logging",
|
||||||
"kubi-shared",
|
"kubi-shared",
|
||||||
"log",
|
"log",
|
||||||
|
@ -1403,7 +1458,7 @@ dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1824,7 +1879,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1874,7 +1929,7 @@ dependencies = [
|
||||||
"darling",
|
"darling",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1897,7 +1952,7 @@ source = "git+https://github.com/leudz/shipyard?rev=9099b990e#9099b990e332229f7e
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2013,7 +2068,18 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"rustversion",
|
"rustversion",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.109"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2059,7 +2125,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2270,7 +2336,7 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2304,7 +2370,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
"wasm-bindgen-backend",
|
"wasm-bindgen-backend",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
@ -2829,5 +2895,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.49",
|
||||||
]
|
]
|
||||||
|
|
|
@ -11,7 +11,7 @@ log = "0.4"
|
||||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "9099b990e", default-features = false, features = ["std", "proc", "thread_local"] }
|
shipyard = { git = "https://github.com/leudz/shipyard", rev = "9099b990e", default-features = false, features = ["std", "proc", "thread_local"] }
|
||||||
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
|
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
|
||||||
toml = "0.8"
|
toml = "0.8"
|
||||||
glam = { version = "0.25", features = ["debug-glam-assert", "fast-math"] }
|
glam = { version = "0.27", features = ["debug-glam-assert", "fast-math"] }
|
||||||
hashbrown = "0.14"
|
hashbrown = "0.14"
|
||||||
nohash-hasher = "0.2"
|
nohash-hasher = "0.2"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
|
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glam = { version = "0.25", features = ["debug-glam-assert", "fast-math", "serde"] }
|
glam = { version = "0.27", features = ["debug-glam-assert", "fast-math", "serde"] }
|
||||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "9099b990e", default-features = false, features = ["std"] }
|
shipyard = { git = "https://github.com/leudz/shipyard", rev = "9099b990e", default-features = false, features = ["std"] }
|
||||||
strum = { version = "0.26", features = ["derive"] }
|
strum = { version = "0.26", features = ["derive"] }
|
||||||
num_enum = "0.7"
|
num_enum = "0.7"
|
||||||
|
|
|
@ -11,15 +11,15 @@ crate-type = ["lib", "cdylib"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
kubi-shared = { path = "../kubi-shared" }
|
kubi-shared = { path = "../kubi-shared" }
|
||||||
kubi-logging = { path = "../kubi-logging" }
|
kubi-logging = { path = "../kubi-logging" }
|
||||||
hui = { version = "0.1.0-alpha.3", git = "https://github.com/griffi-gh/hui", rev = "9bb95b3baff" }
|
hui = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
|
||||||
hui-glium = { version = "0.1.0-alpha.3", git = "https://github.com/griffi-gh/hui", rev = "9bb95b3baff" }
|
hui-glium = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
glium = { git = "https://github.com/glium/glium", rev = "a352c667" }
|
glium = { git = "https://github.com/glium/glium", rev = "a352c667" }
|
||||||
glutin = "0.31"
|
glutin = "0.31"
|
||||||
winit = { version = "0.29", features = ["android-native-activity"] }
|
winit = { version = "0.29", features = ["android-native-activity"] }
|
||||||
glutin-winit = "0.4"
|
glutin-winit = "0.4"
|
||||||
raw-window-handle = "=0.5.*"
|
raw-window-handle = "=0.5.*"
|
||||||
glam = { version = "0.25", features = ["debug-glam-assert", "fast-math"] }
|
glam = { version = "0.27", features = ["debug-glam-assert", "fast-math"] }
|
||||||
image = { version = "0.24", default_features = false, features = ["png"] }
|
image = { version = "0.24", default_features = false, features = ["png"] }
|
||||||
strum = { version = "0.26", features = ["derive"] }
|
strum = { version = "0.26", features = ["derive"] }
|
||||||
hashbrown = "0.14"
|
hashbrown = "0.14"
|
||||||
|
|
|
@ -75,7 +75,8 @@ pub fn load_prefabs(
|
||||||
let asset_handle = assman.open_asset(Path::new("fonts/Crisp.ttf")).unwrap();
|
let asset_handle = assman.open_asset(Path::new("fonts/Crisp.ttf")).unwrap();
|
||||||
let mut font_data = vec![];
|
let mut font_data = vec![];
|
||||||
BufReader::new(asset_handle).read_to_end(&mut font_data).unwrap();
|
BufReader::new(asset_handle).read_to_end(&mut font_data).unwrap();
|
||||||
let font_handle = ui.hui.add_font_from_bytes(&font_data);
|
let font_handle = ui.hui.add_font(&font_data);
|
||||||
|
ui.hui.push_font(font_handle);
|
||||||
storages.add_unique(UiFontPrefab(font_handle));
|
storages.add_unique(UiFontPrefab(font_handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use hui::element::text::Text;
|
use hui::element::{text::Text, UiElementExt};
|
||||||
use kubi_shared::networking::state::ClientJoinState;
|
use kubi_shared::networking::state::ClientJoinState;
|
||||||
use shipyard::{IntoWorkload, NonSendSync, UniqueView, UniqueViewMut, Workload};
|
use shipyard::{IntoWorkload, NonSendSync, UniqueView, UniqueViewMut, Workload};
|
||||||
use crate::{
|
use crate::{
|
||||||
hui_integration::UiState,
|
hui_integration::UiState,
|
||||||
loading_screen::loading_screen_base,
|
loading_screen::loading_screen_base,
|
||||||
networking::{ConnectionRejectionReason, ServerAddress},
|
networking::{ConnectionRejectionReason, ServerAddress},
|
||||||
prefabs::UiFontPrefab,
|
|
||||||
rendering::WindowSize,
|
rendering::WindowSize,
|
||||||
state::{GameState, NextState}
|
state::{GameState, NextState}
|
||||||
};
|
};
|
||||||
|
@ -15,24 +14,25 @@ fn render_connecting_ui(
|
||||||
rejection: Option<UniqueView<ConnectionRejectionReason>>,
|
rejection: Option<UniqueView<ConnectionRejectionReason>>,
|
||||||
join_state: UniqueView<ClientJoinState>,
|
join_state: UniqueView<ClientJoinState>,
|
||||||
mut ui: NonSendSync<UniqueViewMut<UiState>>,
|
mut ui: NonSendSync<UniqueViewMut<UiState>>,
|
||||||
font: UniqueView<UiFontPrefab>,
|
|
||||||
size: UniqueView<WindowSize>,
|
size: UniqueView<WindowSize>,
|
||||||
) {
|
) {
|
||||||
ui.hui.add(
|
let text = match (rejection, *join_state) {
|
||||||
loading_screen_base(vec![
|
(Some(err), _) => {
|
||||||
Box::new(Text {
|
format!("Connection rejected by {}\n\n{}", addr.0, err.reason)
|
||||||
text: match (rejection, *join_state) {
|
|
||||||
(Some(err), _) => format!("Connection rejected by {}\n\n{}", addr.0, err.reason).into(),
|
|
||||||
(_, ClientJoinState::Disconnected) => format!("Lost connection to {}", addr.0).into(),
|
|
||||||
_ => format!("Connecting to {}...", addr.0).into(),
|
|
||||||
},
|
},
|
||||||
font: font.0,
|
(_, ClientJoinState::Disconnected) => {
|
||||||
text_size: 16,
|
format!("Lost connection to {}", addr.0)
|
||||||
..Default::default()
|
},
|
||||||
}),
|
_ => {
|
||||||
], 1.),
|
format!("Connecting to {}...", addr.0)
|
||||||
size.0.as_vec2(),
|
},
|
||||||
);
|
};
|
||||||
|
|
||||||
|
loading_screen_base(1., |ui| {
|
||||||
|
Text::new(text)
|
||||||
|
.with_text_size(16)
|
||||||
|
.add_child(ui);
|
||||||
|
}).add_root(&mut ui.hui, size.0.as_vec2())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn switch_to_loading_if_connected(
|
fn switch_to_loading_if_connected(
|
||||||
|
|
|
@ -1,38 +1,48 @@
|
||||||
use hui::{
|
use hui::{
|
||||||
element::{container::Container, progress_bar::ProgressBar, text::Text, UiElement},
|
element::{
|
||||||
layout::{Alignment, UiDirection, UiSize},
|
container::Container,
|
||||||
rectangle::{Corners, Sides},
|
progress_bar::ProgressBar,
|
||||||
|
text::Text,
|
||||||
|
ElementList,
|
||||||
|
UiElementExt,
|
||||||
|
},
|
||||||
|
layout::{Alignment, Direction},
|
||||||
|
frame_rect, size,
|
||||||
};
|
};
|
||||||
use shipyard::{UniqueView, UniqueViewMut, Workload, NonSendSync, IntoWorkload};
|
use shipyard::{UniqueView, UniqueViewMut, Workload, NonSendSync, IntoWorkload};
|
||||||
use winit::keyboard::KeyCode;
|
use winit::keyboard::KeyCode;
|
||||||
use crate::{
|
use crate::{
|
||||||
hui_integration::UiState, input::RawKbmInputState, networking::ServerAddress, prefabs::UiFontPrefab, rendering::WindowSize, state::{GameState, NextState}, world::ChunkStorage
|
hui_integration::UiState,
|
||||||
|
input::RawKbmInputState,
|
||||||
|
networking::ServerAddress,
|
||||||
|
rendering::WindowSize,
|
||||||
|
state::{GameState, NextState},
|
||||||
|
world::ChunkStorage,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn loading_screen_base(elements: Vec<Box<dyn UiElement>>, bg_alpha: f32) -> Container {
|
pub fn loading_screen_base(bg_alpha: f32, xui: impl FnOnce(&mut ElementList)) -> Container {
|
||||||
Container {
|
Container::default()
|
||||||
size: (UiSize::Fraction(1.), UiSize::Fraction(1.)),
|
.with_size(size!(100%))
|
||||||
background: (0.1, 0.1, 0.1, bg_alpha).into(),
|
.with_background((0.1, 0.1, 0.1, bg_alpha))
|
||||||
align: Alignment::Center.into(),
|
.with_align(Alignment::Center)
|
||||||
elements: vec![
|
.with_children(|ui| {
|
||||||
Box::new(Container {
|
Container::default()
|
||||||
padding: Sides::all(10.),
|
.with_size(size!(400, auto))
|
||||||
gap: 5.,
|
.with_background(frame_rect! {
|
||||||
background: (0.2, 0.2, 0.2).into(),
|
color: (0.2, 0.2, 0.2),
|
||||||
corner_radius: Corners::all(8.),
|
corner_radius: 8.
|
||||||
elements,
|
})
|
||||||
..Default::default()
|
.with_gap(5.)
|
||||||
|
.with_padding(10.)
|
||||||
|
.with_children(xui)
|
||||||
|
.add_child(ui);
|
||||||
})
|
})
|
||||||
],
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_loading_ui(
|
fn render_loading_ui(
|
||||||
addr: Option<UniqueView<ServerAddress>>,
|
addr: Option<UniqueView<ServerAddress>>,
|
||||||
world: UniqueView<ChunkStorage>,
|
world: UniqueView<ChunkStorage>,
|
||||||
mut ui: NonSendSync<UniqueViewMut<UiState>>,
|
mut ui: NonSendSync<UniqueViewMut<UiState>>,
|
||||||
font: UniqueView<UiFontPrefab>,
|
|
||||||
size: UniqueView<WindowSize>
|
size: UniqueView<WindowSize>
|
||||||
) {
|
) {
|
||||||
let loaded = world.chunks.iter().fold(0, |acc, (&_, chunk)| {
|
let loaded = world.chunks.iter().fold(0, |acc, (&_, chunk)| {
|
||||||
|
@ -42,44 +52,38 @@ fn render_loading_ui(
|
||||||
let value = loaded as f32 / total as f32;
|
let value = loaded as f32 / total as f32;
|
||||||
let percentage = value * 100.;
|
let percentage = value * 100.;
|
||||||
|
|
||||||
ui.hui.add(loading_screen_base(vec![
|
loading_screen_base(1. - (value - 0.75).max(0.), |ui| {
|
||||||
Box::new(Text {
|
Text::new(match addr {
|
||||||
text: match addr {
|
Some(addr) => format!("Connected to {}\nDownloading world data...", addr.0),
|
||||||
Some(addr) => format!("Connected to {}\nDownloading world data...", addr.0).into(),
|
|
||||||
_ => "Loading...".into(),
|
_ => "Loading...".into(),
|
||||||
},
|
|
||||||
font: font.0,
|
|
||||||
text_size: 16,
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
Box::new(ProgressBar {
|
|
||||||
value,
|
|
||||||
size: (UiSize::Static(400.), UiSize::Auto),
|
|
||||||
corner_radius: Corners::all(2.),
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
Box::new(Container {
|
|
||||||
size: (UiSize::Static(400.), UiSize::Auto),
|
|
||||||
align: (Alignment::End, Alignment::Begin).into(),
|
|
||||||
direction: UiDirection::Horizontal,
|
|
||||||
elements: vec![
|
|
||||||
Box::new(Text {
|
|
||||||
text: format!("{loaded}/{total} ({percentage:.1}%)").into(),
|
|
||||||
font: font.0,
|
|
||||||
text_size: 16,
|
|
||||||
..Default::default()
|
|
||||||
})
|
})
|
||||||
],
|
.with_text_size(16)
|
||||||
..Default::default()
|
.add_child(ui);
|
||||||
}),
|
|
||||||
// Box::new(Text {
|
ProgressBar::default()
|
||||||
// text: "--------------------------------------------------\nTip: You can press F to skip this loading screen".into(),
|
.with_value(value)
|
||||||
// font: font_handle,
|
.with_size(size!(100%, 15))
|
||||||
// text_size: 16,
|
.with_background(frame_rect! {
|
||||||
// color: (0.5, 0.5, 0.5, 1.).into(),
|
color: (0.1, 0.1, 0.1),
|
||||||
// ..Default::default()
|
corner_radius: 2.
|
||||||
// })
|
})
|
||||||
], 1. - (value - 0.75).max(0.)), size.0.as_vec2());
|
.with_foreground(frame_rect! {
|
||||||
|
color: (0.4, 0.4, 1.0),
|
||||||
|
corner_radius: 2.
|
||||||
|
})
|
||||||
|
.add_child(ui);
|
||||||
|
|
||||||
|
Container::default()
|
||||||
|
.with_size(size!(100%, auto))
|
||||||
|
.with_align((Alignment::End, Alignment::Begin))
|
||||||
|
.with_direction(Direction::Horizontal)
|
||||||
|
.with_children(|ui| {
|
||||||
|
Text::new(format!("{loaded}/{total} ({percentage:.1}%)"))
|
||||||
|
.with_text_size(16)
|
||||||
|
.add_child(ui)
|
||||||
|
})
|
||||||
|
.add_child(ui);
|
||||||
|
}).add_root(&mut ui.hui, size.0.as_vec2());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn switch_to_ingame_if_loaded(
|
fn switch_to_ingame_if_loaded(
|
||||||
|
|
Loading…
Reference in a new issue