Creatd panel problem

Posted By: MDI

Creatd panel problem - 12/09/07 19:19

Im without ideas how can make every created panel with his own identity - that mean when under one name from three created panels --> function execute only last created and others ignore all of this.
/////////////////////////////////////////////////////
Here some example code
/////////////////////////////////////////////////////
function radit
{
///this function is executed only after button pressing
mantu_pan = pan_create("bmap =abols.tga;",14,);
mantu_pan.on_click = parvietot_mani;
}

function parvietot_mani
{
while(mouse_left == 1)
{
mantu_pan.pos_x = mouse_pos.x;
mantu_pan.pos_y = mouse_pos.y;
wait(1);
}
}
/////////////////////////////////////////////
This is very short example but only to show that when here pressing on every panel let execute function only to last one created
*Please help any --> with this im fighting long time and cant solve.
Posted By: raiden

Re: Creatd panel problem - 12/11/07 01:57

Hi MDI, the solution to your problem can be easily solved by storing the panel pointer in an array with the commands handle() and ptr_to_handle().

Here is an example:
Code:

define maxPanels, 10; // this defines the total amount of panels you want
//
panel* panel1;
panel* panel2;
panel* panel3;
panel* panel4;
panel* panel5;
panel* panel6;
panel* panel7;
panel* panel8;
panel* panel9;
panel* panel10;
//
panel* tempPanel;
//
var panelArray[maxPanels]; // holds your panel pointers
var panelCtr; // increments the indexes in the array
//
function storePanels(index)
{
if(index == 0) { panelArray[index] = handle(panel1); return; }
if(index == 1) { panelArray[index] = handle(panel2); return; }
if(index == 2) { panelArray[index] = handle(panel3); return; }
if(index == 3) { panelArray[index] = handle(panel4); return; }
if(index == 4) { panelArray[index] = handle(panel5); return; }
if(index == 5) { panelArray[index] = handle(panel6); return; }
if(index == 6) { panelArray[index] = handle(panel7); return; }
if(index == 7) { panelArray[index] = handle(panel8); return; }
if(index == 8) { panelArray[index] = handle(panel9); return; }
if(index == 9) { panelArray[index] = handle(panel10); }
}
//
function createPanels()
{
if(panelCtr > maxPanels-1) { error("Not enough indexes in array!"); return; }
if(panelCtr == 0) { panel1 = pan_create("bmap = abols.tga",14); }
if(panelCtr == 1) { panel2 = pan_create("bmap = abols.tga",14); }
if(panelCtr == 2) { panel3 = pan_create("bmap = abols.tga",14); }
if(panelCtr == 3) { panel4 = pan_create("bmap = abols.tga",14); }
if(panelCtr == 4) { panel5 = pan_create("bmap = abols.tga",14); }
if(panelCtr == 5) { panel6 = pan_create("bmap = abols.tga",14); }
if(panelCtr == 6) { panel7 = pan_create("bmap = abols.tga",14); }
if(panelCtr == 7) { panel8 = pan_create("bmap = abols.tga",14); }
if(panelCtr == 8) { panel9 = pan_create("bmap = abols.tga",14); }
if(panelCtr == 9) { panel10 = pan_create("bmap = abols.tga",14); }
//
storePanels(panelCtr); // store the handle
//
panelCtr += 1;
}
//
function getPanel(index)
{
tempPanel = ptr_for_handle(panelArray[index]);
if(tempPanel != null)
{
// do some stuff(testing)
tempPanel.pos_x += 10;
tempPanel.pos_y += 10;
}
}



So thats the cscript way I know of, its not very clean, but it works(i think )

Anyway, you have all your panel pointers, and a way to store them in the array every time you call createPanels(); Next its just a matter of knowing which panel is stored in the array and getting it back to manipulate it however you need and you would do that through getPanel(index);, so if you want to grab your 1st panel, you would call getPanel(0); and now tempPanel points to panel1, to which you can alter however you need.

I hope that helps you out.

-raiden
Posted By: MDI

Creatd panel problem - 12/15/07 19:44

Sorry for so late answer, but first i wishes something where can undefined quantity of panel use! - That first.
second is here:
//////////////////////////////////////////////
mantu_pan = pan_create("bmap =abols.tga;",14,);
mantu_pan.on_click = parvietot_mani;
//////////////////////////////////////////////
OR "on_click" can get in that quotation marks! Then sure every panel will execute his own pressed function, but then for panels need termine like "Me". Overnamed entity name let use mostly functions for last entity! And that next_entity i dont understand too - haw can use it.

And then here is much questions - if any really this engine user can help me - please, because panel system looks quit primitive here!
Posted By: mpdeveloper_B

Re: Creatd panel problem - 12/16/07 03:09

did you define mantu_pan like this:

panel* mantu_pan;

this is very important, if you don't do this, you will get errors, or it just won't work
Posted By: adoado

Re: Creatd panel problem - 12/16/07 03:15

Quote:

Sorry for so late answer, but first i wishes something where can undefined quantity of panel use! - That first.





You will need to use an array like Raiden said. Arrays cannot change their size during runtime, so if you wanted the size the change at runtime you would need to use a DLL as the storage (and not 3dgs arrays) or, in Lite-C, I think you can use Linked Lists.

Thanks, ^^
Adoado
Posted By: MDI

Creatd panel problem - 12/16/07 08:30

Pity from dll i dont know anything! But or with dll can make panels so interactive like entities? Otherwise i cant work normal. But i can try to hide all problems, but that never is good solution.

mpdeveloper_B : Im always defining all names, but that isnt problem here.
adoado: Im using standart c-script. Ann how i see you have experience with dlls - possible you can help me understand how to work with thrm.
© 2024 lite-C Forums