コード例 #1
0
        void autoConfig()
        {
            EmulatorProfile autoSettings = EmuSettingsAutoFill.Instance.CheckForSettings(pathTextBox.Text);

            if (autoSettings == null)
            {
                return;
            }

            if (autoSettings.HasSettings && MessageBox.Show(string.Format("Would you like to use the recommended settings for {0}?", autoSettings.Title), "Use recommended settings?", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (!string.IsNullOrEmpty(autoSettings.Filters) && Options.Instance.GetBoolOption("autoconfemu"))
                {
                    Emulator.Filter = autoSettings.Filters;
                }

                if (!string.IsNullOrEmpty(autoSettings.Platform))
                {
                    Emulator.PlatformTitle = autoSettings.Platform;
                    Emulator.Title         = autoSettings.Platform;
                    Emulator.CaseAspect    = EmuSettingsAutoFill.Instance.GetCaseAspect(autoSettings.Platform);
                }

                if (autoSettings.HasSettings)
                {
                    Emulator.DefaultProfile.Arguments        = autoSettings.Arguments;
                    Emulator.DefaultProfile.UseQuotes        = autoSettings.UseQuotes != false; //default to true if null
                    Emulator.DefaultProfile.SuspendMP        = autoSettings.SuspendMP == true;
                    Emulator.DefaultProfile.WorkingDirectory = autoSettings.WorkingDirectory;
                    Emulator.DefaultProfile.MountImages      = autoSettings.MountImages;
                    Emulator.DefaultProfile.EscapeToExit     = autoSettings.EscapeToExit;
                }
            }
        }
コード例 #2
0
ファイル: DB.cs プロジェクト: brownard/MyEmulators2
        public List <EmulatorProfile> GetProfiles(Game game)
        {
            if (!game.ParentEmulator.IsPc())
            {
                return(GetProfiles(game.ParentEmulator));
            }

            List <EmulatorProfile> profiles = new List <EmulatorProfile>();
            SQLiteResultSet        result   = Execute("SELECT * FROM {0} WHERE emulator_id=-1 AND game_id={1} ORDER BY defaultprofile DESC", EmulatorProfile.TABLE_NAME, game.GameID);

            if (result.Rows.Count > 0)
            {
                foreach (SQLiteResultSet.Row row in result.Rows)
                {
                    profiles.Add(EmulatorProfile.CreateProfile(row));
                }
            }
            else
            {
                profiles.Add(new EmulatorProfile(true)
                {
                    EmulatorID = -1, GameId = game.GameID, Arguments = game.Arguments, SuspendMP = true, UseQuotes = false, StopEmulationOnKey = false
                });
            }

            return(profiles);
        }
コード例 #3
0
        private void delProfileButton_Click(object sender, EventArgs e)
        {
            if (selectedProfile.IsDefault)
            {
                Logger.LogDebug("Default profile cannot be deleted");
                return;
            }

            EmulatorProfile profile = selectedProfile;

            saveProfile     = false;
            selectedProfile = null;
            profile.Delete();

            int index = profileComboBox.SelectedIndex;

            profileComboBox.Items.Remove(profile);

            if (index > 0)
            {
                profileComboBox.SelectedIndex = index - 1;
            }
            else
            {
                profileComboBox.SelectedIndex = 0;
            }
        }
コード例 #4
0
        //Fired when the user selectes an item in the listview
        void emulatorListView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            //This event is fired twice, once for the item losing selection
            //and once for the item being selected. Ensure we only process
            //one for performance.
            if (!e.IsSelected)
            {
                return;
            }

            updateEmulator();
            updateProfile();

            if (emulatorListView.SelectedItems.Count != 1)
            {
                //multiple items selected, shouldn't occur
                //with current setup but just in case.
                selectedListItem = null;
                selectedEmulator = null;
                selectedProfile  = null;
                return;
            }

            selectedListItem = e.Item;
            //update panel with selected emu details
            setEmulatorToPanel(selectedListItem);
            //update panel enablings
            updatePanels();
        }
コード例 #5
0
        public override void UpdatePanel()
        {
            EmulatorProfile profile = Emulator.DefaultProfile;

            mountImagesCheckBox.Checked = profile.MountImages;
            escExitCheckBox.Checked     = profile.EscapeToExit;
            suspendMPCheckBox.Checked   = profile.SuspendMP == true;
            enableGMCheckBox.Checked    = profile.EnableGoodmerge;
        }
