public void Serialization()
        {
            IModSource src = new InstalledMods(new MockFileSystem());

            IModDatabase db = new ModDatabase(src, modlinks_xml, api_xml);

            Assert.Equal
            (
                new ModItem
                (
                    new NotInstalledState(),
                    new Version(3, 0, 0, 0),
                    new[] { "Vasi" },
                    "https://github.com/fifty-six/HollowKnight.QoL/releases/download/v3/QoL.zip",
                    "QoL",
                    "A collection of various quality of life improvements."
                ),
                db.Items.First(x => x.Name == "QoL")
            );

            Assert.Equal(
                63,
                db.Api.Version
                );
        }
        public MainWindow()
        {
            InitializeComponent();

            eventHistory = new List <string>();
            settings     = new Settings();

            btnDisableCrashReports.DataContext = settings;
            btnEnableDeveloperMode.DataContext = settings;

            CrashReporting.CrashReporter.StartWatching();
            CrashReporting.CrashReporter.OnCrashDumpProcessed += CrashReporter_OnDumpProcessed;

            Api.ApiQueue.OnApiRequestIssued += ApiQueue_OnApiRequestIssued;
            Api.ApiQueue.OnApiRequestResult += ApiQueue_OnApiRequestResult;

            TitanfallMod.OnStatusUpdateException += TitanfallMod_OnStatusUpdateException;

            SDKInjector.OnLaunchingProcess     += SDKInjector_OnLaunchingProcess;
            SDKInjector.OnInjectingIntoProcess += SDKInjector_OnInjectingIntoProcess;
            SDKInjector.OnInjectionComplete    += SDKInjector_OnInjectionComplete;
            SDKInjector.OnInjectionException   += SDKInjector_OnInjectionException;

            ModDatabase.OnStartedLoadingMods   += ModDatabase_OnStartedLoadingMods;
            ModDatabase.OnFinishedLoadingMods  += ModDatabase_OnFinishedLoadingMods;
            ModDatabase.OnModLoaded            += ModDatabase_OnModLoaded;
            ModDatabase.OnFinishedImportingMod += ModDatabase_OnFinishedImportingMod;
            ModDatabase.LoadAll();

            UpdateLauncherSelection();
        }
 public void RefreshMods()
 {
     Mods = ModDatabase.Get(SelectedGame)
            .OrderBy(x => GameConfig.GetModPriority(x.Id))
            .Select(x => new ModViewModel(x))
            .ToList();
 }
Exemple #4
0
        public MainWindow()
        {
            InitializeComponent();

            eventHistory = new List <string>();
            settings     = new Settings();

            btnDisableCrashReports.DataContext = settings;
            btnEnableDeveloperMode.DataContext = settings;

            CrashReporting.CrashReporter.StartWatching();
            CrashReporting.CrashReporter.OnCrashDumpProcessed += CrashReporter_OnDumpProcessed;

            SDKInjector.OnLaunchingProcess     += SDKInjector_OnLaunchingProcess;
            SDKInjector.OnInjectingIntoProcess += SDKInjector_OnInjectingIntoProcess;
            SDKInjector.OnInjectionComplete    += SDKInjector_OnInjectionComplete;
            SDKInjector.OnInjectionException   += SDKInjector_OnInjectionException;

            ModDatabase.OnStartedLoadingMods   += ModDatabase_OnStartedLoadingMods;
            ModDatabase.OnFinishedLoadingMods  += ModDatabase_OnFinishedLoadingMods;
            ModDatabase.OnModLoaded            += ModDatabase_OnModLoaded;
            ModDatabase.OnFinishedImportingMod += ModDatabase_OnFinishedImportingMod;
            ModDatabase.OnModsChanged          += ModDatabase_OnModsChanged;
            ModDatabase.LoadAll();
            ModDatabase.WatchModsFolder();

            UpdateLauncherSelection();
        }
Exemple #5
0
        private void InitializeFolderComboBox()
        {
            FolderComboBox.SelectedIndex = 0;
            List <string> sModFolders = new List <string> {
                "All Folders"
            };
            var allModConfigs = GameConfig.ModConfigs.ToList();

            Mods = ModDatabase.Get(SelectedGame)
                   .OrderBy(x => GameConfig.GetModPriority(x.Id))
                   .Select(x => new ModViewModel(x, SelectedGame))
                   .ToList();

            foreach (ModViewModel modViewModel in Mods)
            {
                Mod    mod       = (Mod)modViewModel;
                string modFolder = Path.GetFileName(Path.GetDirectoryName(mod.BaseDirectory));
                if (modFolder != "Mods" && !Regex.IsMatch(modFolder, "Persona[^ ]*") && !sModFolders.Contains(modFolder)) //Any folder containing mod that isn't for sorting mods by game
                {
                    sModFolders.Add(modFolder);
                }
            }

            FolderComboBox.ItemsSource = sModFolders.ToArray();
        }
