private async static Task <bool> LoadModsManifestAsync(Values values, bool forceUpdate = false)
        {
            bool         success      = false;
            ModsManifest modsManifest = null;

            try
            {
                modsManifest = await ModsManifest.TryLoadModManifestFile(forceUpdate);

                success = true;
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show($"Mods manifest file {Path.Combine(FileService.ValuesFolder, FileService.ModsManifest)} not found " +
                                "and downloading it failed. You can try it later or try to update your application.",
                                "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                FormatExceptionMessageBox(Path.Combine(FileService.ValuesFolder, FileService.ModsManifest));
            }

            values.SetModsManifest(modsManifest);
            return(success);
        }
示例#2
0
        internal async Task <bool> LoadModsManifestAsync(bool forceUpdate = false)
        {
            modsManifest = await ModsManifest.TryLoadModManifestFile(forceUpdate);

            bool manifestFileLoadingSuccessful = modsManifest != null;

            if (!manifestFileLoadingSuccessful)
            {
                modsManifest = new ModsManifest();
            }

            // UpdateManualModValueFiles(); // TODO

            return(manifestFileLoadingSuccessful);
        }
示例#3
0
        private static async Task <bool> LoadModsManifestAsync(Values values, bool forceUpdate = false)
        {
            ModsManifest modsManifest = null;

            try
            {
                try
                {
                    modsManifest = await ModsManifest.TryLoadModManifestFile(forceUpdate);

                    // assume all officially supported mods are online available
                    foreach (var m in modsManifest.modsByFiles)
                    {
                        m.Value.onlineAvailable = true;
                    }
                }
                catch (FileNotFoundException)
                {
                    MessageBox.Show(
                        $"Mods manifest file {Path.Combine(FileService.ValuesFolder, FileService.ModsManifest)} not found " +
                        "and downloading it failed. You can try it later or try to update your application.",
                        $"File not found - {Utils.ApplicationNameVersion}", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                catch (FormatException)
                {
                    FormatExceptionMessageBox(Path.Combine(FileService.ValuesFolder, FileService.ModsManifest));
                    return(false);
                }

                // load custom manifest file for manually created mod value files
                if (ModsManifest.TryLoadCustomModManifestFile(out var customModsManifest))
                {
                    modsManifest = ModsManifest.MergeModsManifest(modsManifest, customModsManifest);
                }
            }
            catch (SerializationException serEx)
            {
                MessageBox.Show(
                    $"Serialization exception while trying to load the mods-manifest file.\n\n{serEx.Message}",
                    $"File loading error - {Utils.ApplicationNameVersion}", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            modsManifest?.Initialize();
            values.SetModsManifest(modsManifest);
            return(true);
        }