Game Development Community

Methods to add objects to GuiFrameSetCtrl via Script?

by Matthew Jessick · in Torque Game Engine · 06/27/2007 (9:08 am) · 3 replies

I looked and didn't see anything obvious to allow adding elements to a GuiFrameSetCtrl via script. Did I miss something?

(In some cases I would prefer to write 10 lines of script to fill up a large array of similar controls rather than using the gui editor or cutting and pasting in the .gui file. )

In code, a base class seems to provide addObject(objectPointer), so I suppose I could create a ConsoleFunction that converts the script ID to an object pointer then calls the addObject.


Possible problems: I'm not 100% sure how the changes happen when the display resolution is changed. Dynamically added objects like this may have to be "manually" resized to the current screen when created...

Any advice or other possible problems?

#1
06/27/2007 (3:28 pm)
Matthew - you'll be pleased to hear the work is already there for you, the object is derived from SimSet if you trace it back far enough, and there is an GuiFramesetCtrl.add() function available in script for precisely this.

So to generate a group via script then you could use:
%obj = new GuiControl() {
             canSaveDynamicFields = "0";
             Profile = "GuiButtonProfile";
             Position = "0 0";
             Extent = "175 220";
               
             new GuiButtonCtrl() {
                Profile = "GuiButtonProfile";
                Position = "10 180";
                Extent = "155 30";
                text = "Test";
                buttonType = "PushButton";
             };
               
      };

      my_guiFrameSetCtrl.add(%obj);

You'll have to play around with the changes in screen resolution, I've always placed them relative positions so don't need to worry about it.
#2
06/28/2007 (12:49 pm)
Thanks, I was pretty sure I was missing something pretty close by! ;)
#3
06/28/2007 (3:44 pm)
Matthew - Not sure if you know about it but you can use %obj.dump(); to list all the variables and functions available for any object, from there you just need to figure out which one to use.