private void Setup() { g = (Legacy.Game)base.Tag; pcsx2_ini = new Legacy.IniFile(Path.Combine(Legacy.UserSettings.ConfigDir, g.FileSafeTitle) + @"\PCSX2Bonus.ini"); lbVersions.Items.Add(Path.GetFileNameWithoutExtension(pcsx2_ini.Read("Additional Executables", "Default"))); original = pcsx2_ini.Read("Additional Executables", "Default"); }
private void UpdateSettings() { var str = pcsx2_ini.Read("Boot", "NoGUI"); var str2 = pcsx2_ini.Read("Boot", "UseCD"); var str3 = pcsx2_ini.Read("Boot", "NoHacks"); var str4 = pcsx2_ini.Read("Boot", "FullBoot"); var str5 = pcsx2_vm.Read("EmuCore", "EnableCheats"); cbNoGui.IsChecked = str == "true"; cbUseCd.IsChecked = str2 == "true"; cbNoHacks.IsChecked = str3 == "true"; cbFullBoot.IsChecked = str4 == "true"; cbEnableCheats.IsChecked = str5 == "enabled"; }
private void LoadInitialCard() { var path = Extensions.Unescape(_pcsx2Ui.Read("Folders", "MemoryCards")); if (path == "memcards") { path = Path.Combine(Settings.Default.pcsx2DataDir, "memcards"); } if (!Directory.Exists(path)) { var dialog = new FolderBrowserDialog { Description = "Select the directory containing the memory card files" }; if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { Close(); return; } tbCardPath.Text = dialog.SelectedPath; } else { tbCardPath.Text = path; } foreach (var newItem in Directory.GetFiles(tbCardPath.Text, "*.ps2").Select(str2 => new FileInfo(str2)).Select(info => new Legacy.MemoryCard { Name = info.Name, WriteTime = info.LastWriteTime.ToShortDateString(), Size = Legacy.Tools.GetSizeReadable2(info.Length) })) { lvMemCards.Items.Add(newItem); } }
private async void LoadBios() { var currentBios = Extensions.Unescape(pcsx2_ui.Read("Filenames", "BIOS")); var bioses = new List <Legacy.Bios>(); await Task.Run(delegate { foreach (var str in Directory.GetFiles(Settings.Default.pcsx2DataDir + @"\bios")) { using (var reader = new StreamReader(str)) { string str2; while ((str2 = reader.ReadLine()) != null) { if (str2.Contains("ROMconf")) { var bytes = (from i in Encoding.UTF8.GetBytes(str2) where i != 0 select i).ToArray <byte>(); var src = Encoding.UTF8.GetString(bytes); var str4 = Extensions.Between(src, (string)"OSDSYS", (string)"@rom"); if (Extensions.IsEmpty(str4)) { str4 = Extensions.Between(src, (string)"OSDSYS", (string)"@"); } var item = new Legacy.Bios { DisplayInfo = GetValue(str4), Tag = str, Location = str }; bioses.Add(item); } } } } }); bioses.ForEach(b => lbBios.Items.Add(b)); var enumerator = ((IEnumerable)lbBios.Items).GetEnumerator(); try { while (enumerator.MoveNext()) { var current = enumerator.Current; var bios = (Legacy.Bios)current; if (bios.Tag.ToString() != currentBios) { continue; } lbBios.SelectedItem = bioses; return; } } finally { var disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } }
private void btnOk_Click(object sender, RoutedEventArgs e) { if (lbShaders.SelectedItems.Count == 0) { Legacy.Tools.ShowMessage("A shader must be selected!", Legacy.MessageType.Error); } else { pcsx2_ini.Read("Shader", "Default"); var selectedItem = (ListViewItem)lbShaders.SelectedItem; pcsx2_ini.Write("Shader", "Default", selectedItem.Tag.ToString()); Close(); } }
private void btnOk_Click(object sender, RoutedEventArgs e) { if (Extensions.IsEmpty(tbOutputPath.Text)) Legacy.Tools.ShowMessage("Output path cannot be empty!", Legacy.MessageType.Error); else { var path = string.Empty; try { var stopwatch = new Stopwatch(); stopwatch.Start(); var location = g.Location; var newValue = cbNoHacks.IsChecked.Value ? "--nohacks" : string.Empty; var str4 = cbNoGui.IsChecked.Value ? "--nogui" : string.Empty; var str5 = cbNoDisc.IsChecked.Value ? "--nodisc" : string.Empty; var str6 = cbFullBoot.IsChecked.Value ? "--fullboot" : string.Empty; var str7 = cbUseDefault.IsChecked.Value ? ("--cfgpath=\"\"" + Legacy.UserSettings.ConfigDir + @"\" + g.FileSafeTitle + "\"\"") : string.Empty; var outputName = tbOutputPath.Text + @"\" + g.FileSafeTitle + ".exe"; var providerOptions = new Dictionary<string, string>(); providerOptions.Add("CompilerVersion", "v4.0"); var provider = new CSharpCodeProvider(providerOptions); var options = new CompilerParameters(new string[] { "mscorlib.dll", "System.Core.dll" }, outputName, true) { GenerateExecutable = true }; if (cbUseDefaultIcon.IsChecked != null && cbUseDefaultIcon.IsChecked.Value) { path = Legacy.UserSettings.ImageDir + @"\" + g.FileSafeTitle + ".ico"; CreateIcon(path, true); options.CompilerOptions = string.Format("/target:winexe /optimize /win32icon:{1}{0}{1}", path, "\""); } else if (!cbUseDefault.IsChecked.Value) { path = tbIconPath.Text; options.CompilerOptions = string.Format("/target:winexe /optimize /win32icon:{1}{0}{1}", path, "\""); } if (string.IsNullOrWhiteSpace(path)) { options.CompilerOptions = string.Format("/target:winexe /optimize", new object[0]); } options.ReferencedAssemblies.Add("System.dll"); options.IncludeDebugInformation = false; var str9 = Settings.Default.pcsx2Exe; var file = new Legacy.IniFile(Legacy.UserSettings.ConfigDir + @"\" + g.Title + @"\Settings.ini"); if (!string.IsNullOrWhiteSpace(file.Read("Additional Executables", "Default"))) { str9 = file.Read("Additional Executables", "Default"); } var process = new Process { StartInfo = { WorkingDirectory = "" } }; var directoryName = Path.GetDirectoryName(str9); var str11 = Properties.Resources.executableTemplate.Replace("{1}", str9) .Replace("{2}", newValue) .Replace("{3}", str4) .Replace("{4}", str5) .Replace("{5}", str6) .Replace("{6}", location) .Replace("{7}", "\"\"") .Replace("{8}", str7) .Replace("{9}", directoryName); provider.CompileAssemblyFromSource(options, new string[] { str11 }) .Errors.Cast<CompilerError>() .ToList<CompilerError>() .ForEach(error => Console.WriteLine(error.ErrorText)); stopwatch.Stop(); System.Windows.MessageBox.Show( string.Concat(new object[] { "Successfully compiled the executable at ", outputName, "\n[", stopwatch.ElapsedMilliseconds, "ms]" }), "PCSX2Bonus", MessageBoxButton.OK, MessageBoxImage.Asterisk); } catch (Exception exception) { Legacy.Tools.ShowMessage("There was an error building the executable.\nReason: " + exception.Message, Legacy.MessageType.Error); } if (File.Exists(path) && Path.GetDirectoryName(path).Contains("PCSX2Bonus")) File.Delete(path); } }
public void LaunchGame(Legacy.Game g, bool tvMode = false) { if (File.Exists(g.Location) == false) { Legacy.Tools.ShowMessage("Unable to find image file!", Legacy.MessageType.Error); if (tvMode == false) { return; } var window = System.Windows.Application.Current.Windows.Cast <Window>().FirstOrDefault(w => w.Title == "wndFullScreen"); if (window != null) { window.ShowDialog(); } } else { var pcsxProcess = new Process(); var path = Legacy.UserSettings.RootDir + string.Format(@"\Configs\{0}", g.FileSafeTitle); var str = Directory.Exists(path) ? string.Format(" --cfgpath={0}{2}{0} {0}{1}{0}", "\"", g.Location, path) : string.Format(" {0}{1}{0}", "\"", g.Location); str = str.Replace(@"\\", @"\"); var src = string.Empty; var str4 = Settings.Default.pcsx2Dir; if (File.Exists(path + @"\PCSX2Bonus.ini")) { var file = new Legacy.IniFile(path + @"\PCSX2Bonus.ini"); var str5 = file.Read("Additional Executables", "Default"); var str6 = Extensions.IsEmpty(str5) ? Settings.Default.pcsx2Exe : str5; str4 = Extensions.IsEmpty(str5) ? Settings.Default.pcsx2Dir : Path.GetDirectoryName(str5); var str7 = file.Read("Boot", "NoGUI"); var str8 = file.Read("Boot", "UseCD"); var str9 = file.Read("Boot", "NoHacks"); var str10 = file.Read("Boot", "FullBoot"); src = file.Read("Shader", "Default"); pcsxProcess.StartInfo.FileName = str6; if (str7 == "true") { str = str.Insert(0, " --nogui"); } if (str8 == "true") { str = str.Insert(0, " --usecd"); } if (str9 == "true") { str = str.Insert(0, " --nohacks"); } if (str10 == "true") { str = str.Insert(0, " --fullboot"); } } else { pcsxProcess.StartInfo.FileName = Settings.Default.pcsx2Exe; } pcsxProcess.EnableRaisingEvents = true; if (str4 != null) { pcsxProcess.StartInfo.WorkingDirectory = str4; pcsxProcess.StartInfo.Arguments = str; if (Extensions.IsEmpty(src) == false) { try { File.Copy(src, Path.Combine(str4, "shader.fx"), true); } catch (Exception exception) { Legacy.Tools.ShowMessage("Could not save shader file! Details: " + exception.Message, Legacy.MessageType.Error); } } } var timeOpened = DateTime.Now; pcsxProcess.Exited += delegate { pcsxProcess.Dispose(); System.Windows.Application.Current.Dispatcher.Invoke(delegate { var now = DateTime.Now; g.TimePlayed = g.TimePlayed.Add(now.Subtract(timeOpened)); var element = Legacy.UserSettings.xGames.Descendants("Game").FirstOrDefault(x => { var xElement1 = x.Element("Name"); return(xElement1 != null && xElement1.Value == g.Title); }); if ((element != null) && (element.Element("Time") != null)) { var xElement = element.Element("Time"); if (xElement != null) { xElement.Value = g.TimePlayed.ToString(); } } if (tvMode) { var window = System.Windows.Application.Current.Windows.Cast <Window>().FirstOrDefault(w => w.Title == "wndFullScreen"); if (window != null) { window.ShowDialog(); } } _notifyIcon.Visible = false; Show(); Activate(); }); }; Hide(); if (Settings.Default.enableGameToast) { new wndGameNotify { Tag = g } }
private void btnOk_Click(object sender, RoutedEventArgs e) { if (Extensions.IsEmpty(tbOutputPath.Text)) { Legacy.Tools.ShowMessage("Output path cannot be empty!", Legacy.MessageType.Error); } else { var path = string.Empty; try { var stopwatch = new Stopwatch(); stopwatch.Start(); var location = g.Location; var newValue = cbNoHacks.IsChecked == true ? "--nohacks" : string.Empty; var str4 = cbNoGui.IsChecked == true ? "--nogui" : string.Empty; var str5 = cbNoDisc.IsChecked == true ? "--nodisc" : string.Empty; var str6 = cbFullBoot.IsChecked == true ? "--fullboot" : string.Empty; var str7 = cbUseDefault.IsChecked == true ? "--cfgpath=\"\"" + Legacy.UserSettings.ConfigDir + @"\" + g.FileSafeTitle + "\"\"" : string.Empty; var outputName = tbOutputPath.Text + @"\" + g.FileSafeTitle + ".exe"; var providerOptions = new Dictionary <string, string> { { "CompilerVersion", "v4.0" } }; var provider = new CSharpCodeProvider(providerOptions); var options = new CompilerParameters(new[] { "mscorlib.dll", "System.Core.dll" }, outputName, true) { GenerateExecutable = true }; if (cbUseDefaultIcon.IsChecked != null && cbUseDefaultIcon.IsChecked.Value) { path = Legacy.UserSettings.ImageDir + @"\" + g.FileSafeTitle + ".ico"; CreateIcon(path); options.CompilerOptions = string.Format("/target:winexe /optimize /win32icon:{1}{0}{1}", path, "\""); } else if (!cbUseDefault.IsChecked == true) { path = tbIconPath.Text; options.CompilerOptions = string.Format("/target:winexe /optimize /win32icon:{1}{0}{1}", path, "\""); } if (string.IsNullOrWhiteSpace(path)) { options.CompilerOptions = "/target:winexe /optimize"; } options.ReferencedAssemblies.Add("System.dll"); options.IncludeDebugInformation = false; var str9 = Settings.Default.pcsx2Exe; var file = new Legacy.IniFile(Legacy.UserSettings.ConfigDir + @"\" + g.Title + @"\Settings.ini"); if (!string.IsNullOrWhiteSpace(file.Read("Additional Executables", "Default"))) { str9 = file.Read("Additional Executables", "Default"); } var directoryName = Path.GetDirectoryName(str9); var str11 = Properties.Resources.executableTemplate.Replace("{1}", str9) .Replace("{2}", newValue) .Replace("{3}", str4) .Replace("{4}", str5) .Replace("{5}", str6) .Replace("{6}", location) .Replace("{7}", "\"\"") .Replace("{8}", str7) .Replace("{9}", directoryName); provider.CompileAssemblyFromSource(options, str11) .Errors.Cast <CompilerError>() .ToList() .ForEach(error => Console.WriteLine(error.ErrorText)); stopwatch.Stop(); System.Windows.MessageBox.Show( string.Concat("Successfully compiled the executable at ", outputName, "\n[", stopwatch.ElapsedMilliseconds, "ms]"), "PCSX2Bonus", MessageBoxButton.OK, MessageBoxImage.Asterisk); } catch (Exception exception) { Legacy.Tools.ShowMessage("There was an error building the executable.\nReason: " + exception.Message, Legacy.MessageType.Error); } var name = Path.GetDirectoryName(path); if (name != null && File.Exists(path) && name.Contains("PCSX2Bonus")) { File.Delete(path); } } }
public void LaunchGame(Legacy.Game g, bool tvMode = false) { if (File.Exists(g.Location) == false) { Legacy.Tools.ShowMessage("Unable to find image file!", Legacy.MessageType.Error); if (tvMode == false) return; var window = System.Windows.Application.Current.Windows.Cast<Window>().FirstOrDefault(w => w.Title == "wndFullScreen"); if (window != null) window.ShowDialog(); } else { var pcsxProcess = new Process(); var path = Legacy.UserSettings.RootDir + string.Format(@"\Configs\{0}", g.FileSafeTitle); var str = Directory.Exists(path) ? string.Format(" --cfgpath={0}{2}{0} {0}{1}{0}", "\"", g.Location, path) : string.Format(" {0}{1}{0}", "\"", g.Location); str = str.Replace(@"\\", @"\"); var src = string.Empty; var str4 = Settings.Default.pcsx2Dir; if (File.Exists(path + @"\PCSX2Bonus.ini")){ var file = new Legacy.IniFile(path + @"\PCSX2Bonus.ini"); var str5 = file.Read("Additional Executables", "Default"); var str6 = Extensions.IsEmpty(str5) ? Settings.Default.pcsx2Exe : str5; str4 = Extensions.IsEmpty(str5) ? Settings.Default.pcsx2Dir : Path.GetDirectoryName(str5); var str7 = file.Read("Boot", "NoGUI"); var str8 = file.Read("Boot", "UseCD"); var str9 = file.Read("Boot", "NoHacks"); var str10 = file.Read("Boot", "FullBoot"); src = file.Read("Shader", "Default"); pcsxProcess.StartInfo.FileName = str6; if (str7 == "true") str = str.Insert(0, " --nogui"); if (str8 == "true") str = str.Insert(0, " --usecd"); if (str9 == "true") str = str.Insert(0, " --nohacks"); if (str10 == "true") str = str.Insert(0, " --fullboot"); } else pcsxProcess.StartInfo.FileName = Settings.Default.pcsx2Exe; pcsxProcess.EnableRaisingEvents = true; if (str4 != null) { pcsxProcess.StartInfo.WorkingDirectory = str4; pcsxProcess.StartInfo.Arguments = str; if (Extensions.IsEmpty(src) == false) { try { File.Copy(src, Path.Combine(str4, "shader.fx"), true); } catch (Exception exception) { Legacy.Tools.ShowMessage("Could not save shader file! Details: " + exception.Message, Legacy.MessageType.Error); } } } var timeOpened = DateTime.Now; pcsxProcess.Exited += delegate{ pcsxProcess.Dispose(); System.Windows.Application.Current.Dispatcher.Invoke(delegate { var now = DateTime.Now; g.TimePlayed = g.TimePlayed.Add(now.Subtract(timeOpened)); var element = Legacy.UserSettings.xGames.Descendants("Game").FirstOrDefault(x => { var xElement1 = x.Element("Name"); return xElement1 != null && xElement1.Value == g.Title; }); if ((element != null) && (element.Element("Time") != null)) { var xElement = element.Element("Time"); if (xElement != null) xElement.Value = g.TimePlayed.ToString(); } if (tvMode) { var window = System.Windows.Application.Current.Windows.Cast<Window>().FirstOrDefault(w => w.Title == "wndFullScreen"); if (window != null) window.ShowDialog(); } _notifyIcon.Visible = false; Show(); Activate(); }); }; Hide(); if (Settings.Default.enableGameToast) new wndGameNotify{Tag = g}.Show(); _notifyIcon.Text = string.Format("Currently playing [{0}]", Extensions.Truncate(g.Title, 40)); _notifyIcon.Visible = true; pcsxProcess.Start(); } }