Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Strange things in menus

  1. #11
    Private Lonsofore's Avatar
    Join Date
    Oct 2016
    Posts
    86
    Thanks
    82
    Thanked 38 Times in 25 Posts
    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_CHOICEAm1carbine_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_CHOICEAm1carbine_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.

  2. #12
    Private Lonsofore's Avatar
    Join Date
    Oct 2016
    Posts
    86
    Thanks
    82
    Thanked 38 Times in 25 Posts
    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?

  3. #13
    Private Lonsofore's Avatar
    Join Date
    Oct 2016
    Posts
    86
    Thanks
    82
    Thanked 38 Times in 25 Posts
    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

  4. #14
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    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
    timescale 0.01

  5. The Following User Says Thank You to kung foo man For This Useful Post:

    kubislav23 (18th June 2017)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •