Esempio n. 1
0
        internal static void BuildCachedManifest()
        {
            // First load the default battletech manifest, then it'll get appended to
            VersionManifest vanillaManifest = VersionManifestUtilities.LoadDefaultManifest();

            // Wrapper to be able to submit a parameterless work function
            IEnumerator <ProgressReport> NestedFunc()
            {
                IEnumerator <ProgressReport> reports = BuildCachedManifestLoop(vanillaManifest);

                while (reports.MoveNext())
                {
                    yield return(reports.Current);
                }
            }

            ProgressPanel.SubmitWork(NestedFunc);
        }
Esempio n. 2
0
        public static void Init()
        {
            stopwatch.Start();

            // if the manifest directory is null, there is something seriously wrong
            var manifestDirectory = Path.GetDirectoryName(VersionManifestUtilities.MANIFEST_FILEPATH);

            if (manifestDirectory == null)
            {
                return;
            }

            // setup directories
            ModsDirectory = Path.GetFullPath(
                Path.Combine(manifestDirectory,
                             Path.Combine(Path.Combine(Path.Combine(
                                                           "..", ".."), ".."), MODS_DIRECTORY_NAME)));

            StreamingAssetsDirectory = Path.GetFullPath(Path.Combine(manifestDirectory, ".."));
            GameDirectory            = Path.GetFullPath(Path.Combine(Path.Combine(StreamingAssetsDirectory, ".."), ".."));
            MDDBPath = Path.Combine(Path.Combine(StreamingAssetsDirectory, "MDD"), MDD_FILE_NAME);

            ModTekDirectory   = Path.Combine(ModsDirectory, MODTEK_DIRECTORY_NAME);
            CacheDirectory    = Path.Combine(ModTekDirectory, CACHE_DIRECTORY_NAME);
            DatabaseDirectory = Path.Combine(ModTekDirectory, DATABASE_DIRECTORY_NAME);

            LogPath            = Path.Combine(ModTekDirectory, LOG_NAME);
            HarmonySummaryPath = Path.Combine(ModTekDirectory, HARMONY_SUMMARY_FILE_NAME);
            LoadOrderPath      = Path.Combine(ModTekDirectory, LOAD_ORDER_FILE_NAME);
            MergeCachePath     = Path.Combine(CacheDirectory, MERGE_CACHE_FILE_NAME);
            TypeCachePath      = Path.Combine(CacheDirectory, TYPE_CACHE_FILE_NAME);
            ModMDDBPath        = Path.Combine(DatabaseDirectory, MDD_FILE_NAME);
            DBCachePath        = Path.Combine(DatabaseDirectory, DB_CACHE_FILE_NAME);

            // creates the directories above it as well
            Directory.CreateDirectory(CacheDirectory);
            Directory.CreateDirectory(DatabaseDirectory);

            // create log file, overwritting if it's already there
            using (var logWriter = File.CreateText(LogPath))
            {
                logWriter.WriteLine($"ModTek v{Assembly.GetExecutingAssembly().GetName().Version} -- {DateTime.Now}");
            }

            // create all of the caches
            dbCache        = LoadOrCreateDBCache(DBCachePath);
            jsonMergeCache = LoadOrCreateMergeCache(MergeCachePath);
            typeCache      = LoadOrCreateTypeCache(TypeCachePath);

            // First step in setting up the progress panel
            if (ProgressPanel.Initialize(ModsDirectory, $"ModTek v{Assembly.GetExecutingAssembly().GetName().Version}"))
            {
                // init harmony and patch the stuff that comes with ModTek (contained in Patches.cs)
                var harmony = HarmonyInstance.Create("io.github.mpstark.ModTek");
                harmony.PatchAll(Assembly.GetExecutingAssembly());

                LoadMods();

                BuildCachedManifest();
            }
            else
            {
                Log("Failed to load progress bar.  Skipping mod loading completely.");
            }

            stopwatch.Stop();
        }
Esempio n. 3
0
 internal static void LoadMods()
 {
     ProgressPanel.SubmitWork(ModTek.LoadMoadsLoop);
 }
Esempio n. 4
0
 internal static void BuildModManifestEntries()
 {
     CachedVersionManifest = VersionManifestUtilities.LoadDefaultManifest();
     ProgressPanel.SubmitWork(BuildModManifestEntriesLoop);
 }