Exemple #1
0
        protected override GameXmlFile ReadFile(FileInfo path) {
            bool keep_trying = true;
            while (keep_trying) {
                try {
                    if (path.Name == "custom.xml") {
                        this.custom = new CustomGameXmlFile(path);
                        return this.custom;
                    } else {
                        GameXmlFile file = new GameXmlFile(path);
                        return file;
                    }
                } catch (VersionNotSupportedException ex) {
                    if (ex.FileVersion == null || !GameSaveInfo.Converters.AConverter.CanConvert(ex.FileVersion)) {
                        string version_string;
                        if (ex.FileVersion == null)
                            version_string = Strings.GetLabelString("UnknownVersion");
                        else
                            version_string = ex.FileVersion.ToString();

                        if (!TranslatingRequestHandler.Request(MVC.Communication.RequestType.Question, "GameDataObsoleteDelete", path.Name, version_string).Cancelled) {
                            path.Delete();
                        }
                        keep_trying = false;
                    }
                } catch (XmlException ex) {
                    TranslatingMessageHandler.SendError("XMLFormatError", ex, path.FullName);
                    keep_trying = handleCorruptedFile(path);
                } catch (NotSupportedException ex) {
                    TranslatingMessageHandler.SendError("XMLFormatError", ex, path.FullName);
                    keep_trying = handleCorruptedFile(path);
                }
            }
            return null;
        }
Exemple #2
0
        public bool purge(bool include_archives)
        {
            List <string> options    = new List <string>();
            string        all_option = Strings.GetLabelString("PurgeAllRoots");
            string        question;

            if (include_archives)
            {
                question = "PurgeGameAndArchivesQuestion";
            }
            else
            {
                question = "PurgeJustGameQuestion";
            }

            options.Add(all_option);
            foreach (DetectedLocationPathHolder root in DetectedLocations)
            {
                string path;
                if (root.Path == null)
                {
                    path = root.AbsoluteRoot;
                }
                else
                {
                    path = Path.Combine(root.AbsoluteRoot, root.Path);
                }
                if (!options.Contains(path))
                {
                    options.Add(path);
                }
            }

            RequestReply info = TranslatingRequestHandler.Request(RequestType.Choice, question, options[0], options, this.Name);

            if (info.Cancelled)
            {
                return(false);
            }
            if (info.SelectedIndex == 0)
            {
                foreach (DetectedLocationPathHolder delete_me in DetectedLocations)
                {
                    delete_me.delete();
                }
            }
            else
            {
                DetectedLocations[info.SelectedOption].delete();
            }
            return(true);
        }
        public static void beginRestore(AViewWindow parent, List <Archive> archives)
        {
            string extrasave = ProgressHandler.message;

            ProgressHandler.saveMessage();
            parent.hideInterface();
            if (archives.Count > 1 && !TranslatingRequestHandler.Request(RequestType.Question, "RestoreMultipleArchives").Cancelled)
            {
                Restore.RestoreProgramHandler.use_defaults = true;
            }

            foreach (Archive archive in archives)
            {
                if (Restore.RestoreProgramHandler.overall_stop)
                {
                    break;
                }

                Restore.RestoreWindow restore = new Restore.RestoreWindow(archive, parent);
                restore.ShowDialog();

                switch (restore.Result)
                {
                case RestoreResult.Success:
                    Core.redetect_games = true;
                    break;

                case RestoreResult.Cancel:
                case RestoreResult.Failed:
                case RestoreResult.ElevationFailed:
                    break;
                }
            }
            Restore.RestoreProgramHandler.use_defaults = false;
            Restore.RestoreProgramHandler.overall_stop = false;
            // Restore.RestoreProgramHandler.default_user = null;
            if (Restore.RestoreProgramHandler.unsuccesfull_restores.Count > 0)
            {
                StringBuilder fail_list = new StringBuilder();
                foreach (string failed in Restore.RestoreProgramHandler.unsuccesfull_restores)
                {
                    fail_list.AppendLine(failed);
                }
                TranslatingMessageHandler.SendError("RestoreSomeFailed", fail_list.ToString());
            }
            parent.showInterface();
            ProgressHandler.message = extrasave;
        }
Exemple #4
0
 private bool handleCorruptedFile(FileInfo path) {
     if (IsRestorable(path)) {
         if (!TranslatingRequestHandler.Request(MVC.Communication.RequestType.Question, "GameDataCorruptedRestore", path.Name).Cancelled) {
             path.Delete();
             prepareDataFiles();
         } else {
             return false;
         }
     } else {
         if (!TranslatingRequestHandler.Request(MVC.Communication.RequestType.Question, "GameDataCorruptedDelete", path.Name).Cancelled) {
             path.Delete();
         }
         return false;
     }
     return true;
 }
