PDA

View Full Version : Close menu



randall
3rd June 2013, 17:27
Hi,

I made a small pop-up menu on the center of the screen. And my question: is it any function what closes the menuDef if I click the outside of the menu?

Thanks the answers!

Tally
3rd June 2013, 17:51
Hi,

I made a small pop-up menu on the center of the screen. And my question: is it any function what closes the menuDef if I click the outside of the menu?

Thanks the answers!

Answering the question specifically: no, there is no engine function to close a MenuDef{} if you click outside its rectangle. The closest you will come to this is to close the popup by using the Escape button:


onEsc
{
close <nameofmenu>;
}


However, having answered that quesiton specifically, if you don't want to use the escape button to manually close a popup, and insist on using a mouse click, simply place itemDef{} all around the center safe area (= the area of the menu which will be drawn no matter what the resolution or aspect ratio is) where the rectangle is limited to the boundaries of the popup only. Then, have a scriptmenureponse in the action{} and monitor it in _menus.gsc to close the menu when detected.

This wouldn't work for my pop menus as I draw them full screen (640x480) and simply have the background smaller so it "looks" like a smaller menu. But, if you are sizing your pop menu much smaller than the center safe area, then this could work for you.

randall
3rd June 2013, 18:13
Sadly the mouseclick only works the inside the menuDef, so it's not solution to place a fullscreen-button behind the other itemDefs. (i tried this at first :D)

EDIT: Ok i solved, i opened an other menuDef in the background. Thanks Tally the rapid help!

serthy
5th June 2013, 11:07
check out rfactory (google it)

its called "outofboundsclick" and it is an attribute in your menuDef, similar used like popup

Tally
5th June 2013, 12:49
check out rfactory (google it)

its called "outofboundsclick" and it is an attribute in your menuDef, similar used like popup

You have to be careful referencing Quake 3 items. The COD2 engine is not a Quake 3 engine. It has only 30% legacy code from the engine they used for COD1 (which was a heavily modified Team Arena UberTools engine) , but the other 70% is proprietary, built from the ground up, and developed in-house by Infinity Ward themselves. The menu system is part of that legacy code, but it is heavily modified, and many many items from their COD1 engine don't work any more.

Now, I'm not saying outofboundsclick wont work - I have no idea because I haven't tried it - but looking at a resource site like rfactory will be very much a hit-and-miss affair.

serthy
5th June 2013, 13:19
but looking at a resource site like rfactory will be very much a hit-and-miss affair

you are right about that, but many ppl in here are asking now things about ui-modding
and rfactory is the best start-off of basic ui-scripting i have found in the web
there are good explanations about itemDef's, rects, alignments and ui_scripts
in my eyes its better to look around there for some hours by yourself (not you Tally, i mean the beginners :] ) instead of hunting your ui-mod-wishes with closed eyes.

just look around there and compare what is done in cod2 and youll know what is possible

http://rfactory.org/

there are 2 sites, the tutorial one and the documentary one


but btw, i would also go with Tally, do a menuDef with 640x480 and a menuDef with 640x480 that will close when clicked and just draw your menu above the close-itemDef

Tally
5th June 2013, 13:29
you are right about that, but many ppl in here are asking now things about ui-modding
and rfactory is the best start-off of basic ui-scripting i have found in the web
there are good explanations about itemDef's, rects, alignments and ui_scripts
in my eyes its better to look around there for some hours by yourself (not you Tally, i mean the beginners :] ) instead of hunting your ui-mod-wishes with closed eyes.

just look around there and compare what is done in cod2 and youll know what is possible

http://rfactory.org/

there are 2 sites, the tutorial one and the documentary one


but btw, i would also go with Tally, do a menuDef with 640x480 and a menuDef with 640x480 that will close when clicked and just draw your menu above the close-itemDef

I did have a look around rfactory. I know a fair bit about Quake UI modding (I used to mod for Quake 2 before I became a COD modder), but I still learnt some stuff from it I didn't know before (like what "decoration" is - it stops things like roll over blink on rectangles). So, it is a useful resource site if you know what you're doing. But I have never forgotten the hours and hours of frustration when COD2 came out trying to do things in the UI system we used to do with COD1 (like animated shaders - waving team flags on the menus were one of my specialities in COD1) only to find you couldn't do them any more. I'm just trying to save people that pain. Just be aware that if you can't get it to work first time, chances are it wont ever work, so move on.

serthy
5th June 2013, 13:48
But I have never forgotten the hours and hours of frustration when COD2 came out trying to do things in the UI system we used to do with COD1
Hell yeah... i did all of my menus thsi way, and also almost everything from rfactory/cod4 and the macro testing... it was such a pain... and as you know, i didnt know about that menu-syntax-error were printed in the console.log


Happy scripting ;)

kung foo man
5th June 2013, 15:26
Hm, why you look in console.log for menu-errors? They should be all written in the developer-console (Shift+Console)?

Tally
5th June 2013, 16:58
Hm, why you look in console.log for menu-errors? They should be all written in the developer-console (Shift+Console)?

Because you don't have to run your server in developer mode in order to see errors in log files. For example, testing on a dedicated server - which I do most of the time because it reveals things a Listen server wont reveal - doesn't allow for developer mode. But you can still see errors in log files.