PDA

View Full Version : .menu as hud-elem replacement bug



kung foo man
2nd February 2014, 00:36
Hey all,

I wanna replace many precached strings with a .menu-file (ItemDef with dvar-attribute) but for some reason openMenu() is hiding all other 2d huds:

630

Is there some way to draw a menu without hiding all the other 2d stuff?

Regards :)

IzNoGoD
2nd February 2014, 02:22
can you .foreground=true the hud?

If not, then you're mostly boned due to the fact that player-opened menus are different...

kung foo man
2nd February 2014, 03:43
Hm, I don't see a way to foreground all the 2d stuff or the .menu

Gonna just put the dvar things in hud.menu, since that is displayed without any precaching/opening

serthy
2nd February 2014, 07:31
replace your wm_quickmenu with a short placeholdermenu containing only that for every quickmenu:

onOpen
{
openmenuondvar ui_quickmenu myquickmenu1 quickmenu1;
openmenuondvar ui_quickmenu myquickmenu2 quickmenu2;
openmenuondvar ui_quickmenu myquickmenu3 quickmenu3;

//optionally:
//closemenuondvarnot ui_quickmenu myquickmenu1 quickmenu1;
//closemenuondvarnot ui_quickmenu myquickmenu2 quickmenu2;
//closemenuondvarnot ui_quickmenu myquickmenu3 quickmenu3;
}
and in gsc update the corresponding var:

openQuickMenu( menu )
{
player setClientCvar( "ui_quickmenu" , menu );
player execClientCommand( "wm-quickmenu" ); //dont know the command when pressing [V]
}
opening a menu via wm_quickmenu prevents me from hiding allhuds when opening a custom menu

Tally
2nd February 2014, 10:48
Script Menus will by default hide hud elements. You can get your mouse to work with them by using a dvar to allow it, but hud elements are typically hidden. They fixed this in COD4, and you now have to manually put in an aspect to the hud element to get hidden when a menu is open.

The only menus that don't hide hud elements are ones that are called straight from ui_mp (ie. none-script menus). There is, of course, the stock hud.menu. This is open all the time, and does not prevent hud elements from showing. I created my own one so that I didn't have to keep editing hud.menu (it was already too big), and you call these by hud.txt:


// hud menu defs
//
{
loadMenu { "ui_mp/hud.menu" }
loadMenu { "ui_mp/dpadhud.menu" }
}


You will notice dpadhud.menu. This is opened on the player when he joins the server - whether he is in spectator or spawned. And it was designed to take over many hud elements because my mod draws too many hud elements, and I had reached the element limit. So, you might consider doing the same thing.

There is one major drawback with these menus, and it may not suit your purposes because of it: the itemDef{} are limited: you can't use a dvar to show text; and you have to use an ownerdraw of some sort in order for the item to show.

Here is my dpadhud.menu with examples of ownerdraw:


#include "ui_mp/menudef.h"