Exemple #6
0
        public static async Task InitializeAsync()
        {
            _mods = await DataUtils.LoadRePoEAsync <Dictionary <string, JsonMod> >("mods");

            _benchOptions = await DataUtils.LoadRePoEAsync <JsonCraftingBenchOption[]>("crafting_bench_options");

            _modDatabase = new ModDatabase(_mods, _benchOptions);
        }
        public void ReadEmptyState()
        {
            IModSource src = new InstalledMods(new MockFileSystem());

            IModDatabase db = new ModDatabase(src, modlinks_xml, api_xml);

            Assert.True(db.Items.All(x => x.State is NotInstalledState));
        }
Exemple #8
0
 /// <summary>
 /// Refreshes the mods.
 /// Clears the nodestore,
 /// Sets up the modviewmodels from the moddatabase
 /// adds them to a list and the nodestore
 /// </summary>
 private void RefreshMods()
 {
     ModGrid.NodeStore.Clear();
     Mods = ModDatabase.Get(SelectedGame)
            .OrderBy(x => GameConfig.GetModPriority(x.Id))
            .Select(x => new ModViewModel(x))
            .ToList();
     Mods.ForEach(x => ModGrid.NodeStore.AddNode(x));
 }
Exemple #9
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="environment">The web hosting environment.</param>
        /// <param name="wikiCache">The cache in which to store wiki data.</param>
        /// <param name="modCache">The cache in which to store mod metadata.</param>
        /// <param name="config">The config settings for mod update checks.</param>
        /// <param name="chucklefish">The Chucklefish API client.</param>
        /// <param name="curseForge">The CurseForge API client.</param>
        /// <param name="github">The GitHub API client.</param>
        /// <param name="modDrop">The ModDrop API client.</param>
        /// <param name="nexus">The Nexus API client.</param>
        public ModsApiController(IWebHostEnvironment environment, IWikiCacheRepository wikiCache, IModCacheRepository modCache, IOptions <ModUpdateCheckConfig> config, IChucklefishClient chucklefish, ICurseForgeClient curseForge, IGitHubClient github, IModDropClient modDrop, INexusClient nexus)
        {
            this.ModDatabase = new ModToolkit().GetModDatabase(Path.Combine(environment.WebRootPath, "SMAPI.metadata.json"));

            this.WikiCache = wikiCache;
            this.ModCache  = modCache;
            this.Config    = config;
            this.ModSites  = new ModSiteManager(new IModSiteClient[] { chucklefish, curseForge, github, modDrop, nexus });
        }
Exemple #10
0
        private void RefreshMods()
        {
            Mods = ModDatabase.Get(SelectedGame)
                   .OrderBy(x => GameConfig.GetModPriority(x.Id))
                   .Select(x => new ModViewModel(x, SelectedGame))
                   .ToList();

            ModGrid.ItemsSource = Mods;
        }
