public void TestEmuBlacklistWithDifferentTrueAndFalseValues(string blackList, bool detected) { // Arrange // Act // Assert Assert.Equal(detected, EmuBlacklist.CheckForBlacklist(blackList)); }
/// <summary> /// Validates that the game exists and then runs it with the emulator. /// </summary> /// <param name="gameProfile">Input profile.</param> public static bool ValidateAndRun(GameProfile gameProfile, out string loaderExe, out string loaderDll, bool emuOnly, Library library, bool _test) { loaderDll = string.Empty; loaderExe = string.Empty; bool is64Bit = _test ? gameProfile.TestExecIs64Bit : gameProfile.Is64Bit; // don't attempt to run 64 bit game on non-64 bit OS if (is64Bit && !App.Is64Bit()) { MessageBoxHelper.ErrorOK(Properties.Resources.Library64bit); return(false); } if (emuOnly) { return(true); } loaderExe = is64Bit ? ".\\OpenParrotx64\\OpenParrotLoader64.exe" : ".\\OpenParrotWin32\\OpenParrotLoader.exe"; loaderDll = string.Empty; switch (gameProfile.EmulatorType) { case EmulatorType.Lindbergh: loaderExe = ".\\TeknoParrot\\BudgieLoader.exe"; break; case EmulatorType.N2: loaderExe = ".\\N2\\BudgieLoader.exe"; break; case EmulatorType.ElfLdr2: loaderExe = ".\\ElfLdr2\\BudgieLoader.exe"; break; case EmulatorType.OpenParrot: loaderDll = (is64Bit ? ".\\OpenParrotx64\\OpenParrot64" : ".\\OpenParrotWin32\\OpenParrot"); break; case EmulatorType.OpenParrotKonami: loaderExe = ".\\OpenParrotWin32\\OpenParrotKonamiLoader.exe"; break; case EmulatorType.SegaTools: File.Copy(".\\SegaTools\\aimeio.dll", Path.GetDirectoryName(gameProfile.GamePath) + "\\aimeio.dll", true); File.Copy(".\\SegaTools\\idzhook.dll", Path.GetDirectoryName(gameProfile.GamePath) + "\\idzhook.dll", true); File.Copy(".\\SegaTools\\idzio.dll", Path.GetDirectoryName(gameProfile.GamePath) + "\\idzio.dll", true); File.Copy(".\\SegaTools\\inject.exe", Path.GetDirectoryName(gameProfile.GamePath) + "\\inject.exe", true); loaderExe = ".\\SegaTools\\inject.exe"; loaderDll = "idzhook"; break; default: loaderDll = (is64Bit ? ".\\TeknoParrot\\TeknoParrot64" : ".\\TeknoParrot\\TeknoParrot"); break; } if (!File.Exists(loaderExe)) { MessageBoxHelper.ErrorOK(string.Format(Properties.Resources.LibraryCantFindLoader, loaderExe)); return(false); } var dll_filename = loaderDll + ".dll"; if (loaderDll != string.Empty && !File.Exists(dll_filename) && gameProfile.EmulationProfile != EmulationProfile.SegaToolsIDZ) { MessageBoxHelper.ErrorOK(string.Format(Properties.Resources.LibraryCantFindLoader, dll_filename)); return(false); } if (string.IsNullOrEmpty(gameProfile.GamePath)) { MessageBoxHelper.ErrorOK(Properties.Resources.LibraryGameLocationNotSet); return(false); } if (!File.Exists(gameProfile.GamePath)) { MessageBoxHelper.ErrorOK(string.Format(Properties.Resources.LibraryCantFindGame, gameProfile.GamePath)); return(false); } // Check second exe if (gameProfile.HasTwoExecutables) { if (string.IsNullOrEmpty(gameProfile.GamePath2)) { MessageBoxHelper.ErrorOK(Properties.Resources.LibraryGameLocation2NotSet); return(false); } if (!File.Exists(gameProfile.GamePath2)) { MessageBoxHelper.ErrorOK(string.Format(Properties.Resources.LibraryCantFindGame, gameProfile.GamePath)); return(false); } } if (gameProfile.EmulationProfile == EmulationProfile.FastIo || gameProfile.EmulationProfile == EmulationProfile.Theatrhythm) { if (!CheckiDMAC(gameProfile.GamePath, gameProfile.Is64Bit)) { return(false); } } if (gameProfile.RequiresAdmin) { using (var identity = WindowsIdentity.GetCurrent()) { var admin = new WindowsPrincipal(identity).IsInRole(WindowsBuiltInRole.Administrator); if (!admin) { if (!MessageBoxHelper.WarningYesNo(string.Format(Properties.Resources.LibraryNeedsAdmin, gameProfile.GameName))) { return(false); } } } } EmuBlacklist bl = new EmuBlacklist(gameProfile.GamePath); EmuBlacklist bl2 = new EmuBlacklist(gameProfile.GamePath2); if (bl.FoundProblem || bl2.FoundProblem) { string err = "It seems you have another emulator already in use.\nThis will most likely cause problems."; if (bl.FilesToRemove.Count > 0 || bl2.FilesToRemove.Count > 0) { err += "\n\nRemove the following files:\n"; err += String.Join("\n", bl.FilesToRemove); err += String.Join("\n", bl2.FilesToRemove); } if (bl.FilesToClean.Count > 0 || bl2.FilesToClean.Count > 0) { err += "\n\nReplace the following patched files by the originals:\n"; err += String.Join("\n", bl.FilesToClean); err += String.Join("\n", bl2.FilesToClean); } err += "\n\nContinue?"; if (!MessageBoxHelper.ErrorYesNo(err)) { return(false); } } if (gameProfile.InvalidFiles != null) { string[] filesToDelete = gameProfile.InvalidFiles.Split(','); List <string> filesThatExist = new List <string>(); foreach (var file in filesToDelete) { if (File.Exists(Path.Combine(Path.GetDirectoryName(gameProfile.GamePath), file))) { filesThatExist.Add(file); } } if (filesThatExist.Count > 0) { var errorMsg = Properties.Resources.LibraryInvalidFiles; foreach (var fileName in filesThatExist) { errorMsg += fileName + Environment.NewLine; } errorMsg += Properties.Resources.LibraryInvalidFilesContinue; if (!MessageBoxHelper.WarningYesNo(errorMsg)) { return(false); } } } // Check raw input profile if (gameProfile.ConfigValues.Any(x => x.FieldName == "Input API" && x.FieldValue == "RawInput")) { bool fixedSomething = false; var _joystickControlRawInput = new JoystickControlRawInput(); foreach (var t in gameProfile.JoystickButtons) { // Binded key without device path if (!string.IsNullOrWhiteSpace(t.BindNameRi) && string.IsNullOrWhiteSpace(t.RawInputButton.DevicePath)) { Debug.WriteLine("Keybind without path: button: {0} bind: {1}", t.ButtonName, t.BindNameRi); // Handle special binds first if (t.BindNameRi == "Windows Mouse Cursor") { t.RawInputButton.DevicePath = "Windows Mouse Cursor"; fixedSomething = true; } else if (t.BindNameRi == "None") { t.RawInputButton.DevicePath = "None"; fixedSomething = true; } else if (t.BindNameRi.ToLower().StartsWith("unknown device")) { t.RawInputButton.DevicePath = "null"; fixedSomething = true; } else { // Find device RawInputDevice device = null; if (t.RawInputButton.DeviceType == RawDeviceType.Mouse) { device = _joystickControlRawInput.GetMouseDeviceByBindName(t.BindNameRi); } else if (t.RawInputButton.DeviceType == RawDeviceType.Keyboard) { device = _joystickControlRawInput.GetKeyboardDeviceByBindName(t.BindNameRi); } if (device != null) { Debug.WriteLine("Device found: " + device.DevicePath); t.RawInputButton.DevicePath = device.DevicePath; fixedSomething = true; } else { Debug.WriteLine("Could not find device!"); } } } } // Save profile and reload library if (fixedSomething) { JoystickHelper.SerializeGameProfile(gameProfile); library.ListUpdate(gameProfile.GameName); } } return(true); }