public void writeSettings()
        {
            Settings       EditorSettings             = "EditorSettings";
            GuiTabBookCtrl DatablockEditorTreeTabBook = "DatablockEditorTreeTabBook";

            EditorSettings.beginGroup("DatablockEditor", true);

            EditorSettings.setValue("libraryTab", DatablockEditorTreeTabBook.getSelectedPage().AsString());
            if (this.getNumSelectedDatablocks() > 0)
            {
                EditorSettings.setValue("selectedDatablock", this.getSelectedDatablock().getName());
            }

            EditorSettings.endGroup();
        }
        public void readSettings()
        {
            Settings       EditorSettings             = "EditorSettings";
            GuiTabBookCtrl DatablockEditorTreeTabBook = "DatablockEditorTreeTabBook";

            EditorSettings.beginGroup("DatablockEditor", true);

            DatablockEditorTreeTabBook.selectPage(EditorSettings.value("libraryTab").AsInt());
            SimObject db = EditorSettings.value("selectedDatablock");

            if (db.isObject() && db.isMemberOfClass("SimDatablock"))
            {
                this.selectDatablock(db);
            }

            EditorSettings.endGroup();
        }
        public override void onWake()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            GuiCheckBoxCtrl PosRelative    = this.FOT("PosRelative");
            GuiCheckBoxCtrl RotRelative    = this.FOT("RotRelative");
            GuiCheckBoxCtrl ScaleRelative  = this.FOT("ScaleRelative");
            GuiCheckBoxCtrl SizeRelative   = this.FOT("SizeRelative");
            GuiButtonCtrl   GetPosButton   = this.FOT("GetPosButton");
            GuiButtonCtrl   GetRotButton   = this.FOT("GetRotButton");
            GuiButtonCtrl   GetScaleButton = this.FOT("GetScaleButton");
            GuiButtonCtrl   GetSizeButton  = this.FOT("GetSizeButton");
            GuiCheckBoxCtrl SizeLocal      = this.FOT("SizeLocal");
            GuiTabBookCtrl  ScaleTabBook   = this.FOT("ScaleTabBook");
            GuiButtonCtrl   ApplyButton    = this.FOT("ApplyButton");

            // Make everything relative
            PosRelative.setStateOn(true);
            RotRelative.setStateOn(true);
            ScaleRelative.setStateOn(true);
            SizeRelative.setStateOn(false);

            GetPosButton.setActive(false);
            GetRotButton.setActive(false);
            GetScaleButton.setActive(false);
            GetSizeButton.setActive(false);

            // Size is always local
            SizeLocal.setStateOn(true);
            SizeLocal.setActive(false);

            ScaleTabBook.selectPage(0); // Scale page

            ApplyButton.setActive(false);

            EWorldEditor["ETransformSelectionDisplayed"] = false.AsString();
        }
        public override void onWorldEditorStartup()
        {
            EditorGui EditorGui = "EditorGui";

            // Add ourselves to the window menu.
            string accel = EditorGui.addToEditorsMenu("Shape Editor", "", this);

            // Add ourselves to the ToolsToolbar
            string tooltip = "Shape Editor (" + accel + ")";

            EditorGui.addToToolsToolbar("ShapeEditorPlugin", "ShapeEditorPalette",
                                        Util._expandFilename("tools/worldEditor/images/toolbar/shape-editor"), tooltip);

            // Add ourselves to the Editor Settings window
            //exec( "./gui/ShapeEditorSettingsTab.gui" );
            //console.Call("ShapeEditorSettingsTab_initialize");
            ShapeEditorSettingsTab.initialize();


            ESettingsWindow ESettingsWindow = "ESettingsWindow";

            ESettingsWindow.addTabPage("EShapeEditorSettingsPage");

            ShapeEdPropWindow ShapeEdPropWindow = "ShapeEdPropWindow";

            ShapeEdPropWindow.attachTo("ShapeEdSelectWindow");
            ShapeEdAnimWindow ShapeEdAnimWindow = "ShapeEdAnimWindow";

            ShapeEdAnimWindow.resize(-1, 526, 593, 53);

            // Initialise gui
            ShapeEditor.ShapeEdSeqNodeTabBook ShapeEdSeqNodeTabBook = "ShapeEdSeqNodeTabBook";
            ShapeEdSeqNodeTabBook.selectPage(0);
            ShapeEdAdvancedWindow ShapeEdAdvancedWindow        = "ShapeEdAdvancedWindow";
            GuiTabBookCtrl        ShapeEdAdvancedWindowtabBook = ShapeEdAdvancedWindow.FOT("tabBook");

            ShapeEdAdvancedWindowtabBook.selectPage(0);

            ShapeEdSelectWindow ShapeEdSelectWindow        = "ShapeEdSelectWindow";
            GuiTabBookCtrl      ShapeEdSelectWindowtabBook = ShapeEdSelectWindow.FOT("tabBook");

            ShapeEdSelectWindowtabBook.selectPage(0);
            ShapeEdSelectWindow.navigate("");

            ShapeEditorToolbar  ShapeEditorToolbar = "ShapeEditorToolbar";
            GuiBitmapButtonCtrl orbitNodeBtn       = ShapeEditorToolbar.FOT("orbitNodeBtn");

            SetToggleButtonValue(orbitNodeBtn, "0");
            GuiBitmapButtonCtrl ghostMode = ShapeEditorToolbar.FOT("ghostMode");

            SetToggleButtonValue(ghostMode, "0");

            // Initialise hints menu
            SimGroup ShapeHintGroup = "ShapeHintGroup";

            ShapeEditor.ShapeEdHintMenu ShapeEdHintMenu = "ShapeEdHintMenu";
            ShapeEdHintMenu.clear();
            int count = ShapeHintGroup.getCount();

            for (uint i = 0; i < count; i++)
            {
                SimObject hint = ShapeHintGroup.getObject(i);
                ShapeEdHintMenu.add(hint["objectType"], hint);
            }
        }
        public void apply()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            GuiCheckBoxCtrl DoPosition    = this.FOT("DoPosition");
            GuiCheckBoxCtrl DoRotation    = this.FOT("DoRotation");
            GuiCheckBoxCtrl DoScale       = this.FOT("DoScale");
            GuiCheckBoxCtrl DoSize        = this.FOT("DoSize");
            GuiCheckBoxCtrl PosRelative   = this.FOT("PosRelative");
            GuiCheckBoxCtrl RotRelative   = this.FOT("RotRelative");
            GuiCheckBoxCtrl RotLocal      = this.FOT("RotLocal");
            GuiCheckBoxCtrl ScaleRelative = this.FOT("ScaleRelative");
            GuiCheckBoxCtrl ScaleLocal    = this.FOT("ScaleLocal");
            GuiCheckBoxCtrl SizeRelative  = this.FOT("SizeRelative");
            GuiCheckBoxCtrl SizeLocal     = this.FOT("SizeLocal");
            GuiTextEditCtrl PosY          = this.FOT("PosY");
            GuiTextEditCtrl PosX          = this.FOT("PosX");
            GuiTextEditCtrl PosZ          = this.FOT("PosZ");
            GuiTextEditCtrl ScaleX        = this.FOT("ScaleX");
            GuiTextEditCtrl ScaleY        = this.FOT("ScaleY");
            GuiTextEditCtrl ScaleZ        = this.FOT("ScaleZ");
            GuiTextEditCtrl SizeX         = this.FOT("SizeX");
            GuiTextEditCtrl SizeY         = this.FOT("SizeY");
            GuiTextEditCtrl SizeZ         = this.FOT("SizeZ");
            GuiTextEditCtrl Pitch         = this.FOT("Pitch");
            GuiTextEditCtrl Bank          = this.FOT("Bank");
            GuiTextEditCtrl Heading       = this.FOT("Heading");
            GuiTabBookCtrl  ScaleTabBook  = this.FOT("ScaleTabBook");

            string position    = DoPosition.getValue().AsString();
            string p           = PosX.getValue() + ' ' + PosY.getValue() + ' ' + PosZ.getValue();
            string relativePos = PosRelative.getValue();

            string rotate = DoRotation.getValue();
            string r      = Util.mDegToRad(Pitch.getValue().AsFloat()) + ' ' + Util.mDegToRad(Bank.getValue().AsFloat()) +
                            ' ' + Util.mDegToRad(Heading.getValue().AsFloat()).AsString();
            string relativeRot = RotRelative.getValue();
            string rotLocal    = RotLocal.getValue();

            string scale, s, sRelative, sLocal, size;

            // We need to check which Tab page is active
            if (ScaleTabBook.getSelectedPage() == 0)
            {
                // Scale Page
                scale     = DoScale.getValue();
                s         = ScaleX.getValue() + ' ' + ScaleY.getValue() + ' ' + ScaleZ.getValue();
                sRelative = ScaleRelative.getValue();
                sLocal    = ScaleLocal.getValue();

                size = false.AsString();
            }
            else
            {
                // Size Page
                size      = DoSize.getValue();
                s         = SizeX.getValue() + ' ' + SizeY.getValue() + ' ' + SizeZ.getValue();
                sRelative = SizeRelative.getValue();
                sLocal    = SizeLocal.getValue();

                scale = false.AsString();
            }

            EWorldEditor.transformSelection(position.AsBool(), p.AsPoint3F(), relativePos.AsBool(), rotate.AsBool(), r.AsPoint3F(), relativeRot.AsBool(), rotLocal.AsBool(),
                                            (scale.AsBool() ? 1 : (size.AsBool() ? 2 : 0)), s.AsPoint3F(), sRelative.AsBool(), sLocal.AsBool());
        }