|
0 registered members (),
631
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
panel close
#280882
07/24/09 14:18
07/24/09 14:18
|
Joined: Nov 2008
Posts: 215
vertex
OP
Member
|
OP
Member
Joined: Nov 2008
Posts: 215
|
Any help appreciated.
I am simply trying to close a panel that has been toggled on utilizing a mouse click over a button within the panel to be closed just as in Windows OS. the button (as seen below in the code at the bottom of this post):
button = 693,155,escape_bmp,escape_bmp,escape_bmp,clickEscape,NULL,NULL;
I'm trying to prototype the clickEscape function (sets menu visible flag to off) before the panel definition, but think I might have goofed it up. The following works ok, but for the fact that two menu_pan panels are visible-- one in the center as needed and the other bleeding off the edge:
function clickEscape();// closing menu_pan is dependant on a //function which closes the as yet undescribed menu_pan so this //is a prototype.
panel menu_pan { // pos_x =0; // pos_y =0; flags = TRANSLUCENT; layer = 1; bmap = menu_bmp; mouse_map = arrow_bmp; button = 421,556,quit_bmp,quit_bmp,quit_bmp,quit_game,NULL,NUll; button = 693,155,escape_bmp,escape_bmp,escape_bmp,clickEscape,NULL,NULL; HSLIDER = 400,455,208,slide_bmp ,1,100,master_vol;// shifts master_vol from 1 to 100 over 208 pixels }
function clickEscape() { menu_pan.visible = OFF;}
// turns my menu on and off function toggleMenu() { // center the menu panel menu_pan.pos_x = (screen_size.x - bmap_width(menu_bmp))/2; menu_pan.pos_y = (screen_size.y - bmap_height(menu_bmp))/2; menu_pan.visible = (menu_pan.visible == OFF);
}
Last edited by vertex; 07/24/09 14:20.
|
|
|
Re: panel close
[Re: vertex]
#280897
07/24/09 15:41
07/24/09 15:41
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I dunno if this works for C-Script, but it does for Lite-C Here is a new function to attach to the close button. This ONE function can be shared by any panel.
function clickEscape(var butt, panel* pan) //the 'butt' parameter is unnused but required
{
pan.visible = OFF;
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: panel close
[Re: EvilSOB]
#280908
07/24/09 16:10
07/24/09 16:10
|
Joined: Nov 2008
Posts: 215
vertex
OP
Member
|
OP
Member
Joined: Nov 2008
Posts: 215
|
Ok I'll try that.
I did get it to work with another method before I saw your post, though. (It ain't pretty.):
function clickEscape();//proto this function function toggleMenuNoPos();//proto this function
panel menu_pan { pos_X = 0; pos_y = 0; flags = TRANSLUCENT; layer = 1; bmap = menu_bmp; mouse_map = arrow_bmp; on_click = toggleMenuNoPos;// this is the new bit-- closes on any click //but defined button click button = 421,556,quit_bmp,quit_bmp,quit_bmp,quit_game,NULL,NUll; //OUT (uses on_click instead) : button = //693,155,escape_bmp,escape_bmp,escape_bmp,clickEscape,NULL,NULL;
HSLIDER = 400,455,208,slide_bmp ,1,100,master_vol;// shifts master_vol from 1 to 100 over 208 pixels
}
//below I took out the centering code-- which i suspect was the real cause of th //trouble function toggleMenuNoPos() // this really is not a toggle but off and unfreeze { // center the menu panel code was here-- now it's gone-- no more double menus
menu_pan.visible = (menu_pan.visible == OFF); freeze_mode = 0;
}
This has the effect of closing the menu on any click outside defined buttons which is just fine for now I think; one of those buttons is on the menu btm-- a cross close icon. Also, the menu is centered in other toggle code.
Last edited by vertex; 07/24/09 16:27.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|