static public Dialogue CreateDialogueFile(string path, Package package = null) { string projectDirectory = Path.Combine(System.Environment.CurrentDirectory, Project.GetFilePath()); string filePath = ""; try { filePath = Utility.GetRelativePath(path, projectDirectory); } catch (System.UriFormatException) { filePath = path; //In case the given path is already relative (or consider it as relative if it's invalid) } Dialogue dialogue = new Dialogue(); dialogue.Init(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath)); dialogue.Package = (package != null) ? package : Project.GetDefaultPackage(); if (AddDialogue(dialogue)) { DialogueNodeRoot root = new DialogueNodeRoot(); dialogue.AddNode(root); dialogue.RootNode = root; ExporterJson.SaveDialogueFile(Project, dialogue); return(dialogue); } return(null); }
static public bool RenameDialogueFile(Dialogue dialogue, string path) { string projectDirectory = Path.Combine(System.Environment.CurrentDirectory, Project.GetFilePath()); string filePath = ""; try { filePath = Utility.GetRelativePath(path, projectDirectory); } catch (System.UriFormatException) { filePath = path; //In case the given path is already relative (or consider it as relative if it's invalid) } string newPath = Path.GetDirectoryName(filePath); string newName = Path.GetFileNameWithoutExtension(filePath); if (CheckDialogueNameAvailable(newPath, newName, true)) { RemoveDialogueFile(dialogue); dialogue.ResetFilePathName(newPath, newName); AddDialogue(dialogue); ExporterJson.SaveDialogueFile(Project, dialogue); return(true); } return(false); }
static public void ReloadProject() { if (Project != null) { ExporterJson.LoadProjectFile(Project); Project.Dirty = false; } }
static public void SaveDialogue(Dialogue dialogue) { var holder = dialogues[dialogue.GetName()]; if (dialogue != null && holder != null) { ExporterJson.SaveDialogueFile(Project, dialogue); holder.Dirty = false; } }
static public void ReloadDialogueFromString(Dialogue dialogue, string content) { var holder = dialogues[dialogue.GetName()]; if (dialogue != null && holder != null) { ExporterJson.LoadDialogueFromString(Project, dialogue, content); holder.Dirty = true; } }
static public void ReloadDialogue(string name) { var holder = dialogues[name]; if (holder != null && holder.Dialogue != null) { ExporterJson.LoadDialogueFile(Project, holder.Dialogue); holder.Dirty = false; } }
static public void SaveAll() { ExporterJson.SaveProjectFile(Project); Project.Dirty = false; foreach (var kvp in dialogues) { ExporterJson.SaveDialogueFile(Project, kvp.Value.Dialogue); kvp.Value.Dirty = false; } }
static public void LoadAllDialogues() { List <string> toRemove = new List <string>(); foreach (var kvp in dialogues) { if (!ExporterJson.LoadDialogueFile(Project, kvp.Value.Dialogue)) { toRemove.Add(kvp.Key); } } foreach (var key in toRemove) { dialogues.Remove(key); } }
static public void LoadProjectFile(string path) { Clear(); string projectPath = Utility.GetRelativePathFromCurrentDir(path); Project = new Project(); Project.Init(Path.GetDirectoryName(projectPath), Path.GetFileNameWithoutExtension(projectPath)); ParseProject(); ExporterJson.LoadProjectFile(Project); LoadAllDialogues(); if (EditorCore.OnProjectLoad != null) { EditorCore.OnProjectLoad(); } }
//-------------------------------------------------------------------------------------------------------------- // static public void SaveProject() { ExporterJson.SaveProjectFile(Project); Project.Dirty = false; }