From d346d68aedf60d60a3da65d9e88f1f1e9789bf35 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 7 Jul 2024 17:44:17 +0200 Subject: [PATCH] redistributable game --- .forgejo/workflows/rust.yml | 1 + src/activities/house/furniture.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.forgejo/workflows/rust.yml b/.forgejo/workflows/rust.yml index 84e04f9..9e19494 100644 --- a/.forgejo/workflows/rust.yml +++ b/.forgejo/workflows/rust.yml @@ -66,3 +66,4 @@ jobs: name: Powercreep path: .ci-destdir/* + assets diff --git a/src/activities/house/furniture.rs b/src/activities/house/furniture.rs index 0377185..916eecc 100644 --- a/src/activities/house/furniture.rs +++ b/src/activities/house/furniture.rs @@ -1,5 +1,5 @@ use comfy::{error, texture_id, EngineContext, HashSet, Lazy, Mutex, TextureHandle}; -use std::{fmt::Debug, fs, io, sync::Arc}; +use std::{fmt::Debug, fs, io, path::PathBuf, sync::Arc}; static ASSETS_LOADED: Lazy>>> = Lazy::new(|| Arc::new(Mutex::new(HashSet::new()))); @@ -39,10 +39,13 @@ impl FurnitureAsset { if loaded.contains(&path) { return Some(texture_id(&path)); } - let bytes = match fs::read(format!( - "{}/assets/furniture/{path}", - env!("CARGO_MANIFEST_DIR") - )) { + + let mut asset_path = PathBuf::from(format!("assets/furniture/{path}")); + if !asset_path.exists() { + asset_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(asset_path); + } + + let bytes = match fs::read(asset_path) { Ok(bytes) => bytes, Err(err) if err.kind() == io::ErrorKind::NotFound => return None, Err(err) => {