コード例 #1
0
        private void SoundConfig_Load(object sender, EventArgs e)
        {
            SoundOnCheckBox.Checked  = Global.Config.SoundEnabled;
            MuteFrameAdvance.Checked = Global.Config.MuteFrameAdvance;
            ThrottlecheckBox.Checked = Global.Config.SoundThrottle;
            SoundVolBar.Value        = Global.Config.SoundVolume;
            SoundVolNumeric.Value    = Global.Config.SoundVolume;
            UpdateSoundDialog();

            // vestigal
            ThrottlecheckBox.Visible = false;


            var dd = SoundEnumeration.DeviceNames();

            listBoxSoundDevices.Items.Add("<default>");
            listBoxSoundDevices.SelectedIndex = 0;
            foreach (var d in dd)
            {
                listBoxSoundDevices.Items.Add(d);
                if (d == Global.Config.SoundDevice)
                {
                    listBoxSoundDevices.SelectedItem = d;
                }
            }
        }
コード例 #2
0
        static void SubMain(string[] args)
        {
            // this check has to be done VERY early.  i stepped through a debug build with wrong .dll versions purposely used,
            // and there was a TypeLoadException before the first line of SubMain was reached (some static ColorType init?)
            // zero 25-dec-2012 - only do for public builds. its annoying during development
            if (!VersionInfo.DeveloperBuild)
            {
                var thisversion = typeof(Program).Assembly.GetName().Version;
                var utilversion = Assembly.LoadWithPartialName("Bizhawk.Client.Common").GetName().Version;
                var emulversion = Assembly.LoadWithPartialName("Bizhawk.Emulation.Cores").GetName().Version;

                if (thisversion != utilversion || thisversion != emulversion)
                {
                    MessageBox.Show("Conflicting revisions found!  Don't mix .dll versions!");
                    return;
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            string iniPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini");

            Global.Config = ConfigService.Load <Config>(iniPath);
            Global.Config.ResolveDefaults();
            HawkFile.ArchiveHandlerFactory = new SevenZipSharpArchiveHandler();

#if WINDOWS
            try { GlobalWin.DSound = SoundEnumeration.Create(); }
            catch
            {
                MessageBox.Show("Couldn't initialize DirectSound! Things may go poorly for you. Try changing your sound driver to 41khz instead of 48khz in mmsys.cpl.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
#endif

            //create IGL context.
            //at some point in the future, we may need to select from several drivers
            GlobalWin.GL        = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK();
            GlobalWin.GLManager = new GLManager();
            GlobalWin.CR_GL     = GlobalWin.GLManager.GetContextForIGL(GlobalWin.GL);

            //WHY do we have to do this? some intel graphics drivers (ig7icd64.dll 10.18.10.3304 on an unknown chip on win8.1) are calling SetDllDirectory() for the process, which ruins stuff.
            //The relevant initialization happened just before in "create IGL context".
            //It isn't clear whether we need the earlier SetDllDirectory(), but I think we do.
            //note: this is pasted instead of being put in a static method due to this initialization code being sensitive to things like that, and not wanting to cause it to break
            //pasting should be safe (not affecting the jit order of things)
            string dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll");
            SetDllDirectory(dllDir);

            try
            {
#if WINDOWS
                if (Global.Config.SingleInstanceMode)
                {
                    try
                    {
                        new SingleInstanceController(args).Run(args);
                    }
                    catch (ObjectDisposedException)
                    {
                        /*Eat it, MainForm disposed itself and Run attempts to dispose of itself.  Eventually we would want to figure out a way to prevent that, but in the meantime it is harmless, so just eat the error*/
                    }
                }
                else
                {
#endif
                using (var mf = new MainForm(args))
                {
                    var title = mf.Text;
                    mf.Show();
                    mf.Text = title;
                    try
                    {
                        mf.ProgramRunLoop();
                    }
                    catch (Exception e)
                    {
#if WINDOWS
                        if (!VersionInfo.DeveloperBuild && Global.MovieSession.Movie.IsActive)
                        {
                            var result = MessageBox.Show(
                                "EmuHawk has thrown a fatal exception and is about to close.\nA movie has been detected. Would you like to try to save?\n(Note: Depending on what caused this error, this may or may succeed)",
                                "Fatal error: " + e.GetType().Name,
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Exclamation
                                );
                            if (result == DialogResult.Yes)
                            {
                                Global.MovieSession.Movie.Save();
                            }
                        }
#endif
                        throw;
                    }
                }
#if WINDOWS
            }
#endif
            }
            catch (Exception e)
            {
                string message = e.ToString();
                if (e.InnerException != null)
                {
                    message += "\n\nInner Exception:\n\n" + e.InnerException;
                }

                message += "\n\nStackTrace:\n" + e.StackTrace;
                MessageBox.Show(message);
            }
#if WINDOWS
            finally
            {
                if (GlobalWin.DSound != null && GlobalWin.DSound.Disposed == false)
                {
                    GlobalWin.DSound.Dispose();
                }
                GlobalWin.GL.Dispose();
                GamePad.CloseAll();
            }
#endif
        }