Пример #1
0
 public static void CaptureMouse()
 {
     if (AllowMouseCapture)
     {
         if (!_mouseCaptured)
         {
             EmuApi.DisplayMessage("Input", ResourceHelper.GetMessage("MouseModeEnabled"));
         }
         _mouseCaptured = true;
         HideMouse();
         Form  frm       = Application.OpenForms[0];
         Point centerPos = frm.PointToScreen(new Point(frm.Width / 2, frm.Height / 2));
         Cursor.Position = centerPos;
     }
 }
Пример #2
0
        public void SetScaleBasedOnDimensions(Size dimensions)
        {
            ScreenSize size = EmuApi.GetScreenSize(true);

            double verticalScale   = (double)dimensions.Height / size.Height;
            double horizontalScale = (double)dimensions.Width / size.Width;
            double scale           = Math.Min(verticalScale, horizontalScale);

            if (_fullscreenMode && ConfigManager.Config.Video.FullscreenForceIntegerScale)
            {
                scale = Math.Floor(scale);
            }

            SetScale(scale, false);
        }
Пример #3
0
        private static void tmrHideMouse_Tick(object sender, EventArgs e)
        {
            bool running = EmuRunner.IsRunning() && !EmuApi.IsPaused();

            if (running)
            {
                HideMouse();
                _tmrHideMouse.Stop();
            }
            else
            {
                ShowMouse();
                _tmrHideMouse.Stop();
            }
        }
Пример #4
0
 public static void SaveStateToFile()
 {
     if (EmuRunner.IsRunning())
     {
         using (SaveFileDialog sfd = new SaveFileDialog()) {
             sfd.InitialDirectory = ConfigManager.SaveStateFolder;
             sfd.FileName         = EmuApi.GetRomInfo().GetRomName() + ".mss";
             sfd.SetFilter(ResourceHelper.GetMessage("FilterSavestate"));
             if (sfd.ShowDialog(frmMain.Instance) == DialogResult.OK)
             {
                 EmuApi.SaveStateFile(sfd.FileName);
             }
         }
     }
 }
Пример #5
0
        private void SetEmulationSpeed(uint emulationSpeed)
        {
            ConfigManager.Config.Emulation.EmulationSpeed = emulationSpeed;
            ConfigManager.Config.Emulation.ApplyConfig();
            ConfigManager.ApplyChanges();

            if (emulationSpeed == 0)
            {
                EmuApi.DisplayMessage("EmulationSpeed", "EmulationMaximumSpeed");
            }
            else
            {
                EmuApi.DisplayMessage("EmulationSpeed", "EmulationSpeedPercent", emulationSpeed.ToString());
            }
        }
Пример #6
0
        private void InitMemoryTypeDropdown()
        {
            cboMemoryType.BeginUpdate();
            cboMemoryType.Items.Clear();

            if (EmuApi.GetRomInfo().CoprocessorType == CoprocessorType.Gameboy)
            {
                AddGameboyTypes();
            }
            else
            {
                cboMemoryType.Items.Add(ResourceHelper.GetEnumText(SnesMemoryType.VideoRam));
                cboMemoryType.Items.Add("-");
                cboMemoryType.Items.Add(ResourceHelper.GetEnumText(SnesMemoryType.CpuMemory));
                cboMemoryType.Items.Add(ResourceHelper.GetEnumText(SnesMemoryType.PrgRom));
                cboMemoryType.Items.Add(ResourceHelper.GetEnumText(SnesMemoryType.WorkRam));
                if (DebugApi.GetMemorySize(SnesMemoryType.SaveRam) > 0)
                {
                    cboMemoryType.Items.Add(ResourceHelper.GetEnumText(SnesMemoryType.SaveRam));
                }

                if (DebugApi.GetMemorySize(SnesMemoryType.GsuWorkRam) > 0)
                {
                    cboMemoryType.Items.Add("-");
                    cboMemoryType.Items.Add(ResourceHelper.GetEnumText(SnesMemoryType.GsuWorkRam));
                }
                if (DebugApi.GetMemorySize(SnesMemoryType.Sa1InternalRam) > 0)
                {
                    cboMemoryType.Items.Add("-");
                    cboMemoryType.Items.Add(ResourceHelper.GetEnumText(SnesMemoryType.Sa1InternalRam));
                    cboMemoryType.Items.Add(ResourceHelper.GetEnumText(SnesMemoryType.Sa1Memory));
                }
                if (DebugApi.GetMemorySize(SnesMemoryType.BsxPsRam) > 0)
                {
                    cboMemoryType.Items.Add("-");
                    cboMemoryType.Items.Add(ResourceHelper.GetEnumText(SnesMemoryType.BsxPsRam));
                }
                if (DebugApi.GetMemorySize(SnesMemoryType.BsxMemoryPack) > 0)
                {
                    cboMemoryType.Items.Add("-");
                    cboMemoryType.Items.Add(ResourceHelper.GetEnumText(SnesMemoryType.BsxMemoryPack));
                }
                AddGameboyTypes();
            }

            cboMemoryType.SelectedIndex = 0;
            cboMemoryType.EndUpdate();
        }
