Пример #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);
        }
Пример #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);
        }
Пример #3
0
 static public void ReloadProject()
 {
     if (Project != null)
     {
         ExporterJson.LoadProjectFile(Project);
         Project.Dirty = false;
     }
 }
Пример #4
0
        static public void SaveDialogue(Dialogue dialogue)
        {
            var holder = dialogues[dialogue.GetName()];

            if (dialogue != null && holder != null)
            {
                ExporterJson.SaveDialogueFile(Project, dialogue);
                holder.Dirty = false;
            }
        }
Пример #5
0
        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;
            }
        }
Пример #6
0
        static public void ReloadDialogue(string name)
        {
            var holder = dialogues[name];

            if (holder != null && holder.Dialogue != null)
            {
                ExporterJson.LoadDialogueFile(Project, holder.Dialogue);
                holder.Dirty = false;
            }
        }
Пример #7
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;
            }
        }
Пример #8
0
        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);
            }
        }
Пример #9
0
        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();
            }
        }
Пример #10
0
        //--------------------------------------------------------------------------------------------------------------
        //

        static public void SaveProject()
        {
            ExporterJson.SaveProjectFile(Project);
            Project.Dirty = false;
        }