public static TelemetryPackage GetTelemetryPackageForDLC(Mod.MEGame game, string dlcDirectory, string dlcFoldername, string destinationDLCName, string modName, string modAuthor, string modSite, Mod telemetryMod)
        {
            TelemetryPackage tp = new TelemetryPackage();
            var sourceDir       = Path.Combine(dlcDirectory, dlcFoldername);

            tp.DLCFolderName = destinationDLCName; //this most times will be the same as dlcFoldername, but in case of alternates, it might not be
            if (telemetryMod != null && telemetryMod.HumanReadableCustomDLCNames.TryGetValue(dlcFoldername, out var modNameIni))
            {
                tp.ModName = modNameIni;
            }
            else
            {
                tp.ModName = modName;
            }

            tp.ModAuthor = modAuthor;
            tp.ModSite   = modSite;
            tp.Game      = game;
            switch (game)
            {
            case Mod.MEGame.ME1:
            {
                var ini       = new FileIniDataParser();
                var parsedIni = ini.Parser.Parse(File.ReadAllText(Path.Combine(sourceDir, @"AutoLoad.ini")));
                tp.MountPriority = int.Parse(parsedIni[@"ME1DLCMOUNT"][@"ModMount"]);
                tp.ModMountTLK1  = int.Parse(parsedIni[@"GUI"][@"NameStrRef"]);
                tp.MountFlagHR   = M3L.GetString(M3L.string_me1MountFlagsNotSupportedInM3);
                //No mount flag right now.
            }
            break;

            case Mod.MEGame.ME2:
            {
                var       mountFile = Path.Combine(sourceDir, @"CookedPC", @"mount.dlc");
                MountFile mf        = new MountFile(mountFile);
                tp.ModMountTLK1  = mf.TLKID;
                tp.MountPriority = mf.MountPriority;
                tp.MountFlag     = (int)mf.MountFlag;
                tp.MountFlagHR   = mf.MountFlag.ToString();
                var ini       = new FileIniDataParser();
                var parsedIni = ini.Parser.Parse(File.ReadAllText(Path.Combine(sourceDir, @"CookedPC", @"BIOEngine.ini")));
                tp.ModuleNumber = parsedIni[@"Engine.DLCModules"][dlcFoldername];
            }
            break;

            case Mod.MEGame.ME3:
            {
                var       mountFile = Path.Combine(sourceDir, @"CookedPCConsole", @"mount.dlc");
                MountFile mf        = new MountFile(mountFile);
                tp.ModMountTLK1  = mf.TLKID;
                tp.MountPriority = mf.MountPriority;
                tp.MountFlag     = (int)mf.MountFlag;
                tp.MountFlagHR   = mf.MountFlag.ToString();
            }
            break;
            }

            return(tp);
        }
Example #2
0
        public void TestMounts()
        {
            GlobalTest.Init();
            // Loads compressed packages and attempts to enumerate every object's properties.
            var packagesPath = GlobalTest.GetTestMountsDirectory();
            var mounts       = Directory.GetFiles(packagesPath, "*.dlc", SearchOption.AllDirectories);

            foreach (var mountFilePath in mounts)
            {
                // Do not use package caching in tests
                Debug.WriteLine($"Opening mount file {mountFilePath}");

                (MEGame expectedGame, MEPackage.GamePlatform expectedPlatform) = GlobalTest.GetExpectedTypes(mountFilePath);
                var mountFName = Path.GetFileNameWithoutExtension(mountFilePath);
                var mountProps = mountFName.Split('-');

                var mountName = mountProps[0];

                var            expectedMountPriority = ushort.Parse(mountProps[1]);
                var            expectedMountTLK      = int.Parse(mountProps[2]);
                EMountFileFlag expectedMountFlag     = (EMountFileFlag)byte.Parse(mountProps[3], NumberStyles.HexNumber);

                string me2DlcName   = expectedGame == MEGame.ME2 ? mountProps[4] : null;
                string me2HRDlcName = expectedGame == MEGame.ME2 ? mountProps[5] : null;


                MountFile mf = new MountFile(mountFilePath);
                Assert.AreEqual(expectedGame == MEGame.ME2, mf.IsME2, $"Mount file {mountName} parsed to the wrong game");
                Assert.AreEqual(expectedMountPriority, mf.MountPriority, $"Mount file {mountName} has wrong parsed mount priority");
                Assert.AreEqual(expectedMountTLK, mf.TLKID, $"Mount file {mountName} has wrong parsed mount TLKID");
                Assert.AreEqual(expectedMountFlag, mf.MountFlag, $"Mount file {mountName} has wrong parsed mount flag");
                if (expectedGame == MEGame.ME2)
                {
                    Assert.AreEqual(me2DlcName, mf.ME2Only_DLCFolderName, $"Mount file {mountName} has wrong DLC folder name");
                    Assert.AreEqual(me2HRDlcName, mf.ME2Only_DLCHumanName, $"Mount file {mountName} has wrong human name");
                }
            }
        }
