Ejemplo n.º 1
0
        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;
                }
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }