private void btnOk_Click(object sender, RoutedEventArgs e)
 {
     if (!Extensions.IsEmpty(tbCardPath.Text))
     {
         if (lvMemCards.SelectedItems.Count == 0)
         {
             Legacy.Tools.ShowMessage("You must select a card to assign", Legacy.MessageType.Error);
         }
         else
         {
             _pcsx2Ui.Write("Folders", "UseDefaultMemoryCards", "disabled");
             var iNIPath      = Legacy.UserSettings.ConfigDir + @"\" + g.FileSafeTitle + @"\PCSX2_ui.ini";
             var selectedItem = (Legacy.MemoryCard)lvMemCards.SelectedItem;
             var file         = new Legacy.IniFile(iNIPath);
             file.Write("MemoryCards", "Slot1_Enable", "enabled");
             file.Write("MemoryCards", "Slot1_Filename", selectedItem.Name);
             file.Write("Folders", "MemoryCards", Extensions.Escape(tbCardPath.Text));
             Legacy.Tools.ShowMessage("Successfully assigned and enabled " + selectedItem.Name + " to slot 1\n for the game " + g.Title, Legacy.MessageType.Info);
             Close();
         }
     }
     else
     {
         Legacy.Tools.ShowMessage("The selected memory card cannot be null", Legacy.MessageType.Error);
     }
 }
Beispiel #2
0
        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 static void CheckSettings()
 {
     if ((!Extensions.IsEmpty(Settings.Default.pcsx2Dir) && !Extensions.IsEmpty(Settings.Default.pcsx2DataDir)) &&
         (Directory.Exists(Settings.Default.pcsx2Dir) && Directory.Exists(Settings.Default.pcsx2DataDir)))
     {
         return;
     }
     Legacy.Tools.ShowMessage("Please select the directory containing PCSX2 and the PCSX2 data directory", Legacy.MessageType.Info);
     new wndSetup().ShowDialog();
 }
Beispiel #4
0
 private void btnOk_Click(object sender, RoutedEventArgs e)
 {
     if (lbVersions.SelectedItems.Count == 0)
     {
         Legacy.Tools.ShowMessage("A PCSX2 version must be selected", Legacy.MessageType.Error);
     }
     else
     {
         pcsx2_ini.Write("Additional Executables", "Default",
                         Extensions.IsEmpty(selectedExe) ? original : selectedExe);
         Close();
     }
 }
 private void btnOk_Click(object sender, RoutedEventArgs e)
 {
     if (Extensions.IsEmpty(tbPcsx2DataDir.Text) || Extensions.IsEmpty(tbPcsx2Dir.Text))
     {
         Legacy.Tools.ShowMessage("Required fields cannot be empty!", Legacy.MessageType.Error);
     }
     else
     {
         Settings.Default.pcsx2Dir     = tbPcsx2Dir.Text;
         Settings.Default.pcsx2DataDir = tbPcsx2DataDir.Text;
         _setupCompleted = true;
         Close();
     }
 }
        private void Filter(object sender, EventArgs e)
        {
            _t.Stop();
            if (lvGames.IsVisible == false)
            {
                return;
            }
            var query       = tbSearch.Text;
            var defaultView = CollectionViewSource.GetDefaultView(Legacy.Game.AllGames);

            if (Extensions.IsEmpty(query) || query == "Search")
            {
                defaultView.Filter = null;
            }
            else
            {
                defaultView.Filter = (Predicate <object>)Delegate.Combine(defaultView.Filter, (Predicate <object>)(o => Extensions.Contains(((Legacy.Game)o).Title, query, StringComparison.InvariantCultureIgnoreCase)));
                ((ScrollViewer)Legacy.Tools.GetDescendantByType(lvGames, typeof(ScrollViewer))).ScrollToVerticalOffset(0.0);
            }
        }
 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);
         }
     }
 }