コード例 #6
0
        public override bool Next()
        {
            EmulatorProfile profile = Emulator.DefaultProfile;

            profile.MountImages     = mountImagesCheckBox.Checked;
            profile.EscapeToExit    = escExitCheckBox.Checked;
            profile.SuspendMP       = suspendMPCheckBox.Checked;
            profile.EnableGoodmerge = enableGMCheckBox.Checked;
            return(true);
        }
コード例 #7
0
        public string ExtractGame(Game game, EmulatorProfile profile = null, ExecutorLaunchProgressHandler progressHandler = null)
        {
            if (profile == null || profile.EmulatorID != game.ParentEmulator.UID)
            {
                profile = game.GetSelectedProfile();
            }

            lock (syncRoot)
            {
                if (progressHandler != null)
                {
                    progressHandler("Loading archive...", 0);
                }

                if (!loadArchive(game.CurrentDisc.Path))
                {
                    throw new ExtractException("{0} {1}", Translator.Instance.goodmergearchiveerror, game.CurrentDisc.Path);
                }

                using (extractor)
                {
                    List <IArchiveEntry> entries;
                    if (extractor.Entries == null || (entries = extractor.Entries.Where(e => !e.IsDirectory).ToList()).Count < 1)
                    {
                        Logger.LogError("Goodmerge: Archive '{0}' appears to be empty");
                        throw new ExtractException(Translator.Instance.goodmergeempty);
                    }

                    if (progressHandler != null)
                    {
                        progressHandler("Selecting file...", 0);
                    }
                    IArchiveEntry selectedEntry = selectEntry(entries, game.CurrentDisc.LaunchFile, profile.GetGoodmergeTags());
                    Logger.LogDebug("Goodmerge: Selected entry {0}", selectedEntry.FilePath);

                    string cacheKey = string.Format("{0}****{1}", game.CurrentDisc.Path, selectedEntry.FilePath);
                    string extractionPath;
                    if (isInCache(cacheKey, out extractionPath))
                    {
                        Logger.LogDebug("Goodmerge: Using cached file '{0}'", extractionPath);
                        return(extractionPath);
                    }

                    extractionPath = Path.Combine(GoodmergeTempPath, GOODMERGE_FILENAME_PREFIX + game.Filename);
                    string extractedFile = extractFile(extractor, selectedEntry, extractionPath, progressHandler);
                    if (extractedFile != null)
                    {
                        addToCache(cacheKey, extractedFile);
                    }

                    return(extractedFile);
                }
            }
        }
