2019-04-26 03:30:46 +00:00
|
|
|
/// This macro will automatically load all specified assets, get the corresponding ImgIds and
|
|
|
|
/// create a struct with all of them
|
|
|
|
///
|
|
|
|
/// Example usage:
|
|
|
|
/// ```
|
|
|
|
/// image_ids! {
|
2019-04-28 16:44:44 +00:00
|
|
|
/// pub struct Imgs {
|
|
|
|
/// <DotVoxData>
|
2019-04-26 03:30:46 +00:00
|
|
|
/// button1: "filename1.vox",
|
|
|
|
/// button2: "filename2.vox",
|
2019-04-28 16:44:44 +00:00
|
|
|
///
|
|
|
|
/// <DynamicImage>
|
2019-04-26 03:30:46 +00:00
|
|
|
/// background: "background.png",
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
// TODO: will this work with shorter name paths? eg not rate::ui::Graphic::
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! image_ids {
|
2019-04-28 16:44:44 +00:00
|
|
|
($($v:vis struct $Ids:ident { $( <$T:ty> $( $name:ident: $specifier:expr ),* $(,)? )* })*) => {
|
2019-04-26 03:30:46 +00:00
|
|
|
$(
|
|
|
|
$v struct $Ids {
|
2019-04-28 16:44:44 +00:00
|
|
|
$($( $v $name: conrod_core::image::Id, )*)*
|
2019-04-26 03:30:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl $Ids {
|
2019-04-28 04:44:13 +00:00
|
|
|
pub fn load(ui: &mut crate::ui::Ui) -> Result<Self, common::assets::Error> {
|
2019-04-26 03:30:46 +00:00
|
|
|
Ok(Self {
|
2019-04-28 16:44:44 +00:00
|
|
|
$($( $name: ui.new_graphic(common::assets::load::<$T>($specifier)?.into()), )*)*
|
2019-04-26 03:30:46 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)*
|
|
|
|
};
|
|
|
|
}
|