Merge pull request #28 from kristoferssolo/fix/asset-loading

This commit is contained in:
Kristofers Solo 2025-01-06 16:44:43 +02:00 committed by GitHub
commit 69eacd42d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 77 additions and 77 deletions

View File

@ -21,17 +21,13 @@ jobs:
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
- name: Install dependencies - name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
- name: Install cargo-nextest
run: cargo install cargo-nextest
- name: Populate target directory from cache - name: Populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2 uses: Leafwing-Studios/cargo-cache@v2
with: with:
sweep-cache: true sweep-cache: true
- name: Run tests - name: Run tests
run: | run: |
cargo nextest run --locked --workspace --no-default-features --all-targets cargo test --locked --workspace --no-default-features
# Run doctests separately since nextest doesn't support them
cargo test --doc --locked --workspace --no-default-features
# Run clippy lints. # Run clippy lints.
clippy: clippy:
name: Clippy name: Clippy

2
Cargo.lock generated
View File

@ -3129,7 +3129,7 @@ dependencies = [
[[package]] [[package]]
name = "maze-ascension" name = "maze-ascension"
version = "1.0.1" version = "1.0.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bevy", "bevy",

View File

@ -1,7 +1,7 @@
[package] [package]
name = "maze-ascension" name = "maze-ascension"
authors = ["Kristofers Solo <dev@kristofers.xyz>"] authors = ["Kristofers Solo <dev@kristofers.xyz>"]
version = "1.0.1" version = "1.0.2"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -37,8 +37,8 @@ pub struct MazeAssets {
impl MazeAssets { impl MazeAssets {
/// Creates a new instance of MazeAssets with all necessary meshes and materials. /// Creates a new instance of MazeAssets with all necessary meshes and materials.
pub fn new( pub fn new(
meshes: &mut ResMut<Assets<Mesh>>, meshes: &mut Assets<Mesh>,
materials: &mut ResMut<Assets<StandardMaterial>>, materials: &mut Assets<StandardMaterial>,
global_config: &GlobalMazeConfig, global_config: &GlobalMazeConfig,
) -> Self { ) -> Self {
let custom_materials = RosePineDawn::iter() let custom_materials = RosePineDawn::iter()

View File

@ -1,4 +1,4 @@
mod assets; pub mod assets;
pub mod commands; pub mod commands;
pub mod components; pub mod components;
mod systems; mod systems;

View File

@ -4,6 +4,8 @@
use bevy::prelude::*; use bevy::prelude::*;
use crate::{ use crate::{
hint::assets::HintAssets,
player::assets::PlayerAssets,
screens::Screen, screens::Screen,
theme::{interaction::InteractionAssets, prelude::*}, theme::{interaction::InteractionAssets, prelude::*},
}; };
@ -33,6 +35,10 @@ fn continue_to_title_screen(mut next_screen: ResMut<NextState<Screen>>) {
next_screen.set(Screen::Title); next_screen.set(Screen::Title);
} }
const fn all_assets_loaded(interaction_assets: Option<Res<InteractionAssets>>) -> bool { const fn all_assets_loaded(
interaction_assets.is_some() player_assets: Option<Res<PlayerAssets>>,
interaction_assets: Option<Res<InteractionAssets>>,
hints_assets: Option<Res<HintAssets>>,
) -> bool {
player_assets.is_some() && interaction_assets.is_some() && hints_assets.is_some()
} }

View File

@ -1,38 +1,36 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<meta charset="utf-8" /> <head>
<meta name="description" <meta charset="utf-8" />
content="Maze exploration game built using the Bevy engine"> <meta name="description" content="Maze exploration game built using the Bevy engine">
<meta name="keywords" content="game, bevy"> <meta name="keywords" content="game, bevy">
<title>Maze Ascension: The Labyrinth of Echoes</title> <title>Maze Ascension: The Labyrinth of Echoes</title>
<link data-trunk rel="copy-dir" href="../assets" /> <link data-trunk rel="copy-dir" href="../assets" />
<link data-trunk rel="inline" href="style.css" /> <link data-trunk rel="inline" href="style.css" />
<link data-trunk rel="inline" type="module" href="restart-audio-context.js" /> <link data-trunk rel="inline" type="module" href="restart-audio-context.js" />
<link data-trunk <link data-trunk rel="rust" data-cargo-no-default-features data-wasm-opt="s" href="../" />
rel="rust" </head>
data-cargo-no-default-features
data-wasm-opt="s" <body>
href="../" /> <div id="game" class="center">
</head> <div id="loading-screen" class="center">
<body> <span class="spinner"></span>
<div id="game" class="center">
<div id="loading-screen" class="center">
<span class="spinner"></span>
</div>
<canvas id="bevy"> Javascript and canvas support is required </canvas>
</div> </div>
<script type="module"> <canvas id="bevy"> Javascript and canvas support is required </canvas>
// Hide loading screen when the game starts. </div>
const loading_screen = document.getElementById("loading-screen"); <script type="module">
const bevy = document.getElementById("bevy"); // Hide loading screen when the game starts.
const observer = new MutationObserver(() => { const loading_screen = document.getElementById("loading-screen");
if (bevy.height > 1) { const bevy = document.getElementById("bevy");
loading_screen.style.display = "none"; const observer = new MutationObserver(() => {
observer.disconnect(); if (bevy.height > 1) {
} loading_screen.style.display = "none";
}); observer.disconnect();
observer.observe(bevy, { attributeFilter: ["height"] }); }
</script> });
</body> observer.observe(bevy, {attributeFilter: ["height"]});
</script>
</body>
</html> </html>

View File

@ -1,56 +1,56 @@
:root { :root {
/* Consider adjusting this color to match your splash screen! */ /* Consider adjusting this color to match your splash screen! */
--loading-screen-bg-color: #282828; --loading-screen-bg-color: #282828;
} }
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;
border: 0; border: 0;
} }
html, html,
body { body {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.center { .center {
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
} }
#loading-screen { #loading-screen {
background-color: var(--loading-screen-bg-color); background-color: var(--loading-screen-bg-color);
} }
.spinner { .spinner {
width: 128px; width: 128px;
height: 128px; height: 128px;
border: 64px solid transparent; border: 64px solid transparent;
border-bottom-color: #ececec; border-bottom-color: #ececec;
border-right-color: #b2b2b2; border-right-color: #b2b2b2;
border-top-color: #787878; border-top-color: #787878;
border-radius: 50%; border-radius: 50%;
box-sizing: border-box; box-sizing: border-box;
animation: spin 1.2s linear infinite; animation: spin 1.2s linear infinite;
} }
@keyframes spin { @keyframes spin {
0% { 0% {
transform: rotate(0deg); transform: rotate(0deg);
} }
100% { 100% {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
#bevy { #bevy {
/* Hide Bevy app before it loads */ /* Hide Bevy app before it loads */
height: 0; height: 0;
} }