{ // DPAD HUD

// KEYBOARD MAP
menuDef
{
name "keyboardmap"
fullScreen MENU_FALSE
visible MENU_TRUE
rect 450 425 640 40

itemDef
{
name "hud_keyboardmap"
rect 0 5 50 50
forecolor 1 1 1 .4
ownerdraw CG_PLAYER_COMPASS_BACK
background "hud_keyboardmap"
visible MENU_TRUE
decoration
dvartest "scr_demon_dynamic_perks"
showDvar { "1" }
}

itemDef
{
name "hud_keyboardmap"
rect 0 52 70 70
text "[ K ]"
forecolor 1 1 1 .6
textstyle ITEM_TEXTSTYLE_SHADOWED
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
textscale .25
textalignx 14
dvartest "scr_demon_dynamic_perks"
showDvar { "1" }
}

}

//Binoculars
menuDef
{
name "binoculars"
fullScreen MENU_FALSE
visible MENU_TRUE
rect 370 428 640 40

itemDef
{
name "binoculars"
rect 5 5 34 34
forecolor 1 1 1 .4
background "weapon_binoculars"
ownerdraw CG_PLAYER_COMPASS_BACK
visible MENU_TRUE
decoration
dvartest "cg_player_binoculars"
showDvar { "1" }
}

itemDef
{
name "binoculars"
rect -1 50 70 70
text "[ L ]"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
textalignx 14
dvartest "cg_player_binoculars"
showDvar { "1" }
}
}

//Tactical Insertion
menuDef
{
name "insertion"
fullScreen MENU_FALSE
visible MENU_TRUE
rect 300 428 640 40

itemDef
{
name "insertion"
rect 7 7 30 30
forecolor 1 1 1 .4
background "hud_insertion"
ownerdraw CG_PLAYER_COMPASS_BACK
visible MENU_TRUE
decoration
dvartest "cg_player_insertion"
showDvar { "1" }
}

itemDef
{
name "insertion"
rect -1 50 70 70
text "[ M ]"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
textalignx 14
dvartest "cg_player_insertion"
showDvar { "1" }
}
}

//First Aid
menuDef
{
name "firstaid"
fullScreen MENU_FALSE
visible MENU_TRUE
rect 300 428 640 40

itemDef
{
name "firstaid"
rect 7 7 30 30
forecolor 1 1 1 .4
background "hud_firstaid"
ownerdraw CG_PLAYER_COMPASS_BACK
visible MENU_TRUE
decoration
dvartest "cg_player_firstaid"
showDvar { "1" }
}

itemDef
{
name "firstaid"
rect 0 50 70 70
text "[ ]"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
textalignx 14
dvartest "cg_player_firstaid"
showDvar { "1" }
}

itemDef
{
name "firstaid"
rect 0 50 70 70
text "0"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
textalignx 19
dvartest "cg_player_firstaid_value"
showDvar { "0" }
}
itemDef
{
name "firstaid"
rect 0 50 70 70
text "1"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
textalignx 19
dvartest "cg_player_firstaid_value"
showDvar { "1" }
}
itemDef
{
name "firstaid"
rect 0 50 70 70
text "2"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
textalignx 19
dvartest "cg_player_firstaid_value"
showDvar { "2" }
}
itemDef
{
name "firstaid"
rect 0 50 70 70
text "3"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
textalignx 19
dvartest "cg_player_firstaid_value"
showDvar { "3" }
}
itemDef
{
name "firstaid"
rect 0 50 70 70
text "4"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
textalignx 19
dvartest "cg_player_firstaid_value"
showDvar { "4" }

}
itemDef
{
name "firstaid"
rect 0 50 70 70
text "5"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
textalignx 19
dvartest "cg_player_firstaid_value"
showDvar { "5" }
}
}

// TRIPWIRES
menuDef
{
name "tripwires"
fullScreen MENU_FALSE
visible MENU_TRUE
rect 230 428 640 40

itemDef
{
name "tripwire"
rect 5 3 35 35
forecolor 1 1 1 .4
background "hud_tripwire_dpad"
ownerdraw CG_PLAYER_COMPASS_BACK
visible MENU_TRUE
decoration
dvartest "cg_player_tripwire"
showDvar { "1" }
}

itemDef
{
name "tripwire"
rect 0 50 70 70
text "[ ]"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
dvartest "cg_player_tripwire"
showDvar { "1" }
textalignx 14
}

itemDef
{
name "tripwire"
rect 0 50 70 70
text "2"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
dvartest "cg_player_tripwire_count"
showDvar { "2" }
textalignx 19
}
itemDef
{
name "tripwire"
rect 0 50 70 70
text "1"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
dvartest "cg_player_tripwire_count"
showDvar { "1" }
textalignx 19
}
itemDef
{
name "tripwire"
rect 0 50 70 70
text "0"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
dvartest "cg_player_tripwire_count"
showDvar { "0" }
textalignx 19
}
}

// LANDMINES
menuDef
{
name "landmines"
fullScreen MENU_FALSE
visible 1
rect 230 428 640 40

itemDef
{
name "landmine"
rect 5 1 35 35
forecolor 1 1 1 .4
background "hud_landmine"
ownerdraw CG_PLAYER_COMPASS_BACK
visible MENU_TRUE
decoration
dvartest "cg_player_landmine"
showDvar { "allies" }
}

itemDef
{
name "landmine"
rect 5 1 35 35
forecolor 1 1 1 .4
background "hud_tellermine"
ownerdraw CG_PLAYER_COMPASS_BACK
visible MENU_TRUE
decoration
dvartest "cg_player_landmine"
showDvar { "axis" }
}

itemDef
{
name "landmine"
rect 0 50 70 70
text "[ ]"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
dvartest "cg_player_landmine_brackets"
showDvar { "1" }
textalignx 14
}

itemDef
{
name "landmine"
rect 0 50 70 70
text "2"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
dvartest "cg_player_landmine_count"
showDvar { "2" }
textalignx 19
}
itemDef
{
name "landmine"
rect 0 50 70 70
text "1"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
dvartest "cg_player_landmine_count"
showDvar { "1" }
textalignx 19
}
itemDef
{
name "landmine"
rect 0 50 70 70
text "0"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
dvartest "cg_player_landmine_count"
showDvar { "0" }
textalignx 19
}
}

//==================== HARDPOINTS ===========================

//Artillery
menuDef
{
name "artillery"
fullScreen MENU_FALSE
visible MENU_TRUE
rect 150 428 640 40

itemDef
{
name "artillery"
rect 9 -2 39 39
forecolor 1 1 1 .4
background "hud_artillery"
ownerdraw CG_PLAYER_COMPASS_BACK
visible MENU_TRUE
decoration
dvartest "cg_player_artillery"
showDvar { "1" }
}

itemDef
{
name "artillery"
rect 0 50 70 70
text "[ 1 ]"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
textalignx 14
dvartest "cg_player_artillery_count"
showDvar { "1" }
}
}

//Airstrike
menuDef
{
name "airstrike"
fullScreen MENU_FALSE
visible MENU_TRUE
rect 150 428 640 40

itemDef
{
name "airstrike"
rect 5 2 37 37
forecolor 1 1 1 .4
background "hud_airstrike"
ownerdraw CG_PLAYER_COMPASS_BACK
visible MENU_TRUE
decoration
dvartest "cg_player_airstrike"
showDvar { "1" }
}

itemDef
{
name "airstrike"
rect 0 50 70 70
text "[ 1 ]"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
dvartest "cg_player_airstrike_count"
showDvar { "1" }
textalignx 14
}
}

//Carepackage
menuDef
{
name "Carepackage"
fullScreen MENU_FALSE
visible MENU_TRUE
rect 150 428 640 40

itemDef
{
name "Carepackage"
rect 6 -2 39 39
forecolor 1 1 1 .4
background "hud_carepackage"
ownerdraw CG_PLAYER_COMPASS_BACK
visible MENU_TRUE
decoration
dvartest "cg_player_carepackage"
showDvar { "1" }
}

itemDef
{
name "Carepackage"
rect 0 50 70 70
text "[ M ]"
textstyle ITEM_TEXTSTYLE_SHADOWED
textscale .25
forecolor 1 1 1 .6
ownerdraw CG_PLAYER_WEAPON_MODE_ICON
visible MENU_TRUE
decoration
dvartest "cg_player_carepackage_count"
showDvar { "1" }
textalignx 14
}
}
}