コード例 #8
0
        void emuPathTextBox_TextChanged(object sender, EventArgs e)
        {
            if (!allowChangedEvents || selectedEmulator == null)
            {
                return;
            }

            EmulatorProfile autoSettings = EmuSettingsAutoFill.Instance.CheckForSettings(emuPathTextBox.Text);

            if (autoSettings == null)
            {
                return;
            }

            if (MessageBox.Show(string.Format("Would you like to use the recommended settings for {0}?", autoSettings.Title), "Use recommended settings?", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (Options.Instance.GetBoolOption("autoconfemu"))
                {
                    updateFilterBox(autoSettings.Filters);
                }

                if (autoSettings.Platform != null && platformComboBox.Text == "Unspecified")
                {
                    int index = platformComboBox.FindStringExact(autoSettings.Platform);
                    if (index > -1)
                    {
                        platformComboBox.SelectedItem = platformComboBox.Items[index];
                        EmuSettingsAutoFill.SetupAspectDropdown(thumbAspectComboBox, EmuSettingsAutoFill.Instance.GetCaseAspect(platformComboBox.Text));
                    }
                }

                if (autoSettings.HasSettings)
                {
                    argumentsTextBox.Text     = autoSettings.Arguments;
                    useQuotesCheckBox.Checked = autoSettings.UseQuotes != false; //default to true if null
                    suspendMPCheckBox.Checked = autoSettings.SuspendMP == true;
                    if (autoSettings.WorkingDirectory == EmuSettingsAutoFill.USE_EMULATOR_DIRECTORY)
                    {
                        System.IO.FileInfo file = new System.IO.FileInfo(emuPathTextBox.Text);
                        if (file.Exists)
                        {
                            workingDirTextBox.Text = file.Directory.FullName;
                        }
                    }
                    else
                    {
                        workingDirTextBox.Text = autoSettings.WorkingDirectory;
                    }

                    mountImagesCheckBox.Checked = autoSettings.MountImages;
                    escExitCheckBox.Checked     = autoSettings.EscapeToExit;
                }
            }
        }
コード例 #9
0
        EmulatorProfile createAutoConfig(XmlNode emulator, string exeName)
        {
            EmulatorProfile autoConfig = new EmulatorProfile(false);
            XmlNode         titleNode  = emulator.SelectSingleNode("./@name");

            if (titleNode != null)
            {
                autoConfig.Title = titleNode.Value;
            }
            else
            {
                autoConfig.Title = exeName;
            }

            foreach (XmlNode property in emulator.SelectNodes("./*"))
            {
                if (string.IsNullOrEmpty(property.InnerText))
                {
                    continue;
                }
                System.Reflection.PropertyInfo pi = null;
                try { pi = typeof(EmulatorProfile).GetProperty(property.Name); }
                catch { }
                if (pi == null)
                {
                    continue;
                }

                if (pi.PropertyType == typeof(string))
                {
                    pi.SetValue(autoConfig, property.InnerText, null);
                }
                else if (pi.PropertyType == typeof(bool) || pi.PropertyType == typeof(bool?))
                {
                    bool result;
                    if (bool.TryParse(property.InnerText, out result))
                    {
                        pi.SetValue(autoConfig, result, null);
                    }
                }
                else
                {
                    continue;
                }
                if (property.Name != "Filters")
                {
                    autoConfig.HasSettings = true;
                }
            }
            return(autoConfig);
        }
コード例 #10
0
        void initSettings()
        {
            autoConfigDictionary = new Dictionary <string, EmulatorProfile>();
            aspectDictionary     = new Dictionary <string, double>();
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyEmulators2.Data.EmuSettings.xml"));
            }
            catch (Exception ex)
            {
                Logger.LogError("Error loading Emulator auto configuration settings - {0}", ex.Message);
                return;
            }
            XmlNodeList platforms = doc.SelectNodes("//Platform");
            XmlNode     dummyAttr;

            foreach (XmlNode platform in platforms)
            {
                dummyAttr = platform.SelectSingleNode("./@name");
                string platformName         = dummyAttr != null ? dummyAttr.Value : null;
                bool   hasPlatformReference = !string.IsNullOrEmpty(platformName);

                dummyAttr = platform.SelectSingleNode("./@caseaspect");
                if (hasPlatformReference && dummyAttr != null)
                {
                    double aspect;
                    if (double.TryParse(dummyAttr.Value, out aspect))
                    {
                        aspectDictionary[platformName] = aspect;
                    }
                }

                foreach (XmlNode emulator in platform.SelectNodes("./Emulator"))
                {
                    dummyAttr = emulator.SelectSingleNode("./@exe");
                    if (dummyAttr == null || string.IsNullOrEmpty(dummyAttr.Value))
                    {
                        continue;
                    }
                    EmulatorProfile autoConfig = createAutoConfig(emulator, dummyAttr.Value);
                    if (hasPlatformReference)
                    {
                        autoConfig.Platform = platformName;
                    }
                    autoConfigDictionary[dummyAttr.Value] = autoConfig;
                }
            }
        }
