示例#1
0
        public override void onWorldEditorStartup()
        {
            ForestEditorGui.ForestEditBrushTree ForestEditBrushTree = "ForestEditBrushTree";
            SimSet ForestItemDataSet = "ForestItemDataSet";

            ForestEditorGui.ForestEditMeshTree ForestEditMeshTree = "ForestEditMeshTree";
            EditorGui EditorGui = "EditorGui";

            ForestEditorGui.ForestEditTabBook            ForestEditTabBook            = "ForestEditTabBook";
            ForestEditorGui.ForestEditorPropertiesWindow ForestEditorPropertiesWindow = "ForestEditorPropertiesWindow";
            ForestEditorGui.ForestEditorPalleteWindow    ForestEditorPalleteWindow    = "ForestEditorPalleteWindow";

            new ObjectCreator("PersistenceManager", "ForestDataManager").Create();

            const string brushPath = "art/forest/brushes.cs";

            if (!Util.isFile(brushPath))
            {
                Util.createPath(brushPath);
            }

            // This creates the ForestBrushGroup, all brushes, and elements.
            Util.exec(brushPath, false, false);

            SimGroup ForestBrushGroup = "ForestBrushGroup";

            if (!ForestBrushGroup.isObject())
            {
                ForestBrushGroup  = new ObjectCreator("SimGroup", "ForestBrushGroup").Create();
                this["showError"] = true.AsString();
            }

            ForestEditBrushTree.open(ForestBrushGroup);

            if (!ForestItemDataSet.isObject())
            {
                ForestItemDataSet = new ObjectCreator("SimSet", "ForestItemDataSet").Create();
            }

            ForestEditMeshTree.open(ForestItemDataSet);

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

            // Add ourselves to the tools menu.
            string tooltip = "Forest Editor (" + accel + ")";

            EditorGui.addToToolsToolbar("ForestEditorPlugin", "ForestEditorPalette",
                                        Util._expandFilename("tools/forestEditor/images/forest-editor-btn"), tooltip);

            //connect editor windows
            ForestEditorPalleteWindow.attachTo(ForestEditorPropertiesWindow);
            ForestEditTabBook.selectPage(0);
        }
示例#2
0
        public override void onActivated()
        {
            EditorGui       EditorGui       = "EditorGui";
            ForestEditorGui ForestEditorGui = "ForestEditorGui";

            ForestEditorGui.ForestEditorPropertiesWindow ForestEditorPropertiesWindow = "ForestEditorPropertiesWindow";
            ForestEditorGui.ForestEditorPalleteWindow    ForestEditorPalleteWindow    = "ForestEditorPalleteWindow";
            ForestEditorGui.ForestEditMeshTree           ForestEditMeshTree           = "ForestEditMeshTree";
            ForestEditorGui.ForestEditBrushTree          ForestEditBrushTree          = "ForestEditBrushTree";
            ForestEditorGui.ForestEditTabBook            ForestEditTabBook            = "ForestEditTabBook";
            SimGroup     ForestBrushGroup   = "ForestBrushGroup";
            SimSet       ForestItemDataSet  = "ForestItemDataSet";
            SimSet       ForestTools        = "ForestTools";
            GizmoProfile GlobalGizmoProfile = "GlobalGizmoProfile";

            GuiBitmapButtonCtrl ForestEditorPaintModeBtn         = "ForestEditorPaintModeBtn";
            GuiBitmapButtonCtrl ForestEditorSelectModeBtn        = "ForestEditorSelectModeBtn";
            GuiBitmapButtonCtrl ForestEditorMoveModeBtn          = "ForestEditorMoveModeBtn";
            GuiBitmapButtonCtrl ForestEditorRotateModeBtn        = "ForestEditorRotateModeBtn";
            GuiBitmapButtonCtrl ForestEditorScaleModeBtn         = "ForestEditorScaleModeBtn";
            GuiBitmapButtonCtrl ForestEditorEraseModeBtn         = "ForestEditorEraseModeBtn";
            GuiBitmapButtonCtrl ForestEditorEraseSelectedModeBtn = "ForestEditorEraseSelectedModeBtn";
            GuiBitmapButtonCtrl ForestEditorDropToGroundModeBtn  = "ForestEditorDropToGroundModeBtn";

            ForestSelectionTool SelectionTool = ForestTools.FOF("SelectionTool");
            ForestBrushTool     BrushTool     = ForestTools.FOF("BrushTool");

            string mode;

            //Copyright Winterleaf Entertainment L.L.C. 2013
            this["isActive"] = true.AsString();
            //Copyright Winterleaf Entertainment L.L.C. 2013
            EditorGui.bringToFront(ForestEditorGui);
            ForestEditorGui.setVisible(true);
            ForestEditorPalleteWindow.setVisible(true);
            ForestEditorPropertiesWindow.setVisible(true);
            ForestEditorGui.makeFirstResponder(true);
            //ForestEditToolbar.setVisible( true );

            this.map.push();
            base.onActivated();

            ForestEditBrushTree.open(ForestBrushGroup);
            ForestEditMeshTree.open(ForestItemDataSet);

            // Open the Brush tab.
            ForestEditTabBook.selectPage(0);

            // Sync the pallete button state

            // And toolbar.
            SimObject tool = ForestEditorGui.getActiveTool();

            if (tool.isObject())
            {
                tool.call("onActivated");
            }

            if (!tool.isObject())
            {
                ForestEditorPaintModeBtn.performClick();

                if (ForestEditBrushTree.getItemCount() > 0)
                {
                    ForestEditBrushTree.selectItem(0, true);
                }
            }
            else if (tool == SelectionTool)
            {
                mode = GlobalGizmoProfile["mode"];
                switch (mode)
                {
                case "None":
                    ForestEditorSelectModeBtn.performClick();
                    break;

                case "Move":
                    ForestEditorMoveModeBtn.performClick();
                    break;

                case "Rotate":
                    ForestEditorRotateModeBtn.performClick();
                    break;

                case "Scale":
                    ForestEditorScaleModeBtn.performClick();
                    break;
                }
            }
            else if (tool == BrushTool)
            {
                mode = BrushTool["mode"];
                switch (mode)
                {
                case "Paint":
                    ForestEditorPaintModeBtn.performClick();
                    break;

                case "Erase":
                    ForestEditorEraseModeBtn.performClick();
                    break;

                case "EraseSelected":
                    ForestEditorEraseSelectedModeBtn.performClick();
                    break;

                case "DropToGround":
                    ForestEditorDropToGroundModeBtn.performClick();
                    break;
                }
            }

            if (this["showError"].AsBool())
            {
                messageBox.MessageBoxOK("Error",
                                        "Your art/forest folder does not contain a valid brushes.cs. Brushes you create will not be saved!");
            }
        }