Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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.ResetFilePathName(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);
        }
Ejemplo n.º 3
0
        static public Dialogue CreateEmptyDialogueInstance(string name)
        {
            Dialogue dialogue = new Dialogue();

            dialogue.ResetFilePathName("", name);
            dialogue.Package = Project.GetDefaultPackage();
            if (AddDialogue(dialogue))
            {
                return(dialogue);
            }
            return(null);
        }
Ejemplo n.º 4
0
        static public Dialogue CreateDialogueInstance(string name)
        {
            Dialogue dialogue = new Dialogue();

            dialogue.ResetFilePathName("", name);
            dialogue.Package = Project.GetDefaultPackage();
            if (AddDialogue(dialogue))
            {
                DialogueNodeRoot root = new DialogueNodeRoot();
                dialogue.AddNode(root);
                dialogue.RootNode = root;

                return(dialogue);
            }
            return(null);
        }
Ejemplo n.º 5
0
        static public void ParseDirectory(System.IO.DirectoryInfo root)
        {
            System.IO.FileInfo[]      files   = null;
            System.IO.DirectoryInfo[] subDirs = null;

            try
            {
                files = root.GetFiles("*.*");
            }
            catch (UnauthorizedAccessException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (System.IO.DirectoryNotFoundException e)
            {
                Console.WriteLine(e.Message);
            }

            if (files != null)
            {
                string projectDirectory = Path.Combine(System.Environment.CurrentDirectory, Project.GetFilePath());

                foreach (System.IO.FileInfo fi in files)
                {
                    if (fi.Extension == Dialogue.GetExtension())
                    {
                        string filePath = Utility.GetRelativePath(fi.FullName, projectDirectory);

                        Dialogue dialogue = new Dialogue();
                        dialogue.ResetFilePathName(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));
                        AddDialogue(dialogue);
                    }
                }

                subDirs = root.GetDirectories();

                foreach (System.IO.DirectoryInfo dirInfo in subDirs)
                {
                    ParseDirectory(dirInfo);
                }
            }
        }