Exemple #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);
        }
Exemple #2
0
        private bool ShowPopupCloseDocuments(Project dirtyProject, List<Dialogue> dirtyDialogues)
        {
            if (dirtyProject != null || dirtyDialogues.Count > 0)
            {
                DialogSaveOnClose dialog = new DialogSaveOnClose(dirtyProject, dirtyDialogues);
                DialogResult result = dialog.ShowDialog();
                if (result == DialogResult.Cancel)
                {
                    return false;
                }
                else if (result == DialogResult.OK)
                {
                    if (dirtyProject != null)
                        ResourcesHandler.SaveProject();

                    foreach (Dialogue dialogue in dirtyDialogues)
                    {
                        ResourcesHandler.SaveDialogue(dialogue);
                    }
                }
                else    //DialogResult.Ignore > Close without saving
                {
                    if (dirtyProject != null)
                        ResourcesHandler.ReloadProject();

                    foreach (Dialogue dialogue in dirtyDialogues)
                    {
                        ResourcesHandler.ReloadDialogue(dialogue);
                    }
                }
            }

            return true;
        }
Exemple #3
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");
                }
            }
        }