Exemple #11
0
        private async Task InitializeAsync()
        {
            _mods = await RePoEUtils.LoadAsync <Dictionary <string, JsonMod> >("mods");

            _benchOptions = await RePoEUtils.LoadAsync <JsonCraftingBenchOption[]>("crafting_bench_options");

            _npcMasters = await RePoEUtils.LoadAsync <Dictionary <string, JsonNpcMaster> >("npc_master");

            _modDatabase = new ModDatabase(_mods, _benchOptions, _npcMasters);
        }
        public CommandHandler(DiscordSocketClient client)
        {
            this.client = client;

            _service = new CommandService();

            _service.AddModulesAsync(Assembly.GetEntryAssembly(), null);

            client.MessageReceived += HandleCommand;

            ModDatabase.Start(client.GetGuild(Global.GuildID), client).GetAwaiter().GetResult();
        }
 private void Icepick_Drop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
         foreach (string file in files)
         {
             AddEvent($"Attempting to import potential mod: {file}");
             ModDatabase.AttemptImportMod(file);
         }
     }
 }
 private void DeserializeEnabledModsLegacy(XElement element)
 {
     foreach (var xModId in element.Elements())
     {
         if (Guid.TryParse(xModId.Value, out var modId) &&
             modId != Guid.Empty &&
             ModDatabase.Exists(modId))
         {
             mModConfigs[modId] = new ModConfig(modId, GetNextAvailableModPriority(), true);
         }
     }
 }
        public BrowseTabViewModel()
        {
            Mods        = new ObservableCollection <ModDatabaseModViewModel>();
            modDatabase = new ModDatabase();

            PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == "BrowseModsIsSelected" && BrowseModsIsSelected)
                {
                    LazyLoadMods();
                }
            };
        }
        private void DeserializeEnabledMods(XElement element)
        {
            foreach (var xModConfig in element.Elements())
            {
                var modConfig = ModConfig.Deserialize(xModConfig);

                if (modConfig.ModId != Guid.Empty &&
                    ModDatabase.Exists(modConfig.ModId))
                {
                    mModConfigs[modConfig.ModId] = modConfig;
                }
            }
        }
        protected GameConfig()
        {
            OutputDirectoryPath = Path.Combine("Output", $"{Game}");

            mModConfigs = new Dictionary <Guid, ModConfig>();

            // Initialize default mod configs for game mods in the database
            int priority = 0;

            foreach (var mod in ModDatabase.Get(Game))
            {
                AddModConfig(mod.Id, priority++, false);
            }
        }
        public void ReadState()
        {
            var src = new InstalledMods(new MockFileSystem())
            {
                Mods =
                {
                    ["QoL"] = new InstalledState(true, new Version(1, 0), false)
                }
            };

            IModDatabase db = new ModDatabase(src, modlinks_xml, api_xml);

            Assert.True(db.Items.First(x => x.Name == "QoL").State is InstalledState {
                Updated: false, Enabled: true
            });
        /// <summary>
        /// Resolves a dependency and returns all DLL files that the dependency uses
        /// </summary>
        /// <param name="name"></param>
        /// <param name="verMajor"></param>
        /// <param name="verMinor"></param>
        /// <param name="canBeNewer"></param>
        /// <param name="searchDirs"></param>
        /// <param name="dllDir"></param>
        /// <param name="imageDir"></param>
        /// <param name="soundDir"></param>
        /// <param name="caller"></param>
        /// <returns></returns>
        public static IEnumerable <string> LoadDependency(string name, int verMajor, int verMinor,
                                                          string dllDir, string mapDir, string assetDir, string caller, bool overwriteExisting)
        {
            List <string> _dependencyDlls = new List <string>();

            if (!ModDatabase.Contains(name, verMajor))
            {
                return(Enumerable.Empty <string>());
            }

            var  dbItem    = ModDatabase.Get(name, verMajor);
            bool versionOk = true;

            if (verMajor > dbItem.Major)
            {
                versionOk = false;
            }
            else if (verMajor == dbItem.Major && verMinor < dbItem.Minor)
            {
                versionOk = false;
            }

            if (!versionOk)
            {
                throw new Exception("Could not resolve to an appropriate version of a dependency. All versions are too old.");
            }

            if (IsCircular(dbItem.File, caller))
            {
                throw new Exception($"{name} and {caller} reference each other circularly. Cannot load either.");
            }

            //Resolve and load the dependency
            string errors;
            var    module = ModLoader.LoadCompressedModFile(dbItem.File, dllDir, mapDir, assetDir, out errors,
                                                            dbItem.UsesWhitelist, overwriteExisting);

            if (errors != null)
            {
                throw new Exception(errors);
            }
            //And then add all the dependencies
            _dependencyDlls.AddRange(module.Assemblies.Select(a => a.Location));
            _dependencyDlls.AddRange(module.Dependencies.Select(a => a.Location));

            return(_dependencyDlls.Distinct());
        }
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="environment">The web hosting environment.</param>
        /// <param name="wikiCache">The cache in which to store wiki data.</param>
        /// <param name="modCache">The cache in which to store mod metadata.</param>
        /// <param name="config">The config settings for mod update checks.</param>
        /// <param name="chucklefish">The Chucklefish API client.</param>
        /// <param name="curseForge">The CurseForge API client.</param>
        /// <param name="github">The GitHub API client.</param>
        /// <param name="modDrop">The ModDrop API client.</param>
        /// <param name="nexus">The Nexus API client.</param>
        public ModsApiController(IWebHostEnvironment environment, IWikiCacheRepository wikiCache, IModCacheRepository modCache, IOptions <ModUpdateCheckConfig> config, IChucklefishClient chucklefish, ICurseForgeClient curseForge, IGitHubClient github, IModDropClient modDrop, INexusClient nexus)
        {
            this.ModDatabase = new ModToolkit().GetModDatabase(Path.Combine(environment.WebRootPath, "SMAPI.metadata.json"));

            this.WikiCache    = wikiCache;
            this.ModCache     = modCache;
            this.Config       = config;
            this.Repositories =
                new IModRepository[]
            {
                new ChucklefishRepository(chucklefish),
                new CurseForgeRepository(curseForge),
                new GitHubRepository(github),
                new ModDropRepository(modDrop),
                new NexusRepository(nexus)
            }
            .ToDictionary(p => p.VendorKey);
        }
        private async Task InitializeAsync()
        {
            var modsTask             = DataUtils.LoadRePoEAsync <Dictionary <string, JsonMod> >("mods");
            var benchOptionsTask     = DataUtils.LoadRePoEAsync <JsonCraftingBenchOption[]>("crafting_bench_options");
            var npcMastersTask       = DataUtils.LoadRePoEAsync <Dictionary <string, JsonNpcMaster> >("npc_master");
            var statTranslationsTask = DataUtils.LoadRePoEAsync <List <JsonStatTranslation> >("stat_translations");

            ModDatabase    = new ModDatabase(await modsTask, await benchOptionsTask, await npcMastersTask);
            StatTranslator = new StatTranslator(await statTranslationsTask);

            ItemBases   = (await LoadBases()).ToList();
            UniqueBases = (await LoadUniques()).ToList();

            ItemBaseDictionary   = ItemBases.DistinctBy(b => b.Name).ToDictionary(b => b.Name);
            UniqueBaseDictionary = UniqueBases.DistinctBy(b => b.UniqueName).ToDictionary(b => b.UniqueName);

            _root = new WordSetTreeNode(ItemBases.Select(m => m.Name));
        }
Exemple #22
0
        public ModDatabaseModViewModel(ModDatabaseMod mod, ModDatabase database)
        {
            this.mod       = mod;
            this.timer     = new Timer();
            this.database  = database;
            this.saver     = new DownloadedModSaver();
            this.extractor = new ModExtracter();

            DownloadModCommand = new Command(DownloadMod, x => !IsDownloading);

            timer.AutoReset = false;
            timer.Elapsed  += (o, e) =>
            {
                ModHasBeenDownloaded = false;
                timer.Stop();
            };
            timer.Interval = TimeSpan.FromSeconds(5).TotalMilliseconds;
        }
Exemple #23
0
        private async Task InitializeAsync()
        {
            var modsTask           = DataUtils.LoadRePoEAsync <Dictionary <string, JsonMod> >("mods", true);
            var benchOptionsTask   = DataUtils.LoadRePoEAsync <JsonCraftingBenchOption[]>("crafting_bench_options", true);
            var statTranslatorTask = StatTranslators.CreateFromMainFileAsync(true);

            ModDatabase = new ModDatabase(await modsTask, await benchOptionsTask);

            ItemBases = await LoadBases();

            UniqueBases = await LoadUniques();

            StatTranslator = await statTranslatorTask;

            ItemBaseDictionary   = ItemBases.DistinctBy(b => b.Name).ToDictionary(b => b.Name);
            UniqueBaseDictionary = UniqueBases.DistinctBy(b => b.UniqueName).ToDictionary(b => b.UniqueName);

            _root = new WordSetTreeNode(ItemBases.Select(m => m.Name));
        }
Exemple #24
0
        public ItemParser()
        {
            var modDefinitionsFile = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, @"Data\ModDefinitions.json"));
            var modDefinitions = JsonConvert.DeserializeObject<IEnumerable<ModDefinition>>(modDefinitionsFile);
            var modDatabase = new ModDatabase(modDefinitions);

            parsers = new IParser<PoeItem>[]
            {
                new PhysicalDamagaParser(),
                new ElementalDamageParser(),
                new AttackSpeedParser(),
                new ItemLevelParser(),
                //new IncreasedDamageModParser(modDatabase),
                new IncreasedDamageWithWeaponsModParser(modDatabase),
                new IncreasedPropertyModParser(modDatabase),
                new IncreasedPercentagePropertyModParser(modDatabase),
                new AddedPropertyModParser(modDatabase),
            };
        }
