Example #1
0
        public override void onDeactivated()
        {
            ETransformSelection ETransformSelection = "ETransformSelection";
            EWorldEditor        EWorldEditor        = "EWorldEditor";
            EditorGui           EditorGui           = "EditorGui";

            ETransformSelection.setVisible(false);
            EWorldEditor.setVisible(false);
            EditorGui.menuBar.remove(EditorGui.worldMenu);
            base.onDeactivated();
        }
Example #2
0
        public void positionContextMenu(SimObject menu)
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            if ((Util.getWord(menu["position"], 0).AsInt() + Util.getWord(menu["extent"], 0).AsInt()) > Util.getWord(EWorldEditor["extent"], 0).AsInt())
            {
                int posx   = Util.getWord(menu["position"], 0).AsInt();
                int offset = Util.getWord(EWorldEditor["extent"], 0).AsInt() - (posx + Util.getWord(menu["extent"], 0).AsInt()) - 5;
                posx            += offset;
                menu["position"] = posx + " " + Util.getWord(menu["position"], 1);
            }
        }
        public void getAbsRotation()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            GuiCheckBoxCtrl DoRotation  = this.FOT("DoRotation");
            GuiCheckBoxCtrl RotRelative = this.FOT("RotRelative");
            GuiCheckBoxCtrl RotLocal    = this.FOT("RotLocal");
            GuiTextEditCtrl Bank        = this.FOT("Bank");
            GuiTextEditCtrl Pitch       = this.FOT("Pitch");
            GuiTextEditCtrl Heading     = this.FOT("Heading");

            int count = EWorldEditor.getSelectionSize();

            // If we have more than one SceneObject selected,
            // we must exit.
            SimObject obj = -1;

            for (int i = 0; i < count; i++)
            {
                SimObject test = EWorldEditor.getSelectedObject(i);
                if (test.isMemberOfClass("SceneObject"))
                {
                    if (obj != -1)
                    {
                        return;
                    }

                    obj = test;
                }
            }

            if (obj == -1)
            {
                // No SceneObjects selected
                return;
            }

            string rot = obj.call("getEulerRotation");

            Pitch.setText(Util.getWord(rot, 0));
            Bank.setText(Util.getWord(rot, 1));
            Heading.setText(Util.getWord(rot, 2));

            // Turn off relative as we're populating absolute values.
            // Of course this means that we need to set local on.
            RotRelative.setValue("0");
            RotLocal.setValue("1");

            // Finally, set the Rotation check box as active.  The user
            // likely wants this if they're getting the position.
            DoRotation.setValue("1");
        }
Example #4
0
        public override void onInspectorFieldModified(string objectx, string fieldName, string arrayIndex, string oldValue, string newValue)
        {
            SimObject obj    = objectx;
            editor    Editor = "Editor";

            // The instant group will try to add our
            // UndoAction if we don't disable it.
            Util.pushInstantGroup();

            string nameOrClass = obj.getName();

            if (nameOrClass == "")
            {
                nameOrClass = obj.getClassName();
            }

            ObjectCreator oc = new ObjectCreator("InspectorFieldUndoAction");

            oc["actionName"]   = nameOrClass + "." + fieldName + " Change";
            oc["objectId"]     = obj.getId();
            oc["fieldName"]    = fieldName;
            oc["fieldValue"]   = oldValue;
            oc["arrayIndex"]   = arrayIndex;
            oc["inspectorGui"] = this;
            InspectorFieldUndoAction action = oc.Create();

            // If it's a datablock, initiate a retransmit.  Don't do so
            // immediately so as the actual field value will only be set
            // by the inspector code after this method has returned.

            if (obj.isMemberOfClass("SimDataBlock"))
            {
                obj.schedule("1", "reloadOnLocalClient");
            }

            // Restore the instant group.
            Util.popInstantGroup();

            action.addToManager(Editor.getUndoManager());

            EWorldEditor EWorldEditor = "EWorldEditor";

            EWorldEditor.isDirty = true;

            // Update the selection
            if (EWorldEditor.getSelectionSize() > 0 &&
                (fieldName == "position" || fieldName == "rotation" || fieldName == "scale"))
            {
                EWorldEditor.invalidateSelectionCentroid();
            }
        }