コード例 #11
0
        //If this function returns null the plugin will attempt to launch the item
        //as a rom
        public List <string> ViewFiles(Game game, out int matchIndex)
        {
            lock (syncRoot)
            {
                matchIndex = -1;
                if (!loadArchive(game.CurrentDisc.Path))
                {
                    throw new ExtractException("{0} {1}", Translator.Instance.goodmergearchiveerror, game.CurrentDisc.Path);
                }

                List <string> files = new List <string>();
                using (extractor)
                {
                    //List<IArchiveEntry> entries;
                    List <IArchiveEntry> entries;
                    if (extractor.Entries == null || (entries = extractor.Entries.Where(e => !e.IsDirectory).ToList()).Count < 1)
                    {
                        Logger.LogError("Goodmerge: Archive '{0}' appears to be empty");
                        throw new ExtractException(Translator.Instance.goodmergeempty);
                    }

                    Logger.LogInfo("Goodmerge: Viewing archive '{0}', found {1} file{2}", game.CurrentDisc.Path, entries.Count, entries.Count == 1 ? "" : "s");

                    bool matchFile = !string.IsNullOrEmpty(game.CurrentDisc.LaunchFile);
                    if (entries.Count > 0)
                    {
                        for (int i = 0; i < entries.Count; i++)
                        {
                            string file = entries[i].FilePath;
                            if (matchFile && file == game.CurrentDisc.LaunchFile)
                            {
                                matchIndex = i;
                                matchFile  = false;
                            }
                            files.Add(file);
                        }
                        if (matchIndex < 0)
                        {
                            EmulatorProfile profile = game.GetSelectedProfile();
                            if (profile != null)
                            {
                                matchIndex = getBestGoodmergeMatch(entries, profile.GetGoodmergeTags());
                            }
                        }
                    }
                }
                return(files);
            }
        }
コード例 #12
0
 public Conf_NewProfile(Emulator emu, EmulatorProfile profile)
 {
     InitializeComponent();
     if (profile == null)
     {
         EmulatorProfile              = new EmulatorProfile(false);
         EmulatorProfile.EmulatorID   = emu.UID;
         EmulatorProfile.EmulatorPath = emu.DefaultProfile.EmulatorPath;
     }
     else
     {
         EmulatorProfile = profile;
         this.Text       = "Rename Profile";
     }
     profileTitleTextBox.SelectedText = EmulatorProfile.Title;
 }
コード例 #13
0
 void setProfileToPanel(EmulatorProfile selectedProfile)
 {
     currentPCProfile = selectedProfile;
     updatePCSettingsButtons();
     if (selectedProfile == null)
     {
         return;
     }
     suspendMPCheckBox.Checked      = selectedProfile.SuspendMP == true;
     argumentsTextBox.Text          = selectedProfile.Arguments;
     launchedFileTextBox.Text       = selectedProfile.LaunchedExe;
     preCommandText.Text            = selectedProfile.PreCommand;
     preCommandWaitCheck.Checked    = selectedProfile.PreCommandWaitForExit;
     preCommandWindowCheck.Checked  = selectedProfile.PreCommandShowWindow;
     postCommandText.Text           = selectedProfile.PostCommand;
     postCommandWaitCheck.Checked   = selectedProfile.PostCommandWaitForExit;
     postCommandWindowCheck.Checked = selectedProfile.PostCommandShowWindow;
 }
コード例 #14
0
        //Fired when a new profile is seleced from the profile dropdown.
        //Save any changes to current profile and update panel with new
        //profile details.
        void profileComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateProfile();

            selectedProfile = profileComboBox.SelectedItem as EmulatorProfile;
            if (selectedProfile == null)
            {
                return;
            }

            allowChangedEvents = false; //don't fire changed event when we are updating

            emuPathTextBox.Text       = selectedProfile.EmulatorPath;
            workingDirTextBox.Text    = selectedProfile.WorkingDirectory;
            argumentsTextBox.Text     = selectedProfile.Arguments;
            useQuotesCheckBox.Checked = selectedProfile.UseQuotes != false;
            //suspend
            suspendMPCheckBox.Checked   = selectedProfile.SuspendMP == true;
            delayResumeCheckBox.Checked = selectedProfile.DelayResume;
            resumeDelayUpDown.Value     = selectedProfile.ResumeDelay;
            bool enabled = suspendMPCheckBox.Checked;

            delayResumeCheckBox.Enabled = enabled;
            resumeDelayUpDown.Enabled   = enabled;

            enableGoodCheckBox.Checked = selectedProfile.EnableGoodmerge;
            goodComboBox.Text          = selectedProfile.GoodmergeTags;

            mountImagesCheckBox.Checked      = selectedProfile.MountImages;
            escExitCheckBox.Checked          = selectedProfile.EscapeToExit;
            checkControllerCheckBox.Checked  = selectedProfile.CheckController;
            stopEmulationCheckBox.CheckState = selectedProfile.StopEmulationOnKey.HasValue ? selectedProfile.StopEmulationOnKey.Value ? CheckState.Checked : CheckState.Unchecked : CheckState.Indeterminate;

            preCommandText.Text            = selectedProfile.PreCommand;
            preCommandWaitCheck.Checked    = selectedProfile.PreCommandWaitForExit;
            preCommandWindowCheck.Checked  = selectedProfile.PreCommandShowWindow;
            postCommandText.Text           = selectedProfile.PostCommand;
            postCommandWaitCheck.Checked   = selectedProfile.PostCommandWaitForExit;
            postCommandWindowCheck.Checked = selectedProfile.PostCommandShowWindow;

            allowChangedEvents = true;

            updateButtons();
        }
