예제 #1
0
        private void OnReloadAllFiles(object sender, EventArgs e)
        {
            if (ResourcesHandler.Project == null)
            {
                return;
            }

            // Backup opened dialogues names.
            List <string> openedDialogues = new List <string>();

            foreach (DocumentDialogue document in documentDialogues)
            {
                openedDialogues.Add(document.Dialogue.GetName());
            }

            if (CloseAllDocuments())
            {
                EditorCore.Properties?.Clear();
                EditorCore.CustomProperties?.Clear();
                EditorCore.ProjectExplorer?.Clear();

                ResourcesHandler.ReloadAll();

                EditorCore.ProjectExplorer.ResyncAllFiles();

                // Re-open dialogues if possible.
                foreach (string name in openedDialogues)
                {
                    OpenDocumentDialogue(name);
                }

                EditorCore.LogInfo("Reloaded all project files");
            }
        }
예제 #2
0
        static private bool DeserializeFromFile <T>(string path, T value)
        {
            //var jObject = Newtonsoft.Json.Linq.JObject.Parse(File.ReadAllText(path));
            //int version = jObject.GetValue("Version");

            try
            {
                JsonSerializerSettings settings = new JsonSerializerSettings();
                settings.TypeNameHandling           = TypeNameHandling.Auto;            //default
                settings.NullValueHandling          = NullValueHandling.Include;        //default
                settings.ObjectCreationHandling     = ObjectCreationHandling.Replace;   //not default
                settings.PreserveReferencesHandling = PreserveReferencesHandling.None;  //default

                settings.Binder = EditorCore.SerializationBinder;

                JsonConvert.PopulateObject(File.ReadAllText(path), value, settings);
            }
            catch (Newtonsoft.Json.JsonReaderException e)
            {
                EditorCore.LogError("A malformed file could not be loaded : " + path);
                EditorCore.LogError("> exception : " + e.Message);
                return(false);
            }
            catch (Newtonsoft.Json.JsonSerializationException e)
            {
                //TODO: Here I could plug additionnal handlers with older versions of the SerializationBinder

                EditorCore.LogError("A file containing unknown serialization bindings could not be loaded : " + path);
                EditorCore.LogError("> exception : " + e.Message);
                return(false);
            }

            return(true);
        }
예제 #3
0
 private void OnExportConstantsUnreal4(object sender, EventArgs e)
 {
     if (ResourcesHandler.Project != null)
     {
         if (ExporterConstants.ExportToUnreal4())
             EditorCore.LogInfo("Export Constants Finished");
     }
 }
예제 #4
0
 private void OnExportLipsyncFaceFX(object sender, EventArgs e)
 {
     if (ResourcesHandler.Project != null)
     {
         if (ExporterLipsync.ExportFaceFx())
             EditorCore.LogInfo("Export Face FX Finished");
     }
 }
예제 #5
0
 private void OnExportStats(object sender, EventArgs e)
 {
     if (ResourcesHandler.Project != null)
     {
         if (ExporterStats.ExportAll())
             EditorCore.LogInfo("Export Stats Finished");
     }
 }
예제 #6
0
 private void OnExportLocalizationUnreal4(object sender, EventArgs e)
 {
     if (ResourcesHandler.Project != null)
     {
         if (ExporterLocalization.ExportToUnreal4())
             EditorCore.LogInfo("Export Localization Finished");
     }
 }
예제 #7
0
 private void OnExportDialogues(object sender, EventArgs e)
 {
     if (ResourcesHandler.Project != null)
     {
         if (ExporterDialogues.ExportToCsv())
             EditorCore.LogInfo("Export Dialogues Finished");
     }
 }
예제 #8
0
            public override Type BindToType(string assemblyName, string typeName)
            {
                if (Bindings.ContainsKey(typeName))
                {
                    return(Bindings[typeName]);
                }

                EditorCore.LogError("Unknown type on deserialization : " + typeName);
                return(null);
            }
예제 #9
0
        public Package GetDefaultPackage()
        {
            if (ListPackages.Count > 0)
            {
                return(ListPackages[0]);
            }

            EditorCore.LogError("No Default package found");
            return(null);
        }
예제 #10
0
        public Language GetDefaultLanguage()
        {
            if (ListLanguages.Count > 0)
            {
                return(ListLanguages[0]);
            }

            EditorCore.LogError("No Default language found");
            return(null);
        }
예제 #11
0
            public override void BindToName(Type type, out string assemblyName, out string typeName)
            {
                if (!Bindings.Values.Contains(type))
                {
                    EditorCore.LogError("Unknown type on serialization : " + type);
                }

                assemblyName = null;
                typeName     = Bindings.Single(item => item.Value == type).Key;
            }
예제 #12
0
        private void OnCheckAll(object sender, EventArgs e)
        {
            if (ResourcesHandler.Project == null)
                return;

            EditorCore.LogInfo("Checking all Dialogues - Begin");

            ResourcesHandler.CheckAll();

            EditorCore.LogInfo("Checking all Dialogues - End");
        }
