If flag included, and interaction between a function and panel.

Posted By: Valdsator

If flag included, and interaction between a function and panel. - 07/02/12 09:30

I'm making a menu at the moment, and I need to find out how to accomplish two things.

How can I check if a certain flag is included in a panel? For instance, if I set:
panel.flags = SHOW | OVERLAY;
if(panel.flags == SHOW) will be false regardless of whether SHOW is on or off, due to OVERLAY being on. How do I check if a certain flag is on, ignoring any other?
----------------------------------------------------
Also, I need a panel and a function to interact with each other. More specifically, the panel will have buttons that can activate the function, and the function might have to change the flags of the panel. This creates a problem of code order.
Code:
PANEL* superpanel={
   button(blah,blah,superfunction);
}

function superfunction(){
   superpanel.flags = SHOW;
}


superpanel doesn't know what superfunction is. I can fix this by putting this somewhere before the panel:
Code:
function superfunction(){}


...but I'm afraid that might be a very rough and hack-ish solution to this problem that may cause issues. Is this ok, or should I do something else?
Posted By: 3dgs_snake

Re: If flag included, and interaction between a function and panel. - 07/02/12 09:51

1 . (panel->flags & SHOW) == SHOW;
or
is(panel, SHOW); // Macro defined in gs

2. Don't worry, it is the right way to do it laugh (define your functions headers before you main function and implement them later). You can separate function headers and implementations in many files

Best regards.
Posted By: Valdsator

Re: If flag included, and interaction between a function and panel. - 07/02/12 10:10

Awesome, thank you!

Edit: Would just like to mention that it seems panels don't care about whether they're defined before or after functions that they might have to call, so pre-defining them isn't required. But, knowing how to do this will definitely be helpful in the future. laugh
© 2024 lite-C Forums