コード例 #15
0
        private void addProfileButton_Click(object sender, EventArgs e)
        {
            if (selectedEmulator == null)
            {
                return;
            }

            using (Conf_NewProfile profileDlg = new Conf_NewProfile(selectedEmulator, null))
            {
                if (profileDlg.ShowDialog() != DialogResult.OK || profileDlg.EmulatorProfile == null)
                {
                    return;
                }

                EmulatorProfile profile = profileDlg.EmulatorProfile;
                profile.Save();
                profileComboBox.Items.Add(profile);
                profileComboBox.SelectedItem = profile;
            }
        }
コード例 #16
0
ファイル: DB.cs プロジェクト: brownard/MyEmulators2
        public List <EmulatorProfile> GetProfiles(Emulator emu)
        {
            List <EmulatorProfile> profiles = new List <EmulatorProfile>();

            if (emu.UID == -1)
            {
                profiles.Add(new EmulatorProfile(true)
                {
                    EmulatorID = -1
                });
                return(profiles);
            }

            SQLiteResultSet result = Execute("SELECT * FROM {0} WHERE emulator_id={1} ORDER BY defaultprofile DESC", EmulatorProfile.TABLE_NAME, emu.UID);

            foreach (SQLiteResultSet.Row row in result.Rows)
            {
                profiles.Add(EmulatorProfile.CreateProfile(row));
            }
            return(profiles);
        }
コード例 #17
0
ファイル: DB.cs プロジェクト: brownard/MyEmulators2
        public EmulatorProfile GetProfile(int id, Emulator parentEmu)
        {
            if (parentEmu.UID < 0)
            {
                return new EmulatorProfile(true)
                       {
                           EmulatorID = -1
                       }
            }
            ;
            SQLiteResultSet result;

            if (id > -1)
            {
                result = Execute("SELECT * FROM {0} WHERE uid={1} AND emulator_id={2}", EmulatorProfile.TABLE_NAME, id, parentEmu.UID);

                if (result.Rows.Count > 0)
                {
                    return(EmulatorProfile.CreateProfile(result.Rows[0]));
                }
            }
            else
            {
                result = Execute("SELECT * FROM {0} WHERE emulator_id={1} AND defaultprofile='True'", EmulatorProfile.TABLE_NAME, parentEmu.UID);
                if (result.Rows.Count > 0)
                {
                    return(EmulatorProfile.CreateProfile(result.Rows[0]));
                }
            }

            List <EmulatorProfile> profiles = GetProfiles(parentEmu);

            if (profiles.Count > 0)
            {
                return(profiles[0]);
            }

            Logger.LogError("No profiles found for {0}, database corrupt", parentEmu.Title);
            return(null);
        }
コード例 #18
0
        void delProfileButton_Click(object sender, EventArgs e)
        {
            savePCSettings = false;
            int index = pcProfileComboBox.SelectedIndex;

            if (index > -1)
            {
                EmulatorProfile profile = (EmulatorProfile)pcProfileComboBox.Items[index];
                if (profile.IsDefault)
                {
                    return;
                }
                pcProfileComboBox.Items.Remove(profile);
                if (index > 0)
                {
                    index = index - 1;
                }
                pcProfileComboBox.SelectedIndex = index;
                profile.Delete();
            }
            loadProfileDropdown(selectedGame);
        }