Exemple #5
0
        private RestoreResult restoreElevation(string destination)
        {
            try {
                //   if (SecurityHandler.amAdmin()) {
                //     TranslatingMessageHandler.SendError("UnableToCreateOutputFolderAdmin", destination);
                //   return false;
                //}

                MVC.Communication.Interface.InterfaceHandler.disableInterface();
                if (!TranslatingRequestHandler.Request(RequestType.Question, "UnableToCreateOutputFolderRequest", destination).Cancelled)
                {
                    try {
                        MVC.Communication.Interface.InterfaceHandler.disableInterface();
                        ElevationResult res = SecurityHandler.elevation(Core.ExecutableName, "\"" + ArchiveFile.FullName + "\"", true);
                        switch (res)
                        {
                        case ElevationResult.Success:
                            return(RestoreResult.Success);

                        case ElevationResult.Cancelled:
                            return(RestoreResult.ElevationDenied);

                        case ElevationResult.Failed:
                            return(RestoreResult.ElevationFailed);

                        default:
                            throw new NotSupportedException(res.ToString());
                        }
                    } catch (Exception e) {
                        throw new TranslateableException("RestoreProgramNotFound", e, Core.ExecutableName);
                    }
                }
                else
                {
                    return(RestoreResult.ElevationDenied);
                }
            } finally {
                //MVC.Communication.Interface.InterfaceHandler.showInterface();
                MVC.Communication.Interface.InterfaceHandler.enableInterface();
                MVC.Communication.Interface.InterfaceHandler.closeInterface();
            }
        }
Exemple #6
0
        private void deleteGame_Click(object sender, RoutedEventArgs e)
        {
            if (TranslatingRequestHandler.Request(RequestType.Question, "DeleteGameConfirm", gamesLst.SelectedItems.Count.ToString()).Cancelled)
            {
                return;
            }

            List <GameEntry> games = new List <GameEntry>();

            foreach (GameEntry game in gamesLst.SelectedItems)
            {
                games.Add(game);
            }
            foreach (GameEntry game in games)
            {
                Games.deleteCustomGame(game);
            }

            submitGame.IsEnabled = Games.HasUnsubmittedGames;
        }
        private void DeleteArchives_Click(object sender, RoutedEventArgs e)
        {
            int selected_count = ArchiveList.SelectedItems.Count;

            if (selected_count > 0)
            {
                List <Archive> archives = new List <Archive>();
                foreach (Archive archive in ArchiveList.SelectedItems)
                {
                    archives.Add(archive);
                }
                foreach (Archive archive in archives)
                {
                    if (!TranslatingRequestHandler.Request(RequestType.Question, "DeleteArchiveConfirm", archive.ArchiveFile.Name).Cancelled)
                    {
                        archive.Delete();
                    }
                }
                updateArchiveList();
            }
        }
Exemple #8
0
        private void AddGameButton_Click(object sender, RoutedEventArgs e)
        {
            CustomGameEntry game = Games.addCustomGame(AddGameTitle.Value, new System.IO.DirectoryInfo(AddGameLocation.Value), AddGameSaves.Value, AddGameExclusions.Value);

            if (!Core.settings.SuppressSubmitRequests)
            {
                RequestReply reply = TranslatingRequestHandler.Request(RequestType.Question, "PleaseSubmitGame", true);
                if (!reply.Cancelled)
                {
                    createGameSubmission(game);
                }
                else
                {
                    if (reply.Suppressed)
                    {
                        Core.settings.SuppressSubmitRequests = true;
                    }
                }
            }
            closeAddGame(true);
            submitGame.IsEnabled = Games.HasUnsubmittedGames;
        }
Exemple #9
0
        private bool askAboutGame()
        {
            if (!submitPromptSuppress)
            {
                while (submitting_games.Count > 0)
                {
                    CustomGameEntry game  = submitting_games.Peek();
                    RequestReply    reply = TranslatingRequestHandler.Request(RequestType.Question, "AskSubmitGame", true, game.Title);
                    submitPromptSuppress = reply.Suppressed;
                    if (reply.Cancelled)
                    {
                        if (reply.Suppressed)
                        {
                            submitting_games.Clear();
                            return(false);
                        }
                        else
                        {
                            submitting_games.Dequeue();
                        }
                    }
                    else
                    {
                        createGameSubmission(submitting_games.Dequeue());
                        return(true);
                    }
                }
            }

            if (submitting_games.Count > 0)
            {
                createGameSubmission(submitting_games.Dequeue());
                return(true);
            }

            return(false);
        }