Example #3
0
        private void GatherTelemetryDataBGThread(object sender, DoWorkEventArgs e)
        {
            List <TelemetryPackage> telemetryPackages = new List <TelemetryPackage>();

            foreach (var mapping in TelemetryMod.GetJob(ModJob.JobHeader.CUSTOMDLC).CustomDLCFolderMapping)
            {
                TelemetryPackage tp = new TelemetryPackage();
                var sourceDir       = mapping.Key;
                tp.DLCFolderName = mapping.Value;
                if (TelemetryMod.HumanReadableCustomDLCNames.TryGetValue(mapping.Value, out var modName))
                {
                    tp.ModName = modName;
                }
                else
                {
                    tp.ModName = TelemetryMod.ModName;
                }

                tp.ModAuthor = TelemetryMod.ModDeveloper;
                tp.ModSite   = TelemetryMod.ModWebsite;
                tp.Game      = TelemetryMod.Game;
                switch (TelemetryMod.Game)
                {
                case Mod.MEGame.ME1:
                {
                    var ini       = new FileIniDataParser();
                    var parsedIni = ini.Parser.Parse(File.ReadAllText(Path.Combine(TelemetryMod.ModPath, mapping.Key, "AutoLoad.ini")));
                    tp.MountPriority = int.Parse(parsedIni["ME1DLCMOUNT"]["ModMount"]);
                    tp.ModMountTLK1  = int.Parse(parsedIni["GUI"]["NameStrRef"]);
                    tp.MountFlagHR   = "ME1 does not support mount flags in M3 currently";
                    //No mount flag right now.
                }
                break;

                case Mod.MEGame.ME2:
                {
                    var       mountFile = Path.Combine(TelemetryMod.ModPath, mapping.Key, "CookedPC", "mount.dlc");
                    MountFile mf        = new MountFile(mountFile);
                    tp.ModMountTLK1  = mf.TLKID;
                    tp.MountPriority = mf.MountPriority;
                    tp.MountFlag     = (int)mf.MountFlag;
                    tp.MountFlagHR   = mf.MountFlag.ToString();
                    var ini       = new FileIniDataParser();
                    var parsedIni = ini.Parser.Parse(File.ReadAllText(Path.Combine(TelemetryMod.ModPath, mapping.Key, "CookedPC", "BIOEngine.ini")));
                    tp.ModuleNumber = parsedIni["Engine.DLCModules"][mapping.Key];
                }
                break;

                case Mod.MEGame.ME3:
                {
                    var       mountFile = Path.Combine(TelemetryMod.ModPath, mapping.Key, "CookedPCConsole", "mount.dlc");
                    MountFile mf        = new MountFile(mountFile);
                    tp.ModMountTLK1  = mf.TLKID;
                    tp.MountPriority = mf.MountPriority;
                    tp.MountFlag     = (int)mf.MountFlag;
                    tp.MountFlagHR   = mf.MountFlag.ToString();
                }
                break;
                }
                telemetryPackages.Add(tp);
            }

            e.Result = telemetryPackages;
        }
        public static TelemetryPackage GetTelemetryPackageForDLC(MEGame game, string dlcDirectory, string dlcFoldername, string destinationDLCName, string modName, string modAuthor, string modSite, Mod telemetryMod)
        {
            try
            {
                TelemetryPackage tp = new TelemetryPackage();
                var sourceDir       = Path.Combine(dlcDirectory, dlcFoldername);
                tp.DLCFolderName = destinationDLCName; //this most times will be the same as dlcFoldername, but in case of alternates, it might not be
                if (telemetryMod != null && telemetryMod.HumanReadableCustomDLCNames.TryGetValue(dlcFoldername, out var modNameIni))
                {
                    tp.ModName = modNameIni;
                }
                else
                {
                    tp.ModName = modName;
                }

                tp.ModAuthor = modAuthor;
                tp.ModSite   = modSite;
                tp.Game      = game;
                switch (game)
                {
                case MEGame.LE1:
                case MEGame.ME1:
                {
                    var parsedIni = DuplicatingIni.LoadIni(Path.Combine(sourceDir, @"AutoLoad.ini"));
                    tp.MountPriority = int.Parse(parsedIni[@"ME1DLCMOUNT"][@"ModMount"]?.Value);
                    tp.ModMountTLK1  = int.Parse(parsedIni[@"GUI"][@"NameStrRef"]?.Value);
                    tp.MountFlagHR   = M3L.GetString(M3L.string_me1MountFlagsNotSupportedInM3);
                    //No mount flag right now.
                }
                break;

                case MEGame.ME2:
                case MEGame.LE2:
                {
                    var       mountFile = Path.Combine(sourceDir, game.CookedDirName(), @"mount.dlc");
                    MountFile mf        = new MountFile(mountFile);
                    tp.ModMountTLK1  = mf.TLKID;
                    tp.MountPriority = mf.MountPriority;
                    tp.MountFlag     = (int)mf.MountFlags.FlagValue;
                    tp.MountFlagHR   = mf.MountFlags.ToHumanReadableString();
                    var ini = DuplicatingIni.LoadIni(Path.Combine(sourceDir, game.CookedDirName(), @"BIOEngine.ini"));
                    tp.ModuleNumber = ini[@"Engine.DLCModules"][dlcFoldername]?.Value;
                }
                break;

                case MEGame.ME3:
                case MEGame.LE3:
                {
                    var       mountFile = Path.Combine(sourceDir, @"CookedPCConsole", @"mount.dlc");
                    MountFile mf        = new MountFile(mountFile);
                    tp.ModMountTLK1  = mf.TLKID;
                    tp.MountPriority = mf.MountPriority;
                    tp.MountFlag     = mf.MountFlags.FlagValue;
                    tp.MountFlagHR   = mf.MountFlags.ToHumanReadableString();
                }
                break;
                }

                return(tp);
            }
            catch (Exception e)
            {
                Log.Error($@"Error building telemetry package for {dlcFoldername}: {e.Message}.");
                return(null);
            }
        }