コード例 #19
0
        public static EmulatorProfile CreateProfile(SQLite.NET.SQLiteResultSet.Row sqlRow)
        {
            if (sqlRow.fields.Count != 25)
            {
                Logger.LogError("Unable to create Profile, invalid database row");
                return(null);
            }

            System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.InvariantCulture;

            EmulatorProfile profile = new EmulatorProfile(false);

            profile.ID                     = int.Parse(sqlRow.fields[0], culture);
            profile.Title                  = DB.Decode(sqlRow.fields[1]);
            profile.EmulatorID             = int.Parse(sqlRow.fields[2], culture);
            profile.EmulatorPath           = DB.Decode(sqlRow.fields[3]);
            profile.WorkingDirectory       = DB.Decode(sqlRow.fields[4]);
            profile.UseQuotes              = bool.Parse(sqlRow.fields[5]);
            profile.Arguments              = DB.Decode(sqlRow.fields[6]);
            profile.SuspendMP              = bool.Parse(sqlRow.fields[7]);
            profile.MountImages            = bool.Parse(sqlRow.fields[8]);
            profile.EscapeToExit           = bool.Parse(sqlRow.fields[9]);
            profile.CheckController        = bool.Parse(sqlRow.fields[10]);
            profile.IsDefault              = bool.Parse(sqlRow.fields[11]);
            profile.PreCommand             = DB.Decode(sqlRow.fields[12]);
            profile.PreCommandWaitForExit  = bool.Parse(sqlRow.fields[13]);
            profile.PreCommandShowWindow   = bool.Parse(sqlRow.fields[14]);
            profile.PostCommand            = DB.Decode(sqlRow.fields[15]);
            profile.PostCommandWaitForExit = bool.Parse(sqlRow.fields[16]);
            profile.PostCommandShowWindow  = bool.Parse(sqlRow.fields[17]);
            profile.GameId                 = int.Parse(sqlRow.fields[18], culture);
            profile.LaunchedExe            = DB.Decode(sqlRow.fields[19]);
            profile.StopEmulationOnKey     = boolFromInt(int.Parse(sqlRow.fields[20], culture));
            profile.DelayResume            = bool.Parse(sqlRow.fields[21]);
            profile.ResumeDelay            = int.Parse(sqlRow.fields[22], culture);
            profile.GoodmergeTags          = DB.Decode(sqlRow.fields[23]);
            profile.EnableGoodmerge        = bool.Parse(sqlRow.fields[24]);
            return(profile);
        }
コード例 #20
0
        void addProfileButton_Click(object sender, EventArgs e)
        {
            if (selectedGame == null)
            {
                return;
            }
            updatePCSettings();
            using (Conf_NewProfile profileDlg = new Conf_NewProfile(selectedGame.ParentEmulator, null))
            {
                if (profileDlg.ShowDialog() != DialogResult.OK || profileDlg.EmulatorProfile == null)
                {
                    return;
                }

                EmulatorProfile profile = profileDlg.EmulatorProfile;
                profile.GameId    = selectedGame.GameID;
                profile.SuspendMP = true;
                profile.Save();
                pcProfileComboBox.Items.Add(profile);
                pcProfileComboBox.SelectedItem = profile;
            }
            loadProfileDropdown(selectedGame);
        }
コード例 #21
0
ファイル: DB.cs プロジェクト: brownard/MyEmulators2
        public EmulatorProfile GetProfile(Game game)
        {
            if (!game.ParentEmulator.IsPc())
            {
                return(GetProfile(game.SelectedProfileId, game.ParentEmulator));
            }

            SQLiteResultSet result = Execute("SELECT * FROM {0} WHERE uid={1} AND game_id={2}", EmulatorProfile.TABLE_NAME, game.SelectedProfileId, game.GameID);

            if (result.Rows.Count > 0)
            {
                return(EmulatorProfile.CreateProfile(result.Rows[0]));
            }

            List <EmulatorProfile> profiles = GetProfiles(game);

            if (profiles.Count > 0)
            {
                return(profiles[0]);
            }

            Logger.LogError("No profiles found for {0}, database corrupt", game.Title);
            return(null);
        }
