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

            ShapeEditor.ShapeEdPreviewGui ShapeEdPreviewGui  = "ShapeEdPreviewGui";
            ShapeEditor.ShapeEdMaterials  ShapeEdMaterials   = "ShapeEdMaterials";
            ShapeEditorToolbar            ShapeEditorToolbar = "ShapeEditorToolbar";

            ShapeEditor.ShapeEdMountWindow ShapeEdMountWindow = "ShapeEdMountWindow";
            ShapeEditor.ShapeEdShapeView   ShapeEdShapeView   = "ShapeEdShapeView";

            GuiSwatchButtonCtrl previewBackground = ShapeEdPreviewGui.FOT("previewBackground");
            GuiCheckBoxCtrl     highlightMaterial = ShapeEdMaterials.FOT("highlightMaterial");
            GuiBitmapButtonCtrl showNodes         = ShapeEditorToolbar.FOT("showNodes");
            GuiBitmapButtonCtrl showBounds        = ShapeEditorToolbar.FOT("showBounds");
            GuiBitmapButtonCtrl showObjBox        = ShapeEditorToolbar.FOT("showObjBox");
            GuiBitmapButtonCtrl showAdvanced      = ShapeEditorToolbar.FOT("showAdvanced");
            GuiBitmapButtonCtrl showGridBtn       = ShapeEditorToolbar.FOT("showGridBtn");
            GuiBitmapButtonCtrl renderColMeshes   = ShapeEditorToolbar.FOT("renderColMeshes");
            GuiCheckBoxCtrl     renderMounts      = ShapeEdMountWindow.FOT("renderMounts");

            EditorSettings.beginGroup("ShapeEditor", true);

            // Display options
            EditorSettings.setValue("BackgroundColor", ColorPickerDlg.ColorFloatToInt(previewBackground["color"]));
            EditorSettings.setValue("HighlightMaterial", highlightMaterial.getValue());
            EditorSettings.setValue("ShowNodes", showNodes.getValue());
            EditorSettings.setValue("ShowBounds", showBounds.getValue());
            EditorSettings.setValue("ShowObjBox", showObjBox.getValue());
            EditorSettings.setValue("RenderCollision", renderColMeshes.getValue());
            EditorSettings.setValue("RenderMounts", renderMounts.getValue());

            // Grid
            EditorSettings.setValue("ShowGrid", showGridBtn.getValue());
            EditorSettings.setValue("GridSize", ShapeEdShapeView["gridSize"]);
            EditorSettings.setValue("GridDimension", ShapeEdShapeView["gridDimension"]);

            // Sun
            EditorSettings.setValue("SunDiffuseColor", ShapeEdShapeView["sunDiffuse"]);
            EditorSettings.setValue("SunAmbientColor", ShapeEdShapeView["sunAmbient"]);
            EditorSettings.setValue("SunAngleX", ShapeEdShapeView["sunAngleX"]);
            EditorSettings.setValue("SunAngleZ", ShapeEdShapeView["sunAngleZ"]);

            // Sub-windows
            EditorSettings.setValue("AdvancedWndVisible", showAdvanced.getValue());

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

            ShapeEditor.ShapeEdPreviewGui ShapeEdPreviewGui  = "ShapeEdPreviewGui";
            ShapeEditor.ShapeEdMaterials  ShapeEdMaterials   = "ShapeEdMaterials";
            ShapeEditorToolbar            ShapeEditorToolbar = "ShapeEditorToolbar";

            ShapeEditor.ShapeEdMountWindow ShapeEdMountWindow = "ShapeEdMountWindow";
            ShapeEditor.ShapeEdShapeView   ShapeEdShapeView   = "ShapeEdShapeView";

            GuiSwatchButtonCtrl previewBackground = ShapeEdPreviewGui.FOT("previewBackground");
            GuiCheckBoxCtrl     highlightMaterial = ShapeEdMaterials.FOT("highlightMaterial");
            GuiBitmapButtonCtrl showNodes         = ShapeEditorToolbar.FOT("showNodes");
            GuiBitmapButtonCtrl showBounds        = ShapeEditorToolbar.FOT("showBounds");
            GuiBitmapButtonCtrl showObjBox        = ShapeEditorToolbar.FOT("showObjBox");
            GuiBitmapButtonCtrl showAdvanced      = ShapeEditorToolbar.FOT("showAdvanced");
            GuiBitmapButtonCtrl showGridBtn       = ShapeEditorToolbar.FOT("showGridBtn");
            GuiBitmapButtonCtrl renderColMeshes   = ShapeEditorToolbar.FOT("renderColMeshes");
            GuiCheckBoxCtrl     renderMounts      = ShapeEdMountWindow.FOT("renderMounts");

            EditorSettings.beginGroup("ShapeEditor", true);

            // Display options
            previewBackground["color"] = ColorPickerDlg.ColorIntToFloat(EditorSettings.value("BackgroundColor"));
            SetToggleButtonValue(highlightMaterial, EditorSettings.value("HighlightMaterial"));
            SetToggleButtonValue(showNodes, EditorSettings.value("ShowNodes"));
            SetToggleButtonValue(showBounds, EditorSettings.value("ShowBounds"));
            SetToggleButtonValue(showObjBox, EditorSettings.value("ShowObjBox"));
            SetToggleButtonValue(renderColMeshes, EditorSettings.value("RenderCollision"));
            SetToggleButtonValue(renderMounts, EditorSettings.value("RenderMounts"));

            // Grid
            SetToggleButtonValue(showGridBtn, EditorSettings.value("ShowGrid"));
            ShapeEdShapeView["gridSize"]      = EditorSettings.value("GridSize");
            ShapeEdShapeView["gridDimension"] = EditorSettings.value("GridDimension");

            // Sun
            ShapeEdShapeView["sunDiffuse"] = EditorSettings.value("SunDiffuseColor");
            ShapeEdShapeView["sunAmbient"] = EditorSettings.value("SunAmbientColor");

            // Sub-windows
            SetToggleButtonValue(showAdvanced, EditorSettings.value("AdvancedWndVisible"));

            EditorSettings.endGroup();
        }
