Ejemplo n.º 1
0
    private void button_CreateProfile_Click(object sender, EventArgs e)
    {
      if (!PromptProfileModified())
        return;

      CreateFileDlg dlg = new CreateFileDlg();
      dlg.InitialDirectory = EditorManager.Scene.LayerDirectoryName;
      dlg.Caption = "Creating a new Export Profile";
      dlg.Description = "Enter the name of the new profile file.";
      dlg.Ext = "." + SceneExportProfile.FILE_EXTENSION_EXPORTPROFILE;
      dlg.Filter = new string[] { dlg.Ext.ToLower() };
      dlg.AllowOverwrite = false;
      dlg.SupportCustomDirectories = false;
      dlg.AllowFolderCreation = false;

      if (dlg.ShowDialog(this) != DialogResult.OK)
        return;
      SceneExportProfile settings = Settings;
      string oldName = settings.ProfileName;
      settings.ProfileName = Path.GetFileNameWithoutExtension(dlg.FileName);
      if (!SaveProfile(settings))
      {
        settings.ProfileName = oldName;
        return;
      }
      Settings = settings; // create unmodified copy
    }
        private void createNewBillboardAtlasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CreateFileDlg fileDlg = new CreateFileDlg();
              fileDlg.Caption = "Create a new Billboard Atlas file";
              fileDlg.Description = "Enter the name of the new atlas file and select the directory to create it in. Then press OK to continue.";
              fileDlg.InitialDirectory = EditorManager.Project.ProjectDir;
              fileDlg.Ext = ".atlas";
              fileDlg.AllowOverwrite = false;
              fileDlg.Filter = new string[] { ".atlas" };
              if (fileDlg.ShowDialog() != DialogResult.OK)
            return;

              TextureAtlas atlas = new TextureAtlas();
              atlas.Filename = EditorManager.Project.MakeRelative(fileDlg.FileName);
              TextureAtlasEditorDlg dlg = new TextureAtlasEditorDlg(true);
              dlg.Atlas = atlas;

              if (dlg.ShowDialog(this) != DialogResult.OK)
            return;
              dlg.Atlas.SaveToFile(null);
        }
Ejemplo n.º 3
0
        public override void PerformRelevantOperation(string name, int iShapeIndex, int iShapeCount)
        {
            if (name == RO_MOVEFOLDER)
              {
            CreateFileDlg FileDialog = new CreateFileDlg();
            FileDialog.Caption = "Relocate Terrain Folder";
            FileDialog.Description = "Choose a directory into which the terrain data should be relocated.";
            FileDialog.Filter = new string[] { "" };
            FileDialog.InitialDirectory = EditorManager.Project.ProjectDir;
            FileDialog.Text = "vForge";
            FileDialog.Ext = "";
            FileDialog.SelectFolder = true;

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

            String sResult = EditorManager.Project.MakeRelative(FileDialog.FileName);

            if (string.IsNullOrEmpty(sResult) || (sResult == Config.TerrainFolder))
              return;

            MoveTerrainFolder(sResult, true);
            return;
              }
              if (name == RO_MOVEFOLDER_SCENE)
              {
            MoveTerrainFolder(GetSuggestedFolderName() , true );
              }

              base.PerformRelevantOperation(name, iShapeIndex, iShapeCount);
        }
        private void button_ExportFilenameBrowse_Click(object sender, EventArgs e)
        {
            if (TerrainEditor.CurrentTerrain == null || TerrainEditor.CurrentTerrain.EngineTerrain == null)
            return;

              CreateFileDlg fileDlg = new CreateFileDlg();
              fileDlg.Caption = "Select Texture file";
              fileDlg.Description = "Select a DDS target file to export the terrain height map data. The format of the dds texture is R32F.";
              fileDlg.InitialDirectory = EditorManager.Project.ProjectDir;
              fileDlg.Ext = ".dds";
              fileDlg.Filter = new string[] { ".dds" };
              fileDlg.AllowOverwrite = true;
              //Just use the filename and do not use any path for the fileDlg.FileName, since the CreateFileDlg always combines the path with the filename.
              //If the FileName has path information these get also combined with the chosen path, which leads to unwanted results [#2851]
              fileDlg.FileName = Path.GetFileName(TerrainEditor.CurrentTerrain.HeightmapExportFilename);
              fileDlg.SelectedStartSubDirectory = Path.GetDirectoryName(TerrainEditor.CurrentTerrain.HeightmapExportFilename);
              if (fileDlg.ShowDialog() != DialogResult.OK)
            return;

              TerrainEditor.CurrentTerrain.HeightmapExportFilename = EditorManager.Project.MakeRelative(fileDlg.FileName);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create a new scene
        /// </summary>		
        public void NewScene()
        {
            System.Diagnostics.Debug.Assert(EditorManager.Project!=null);
              //Show our own file create dialog
              CreateFileDlg fileDlg = new CreateFileDlg();
              fileDlg.Caption = "Creating a new Scene";
              fileDlg.Description = "Enter the name of the new scene file and select the directory to create it in. Then press OK to continue.";
              fileDlg.InitialDirectory = EditorManager.Project.ProjectDir;
              fileDlg.Ext = ".scene";
              fileDlg.Filter = new string[] {".scene"};
              if (fileDlg.ShowDialog() != DialogResult.OK)
            return;

              //Make sure the current scene is saved
              if (EditorApp.PromptSaveScene() == DialogResult.Cancel) return;

              // close any currently loaded scene
              if (EditorManager.Project != null && EditorManager.Project.Scene != null)
            EditorManager.Project.Scene.Close();

              //Create a new scene
              if (!EditorManager.Project.NewScene( EditorManager.Project.MakeRelative(fileDlg.FileName) ))
            return;

              // Open Scene Wizard dialog if enabled
              if (EditorManager.Settings.ShowSceneWizardOnSceneCreation)
              {
            SceneWizardDlg dlg = new SceneWizardDlg();
            dlg.Scene = (EditorScene) EditorManager.Project.Scene;
            dlg.ShowDialog();
              }

              // show warning dialog if mixed debug/release assemblies are loaded
              AssemblyHelper.CheckAssemblyConsistency();

              mruList_RecentScenes.Add(fileDlg.FileName);
        }
Ejemplo n.º 6
0
        //File->Save Scene As
        private void Menu_File_SaveSceneAs_Click(object sender, System.EventArgs e)
        {
            if (EditorManager.Scene==null)
            return;

              //Show our own file open dialog
              CreateFileDlg fileDlg = new CreateFileDlg();
              fileDlg.Caption = "Saving the Scene";
              fileDlg.Description = "Enter the name of the scene and select the directory to save it in. Then press OK to continue.";
              fileDlg.InitialDirectory = EditorManager.Project.ProjectDir;
              fileDlg.Ext = ".scene";
              fileDlg.Filter = new string[] {".scene"};
              if (fileDlg.ShowDialog() != DialogResult.OK)
            return;

              string relFilename = EditorManager.Project.MakeRelative(fileDlg.FileName);
              if (!EditorManager.Scene.SaveAs(relFilename))
            return;

              mruList_RecentScenes.Add(fileDlg.FileName);

              UpdateToolbars();

              // also update titlebar
              EditorApp.UpdateTitleBar();
        }
Ejemplo n.º 7
0
        private void button_CreateProfile_Click(object sender, EventArgs e)
        {
            if (!PromptProfileModified())
            return;

              CreateFileDlg dlg = new CreateFileDlg();
              dlg.InitialDirectory = EditorManager.Scene.LayerDirectoryName;
              dlg.Caption = "Creating a new Export Preset";
              dlg.Description = "Enter the name of the new preset file.";
              dlg.Ext = "." + SceneExportProfile.FILE_EXTENSION_EXPORTPROFILE;
              dlg.Filter = new string[] { dlg.Ext.ToLower() };
              dlg.AllowOverwrite = false;
              dlg.SupportCustomDirectories = false;
              dlg.AllowFolderCreation = false;

              if (dlg.ShowDialog(this) != DialogResult.OK)
            return;
              SceneExportProfile settings = Settings;
              string oldName = settings.ProfileName;
              settings.ProfileName = Path.GetFileNameWithoutExtension(dlg.FileName);
              if (!SaveProfile(settings))
              {
            settings.ProfileName = oldName;
            return;
              }
              Settings = settings; // create unmodified copy
        }
Ejemplo n.º 8
0
        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;
            }
              }
        }
