src_ext
This commit is contained in:
@@ -160,6 +160,10 @@ _2nd gradient color_
|
|||||||
|
|
||||||
_External (filesystem) image path. Falls back to Internal (assets) if not found._
|
_External (filesystem) image path. Falls back to Internal (assets) if not found._
|
||||||
|
|
||||||
|
`src_ext`: **string**
|
||||||
|
|
||||||
|
_External (filesystem) image path_
|
||||||
|
|
||||||
`src_builtin`: **string**
|
`src_builtin`: **string**
|
||||||
|
|
||||||
_Internal (assets) image path_
|
_Internal (assets) image path_
|
||||||
@@ -210,7 +214,7 @@ _Tooltip text on hover, translated by key_
|
|||||||
|
|
||||||
_make button act as a toggle (visual only)_
|
_make button act as a toggle (visual only)_
|
||||||
|
|
||||||
`sprite_src` | `sprite_src_builtin` | `sprite_src_internal`
|
`sprite_src` | `sprite_src_ext` | `sprite_src_builtin` | `sprite_src_internal`
|
||||||
|
|
||||||
_Image path (see [sprite](#sprite-widget)) for src descriptions_
|
_Image path (see [sprite](#sprite-widget)) for src descriptions_
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,16 @@ pub enum AssetPath<'a> {
|
|||||||
WguiInternal(&'a str), // tied to internal wgui AssetProvider. Used internally
|
WguiInternal(&'a str), // tied to internal wgui AssetProvider. Used internally
|
||||||
BuiltIn(&'a str), // tied to user AssetProvider
|
BuiltIn(&'a str), // tied to user AssetProvider
|
||||||
FileOrBuiltIn(&'a str), // attempts to load from a path relative to asset_folder, falls back to BuiltIn
|
FileOrBuiltIn(&'a str), // attempts to load from a path relative to asset_folder, falls back to BuiltIn
|
||||||
|
File(&'a str), // load from filesystem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// see AssetPath above for documentation
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum AssetPathOwned {
|
pub enum AssetPathOwned {
|
||||||
WguiInternal(PathBuf),
|
WguiInternal(PathBuf),
|
||||||
BuiltIn(PathBuf),
|
BuiltIn(PathBuf),
|
||||||
FileOrBuiltIn(PathBuf),
|
FileOrBuiltIn(PathBuf),
|
||||||
|
File(PathBuf),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AssetPath<'_> {
|
impl AssetPath<'_> {
|
||||||
@@ -23,6 +26,7 @@ impl AssetPath<'_> {
|
|||||||
AssetPath::WguiInternal(path) => path,
|
AssetPath::WguiInternal(path) => path,
|
||||||
AssetPath::BuiltIn(path) => path,
|
AssetPath::BuiltIn(path) => path,
|
||||||
AssetPath::FileOrBuiltIn(path) => path,
|
AssetPath::FileOrBuiltIn(path) => path,
|
||||||
|
AssetPath::File(path) => path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +35,7 @@ impl AssetPath<'_> {
|
|||||||
AssetPath::WguiInternal(path) => AssetPathOwned::WguiInternal(PathBuf::from(path)),
|
AssetPath::WguiInternal(path) => AssetPathOwned::WguiInternal(PathBuf::from(path)),
|
||||||
AssetPath::BuiltIn(path) => AssetPathOwned::BuiltIn(PathBuf::from(path)),
|
AssetPath::BuiltIn(path) => AssetPathOwned::BuiltIn(PathBuf::from(path)),
|
||||||
AssetPath::FileOrBuiltIn(path) => AssetPathOwned::FileOrBuiltIn(PathBuf::from(path)),
|
AssetPath::FileOrBuiltIn(path) => AssetPathOwned::FileOrBuiltIn(PathBuf::from(path)),
|
||||||
|
AssetPath::File(path) => AssetPathOwned::File(PathBuf::from(path)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,6 +46,7 @@ impl AssetPathOwned {
|
|||||||
AssetPathOwned::WguiInternal(buf) => AssetPath::WguiInternal(buf.to_str().unwrap()),
|
AssetPathOwned::WguiInternal(buf) => AssetPath::WguiInternal(buf.to_str().unwrap()),
|
||||||
AssetPathOwned::BuiltIn(buf) => AssetPath::BuiltIn(buf.to_str().unwrap()),
|
AssetPathOwned::BuiltIn(buf) => AssetPath::BuiltIn(buf.to_str().unwrap()),
|
||||||
AssetPathOwned::FileOrBuiltIn(buf) => AssetPath::FileOrBuiltIn(buf.to_str().unwrap()),
|
AssetPathOwned::FileOrBuiltIn(buf) => AssetPath::FileOrBuiltIn(buf.to_str().unwrap()),
|
||||||
|
AssetPathOwned::File(buf) => AssetPath::File(buf.to_str().unwrap()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +55,7 @@ impl AssetPathOwned {
|
|||||||
AssetPathOwned::WguiInternal(buf) => buf,
|
AssetPathOwned::WguiInternal(buf) => buf,
|
||||||
AssetPathOwned::BuiltIn(buf) => buf,
|
AssetPathOwned::BuiltIn(buf) => buf,
|
||||||
AssetPathOwned::FileOrBuiltIn(buf) => buf,
|
AssetPathOwned::FileOrBuiltIn(buf) => buf,
|
||||||
|
AssetPathOwned::File(buf) => buf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,6 +72,7 @@ impl AssetPathOwned {
|
|||||||
AssetPathOwned::WguiInternal(_) => AssetPathOwned::WguiInternal(new_path),
|
AssetPathOwned::WguiInternal(_) => AssetPathOwned::WguiInternal(new_path),
|
||||||
AssetPathOwned::BuiltIn(_) => AssetPathOwned::BuiltIn(new_path),
|
AssetPathOwned::BuiltIn(_) => AssetPathOwned::BuiltIn(new_path),
|
||||||
AssetPathOwned::FileOrBuiltIn(_) => AssetPathOwned::FileOrBuiltIn(new_path),
|
AssetPathOwned::FileOrBuiltIn(_) => AssetPathOwned::FileOrBuiltIn(new_path),
|
||||||
|
AssetPathOwned::File(_) => AssetPathOwned::File(new_path),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ impl WguiGlobals {
|
|||||||
match asset_path {
|
match asset_path {
|
||||||
AssetPath::WguiInternal(path) => self.assets_internal().load_from_path(path),
|
AssetPath::WguiInternal(path) => self.assets_internal().load_from_path(path),
|
||||||
AssetPath::BuiltIn(path) => self.assets_builtin().load_from_path(path),
|
AssetPath::BuiltIn(path) => self.assets_builtin().load_from_path(path),
|
||||||
|
AssetPath::File(path) => self.load_asset_from_fs(path),
|
||||||
AssetPath::FileOrBuiltIn(path) => self
|
AssetPath::FileOrBuiltIn(path) => self
|
||||||
.load_asset_from_fs(path)
|
.load_asset_from_fs(path)
|
||||||
.inspect_err(|e| log::debug!("{e:?}"))
|
.inspect_err(|e| log::debug!("{e:?}"))
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
assets::AssetPath,
|
assets::AssetPath,
|
||||||
components::{button, tooltip, Component},
|
components::{Component, button, tooltip},
|
||||||
drawing::Color,
|
drawing::Color,
|
||||||
i18n::Translation,
|
i18n::Translation,
|
||||||
layout::WidgetID,
|
layout::WidgetID,
|
||||||
parser::{
|
parser::{
|
||||||
parse_check_f32, parse_check_i32, parse_children, print_invalid_attrib, process_component,
|
AttribPair, ParserContext, ParserFile, parse_check_f32, parse_check_i32, parse_children, print_invalid_attrib,
|
||||||
|
process_component,
|
||||||
style::{parse_color_opt, parse_round, parse_style, parse_text_style},
|
style::{parse_color_opt, parse_round, parse_style, parse_text_style},
|
||||||
AttribPair, ParserContext, ParserFile,
|
|
||||||
},
|
},
|
||||||
widget::util::WLength,
|
widget::util::WLength,
|
||||||
};
|
};
|
||||||
@@ -62,9 +62,10 @@ pub fn parse_component_button<'a>(
|
|||||||
"hover_border_color" => {
|
"hover_border_color" => {
|
||||||
parse_color_opt(value, &mut hover_border_color);
|
parse_color_opt(value, &mut hover_border_color);
|
||||||
}
|
}
|
||||||
"sprite_src" | "sprite_src_builtin" | "sprite_src_internal" => {
|
"sprite_src" | "sprite_src_ext" | "sprite_src_builtin" | "sprite_src_internal" => {
|
||||||
let asset_path = match key {
|
let asset_path = match key {
|
||||||
"sprite_src" => AssetPath::FileOrBuiltIn(value),
|
"sprite_src" => AssetPath::FileOrBuiltIn(value),
|
||||||
|
"sprite_src_ext" => AssetPath::File(value),
|
||||||
"sprite_src_builtin" => AssetPath::BuiltIn(value),
|
"sprite_src_builtin" => AssetPath::BuiltIn(value),
|
||||||
"sprite_src_internal" => AssetPath::WguiInternal(value),
|
"sprite_src_internal" => AssetPath::WguiInternal(value),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ mod widget_rectangle;
|
|||||||
mod widget_sprite;
|
mod widget_sprite;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
assets::{normalize_path, AssetPath, AssetPathOwned},
|
assets::{AssetPath, AssetPathOwned, normalize_path},
|
||||||
components::{Component, ComponentWeak},
|
components::{Component, ComponentWeak},
|
||||||
drawing::{self},
|
drawing::{self},
|
||||||
globals::WguiGlobals,
|
globals::WguiGlobals,
|
||||||
@@ -551,7 +551,7 @@ fn parse_tag_include(
|
|||||||
for pair in attribs {
|
for pair in attribs {
|
||||||
#[allow(clippy::single_match)]
|
#[allow(clippy::single_match)]
|
||||||
match pair.attrib.as_ref() {
|
match pair.attrib.as_ref() {
|
||||||
"src" | "src_builtin" | "src_internal" => {
|
"src" | "src_ext" | "src_builtin" | "src_internal" => {
|
||||||
path = Some({
|
path = Some({
|
||||||
let this = &file.path.clone();
|
let this = &file.path.clone();
|
||||||
let include: &str = &pair.value;
|
let include: &str = &pair.value;
|
||||||
@@ -565,7 +565,9 @@ fn parse_tag_include(
|
|||||||
AssetPathOwned::WguiInternal(_) => AssetPathOwned::WguiInternal(new_path),
|
AssetPathOwned::WguiInternal(_) => AssetPathOwned::WguiInternal(new_path),
|
||||||
AssetPathOwned::BuiltIn(_) => AssetPathOwned::BuiltIn(new_path),
|
AssetPathOwned::BuiltIn(_) => AssetPathOwned::BuiltIn(new_path),
|
||||||
AssetPathOwned::FileOrBuiltIn(_) => AssetPathOwned::FileOrBuiltIn(new_path),
|
AssetPathOwned::FileOrBuiltIn(_) => AssetPathOwned::FileOrBuiltIn(new_path),
|
||||||
|
AssetPathOwned::File(_) => AssetPathOwned::File(new_path),
|
||||||
},
|
},
|
||||||
|
"src_ext" => AssetPathOwned::File(new_path),
|
||||||
"src_builtin" => AssetPathOwned::BuiltIn(new_path),
|
"src_builtin" => AssetPathOwned::BuiltIn(new_path),
|
||||||
"src_internal" => AssetPathOwned::WguiInternal(new_path),
|
"src_internal" => AssetPathOwned::WguiInternal(new_path),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
assets::AssetPath,
|
assets::AssetPath,
|
||||||
layout::WidgetID,
|
layout::WidgetID,
|
||||||
parser::{parse_children, parse_widget_universal, style::parse_style, AttribPair, ParserContext, ParserFile},
|
parser::{AttribPair, ParserContext, ParserFile, parse_children, parse_widget_universal, style::parse_style},
|
||||||
renderer_vk::text::custom_glyph::{CustomGlyphContent, CustomGlyphData},
|
renderer_vk::text::custom_glyph::{CustomGlyphContent, CustomGlyphData},
|
||||||
widget::sprite::{WidgetSprite, WidgetSpriteParams},
|
widget::sprite::{WidgetSprite, WidgetSpriteParams},
|
||||||
};
|
};
|
||||||
@@ -22,9 +22,10 @@ pub fn parse_widget_sprite<'a>(
|
|||||||
for pair in attribs {
|
for pair in attribs {
|
||||||
let (key, value) = (pair.attrib.as_ref(), pair.value.as_ref());
|
let (key, value) = (pair.attrib.as_ref(), pair.value.as_ref());
|
||||||
match key {
|
match key {
|
||||||
"src" | "src_builtin" | "src_internal" => {
|
"src" | "src_ext" | "src_builtin" | "src_internal" => {
|
||||||
let asset_path = match key {
|
let asset_path = match key {
|
||||||
"src" => AssetPath::FileOrBuiltIn(value),
|
"src" => AssetPath::FileOrBuiltIn(value),
|
||||||
|
"src_ext" => AssetPath::File(value),
|
||||||
"src_builtin" => AssetPath::BuiltIn(value),
|
"src_builtin" => AssetPath::BuiltIn(value),
|
||||||
"src_internal" => AssetPath::WguiInternal(value),
|
"src_internal" => AssetPath::WguiInternal(value),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|||||||
Reference in New Issue
Block a user