public GameTarget(Mod.MEGame game, string target, bool currentRegistryActive, bool isCustomOption = false) { this.Game = game; this.RegistryActive = currentRegistryActive; this.IsCustomOption = isCustomOption; this.TargetPath = target.TrimEnd('\\'); if (game != Mod.MEGame.Unknown && !IsCustomOption) { var alotInfo = GetInstalledALOTInfo(); if (alotInfo != null) { ALOTInstalled = true; ALOTVersion = alotInfo.ToString(); } Log.Information("Getting game source for target " + TargetPath); var hashCheckResult = VanillaDatabaseService.GetGameSource(this); GameSource = hashCheckResult.result; if (GameSource == null) { Log.Error("Unknown source or illegitimate installation: " + hashCheckResult.hash); } else { Log.Information("Source: " + GameSource); } IsPolishME1 = game == Mod.MEGame.ME1 && File.Exists(Path.Combine(target, "BioGame", "CookedPC", "Movies", "niebieska_pl.bik")); if (IsPolishME1) { Log.Information("ME1 Polish Edition detected"); } } }
/// <summary> /// Gets a Dictionary of all loaded files in the given target. Key is the filename, value is file path /// </summary> /// <param name="target">Game target</param> /// <returns>Mapping of files</returns> public static Dictionary <string, string> GetFilesLoadedInGame(GameTarget target, bool includeTFC = false, bool includeBasegame = true) { Mod.MEGame game = target.Game; //make dictionary from basegame files var loadedFiles = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase); var directories = GetEnabledDLC(target).OrderBy(dir => GetMountPriority(dir, target.Game)); if (includeBasegame) { directories.Prepend(MEDirectories.BioGamePath(target)); } foreach (string directory in directories) { foreach (string filePath in GetCookedFiles(target.Game, directory, includeTFC)) { string fileName = Path.GetFileName(filePath); if (fileName != null) { loadedFiles[fileName] = filePath; } } } return(loadedFiles); }
public OIGGame(Mod.MEGame game, IEnumerable <GameTarget> targets) { Game = game; Targets.ReplaceAll(targets); ToggleDisablerCommand = new GenericCommand(ToggleDisabler, CanToggleDisabler); switch (Game) { case Mod.MEGame.ME1: GameTitle = @"Mass Effect"; GameIconSource = @"/images/gameicons/ME1_48.ico"; break; case Mod.MEGame.ME2: GameTitle = @"Mass Effect 2"; GameIconSource = @"/images/gameicons/ME2_48.ico"; break; case Mod.MEGame.ME3: GameTitle = @"Mass Effect 3"; GameIconSource = @"/images/gameicons/ME3_48.ico"; break; } SelectedTarget = Targets.FirstOrDefault(); if (SelectedTarget == null) { D3D9Status = M3L.GetString(M3L.string_noOriginBasedTargetsInstalledForThisGame); } }
public GameBackup(Mod.MEGame game, IEnumerable <GameTarget> availableBackupSources, MainWindow window) { this.window = window; this.Game = game; this.AvailableBackupSources.AddRange(availableBackupSources); this.AvailableBackupSources.Add(new GameTarget(Game, M3L.GetString(M3L.string_linkBackupToAnExistingGameCopy), false, true)); LoadCommands(); switch (Game) { case Mod.MEGame.ME1: GameTitle = @"Mass Effect"; GameIconSource = @"/images/gameicons/ME1_48.ico"; break; case Mod.MEGame.ME2: GameTitle = @"Mass Effect 2"; GameIconSource = @"/images/gameicons/ME2_48.ico"; break; case Mod.MEGame.ME3: GameTitle = @"Mass Effect 3"; GameIconSource = @"/images/gameicons/ME3_48.ico"; break; } ResetBackupStatus(); }
private Dictionary <string, List <string> > getFileSupercedances() { Mod.MEGame game = target.Game; //make dictionary from basegame files var fileListMapping = new CaseInsensitiveDictionary <List <string> >(); var directories = MELoadedFiles.GetEnabledDLC(target).OrderBy(dir => MELoadedFiles.GetMountPriority(dir, target.Game)); foreach (string directory in directories) { var dlc = Path.GetFileName(directory); if (MEDirectories.OfficialDLC(target.Game).Contains(dlc)) { continue; //skip } foreach (string filePath in MELoadedFiles.GetCookedFiles(target.Game, directory, false)) { string fileName = Path.GetFileName(filePath); if (fileName != null && fileName.RepresentsPackageFilePath()) { if (fileListMapping.TryGetValue(fileName, out var supercedingList)) { supercedingList.Insert(0, dlc); } else { fileListMapping[fileName] = new List <string>(new[] { dlc }); } } } } return(fileListMapping); }
public GameRestoreObject(Mod.MEGame game, IEnumerable <GameTarget> availableBackupSources, Window window) { this.window = window; this.Game = game; this.AvailableBackupSources.AddRange(availableBackupSources); AvailableBackupSources.Add(new GameTarget(Game, "Restore to custom location", false, true)); LoadCommands(); switch (Game) { case Mod.MEGame.ME1: GameTitle = "Mass Effect"; GameIconSource = "/images/gameicons/ME1_48.ico"; break; case Mod.MEGame.ME2: GameTitle = "Mass Effect 2"; GameIconSource = "/images/gameicons/ME2_48.ico"; break; case Mod.MEGame.ME3: GameTitle = "Mass Effect 3"; GameIconSource = "/images/gameicons/ME3_48.ico"; break; } ResetRestoreStatus(); }
public GameBackup(Mod.MEGame game, IEnumerable <GameTarget> availableBackupSources, Window window) { this.window = window; this.Game = game; this.AvailableBackupSources.AddRange(availableBackupSources); LoadCommands(); switch (Game) { case Mod.MEGame.ME1: GameTitle = @"Mass Effect"; GameIconSource = @"/images/gameicons/ME1_48.ico"; break; case Mod.MEGame.ME2: GameTitle = @"Mass Effect 2"; GameIconSource = @"/images/gameicons/ME2_48.ico"; break; case Mod.MEGame.ME3: GameTitle = @"Mass Effect 3"; GameIconSource = @"/images/gameicons/ME3_48.ico"; break; } ResetBackupStatus(); }
private void TryChangeGameTo(Mod.MEGame newgame) { if (newgame == SelectedGame) { return; //don't care } if (ModsInGroup.Count > 0 && newgame != SelectedGame) { var result = M3L.ShowDialog(this, M3L.GetString(M3L.string_dialog_changingGameWillClearGroup), M3L.GetString(M3L.string_changingGameWillClearGroup), MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { ModsInGroup.ClearEx(); SelectedGame = newgame; } else { //reset choice SetGameRadioUI(SelectedGame); //reset back } } else { SelectedGame = newgame; } }
/// <summary> /// Gets the type of an array /// </summary> /// <param name="game">What game we are looking info for</param> /// <param name="propName">Name of the array property</param> /// <param name="className">Name of the class that should contain the information. If contained in a struct, this will be the name of the struct type</param> /// <param name="parsingEntry">Entry that is being parsed. Used for dynamic lookup if it's not in the DB</param> /// <returns></returns> public static ArrayType GetArrayType(Mod.MEGame game, string propName, string className, IEntry parsingEntry = null) { switch (game) { case Mod.MEGame.ME1: return(ME1UnrealObjectInfo.getArrayType(className, propName, export: parsingEntry as ExportEntry)); case Mod.MEGame.ME2: var res2 = ME2UnrealObjectInfo.getArrayType(className, propName, export: parsingEntry as ExportEntry); #if DEBUG //For debugging only! if (res2 == ArrayType.Int && ME2UnrealObjectInfo.ArrayTypeLookupJustFailed) { ME2UnrealObjectInfo.ArrayTypeLookupJustFailed = false; Debug.WriteLine("[ME2] Array type lookup failed for " + propName + " in class " + className + " in export " + parsingEntry.FileRef.GetEntryString(parsingEntry.UIndex)); } #endif return(res2); case Mod.MEGame.ME3: var res = ME3UnrealObjectInfo.getArrayType(className, propName, export: parsingEntry as ExportEntry); #if DEBUG //For debugging only! if (res == ArrayType.Int && ME3UnrealObjectInfo.ArrayTypeLookupJustFailed) { Debug.WriteLine("[ME3] Array type lookup failed for " + propName + " in class " + className + " in export " + parsingEntry.FileRef.GetEntryString(parsingEntry.UIndex)); ME3UnrealObjectInfo.ArrayTypeLookupJustFailed = false; } #endif return(res); } return(ArrayType.Int); }
/// <summary> ///// Fetches the specified ASI by it's hash for the specified game /// </summary> /// <param name="asi"></param> /// <returns></returns> public static ASIModVersion GetASIVersionByHash(string hash, Mod.MEGame game) { List <ASIMod> relevantGroups = null; switch (game) { case Mod.MEGame.ME1: relevantGroups = MasterME1ASIUpdateGroups; break; case Mod.MEGame.ME2: relevantGroups = MasterME2ASIUpdateGroups; break; case Mod.MEGame.ME3: relevantGroups = MasterME3ASIUpdateGroups; break; default: return(null); } if (relevantGroups.Any()) { return(relevantGroups.FirstOrDefault(x => x.HashMatchingHash(hash))?.Versions.First(x => x.Hash == hash)); } return(null); }
internal static List <GameTarget> GetCachedTargets(Mod.MEGame game) { var cacheFile = GetCachedTargetsFile(game); if (File.Exists(cacheFile)) { List <GameTarget> targets = new List <GameTarget>(); foreach (var file in File.ReadAllLines(cacheFile)) { //Validate game directory GameTarget target = new GameTarget(game, file, false); var failureReason = target.ValidateTarget(); if (failureReason == null) { targets.Add(target); } else { Log.Error("Cached target for " + target.Game.ToString() + " is invalid: " + failureReason); } } return(targets); } else { return(new List <GameTarget>()); } }
public ASIGame(Mod.MEGame game, List <GameTarget> targets) { Game = game; GameTargets.ReplaceAll(targets); SelectedTarget = targets.FirstOrDefault(x => x.RegistryActive); InstallLoaderCommand = new GenericCommand(InstallLoader, CanInstallLoader); }
public static string GetGameBackupPath(Mod.MEGame game) { string path; switch (game) { case Mod.MEGame.ME1: path = Utilities.GetRegistrySettingString(App.BACKUP_REGISTRY_KEY, "ME1VanillaBackupLocation"); break; case Mod.MEGame.ME2: path = Utilities.GetRegistrySettingString(App.BACKUP_REGISTRY_KEY, "ME2VanillaBackupLocation"); break; case Mod.MEGame.ME3: //Check for backup via registry - Use Mod Manager's game backup key to find backup. path = Utilities.GetRegistrySettingString(App.REGISTRY_KEY_ME3CMM, "VanillaCopyLocation"); break; default: return(null); } if (path == null || !Directory.Exists(path)) { return(null); } //Super basic validation if (!Directory.Exists(path + @"\BIOGame") || !Directory.Exists(path + @"\Binaries")) { return(null); } return(path); }
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); }
public static List <string> EnumerateGameFiles(Mod.MEGame GameVersion, string searchPath, bool recurse = true, Predicate <string> predicate = null) { List <string> files = Directory.EnumerateFiles(searchPath, "*", recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).ToList(); files = EnumerateGameFiles(GameVersion, files, predicate); return(files); }
public static string GetDefaultKeybindsOverride(Mod.MEGame game) { var path = Utilities.GetKeybindsOverrideFolder(); if (game == Mod.MEGame.ME1) return Path.Combine(path, @"me1-bioinput.ini"); if (game == Mod.MEGame.ME2) return Path.Combine(path, @"me2-bioinput.ini"); if (game == Mod.MEGame.ME3) return Path.Combine(path, @"me3-bioinput.xml"); return null; }
public InstalledASIMod(string asiFile, Mod.MEGame game) { Game = game; InstalledPath = asiFile; Filename = Path.GetFileNameWithoutExtension(asiFile); Hash = BitConverter.ToString(System.Security.Cryptography.MD5.Create() .ComputeHash(File.ReadAllBytes(asiFile))).Replace(@"-", "").ToLower(); }
public GameTarget(Mod.MEGame game, string target, bool currentRegistryActive, bool isCustomOption = false) { this.Game = game; this.RegistryActive = currentRegistryActive; this.IsCustomOption = isCustomOption; this.TargetPath = target.TrimEnd('\\'); ReloadGameTarget(); }
public GameTarget(Mod.MEGame game, string targetRootPath, bool currentRegistryActive, bool isCustomOption = false) { this.Game = game; this.RegistryActive = currentRegistryActive; this.IsCustomOption = isCustomOption; this.TargetPath = targetRootPath.TrimEnd('\\'); MemoryAnalyzer.AddTrackedMemoryItem($@"{game} GameTarget {TargetPath} - IsCustomOption: {isCustomOption}", new WeakReference(this)); ReloadGameTarget(); }
//public static bool IsInOfficialDLC(this IMEPackage pcc) => IsInOfficialDLC(pcc.FilePath, pcc.Game); public static bool IsInOfficialDLC(string path, Mod.MEGame game) { if (game == Mod.MEGame.Unknown) { return(false); } string dlcPath = DLCPath(game); return(OfficialDLC(game).Any(dlcFolder => path.StartsWith(Path.Combine(dlcPath, dlcFolder)))); }
public static bool IsEnabledDLC(string dir, Mod.MEGame game) { string dlcName = Path.GetFileName(dir); if (game == Mod.MEGame.ME1) { return(ME1Directory.OfficialDLC.Contains(dlcName) || File.Exists(Path.Combine(dir, "AutoLoad.ini"))); } return(dlcName.StartsWith("DLC_") && File.Exists(GetMountDLCFromDLCDir(dir, game))); }
public static void WriteUnrealString(this Stream stream, string value, Mod.MEGame game) { if (game == Mod.MEGame.ME3) { stream.WriteUnrealStringUnicode(value); } else { stream.WriteUnrealStringASCII(value); } }
/// <summary> /// Gets DLC path based on specified game root and game. /// </summary> /// <param name="gameRoot"></param> /// <param name="game"></param> /// <returns></returns> internal static string DLCPath(string gameRoot, Mod.MEGame game) { if (game == Mod.MEGame.ME1) { return(Path.Combine(gameRoot, @"DLC")); } if (game == Mod.MEGame.ME2 || game == Mod.MEGame.ME3) { return(Path.Combine(gameRoot, "BioGame", @"DLC")); } return(null); }
/// <summary> /// Gets the default values for a struct /// </summary> /// <param name="game">Game to pull info from</param> /// <param name="typeName">Struct type name</param> /// <param name="stripTransients">Strip transients from the struct</param> /// <returns></returns> internal static PropertyCollection getDefaultStructValue(Mod.MEGame game, string typeName, bool stripTransients) { switch (game) { case Mod.MEGame.ME1: return(ME1UnrealObjectInfo.getDefaultStructValue(typeName, stripTransients)); case Mod.MEGame.ME2: return(ME2UnrealObjectInfo.getDefaultStructValue(typeName, stripTransients)); case Mod.MEGame.ME3: return(ME3UnrealObjectInfo.getDefaultStructValue(typeName, stripTransients)); } return(null); }
public static List <NameReference> GetEnumValues(Mod.MEGame game, string enumName, bool includeNone = false) { switch (game) { case Mod.MEGame.ME1: return(ME1UnrealObjectInfo.getEnumValues(enumName, includeNone)); case Mod.MEGame.ME2: return(ME2UnrealObjectInfo.getEnumValues(enumName, includeNone)); case Mod.MEGame.ME3: return(ME3UnrealObjectInfo.getEnumValues(enumName, includeNone)); } return(null); }
public static IEnumerable <string> GetCookedFiles(Mod.MEGame game, string directory, bool includeTFCs = false) { if (game == Mod.MEGame.ME1) { return(ME1FilePatterns.SelectMany(pattern => Directory.EnumerateFiles(Path.Combine(directory, "CookedPC"), pattern, SearchOption.AllDirectories))); } if (includeTFCs) { return(ME2and3FilePatternIncludeTFC.SelectMany(pattern => Directory.EnumerateFiles(Path.Combine(directory, game == Mod.MEGame.ME3 ? "CookedPCConsole" : "CookedPC"), pattern, SearchOption.AllDirectories))); } else { return(Directory.EnumerateFiles(Path.Combine(directory, game == Mod.MEGame.ME3 ? "CookedPCConsole" : "CookedPC"), ME2and3FilePattern)); } }
public static string CookedName(Mod.MEGame game) { switch (game) { case Mod.MEGame.ME1: case Mod.MEGame.ME2: return("CookedPC"); case Mod.MEGame.ME3: return("CookedPCConsole"); default: throw new ArgumentOutOfRangeException(nameof(game), game, null); } }
/// <summary> /// Gets a Dictionary of all loaded files in the given game. Key is the filename, value is file path /// </summary> /// <param name="game"></param> /// <returns></returns> public static Dictionary <string, string> GetFilesLoadedInGame(Mod.MEGame game, bool forceReload = false, bool includeTFC = false) { if (!forceReload) { if (game == Mod.MEGame.ME1 && cachedME1LoadedFiles != null) { return(cachedME1LoadedFiles); } if (game == Mod.MEGame.ME2 && cachedME2LoadedFiles != null) { return(cachedME2LoadedFiles); } if (game == Mod.MEGame.ME3 && cachedME3LoadedFiles != null) { return(cachedME3LoadedFiles); } } //make dictionary from basegame files var loadedFiles = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase); foreach (string directory in GetEnabledDLC(game).OrderBy(dir => GetMountPriority(dir, game)).Prepend(MEDirectories.BioGamePath(game))) { foreach (string filePath in GetCookedFiles(game, directory, includeTFC)) { string fileName = Path.GetFileName(filePath); if (fileName != null) { loadedFiles[fileName] = filePath; } } } if (game == Mod.MEGame.ME1) { cachedME1LoadedFiles = loadedFiles; } if (game == Mod.MEGame.ME2) { cachedME2LoadedFiles = loadedFiles; } if (game == Mod.MEGame.ME3) { cachedME3LoadedFiles = loadedFiles; } return(loadedFiles); }
internal static object GetGameName(Mod.MEGame game) { if (game == Mod.MEGame.ME1) { return("Mass Effect"); } if (game == Mod.MEGame.ME2) { return("Mass Effect 2"); } if (game == Mod.MEGame.ME3) { return("Mass Effect 3"); } return("Error: Unknown game"); }
public static string GetModDirectoryForGame(Mod.MEGame game) { if (game == Mod.MEGame.ME1) { return(GetME1ModsDirectory()); } if (game == Mod.MEGame.ME2) { return(GetME2ModsDirectory()); } if (game == Mod.MEGame.ME3) { return(GetME3ModsDirectory()); } return(null); }