[solved] comparing of panels

Posted By: JoGa

[solved] comparing of panels - 10/05/11 14:34

Hi

I have a problem in comparing Panel-pointers.
I have got some Panels and wrote a little piece of code, which cycles through the panels:
Code:
var i;
	for(i=1; i <60; i++)
	{
		str_cpy(str_mouse_over, "pan_invplatz"); //Name of panels
		str_cat_num(str_mouse_over,"%.0f",i); //number of panels in the name
		pan_mouse_over = (PANEL*) str_mouse_over; //tried to say "dude, thats a panel-pointer"
		if(mouse_panel == pan_mouse_over) // and tried to compare it with the mouse-over-panel
		{
			str_cpy(str_debug,str_mouse_over);
			// ....
		}
	}
}


But I think i can't do this - it is not detected right.
The Panels name is pan_invplatz1 and goes to pan_invplatz60.
I hoped I could do this with the strings, because if this does not working, I have to wrote a if-comparing for every single panel (if(mouse_panel == pan_invplatz1){...}, if(mouse_panel == pan_invplatz2){...}, ...) An thats a lot :-) Not only this 60, there are some other places in the code, i would be forced to write the same code clusters.

So, how can i convert a string in a panel-pointer?

Thanks for reading, i'm excited for your hints :-)
Posted By: Superku

Re: comparing of panels - 10/05/11 15:23

Why don't you use an array of panels?

PANEL* pan_invplatz[60];
...
for(i = 0; i < 60; i++) pan_invplatz[i] = pan_create("",layer);

Alternatively, you can use draw_quad with a BMAP array (and a var array to store inventory information).
Posted By: EvilSOB

Re: comparing of panels - 10/05/11 15:36

Ummm.. dumb question...

Have looked at the "mouse_panel" pointer in the manual?
Posted By: JoGa

[solved] Re: comparing of panels - 10/05/11 15:50

Yes, I looked in the manual =)
Its a read-only Panel*

Okay, thanks for your both reply, wasn't aware of the possibility to take a Panel*-Pointer-array, that makes it much more easier as I thought.

I will change my inventory and take the panel-array, this will also reduce the cluster of code, i wrote.
Thanks!!
© 2024 lite-C Forums