Exemple #25
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="environment">The web hosting environment.</param>
        /// <param name="cache">The cache in which to store mod metadata.</param>
        /// <param name="configProvider">The config settings for mod update checks.</param>
        /// <param name="chucklefish">The Chucklefish API client.</param>
        /// <param name="github">The GitHub API client.</param>
        /// <param name="nexus">The Nexus API client.</param>
        public ModsApiController(IHostingEnvironment environment, IMemoryCache cache, IOptions <ModUpdateCheckConfig> configProvider, IChucklefishClient chucklefish, IGitHubClient github, INexusClient nexus)
        {
            this.ModDatabase = new ModToolkit().GetModDatabase(Path.Combine(environment.WebRootPath, "StardewModdingAPI.metadata.json"));
            ModUpdateCheckConfig config = configProvider.Value;

            this.WikiCompatibilityPageUrl = config.WikiCompatibilityPageUrl;

            this.Cache = cache;
            this.SuccessCacheMinutes = config.SuccessCacheMinutes;
            this.ErrorCacheMinutes   = config.ErrorCacheMinutes;
            this.VersionRegex        = config.SemanticVersionRegex;
            this.Repositories        =
                new IModRepository[]
            {
                new ChucklefishRepository(config.ChucklefishKey, chucklefish),
                new GitHubRepository(config.GitHubKey, github),
                new NexusRepository(config.NexusKey, nexus)
            }
            .ToDictionary(p => p.VendorKey, StringComparer.CurrentCultureIgnoreCase);
        }