コード例 #22
0
ファイル: Executor.cs プロジェクト: brownard/MyEmulators2
        /// <summary>
        /// Launches the specified game using the specified profile. If the specified profile is null
        /// the game's configured profile is used. If isConfig is true then any suspend settings are ignored
        /// and the specified game's playcount and playdate are not updated.
        /// </summary>
        /// <param name="game"></param>
        /// <param name="isConfig">Whether the game is being launched by Configuration. Default false.</param>
        /// <param name="profile">The profile to use when launching the game.</param>
        public void LaunchGame(string path, EmulatorProfile profile, ExecutorLaunchProgressHandler launchProgressChanged = null)
        {
            if (profile == null)
            {
                throw new LaunchException("Profile cannot be null");
            }

            bool isPC     = profile.EmulatorID == -1;
            bool isConfig = Emulators2Settings.Instance.IsConfig;

            ExecutorItem exeItem = new ExecutorItem(isPC);

            exeItem.Arguments = profile.Arguments;
            exeItem.Suspend   = !isConfig && profile.SuspendMP == true;
            if (profile.DelayResume && profile.ResumeDelay > 0)
            {
                exeItem.ResumeDelay = profile.ResumeDelay;
            }

            if (isPC)
            {
                exeItem.Path = path;
                if (!string.IsNullOrEmpty(profile.LaunchedExe))
                {
                    try { exeItem.LaunchedExe = Path.GetFileNameWithoutExtension(profile.LaunchedExe); }
                    catch { exeItem.LaunchedExe = profile.LaunchedExe; }
                }
            }
            else
            {
                exeItem.Path    = profile.EmulatorPath;
                exeItem.RomPath = path;
                exeItem.Mount   = profile.MountImages && DaemonTools.IsImageFile(Path.GetExtension(path));
                exeItem.ShouldReplaceWildcards = !exeItem.Mount;
                exeItem.UseQuotes          = profile.UseQuotes == true;
                exeItem.CheckController    = profile.CheckController;
                exeItem.StopEmulationOnKey = profile.StopEmulationOnKey.HasValue ? profile.StopEmulationOnKey.Value : Options.Instance.GetBoolOption("domap");
                exeItem.EscapeToExit       = profile.EscapeToExit;
            }
            exeItem.PreCommand = new LaunchCommand()
            {
                Command = profile.PreCommand, WaitForExit = profile.PreCommandWaitForExit, ShowWindow = profile.PreCommandShowWindow
            };
            exeItem.PostCommand = new LaunchCommand()
            {
                Command = profile.PostCommand, WaitForExit = profile.PostCommandWaitForExit, ShowWindow = profile.PostCommandShowWindow
            };
            exeItem.Init();

            //stop any media playing
            if (!isConfig && Options.Instance.GetBoolOption("stopmediaplayback") && MediaPortal.Player.g_Player.Playing)
            {
                Logger.LogDebug("Stopping playing media...");
                MediaPortal.Player.g_Player.Stop();
            }

            lock (launchSync)
            {
                launchGame(exeItem, launchProgressChanged);
            }
        }
コード例 #23
0
        //Updates the panels with the selected Emulator's details.
        private void setEmulatorToPanel(ListViewItem listViewItem)
        {
            //reset status flags
            saveSelectedEmulator = false;
            saveThumbs           = false;
            saveProfile          = false;
            //get the selected Emulator
            Emulator dbEmu = listViewItem.Tag as Emulator;

            selectedEmulator = dbEmu;

            if (dbEmu == null)
            {
                return;
            }

            allowChangedEvents = false;

            int index = platformComboBox.FindStringExact(dbEmu.PlatformTitle);

            if (index < 0)
            {
                index = 0;
            }

            if (index < platformComboBox.Items.Count)
            {
                platformComboBox.SelectedItem = platformComboBox.Items[index];
            }

            txt_Title.Text           = dbEmu.Title;
            romDirTextBox.Text       = dbEmu.PathToRoms;
            filterTextBox.Text       = dbEmu.Filter;
            isArcadeCheckBox.Checked = dbEmu.IsArcade;
            txt_company.Text         = dbEmu.Company;
            txt_yearmade.Text        = dbEmu.Year.ToString();
            txt_description.Text     = dbEmu.Description;
            gradeUpDown.Value        = dbEmu.Grade;

            EmuSettingsAutoFill.SetupAspectDropdown(thumbAspectComboBox, dbEmu.CaseAspect);

            videoTextBox.Text = dbEmu.VideoPreview;

            idLabel.Text = dbEmu.UID.ToString();

            if (emuThumbs != null)
            {
                emuThumbs.Dispose();
            }
            emuThumbs = new ThumbGroup(dbEmu);

            if (mainTabControl.SelectedTab == thumbsTabPage)
            {
                setGameArt(emuThumbs);
                thumbsLoaded = true;
            }
            else
            {
                setGameArt(null);
                thumbsLoaded = false;
            }

            txt_Manual.Text = emuThumbs.ManualPath;


            selectedProfile = null;
            profileComboBox.Items.Clear();
            foreach (EmulatorProfile profile in DB.Instance.GetProfiles(selectedEmulator))
            {
                profileComboBox.Items.Add(profile);
                if (profile.IsDefault)
                {
                    profileComboBox.SelectedItem = profile;
                    selectedProfile = profile;
                }
            }

            allowChangedEvents = true;
            profileComboBox_SelectedIndexChanged(profileComboBox, new EventArgs());
        }
