Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
0 registered members (), 631 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
panel close #280882
07/24/09 14:18
07/24/09 14:18
Joined: Nov 2008
Posts: 215
V
vertex Offline OP
Member
vertex  Offline OP
Member
V

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] #280888
07/24/09 14:37
07/24/09 14:37
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
panel menu_pan {
should be:
panel menu_pan = {

(or you use wdl? Then post in the cscript & wdl forum)

Re: panel close [Re: Widi] #280892
07/24/09 14:55
07/24/09 14:55
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Your prototype is defined the right way, and this is indeed C-Script, not Lite-C wink

But I don't really understand what the problem is? grin

Re: panel close [Re: Claus_N] #280895
07/24/09 15:27
07/24/09 15:27
Joined: Nov 2008
Posts: 215
V
vertex Offline OP
Member
vertex  Offline OP
Member
V

Joined: Nov 2008
Posts: 215
Well in the end all I'm trying to do is close a panel in c-script on a button click, so alternate code would also be appreciated. I am learning a lot as I try to solve this issue and build an interface; however this simple problem I admit has got me.

I can close the menu via a keyboard key press no problem-- on_esc= toggleMenu; . It's just the mouse click button to escape menu function and its relation to the toggle menu on off logic that appears to be thr problem.

Re: panel close [Re: vertex] #280897
07/24/09 15:41
07/24/09 15:41
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
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.

Code:
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] #280903
07/24/09 15:59
07/24/09 15:59
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Yep, almost the same in c-script:
Code:
function clickEscape(butt, pan)  //the 'butt' parameter is unnused but required
{
    pan.visible = OFF;
}



Re: panel close [Re: EvilSOB] #280908
07/24/09 16:10
07/24/09 16:10
Joined: Nov 2008
Posts: 215
V
vertex Offline OP
Member
vertex  Offline OP
Member
V

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.

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1