Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        static public void SaveDialogue(Dialogue dialogue)
        {
            var holder = dialogues[dialogue.GetName()];

            if (dialogue != null && holder != null)
            {
                ExporterJson.SaveDialogueFile(Project, dialogue);
                holder.Dirty = false;
            }
        }
Exemplo n.º 4
0
        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;
            }
        }