Type organisation *sigh*
Blitz3D Forums/Blitz3D Beginners Area/Type organisation *sigh*
| ||
Hey peeps! Need a little beginners help here :) Ive got a small problem organising my gadgets. I have previously used a field "Order" which actually slightly changes the z position of the gadgets in 3d to position them first/last/wherever, what i need to do, is organise the type list in such a way that the first to be drawn is the first in the list... Ive tried using before/after first/last but im getting no luck. The reason i need to do this is because in my previous technique, everything apart from the front gadget would lose its order. using this technique, if i click on level, then file, then camera, they will apear in that order rather than when i click on camera, file going to the back. So, How can i order my type list? is there a bug or am i just doing it wrong? Heres some code im using: Type ui_gadget Field iterated=0 Field name$ Field childcount Field child.ui_gadget[1024] Field ID Field title$ Field mesh Field surface Field parent Field Pickable Field x,y,width,height Field Globalx,Globaly Field Txt$ Field Ret$ Field Texture Field textureframes Field Togglemode Field Toggle Field Order# Field draworder# Field minx,miny,maxx,maxy Field autohide End Type Function bringtofront(gadgetid) Local frontgadget.ui_gadget=gadgetfromID(findparent(gadgetID)) Local gadget.ui_gadget Local gadget2.ui_gadget Local Lastgadget.ui_gadget=Last ui_gadget Local count=1,cc,c2,ocnt,cnt=1 Insert frontgadget After Last ui_gadget ;insert the gadget at the end of the list!???? If frontgadget<>Last ui_gadget Then RuntimeError "poo" ;test if its not working, seems to be.... cc=frontgadget\childcount For c2=1 To cc ;iterate and bring children to front also Insert frontgadget\child[c2] After Last ui_gadget ;Place child last ;(forcing the previous last position back one? is that how it works?) Next ;Now iterate through the list and give them all an order... For gadget=Each ui_gadget GADGET\ITERATED=0 gadget\draworder=cnt gadget\order=cnt updategadget gadget cnt=cnt+1 Next ..... |
| ||
You could have another type collection you use to order your gadgets. Everytime you want to re-order, delete the type collection, then readd the fields again. Your orginal type collection will hold the types on jumbled order, and you'll just use the new list to order the types. :o) |
| ||
@Ross C: That sounds like hard work. I'm rather new to using types. Why does my above technique not work anyway? I will give that ago if i understand it, i will need to iterate the types, and generate a new list? That sounds like alot of work just to reposition a type. :/ |
| ||
How about an array of types? |
| ||
Not too sure how i would use them, Ive gone as far as making an array, storing the types. thats something i could do and it would work, but the time it takes to do its stuff increases exponentially. 1 item is pretty much instant... 10 items is 10x10... 2000...? well, you see my point here. Rather dissapointed i cant do a quick run through the list after rearanging and just assign a new zorder :/ |
| ||
As an update, im printing though the list and last ui_gadget is NOT the last one printed out :S Im pretty sure i can sort this now, but anymore ideas anyway? :D |
| ||
[edited] bug induced by not using a delay in windowed mode cause what was typed here to be typed :P Is there any way that using positionentity could cock up the 3d? Im not using ANY rotation commands anywhere but at this one point im using "positionentity" and everything while still on a plane, is slanted heavily to the screen I have to go now, but i will show a screenie of this later... I suspect a bug!!! |
| ||
Cygnus, Obviously your developing a 3D GUI. Your ui_gadget Object looks very similar to my own. |
| ||
Well, to order them requires you to search through the entire list again and again, finding the lowest ordered. So, it's gonna take alot of iterations. But, you could take an array of the type handles. Get the order number and plug the handle of the type into the array.means you'd only go through the list once. eg:for g.gadget = each gadget array(g\order) = handle g.gadget next then you would go through the array and access the type in the order there to be drawn in. Thing is, you'd need to have a variable holding the number of gadgets, because of the static size of the array. for loop = 0 to number_of_gadgets-1 g.gadget = object array(loop) drawimage g\gadget_image next It's getting late and i can't remember how exactly the object handle thing works. I'll have a look tommorow, but the code above should work and be fairly quick. Quicker then cycling through the types again and again. |
| ||
My old example of sorting a list is here. And this is a slightly different version. |
| ||
@Fank; Pure coinsidence ;) i started this from scratch as a UI is not something ive done before :) *continues to read* |
| ||
Ahh guys, cheers for your help Sadly, i was already doing the organising and it was working, but the bug is still there, so its somewhere else.... IM going to try getting that wierd 3d thing to happen again and il post about it :) Cheers anyway |