Ejemplo n.º 9
0
        public override void PerformRelevantOperation(string name, int iShapeIndex, int iShapeCount)
        {
            base.PerformRelevantOperation(name, iShapeIndex, iShapeCount);
            if (name == "Load XML")
            {
                OpenFileDlg dlg = new OpenFileDlg();
                dlg.Caption          = "Opening a model group file";
                dlg.Description      = "Please select a model group file and click OK to continue";
                dlg.Text             = "Opening an model group file";
                dlg.InitialDirectory = EditorManager.Project.ProjectDir;
                dlg.FileName         = _filename;
                dlg.Filter           = new string[] { ".xml" };
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    _filename = EditorManager.Project.MakeRelative(dlg.FileName);

                    if (UIDialogInstance.BuildFromXML(_filename) == false)
                    {
                        EditorManager.ShowMessageBox("Wrong Dialog resource file.");
                        _filename = "";
                    }
                }

                UpdateLayout();
                //UpdateShape
            }
            else if (name == "Save XML")
            {
                CreateFileDlg dlg = new CreateFileDlg();
                dlg.Caption          = "Opening a GUI Dialog file";
                dlg.Description      = "Please select a GUI Dialog file and click OK to continue";
                dlg.Text             = "Opening a GUI Dialog file";
                dlg.InitialDirectory = EditorManager.Project.ProjectDir;
                dlg.FileName         = _filename;
                dlg.Filter           = new string[] { ".xml" };
                dlg.AllowOverwrite   = true;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    _filename = EditorManager.Project.MakeRelative(dlg.FileName);

                    if (UIDialogInstance.BuildToXML(dlg.FileName) == false)
                    {
                        EditorManager.ShowMessageBox("Write failed.");
                        _filename = "";
                    }
                }


                UpdateLayout();
            }
            else if (name == "Rebuild UI Shape tree from XML")
            {
                OpenFileDlg dlg = new OpenFileDlg();
                dlg.Caption          = "Opening a model group file";
                dlg.Description      = "Please select a model group file and click OK to continue";
                dlg.Text             = "Opening an model group file";
                dlg.InitialDirectory = EditorManager.Project.ProjectDir;
                dlg.FileName         = _filename;
                dlg.Filter           = new string[] { ".xml" };
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    _filename = EditorManager.Project.MakeRelative(dlg.FileName);

                    if (UIDialogInstance.BuildFromXML(_filename) == false)
                    {
                        EditorManager.ShowMessageBox("Wrong Dialog resource file.");
                        _filename = "";
                    }
                }

                ShapeCollection Collection = ChildCollection;
                foreach (ShapeBase shape in Collection)
                {
                    RemoveChild(shape);
                }


                int iItemCount = UIDialogInstance.GetChildUIInstanceCount();

                this.Bound = UIDialogInstance.GetBound();

                UpdateLayout();
            }
        }