I use 2 ownerdraw: 1) CG_PLAYER_WEAPON_MODE_ICON = this draws text; 2) CG_PLAYER_COMPASS_BACK = this draws all my shaders.

kung foo man
2nd February 2014, 15:58
Thanks for the input, I'm not sure which way I will use, maybe a mix of both :D



There is one major drawback with these menus, and it may not suit your purposes because of it: the itemDef{} are limited: you can't use a dvar to show text; and you have to use an ownerdraw of some sort in order for the item to show.


Hm, I just commented the ownerdraw out and now it prints my dvar "test".




//text "[ ]"
//ownerdraw CG_PLAYER_WEAPON_MODE_ICON
dvar test


You tested that out? I wonder why it didn't work for you (testing on 1.2 here)


My setup is very simple atm: clean CoD2, made a fs_game, start with an link: in the fs_game-folder test_menu I have the ui_mp folder which contains:
- ui_mp.iwd: this contains only the ui_mp/hud.txt, because otherwise it's not loaded
- ui_mp/dpadhud.menu, this is not zipped, so I just type "map_restart" after each change for very fast testing

Tally
2nd February 2014, 19:05
Thanks for the input, I'm not sure which way I will use, maybe a mix of both :D



Hm, I just commented the ownerdraw out and now it prints my dvar "test".




//text "[ ]"
//ownerdraw CG_PLAYER_WEAPON_MODE_ICON
dvar test