Exemple #26
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="environment">The web hosting environment.</param>
        /// <param name="wikiCache">The cache in which to store wiki data.</param>
        /// <param name="modCache">The cache in which to store mod metadata.</param>
        /// <param name="configProvider">The config settings for mod update checks.</param>
        /// <param name="chucklefish">The Chucklefish API client.</param>
        /// <param name="github">The GitHub API client.</param>
        /// <param name="modDrop">The ModDrop API client.</param>
        /// <param name="nexus">The Nexus API client.</param>
        public ModsApiController(IHostingEnvironment environment, IWikiCacheRepository wikiCache, IModCacheRepository modCache, IOptions <ModUpdateCheckConfig> configProvider, IChucklefishClient chucklefish, IGitHubClient github, IModDropClient modDrop, INexusClient nexus)
        {
            this.ModDatabase = new ModToolkit().GetModDatabase(Path.Combine(environment.WebRootPath, "SMAPI.metadata.json"));
            ModUpdateCheckConfig config = configProvider.Value;

            this.CompatibilityPageUrl = config.CompatibilityPageUrl;

            this.WikiCache           = wikiCache;
            this.ModCache            = modCache;
            this.SuccessCacheMinutes = config.SuccessCacheMinutes;
            this.ErrorCacheMinutes   = config.ErrorCacheMinutes;
            this.Repositories        =
                new IModRepository[]
            {
                new ChucklefishRepository(chucklefish),
                new GitHubRepository(github),
                new ModDropRepository(modDrop),
                new NexusRepository(nexus)
            }
            .ToDictionary(p => p.VendorKey);
        }
Exemple #27
0
        public static async Task WhyReadThisLol(HttpListenerContext c)
        {
            var r = await QuinsCryptoLol.IsValidRequest(c);

            if (!r.result)
            {
                c.Response.StatusCode = 401;
                c.Response.Close();
                return;
            }

            string     cont = r.payload;
            ModlogBody body;

            try
            {
                body = JsonConvert.DeserializeObject <ModlogBody>(cont);
            }
            catch
            {
                c.Response.StatusCode = 400;
                c.Response.Close();
                return;
            }

            try
            {
                await ModDatabase.AddModlogs(body.userId, body.type, body.moderatorId, body.reason, body.username);

                c.Response.StatusCode = 200;
                c.Response.Close();
            }
            catch (Exception x)
            {
                Global.ConsoleLog(x.ToString());
                c.Response.StatusCode = 500;
                c.Response.Close();
            }
        }
Exemple #28
0
        public ItemBase(ItemImageService itemImageService, ModDatabase modDatabase, ItemBaseDto xmlBase)
        {
            Level                = xmlBase.Level;
            RequiredStrength     = xmlBase.Strength;
            RequiredDexterity    = xmlBase.Dexterity;
            RequiredIntelligence = xmlBase.Intelligence;
            DropDisabled         = xmlBase.DropDisabled;
            InventoryHeight      = xmlBase.InventoryHeight;
            InventoryWidth       = xmlBase.InventoryWidth;

            Name       = xmlBase.Name;
            ItemClass  = xmlBase.ItemClass;
            Tags       = xmlBase.Tags;
            MetadataId = xmlBase.MetadataId;

            ImplicitMods   = xmlBase.Implicit.Select(id => modDatabase.Mods[id]).ToList();
            _properties    = xmlBase.Properties;
            CanHaveQuality = Tags.HasFlag(Tags.Weapon) || Tags.HasFlag(Tags.Armour);

            Image = new ItemImage(itemImageService, Name, ItemClass);

            MaximumNumberOfSockets = GetMaximumNumberOfSockets();
        }
