addGuiControl issue
by Howard Dortch · in Torque 3D Professional · 02/09/2014 (8:31 am) · 8 replies
I want to create a bitmap for a gui on the fly.
I have a base bitmap named "buildmap" (displays normally)
An event calls a function to create a new bitmap.
new GuiBitmapCtrl(U2) { all elements removed for brevity };
After creating the new bitmap gui object I call this
buildmap.addguiControl(U2);
The outline of the object shows up but the actual picture wont.
I can open the editor and set the bitmap and it shows up even tho it is exactly the same path and name
Is there a command I can call like registerGuiElement or something like that to make the bitmap picture show up at the time of creation?
I have a base bitmap named "buildmap" (displays normally)
An event calls a function to create a new bitmap.
new GuiBitmapCtrl(U2) { all elements removed for brevity };
After creating the new bitmap gui object I call this
buildmap.addguiControl(U2);
The outline of the object shows up but the actual picture wont.
I can open the editor and set the bitmap and it shows up even tho it is exactly the same path and name
Is there a command I can call like registerGuiElement or something like that to make the bitmap picture show up at the time of creation?
#2
IE:
02/09/2014 (10:26 am)
If you're just trying to create GUI elements on the fly, you can just go about it normally by creating the control in a string buffer and then calling eval() on the buffer.IE:
//I wrote this by hand so mistakes are possible
function createBitmapControl(%position, %image) {
%code = "new GuiBitmapCtrl() { position = \""@%position@"\"; bitmap = \""@%image@"\" ... ect... };";
eval(%code);
}
#3
Thanks....
02/09/2014 (10:44 am)
Tried both of those, the object creates just fine but the bitmap does not show up, only the outline of where the object is. There has to be a update or reflow to get that to work.Thanks....
#4
02/09/2014 (10:47 am)
Did you check the console? Any relevant errors or warnings?
#5
I would make a container GuiControl, add the GuiBitmapCtrl buildmap to it. Then to switch, I'd remove buildmap and add the new GuiBitmapCtrl in its place just to be sure - they should render first-to-last (leaving the last one added on top) but I like to be sure.
02/09/2014 (11:16 am)
What type of control is buildmap? It should work regardless. What about the new control's position field? Should be "0 0" the image itself is being rendered at that position relative to the containing control.I would make a container GuiControl, add the GuiBitmapCtrl buildmap to it. Then to switch, I'd remove buildmap and add the new GuiBitmapCtrl in its place just to be sure - they should render first-to-last (leaving the last one added on top) but I like to be sure.
#6
1. You're pointing to an invalid image path (be sure to double check that).
2. The image you're pointing to is an unsupported image format for the engine.
3. There's a bug in the code, in which case, use my above, but assign the control a name and then follow it immediately with %ctrl.setBitmap(%path); and see if that works.
02/09/2014 (11:20 am)
@Howard: Three things strike me as possible here.1. You're pointing to an invalid image path (be sure to double check that).
2. The image you're pointing to is an unsupported image format for the engine.
3. There's a bug in the code, in which case, use my above, but assign the control a name and then follow it immediately with %ctrl.setBitmap(%path); and see if that works.
#7
path is valid since I can add it from the editor
image format is png and it does load when I create the control using the editor.
setBitmap(%path) works with no errors
image does not show up.
If I edit the new object and click on the bitmap button and add it there it shows up even though it is exactly the same path/name.ext
thanks
02/09/2014 (11:57 am)
new GuiControl(BuildMap) is container = truepath is valid since I can add it from the editor
image format is png and it does load when I create the control using the editor.
setBitmap(%path) works with no errors
image does not show up.
If I edit the new object and click on the bitmap button and add it there it shows up even though it is exactly the same path/name.ext
thanks
#8
02/09/2014 (5:48 pm)
Got it working, Thanks for the help...
Andrew Mac
%draggable = new GuiDragAndDropControl() { position = -50 SPC -50; extent = "64 64"; deleteOnMouseUp = true; }; %bmp_icon = new GuiBitmapCtrl() { Extent = "64 64"; bitmap = "art/gui/equipment/" @ %this.eq.icon; eq = %this.eq; draggedFrom = %this; }; %draggable.add(%bmp_icon); LoadoutGui.add(%draggable);