Results 1 to 4 of 4

Thread: Radiobutton / Checkbox in menu-files (CoD2)

  1. #1
    Private
    Join Date
    Apr 2014
    Posts
    11
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Question Radiobutton / Checkbox in menu-files (CoD2)

    Hey people,

    I can't find any example how to make radiobuttons and checkboxes work in menu-files. I maybe wanna use them for an ingame serveradmin menu.

    When I opened ui/menudefinition.h I found these GUI widgets:
    #define ITEM_TYPE_TEXT 0 // simple text
    #define ITEM_TYPE_BUTTON 1 // button, basically text with a border
    #define ITEM_TYPE_RADIOBUTTON 2 // toggle button, may be grouped
    #define ITEM_TYPE_CHECKBOX 3 // check box
    #define ITEM_TYPE_EDITFIELD 4 // editable text, associated with a dvar
    #define ITEM_TYPE_COMBO 5 // drop down list
    #define ITEM_TYPE_LISTBOX 6 // scrollable list
    #define ITEM_TYPE_MODEL 7 // model
    #define ITEM_TYPE_OWNERDRAW 8 // owner draw, name specs what it is
    #define ITEM_TYPE_NUMERICFIELD 9 // editable text, associated with a dvar
    #define ITEM_TYPE_SLIDER 10 // mouse speed, volume, etc.
    #define ITEM_TYPE_YESNO 11 // yes no dvar setting
    #define ITEM_TYPE_MULTI 12 // multiple list setting, enumerated
    #define ITEM_TYPE_DVARENUM 13 // multiple list setting, enumerated from a dvar
    #define ITEM_TYPE_BIND 14 // bind
    #define ITEM_TYPE_MENUMODEL 15 // special menu model
    #define ITEM_TYPE_VALIDFILEFIELD 16 // text must be valid for use in a dos filename
    #define ITEM_TYPE_DECIMALFIELD 17 // editable text, associated with a dvar, which allows decimal input
    #define ITEM_TYPE_UPREDITFIELD 18 // editable text, associated with a dvar

    They exist but to be honest, I can't remember to have ever seen any radiobutton or checkbox in CoD2. Anyone got a template or an idea?

    I tried this one after I had removed useless properties:
    Code:
    	...
    		 itemDef
    		{
    			 text			" "
    			name			checkbox
    			type			ITEM_TYPE_CHECKBOX
    			style			WINDOW_STYLE_FILLED
    			dvar			"scr_allow_bar"
    			rect			52.5 -15 120 10
    			 origin			OPTIONS_ITEM_ORIGIN
     			backcolor		OPTIONS_CONTROL_BACKCOLOR
    			forecolor		OPTIONS_CONTROL_FORECOLOR
    			visible		1
    			 mouseEnter		{ play "mouse_over" }
    		}
                    ...
    On mouseEnter the clicksound appears but it's not visible. No idea which properties are necessary to make it visible.

  2. #2
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Quote Originally Posted by Para View Post
    Hey people,
    Hey there
    Quote Originally Posted by Para View Post
    I can't find any example how to make radiobuttons and checkboxes work in menu-files.
    there are only 3 ways of testing if and how some features of cod2 menu mods may work:

    1. check cod2 ui and ui_mp sources for references. if no success, check cod1/uo, cod4, cod5, cod7 ui/ui_mp sources
    2. the only quake menu modding site ive seen so far: rfactory.org (here you go) (Note: not all features will work in cod2! but its pretty good explained how quake menus do work)
    3. test and fail on your own until eternal despair (this is the true way of cod2 menu modding, no way arond :/)

  3. #3
    Private
    Join Date
    Apr 2014
    Posts
    11
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Lightbulb

    Quote Originally Posted by serthy View Post
    Hey there

    there are only 3 ways of testing if and how some features of cod2 menu mods may work:

    1. check cod2 ui and ui_mp sources for references. if no success, check cod1/uo, cod4, cod5, cod7 ui/ui_mp sources
    2. the only quake menu modding site ive seen so far: rfactory.org (here you go) (Note: not all features will work in cod2! but its pretty good explained how quake menus do work)
    3. test and fail on your own until eternal despair (this is the true way of cod2 menu modding, no way arond :/)
    There is a tutorial for graphical extensions on rfactory.org (http://rfactory.org/extensions.html), explaining how checkboxes, dropdown combobox etc. are added to q3 but the commands for checkboxes in assetglobaldef don't work in CoD2. Actually, there is not even one website documentating the actual commands to get the assets for the widgets, though there is an invisible checkbox/radiobutton reacting to events without having a graphical asset. Depending on the following picture (http://www.winmobiletech.com/072007C...inmenu.bmp.png) I guess checkboxes were supposed to be a part of the game at the very beginning (v 1.0) and later removed for some reason. I don't have 1.0, only 1.01. So I can't see the actual command in the code. I'm pretty sure that there is still a checkbox command for the asset in the current version of CoD2 but it's unknown cos it has never been used officially. You can find the assets in iw_13.iwd "materials/ui/assets/...". There are checkbox assets called "checkbox_checked", "checkbox_fail", "checkbox_clear". I replaced the cursor asset in mains assetglobaldef to see the pictures. They are visible in the cursor but I'm not able yet to connect them to the checkbox widget. In /materials are also some checkbox pictures that work but with a different look. Btw I couldn't find any radiobutton asset. You can add the assets just like background pictures but the checkbox just seems to act like a button (?).

    Obviously, the only way is to build my own checkbox. I use color switching buttons:
    Code:
            itemDef
            {
                     name "checkbox_green"
                type 1
                  style 1
                backcolor 0 1 0 1
                border    1
                bordersize 1
                bordercolor 0 0 0 1
                text "on"
                textstyle    OPTIONS_ITEM_TEXT_STYLE
                textalign    OPTIONS_ITEM_ALIGN
                textalignx    0
                textaligny    7.5
                textscale    .18
                forecolor    0 0 0 1
                rect .25 0 10.25 10
                 visible 1
                dvartest "scr_allow_mp44"
                showdvar { "1" }
                onFocus { play "mouse_over" }
                action { play "mouse_click"; setdvar scr_allow_mp44 "0"; setfocus "checkbox_red" }
            }
    
            itemDef 
             {
                     name "checkbox_red"
                type 1
                  style WINDOW_STYLE_FILLED
                backcolor 1 0 0 1
                border    1
                bordersize 1
                bordercolor 0 0 0 1
                text "off"
                textstyle    OPTIONS_ITEM_TEXT_STYLE
                textalign    OPTIONS_ITEM_ALIGN
                textalignx    .5
                textaligny    7.75
                textscale    .15
                forecolor    0 0 0 1
                rect .5 0.25 10.5 10.25
                visible 1
                dvartest "scr_allow_mp44"
                hideDvar { "1" }
                onFocus { play "mouse_over" }
                action { play "mouse_click"; setdvar scr_allow_mp44 "1"; setfocus "checkbox_green" }
            }
    My best solution with only one button so far:
    Code:
            itemDef
            {
                name checkbox
                type ITEM_TYPE_BUTTON
                style WINDOW_STYLE_DVAR_SHADER
                rect 0 50 15 15
                border    1
                bordercolor 0 0 0 0
                dvar "ui_checkbox"
                visible 1
                mouseEnter { play "mouse_over"; setitemcolor checkbox bordercolor 0 0 0 1 }
                mouseExit { setitemcolor checkbox bordercolor 0 0 0 0 }
                action { play "mouse_click"; scriptMenuResponse "checkbox_change" }
            }
    Code:
    onMenuResponse()
    {
        for(;;)
        {
            self waittill("menuresponse", menu, response);
    
            if(response == "checkbox_change")
            {
                if(getCvar("ui_checkbox") == "ui/assets/checkbox_checked")
                {
                    setCvar("ui_checkbox", "ui/assets/checkbox_clear");
                    self setClientCvar("ui_checkbox", "ui/assets/checkbox_clear");
                }
                else
                {
                    setCvar("ui_checkbox", "ui/assets/checkbox_checked");
                    self setClientCvar("ui_checkbox", "ui/assets/checkbox_checked");
                }
            }
                    ...
            }
    }
    Last edited by kung foo man; 29th May 2014 at 15:19. Reason: Added pic in case for dead-link

  4. The Following User Says Thank You to Para For This Useful Post:

    kung foo man (29th May 2014)

  5. #4
    Private
    Join Date
    Apr 2014
    Posts
    11
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Lightbulb Radiobuttons

    I just tried to build a template for the behaviour of a radiobutton-group using checkbutton-assets (only one radiobutton can be activated at once):
    Code:
    		itemDef
    		{
    			name radiobutton_1
    			type ITEM_TYPE_BUTTON
    			style WINDOW_STYLE_DVAR_SHADER
    			rect 0 200 15 15
    			border	1
    			bordercolor 0 0 0 0
    			dvar "ui_radiobutton_1"
    			visible 1
    			mouseEnter { play "mouse_over"; setitemcolor radiobutton_1 bordercolor 0 0 0 1 }
    			mouseExit { setitemcolor radiobutton_1 bordercolor 0 0 0 0 }
    			action { play "mouse_click"; scriptMenuResponse "1" }
    		}
    		itemDef
    		{
    			name radiobutton_2
    			type ITEM_TYPE_BUTTON
    			style WINDOW_STYLE_DVAR_SHADER
    			rect 0 220 15 15
    			border	1
    			bordercolor 0 0 0 0
    			dvar "ui_radiobutton_2"
    			visible 1
    			mouseEnter { play "mouse_over"; setitemcolor radiobutton_2 bordercolor 0 0 0 1 }
    			mouseExit { setitemcolor radiobutton_2 bordercolor 0 0 0 0 }
    			action { play "mouse_click"; scriptMenuResponse "2" }
    		}
    		itemDef
    		{
    			name radiobutton_3
    			type ITEM_TYPE_BUTTON
    			style WINDOW_STYLE_DVAR_SHADER
    			rect 0 240 15 15
    			border	1
    			bordercolor 0 0 0 0
    			dvar "ui_radiobutton_3"
    			visible 1
    			mouseEnter { play "mouse_over"; setitemcolor radiobutton_3 bordercolor 0 0 0 1 }
    			mouseExit { setitemcolor radiobutton_3 bordercolor 0 0 0 0 }
    			action { play "mouse_click"; scriptMenuResponse "3" }
    		}
    Code:
    onMenuResponse()
    {
    	for(;;)
    	{
    		self waittill("menuresponse", menu, response);
    
    		if(menu == "your_menu")
    		{
    			switch(response)
    			{
    				case "1":
    					self setClientCvar("ui_radiobutton_2", "ui/assets/checkbox_clear");
    					self setClientCvar("ui_radiobutton_3", "ui/assets/checkbox_clear");
    					self setClientCvar("ui_radiobutton_1", "ui/assets/checkbox_checked");
    					break;
    				case "2":
    					self setClientCvar("ui_radiobutton_1", "ui/assets/checkbox_clear");
    					self setClientCvar("ui_radiobutton_3", "ui/assets/checkbox_clear");
    					self setClientCvar("ui_radiobutton_2", "ui/assets/checkbox_checked");
    					break;
    				case "3":
    					self setClientCvar("ui_radiobutton_1", "ui/assets/checkbox_clear");
    					self setClientCvar("ui_radiobutton_2", "ui/assets/checkbox_clear");
    					self setClientCvar("ui_radiobutton_3", "ui/assets/checkbox_checked");
    			}
    		}
            }
    }
    Last edited by Para; 29th May 2014 at 16:34.

  6. The Following User Says Thank You to Para For This Useful Post:

    kung foo man (29th May 2014)

Posting Permissions

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