Пример #7
0
        protected override void OnDragEnter(DragEventArgs e)
        {
            base.OnDragEnter(e);

            try {
                if (e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    e.Effect = DragDropEffects.Copy;
                }
                else
                {
                    EmuApi.DisplayMessage("Error", "Unsupported operation.");
                }
            } catch (Exception ex) {
                MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
            }
        }
Пример #8
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == ConfigManager.Config.Debug.Shortcuts.ToggleBreakContinue)
            {
                if (EmuApi.IsPaused())
                {
                    DebugApi.ResumeExecution();
                }
                else
                {
                    DebugApi.Step(_cpuType, 1, StepType.Step);
                }
                return(true);
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Пример #9
0
        private static void ToggleRecordVideo()
        {
            if (!EmuApi.IsRunning())
            {
                return;
            }

            if (RecordApi.AviIsRecording())
            {
                RecordApi.AviStop();
            }
            else
            {
                string filename = GetOutputFilename(ConfigManager.AviFolder, ConfigManager.Config.AviRecord.Codec == VideoCodec.GIF ? ".gif" : ".avi");
                RecordApi.AviRecord(filename, ConfigManager.Config.AviRecord.Codec, ConfigManager.Config.AviRecord.CompressionLevel);
            }
        }
Пример #10
0
        private static void ToggleRecordAudio()
        {
            if (!EmuApi.IsRunning())
            {
                return;
            }

            if (RecordApi.WaveIsRecording())
            {
                RecordApi.WaveStop();
            }
            else
            {
                string filename = GetOutputFilename(ConfigManager.WaveFolder, ".wav");
                RecordApi.WaveRecord(filename);
            }
        }
Пример #11
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            HistoryViewerApi.HistoryViewerInitialize(this.Handle, ctrlRenderer.Handle);
            trkPosition.Maximum = (int)(HistoryViewerApi.HistoryViewerGetHistoryLength() / 60);
            UpdatePositionLabel(0);
            EmuApi.Resume(EmuApi.ConsoleId.HistoryViewer);
            tmrUpdatePosition.Start();
            trkVolume.Value = ConfigManager.Config.HistoryViewer.Volume;
            btnPausePlay.Focus();

            UpdateScale();
            this.Resize += (s, evt) => {
                UpdateScale();
            };
        }
