Mesen-SX/UI/Forms/frmMain.cs

540 lines
20 KiB
C#
Raw Normal View History

using Mesen.GUI.Config;
using Mesen.GUI.Config.Shortcuts;
using Mesen.GUI.Debugger;
using Mesen.GUI.Debugger.Workspace;
2019-03-12 09:15:57 -04:00
using Mesen.GUI.Emulation;
using Mesen.GUI.Forms.Config;
using Mesen.GUI.Updates;
using Mesen.GUI.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
2019-02-15 21:33:13 -05:00
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
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
{
private NotificationListener _notifListener;
private ShortcutHandler _shortcuts;
private DisplayManager _displayManager;
private CommandLineHelper _commandLine;
public frmMain(string[] args)
{
InitializeComponent();
if(DesignMode) {
return;
}
_commandLine = new CommandLineHelper(args);
ResourceHelper.LoadResources(Language.English);
}
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;
}
}
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.SetScaleBasedOnWindowSize();
_shortcuts = new ShortcutHandler(_displayManager);
_notifListener = new NotificationListener();
_notifListener.OnNotification += OnNotificationReceived;
_commandLine.LoadGameFromCommandLine();
2019-03-12 09:15:57 -04:00
Task.Run(() => {
System.Threading.Thread.Sleep(25);
this.BeginInvoke((Action)(() => {
SaveStateManager.InitializeStateMenu(mnuSaveState, true, _shortcuts);
SaveStateManager.InitializeStateMenu(mnuLoadState, false, _shortcuts);
2019-03-14 18:07:25 -04:00
BindShortcuts();
ResizeRecentGames();
ctrlRecentGames.Initialize();
if(!EmuRunner.IsRunning()) {
ctrlRecentGames.Visible = true;
}
}));
});
if(ConfigManager.Config.Preferences.AutomaticallyCheckForUpdates) {
UpdateHelper.CheckForUpdates(true);
}
InBackgroundHelper.StartBackgroundTimer();
this.Resize += frmMain_Resize;
}
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();
}
private void OnNotificationReceived(NotificationEventArgs e)
{
switch(e.NotificationType) {
2019-03-12 09:15:57 -04:00
case ConsoleNotificationType.GameLoaded:
this.BeginInvoke((Action)(() => {
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();
if(DebugWindowManager.HasOpenedWindow) {
DebugWorkspaceManager.GetWorkspace();
}
2019-03-12 09:15:57 -04:00
}));
break;
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";
UpdateDebuggerMenu();
2019-03-14 18:07:25 -04:00
ctrlRecentGames.Initialize();
ctrlRecentGames.Visible = true;
ResizeRecentGames();
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;
case ConsoleNotificationType.ExecuteShortcut:
this.BeginInvoke((Action)(() => {
_shortcuts.ExecuteShortcut((EmulatorShortcut)e.Parameter);
}));
break;
case ConsoleNotificationType.MissingFirmware:
this.Invoke((Action)(() => {
MissingFirmwareMessage msg = (MissingFirmwareMessage)Marshal.PtrToStructure(e.Parameter, typeof(MissingFirmwareMessage));
FirmwareHelper.RequestFirmwareFile(msg);
}));
break;
}
}
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);
}
private void BindShortcuts()
{
Func<bool> notClient = () => { return true; }; //TODO
Func<bool> running = () => { return EmuRunner.IsRunning(); };
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, running);
mnuDebugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenDebugger));
mnuSpcDebugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenSpcDebugger));
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));
mnuTraceLogger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenTraceLogger));
2019-05-12 21:18:05 -04:00
mnuScriptWindow.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenScriptWindow));
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); };
mnuDebugger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.Debugger); };
mnuSpcDebugger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.SpcDebugger); };
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); };
mnuPaletteViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.PaletteViewer); };
mnuEventViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.EventViewer); };
2019-05-12 21:18:05 -04:00
mnuScriptWindow.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.ScriptWindow); };
UpdateDebuggerMenu();
}
private void UpdateDebuggerMenu()
{
bool running = EmuRunner.IsRunning();
mnuDebugger.Enabled = running;
mnuSpcDebugger.Enabled = running;
mnuTraceLogger.Enabled = running;
mnuScriptWindow.Enabled = running;
mnuMemoryTools.Enabled = running;
mnuTilemapViewer.Enabled = running;
mnuTileViewer.Enabled = running;
2019-04-25 19:49:15 -04:00
mnuSpriteViewer.Enabled = running;
mnuPaletteViewer.Enabled = running;
mnuEventViewer.Enabled = running;
}
private void ResizeRecentGames()
2019-03-14 18:07:25 -04:00
{
ctrlRecentGames.Height = this.ClientSize.Height - ctrlRecentGames.Top - 80;
}
private void frmMain_Resize(object sender, EventArgs e)
{
ResizeRecentGames();
}
private void mnuVideoConfig_Click(object sender, EventArgs e)
{
using(frmVideoConfig frm = new frmVideoConfig()) {
frm.ShowDialog(sender, this);
}
ConfigManager.Config.Video.ApplyConfig();
}
private void mnuAudioConfig_Click(object sender, EventArgs e)
{
using(frmAudioConfig frm = new frmAudioConfig()) {
frm.ShowDialog(sender, this);
}
ConfigManager.Config.Audio.ApplyConfig();
}
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
private void mnuPreferences_Click(object sender, EventArgs e)
{
using(frmPreferences frm = new frmPreferences()) {
frm.ShowDialog(sender, this);
2019-07-16 22:19:13 -04:00
ConfigManager.Config.Preferences.ApplyConfig();
if(frm.NeedRestart) {
this.Close();
}
}
}
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])) {
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
private void mnuLogWindow_Click(object sender, EventArgs e)
{
new frmLogWindow().Show();
}
2019-03-10 19:37:42 -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;
}
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);
mnuFullscreen.Checked = _displayManager.Fullscreen;
}
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;
mnuShowFPS.Checked = ConfigManager.Config.Preferences.ShowFps;
}
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 mnuTools_DropDownOpening(object sender, EventArgs e)
2019-03-15 12:48:34 -04:00
{
mnuSoundRecorder.Enabled = EmuRunner.IsRunning();
mnuWaveRecord.Enabled = EmuRunner.IsRunning() && !RecordApi.WaveIsRecording();
mnuWaveStop.Enabled = EmuRunner.IsRunning() && RecordApi.WaveIsRecording();
2019-03-15 12:48:34 -04:00
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 mnu_DropDownOpened(object sender, EventArgs e)
{
Interlocked.Increment(ref _inMenu);
}
private void mnu_DropDownClosed(object sender, EventArgs e)
{
Task.Run(() => {
Thread.Sleep(100);
Interlocked.Decrement(ref _inMenu);
});
}
}
}