private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { JoystickHelper.SerializeGameProfile(_gameProfile); _comboItem.Tag = _gameProfile; Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, "Joystick Settings")); _contentControl.Content = _library; }
private void BtnSaveSettings(object sender, RoutedEventArgs e) { string inputApiString = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Input API")?.FieldValue; if (inputApiString != null) { _inputApi = (InputApi)Enum.Parse(typeof(InputApi), inputApiString); } foreach (var t in _gameProfile.JoystickButtons) { if (_inputApi == InputApi.DirectInput) { t.BindName = t.BindNameDi; } else if (_inputApi == InputApi.XInput) { t.BindName = t.BindNameXi; } else if (_inputApi == InputApi.RawInput) { t.BindName = t.BindNameRi; } } JoystickHelper.SerializeGameProfile(_gameProfile); _gameProfile.GamePath = GamePathBox.Text; Lazydata.GamePath = GamePathBox.Text; JoystickHelper.SerializeGameProfile(_gameProfile); _comboItem.Tag = _gameProfile; Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, System.IO.Path.GetFileName(_gameProfile.FileName))); _contentControl.Content = _library; }
private void BtnSaveSettings(object sender, RoutedEventArgs e) { _gameProfile.GamePath = GamePathBox.Text; Lazydata.GamePath = GamePathBox.Text; JoystickHelper.SerializeGameProfile(_gameProfile); _comboItem.Tag = _gameProfile; MessageBox.Show($"Generation of {System.IO.Path.GetFileName(_gameProfile.FileName)} was succesful!", "Save Complete", MessageBoxButton.OK, MessageBoxImage.Information); }
private void BtnSaveSettings(object sender, RoutedEventArgs e) { _gameProfile.GamePath = GamePathBox.Text; Lazydata.GamePath = GamePathBox.Text; JoystickHelper.SerializeGameProfile(_gameProfile); _comboItem.Tag = _gameProfile; Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, System.IO.Path.GetFileName(_gameProfile.FileName))); _contentControl.Content = _library; }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { // Save here, also save gamepath. if (Lazydata.GamePath != String.Empty) { _gameProfile.GamePath = Lazydata.GamePath; } JoystickHelper.SerializeGameProfile(_gameProfile); _comboItem.Tag = _gameProfile; MessageBox.Show("Save complete"); }
private void BtnSaveSettings(object sender, RoutedEventArgs e) { string inputApiString = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Input API")?.FieldValue; if (inputApiString != null) { _inputApi = (InputApi)Enum.Parse(typeof(InputApi), inputApiString); } foreach (var t in _gameProfile.JoystickButtons) { if (_inputApi == InputApi.DirectInput) { t.BindName = t.BindNameDi; } else if (_inputApi == InputApi.XInput) { t.BindName = t.BindNameXi; } else if (_inputApi == InputApi.RawInput) { t.BindName = t.BindNameRi; } } string NameString = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Submission Name")?.FieldValue; if (NameString != null) { if (_gameProfile.ConfigValues.Any(x => x.FieldName == "Enable Submission (Patreon Only)" && x.FieldValue == "1")) { if (_gameProfile.ConfigValues.Find(cv => cv.FieldName == "Submission Name").FieldValue == "") { MessageBox.Show("Score Submission requires a name!"); } } string[] badWords = new[] { "f**k", "c**t", "f*****t", "f*g", "dick", "shit", "c**k", "pussy", "ass", "asshole", "bitch", "h**o", "f****t", "a$$", "@ss", "f@g", "f****r", "f*****g", "fuk", "f****n", "fucken", "teknoparrot", "tp", "arse", "@rse", "@$$", "bastard", "crap", "effing", "god", "hell", "m**********r", "w***e", "twat", "gay", "g@y", "ash0le", "assh0le", "a$$hol", "anal", }; NameString = Filter(NameString, badWords); _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Submission Name").FieldValue = NameString; } JoystickHelper.SerializeGameProfile(_gameProfile); _gameProfile.GamePath = GamePathBox.Text; Lazydata.GamePath = GamePathBox.Text; JoystickHelper.SerializeGameProfile(_gameProfile); _comboItem.Tag = _gameProfile; Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, System.IO.Path.GetFileName(_gameProfile.FileName))); _library.ListUpdate(_gameProfile.GameName); _contentControl.Content = _library; }
private void CreateConfigValue() { var game = new GameProfile(); var f1 = new FieldInformation { CategoryName = "Network", FieldName = "Dhcp", FieldType = FieldType.Bool, FieldValue = "1" }; var f2 = new FieldInformation { CategoryName = "Network", FieldName = "Ip", FieldType = FieldType.Text, FieldValue = "192.168.1.2" }; var f3 = new FieldInformation { CategoryName = "Network", FieldName = "Mask", FieldType = FieldType.Text, FieldValue = "255.255.255.0" }; var f4 = new FieldInformation { CategoryName = "Network", FieldName = "Gateway", FieldType = FieldType.Text, FieldValue = "192.168.1.1" }; var f5 = new FieldInformation { CategoryName = "Network", FieldName = "Dns1", FieldType = FieldType.Text, FieldValue = "192.168.1.1" }; var f6 = new FieldInformation { CategoryName = "Network", FieldName = "Dns2", FieldType = FieldType.Text, FieldValue = "0.0.0.0" }; var f7 = new FieldInformation { CategoryName = "Network", FieldName = "BroadcastIP", FieldType = FieldType.Text, FieldValue = "192.168.1.255" }; var f8 = new FieldInformation { CategoryName = "Network", FieldName = "Cab1IP", FieldType = FieldType.Text, FieldValue = "192.168.1.2" }; var f9 = new FieldInformation { CategoryName = "Network", FieldName = "Cab2IP", FieldType = FieldType.Text, FieldValue = "192.168.1.3" }; var x1 = new FieldInformation { CategoryName = "General", FieldName = "DongleRegion", FieldType = FieldType.Text, FieldValue = "JAPAN" }; var x2 = new FieldInformation { CategoryName = "General", FieldName = "PcbRegion", FieldType = FieldType.Text, FieldValue = "JAPAN" }; var x3 = new FieldInformation { CategoryName = "General", FieldName = "FreePlay", FieldType = FieldType.Bool, FieldValue = "1" }; var x4 = new FieldInformation { CategoryName = "General", FieldName = "Windowed", FieldType = FieldType.Bool, FieldValue = "1" }; game.ConfigValues = new List <FieldInformation> { x1, x2, x3, x4, f1, f2, f3, f4, f5, f6, f7, f8, f9 }; game.FileName = "test.xml"; JoystickHelper.SerializeGameProfile(game); }
public override System.Diagnostics.ProcessStartInfo Generate(string system, string emulator, string core, string rom, string playersControllers, ScreenResolution resolution) { string path = AppConfig.GetFullPath("TeknoParrot"); string exe = Path.Combine(path, "TeknoParrotUi.exe"); if (!File.Exists(exe)) { return(null); } // ExtractUserProfiles("h:\\"); string gameName = Path.GetFileNameWithoutExtension(rom); GameProfile profile = FindGameProfile(path, rom, gameName); if (profile == null) { SimpleLogger.Instance.Error("Unable to find gameprofile for " + rom); return(new ProcessStartInfo() { FileName = "WARNING", Arguments = "Unable to find game profile.\r\nPlease make sure the game folder is named like the xml file in emulators/teknoparrot/GameProfiles folder or like the <GameName> element in the xml" }); } GameProfile userProfile = null; var userProfilePath = Path.Combine(Path.Combine(path, "UserProfiles", Path.GetFileName(profile.FileName))); if (File.Exists(userProfilePath)) { userProfile = JoystickHelper.DeSerializeGameProfile(userProfilePath, true); } else { JoystickHelper.SerializeGameProfile(profile, userProfilePath); userProfile = JoystickHelper.DeSerializeGameProfile(userProfilePath, true); } if (userProfile == null) { SimpleLogger.Instance.Error("Unable create userprofile for " + rom); return(new ProcessStartInfo() { FileName = "WARNING", Arguments = "Unable to create userprofile" }); } if (userProfile.GamePath == null || !File.Exists(userProfile.GamePath)) { userProfile.GamePath = FindExecutable(rom, Path.GetFileNameWithoutExtension(userProfile.FileName)); if (userProfile.GamePath == null) { userProfile.GamePath = FindBestExecutable(rom, userProfile.ExecutableName); } if (userProfile.GamePath == null) { SimpleLogger.Instance.Error("Unable to find Game executable for " + rom); return(new ProcessStartInfo() { FileName = "WARNING", Arguments = "Unable to find game executable" }); } } var windowed = userProfile.ConfigValues.FirstOrDefault(c => c.FieldName == "Windowed"); if (windowed != null) { windowed.FieldValue = "0"; } var hideCursor = userProfile.ConfigValues.FirstOrDefault(c => c.FieldName == "HideCursor"); if (hideCursor != null) { hideCursor.FieldValue = "1"; } var customResolution = userProfile.ConfigValues.FirstOrDefault(c => c.FieldName == "CustomResolution"); var resolutionWidth = userProfile.ConfigValues.FirstOrDefault(c => c.FieldName == "ResolutionWidth"); var resolutionHeight = userProfile.ConfigValues.FirstOrDefault(c => c.FieldName == "ResolutionHeight"); if (customResolution != null && resolutionWidth != null && resolutionHeight != null) { int resX = (resolution == null ? Screen.PrimaryScreen.Bounds.Width : resolution.Width); int resY = (resolution == null ? Screen.PrimaryScreen.Bounds.Height : resolution.Height); customResolution.FieldValue = "1"; resolutionWidth.FieldValue = resX.ToString(); resolutionHeight.FieldValue = resY.ToString(); } ConfigureControllers(userProfile); JoystickHelper.SerializeGameProfile(userProfile, userProfilePath); string profileName = Path.GetFileName(userProfile.FileName); _exename = Path.GetFileNameWithoutExtension(userProfile.GamePath); _gameProfile = userProfile; return(new ProcessStartInfo() { FileName = exe, Verb = userProfile.RequiresAdmin ? "runas" : null, WorkingDirectory = path, Arguments = "--profile=" + profileName // + " --startMinimized", }); }
/// <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); }
private void BtnSaveSettings(object sender, RoutedEventArgs e) { _isXinput = _gameProfile.ConfigValues.Any(x => x.FieldName == "XInput" && x.FieldValue == "1"); _isKeyboardorButtonAxis = _gameProfile.ConfigValues.Any(x => x.FieldName == "Use Keyboard/Button For Axis" && x.FieldValue == "1"); foreach (var t in _gameProfile.JoystickButtons) { t.BindName = _isXinput ? t.BindNameXi : t.BindNameDi; if ((_isKeyboardorButtonAxis) && (!_isXinput)) { //Wheel Axis Right (Keyboard/Button Only) = " " //Joystick Analog X Right (Keyboard/Button Only) = " " //Joystick Analog Y Up (Keyboard/Button Only) = " " //Analog X Right (Keyboard/Button Only) = " " //Analog Y Down (Keyboard/Button Only) = " " //Throttle Brake (Keyboard/Button Only) = " " //Wheel Axis Half Turn (Hold Down) = " " if (t.ButtonName.Equals(" ")) { t.ButtonName = "Wheel Axis Right (Keyboard/Button Only)"; } if (t.ButtonName.Equals(" ")) { t.ButtonName = "Joystick Analog X Right (Keyboard/Button Only)"; } if (t.ButtonName.Equals(" ")) { t.ButtonName = "Joystick Analog Y Up (Keyboard/Button Only)"; } if (t.ButtonName.Equals(" ")) { t.ButtonName = "Analog X Right (Keyboard/Button Only)"; } if (t.ButtonName.Equals(" ")) { t.ButtonName = "Analog Y Down (Keyboard/Button Only)"; } if (t.ButtonName.Equals(" ")) { t.ButtonName = "Throttle Brake (Keyboard/Button Only)"; } if (t.ButtonName.Equals(" ")) { t.ButtonName = "Wheel Axis Half Turn (Hold Down)"; } } else { if ((t.ButtonName.Equals(" ")) || (t.ButtonName.Equals(" ")) || (t.ButtonName.Equals(" ")) || (t.ButtonName.Equals(" ")) || (t.ButtonName.Equals(" ")) || (t.ButtonName.Equals(" ")) || (t.ButtonName.Equals(" "))) { t.BindName = "Hide"; } if (t.ButtonName.Equals("Wheel Axis Right (Keyboard/Button Only)")) { t.ButtonName = " "; t.BindName = "Hide"; } if (t.ButtonName.Equals("Joystick Analog X Right (Keyboard/Button Only)")) { t.ButtonName = " "; t.BindName = "Hide"; } if (t.ButtonName.Equals("Joystick Analog Y Up (Keyboard/Button Only)")) { t.ButtonName = " "; t.BindName = "Hide"; } if (t.ButtonName.Equals("Analog X Right (Keyboard/Button Only)")) { t.ButtonName = " "; t.BindName = "Hide"; } if (t.ButtonName.Equals("Analog Y Down (Keyboard/Button Only)")) { t.ButtonName = " "; t.BindName = "Hide"; } if (t.ButtonName.Equals("Throttle Brake (Keyboard/Button Only)")) { t.ButtonName = " "; t.BindName = "Hide"; } if (t.ButtonName.Equals("Wheel Axis Half Turn (Hold Down)")) { t.ButtonName = " "; t.BindName = "Hide"; } if (t.ButtonName.Equals("Wheel Axis Left")) { t.ButtonName = "Wheel Axis"; } if (_gameProfile.EmulationProfile == EmulationProfile.NamcoMachStorm) { if (t.ButtonName.Equals("Analog X Left")) { t.ButtonName = "Analog X"; } if (t.ButtonName.Equals("Analog Y Up")) { t.ButtonName = "Analog Y"; } } if (_gameProfile.EmulationProfile == EmulationProfile.AfterBurnerClimax) { if (t.ButtonName.Equals("Joystick Analog X Left")) { t.ButtonName = "Joystick Analog X"; } if (t.ButtonName.Equals("Joystick Analog Y Down")) { t.ButtonName = "Joystick Analog Y"; } } if (_gameProfile.EmulationProfile == EmulationProfile.TokyoCop) { if (t.ButtonName.Equals("Leaning Axis Left")) { t.ButtonName = "Leaning Axis"; } if (t.ButtonName.Equals("Handlebar Axis Left")) { t.ButtonName = "Handlebar Axis"; } } } } JoystickHelper.SerializeGameProfile(_gameProfile); _gameProfile.GamePath = GamePathBox.Text; Lazydata.GamePath = GamePathBox.Text; JoystickHelper.SerializeGameProfile(_gameProfile); _comboItem.Tag = _gameProfile; Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, System.IO.Path.GetFileName(_gameProfile.FileName))); _contentControl.Content = _library; }