Пример #12
0
        public static void LoadPatchFile(string patchFile)
        {
            string        patchFolder  = Path.GetDirectoryName(patchFile);
            List <string> romsInFolder = new List <string>();

            foreach (string filepath in Directory.EnumerateFiles(patchFolder))
            {
                if (FolderHelper.IsRomFile(filepath))
                {
                    romsInFolder.Add(filepath);
                }
            }

            if (romsInFolder.Count == 1)
            {
                //There is a single rom in the same folder as the IPS/BPS patch, use it automatically
                LoadRom(romsInFolder[0], patchFile);
            }
            else
            {
                if (!IsRunning())
                {
                    //Prompt the user for a rom to load
                    if (MesenMsgBox.Show("SelectRomIps", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        using (OpenFileDialog ofd = new OpenFileDialog()) {
                            ofd.SetFilter(ResourceHelper.GetMessage("FilterRom"));
                            if (ConfigManager.Config.RecentFiles.Items.Count > 0)
                            {
                                ofd.InitialDirectory = ConfigManager.Config.RecentFiles.Items[0].RomFile.Folder;
                            }

                            if (ofd.ShowDialog(frmMain.Instance) == DialogResult.OK)
                            {
                                LoadRom(ofd.FileName, patchFile);
                            }
                        }
                    }
                }
                else if (MesenMsgBox.Show("PatchAndReset", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    //Confirm that the user wants to patch the current rom and reset
                    LoadRom(EmuApi.GetRomInfo().RomPath, patchFile);
                }
            }
        }
Пример #13
0
 public static void LoadFile(string filename)
 {
     if (File.Exists(filename))
     {
         if (IsPatchFile(filename))
         {
             LoadPatchFile(filename);
         }
         else if (Path.GetExtension(filename).ToLowerInvariant() == ".mss")
         {
             EmuApi.LoadStateFile(filename);
         }
         else
         {
             LoadRom(filename);
         }
     }
 }
Пример #14
0
        protected override void OnDragDrop(DragEventArgs e)
        {
            base.OnDragDrop(e);

            try {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
                if (File.Exists(files[0]))
                {
                    EmuRunner.LoadFile(files[0]);
                    this.Activate();
                }
                else
                {
                    EmuApi.DisplayMessage("Error", "File not found: " + files[0]);
                }
            } catch (Exception ex) {
                MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
            }
        }
Пример #15
0
        public frmAbout()
        {
            InitializeComponent();

            lblMesenVersion.Text = EmuApi.GetMesenVersion().ToString(3);

            Version  ver       = Assembly.GetEntryAssembly().GetName().Version;
            DateTime buildTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddDays(ver.Build).AddSeconds(ver.Revision * 2);

            lblBuildDate.Text = buildTime.ToShortDateString() + " " + buildTime.ToShortTimeString();

#if AUTOBUILD
            string devVersion = ResourceExtractor.ReadZippedResource("DevBuild.txt");
            if (devVersion != null)
            {
                lblMesenVersion.Text = devVersion;
            }
#endif
        }
Пример #16
0
        public static void ImportDbgFile()
        {
            _symbolProvider = null;

            if (ConfigManager.Config.Debug.DbgIntegration.AutoImport)
            {
                RomInfo romInfo = EmuApi.GetRomInfo();
                string  dbgPath = Path.Combine(((ResourcePath)romInfo.RomPath).Folder, romInfo.GetRomName() + ".dbg");
                if (File.Exists(dbgPath))
                {
                    _symbolProvider = new DbgImporter();
                    _symbolProvider.Import(dbgPath, true);
                    SymbolProviderChanged?.Invoke(_symbolProvider);
                    LabelManager.RefreshLabels();
                }
            }

            SymbolProviderChanged?.Invoke(_symbolProvider);
        }
Пример #17
0
        public frmAssembler(CpuType?cpuType = null, string code = "", int startAddress = 0, int blockLength = 0)
        {
            if (cpuType != null)
            {
                _cpuType = cpuType.Value;
            }
            else
            {
                _cpuType = EmuApi.GetRomInfo().CoprocessorType == CoprocessorType.Gameboy ? CpuType.Gameboy : CpuType.Cpu;
            }

            if (_cpuType == CpuType.Sa1)
            {
                _cpuType = CpuType.Cpu;
            }

            InitializeComponent();

            txtCode.ForeColor = Color.Black;

            AssemblerConfig cfg = ConfigManager.Config.Debug.Assembler;

            RestoreLocation(cfg.WindowLocation, cfg.WindowSize);
            txtCode.Font = new Font(cfg.FontFamily, cfg.FontSize, cfg.FontStyle);
            txtCode.Zoom = cfg.Zoom;

            UpdateCodeHighlighting();

            _initialCode  = code;
            _startAddress = startAddress;
            _blockLength  = blockLength;

            ctrlHexBox.Font = new Font(BaseControl.MonospaceFontFamily, 10, FontStyle.Regular);
            ctrlHexBox.SelectionForeColor = Color.White;
            ctrlHexBox.SelectionBackColor = Color.FromArgb(31, 123, 205);
            ctrlHexBox.InfoBackColor      = Color.FromArgb(235, 235, 235);
            ctrlHexBox.InfoForeColor      = Color.Gray;
            ctrlHexBox.Width        = ctrlHexBox.RequiredWidth;
            ctrlHexBox.ByteProvider = new StaticByteProvider(new byte[0]);

            txtStartAddress.Text = _startAddress.ToString("X6");
        }
Пример #18
0
        public static void OnMouseMove(Control ctrl)
        {
            if (_mouseCaptured && AllowMouseCapture)
            {
                HideMouse();
                _tmrHideMouse.Stop();
                Form  frm       = frmMain.Instance;
                Point centerPos = frm.PointToScreen(new Point(frm.Width / 2, frm.Height / 2));
                Point diff      = new Point(Cursor.Position.X - centerPos.X, Cursor.Position.Y - centerPos.Y);
                if (diff.X != 0 || diff.Y != 0)
                {
                    InputApi.SetMouseMovement((Int16)diff.X, (Int16)diff.Y);
                    Cursor.Position = centerPos;
                }
            }
            else
            {
                _mouseCaptured = false;

                if (!EmuRunner.IsRunning() || EmuApi.IsPaused())
                {
                    ShowMouse();
                }                 /* TODO else if(ConfigManager.Config.Input.HideMousePointerForZapper && CursorManager.IsLightGun) {
                                   *    //Keep mouse hidden when using zapper if option to hide mouse is enabled
                                   *    HideMouse();
                                   *    return;
                                   * }*/

                _tmrHideMouse.Stop();

                if (!CursorManager.NeedMouseIcon)
                {
                    //Only hide mouse if no zapper (otherwise this could be pretty annoying)
                    ctrl.Cursor = Cursors.Default;

                    if (EmuRunner.IsRunning() && !EmuApi.IsPaused())
                    {
                        _tmrHideMouse.Start();
                    }
                }
            }
        }
Пример #19
0
        public void RefreshViewer()
        {
            EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions();

            _isGameboy = EmuApi.GetRomInfo().CoprocessorType == CoprocessorType.Gameboy;
            if (_isGameboy)
            {
                _baseWidth = 456 * 2;
                _xRatio    = 0.5;
            }
            else
            {
                _baseWidth = 1364 / 2;
                _xRatio    = 2;
            }
            _pictureData = DebugApi.GetEventViewerOutput(_baseWidth, ScanlineCount, options);

            int picHeight = (int)ScanlineCount * 2;

            if (_screenBitmap == null || _screenBitmap.Height != picHeight || _screenBitmap.Width != _baseWidth)
            {
                _screenBitmap  = new Bitmap(_baseWidth, picHeight, PixelFormat.Format32bppPArgb);
                _overlayBitmap = new Bitmap(_baseWidth, picHeight, PixelFormat.Format32bppPArgb);
                _displayBitmap = new Bitmap(_baseWidth, picHeight, PixelFormat.Format32bppPArgb);
            }

            GCHandle handle = GCHandle.Alloc(this._pictureData, GCHandleType.Pinned);

            try {
                Bitmap source = new Bitmap(_baseWidth, (int)ScanlineCount * 2, _baseWidth * 4, PixelFormat.Format32bppPArgb, handle.AddrOfPinnedObject());
                using (Graphics g = Graphics.FromImage(_screenBitmap)) {
                    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                    g.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.None;
                    g.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.None;
                    g.DrawImageUnscaled(source, 0, 0);
                }
            } finally {
                handle.Free();
            }

            UpdateDisplay(true);
        }
Пример #20
0
        public static bool PerformUpgrade()
        {
            Version newVersion = EmuApi.GetMesenVersion();
            Version oldVersion = new Version(ConfigManager.Config.Version);

            if (oldVersion < newVersion)
            {
                //Upgrade
                if (oldVersion <= new Version("0.1.0"))
                {
                    ConfigManager.Config.Audio.MasterVolume = 100;
                }

                ConfigManager.Config.Version = EmuApi.GetMesenVersion().ToString();
                ConfigManager.ApplyChanges();

                return(true);
            }
            return(false);
        }
Пример #21
0
        public static void ImportSymFile(string symPath, bool silent = false)
        {
            if (ConfigManager.Config.Debug.DbgIntegration.ResetLabelsOnImport)
            {
                ResetLabels();
            }

            if (symPath.EndsWith(".tass"))
            {
                Tass64DumpLabels.Import(symPath, silent);
            }
            else
            {
                string symContent = File.ReadAllText(symPath);
                if (symContent.Contains("[labels]"))
                {
                    //Assume WLA-DX symbol files
                    new WlaDxImporter().Import(symPath, silent);
                }
                else
                {
                    RomInfo romInfo = EmuApi.GetRomInfo();
                    if (romInfo.CoprocessorType == CoprocessorType.Gameboy || romInfo.CoprocessorType == CoprocessorType.SGB)
                    {
                        if (RgbdsSymbolFile.IsValidFile(symPath))
                        {
                            RgbdsSymbolFile.Import(symPath, silent);
                        }
                        else
                        {
                            BassLabelFile.Import(symPath, silent);
                        }
                    }
                    else
                    {
                        BassLabelFile.Import(symPath, silent);
                    }
                }
            }
            LabelManager.RefreshLabels();
        }
Пример #22
0
        public void UpdateViewerSize()
        {
            if (HideMenuStrip)
            {
                _menu.Visible = false;
            }

            ScreenSize screenSize = EmuApi.GetScreenSize(false);

            if (_resizeForm && _frm.WindowState != FormWindowState.Maximized)
            {
                _frm.Resize -= frmMain_Resize;
                Size newSize = new Size(screenSize.Width, screenSize.Height);
                _frm.ClientSize = new Size(newSize.Width, newSize.Height + (HideMenuStrip ? 0 : _panel.Top));
                _frm.Resize    += frmMain_Resize;
            }

            _renderer.Size = new Size(screenSize.Width, screenSize.Height);
            _renderer.Top  = (_panel.Height - _renderer.Height) / 2;
            _renderer.Left = (_panel.Width - _renderer.Width) / 2;
        }
Пример #23
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);

            DebugApi.ResumeExecution();
            DebugWindowManager.CloseAll();

            EmuApi.Stop();

            if (_notifListener != null)
            {
                _notifListener.Dispose();
                _notifListener = null;
            }

            ConfigManager.Config.WindowLocation = this.WindowState == FormWindowState.Normal ? this.Location : this.RestoreBounds.Location;
            ConfigManager.Config.WindowSize     = this.WindowState == FormWindowState.Normal ? this.Size : this.RestoreBounds.Size;
            ConfigManager.ApplyChanges();

            EmuApi.Release();
        }
