-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load github resources from web editor (#68)
* wasm url loader * testing * style fix and format fix * forgot to save * update botw-map * update botw-map * update default branch and add preset placeholders * run fixer * small fixes
- Loading branch information
1 parent
22df33c
commit ef09b59
Showing
33 changed files
with
264 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use std::cell::RefCell; | ||
|
||
use celerc::pack::{PackerError, PackerResult, ResourceLoader}; | ||
use celerc::yield_now; | ||
use js_sys::{Function, Uint8Array}; | ||
use wasm_bindgen::{JsCast, JsValue}; | ||
|
||
use crate::wasm::{into_future, stub_function}; | ||
|
||
/// Loader for loading a URL using a provided JS function | ||
pub struct UrlLoader { | ||
/// Callback function to ask JS to load a file | ||
/// | ||
/// Takes in a string (url) as argument. | ||
/// Returns a promise that resolves to a Uint8Array that could throw | ||
fetch: RefCell<Function>, | ||
} | ||
|
||
impl UrlLoader { | ||
pub fn new() -> Self { | ||
Self { | ||
fetch: RefCell::new(stub_function()), | ||
} | ||
} | ||
pub fn init(&self, fetch: Function) { | ||
self.fetch.replace(fetch); | ||
} | ||
} | ||
|
||
#[async_trait::async_trait(?Send)] | ||
impl ResourceLoader for UrlLoader { | ||
async fn load_raw(&self, url: &str) -> PackerResult<Vec<u8>> { | ||
yield_now!()?; | ||
let result: Result<Uint8Array, JsValue> = async { | ||
let promise = self | ||
.fetch | ||
.borrow() | ||
.call1(&JsValue::UNDEFINED, &JsValue::from(url))?; | ||
let vec: Uint8Array = into_future(promise).await?.dyn_into()?; | ||
Ok(vec) | ||
} | ||
.await; | ||
// see if JS call is successful | ||
let uint8arr = | ||
result.map_err(|_| PackerError::LoadUrl(format!("loading URL failed: {url}")))?; | ||
Ok(uint8arr.to_vec()) | ||
} | ||
|
||
async fn load_image_url(&self, url: &str) -> PackerResult<String> { | ||
// image is already a URL, so just return it | ||
Ok(url.to_string()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type bool = boolean; | ||
type JsValue = any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Presets for Breath of the Wild | ||
README under construction. Tracked by https://github.com/Pistonite/celer/issues/27 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
map: | ||
layers: | ||
- name: Overworld | ||
template-url: https://objmap.zeldamods.org/game_files/maptex/{z}/{x}/{y}.png | ||
size: [24000, 20000] | ||
max-native-zoom: 7 | ||
zoom-bounds: [2, 9] | ||
transform: | ||
translate: [12000, 10000] | ||
scale: [2, 2] | ||
start-z: -5000 | ||
attribution: | ||
link: https://objmap.zeldamods.org | ||
coord-map: | ||
"2d": [x, y] | ||
"3d": [x, z, y] | ||
initial-coord: [-1099.10, 242.00, 1876.31] | ||
initial-zoom: 3 | ||
initial-color: "#38F" | ||
|
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.