mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-13 10:12:19 -06:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ec800a88fc | |||
| abc37dee4e | |||
| 1ae7839275 |
11
.github/workflows/build.yaml
vendored
11
.github/workflows/build.yaml
vendored
@@ -11,8 +11,6 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build (${{ matrix.target }})
|
name: Build (${{ matrix.target }})
|
||||||
env:
|
|
||||||
VCPKG_SYSTEM_LIBRARIES: "OFF"
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -47,15 +45,16 @@ jobs:
|
|||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: target/vcpkg
|
path: target/vcpkg
|
||||||
key: ${{ runner.os }}-vcpkg-${{ hashFiles('Cargo.toml', 'Cargo.lock') }}
|
key: vcpkg-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('Cargo.toml', 'Cargo.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-vcpkg-
|
${{ runner.os }}-vcpkg
|
||||||
|
vcpkg-${{ runner.os }}-${{ matrix.target }}-
|
||||||
|
|
||||||
- name: Vcpkg Linux Dependencies
|
- name: Vcpkg Linux Dependencies
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y build-essential gettext libltdl-dev
|
sudo apt-get install -y build-essential gettext libltdl-dev zlib1g-dev
|
||||||
|
|
||||||
- name: Vcpkg
|
- name: Vcpkg
|
||||||
run: |
|
run: |
|
||||||
@@ -125,7 +124,7 @@ jobs:
|
|||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
cp assets/site/{build.css,favicon.ico,index.html} dist
|
cp assets/site/{build.css,favicon.ico,index.html} dist
|
||||||
output_folder="target/wasm32-unknown-emscripten/release"
|
output_folder="target/wasm32-unknown-emscripten/release"
|
||||||
cp $output_folder/pacman.{wasm,js,data} dist
|
cp $output_folder/pacman.{wasm,js} $output_folder/deps/pacman.data dist
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-pages-artifact@v3
|
uses: actions/upload-pages-artifact@v3
|
||||||
|
|||||||
18
src/asset.rs
18
src/asset.rs
@@ -78,15 +78,17 @@ mod imp {
|
|||||||
#[cfg(target_os = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::fs;
|
use sdl2::rwops::RWops;
|
||||||
use std::path::Path;
|
use std::io::Read;
|
||||||
pub fn get_asset_bytes(asset: Asset) -> Result<Cow<'static, [u8]>, AssetError> {
|
pub fn get_asset_bytes(asset: Asset) -> Result<Cow<'static, [u8]>, AssetError> {
|
||||||
let path = Path::new("assets/game").join(asset.path());
|
let path = format!("assets/game/{}", asset.path());
|
||||||
if !path.exists() {
|
let mut rwops = RWops::from_file(&path, "rb").map_err(|_| AssetError::NotFound(asset.path().to_string()))?;
|
||||||
return Err(AssetError::NotFound(asset.path().to_string()));
|
let len = rwops.len().ok_or_else(|| AssetError::NotFound(asset.path().to_string()))?;
|
||||||
}
|
let mut buf = vec![0u8; len];
|
||||||
let bytes = fs::read(&path)?;
|
rwops
|
||||||
Ok(Cow::Owned(bytes))
|
.read_exact(&mut buf)
|
||||||
|
.map_err(|e| AssetError::Io(std::io::Error::new(std::io::ErrorKind::Other, e)))?;
|
||||||
|
Ok(Cow::Owned(buf))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user