Example #5
0
        public void onEditorActivated()
        {
            EWorldEditor       EWorldEditor = "EWorldEditor";
            GuiMissionAreaCtrl MissionAreaEditorTerrainEditor = "MissionAreaEditorTerrainEditor";

            EWorldEditor.clearSelection();

            MissionArea ma = Util.getMissionAreaServerObject();

            EWorldEditor.selectObject(ma);
            EWorldEditor.syncGui();
            MissionAreaEditorTerrainEditor.updateTerrain();
            this.setSelectedMissionArea(ma);
            this.onMissionAreaSelected(this.getSelectedMissionArea());
        }
        public void ToggleVisibility()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            if (this.visible)
            {
                this.setVisible(false);
                EWorldEditor["ETransformSelectionDisplayed"] = false.AsString();
            }
            else
            {
                this.setVisible(true);
                this.selectWindow();
                this.setCollapseGroup(false);
                EWorldEditor["ETransformSelectionDisplayed"] = true.AsString();
            }
        }
Example #7
0
        public bool isValidDragTarget(int id, SimObject obj)
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            if (obj.isMemberOfClass("Path"))
            {
                return(EWorldEditor.areAllSelectedObjectsOfType("Marker"));
            }
            if (obj.name == "CameraBookmarks")
            {
                return(EWorldEditor.areAllSelectedObjectsOfType("CameraBookmark"));
            }
            else
            {
                return(obj.getClassName() == "SimGroup");
            }
        }
Example #8
0
        public override void onObjectDeleteCompleted()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            // This can be called when a deletion is attempted but nothing was
            // actually deleted ( cannot delete the root of the tree ) so only submit
            // the undo if we really deleted something.
            if (this.undoDeleteList != "")
            {
                Extendable.MEDeleteUndoAction.submit(this.undoDeleteList, false);
            }

            // Let the world editor know to
            // clear its selection.
            EWorldEditor.clearSelection();
            EWorldEditor.isDirty = true;
        }
Example #9
0
        public override void onAddSelection(int obj, bool isLastSelection)
        {
            EWorldEditor EWorldEditor = "EWorldEditor";
            EWTreeWindow EWTreeWindow = "EWTreeWindow";
            Inspector    Inspector    = "Inspector";

            GuiBitmapButtonCtrl LockSelection   = EWTreeWindow.FOT("LockSelection");
            GuiBitmapButtonCtrl DeleteSelection = EWTreeWindow.FOT("DeleteSelection");

            EWorldEditor.selectObject(obj.AsString());

            int selSize   = EWorldEditor.getSelectionSize();
            int lockCount = EWorldEditor.getSelectionLockCount();

            if (lockCount < selSize)
            {
                LockSelection.setStateOn(false);
                LockSelection.command = "EWorldEditor.lockSelection(true); EditorTree.toggleLock();";
            }
            else if (lockCount > 0)
            {
                LockSelection.setStateOn(true);
                LockSelection.command = "EWorldEditor.lockSelection(false); EditorTree.toggleLock();";
            }

            if (selSize > 0 && lockCount == 0)
            {
                DeleteSelection.command = "EditorMenuEditDelete();";
            }
            else
            {
                DeleteSelection.command = "";
            }

            if (isLastSelection)
            {
                Inspector.addInspect(obj.AsString());
            }
            else
            {
                Inspector.addInspect(obj.AsString(), false);
            }
        }
        public override void handleDelete()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";
            EditorTree   EditorTree   = "EditorTree";

            // The tree handles deletion and notifies the
            // world editor to clear its selection.
            //
            // This is because non-SceneObject elements like
            // SimGroups also need to be destroyed.
            //
            // See EditorTree::onObjectDeleteCompleted().
            int selSize = EWorldEditor.getSelectionSize();

            if (selSize > 0)
            {
                EditorTree.deleteSelection();
            }
        }