You tested that out? I wonder why it didn't work for you (testing on 1.2 here)


My setup is very simple atm: clean CoD2, made a fs_game, start with an link: in the fs_game-folder test_menu I have the ui_mp folder which contains:
- ui_mp.iwd: this contains only the ui_mp/hud.txt, because otherwise it's not loaded
- ui_mp/dpadhud.menu, this is not zipped, so I just type "map_restart" after each change for very fast testing

DOH! I was doing it with ownerdraw. Once I removed that, it works like a charm.

thanks for the heads-up!

kung foo man
5th February 2014, 20:48
Ok, back to the menu work ^^



dvarTest "menu_show"
showDvar {"1"}


That's also possible.

I needed some time figuring out why nothing at all were shown. Till I compared every menu-attribute with a working menuDef: the difference was "visible 1". It's even needed when every itemDef has "visible 1" already.

Edit:

Had to use:



// format: uiScript openMenuOnDvar $cvarname $cvarvalue $menuname
uiScript openMenuOnDvar menu_ondvar mapvote mapvote;

kung foo man
14th February 2014, 01:48
I'm writing a dynamic quickchat atm, it's working quite nice, but I have one "big" problem: I can't close the menu quickmessage by script (only ESC). Does somebody know how to close it?

Tried a mix of:




player closeMenu();
player closeMenu("quickmessage");

// failed lol:
//player setClientCvar("menu_ondvar", "quickmessage");
//player openMenu("quickmessage");
//player setClientCvar("menu_ondvar", "");

//player setclientcvar("clientcmd", "closemenu quickmessage");
player setclientcvar("clientcmd", "say quickmessage"); // printed AFTER menu is closed by ESC
player openMenu("clientcmd");




wm_quickmessage.menu:
uiScript closeMenuOnDvar menu_ondvar quickmessage quickmessage;

clientcmd.menu:
onOpen
{
exec "vstr clientcmd";
close clientcmd;
close quickmessage;
}


When I execute "closemenu quickmessage" by hand it works, but by script it's stuck by quickmessage-menu or so :S

Kinda running out of ideas

IzNoGoD
14th February 2014, 08:52
Open it manually using openmenu().

Then you can closemenu() it

kung foo man
14th February 2014, 09:02
Yea, but then the quickmenu would hide everything else again (screenshot in first post)

filthy_freak_
14th May 2014, 15:15
I can't close the menu quickmessage by script (only ESC). Does somebody know how to close it?

Also having the same problem. Anyone have any ideas?

serthy
14th May 2014, 15:57
http://killtube.org/showthread.php?1802-menu-as-hud-elem-replacement-bug&p=8969&viewfull=1#post8969

or


dvarTest ui_quickmenu
hideDvar
{
"";
}

filthy_freak_
14th May 2014, 16:50
http://killtube.org/showthread.php?1802-menu-as-hud-elem-replacement-bug&p=8969&viewfull=1#post8969

Not 100% sure what you mean with this, but if your trying to direct me to


closemenuondvarnot ui_quickmenu myquickmenu1 quickmenu1;

then how can I call this with a menu already open? I'm trying to close the custom quickmenu via script (gsc) without any client input needed.


or


dvarTest ui_quickmenu
hideDvar
{
"";
}

I can hide it yes but then the client cannot open other menus.

kung foo man
15th May 2014, 03:03
Did you write your menu-items in the global menu.hud? They are drawn *always*. Then you replace your quickchat-menu, to just "toggle" the global menu-items with a custom-cvar in onOpen/onClose.

filthy_freak_
15th May 2014, 03:35
Did you write your menu-items in the global menu.hud? They are drawn *always*. Then you replace your quickchat-menu, to just "toggle" the global menu-items with a custom-cvar in onOpen/onClose.

I haven't done that because I'm trying to make a map vote so I need to be able to track keys pressed and do menu responses.



execKey "1" { scriptMenuResponse "testballs" }


I'm unaware if its possible to do this with hud.menu.

Tally
15th May 2014, 09:27
I haven't done that because I'm trying to make a map vote so I need to be able to track keys pressed and do menu responses.



execKey "1" { scriptMenuResponse "testballs" }


I'm unaware if its possible to do this with hud.menu.

It isn't possible with that menu - hud.menu does not do scriptmenuresponse because it is not a script menu.