Пример #24
0
        private void SaveRomAs(bool saveAsIps, CdlStripOption cdlStripOption)
        {
            using (SaveFileDialog sfd = new SaveFileDialog()) {
                if (saveAsIps)
                {
                    sfd.SetFilter("IPS files (*.ips)|*.ips");
                    sfd.FileName = EmuApi.GetRomInfo().GetRomName() + ".ips";
                }
                else
                {
                    sfd.SetFilter("SFC files (*.sfc)|*.sfc");
                    sfd.FileName = EmuApi.GetRomInfo().GetRomName() + "_Modified.sfc";
                }

                sfd.InitialDirectory = ConfigManager.DebuggerFolder;
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    DebugApi.SaveRomToDisk(sfd.FileName, saveAsIps, cdlStripOption);
                }
            }
        }
Пример #25
0
        private static void tmrUpdateBackground_Tick(object sender, EventArgs e)
        {
            Form focusedForm = null;

            foreach (Form form in Application.OpenForms)
            {
                if (form.ContainsFocus)
                {
                    focusedForm = form;
                    break;
                }
            }

            PreferencesConfig cfg = ConfigManager.Config.Preferences;

            bool needPause = focusedForm == null && cfg.PauseWhenInBackground;

            if (focusedForm != null)
            {
                needPause |= cfg.PauseWhenInMenusAndConfig && focusedForm is BaseForm && (((BaseForm)focusedForm).InMenu || ((BaseForm)focusedForm).IsConfigForm);
                needPause |= cfg.PauseWhenInMenusAndConfig && !(focusedForm is BaseInputForm) && !focusedForm.GetType().FullName.Contains("Debugger");
                needPause |= cfg.PauseWhenInDebuggingTools && focusedForm.GetType().FullName.Contains("Debugger");
            }

            if (needPause)
            {
                if (!EmuApi.IsPaused())
                {
                    _needResume = true;
                    EmuApi.Pause();
                }
            }
            else if (_needResume)
            {
                EmuApi.Resume();
                _needResume = false;
            }

            ConfigApi.SetEmulationFlag(EmulationFlags.InBackground, focusedForm == null);
        }
