示例#1
0
        public bool TryToReloadOrSaveDialogueIfDirty(Dialogue dialogue)
        {
            if (!ResourcesHandler.IsDirty(dialogue))
            {
                return(true);
            }
            else if (ShowPopupCloseDocuments(null, new List <Dialogue>()
            {
                dialogue
            }))
            {
                // Just in case, force a reload of the whole document to ensure we leave in a valid state
                foreach (DocumentDialogue document in documentDialogues)
                {
                    if (document.Dialogue == dialogue)
                    {
                        ResourcesHandler.ReloadDialogue(dialogue);
                        document.OnPostReload();
                        break;
                    }
                }

                return(true);
            }

            return(false);
        }
示例#2
0
        private void OnReloadAllFiles(object sender, EventArgs e)
        {
            if (ResourcesHandler.Project == null)
            {
                return;
            }

            Project project   = null;
            var     dialogues = new List <Dialogue>();

            if (documentProject != null && ResourcesHandler.Project.Dirty)
            {
                project = ResourcesHandler.Project;
            }

            if (documentDialogues.Count > 0)
            {
                foreach (DocumentDialogue document in documentDialogues)
                {
                    var documentDialogue = document as DocumentDialogue;
                    documentDialogue.ResolvePendingDirty();
                    if (ResourcesHandler.IsDirty(documentDialogue.Dialogue))
                    {
                        dialogues.Add(documentDialogue.Dialogue);
                    }
                }
            }

            bool reloadOK = true;

            if (project != null || dialogues.Count > 0)
            {
                var          dialog = new DialogConfirmReload(project, dialogues);
                DialogResult result = dialog.ShowDialog();
                reloadOK = (result == DialogResult.OK);
            }

            if (reloadOK)
            {
                ResourcesHandler.ReloadAll();

                if (documentProject != null)
                {
                    documentProject.OnPostReload();
                }

                foreach (DocumentDialogue document in documentDialogues)
                {
                    var documentDialogue = document as DocumentDialogue;
                    documentDialogue.OnPostReload();
                }

                EditorCore.LogInfo("Reloaded all project files");
            }
        }
示例#3
0
        //--------------------------------------------------------------------------------------------------------------
        // Events from other forms

        public bool OnDocumentDialogueClosed(DocumentDialogue document, bool force)
        {
            if (force || !ResourcesHandler.IsDirty(document.Dialogue) || ShowPopupCloseDocuments(null, new List<Dialogue>() { document.Dialogue }))
            {
                if (document == dockPanel.ActiveContent)
                {
                    if (EditorCore.Properties != null)
                        EditorCore.Properties.Clear();
                }

                lastClosedDialogue = document.Dialogue.GetName();
                documentDialogues.Remove(document);
                return true;
            }
            return false;
        }
示例#4
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");
                }
            }
        }
示例#5
0
        private void OnSaveAllFiles(object sender, EventArgs e)
        {
            if (documentProject != null)
            {
                if (ResourcesHandler.Project.Dirty)
                {
                    ResourcesHandler.SaveProject();
                    documentProject.RefreshTitle();
                }
            }

            foreach (DocumentDialogue document in documentDialogues)
            {
                var documentDialogue = document as DocumentDialogue;
                documentDialogue.ResolvePendingDirty();
                if (ResourcesHandler.IsDirty(documentDialogue.Dialogue))
                {
                    ResourcesHandler.SaveDialogue(documentDialogue.Dialogue);
                    documentDialogue.OnPostSave();
                    documentDialogue.RefreshTitle();
                }
            }
        }