예제 #13
0
        //--------------------------------------------------------------------------------------------------------------
        //

        static private bool CheckDialogueNameAvailable(string path, string name, bool logErrorIfNotAvailable)
        {
            if (!dialogues.ContainsKey(name))
            {
                return(true);
            }

            if (logErrorIfNotAvailable)
            {
                EditorCore.LogError("Dialogue already exists (ignored) : " + name + " at \"" + path + "\" and \"" + dialogues[name].Dialogue.GetFilePath() + "\"");
            }

            return(false);
        }
예제 #14
0
        static public Project CreateProjectInstance(string name)
        {
            Clear();

            Project = new Project();
            Project.Init("", name);

            if (EditorCore.OnProjectLoad != null)
            {
                EditorCore.OnProjectLoad();
            }

            return(Project);
        }
예제 #15
0
        private void OnCheckCurrent(object sender, EventArgs e)
        {
            if (ResourcesHandler.Project == null)
                return;

            if (dockPanel.ActiveDocument is DocumentDialogue)
            {
                EditorCore.LogInfo("Checking Dialogue - Begin");

                var dialogue = dockPanel.ActiveDocument as DocumentDialogue;
                ResourcesHandler.Check(dialogue.Dialogue);

                EditorCore.LogInfo("Checking Dialogue - End");
            }
        }
예제 #16
0
        //--------------------------------------------------------------------------------------------------------------
        //

        static public bool AddDialogue(Dialogue dialogue)
        {
            string name = dialogue.GetName();

            if (!dialogues.ContainsKey(name))
            {
                dialogues.Add(name, new ResourceHolder {
                    Dialogue = dialogue
                });
                return(true);
            }

            EditorCore.LogError("Dialogue already exists (ignored) : " + name + " at \"" + dialogue.GetFilePath() + "\" and \"" + dialogues[name].Dialogue.GetFilePath() + "\"");
            return(false);
        }
예제 #17
0
        private void OnReloadFile(object sender, EventArgs e)
        {
            if (ResourcesHandler.Project == null)
            {
                return;
            }

            if (dockPanel.ActiveDocument is DocumentProject && ResourcesHandler.Project.Dirty)
            {
                var          dialog = new DialogConfirmReload(ResourcesHandler.Project, new List <Dialogue>());
                DialogResult result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ResourcesHandler.ReloadProject();
                    documentProject.OnPostReload();

                    EditorCore.LogInfo("Reloaded project file");
                }
            }
            else if (dockPanel.ActiveDocument is DocumentDialogue)
            {
                var document = dockPanel.ActiveDocument as DocumentDialogue;
                document.ResolvePendingDirty();

                bool proceed = true;
                if (ResourcesHandler.IsDirty(document.Dialogue))
                {
                    var dialog = new DialogConfirmReload(null, new List <Dialogue>()
                    {
                        document.Dialogue
                    });
                    DialogResult result = dialog.ShowDialog();
                    proceed = (result == DialogResult.OK);
                }

                if (proceed)
                {
                    ResourcesHandler.ReloadDialogue(document.Dialogue);
                    document.OnPostReload();

                    EditorCore.LogInfo("Reloaded current dialogue file");
                }
            }
        }
예제 #18
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();
            }
        }
예제 #19
0
        public void PostLoad(Project project)
        {
            //Resolve links with package
            Package = project.GetPackage(PackageName);
            if (Package == null)
            {
                EditorCore.LogError("Loading a Dialogue without Package (forcing default) : " + GetName(), this);
                Package = project.GetDefaultPackage();
            }

            //Resolve links between nodes
            RootNode = GetNodeByID(RootNodeID) as DialogueNodeRoot;

            foreach (DialogueNode node in ListNodes)
            {
                node.Next = GetNodeByID(node.NextID);
                if (node is DialogueNodeChoice)
                {
                    DialogueNodeChoice nodeChoice = node as DialogueNodeChoice;
                    foreach (int replyID in nodeChoice.RepliesIDs)
                    {
                        DialogueNodeReply nodeReply = GetNodeByID(replyID) as DialogueNodeReply;
                        if (nodeReply != null)
                        {
                            nodeChoice.Replies.Add(nodeReply);
                        }
                    }
                }
                else if (node is DialogueNodeGoto)
                {
                    DialogueNodeGoto nodeGoto = node as DialogueNodeGoto;
                    nodeGoto.Goto = GetNodeByID(nodeGoto.GotoID);
                }
                else if (node is DialogueNodeBranch)
                {
                    DialogueNodeBranch nodebranch = node as DialogueNodeBranch;
                    nodebranch.Branch = GetNodeByID(nodebranch.BranchID);
                }
            }

            EditorCore.OnDialoguePostLoad?.Invoke(this);
        }
예제 #20
0
        static private bool DeserializeFromString <T>(T value, string content)
        {
            try
            {
                JsonSerializerSettings settings = new JsonSerializerSettings();
                settings.TypeNameHandling           = TypeNameHandling.Auto;            //default
                settings.NullValueHandling          = NullValueHandling.Include;        //default
                settings.ObjectCreationHandling     = ObjectCreationHandling.Replace;   //not default
                settings.PreserveReferencesHandling = PreserveReferencesHandling.None;  //default

                settings.Binder = EditorCore.SerializationBinder;

                JsonConvert.PopulateObject(content, value, settings);
            }
            catch (Newtonsoft.Json.JsonSerializationException)
            {
                EditorCore.LogError("Errors occured when parsing a file (will not be loaded)");
                return(false);
            }

            return(true);
        }