Example #11
0
            public void onObjectCreated(SimObject objId)
            {
                EditorTree   EditorTree   = "EditorTree";
                EWorldEditor EWorldEditor = "EWorldEditor";

                // Can we submit an undo action?
                if (objId.isObject())
                {
                    Extendable.MECreateUndoAction.submit(objId);
                }

                EditorTree.clearSelection();
                EWorldEditor.clearSelection();
                EWorldEditor.selectObject(objId);

                // When we drop the selection don't store undo
                // state for it... the creation deals with it.
                EWorldEditor.dropSelection(true);
            }
        public override void onEditMenuSelect(string editMenu)
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            bool canCutCopy = EWorldEditor.getSelectionSize() > 0;

            ((PopupMenu)editMenu).enableItem(3, canCutCopy);                       // Cut
            ((PopupMenu)editMenu).enableItem(4, canCutCopy);                       // Copy
            ((PopupMenu)editMenu).enableItem(5, EWorldEditor.canPasteSelection()); // Paste

            int selSize   = EWorldEditor.getSelectionSize();
            int lockCount = EWorldEditor.getSelectionLockCount();
            int hideCount = EWorldEditor.getSelectionHiddenCount();

            ((PopupMenu)editMenu).enableItem(6, (selSize > 0 && lockCount != selSize));
            // Delete Selection

            ((PopupMenu)editMenu).enableItem(8, canCutCopy);  // Deselect
        }
        public override void onActivated()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            ShapeEditor.ShapeEdShapeTreeView ShapeEdShapeTreeView = "ShapeEdShapeTreeView";
            ShapeEditor ShapeEditor = "ShapeEditor";

            ShapeEditor.ShapeEdShapeView ShapeEdShapeView = "ShapeEdShapeView";
            GuiCanvas Canvas = "Canvas";

            //Copyright Winterleaf Entertainment L.L.C. 2013
            this["isActive"] = true.AsString();
            //Copyright Winterleaf Entertainment L.L.C. 2013
            this.open("");

            // Try to start with the shape selected in the world editor
            int count = EWorldEditor.getSelectionSize();

            for (int i = 0; i < count; i++)
            {
                SimObject obj       = EWorldEditor.getSelectedObject(i);
                string    shapeFile = ShapeEditor.getObjectShapeFile(obj);
                if (shapeFile != "")
                {
                    if (!ShapeEditor.shape.isObject() || (ShapeEditor.shape["baseShape"] != shapeFile))
                    {
                        // Call the 'onSelect' method directly if the object is not in the
                        // MissionGroup tree (such as a Player or Projectile object).
                        ShapeEdShapeTreeView.clearSelection();
                        if (!ShapeEdShapeTreeView.selectItem(obj))
                        {
                            ShapeEdShapeTreeView.onSelect(obj, "");
                        }

                        // 'fitToShape' only works after the GUI has been rendered, so force a repaint first
                        Canvas.repaint(0);
                        ShapeEdShapeView.fitToShape();
                    }
                    break;
                }
            }
        }
        public void getAbsPosition()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            GuiCheckBoxCtrl DoPosition  = this.FOT("DoPosition");
            GuiCheckBoxCtrl PosRelative = this.FOT("PosRelative");
            GuiTextEditCtrl PosY        = this.FOT("PosY");
            GuiTextEditCtrl PosX        = this.FOT("PosX");
            GuiTextEditCtrl PosZ        = this.FOT("PosZ");

            string pos = EWorldEditor.getSelectionCentroid();

            PosX.setText(Util.getWord(pos, 0));
            PosY.setText(Util.getWord(pos, 1));
            PosZ.setText(Util.getWord(pos, 2));

            // Turn off relative as we're populating absolute values
            PosRelative.setValue("0");

            // Finally, set the Position check box as active.  The user
            // likely wants this if they're getting the position.
            DoPosition.setValue("1");
        }
        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 handleDeselect()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            EWorldEditor.clearSelection();
        }
        public void create()
        {
            /*
             * %terrainName = %this-->theName.getText();
             * %resolution = %this-->theRezList.getSelected();
             * %materialName = %this-->theMaterialList.getText();
             * %genNoise = %this-->noiseRadio.getValue();
             *
             * %obj = TerrainBlock::createNew( %terrainName, %resolution, %materialName, %genNoise );
             *
             * if( %genNoise )
             *    ETerrainEditor.isDirty = true;
             *
             * if( isObject( %obj ) )
             * {
             *    // Submit an undo action.
             *    MECreateUndoAction::submit(%obj);
             *
             *    assert( isObject( EWorldEditor ),
             *       "ObjectBuilderGui::processNewObject - EWorldEditor is missing!" );
             *
             *    // Select it in the editor.
             *    EWorldEditor.clearSelection();
             *    EWorldEditor.selectObject(%obj);
             *
             *    // When we drop the selection don't store undo
             *    // state for it... the creation deals with it.
             *    EWorldEditor.dropSelection( true );
             * }
             *
             * Canvas.popDialog( %this );
             */

            string           terrainName  = ((GuiTextEditCtrl)this.findObjectByInternalName("theName", true)).getText();
            GuiPopUpMenuCtrl rezList      = this.findObjectByInternalName("theRezList", true);
            GuiPopUpMenuCtrl matList      = this.findObjectByInternalName("theMaterialList", true);
            string           resolution   = rezList.getSelected().AsString();
            string           materialName = matList.getText();
            string           genNoise     = ((GuiRadioCtrl)this.findObjectByInternalName("noiseRadio", true)).getValue();

            TerrainBlock obj = console.Eval("TerrainBlock::createNew(\"" + terrainName + "\",\"" + resolution + "\",\"" + materialName + "\",\"" + genNoise + "\");", true);

            if (genNoise.AsBool())
            {
                ((SimObject)"ETerrainEditor")["isDirty"] = "1";
            }

            if (obj.isObject())
            {
                EWorldEditor EWorldEditor = "EWorldEditor";
                // Submit an undo action.
                Extendable.MECreateUndoAction.submit(obj);
                // Select it in the editor.
                EWorldEditor.clearSelection();
                EWorldEditor.selectObject(obj);

                // When we drop the selection don't store undo
                // state for it... the creation deals with it.

                EWorldEditor.dropSelection(true);
            }
            ((GuiCanvas)"Canvas").popDialog(this);
        }
        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());
        }
        public void open(string filename)
        {
            EditorGui             EditorGui             = "EditorGui";
            ShapeEdPropWindow     ShapeEdPropWindow     = "ShapeEdPropWindow";
            ShapeEdSelectWindow   ShapeEdSelectWindow   = "ShapeEdSelectWindow";
            ShapeEdAdvancedWindow ShapeEdAdvancedWindow = "ShapeEdAdvancedWindow";
            ShapeEdAnimWindow     ShapeEdAnimWindow     = "ShapeEdAnimWindow";
            ShapeEditorToolbar    ShapeEditorToolbar    = "ShapeEditorToolbar";

            ShapeEditor.ShapeEdShapeView ShapeEdShapeView = "ShapeEdShapeView";
            ShapeEditor.ShapeEdNodes     ShapeEdNodes     = "ShapeEdNodes";
            Settings     EditorSettings     = "EditorSettings";
            EWorldEditor EWorldEditor       = "EWorldEditor";
            GizmoProfile GlobalGizmoProfile = "GlobalGizmoProfile";

            ShapeEditor.ShapeEdShapeTreeView      ShapeEdShapeTreeView = "ShapeEdShapeTreeView";
            ShapeEditor.ShapeEdPreviewGui         ShapeEdPreviewGui    = "ShapeEdPreviewGui";
            ShapeEditorActions.ShapeEdUndoManager ShapeEdUndoManager   = "ShapeEdUndoManager";
            SimGroup MissionGroup = "MissionGroup";
            GuiDynamicCtrlArrayControl ToolsPaletteArray = "ToolsPaletteArray";
            editor Editor = "Editor";

            ShapeEditor.ShapeEdMaterials ShapeEdMaterials = "ShapeEdMaterials";
            ShapeEditor ShapeEditor = "ShapeEditor";

            GuiBitmapButtonCtrl wireframeMode     = ShapeEditorToolbar.FOT("wireframeMode");
            GuiBitmapButtonCtrl showAdvanced      = ShapeEditorToolbar.FOT("showAdvanced");
            GuiIconButtonCtrl   worldTransform    = ShapeEdNodes.FOT("worldTransform");
            GuiIconButtonCtrl   objectTransform   = ShapeEdNodes.FOT("objectTransform");
            GuiCheckBoxCtrl     highlightMaterial = ShapeEdMaterials.FOT("highlightMaterial");
            GuiCanvas           Canvas            = "Canvas";

            if (!this["isActivated"].AsBool())
            {
                // Activate the Shape Editor
                EditorGui.setEditor(this, false);

                // Get editor settings (note the sun angle is not configured in the settings
                // dialog, so apply the settings here instead of in readSettings)
                this.readSettings();
                ShapeEdShapeView["sunAngleX"] = EditorSettings.value("ShapeEditor/SunAngleX");
                ShapeEdShapeView["sunAngleZ"] = EditorSettings.value("ShapeEditor/SunAngleZ");
                EWorldEditor["forceLoadDAE"]  = EditorSettings.value("forceLoadDAE");

                bGlobal["$wasInWireFrameMode"] = bGlobal["$gfx::wireframe"];
                wireframeMode.setStateOn(bGlobal["$gfx::wireframe"]);

                if (GlobalGizmoProfile.getFieldValue("alignment", -1) == "Object")
                {
                    objectTransform.setStateOn(true);
                }
                else
                {
                    worldTransform.setStateOn(true);
                }

                // Initialise and show the shape editor
                ShapeEdShapeTreeView.open(MissionGroup);
                ShapeEdShapeTreeView.buildVisibleTree(true);

                ShapeEdPreviewGui.setVisible(true);
                ShapeEdSelectWindow.setVisible(true);
                ShapeEdPropWindow.setVisible(true);
                ShapeEdAnimWindow.setVisible(true);
                ShapeEdAdvancedWindow.setVisible(showAdvanced.getValue().AsBool());
                ShapeEditorToolbar.setVisible(true);
                EditorGui.bringToFront(ShapeEdPreviewGui);

                ((GuiBitmapButtonCtrl)ToolsPaletteArray.FOT("WorldEditorMove")).performClick();
                this.map.push();

                // Switch to the ShapeEditor UndoManager
                this["oldUndoMgr"] = Editor.getUndoManager();
                Editor.setUndoManager(ShapeEdUndoManager);

                ShapeEdShapeView.setDisplayType(EditorGui["currentDisplayType"].AsInt());
                this.initStatusBar();

                // Customise menu bar
                this["oldCamFitCmd"]      = this.replaceMenuCmd("Camera", "8", "ShapeEdShapeView.fitToShape();");
                this["oldCamFitOrbitCmd"] = this.replaceMenuCmd("Camera", "9", "ShapeEdShapeView.fitToShape();");

                base.onActivated();
            }

            // Select the new shape
            if (ShapeEditor.shape.isObject() && (ShapeEditor.shape["baseShape"] == filename))
            {
                // Shape is already selected => re-highlight the selected material if necessary
                ShapeEdMaterials.updateSelectedMaterial(highlightMaterial.getValue().AsBool());
            }
            else if (filename != "")
            {
                ShapeEditor.selectShape(filename, ShapeEditor.isDirty());

                // 'fitToShape' only works after the GUI has been rendered, so force a repaint first
                Canvas.repaint(0);
                ShapeEdShapeView.fitToShape();
            }
        }