Exemple #29
0
        public UniqueBase(ItemImageService itemImageService, ModDatabase modDatabase, ItemBase itemBase,
                          XmlUnique xmlUnique)
        {
            UniqueName   = xmlUnique.Name;
            Level        = xmlUnique.Level;
            DropDisabled = xmlUnique.DropDisabled;
            _base        = itemBase;
            _properties  = xmlUnique.Properties;
            var explicits = new List <IMod>();

            foreach (var id in xmlUnique.Explicit)
            {
                if (!modDatabase.Mods.TryGetValue(id, out var mod))
                {
                    Log.Error($"Unknown mod id {id} on unique {UniqueName}");
                    continue;
                }
                explicits.Add(mod);
            }
            ExplicitMods = explicits;

            Image = itemBase.Image.AsDefaultForUniqueImage(itemImageService, UniqueName);
        }
Exemple #30
0
        private void BuildButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(GameConfig.OutputDirectoryPath))
            {
                MessageBox.Show(this, "Please specify an output directory in the settings.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (Mods.Count == 0)
            {
                MessageBox.Show(this, "No mods are available.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (!UpdateGameConfigEnabledMods())
            {
                MessageBox.Show(this, "No mods are enabled.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var task = Task.Factory.StartNew(() =>
            {
                gEnabledMods = GameConfig.ModConfigs.Where(x => x.Enabled)
                               .OrderBy(x => x.Priority)
                               .Select(x => x.ModId)
                               .Select(x => ModDatabase.Get(x))
                               .ToList();

                Log.General.Info("Building mods:");
                foreach (var enabledMod in gEnabledMods)
                {
                    Log.General.Info($"\t{enabledMod.Title}");
                }

                // Run prebuild scripts
                RunModScripts(gEnabledMods, "prebuild.bat");

                var merger = new TopToBottomModMerger();
                var merged = merger.Merge(gEnabledMods);

                // Todo
                var builder = ModBuilderManager.GetCompatibleModBuilders(SelectedGame).First().Create();
                if (UltraISOUtility.Available)
                {
                    if (SelectedGame == Game.Persona3)
                    {
                        builder = new Persona3IsoModBuilder();
                    }
                    else if (SelectedGame == Game.Persona4)
                    {
                        builder = new Persona4IsoModBuilder();
                    }
                }

                Log.General.Info($"Output path: {GameConfig.OutputDirectoryPath}");

#if !DEBUG
                try
#endif
                {
                    builder.Build(merged, gEnabledMods, GameConfig.OutputDirectoryPath);
                }
 #if !DEBUG
                catch (InvalidConfigException exception)
                {
                    InvokeOnUIThread(
                        () => MessageBox.Show(this, $"SelectedGame configuration is invalid.\n{exception.Message}", "Error",
                                              MessageBoxButton.OK, MessageBoxImage.Error));

                    return(false);
                }
                catch (MissingFileException exception)
                {
                    InvokeOnUIThread(
                        () => MessageBox.Show(this, $"A file is missing:\n{exception.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error));

                    return(false);
                }
                catch (Exception exception)
                {
                    InvokeOnUIThread(
                        () =>
                        MessageBox.Show(
                            this, $"Unhandled exception occured while building:\n{exception.Message}\n{exception.StackTrace}", "Error",
                            MessageBoxButton.OK, MessageBoxImage.Error));

#if DEBUG
                    throw;
#endif

#pragma warning disable 162
                    return(false);

#pragma warning restore 162
                }
#endif

                return(true);
            }, TaskCreationOptions.AttachedToParent);

            task.ContinueWith((t) =>
            {
                InvokeOnUIThread(() =>
                {
                    if (t.Result)
                    {
                        MessageBox.Show(this, "Done building!", "Done", MessageBoxButton.OK, MessageBoxImage.None);
                        RunModScripts(gEnabledMods, "postbuild.bat");
                    }
                });
            });
        }
Exemple #31
0
 private void RefreshModDatabase()
 {
     ModDatabase.Initialize();
     RefreshMods();
 }