コード例 #24
0
        //update Game with panel info and Commit
        void updateGame()
        {
            updateThumbs();
            updateDiscs();
            updatePCSettings();
            if (!saveSelectedGame || selectedGame == null)
            {
                return;
            }

            selectedGame.Title = txt_Title.Text;
            if (selectedListItem != null)
            {
                selectedListItem.Text = selectedGame.Title;
            }

            selectedGame.Company     = txt_company.Text;
            selectedGame.Description = txt_description.Text;
            selectedGame.Genre       = txt_genre.Text;
            try
            {
                selectedGame.Yearmade = Convert.ToInt32(txt_yearmade.Text);
            }
            catch
            {
                selectedGame.Yearmade = 0;
            }

            selectedGame.Grade = Convert.ToInt32(gradeUpDown.Value);

            selectedGame.Visible   = chk_Visible.Checked;
            selectedGame.Favourite = chk_Favourite.Checked;

            selectedGame.VideoPreview = videoTextBox.Text;

            EmulatorProfile selectedProfile = profileComboBox.SelectedItem as EmulatorProfile;

            if (selectedProfile != null)
            {
                selectedGame.SelectedProfileId = selectedProfile.ID;
            }

            for (int x = 0; x < discBindingSource.Count; x++)
            {
                if (((GameDisc)discBindingSource[x]).Selected)
                {
                    selectedGame.CurrentDiscNum = x + 1;
                    break;
                }
            }

            selectedGame.Save();

            if (itemThumbs != null)
            {
                itemThumbs.ManualPath = txt_Manual.Text;
                itemThumbs.SaveManual();
            }

            saveSelectedGame = false;
        }
コード例 #25
0
        public void StartLaunch(Game game)
        {
            if (game == null)
            {
                return;
            }

            EmulatorProfile       profile  = game.GetSelectedProfile();
            bool                  isConfig = Emulators2Settings.Instance.IsConfig;
            BackgroundTaskHandler handler  = new BackgroundTaskHandler();

            handler.ActionDelegate = () =>
            {
                string errorStr = null;
                string path     = null;
                if (game.IsGoodmerge)
                {
                    try
                    {
                        path = Extractor.Instance.ExtractGame(game, profile, (l, p) =>
                        {
                            handler.ExecuteProgressHandler(p, l);
                            return(true);
                        });
                    }
                    catch (ExtractException ex)
                    {
                        errorStr = ex.Message;
                    }
                }
                else
                {
                    path = game.CurrentDisc.Path;
                }

                GUIGraphicsContext.form.Invoke(new System.Windows.Forms.MethodInvoker(() =>
                {
                    if (path != null)
                    {
                        try
                        {
                            handler.ExecuteProgressHandler(50, "Launching " + game.Title);
                            Executor.Instance.LaunchGame(path, profile, (l, p) =>
                            {
                                handler.ExecuteProgressHandler(p, l);
                                return(true);
                            });

                            if (!isConfig)
                            {
                                game.UpdateAndSaveGamePlayInfo();
                            }
                        }
                        catch (LaunchException ex)
                        {
                            Logger.LogError(ex.Message);
                            errorStr = ex.Message;
                        }
                    }

                    if (errorStr != null)
                    {
                        Emulators2Settings.Instance.ShowMPDialog("Error\r\n{0}", errorStr);
                    }
                }));
            };

            if (isConfig)
            {
                using (Conf_ProgressDialog dlg = new Conf_ProgressDialog(handler))
                    dlg.ShowDialog();
            }
            else
            {
                GUIProgressDialogHandler guiDlg = new GUIProgressDialogHandler(handler);
                guiDlg.ShowDialog();
            }
        }