Пример #26
0
        public static DebugWorkspace GetWorkspace()
        {
            string romName = EmuApi.GetRomInfo().GetRomName();

            if (_workspace == null || _romName != romName)
            {
                if (_workspace != null)
                {
                    SaveWorkspace();
                }
                _romName   = romName;
                _workspace = DebugWorkspace.GetWorkspace();

                //Load watch entries
                WatchManager.GetWatchManager(CpuType.Cpu).WatchEntries = _workspace.WatchValues;
                WatchManager.GetWatchManager(CpuType.Spc).WatchEntries = _workspace.SpcWatchValues;

                //Load breakpoints
                BreakpointManager.SetBreakpoints(_workspace.Breakpoints);
            }
            return(_workspace);
        }
Пример #27
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            EmuApi.InitDll();
            ConfigManager.Config.Video.ApplyConfig();
            EmuApi.InitializeEmu(ConfigManager.HomeFolder, Handle, ctrlRenderer.Handle, false, false, false);

            ConfigManager.Config.InitializeDefaults();
            ConfigManager.Config.ApplyConfig();

            _displayManager = new DisplayManager(this, ctrlRenderer, pnlRenderer, mnuMain, ctrlRecentGames);
            _displayManager.UpdateViewerSize();
            _shortcuts = new ShortcutHandler(_displayManager);

            _notifListener = new NotificationListener();
            _notifListener.OnNotification += OnNotificationReceived;

            SaveStateManager.InitializeStateMenu(mnuSaveState, true, _shortcuts);
            SaveStateManager.InitializeStateMenu(mnuLoadState, false, _shortcuts);

            BindShortcuts();

            ctrlRecentGames.Initialize();
            ResizeRecentGames();

            _commandLine.LoadGameFromCommandLine();
            if (!EmuRunner.IsRunning())
            {
                ctrlRecentGames.Visible = true;
            }

            if (ConfigManager.Config.Preferences.AutomaticallyCheckForUpdates)
            {
                UpdateHelper.CheckForUpdates(true);
            }

            this.Resize += frmMain_Resize;
        }
