2019-02-12 22:13:09 -05:00
|
|
|
|
using Mesen.GUI.Config;
|
2019-03-11 17:56:54 -04:00
|
|
|
|
using Mesen.GUI.Config.Shortcuts;
|
2019-02-12 22:13:09 -05:00
|
|
|
|
using Mesen.GUI.Debugger;
|
2019-03-28 22:40:52 -04:00
|
|
|
|
using Mesen.GUI.Debugger.Workspace;
|
2019-03-12 09:15:57 -04:00
|
|
|
|
using Mesen.GUI.Emulation;
|
2019-03-10 11:12:50 -04:00
|
|
|
|
using Mesen.GUI.Forms.Config;
|
2019-03-14 12:34:29 -04:00
|
|
|
|
using Mesen.GUI.Updates;
|
2019-03-15 12:24:02 -04:00
|
|
|
|
using Mesen.GUI.Utilities;
|
2019-02-12 22:13:09 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
2019-03-14 12:34:29 -04:00
|
|
|
|
using System.Diagnostics;
|
2019-02-12 22:13:09 -05:00
|
|
|
|
using System.Drawing;
|
2019-02-15 21:33:13 -05:00
|
|
|
|
using System.IO;
|
2019-02-12 22:13:09 -05:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Forms
|
|
|
|
|
{
|
2019-02-17 19:54:29 -05:00
|
|
|
|
public partial class frmMain : BaseInputForm
|
2019-02-12 22:13:09 -05:00
|
|
|
|
{
|
2019-02-16 08:10:08 -05:00
|
|
|
|
private NotificationListener _notifListener;
|
2019-03-11 17:56:54 -04:00
|
|
|
|
private ShortcutHandler _shortcuts;
|
2019-03-14 23:30:47 -04:00
|
|
|
|
private DisplayManager _displayManager;
|
2019-03-15 12:24:02 -04:00
|
|
|
|
private CommandLineHelper _commandLine;
|
2019-02-16 08:10:08 -05:00
|
|
|
|
|
2019-02-12 22:13:09 -05:00
|
|
|
|
public frmMain(string[] args)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2019-03-14 23:30:47 -04:00
|
|
|
|
if(DesignMode) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-15 12:24:02 -04:00
|
|
|
|
_commandLine = new CommandLineHelper(args);
|
|
|
|
|
|
2019-02-12 22:13:09 -05:00
|
|
|
|
ResourceHelper.LoadResources(Language.English);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-14 20:54:04 -04:00
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnLoad(e);
|
|
|
|
|
|
|
|
|
|
if(!ConfigManager.Config.WindowSize.IsEmpty) {
|
|
|
|
|
this.StartPosition = FormStartPosition.Manual;
|
|
|
|
|
this.Location = ConfigManager.Config.WindowLocation;
|
|
|
|
|
this.Size = ConfigManager.Config.WindowSize;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-12 22:13:09 -05:00
|
|
|
|
protected override void OnShown(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnShown(e);
|
|
|
|
|
|
|
|
|
|
EmuApi.InitDll();
|
2019-03-11 17:56:54 -04:00
|
|
|
|
ConfigManager.Config.Video.ApplyConfig();
|
2019-02-12 22:13:09 -05:00
|
|
|
|
EmuApi.InitializeEmu(ConfigManager.HomeFolder, Handle, ctrlRenderer.Handle, false, false, false);
|
2019-02-16 08:10:08 -05:00
|
|
|
|
|
2019-03-11 17:56:54 -04:00
|
|
|
|
ConfigManager.Config.InitializeDefaults();
|
2019-03-10 11:12:50 -04:00
|
|
|
|
ConfigManager.Config.ApplyConfig();
|
|
|
|
|
|
2019-03-15 11:15:47 -04:00
|
|
|
|
_displayManager = new DisplayManager(this, ctrlRenderer, pnlRenderer, mnuMain, ctrlRecentGames);
|
2019-03-15 10:15:45 -04:00
|
|
|
|
_displayManager.UpdateViewerSize();
|
2019-03-14 23:30:47 -04:00
|
|
|
|
_shortcuts = new ShortcutHandler(_displayManager);
|
|
|
|
|
|
2019-02-16 08:10:08 -05:00
|
|
|
|
_notifListener = new NotificationListener();
|
|
|
|
|
_notifListener.OnNotification += OnNotificationReceived;
|
2019-03-14 23:30:47 -04:00
|
|
|
|
|
2019-03-12 09:15:57 -04:00
|
|
|
|
SaveStateManager.InitializeStateMenu(mnuSaveState, true, _shortcuts);
|
|
|
|
|
SaveStateManager.InitializeStateMenu(mnuLoadState, false, _shortcuts);
|
|
|
|
|
|
2019-03-11 17:56:54 -04:00
|
|
|
|
BindShortcuts();
|
2019-03-14 18:07:25 -04:00
|
|
|
|
|
|
|
|
|
ctrlRecentGames.Initialize();
|
2019-03-14 23:30:47 -04:00
|
|
|
|
ResizeRecentGames();
|
2019-03-14 20:54:04 -04:00
|
|
|
|
|
2019-03-15 12:24:02 -04:00
|
|
|
|
_commandLine.LoadGameFromCommandLine();
|
|
|
|
|
if(!EmuRunner.IsRunning()) {
|
|
|
|
|
ctrlRecentGames.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-14 20:54:04 -04:00
|
|
|
|
this.Resize += frmMain_Resize;
|
2019-02-12 22:13:09 -05:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-16 01:22:31 -05:00
|
|
|
|
protected override void OnFormClosing(FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnFormClosing(e);
|
|
|
|
|
|
2019-03-31 14:50:12 -04:00
|
|
|
|
DebugApi.ResumeExecution();
|
|
|
|
|
DebugWindowManager.CloseAll();
|
|
|
|
|
|
|
|
|
|
EmuApi.Stop();
|
|
|
|
|
|
2019-02-16 08:10:08 -05:00
|
|
|
|
if(_notifListener != null) {
|
|
|
|
|
_notifListener.Dispose();
|
|
|
|
|
_notifListener = null;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-14 20:54:04 -04:00
|
|
|
|
ConfigManager.Config.WindowLocation = this.WindowState == FormWindowState.Normal ? this.Location : this.RestoreBounds.Location;
|
|
|
|
|
ConfigManager.Config.WindowSize = this.WindowState == FormWindowState.Normal ? this.Size : this.RestoreBounds.Size;
|
2019-03-10 11:12:50 -04:00
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
|
2019-02-16 01:22:31 -05:00
|
|
|
|
EmuApi.Release();
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-16 08:10:08 -05:00
|
|
|
|
private void OnNotificationReceived(NotificationEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch(e.NotificationType) {
|
2019-03-12 09:15:57 -04:00
|
|
|
|
case ConsoleNotificationType.GameLoaded:
|
|
|
|
|
this.BeginInvoke((Action)(() => {
|
2019-03-30 22:41:37 -04:00
|
|
|
|
UpdateDebuggerMenu();
|
2019-03-14 18:07:25 -04:00
|
|
|
|
ctrlRecentGames.Visible = false;
|
2019-03-12 09:15:57 -04:00
|
|
|
|
SaveStateManager.UpdateStateMenu(mnuLoadState, false);
|
|
|
|
|
SaveStateManager.UpdateStateMenu(mnuSaveState, true);
|
2019-03-28 21:20:18 -04:00
|
|
|
|
|
|
|
|
|
RomInfo romInfo = EmuApi.GetRomInfo();
|
|
|
|
|
this.Text = "Mesen-S - " + romInfo.GetRomName();
|
2019-03-28 22:40:52 -04:00
|
|
|
|
|
|
|
|
|
if(DebugWindowManager.HasOpenedWindow) {
|
|
|
|
|
DebugWorkspaceManager.GetWorkspace();
|
|
|
|
|
}
|
2019-03-12 09:15:57 -04:00
|
|
|
|
}));
|
|
|
|
|
break;
|
|
|
|
|
|
2019-03-30 22:41:37 -04:00
|
|
|
|
case ConsoleNotificationType.BeforeEmulationStop:
|
|
|
|
|
this.Invoke((Action)(() => {
|
|
|
|
|
DebugWindowManager.CloseAll();
|
|
|
|
|
}));
|
|
|
|
|
break;
|
|
|
|
|
|
2019-03-14 18:07:25 -04:00
|
|
|
|
case ConsoleNotificationType.EmulationStopped:
|
|
|
|
|
this.BeginInvoke((Action)(() => {
|
2019-03-31 15:15:35 -04:00
|
|
|
|
this.Text = "Mesen-S";
|
2019-03-30 22:41:37 -04:00
|
|
|
|
UpdateDebuggerMenu();
|
2019-03-14 18:07:25 -04:00
|
|
|
|
ctrlRecentGames.Initialize();
|
|
|
|
|
ctrlRecentGames.Visible = true;
|
2019-03-14 20:54:04 -04:00
|
|
|
|
ResizeRecentGames();
|
2019-03-15 11:39:57 -04:00
|
|
|
|
if(_displayManager.ExclusiveFullscreen) {
|
|
|
|
|
_displayManager.SetFullscreenState(false);
|
|
|
|
|
}
|
2019-03-14 18:07:25 -04:00
|
|
|
|
}));
|
|
|
|
|
break;
|
|
|
|
|
|
2019-03-15 10:15:45 -04:00
|
|
|
|
case ConsoleNotificationType.ResolutionChanged:
|
|
|
|
|
this.BeginInvoke((Action)(() => {
|
|
|
|
|
_displayManager.UpdateViewerSize();
|
|
|
|
|
}));
|
|
|
|
|
break;
|
|
|
|
|
|
2019-03-11 17:56:54 -04:00
|
|
|
|
case ConsoleNotificationType.ExecuteShortcut:
|
|
|
|
|
this.BeginInvoke((Action)(() => {
|
|
|
|
|
_shortcuts.ExecuteShortcut((EmulatorShortcut)e.Parameter);
|
|
|
|
|
}));
|
|
|
|
|
break;
|
2019-02-16 08:10:08 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-11 17:56:54 -04:00
|
|
|
|
|
2019-03-15 11:15:47 -04:00
|
|
|
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
|
|
|
|
{
|
|
|
|
|
if(_displayManager.HideMenuStrip && (keyData & Keys.Alt) == Keys.Alt) {
|
|
|
|
|
if(mnuMain.Visible && !mnuMain.ContainsFocus) {
|
|
|
|
|
mnuMain.Visible = false;
|
|
|
|
|
} else {
|
|
|
|
|
mnuMain.Visible = true;
|
|
|
|
|
mnuMain.Focus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return base.ProcessCmdKey(ref msg, keyData);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 17:56:54 -04:00
|
|
|
|
private void BindShortcuts()
|
|
|
|
|
{
|
|
|
|
|
Func<bool> notClient = () => { return true; }; //TODO
|
|
|
|
|
Func<bool> runningNotClient = () => { return EmuRunner.IsRunning(); }; //TODO
|
|
|
|
|
Func<bool> runningNotClientNotMovie = () => { return EmuRunner.IsRunning(); }; //TODO
|
|
|
|
|
|
|
|
|
|
_shortcuts.BindShortcut(mnuOpen, EmulatorShortcut.OpenFile);
|
|
|
|
|
_shortcuts.BindShortcut(mnuExit, EmulatorShortcut.Exit);
|
|
|
|
|
_shortcuts.BindShortcut(mnuIncreaseSpeed, EmulatorShortcut.IncreaseSpeed, notClient);
|
|
|
|
|
_shortcuts.BindShortcut(mnuDecreaseSpeed, EmulatorShortcut.DecreaseSpeed, notClient);
|
|
|
|
|
_shortcuts.BindShortcut(mnuEmuSpeedMaximumSpeed, EmulatorShortcut.MaxSpeed, notClient);
|
|
|
|
|
|
|
|
|
|
_shortcuts.BindShortcut(mnuPause, EmulatorShortcut.Pause, runningNotClient);
|
|
|
|
|
_shortcuts.BindShortcut(mnuReset, EmulatorShortcut.Reset, runningNotClientNotMovie);
|
|
|
|
|
_shortcuts.BindShortcut(mnuPowerCycle, EmulatorShortcut.PowerCycle, runningNotClientNotMovie);
|
|
|
|
|
_shortcuts.BindShortcut(mnuPowerOff, EmulatorShortcut.PowerOff, runningNotClient);
|
|
|
|
|
|
|
|
|
|
_shortcuts.BindShortcut(mnuShowFPS, EmulatorShortcut.ToggleFps);
|
|
|
|
|
|
|
|
|
|
_shortcuts.BindShortcut(mnuScale1x, EmulatorShortcut.SetScale1x);
|
|
|
|
|
_shortcuts.BindShortcut(mnuScale2x, EmulatorShortcut.SetScale2x);
|
|
|
|
|
_shortcuts.BindShortcut(mnuScale3x, EmulatorShortcut.SetScale3x);
|
|
|
|
|
_shortcuts.BindShortcut(mnuScale4x, EmulatorShortcut.SetScale4x);
|
|
|
|
|
_shortcuts.BindShortcut(mnuScale5x, EmulatorShortcut.SetScale5x);
|
|
|
|
|
_shortcuts.BindShortcut(mnuScale6x, EmulatorShortcut.SetScale6x);
|
|
|
|
|
|
|
|
|
|
_shortcuts.BindShortcut(mnuFullscreen, EmulatorShortcut.ToggleFullscreen);
|
|
|
|
|
|
|
|
|
|
_shortcuts.BindShortcut(mnuTakeScreenshot, EmulatorShortcut.TakeScreenshot);
|
|
|
|
|
|
|
|
|
|
mnuDebugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenDebugger));
|
2019-04-07 12:25:14 -04:00
|
|
|
|
mnuSpcDebugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenSpcDebugger));
|
2019-03-11 17:56:54 -04:00
|
|
|
|
mnuMemoryTools.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenMemoryTools));
|
|
|
|
|
mnuEventViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenEventViewer));
|
2019-03-16 16:38:28 -04:00
|
|
|
|
mnuTilemapViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenTilemapViewer));
|
2019-03-23 15:39:21 -04:00
|
|
|
|
mnuTileViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenTileViewer));
|
2019-04-25 19:49:15 -04:00
|
|
|
|
mnuSpriteViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenSpriteViewer));
|
2019-03-16 16:38:28 -04:00
|
|
|
|
mnuPaletteViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenPaletteViewer));
|
2019-03-11 17:56:54 -04:00
|
|
|
|
mnuTraceLogger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenTraceLogger));
|
|
|
|
|
|
|
|
|
|
mnuNoneFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.None); };
|
|
|
|
|
mnuNtscFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.NTSC); };
|
|
|
|
|
|
|
|
|
|
mnuHQ2xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.HQ2x); };
|
|
|
|
|
mnuHQ3xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.HQ3x); };
|
|
|
|
|
mnuHQ4xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.HQ4x); };
|
|
|
|
|
|
|
|
|
|
mnuPrescale2xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale2x); };
|
|
|
|
|
mnuPrescale3xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale3x); };
|
|
|
|
|
mnuPrescale4xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale4x); };
|
|
|
|
|
mnuPrescale6xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale6x); };
|
|
|
|
|
mnuPrescale8xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale8x); };
|
|
|
|
|
mnuPrescale10xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale10x); };
|
|
|
|
|
|
|
|
|
|
mnuScale2xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Scale2x); };
|
|
|
|
|
mnuScale3xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Scale3x); };
|
|
|
|
|
mnuScale4xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Scale4x); };
|
|
|
|
|
|
|
|
|
|
mnu2xSaiFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType._2xSai); };
|
|
|
|
|
mnuSuper2xSaiFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Super2xSai); };
|
|
|
|
|
mnuSuperEagleFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.SuperEagle); };
|
|
|
|
|
|
|
|
|
|
mnuXBRZ2xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.xBRZ2x); };
|
|
|
|
|
mnuXBRZ3xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.xBRZ3x); };
|
|
|
|
|
mnuXBRZ4xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.xBRZ4x); };
|
|
|
|
|
mnuXBRZ5xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.xBRZ5x); };
|
|
|
|
|
mnuXBRZ6xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.xBRZ6x); };
|
|
|
|
|
|
|
|
|
|
mnuBilinearInterpolation.Click += (s, e) => { _shortcuts.ToggleBilinearInterpolation(); };
|
2019-03-14 15:25:35 -04:00
|
|
|
|
|
|
|
|
|
mnuRegionAuto.Click += (s, e) => { _shortcuts.SetRegion(ConsoleRegion.Auto); };
|
|
|
|
|
mnuRegionNtsc.Click += (s, e) => { _shortcuts.SetRegion(ConsoleRegion.Ntsc); };
|
|
|
|
|
mnuRegionPal.Click += (s, e) => { _shortcuts.SetRegion(ConsoleRegion.Pal); };
|
2019-03-30 22:41:37 -04:00
|
|
|
|
|
|
|
|
|
mnuDebugger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.Debugger); };
|
2019-04-07 12:25:14 -04:00
|
|
|
|
mnuSpcDebugger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.SpcDebugger); };
|
2019-03-30 22:41:37 -04:00
|
|
|
|
mnuTraceLogger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.TraceLogger); };
|
|
|
|
|
mnuMemoryTools.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.MemoryTools); };
|
|
|
|
|
mnuTilemapViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.TilemapViewer); };
|
|
|
|
|
mnuTileViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.TileViewer); };
|
2019-04-25 19:49:15 -04:00
|
|
|
|
mnuSpriteViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.SpriteViewer); };
|
2019-03-30 22:41:37 -04:00
|
|
|
|
mnuPaletteViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.PaletteViewer); };
|
|
|
|
|
mnuEventViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.EventViewer); };
|
|
|
|
|
|
|
|
|
|
UpdateDebuggerMenu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateDebuggerMenu()
|
|
|
|
|
{
|
|
|
|
|
bool running = EmuRunner.IsRunning();
|
|
|
|
|
mnuDebugger.Enabled = running;
|
2019-04-07 12:25:14 -04:00
|
|
|
|
mnuSpcDebugger.Enabled = running;
|
2019-03-30 22:41:37 -04:00
|
|
|
|
mnuTraceLogger.Enabled = running;
|
|
|
|
|
mnuMemoryTools.Enabled = running;
|
|
|
|
|
mnuTilemapViewer.Enabled = running;
|
|
|
|
|
mnuTileViewer.Enabled = running;
|
2019-04-25 19:49:15 -04:00
|
|
|
|
mnuSpriteViewer.Enabled = running;
|
2019-03-30 22:41:37 -04:00
|
|
|
|
mnuPaletteViewer.Enabled = running;
|
|
|
|
|
mnuEventViewer.Enabled = running;
|
2019-03-11 17:56:54 -04:00
|
|
|
|
}
|
2019-03-10 11:12:50 -04:00
|
|
|
|
|
2019-03-14 20:54:04 -04:00
|
|
|
|
private void ResizeRecentGames()
|
2019-03-14 18:07:25 -04:00
|
|
|
|
{
|
|
|
|
|
ctrlRecentGames.Height = this.ClientSize.Height - ctrlRecentGames.Top - 80;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-14 20:54:04 -04:00
|
|
|
|
private void frmMain_Resize(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-03-14 23:30:47 -04:00
|
|
|
|
ResizeRecentGames();
|
2019-03-14 20:54:04 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-10 11:12:50 -04:00
|
|
|
|
private void mnuVideoConfig_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using(frmVideoConfig frm = new frmVideoConfig()) {
|
|
|
|
|
frm.ShowDialog(sender, this);
|
|
|
|
|
}
|
|
|
|
|
ConfigManager.Config.Video.ApplyConfig();
|
|
|
|
|
}
|
2019-02-16 08:10:08 -05:00
|
|
|
|
|
2019-03-10 17:39:14 -04:00
|
|
|
|
private void mnuAudioConfig_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using(frmAudioConfig frm = new frmAudioConfig()) {
|
|
|
|
|
frm.ShowDialog(sender, this);
|
|
|
|
|
}
|
|
|
|
|
ConfigManager.Config.Audio.ApplyConfig();
|
|
|
|
|
}
|
2019-03-11 17:56:54 -04:00
|
|
|
|
|
2019-03-12 13:20:29 -04:00
|
|
|
|
private void mnuEmulationConfig_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using(frmEmulationConfig frm = new frmEmulationConfig()) {
|
|
|
|
|
frm.ShowDialog(sender, this);
|
|
|
|
|
}
|
|
|
|
|
ConfigManager.Config.Emulation.ApplyConfig();
|
|
|
|
|
}
|
2019-03-13 22:56:33 -04:00
|
|
|
|
|
|
|
|
|
private void mnuInputConfig_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using(frmInputConfig frm = new frmInputConfig()) {
|
|
|
|
|
frm.ShowDialog(sender, this);
|
|
|
|
|
}
|
|
|
|
|
ConfigManager.Config.Input.ApplyConfig();
|
|
|
|
|
}
|
2019-03-12 13:20:29 -04:00
|
|
|
|
|
2019-03-11 17:56:54 -04:00
|
|
|
|
private void mnuPreferences_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using(frmPreferences frm = new frmPreferences()) {
|
|
|
|
|
frm.ShowDialog(sender, this);
|
|
|
|
|
}
|
|
|
|
|
ConfigManager.Config.Preferences.ApplyConfig();
|
|
|
|
|
}
|
2019-03-10 17:39:14 -04:00
|
|
|
|
|
2019-02-15 21:33:13 -05:00
|
|
|
|
protected override void OnDragDrop(DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnDragDrop(e);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
|
if(File.Exists(files[0])) {
|
2019-03-31 15:51:13 -04:00
|
|
|
|
EmuRunner.LoadFile(files[0]);
|
2019-02-15 21:33:13 -05:00
|
|
|
|
this.Activate();
|
|
|
|
|
} else {
|
2019-03-31 15:15:35 -04:00
|
|
|
|
EmuApi.DisplayMessage("Error", "File not found: " + files[0]);
|
2019-02-15 21:33:13 -05:00
|
|
|
|
}
|
|
|
|
|
} catch(Exception ex) {
|
|
|
|
|
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnDragEnter(DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnDragEnter(e);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if(e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop)) {
|
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
} else {
|
2019-03-31 15:15:35 -04:00
|
|
|
|
EmuApi.DisplayMessage("Error", "Unsupported operation.");
|
2019-02-15 21:33:13 -05:00
|
|
|
|
}
|
|
|
|
|
} catch(Exception ex) {
|
|
|
|
|
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-10 19:37:42 -04:00
|
|
|
|
|
2019-03-11 17:56:54 -04:00
|
|
|
|
private void mnuLogWindow_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
new frmLogWindow().Show();
|
|
|
|
|
}
|
2019-03-10 19:37:42 -04:00
|
|
|
|
|
2019-03-14 12:34:29 -04:00
|
|
|
|
private void mnuCheckForUpdates_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateHelper.CheckForUpdates(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuReportBug_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Process.Start("https://www.mesen.ca/snes/ReportBug.php");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuAbout_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using(frmAbout frm = new frmAbout()) {
|
|
|
|
|
frm.ShowDialog(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-10 19:37:42 -04:00
|
|
|
|
private void mnuFile_DropDownOpening(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
mnuRecentFiles.DropDownItems.Clear();
|
|
|
|
|
mnuRecentFiles.DropDownItems.AddRange(ConfigManager.Config.RecentFiles.GetMenuItems().ToArray());
|
|
|
|
|
mnuRecentFiles.Enabled = ConfigManager.Config.RecentFiles.Items.Count > 0;
|
|
|
|
|
}
|
2019-03-11 17:56:54 -04:00
|
|
|
|
|
|
|
|
|
private void mnuVideoFilter_DropDownOpening(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
VideoFilterType filterType = ConfigManager.Config.Video.VideoFilter;
|
|
|
|
|
mnuNoneFilter.Checked = (filterType == VideoFilterType.None);
|
|
|
|
|
mnuNtscFilter.Checked = (filterType == VideoFilterType.NTSC);
|
|
|
|
|
mnuXBRZ2xFilter.Checked = (filterType == VideoFilterType.xBRZ2x);
|
|
|
|
|
mnuXBRZ3xFilter.Checked = (filterType == VideoFilterType.xBRZ3x);
|
|
|
|
|
mnuXBRZ4xFilter.Checked = (filterType == VideoFilterType.xBRZ4x);
|
|
|
|
|
mnuXBRZ5xFilter.Checked = (filterType == VideoFilterType.xBRZ5x);
|
|
|
|
|
mnuXBRZ6xFilter.Checked = (filterType == VideoFilterType.xBRZ6x);
|
|
|
|
|
mnuHQ2xFilter.Checked = (filterType == VideoFilterType.HQ2x);
|
|
|
|
|
mnuHQ3xFilter.Checked = (filterType == VideoFilterType.HQ3x);
|
|
|
|
|
mnuHQ4xFilter.Checked = (filterType == VideoFilterType.HQ4x);
|
|
|
|
|
mnuScale2xFilter.Checked = (filterType == VideoFilterType.Scale2x);
|
|
|
|
|
mnuScale3xFilter.Checked = (filterType == VideoFilterType.Scale3x);
|
|
|
|
|
mnuScale4xFilter.Checked = (filterType == VideoFilterType.Scale4x);
|
|
|
|
|
mnu2xSaiFilter.Checked = (filterType == VideoFilterType._2xSai);
|
|
|
|
|
mnuSuper2xSaiFilter.Checked = (filterType == VideoFilterType.Super2xSai);
|
|
|
|
|
mnuSuperEagleFilter.Checked = (filterType == VideoFilterType.SuperEagle);
|
|
|
|
|
mnuPrescale2xFilter.Checked = (filterType == VideoFilterType.Prescale2x);
|
|
|
|
|
mnuPrescale3xFilter.Checked = (filterType == VideoFilterType.Prescale3x);
|
|
|
|
|
mnuPrescale4xFilter.Checked = (filterType == VideoFilterType.Prescale4x);
|
|
|
|
|
mnuPrescale6xFilter.Checked = (filterType == VideoFilterType.Prescale6x);
|
|
|
|
|
mnuPrescale8xFilter.Checked = (filterType == VideoFilterType.Prescale8x);
|
|
|
|
|
mnuPrescale10xFilter.Checked = (filterType == VideoFilterType.Prescale10x);
|
|
|
|
|
|
|
|
|
|
mnuBilinearInterpolation.Checked = ConfigManager.Config.Video.UseBilinearInterpolation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuVideoScale_DropDownOpening(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
double scale = ConfigManager.Config.Video.VideoScale;
|
|
|
|
|
mnuScale1x.Checked = (scale == 1.0);
|
|
|
|
|
mnuScale2x.Checked = (scale == 2.0);
|
|
|
|
|
mnuScale3x.Checked = (scale == 3.0);
|
|
|
|
|
mnuScale4x.Checked = (scale == 4.0);
|
|
|
|
|
mnuScale5x.Checked = (scale == 5.0);
|
|
|
|
|
mnuScale6x.Checked = (scale == 6.0);
|
2019-03-15 11:15:47 -04:00
|
|
|
|
|
|
|
|
|
mnuFullscreen.Checked = _displayManager.Fullscreen;
|
2019-03-11 17:56:54 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuEmulationSpeed_DropDownOpening(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uint emulationSpeed = ConfigManager.Config.Emulation.EmulationSpeed;
|
|
|
|
|
mnuEmuSpeedNormal.Checked = emulationSpeed == 100;
|
|
|
|
|
mnuEmuSpeedQuarter.Checked = emulationSpeed == 25;
|
|
|
|
|
mnuEmuSpeedHalf.Checked = emulationSpeed == 50;
|
|
|
|
|
mnuEmuSpeedDouble.Checked = emulationSpeed == 200;
|
|
|
|
|
mnuEmuSpeedTriple.Checked = emulationSpeed == 300;
|
|
|
|
|
mnuEmuSpeedMaximumSpeed.Checked = emulationSpeed == 0;
|
2019-04-02 20:47:24 -04:00
|
|
|
|
|
|
|
|
|
mnuShowFPS.Checked = ConfigManager.Config.Preferences.ShowFps;
|
2019-03-11 17:56:54 -04:00
|
|
|
|
}
|
2019-03-12 09:15:57 -04:00
|
|
|
|
|
|
|
|
|
private void mnuLoadState_DropDownOpening(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SaveStateManager.UpdateStateMenu(mnuLoadState, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuSaveState_DropDownOpening(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SaveStateManager.UpdateStateMenu(mnuSaveState, true);
|
|
|
|
|
}
|
2019-03-14 15:25:35 -04:00
|
|
|
|
|
|
|
|
|
private void mnuRegion_DropDownOpening(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
mnuRegionAuto.Checked = ConfigManager.Config.Emulation.Region == ConsoleRegion.Auto;
|
|
|
|
|
mnuRegionNtsc.Checked = ConfigManager.Config.Emulation.Region == ConsoleRegion.Ntsc;
|
|
|
|
|
mnuRegionPal.Checked = ConfigManager.Config.Emulation.Region == ConsoleRegion.Pal;
|
|
|
|
|
}
|
2019-03-15 12:48:34 -04:00
|
|
|
|
|
|
|
|
|
private void mnuAviRecord_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using(frmRecordAvi frm = new frmRecordAvi()) {
|
|
|
|
|
if(frm.ShowDialog(mnuVideoRecorder, this) == DialogResult.OK) {
|
|
|
|
|
RecordApi.AviRecord(frm.Filename, ConfigManager.Config.AviRecord.Codec, ConfigManager.Config.AviRecord.CompressionLevel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuAviStop_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RecordApi.AviStop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void toolsToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
mnuVideoRecorder.Enabled = EmuRunner.IsRunning();
|
|
|
|
|
mnuAviRecord.Enabled = EmuRunner.IsRunning() && !RecordApi.AviIsRecording();
|
|
|
|
|
mnuAviStop.Enabled = EmuRunner.IsRunning() && RecordApi.AviIsRecording();
|
|
|
|
|
}
|
2019-03-15 12:58:30 -04:00
|
|
|
|
|
|
|
|
|
private void mnuWaveRecord_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using(SaveFileDialog sfd = new SaveFileDialog()) {
|
|
|
|
|
sfd.SetFilter(ResourceHelper.GetMessage("FilterWave"));
|
|
|
|
|
sfd.InitialDirectory = ConfigManager.WaveFolder;
|
2019-03-28 21:20:18 -04:00
|
|
|
|
sfd.FileName = EmuApi.GetRomInfo().GetRomName() + ".wav";
|
2019-03-15 12:58:30 -04:00
|
|
|
|
if(sfd.ShowDialog(this) == DialogResult.OK) {
|
|
|
|
|
RecordApi.WaveRecord(sfd.FileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuWaveStop_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RecordApi.WaveStop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuSoundRecorder_DropDownOpening(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
mnuSoundRecorder.Enabled = EmuRunner.IsRunning();
|
|
|
|
|
mnuWaveRecord.Enabled = EmuRunner.IsRunning() && !RecordApi.WaveIsRecording();
|
|
|
|
|
mnuWaveStop.Enabled = EmuRunner.IsRunning() && RecordApi.WaveIsRecording();
|
|
|
|
|
}
|
2019-02-12 22:13:09 -05:00
|
|
|
|
}
|
|
|
|
|
}
|