-
Ok, so I've got this problem. I tried this case:
PHP Code:
#ifndef DRAW_WEAPON_ITEM
#define DRAW_WEAPON_ITEM(_key, _name) \
itemDef \
{ \
name "button_" ## _name \
visible 1 \
rect 0 0 128 24 HORIZONTAL_ALIGN_DEFAULT VERTICAL_ALIGN_DEFAULT \
origin _key \
forecolor GLOBAL_UNFOCUSED_COLOR \
type ITEM_TYPE_BUTTON \
text "test " ## _name \
textfont UI_FONT_NORMAL \
textscale .25 \
textstyle ITEM_TEXTSTYLE_SHADOWED \
textalignx 10 \
textaligny 20 \
}
#endif
#define DRAW_WEAPON(_key, _name) DRAW_WEAPON_ITEM(_key, _name)
DRAW_WEAPON(ORIGIN_CHOICEA, m1carbine_mp)
And the button name here was "test _name". So, my variable wasn't used. I tried this one then (with #):
PHP Code:
#ifndef DRAW_WEAPON_ITEM
#define DRAW_WEAPON_ITEM(_key, _name) \
itemDef \
{ \
name "button_" ## #_name \
visible 1 \
rect 0 0 128 24 HORIZONTAL_ALIGN_DEFAULT VERTICAL_ALIGN_DEFAULT \
origin _key \
forecolor GLOBAL_UNFOCUSED_COLOR \
type ITEM_TYPE_BUTTON \
text "test " ## #_name \
textfont UI_FONT_NORMAL \
textscale .25 \
textstyle ITEM_TEXTSTYLE_SHADOWED \
textalignx 10 \
textaligny 20 \
}
#endif
#define DRAW_WEAPON(_key, _name) DRAW_WEAPON_ITEM(_key, #_name)
DRAW_WEAPON(ORIGIN_CHOICEA, m1carbine_mp)
And here I've got this name: "test #_name". So, as I see, we can't send our variables. And that's strange, because in kung used it... By the way, with define ORIGIN_CHOICEA it works, so I'll try to use defines only.
-
Ok, and here I found why kung could use it and why I couldn't. That's all because we can't use concatenation here. Removed concatenation and now it's ok:
PHP Code:
#ifndef DRAW_WEAPON_ITEM
#define DRAW_WEAPON_ITEM(_key, _name) \
itemDef \
{ \
name _name \
visible 1 \
rect 0 0 128 24 HORIZONTAL_ALIGN_DEFAULT VERTICAL_ALIGN_DEFAULT \
origin _key \
forecolor GLOBAL_UNFOCUSED_COLOR \
type ITEM_TYPE_BUTTON \
text _name \
textfont UI_FONT_NORMAL \
textscale .25 \
textstyle ITEM_TEXTSTYLE_SHADOWED \
textalignx 10 \
textaligny 20 \
}
#endif
#define DRAW_WEAPON(_key, _name) DRAW_WEAPON_ITEM(_key, _name)
DRAW_WEAPON(ORIGIN_CHOICEA, "m1carbine_mp")
Or maybe somebody knows how to use it?
-
By the way. in this message serthy showed concatenation outside the macros:
PHP Code:
GOOD( "test" , "test " TEST " blaa" )
But can we do the same with non-string text (without quotes)? Because this cases don't work (TEST is variable here):
PHP Code:
FUNC( "test" , test TEST blaa )
PHP Code:
FUNC( "test" , test ## TEST ## blaa )
P.S. and sorry for 3 messages in a row
-
By the time of now you could already have written a Python/PHP/Perl/whatever script which easily produces way more complex menus than what macro fu ever could :p