public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (provider != null) { service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); } if (service != null) { // This is the code you want to run when the [...] is clicked and after it has been verified. OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = SceneManager.GameProject.ProjectPath; if (ofd.ShowDialog() == DialogResult.OK) { string path = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, ofd.FileName); if (File.Exists(SceneManager.GameProject.ProjectPath + "\\" + path)) { value = path; } } // Return the newly selected color. // value = } return(value); }
/// <summary> /// Loads a scene to memory from a file. /// The active scene is updated to this one if loaded with success. /// </summary> /// <param name="scenePath">The path of the scene to load</param> /// <returns>True if successfully loaded</returns> public static bool LoadScene(string scenePath, bool saveHistory) { try { #if WINDOWS GameScene gameScene = (GameScene)GibboHelper.DeserializeObject(scenePath); #elif WINRT GameScene gameScene = (GameScene)GibboHelper.DeserializeObject(typeof(GameScene), scenePath); #endif ActiveScene = gameScene; ActiveScenePath = scenePath; // Update last saved scene: if (GameProject != null && !scenePath.StartsWith("_") && saveHistory) { GameProject.EditorSettings.LastOpenScenePath = GibboHelper.MakeExclusiveRelativePath(GameProject.ProjectPath, ActiveScenePath); } // Load with success, notify: return(true); } catch (Exception exception) { Console.WriteLine("Error loading scene: " + exception.Message + "\n>" + exception.ToString()); // Not loaded, notify: return(false); } }
/// <summary> /// Create a scene at the input location /// </summary> /// <param name="filename">The filename of the scene to be created</param> /// <returns>True if successfully created</returns> public static bool CreateScene(string filename) { GameScene gameScene = new GameScene(); GibboHelper.SerializeObject(filename, gameScene); return(true); }
/// <summary> /// Saves the active scene at its location /// </summary> /// <returns>True if scene is saved</returns> public static bool SaveActiveScene() { if (ActiveScene == null) { return(false); } activeScene.SaveComponentValues(); GibboHelper.SerializeObject(ActiveScenePath, ActiveScene); return(true); }
/// <summary> /// Loads a project and returns it /// </summary> /// <param name="filepath">The source filepath</param> /// <returns>A deserialized gibbo project</returns> public static GibboProject Load(string filepath) { #if WINDOWS GibboProject project = (GibboProject)GibboHelper.DeserializeObject(filepath); #elif WINRT string npath = filepath.Replace(Windows.ApplicationModel.Package.Current.InstalledLocation.Path + "\\", string.Empty); GibboProject project = (GibboProject)GibboHelper.DeserializeObject(typeof(GibboProject), npath); #endif // Update the project path: project.ProjectPath = System.IO.Path.GetDirectoryName(filepath); project.ProjectFilePath = filepath; // Load data files LoadData(ref project); // Create a virtual settings file: project.settings.ReloadPath(project.ProjectPath); return(project); }
/// <summary> /// Saves the active scene at the input location /// </summary> /// <param name="path">The target path</param> /// <returns></returns> public static bool SaveActiveScene(string path, bool xml) { if (ActiveScene == null) { return(false); } activeScene.SaveComponentValues(); if (!xml) { GibboHelper.SerializeObject(path, ActiveScene); } else { GibboHelper.SerializeObjectXML(path, activeScene); } return(true); }
internal void Save(string filePath) { GibboHelper.SerializeObject(filePath, this); }
internal static VisualScriptManager Load(string filepath) { VisualScriptManager manager = (VisualScriptManager)GibboHelper.DeserializeObject(filepath); return(manager); }
/// <summary> /// Saves the game object /// </summary> /// <param name="filename"></param> public void Save(string filename) { GibboHelper.SerializeObject(filename, this); }
/// <summary> /// Saves the project at the current project path location /// </summary> public void Save() { this.Settings.SaveToFile(); GibboHelper.SerializeObject(this.projectFilePath, this); }