示例#1
0
        public void Perform2DViewAction(CSharpFramework.Controls.Scene2DView view, GroupAction parent, string action)
        {
            if (action == RO_CREATEZONEGRID)
            {
                ZoneGridProperties properties = new ZoneGridProperties();
                properties.Area = view.SelectionMarqueeWorldBox;

                using (PropertyGridDlg dlg = new PropertyGridDlg("Create a grid of zones", "Procedurally generate a grid of m times n streaming zones"))
                {
                    dlg.DataObjectNoClone = properties;
                    if (dlg.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    CreateZoneGridAction createaction = new CreateZoneGridAction(properties);
                    EditorManager.Actions.Add(createaction);
                }
            }
        }
        private void treeView_Creators_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            PrefabDesc prefab = SelectedCreatorObject as PrefabDesc;

            if (prefab != null)
            {
                using (PropertyGridDlg dlg = new PropertyGridDlg("Change prefab properties", "Change the properties of this prefab and click OK to apply and save the new settings"))
                {
                    dlg.DataObject = prefab;
                    if (dlg.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    // get back results
                    prefab = (PrefabDesc)dlg.DataObject;
                    if (!prefab.PropertiesChanged) // seems untouched by property grid
                    {
                        return;
                    }

                    // fire the static event
                    prefab.TriggerPropertiesChangedEvent();
                    if (!prefab.SaveToFile(null))
                    {
                        EditorManager.ShowMessageBox("Changes could not be applied because the prefab shape could not be saved.\n\nDetailed message:" + prefab.LastError, "Failed to save prefab", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }


                    //_selectedCreatorNode.CreatorObject = prefab;
                    // brute force rebuild tree:
                    ProjectUpdate();
                }
            }
        }
 bool OpenExportSettingsDialog()
 {
     using (PropertyGridDlg dlg = new PropertyGridDlg("Mesh Export Settings", "This property grid shows properties relevant for the terrain mesh export."))
       {
     dlg.DataObject = TerrainEditor.CurrentTerrain.MeshExportSettings; // clones it
     if (dlg.ShowDialog() != DialogResult.OK)
       return false;
     TerrainEditor.CurrentTerrain.MeshExportSettings = (TerrainMeshExport)dlg.DataObject;
     return true;
       }
 }
        private void listView_VegetationModels_DoubleClick(object sender, EventArgs e)
        {
            if (TerrainEditor.CurrentDecorationModel == null)
            return;

              if (TerrainEditor.CurrentTerrain == null || TerrainEditor.CurrentTerrain.IsReference || !TerrainEditor.CurrentTerrain.Modifiable)
            return;

              using(PropertyGridDlg dlg = new PropertyGridDlg("Edit properties of '" + TerrainEditor.CurrentDecorationModel.Name + "'",
            "Edit all properties of this vegetation model at once so update of the terrain only happens when changes are confirmed"))
              {
            DecorationModelResource other = new DecorationModelResource(null, 0);
            other.CopyPropertiesFrom(TerrainEditor.CurrentDecorationModel, false);
            dlg.DataObjectNoClone = other.ViewObject;
            if (dlg.ShowDialog(this) != DialogResult.OK)
              return;

            TerrainEditor.CurrentDecorationModel.CopyPropertiesFrom(other, true);
              }
        }
        private void toolStripButton_SlopeTextures_Click(object sender, EventArgs e)
        {
            g_SlopeTexturesFilter.OwnerTerrain = TerrainEditor.CurrentTerrain;
              using (PropertyGridDlg dlg = new PropertyGridDlg("Generate weightings from slope", "Choose a bitmap that is used as a gradient lookup to map onto the chosen textures"))
              {
            dlg.DataObjectNoClone = g_SlopeTexturesFilter;
            if (dlg.ShowDialog() != DialogResult.OK)
              return;
            if (string.IsNullOrEmpty(g_SlopeTexturesFilter.SlopeLookup))
            {
              EditorManager.ShowMessageBox("A valid texture must be specified for the slope lookup", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
              return;
            }

            string filename = EditorManager.Project.MakeAbsolute(g_SlopeTexturesFilter.SlopeLookup);
            if (!File.Exists(filename))
            {
              EditorManager.ShowMessageBox("The specified bitmap does not exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
              return;
            }
            if (!PromptClearUndo("Generate Detail Textures"))
              return;

            EditorManager.Progress.ShowProgressDialog("Generate weightings from slope");
            TerrainEditor.CurrentTerrain.EngineTerrain.DetailTexturesFromSlope(
              filename,
              g_SlopeTexturesFilter.DestinationRed,
              g_SlopeTexturesFilter.DestinationGreen,
              g_SlopeTexturesFilter.DestinationBlue,
              g_SlopeTexturesFilter.DestinationAlpha,
              g_SlopeTexturesFilter.NormalNoise,
              EditorManager.Progress);
            TerrainEditor.CurrentTerrain.Modified = true;
            EditorManager.Progress.HideProgressDialog();
              }
        }
        private void toolStripButton_ImportWeightmap_Click(object sender, EventArgs e)
        {
            g_ImportWeightmap.OwnerTerrain = TerrainEditor.CurrentTerrain;
              using (PropertyGridDlg dlg = new PropertyGridDlg("Import Weightmap", "Choose an existing weightmap texture file and select the target channels to map"))
              {
            dlg.DataObjectNoClone = g_ImportWeightmap;
            if (dlg.ShowDialog() != DialogResult.OK)
              return;

            if (string.IsNullOrEmpty(g_ImportWeightmap.WeightmapFilename))
            {
              EditorManager.ShowMessageBox("A valid weightmap file must be specified", "Import Weightmap", MessageBoxButtons.OK, MessageBoxIcon.Information);
              return;
            }

            if (!PromptClearUndo("Import Weightmap"))
              return;

            string filename = EditorManager.Project.MakeAbsolute(g_ImportWeightmap.WeightmapFilename);
            EditorManager.Progress.ShowProgressDialog("Import weightmap");
            TerrainEditor.CurrentTerrain.EngineTerrain.ImportWeightmap(
              filename,
              g_ImportWeightmap.DestinationRed,
              g_ImportWeightmap.DestinationGreen,
              g_ImportWeightmap.DestinationBlue,
              g_ImportWeightmap.DestinationAlpha,
              EditorManager.Progress);
            TerrainEditor.CurrentTerrain.Modified = true;
            EditorManager.Progress.HideProgressDialog();
              }
        }
示例#7
0
 private void Menu_File_SceneSettings_Click(object sender, System.EventArgs e)
 {
     using (PropertyGridDlg dlg = new PropertyGridDlg("Scene Settings", "Setup scene specific preferences that get saved along with the scene"))
       {
     dlg.DataObject = EditorApp.Scene.Settings; // clones it
     if (dlg.ShowDialog()!=DialogResult.OK)
       return;
     // change the settings via an action:
     EditorManager.Actions.Add(new SceneSettingsChangedAction(EditorApp.Scene.Settings,(EditorSceneSettings)dlg.DataObject));
       }
 }
示例#8
0
        private void menu_CreateZoneGrid_Click(object sender, EventArgs e)
        {
            if (EditorManager.Scene == null)
            return;

              ZoneGridProperties properties = new ZoneGridProperties();
              properties.Area = EditorManager.Scene.SceneExtents;

              using (PropertyGridDlg dlg = new PropertyGridDlg("Create a grid of zones", "Procedurally generate a grid of m times n streaming zones"))
              {
            dlg.DataObjectNoClone = properties;
            if (dlg.ShowDialog() != DialogResult.OK)
              return;

            CreateZoneGridAction action = new CreateZoneGridAction(properties);
            EditorManager.Actions.Add(action);
              }
        }
        private void createPrefabToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShapeCollection shapes = shapeTreeView.SelectedShapes;
              PrefabDesc prefab = new PrefabDesc(null);

              // try to use/create the prefabs directory of the project
              string proj = EditorManager.Project.ProjectDir;
              string prefabDir = Path.Combine(proj, EditorManager.Settings.PrefabDirectory);
              if (!Directory.Exists(prefabDir))
              {
            try
            {
              Directory.CreateDirectory(prefabDir);
            }
            catch (Exception ex)
            {
              EditorManager.DumpException(ex);
              prefabDir = proj; // OK, fallback to project directory
            }
              }

              // first select the prefab file to save
              CreateFileDlg fileDlg = new CreateFileDlg();
              fileDlg.Caption = "Save a prefab";
              fileDlg.Description = "Enter the name of the prefab file and select the directory to save it in. Then click OK to proceed.";
              fileDlg.InitialDirectory = prefabDir;
              fileDlg.Ext = ".prefab";
              fileDlg.Filter = new string[] { ".prefab" };
              fileDlg.AllowOverwrite = true;

              if (fileDlg.ShowDialog() != DialogResult.OK)
            return;

              prefab.Filename = fileDlg.FileName;

              // if the file exists, load it to get the properties
              if (File.Exists(prefab.Filename))
              {
            prefab.Load();
              }

              // set this before the dialog opens
              prefab.SourceShapesForExposedParameters = shapes;

              // edit the prefab properties
              using (PropertyGridDlg propDlg = new PropertyGridDlg("Edit prefab properties", "Edit additional prefab properties. Click OK to proceed with saving the prefab file."))
              {
            propDlg.DataObjectNoClone = prefab;
            if (propDlg.ShowDialog() != DialogResult.OK)
              return;

            // fill with the shapes
            if (!prefab.CreateFromInstances(shapes, shapes.Center, true, true))
            {
              EditorManager.ShowMessageBox("Failed to create prefab. Detailed message:\n\n" + prefab.LastError, "Creation Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
              return;
            }

            if (!prefab.SaveToFile(fileDlg.FileName))
            {
              EditorManager.ShowMessageBox("Failed to save prefab. Detailed message:\n\n" + prefab.LastError, "Saving Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
              return;
            }
              }
        }
        public void Perform2DViewAction(CSharpFramework.Controls.Scene2DView view, GroupAction parent, string action)
        {
            if (action == RO_CREATEZONEGRID)
              {
            ZoneGridProperties properties = new ZoneGridProperties();
            properties.Area = view.SelectionMarqueeWorldBox;

            using (PropertyGridDlg dlg = new PropertyGridDlg("Create a grid of zones", "Procedurally generate a grid of m times n streaming zones"))
            {
              dlg.DataObjectNoClone = properties;
              if (dlg.ShowDialog() != DialogResult.OK)
            return;
              CreateZoneGridAction createaction = new CreateZoneGridAction(properties);
              EditorManager.Actions.Add(createaction);
            }
              }
        }