Load placeholder from settings
This commit is contained in:
parent
9c497a1fdb
commit
69c2353730
2 changed files with 42 additions and 42 deletions
|
@ -30,7 +30,7 @@ impl ItemRightSide {
|
|||
hero: Entity,
|
||||
) -> Result<Self> {
|
||||
let snippet = GuiSnippet::from_str(engine.gui_handler(), file)?;
|
||||
let icons = InventoryEmptyIcons::new(&snippet)?;
|
||||
let icons = InventoryEmptyIcons::new(engine)?;
|
||||
|
||||
let me = Self {
|
||||
snippet,
|
||||
|
@ -151,31 +151,34 @@ struct InventoryEmptyIcons {
|
|||
}
|
||||
|
||||
impl InventoryEmptyIcons {
|
||||
fn new(ui: &GuiSnippet) -> Result<Self> {
|
||||
get_place_holder!(ui, helmet);
|
||||
get_place_holder!(ui, chest);
|
||||
get_place_holder!(ui, boots);
|
||||
get_place_holder!(ui, belt);
|
||||
get_place_holder!(ui, gloves);
|
||||
|
||||
get_place_holder!(ui, primary_hand, "main hand");
|
||||
get_place_holder!(ui, secondary_hand, "off hand");
|
||||
|
||||
get_place_holder!(ui, ring, "ring_0");
|
||||
get_place_holder!(ui, amulet, "amulet_0");
|
||||
fn new(engine: &Engine) -> Result<Self> {
|
||||
let place_holder_settings = &engine
|
||||
.scene()
|
||||
.resources
|
||||
.get::<ItemSettings>()
|
||||
.icon_place_holder_paths;
|
||||
|
||||
Ok(Self {
|
||||
helmet,
|
||||
chest,
|
||||
belt,
|
||||
boots,
|
||||
gloves,
|
||||
helmet: Image::from_file(place_holder_settings.helmet.clone())?
|
||||
.build(engine.device(), engine.queue())?,
|
||||
chest: Image::from_file(place_holder_settings.chest.clone())?
|
||||
.build(engine.device(), engine.queue())?,
|
||||
belt: Image::from_file(place_holder_settings.belt.clone())?
|
||||
.build(engine.device(), engine.queue())?,
|
||||
boots: Image::from_file(place_holder_settings.boots.clone())?
|
||||
.build(engine.device(), engine.queue())?,
|
||||
gloves: Image::from_file(place_holder_settings.gloves.clone())?
|
||||
.build(engine.device(), engine.queue())?,
|
||||
|
||||
primary_hand,
|
||||
secondary_hand,
|
||||
primary_hand: Image::from_file(place_holder_settings.main_hand.clone())?
|
||||
.build(engine.device(), engine.queue())?,
|
||||
secondary_hand: Image::from_file(place_holder_settings.off_hand.clone())?
|
||||
.build(engine.device(), engine.queue())?,
|
||||
|
||||
ring,
|
||||
amulet,
|
||||
ring: Image::from_file(place_holder_settings.ring.clone())?
|
||||
.build(engine.device(), engine.queue())?,
|
||||
amulet: Image::from_file(place_holder_settings.amulet.clone())?
|
||||
.build(engine.device(), engine.queue())?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -516,24 +519,4 @@ mod macros {
|
|||
}
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! get_place_holder {
|
||||
($gui:ident, $name:ident) => {
|
||||
let $name = {
|
||||
let button: Arc<Button> = $gui.element(stringify!($name))?;
|
||||
button
|
||||
.icon()?
|
||||
.expect(&format!("missing {} placeholder", stringify!($name)))
|
||||
};
|
||||
};
|
||||
($gui:ident, $name:ident, $id:literal) => {
|
||||
let $name = {
|
||||
let button: Arc<Button> = $gui.element($id)?;
|
||||
button
|
||||
.icon()?
|
||||
.expect(&format!("missing {} placeholder", $id))
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,6 +133,22 @@ create_settings_section!(
|
|||
}
|
||||
);
|
||||
|
||||
create_settings_section!(
|
||||
ItemPlaceHolderIconPaths,
|
||||
"ItemPlaceHolderIcons",
|
||||
{
|
||||
amulet: AssetPath,
|
||||
boots: AssetPath,
|
||||
chest: AssetPath,
|
||||
helmet: AssetPath,
|
||||
ring: AssetPath,
|
||||
belt: AssetPath,
|
||||
gloves: AssetPath,
|
||||
main_hand: AssetPath,
|
||||
off_hand: AssetPath,
|
||||
}
|
||||
);
|
||||
|
||||
create_settings_section!(
|
||||
JewelIconPaths,
|
||||
"JewelIcons",
|
||||
|
@ -164,6 +180,7 @@ create_settings_container!(
|
|||
{
|
||||
general: GeneralItemSettings,
|
||||
icon_paths: ItemIconPaths,
|
||||
icon_place_holder_paths: ItemPlaceHolderIconPaths,
|
||||
jewel_paths: JewelIconPaths,
|
||||
jewel_rarity_multiplier: JewelRarityMultiplier,
|
||||
rarity_color_settings: RarityColorSettings,
|
||||
|
|
Loading…
Reference in a new issue