PDA

View Full Version : 2 dvartest for 1 itemdef?



silentwarrior
18th August 2014, 16:46
Hi everyone! I am trying to make some menus and I came up with a situation which an itemdef that has already a dvartest on it, to need another dvartest.

For example I have this:


itemDef

{


name
"item10"


visible
1


rect
0 0 35 22


origin
ORIGIN_CHOICE10


forecolor
GLOBAL_UNFOCUSED_COLOR


type
ITEM_TYPE_BUTTON


text
"^3Ammo Pack"


textfont
UI_FONT_NORMAL


textscale
.30


textstyle
ITEM_TEXTSTYLE_SHADOWED


textaligny
20


dvartest
"items"


showDvar
{ "10" }


action


{



play "mouse_click";


}



onFocus


{



play "mouse_over";


}

}

So this itemdef appears when the dvartest "items" becomes "10".
and now I want to add to it 1 more dvartest:


dvartest
"players"


showDvar
{ "3" }

So the itemdef to appear when both conditions are appropriate ("items" = 10 , "players" = 3). If one of them is different I want it to disappear.

Is it possible to add 2 dvartests in the same itemdef? I tried some combinations like:


dvartest
"items"


showDvar
{ "10" }


dvartest
"players"


showDvar
{ "3" }
or


dvartest
"items","players"


showDvar
{ "10" },{ "3" }
but didn't worked.

I know it is possible if I add a different menudef, and add the second dvartest into the menudef, but I am trying to find a way t avoid multiple menudefs.

Thanks in advance!

silentwarrior
29th August 2014, 11:58
anyone????

Peterlankton
29th August 2014, 19:39
Why not just check in your code if(items == 10 && players == 3) and then set a boolean which you check in the itemDef.

Some like:


if(items == 10 && players == 3)
{
player setClientCvar("show_item10", 1)
}
else
{
player setClientCvar("show_item10", 0)
}




dvartest "show_item10"
showDvar{ "1" } //not sure if with or without quotation marks


I know you want it to be easier, but I have never seen a double dvar check in menus. And this is the easiest way that by now has popped into my mind.

IzNoGoD
29th August 2014, 20:14
or you could do a check in onopen, downside is that this will only be updated when the menu opens, and is quite hard to implement. Wont require additional cvar pushing to the client though

serthy
30th August 2014, 10:02
2 cvardevs arent possible
you could do this instead:

for images:


#define IMAGE_ON_DVAR( _rect , _dvar ) \
itemdef \
{ \
rect _rect \
dvarTest _dvar \
style WINDOW_STYLE_DVAR_SHADER \
decoration \
hideDvar \
{ \
""; \
} \
}

#define IMG_SIZE 640 480
#define IMG_RECT 0 0 IMG_SIZE HORZ_ALIGN_FULLSCREEN VERT_ALIGN_FULLSCREEN
#define IMG_DVARNAME ui_img

IMAGE_ON_DVAR( IMG_RECT , IMG_DVARNAME )

or for other stuff:


#define STUFF_ON_DVAR( _rect , _dvar , _showdvarvalues , _hidedvarvalues ) \
itemdef \
{ \
rect _rect \
dvarTest _dvar \
showDvar \
{ \
_showdvarvalues; \
} \
hideDvar \
{ \
_hidedvarvalues; \
} \
}

#define STUFF_RECT 0 0 10 10 HORZALIGN VERTALIGN

STUFF_ON_DVAR( STUFF_RECT , ui_stuff , "0";"1";"2" , "3";"4" )
STUFF_ON_DVAR( STUFF_RECT , ui_stuff , "3";"4" , "0";"1";"2" )