public override void onDeactivated()
        {
            ShapeEdPropWindow     ShapeEdPropWindow     = "ShapeEdPropWindow";
            ShapeEdSelectWindow   ShapeEdSelectWindow   = "ShapeEdSelectWindow";
            ShapeEdAdvancedWindow ShapeEdAdvancedWindow = "ShapeEdAdvancedWindow";
            ShapeEdAnimWindow     ShapeEdAnimWindow     = "ShapeEdAnimWindow";
            ShapeEditorToolbar    ShapeEditorToolbar    = "ShapeEditorToolbar";

            ShapeEditor.ShapeEdPreviewGui ShapeEdPreviewGui = "ShapeEdPreviewGui";
            editor Editor = "Editor";

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

            //Copyright Winterleaf Entertainment L.L.C. 2013
            if (!this["isActive"].AsBool())
            {
                return;
            }
            this["isActive"] = false.AsString();
            //Copyright Winterleaf Entertainment L.L.C. 2013
            this.writeSettings();

            // Notify game objects if shape has been modified
            if (ShapeEditor.isDirty())
            {
                ShapeEditor.shape.notifyShapeChanged();
            }

            bGlobal["$gfx::wireframe"] = bGlobal["$wasInWireFrameMode"];

            ShapeEdMaterials.updateSelectedMaterial(false);
            ShapeEditorToolbar.setVisible(false);

            ShapeEdPreviewGui.setVisible(false);
            ShapeEdSelectWindow.setVisible(false);
            ShapeEdPropWindow.setVisible(false);
            ShapeEdAnimWindow.setVisible(false);
            ShapeEdAdvancedWindow.setVisible(false);
            //Copyright Winterleaf Entertainment L.L.C. 2013
            if (MaterialEditorPropertiesWindow.visible)
            {
                ShapeEdMaterials.editSelectedMaterialEnd(true);
            }
            //Copyright Winterleaf Entertainment L.L.C. 2013
            this.map.pop();

            // Restore the original undo manager
            Editor.setUndoManager(this["oldUndoMgr"]);

            // Restore menu bar
            this.replaceMenuCmd("Camera", "8", this["oldCamFitCmd"]);
            this.replaceMenuCmd("Camera", "9", this["oldCamFitOrbitCmd"]);

            base.onDeactivated();
        }
Example #2
0
        public static void initializeShapeEditor()
        {
            Omni.self.Print(" % - Initializing Shape Editor");

            ShapeEditorProfiles.initialize();
            ShapeEdPreviewWindow.initialize();
            ShapeEdAnimWindow.initialize();
            ShapeEdAdvancedWindow.initialize();
            ShapeEditorToolbar.initialize();
            ShapeEdSelectWindow.initialize();
            ShapeEdPropWindow.initialize();
            gui.CodeBehind.ShapeEditor.initialize();
            ShapeEditorHints.initialize();
            ShapeEditorActions.initialize();

            // Add windows to editor gui
            WinterLeaf.Demo.Full.Models.User.GameCode.Tools.ShapeEditor.gui.CodeBehind.ShapeEditor.ShapeEdPreviewGui
                ShapeEdPreviewGui = "ShapeEdPreviewGui";
            ShapeEdPreviewGui.setVisible(false);

            ShapeEdAnimWindow shapeEdAnimWindow = "ShapeEdAnimWindow";

            shapeEdAnimWindow.setVisible(false);

            ShapeEditorToolbar shapeEditorToolbar = "ShapeEditorToolbar";

            shapeEditorToolbar.setVisible(false);

            ShapeEdSelectWindow shapeEdSelectWindow = "ShapeEdSelectWindow";

            shapeEdSelectWindow.setVisible(false);
            ShapeEdPropWindow shapeEdPropWindow = "ShapeEdPropWindow";

            shapeEdPropWindow.setVisible(false);

            EditorGui EditorGui = "EditorGui";

            EditorGui.add("ShapeEdPreviewGui");
            EditorGui.add("ShapeEdAnimWindow");
            EditorGui.add("ShapeEdAdvancedWindow");

            EditorGui.add("ShapeEditorToolbar");
            EditorGui.add("ShapeEdSelectWindow");
            EditorGui.add("ShapeEdPropWindow");


            ObjectCreator oShapeEditorPlugin = new ObjectCreator("ScriptObject", "ShapeEditorPlugin",
                                                                 typeof(WinterLeaf.Demo.Full.Models.User.GameCode.Tools.ShapeEditor.gui.CodeBehind.ShapeEditorPlugin));

            oShapeEditorPlugin["editorGui"] = "ShapeEdShapeView";
            oShapeEditorPlugin.Create();

            ShapeEditorPlugin ShapeEditorPlugin = "ShapeEditorPlugin";

            ShapeEditorPlugin.initialize();
        }
        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 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();
            }
        }