Example #20
0
        public override void onDragDropped()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            EWorldEditor.isDirty = true;
        }
        public override void handlePaste()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            EWorldEditor.pasteSelection();
        }
        public override void onRedone()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            EWorldEditor.syncGui();
        }
        public override void handleCut()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            EWorldEditor.cutSelection();
        }
        public void getAbsSize()
        {
            EWorldEditor    EWorldEditor = "EWorldEditor";
            GuiCheckBoxCtrl ETransformSelectionSizeProportional = "ETransformSelectionSizeProportional";

            GuiCheckBoxCtrl DoSize       = this.FOT("DoSize");
            GuiCheckBoxCtrl SizeRelative = this.FOT("SizeRelative");
            GuiTextEditCtrl SizeX        = this.FOT("SizeX");
            GuiTextEditCtrl SizeY        = this.FOT("SizeY");
            GuiTextEditCtrl SizeZ        = this.FOT("SizeZ");

            int count = EWorldEditor.getSelectionSize();

            // If we have more than one SceneObject selected,
            // we must exit.
            SimObject obj = -1;

            for (int i = 0; i < count; i++)
            {
                SimObject test = EWorldEditor.getSelectedObject(i);
                if (test.isMemberOfClass("SceneObject"))
                {
                    if (obj != -1)
                    {
                        return;
                    }

                    obj = test;
                }
            }

            if (obj == -1)
            {
                // No SceneObjects selected
                return;
            }

            string size  = obj.call("getObjectBox");
            string scale = obj.call("getScale");

            string sizex =
                ((Util.getWord(size, 3).AsFloat() - Util.getWord(size, 0).AsFloat()) * Util.getWord(scale, 0).AsFloat())
                .AsString();

            SizeX.setText(sizex);
            if (!ETransformSelectionSizeProportional.getValue().AsBool())
            {
                SizeY.setText(
                    ((Util.getWord(size, 4).AsFloat() - Util.getWord(size, 1).AsFloat()) *
                     Util.getWord(scale, 1).AsFloat()).AsString());
                SizeZ.setText(
                    ((Util.getWord(size, 5).AsFloat() - Util.getWord(size, 2).AsFloat()) *
                     Util.getWord(scale, 2).AsFloat()).AsString());
            }
            else
            {
                SizeY.setText(sizex);
                SizeZ.setText(sizex);
            }

            // Turn off relative as we're populating absolute values
            SizeRelative.setValue("0");

            // Finally, set the Size check box as active.  The user
            // likely wants this if they're getting the position.
            DoSize.setValue("1");
        }
        public override void handleCopy()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            EWorldEditor.copySelection();
        }
        public void import()
        {
            // Gather all the import settings.
            GuiTextEditCtrl HeightfieldFilename = this.findObjectByInternalName("HeightfieldFilename", true);
            string          heightMapPng        = HeightfieldFilename.getText();
            GuiTextEditCtrl MetersPerPixel      = this.findObjectByInternalName("MetersPerPixel", true);
            string          metersPerPixel      = MetersPerPixel.getText();
            GuiTextEditCtrl HeightScale         = findObjectByInternalName("HeightScale", true);
            string          heightScale         = HeightScale.getText();
            GuiCheckBoxCtrl FlipYAxis           = findObjectByInternalName("FlipYAxis", true);
            bool            flipYAxis           = FlipYAxis.isStateOn();

            editor Editor = "Editor";
            // Grab and validate terrain object name.

            string terrainName = ((GuiTextEditCtrl)this.findObjectByInternalName("TerrainName", true)).getText();

            if (!terrainName.isObject() && ((SimObject)terrainName).isMemberOfClass("TerrainBlock") &&
                !Editor.validateObjectName(terrainName, false))
            {
                return;
            }

            string opacityNames  = "";
            string materialNames = "";

            GuiTextListCtrl opacityList = this.findObjectByInternalName("OpacityLayerTextList", true);


            ArrayObject namesArray    = this["namesArray"];
            ArrayObject channelsArray = this["channelsArray"];

            for (int i = 0; i < opacityList.rowCount(); i++)
            {
                string itemText    = opacityList.getRowTextById(i);
                string opacityName = namesArray.getValue(i);
                string channelInfo = channelsArray.getValue(i);
                string channel     = Util.getWord(channelInfo, 0);

                string materialName = Util.getField(itemText, 2);
                opacityNames  += opacityName + "\t" + channel + "\n";
                materialNames += materialName + "\n";
            }

            int updated = Util.nameToID(terrainName);
            // This will update an existing terrain with the name %terrainName,
            // or create a new one if %terrainName isn't a TerrainBlock

            String obj = console.Call_Classname("TerrainBlock", "import",
                                                new string[]
            {
                terrainName, heightMapPng, metersPerPixel, heightScale, opacityNames, materialNames,
                flipYAxis.AsString()
            });

            ((GuiCanvas)"Canvas").popDialog(this);

            if (obj.isObject())
            {
                if (obj != updated.AsString())
                {
                    // created a new TerrainBlock
                    // Submit an undo action.
                    Extendable.MECreateUndoAction.submit(obj);
                }

                EWorldEditor EWorldEditor = "EWorldEditor";

                if (!EWorldEditor.isObject())
                {
                    throw new Exception("ObjectBuilderGui::processNewObject - EWorldEditor is missing!");
                }

                // Select it in the editor.
                EWorldEditor.clearSelection();
                EWorldEditor.selectObject(obj);
                // When we drop the selection don't store undo
                // state for it... the creation deals with it.

                EWorldEditor.dropSelection(obj.AsBool());

                EWorldEditor.isDirty = true;
                //Copyright Winterleaf Entertainment L.L.C. 2013
                ((TerrainPainter)"TerrainPainter").updateLayers("");
                //Copyright Winterleaf Entertainment L.L.C. 2013
            }
            else
            {
                messageBox.MessageBoxOK("Import Terrain", "Terrain import failed! Check console for error messages.",
                                        "Ok");
            }
        }
Example #27
0
        public override void onUnselect(int obj)
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            EWorldEditor.unselectObject(obj.AsString());
        }
        public void onSelectionChanged()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            GuiCheckBoxCtrl RotRelative    = this.FOT("RotRelative");
            GuiCheckBoxCtrl RotLocal       = this.FOT("RotLocal");
            GuiButtonCtrl   GetPosButton   = this.FOT("GetPosButton");
            GuiButtonCtrl   GetRotButton   = this.FOT("GetRotButton");
            GuiButtonCtrl   GetScaleButton = this.FOT("GetScaleButton");
            GuiButtonCtrl   GetSizeButton  = this.FOT("GetSizeButton");
            GuiButtonCtrl   ApplyButton    = this.FOT("ApplyButton");

            // Count the number of selected SceneObjects.  There are
            // other object classes that could be selected, such
            // as SimGroups.
            int count               = EWorldEditor.getSelectionSize();
            int sceneObjects        = 0;
            int globalBoundsObjects = 0;

            for (int i = 0; i < count; i++)
            {
                SimObject obj = EWorldEditor.getSelectedObject(i);
                if (obj.isMemberOfClass("SceneObject"))
                {
                    sceneObjects++;

                    if (obj.call("isGlobalBounds").AsBool())
                    {
                        globalBoundsObjects++;
                    }
                }
            }

            if (sceneObjects == 0)
            {
                // With nothing selected, disable all Get buttons
                this.disableAllButtons();
            }
            else if (sceneObjects == 1)
            {
                // With one selected, all Get buttons are active
                GetPosButton.setActive(true);
                GetRotButton.setActive(true);

                // Special case for Scale and Size for global bounds objects
                if (globalBoundsObjects == 1)
                {
                    GetSizeButton.setActive(false);
                    GetScaleButton.setActive(false);
                }
                else
                {
                    GetSizeButton.setActive(true);
                    GetScaleButton.setActive(true);
                }

                ApplyButton.setActive(true);
            }
            else
            {
                // With more than one selected, only the position button
                // is active
                GetPosButton.setActive(true);
                GetRotButton.setActive(false);
                GetScaleButton.setActive(false);
                GetSizeButton.setActive(false);

                ApplyButton.setActive(true);

                // If both RotRelative and RotLocal are unchecked, then go with RotLocal
                if (RotRelative.getValue().AsInt() == 0 && RotLocal.getValue().AsInt() == 0)
                {
                    RotLocal.setStateOn(true);
                }
            }
        }