Пример #3
0
        public void openShape(string path, bool discardChangesToCurrent)
        {
            EditorGui   EditorGui   = "EditorGui";
            ShapeEditor ShapeEditor = "ShapeEditor";

            ShapeEditor.ShapeEdShapeView ShapeEdShapeView = "ShapeEdShapeView";

            EditorGui.setEditor(this, false);

            if (ShapeEditor.isDirty() && !discardChangesToCurrent)
            {
                messageBox.MessageBoxYesNo("Save Changes?", "Save changes to current shape?", "ShapeEditor.saveChanges(); ShapeEditorPlugin.openShape(\"" + path + "\");", "ShapeEditorPlugin.openShape(\"" + path + "\");");
                return;
            }

            ShapeEditor.selectShape(path, !discardChangesToCurrent);
            ShapeEdShapeView.fitToShape();
        }
        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 override void onExitMission()
        {
            ShapeEditor.ShapeEdShapeView ShapeEdShapeView = "ShapeEdShapeView";
            ShapeEditor ShapeEditor = "ShapeEditor";

            ShapeEditorActions.ShapeEdUndoManager ShapeEdUndoManager  = "ShapeEdUndoManager";
            ShapeEditor.ShapeEdSequenceList       ShapeEdSequenceList = "ShapeEdSequenceList";
            ShapeEditor.ShapeEdNodeTreeView       ShapeEdNodeTreeView = "ShapeEdNodeTreeView";
            ShapeEdPropWindow ShapeEdPropWindow = "ShapeEdPropWindow";

            ShapeEditor.ShapeEdDetailTree ShapeEdDetailTree = "ShapeEdDetailTree";
            GuiTextListCtrl ShapeEdMaterialList             = "ShapeEdMaterialList";

            ShapeEditor.ShapeEdMountWindow  ShapeEdMountWindow  = "ShapeEdMountWindow";
            ShapeEditor.ShapeEdThreadWindow ShapeEdThreadWindow = "ShapeEdThreadWindow";
            ShapeEditor.ShapeEdThreadList   ShapeEdThreadList   = "ShapeEdThreadList";

            GuiTextListCtrl mountList = ShapeEdMountWindow.FOT("mountList");
            GuiTextListCtrl seqList   = ShapeEdThreadWindow.FOT("seqList");

            // unselect the current shape
            ShapeEdShapeView.setModel("");
            if (ShapeEditor.shape != 0)
            {
                ShapeEditor.shape.delete();
            }
            ShapeEditor.shape = 0;
            ShapeEdUndoManager.clearAll();
            ShapeEditor.setDirty(false);

            ShapeEdSequenceList.clear();
            ShapeEdNodeTreeView.removeItem(0);
            ShapeEdPropWindow.update_onNodeSelectionChanged(-1);
            ShapeEdDetailTree.removeItem(0);
            ShapeEdMaterialList.clear();

            mountList.clear();
            seqList.clear();
            ShapeEdThreadList.clear();
        }
        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();
            }
        }