Пример #28
0
        public void RefreshData()
        {
            _state = DebugApi.GetState();

            if (EmuApi.GetRomInfo().CoprocessorType == CoprocessorType.Gameboy)
            {
                _cgram = ctrlPaletteViewer.GetGameboyPalette();
            }
            else
            {
                _cgram = DebugApi.GetMemoryState(SnesMemoryType.CGRam);
            }

            byte[] source = DebugApi.GetMemoryState(_memoryType);

            int size = Math.Min(source.Length - _address, _options.PageSize);

            _tileSource = new byte[0x40000];
            Array.Copy(source, _address, _tileSource, 0, size);

            ctrlPaletteViewer.RefreshData();
        }
Пример #29
0
        public void ProcessClick()
        {
            if (!this.Enabled)
            {
                return;
            }

            if (Path.GetExtension(_recentGame.FileName) == ".rgd")
            {
                EmuRunner.LoadRecentGame(_recentGame.FileName);
            }
            else
            {
                switch (this.Mode)
                {
                case GameScreenMode.LoadState: EmuApi.LoadState(_recentGame.SaveSlot); break;

                case GameScreenMode.SaveState: EmuApi.SaveState(_recentGame.SaveSlot); break;
                }
            }
            OnRecentGameLoaded?.Invoke(_recentGame);
        }
Пример #30
0
        public static void CheckForUpdates(bool silent)
        {
            Task.Run(() => {
                try {
                    using (var client = new WebClient()) {
                        XmlDocument xmlDoc = new XmlDocument();

                        string platform = Program.IsMono ? "linux" : "win";
                        xmlDoc.LoadXml(client.DownloadString("https://www.mesen.ca/snes/Services/GetLatestVersion.php?v=" + EmuApi.GetMesenVersion().ToString(3) + "&p=" + platform + "&l=" + ResourceHelper.GetLanguageCode()));
                        Version currentVersion = EmuApi.GetMesenVersion();
                        Version latestVersion  = new Version(xmlDoc.SelectSingleNode("VersionInfo/LatestVersion").InnerText);
                        string changeLog       = xmlDoc.SelectSingleNode("VersionInfo/ChangeLog").InnerText;
                        string fileHash        = xmlDoc.SelectSingleNode("VersionInfo/Sha1Hash").InnerText;
                        string donateText      = xmlDoc.SelectSingleNode("VersionInfo/DonateText")?.InnerText;

                        if (latestVersion > currentVersion)
                        {
                            Application.OpenForms[0].BeginInvoke((MethodInvoker)(() => {
                                using (frmUpdatePrompt frmUpdate = new frmUpdatePrompt(currentVersion, latestVersion, changeLog, fileHash, donateText)) {
                                    if (frmUpdate.ShowDialog(null, Application.OpenForms[0]) == DialogResult.OK)
                                    {
                                        Application.Exit();
                                    }
                                }
                            }));
                        }
                        else if (!silent)
                        {
                            MesenMsgBox.Show("MesenUpToDate", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                } catch (Exception ex) {
                    if (!silent)
                    {
                        MesenMsgBox.Show("ErrorWhileCheckingUpdates", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
                    }
                }
            });
        }