From 88bf1aaa9446a218e55eb02c7b5a46873641f19e Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sun, 28 Apr 2019 17:20:08 +0200 Subject: [PATCH] Change macro to make single struct Former-commit-id: ed7876d49fccdc7fb11317c13b59b2b4776daef9 --- voxygen/src/assets/ids.rs | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/voxygen/src/assets/ids.rs b/voxygen/src/assets/ids.rs index aa61686cca..d8dc4e8277 100644 --- a/voxygen/src/assets/ids.rs +++ b/voxygen/src/assets/ids.rs @@ -30,35 +30,35 @@ impl UiId for DotVoxData { /// Example usage: /// ``` /// image_ids! { -/// struct Voxs { +/// pub struct Ids { +/// /// button1: "filename1.vox", /// button2: "filename2.vox", -/// } -/// struct Voxs { +/// +/// /// background: "background.png", /// } /// } /// ``` macro_rules! image_ids { - ($(pub struct<$T:ty> $Ids:ident { $( $name:ident: $file:expr ), *$(,)? } )*) => { - $( - pub struct $Ids { - $( $name: ImgId, )* - } + (pub struct $Ids:ident { $( <$T:ty> $( $name:ident: $file:expr ),* $(,)? )* }) => { + pub struct $Ids { + $($( $name: ImgId, )*)* + } - impl $Ids { - pub fn load(ui: &mut Ui) -> Result { - Ok(Self { - $( $name: UiId::to_ui_asset(<$T>::load($file)?, ui), )* - }) - } + impl $Ids { + pub fn load(ui: &mut Ui) -> Result { + Ok(Self { + $($( $name: UiId::to_ui_asset(<$T>::load($file)?, ui), )*)* + }) } - )* + } }; } image_ids! { - pub struct Voxs { + pub struct Ids { + // Bag bag_contents: "element/frames/bag.vox", inv_grid: "element/frames/inv_grid.vox", @@ -102,9 +102,8 @@ image_ids! { window_frame: "element/frames/window2.vox", map_frame_l: "element/frames/map_l.vox", map_frame_r: "element/frames/map_r.vox", - } - pub struct Imgs { + // Bag bag: "element/buttons/bag/closed.png", bag_hover: "element/buttons/bag/closed_hover.png",