diff options
Diffstat (limited to 'games/rstnode/rst-client/src/assets.rs')
-rw-r--r-- | games/rstnode/rst-client/src/assets.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/games/rstnode/rst-client/src/assets.rs b/games/rstnode/rst-client/src/assets.rs new file mode 100644 index 000000000000..7e368b8d4c16 --- /dev/null +++ b/games/rstnode/rst-client/src/assets.rs @@ -0,0 +1,44 @@ +use ggez::graphics::Image; +use std::{collections::BTreeMap, path::Path}; + +/// Construct a `node` prefixed URI +pub fn node(tt: &str) -> URI { + ("node/".to_owned() + tt).into() +} + +#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] +pub struct URI(String, String); + +impl From<&'static str> for URI { + fn from(s: &'static str) -> Self { + let mut v: Vec<_> = s.split("/").collect(); + Self(v.remove(0).into(), v.remove(0).into()) + } +} + +impl From<String> for URI { + fn from(s: String) -> Self { + let mut v: Vec<_> = s.split("/").collect(); + Self(v.remove(0).into(), v.remove(0).into()) + } +} + +/// Asset loader +pub struct Assets { + inner: BTreeMap<URI, Image>, +} + +impl Assets { + pub fn load(p: &Path) -> Self { + Self { + inner: Default::default(), + } + } +} + + +/// A utility function to take an SVG and render it to a raster image +/// according to a render spec +fn load_svg(p: &Path) -> () { + +} |