/// <summary> /// Initializes a new instance of the <see cref="EmulatorSettingModal"/> class. /// </summary> public EmulatorSettingModal() { InitializeComponent(); // check the text of the selected page menu button. If it is not "Add New Emulator" then get the setting if (GameControlModel.GetInstance.GameSettingsManager.EmulatorSettings.EmulatorSettingList != null) { string selectedButtonText = PageModel.GetInstance.SelectedMenuItemModel.DisplayText; EmulatorSetting setting = GameControlModel.GetInstance.GameSettingsManager.EmulatorSettings.EmulatorSettingList.Where(m => m.EmulatatedSystemName == selectedButtonText).FirstOrDefault(); if (setting != null) { try { txtImagePath.Text = setting.ConsoleImagePath; txtRomPath.Text = setting.RomPath; txtRunCommand.Text = setting.BootCommand; txtSystemName.Text = setting.EmulatatedSystemName; txtFileExt.Text = setting.FileExt; txtEmulatorPath.Text = setting.EmulatorPath; chkWinKawaks.IsChecked = setting.WinKawaks; } catch (Exception) { chkWinKawaks.IsChecked = false; } } } }
/// <summary> /// Runs the emulator. /// </summary> /// <param name="setting">The setting.</param> /// <param name="file">The file.</param> private void RunEmulator(EmulatorSetting setting, string file) { // ** example: this starts goldeneye //p.StartInfo.FileName = @"D:\emu\1964_085_60fps\originals\1964_ultrafast_v3\1964_ultrafast original.exe"; //p.StartInfo.Arguments = "-g \"D:\\emu\\Games_N64\\007_GoldenEye.v64\""; try { Process p = new Process(); p.StartInfo.FileName = setting.EmulatorPath; p.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(setting.EmulatorPath); if (setting.WinKawaks) { p.StartInfo.Arguments = string.Format(System.IO.Path.GetFileNameWithoutExtension(file)); } else { p.StartInfo.Arguments = string.Format(setting.BootCommand, file); } p.StartInfo.UseShellExecute = true; p.Start(); } catch (Exception ex) { // TODO: show Modal error loading the emulator //throw; } }
private void btnSave_Click(object sender, RoutedEventArgs e) { // get settings as a list List <EmulatorSetting> settings = new List <EmulatorSetting>(); if (GameControlModel.GetInstance.GameSettingsManager.EmulatorSettings.EmulatorSettingList != null) { settings = GameControlModel.GetInstance.GameSettingsManager.EmulatorSettings.EmulatorSettingList.ToList(); } EmulatorSetting setting = new EmulatorSetting(); // try to get the existing emulator setting if (settings.Count > 0) { setting = GameControlModel.GetInstance.GameSettingsManager.EmulatorSettings.EmulatorSettingList .Where(m => m.EmulatatedSystemName.ToLower() == txtSystemName.Text.ToLower()) .FirstOrDefault(); if (setting == null) { setting = new EmulatorSetting(); settings.Add(setting); } } else { settings.Add(setting); } // assign to view fields setting.BootCommand = txtRunCommand.Text; setting.ConsoleImagePath = txtImagePath.Text; setting.EmulatatedSystemName = txtSystemName.Text; setting.RomPath = txtRomPath.Text; setting.FileExt = txtFileExt.Text; setting.EmulatorPath = txtEmulatorPath.Text; setting.WinKawaks = chkWinKawaks.IsChecked.Value; // convert the settings back to array sorted by system name GameControlModel.GetInstance.GameSettingsManager.EmulatorSettings.EmulatorSettingList = settings.OrderBy(m => m.EmulatatedSystemName).ToArray(); // save the xml GameControlModel.GetInstance.GameSettingsManager.SaveSettings(); // remove the modal ModalModel.GetInstance.ModalUserControl = null; // change page buttons back to gold PageModel.GetInstance.SelectPageModel(); // reload the emulator setting list by going back twice and navigating to settings again PageModel.GetInstance.NavigateBackwards(); GameControl.GetInstance.NavigateToSettings(); }
/// <summary> /// Navigates to roms. /// </summary> /// <param name="setting">The setting.</param> private void NavigateToRoms(EmulatorSetting setting) { // menu items for new menu entity List <MenuItemModel> menuItems = new List <MenuItemModel>(); // get file extensions string[] extensions = setting.FileExt.Split(',').ToArray(); foreach (string ext in extensions) { // get a list of roms from the directory List <string> files = Directory.GetFiles(setting.RomPath, "*." + ext).ToList(); foreach (string file in files) { menuItems.Add(new MenuItemModel() { DisplayText = System.IO.Path.GetFileNameWithoutExtension(file), ParentSelected = true, FilePath = file, RelayCommand = new RelayCommand(() => { string consoleName = PageModel.GetInstance.MenuEntityModels[0].SelectedMenuItemModel.DisplayText.RemoveCommas(); string gameName = PageModel.GetInstance.SelectedMenuItemModel.DisplayText.RemoveCommas(); // navigate to game options modal ModalModel.GetInstance.ModalUserControl = new GameOptionsModal(consoleName + "_" + gameName, () => { RunEmulator(setting, file); }); }) }); } } // sort the games menuItems = menuItems.OrderBy(m => m.DisplayText).ToList(); // select the first menu item if (menuItems.Count > 0) { menuItems.First().IsSelected = true; } // navigate to new menu PageModel.GetInstance.NavigateForwards(menuItems); }
private void btnDelete_Click(object sender, RoutedEventArgs e) { if (GameControlModel.GetInstance.GameSettingsManager.EmulatorSettings.EmulatorSettingList == null) { // TODO disabled button when no setting exist return; } // get settings List <EmulatorSetting> settings = GameControlModel.GetInstance.GameSettingsManager.EmulatorSettings.EmulatorSettingList.ToList(); // get the setting to be deleted EmulatorSetting setting = settings.Where(m => m.EmulatatedSystemName.ToLower() == txtSystemName.Text.ToLower()).FirstOrDefault(); if (setting == null) { // TODO disabled button when no setting exist return; } settings.Remove(setting); GameControlModel.GetInstance.GameSettingsManager.EmulatorSettings.EmulatorSettingList = settings.ToArray(); // save the xml GameControlModel.GetInstance.GameSettingsManager.SaveSettings(); // remove the modal ModalModel.GetInstance.ModalUserControl = null; // change page buttons back to gold PageModel.GetInstance.SelectPageModel(); // reload the emulator setting list by going back twice and navigating to settings again PageModel.GetInstance.NavigateBackwards(); GameControl.GetInstance.NavigateToSettings(); }
public Settings(string filePath) { FilePath = filePath; if (Platform == null) GeneratePlatform(); if (Resolution == null) GenerateResolution(); if(Resolution.Rules[0].Width<0){ GenerateResolution(); } if (IgnoresFolders == null) GenerateIgnoreFolder(); if (IgnoresFiles == null) GenerateIgnoreFiles(); if (ExtensionList == null) GenerateExtensionList(); if (DisplayOrientations == null) GenerateOrientations(); if (InstallLocations == null) GenerateInstallLocation(); if (OSSupportedDevices == null) GenerateOSSupportedDevices(); if (PlatformResolutions == null) GeneratePlatformResolutions(); if (ApplicationType == null) GenerateApplicationType(); if (AndroidSupportedDevices == null) GenerateAndroidSupportedDevices(); if ((EmulatorSettings == null)) EmulatorSettings = new EmulatorSetting(); EmulatorSettings.UsDefault = true; //if(LibsDefine == null)) GenerateLibs(); //VersionSetting = 111202; }
public Settings(string filePath) { FilePath = filePath; if (Platform == null) { GeneratePlatform(); } if (Resolution == null) { GenerateResolution(); } if (Resolution.Rules[0].Width < 0) { GenerateResolution(); } if (IgnoresFolders == null) { GenerateIgnoreFolder(); } if (IgnoresFiles == null) { GenerateIgnoreFiles(); } if (ExtensionList == null) { GenerateExtensionList(); } if (DisplayOrientations == null) { GenerateOrientations(); } if (InstallLocations == null) { GenerateInstallLocation(); } if (OSSupportedDevices == null) { GenerateOSSupportedDevices(); } if (PlatformResolutions == null) { GeneratePlatformResolutions(); } if (ApplicationType == null) { GenerateApplicationType(); } if (AndroidSupportedDevices == null) { GenerateAndroidSupportedDevices(); } if ((EmulatorSettings == null)) { EmulatorSettings = new EmulatorSetting(); } EmulatorSettings.UsDefault = true; //if(LibsDefine == null)) GenerateLibs(); //VersionSetting = 111202; }