Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Quad), 755 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
search for a panel-pointer #424476
06/16/13 22:05
06/16/13 22:05
Joined: Dec 2003
Posts: 988
Germany, Magdeburg
JoGa Offline OP
User
JoGa  Offline OP
User

Joined: Dec 2003
Posts: 988
Germany, Magdeburg
Hey

in a application i create panels during runtime. Their pointers are saved in a array like (i hope, this is right):
Code:
array_panels_d_elemente[i] = (int*)pan_temp;



If the user right-clicks on a panel, i have to check, if its a panel, which was saved in the array.
I wanted to use mouse_panel for this.

But I have some problems with the comparison . how can I check if the pointer of the mouse_panel "points" on a panel, which is saved in the array?

Code:
int i;
for(i=0;i<50;i++)
	{
		if(mouse_panel !? array_panels_d_elemente[i]) // my problems
		{
			//....
		}
	}



Could someone help me how to search for the pointer right?
Thanks laugh

Last edited by JoGa; 06/16/13 22:06.
Re: search for a panel-pointer [Re: JoGa] #424477
06/16/13 22:25
06/16/13 22:25

M
Malice
Unregistered
Malice
Unregistered
M



Code:
#define MAX_PANELS 500 // ? as many as you need

PANEL* array_panels_d_elemente[MAX_PANELS];
var totalPanels = 0;

if(totalPanels < MAX_PANELS)
{
   array_panels_d_elemente[totalPanels] = pan_create(.....);
   totalPanels += 1;
}



if ( mouse_right && mouse_panel != NULL )
{
    int i;
    for(i=0;i<50;i++)
	{
	    if(mouse_panel == array_panels_d_elemente[i])
              { 
                // panel found do stuff here //
 
                break; // stop the loop
              }            
 	} 
}





Last edited by Malice; 06/16/13 22:33.
Re: search for a panel-pointer [Re: ] #424478
06/16/13 23:27
06/16/13 23:27
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Btw. saving a pointer in an integer variable will most likely not work. (JustSid just informed me that it is perfectly fine to use ints) You can however save them in vars, for instance as follows:

entity-skills are a var skill[100] array, thus writing
my.skill70 = ent_create(...);
and
my.skill71 = pan_create(...);
or
PANEL* pnl_tmp = pan_create(...);
my.skill71 = pnl_tmp;
is perfectly fine. You can then later retrieve the pointer by a simple cast:
((ENTITY*)my.skill70).x = 10;
or handier as
you = (ENTITY*)my.skill70;
pnl_tmp = (PANEL*)my.skill71;

The last two typecasts should not be necessary (you = my.skill70; should work, too) but I like to do it that way.

Last edited by Superku; 06/17/13 02:38.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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