public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            TerrainConfigDlg dlg = new TerrainConfigDlg();
              dlg.FullConfig = false; // allow editing a subset only

              TerrainConfig origConfig = (TerrainConfig)value;

              dlg.Config = origConfig;
            if (dlg.ShowDialog() != DialogResult.OK)
                return value;
            return dlg.Config;
        }
Example #2
0
        private void button_Create_Click(object sender, EventArgs e)
        {
            if (CreationMethod == CreationMethod_e.ExistingTerrain)
            {
                OpenFileDlg dlg = new OpenFileDlg();
                dlg.Caption          = "Select existing terrain file";
                dlg.Description      = "Select an existing terrain file that should be referenced by this scene";
                dlg.InitialDirectory = EditorManager.Project.ProjectDir;
                dlg.Filter           = new string[] { ".vtc" };
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    TerrainShape.TerrainConfig.TerrainFolder = System.IO.Path.GetDirectoryName(dlg.RelativeFileName);
                    TerrainShape._bIsReference = true;
                    TerrainShape._bBakeMode    = true;
                    this.DialogResult          = DialogResult.OK;
                }
            }
            else if (CreationMethod == CreationMethod_e.NewTerrain)
            {
                TerrainConfigDlg dlg = new TerrainConfigDlg();
                dlg.Config = TerrainShape.TerrainConfig;
                dlg.Config._terrainFolder = TerrainConfig.CreateUniqueFolderName();
                dlg.NewTerrain            = true;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                string abspath = System.IO.Path.Combine(EditorManager.Project.ProjectDir, dlg.Config.TerrainFolder);
                if (Directory.Exists(abspath))
                {
                    if (EditorManager.ShowMessageBox("The specified directory '" + dlg.Config.TerrainFolder + "' already exists.\n\nAny existing terrain inside this folder would be overwritten.\nContinue anyway?",
                                                     "Create terrain", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                    {
                        return;
                    }
                }
                TerrainShape.TerrainConfig = dlg.Config;
                this.DialogResult          = DialogResult.OK;
            }
        }
        private void button_ChangeConfig_Click(object sender, EventArgs e)
        {
            if (TerrainEditor.CurrentTerrain == null)
            return;

              TerrainConfigDlg dlg = new TerrainConfigDlg();
              dlg.FullConfig = false; // allow editing a subset only
              dlg.Config = TerrainEditor.CurrentTerrain.Config;
              if (dlg.ShowDialog() != DialogResult.OK)
            return;

              // outputs additional warning
              TerrainEditor.CurrentTerrain.Config = dlg.Config;
        }
        private void button_Create_Click(object sender, EventArgs e)
        {
            if (CreationMethod == CreationMethod_e.ExistingTerrain)
              {
            OpenFileDlg dlg = new OpenFileDlg();
            dlg.Caption = "Select existing terrain file";
            dlg.Description = "Select an existing terrain file that should be referenced by this scene";
            dlg.InitialDirectory = EditorManager.Project.ProjectDir;
            dlg.Filter = new string[] { ".vtc" };
            if (dlg.ShowDialog() == DialogResult.OK)
            {
              TerrainShape.TerrainConfig.TerrainFolder = System.IO.Path.GetDirectoryName(dlg.RelativeFileName);
              TerrainShape._bIsReference = true;
              TerrainShape._bBakeMode = true;
              this.DialogResult = DialogResult.OK;
            }
              }
              else if (CreationMethod == CreationMethod_e.NewTerrain)
              {
            TerrainConfigDlg dlg = new TerrainConfigDlg();
            dlg.Config = TerrainShape.TerrainConfig;
            dlg.Config._terrainFolder = TerrainConfig.CreateUniqueFolderName();
            dlg.NewTerrain = true;
            if (dlg.ShowDialog() != DialogResult.OK)
              return;

            string abspath = System.IO.Path.Combine(EditorManager.Project.ProjectDir, dlg.Config.TerrainFolder);
            if (Directory.Exists(abspath))
            {
              if (EditorManager.ShowMessageBox("The specified directory '" + dlg.Config.TerrainFolder + "' already exists.\n\nAny existing terrain inside this folder would be overwritten.\nContinue anyway?",
            "Create terrain", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            return;
            }
            TerrainShape.TerrainConfig = dlg.Config;
            this.DialogResult = DialogResult.OK;
              }
        }