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

Thread: [CoD2] create functions in .menu-files!

  1. #11
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Does somebody spot the error? I'm trying around for some time, but I just can't find it:

    PHP Code:
            #define ITEM(_rect, _dvar) \
            
    itemDef \
            { \
                
    name            "window" \
                
    group            ingamebox \
                
    visible            1 \
                
    rect             _rect \
                
    origin            ORIGIN_QUICKMESSAGEWINDOW \
                
    forecolor        1 1 1 1 \
                
    textfont        UI_FONT_NORMAL \
                
    textscale        .24 \
                
    textaligny        8 \
                
    dvar            _dvar \
                
    decoration \
            }
            
            
    ITEM(16  20 0 0 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN"menu_1")
            
    ITEM(16  36 0 0 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN"menu_2")
            
    ITEM(16  52 0 0 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN"menu_3")
            
    ITEM(16  68 0 0 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN"menu_4")
            
    ITEM(16  84 0 0 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN"menu_5")
            
    ITEM(16 100 0 0 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN"menu_6")
            
    ITEM(16 116 0 0 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN"menu_7")
            
    ITEM(16 132 0 0 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN"menu_8")
            
    ITEM(16 148 0 0 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN"menu_9")
            
    ITEM(16 164 0 0 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN"menu_0"
    (when I unpack the macro everything looks fine)

    It's supposed to generate a quickmenu, but the font becomes messed up:
    Attached Thumbnails Attached Thumbnails quickmenu.jpg  
    timescale 0.01

  2. #12
    Private First Class RobsoN's Avatar
    Join Date
    Jan 2013
    Location
    /home/cod2/
    Posts
    230
    Thanks
    119
    Thanked 95 Times in 64 Posts
    Did you try with normal spaces between numbers in (first) rect argument?
    "Don't worry if your code doesn't work correctly - if everything worked, you would not work" ~Mosher's right

  3. #13
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    It looks like ORIGIN_QUICKMESSAGEWINDOW is not defined. Try putting in the raw coordinates instead of a definition.

  4. #14
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    I think it is defined, but I also think its not fullscreen align, but rather a center_safearea thingy.

    It should align correctly on 4:3 aspect ratio though, but try center_safearea first (or dig through cod2 source to find possible values)

  5. #15
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Thanks for all the answers, I was already kinda giving up on this

    IzNoGods fullscreen align thought and the search through ui/menudefinition.h got me the answer, now it's nice and clean

    PHP Code:
            #define RECT4(_rect_) \
                
    rect _rect_ HORIZONTAL_ALIGN_DEFAULT VERTICAL_ALIGN_DEFAULT
            
            
    #define ITEM(_rect, _dvar) \
            
    itemDef \
            { \
                
    name            "window" \
                
    group            ingamebox \
                
    visible            1 \
                
    RECT4(_rect) \
                
    origin            ORIGIN_QUICKMESSAGEWINDOW \
                
    forecolor        1 1 1 1 \
                
    textfont        UI_FONT_NORMAL \
                
    textscale        .24 \
                
    textaligny        8 \
                
    dvar            _dvar \
                
    decoration \
            }
            
            
    ITEM(16  20 0 0"menu_1")
            
    ITEM(16  36 0 0"menu_2")
            
    ITEM(16  52 0 0"menu_3")
            
    ITEM(16  68 0 0"menu_4")
            
    ITEM(16  84 0 0"menu_5")
            
    ITEM(16 100 0 0"menu_6")
            
    ITEM(16 116 0 0"menu_7")
            
    ITEM(16 132 0 0"menu_8")
            
    ITEM(16 148 0 0"menu_9")
            
    ITEM(16 164 0 0"menu_0"
    So basically just replaced:
    HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN
    with:
    HORIZONTAL_ALIGN_DEFAULT VERTICAL_ALIGN_DEFAULT

    Here are the other definitions, they may help somebody out later:

    PHP Code:
    // Edge relative placement values for rect->h_align and rect->v_align
    #define HORIZONTAL_ALIGN_SUBLEFT        0    // left edge of a 4:3 screen (safe area not included)
    #define HORIZONTAL_ALIGN_LEFT            1    // left viewable (safe area) edge
    #define HORIZONTAL_ALIGN_CENTER            2    // center of the screen (reticle)
    #define HORIZONTAL_ALIGN_RIGHT            3    // right viewable (safe area) edge
    #define HORIZONTAL_ALIGN_FULLSCREEN        4    // disregards safe area
    #define HORIZONTAL_ALIGN_NOSCALE        5    // uses exact parameters - neither adjusts for safe area nor scales for screen size
    #define HORIZONTAL_ALIGN_TO640            6    // scales a real-screen resolution x down into the 0 - 640 range
    #define HORIZONTAL_ALIGN_CENTER_SAFEAREA 7    // center of the safearea
    #define HORIZONTAL_ALIGN_MAX            HORIZONTAL_ALIGN_CENTER_SAFEAREA
    #define HORIZONTAL_ALIGN_DEFAULT        HORIZONTAL_ALIGN_SUBLEFT

    #define VERTICAL_ALIGN_SUBTOP            0    // top edge of the 4:3 screen (safe area not included)
    #define VERTICAL_ALIGN_TOP                1    // top viewable (safe area) edge
    #define VERTICAL_ALIGN_CENTER            2    // center of the screen (reticle)
    #define VERTICAL_ALIGN_BOTTOM            3    // bottom viewable (safe area) edge
    #define VERTICAL_ALIGN_FULLSCREEN        4    // disregards safe area
    #define VERTICAL_ALIGN_NOSCALE            5    // uses exact parameters - neither adjusts for safe area nor scales for screen size
    #define VERTICAL_ALIGN_TO480            6    // scales a real-screen resolution y down into the 0 - 480 range
    #define VERTICAL_ALIGN_CENTER_SAFEAREA    7    // center of the save area
    #define VERTICAL_ALIGN_MAX                VERTICAL_ALIGN_CENTER_SAFEAREA
    #define VERTICAL_ALIGN_DEFAULT            VERTICAL_ALIGN_SUBTOP 
    timescale 0.01

  6. #16
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Basically created a simple && for menus (logical AND, in case if(a && b) set c 100)
    code:

    PHP Code:
                    execnow "set first_ok 0";
                    
    execnow "set second_ok 0";
                    
    execnowondvarintvalue first_check 100 "set first_ok 1";
                    
    execnowondvarintvalue second_check 200 "setfromdvar second_ok first_ok";
                    
    execnowondvarintvalue second_ok 1 "set result 10";
                    
    execnowondvarintvalue second_ok 0 "set result -10"
    which basically does this:
    PHP Code:
    first_ok false;
    second_ok false;
    if(
    first_check == 100)
            
    first_ok true;
    if(
    second_check == 200)
            
    second_ok first_ok;
    if(
    second_ok)
            
    result 10;
    else
            
    result = -10
    It is however not very possible that you can use this for a double &&, as the amount of execnow's and execnowondvarint's is limited per action. You'll need a second menu then.
    Last edited by IzNoGoD; 21st May 2015 at 18:22.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  7. The Following 2 Users Say Thank You to IzNoGoD For This Useful Post:

    kung foo man (21st May 2015),Mitch (21st May 2015)

Posting Permissions

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