2015-07-01 23:17:14 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2016-05-22 14:43:07 -04:00
|
|
|
|
using System.ComponentModel;
|
2016-01-01 10:21:41 -05:00
|
|
|
|
using System.Diagnostics;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
using System.Drawing;
|
2017-05-06 15:27:48 -04:00
|
|
|
|
using System.Drawing.Text;
|
2015-12-27 18:41:38 -05:00
|
|
|
|
using System.IO;
|
2016-12-09 12:49:17 -05:00
|
|
|
|
using System.Linq;
|
2016-02-08 23:23:31 -05:00
|
|
|
|
using System.Net;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
using System.Text;
|
2018-03-25 13:34:51 -04:00
|
|
|
|
using System.Text.RegularExpressions;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2016-02-08 23:23:31 -05:00
|
|
|
|
using System.Xml;
|
2015-07-03 00:12:02 -04:00
|
|
|
|
using Mesen.GUI.Config;
|
2020-01-28 20:20:54 -05:00
|
|
|
|
using Mesen.GUI.Controls;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
using Mesen.GUI.Debugger;
|
2015-07-03 00:12:02 -04:00
|
|
|
|
using Mesen.GUI.Forms.Cheats;
|
2015-07-10 21:07:24 -04:00
|
|
|
|
using Mesen.GUI.Forms.Config;
|
2017-06-28 19:00:08 -04:00
|
|
|
|
using Mesen.GUI.Forms.HdPackEditor;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
using Mesen.GUI.Forms.NetPlay;
|
2016-05-22 14:43:07 -04:00
|
|
|
|
using Mesen.GUI.GoogleDriveIntegration;
|
2017-11-29 23:24:26 -05:00
|
|
|
|
using Mesen.GUI.Properties;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Forms
|
|
|
|
|
{
|
2017-11-29 23:24:26 -05:00
|
|
|
|
public partial class frmMain : BaseInputForm
|
2015-07-01 23:17:14 -04:00
|
|
|
|
{
|
|
|
|
|
private InteropEmu.NotificationListener _notifListener;
|
|
|
|
|
private Thread _emuThread;
|
2016-06-19 16:54:34 -04:00
|
|
|
|
private frmLogWindow _logWindow;
|
2016-08-25 19:02:33 -04:00
|
|
|
|
private frmCheatList _cheatListWindow;
|
2018-07-11 18:07:13 -04:00
|
|
|
|
private frmHistoryViewer _historyViewerWindow;
|
2017-06-28 19:00:08 -04:00
|
|
|
|
private frmHdPackEditor _hdPackEditorWindow;
|
2017-07-30 09:03:54 -04:00
|
|
|
|
private ResourcePath? _currentRomPath = null;
|
2018-12-22 13:25:09 -05:00
|
|
|
|
|
|
|
|
|
private string _movieToRecord = null;
|
|
|
|
|
private List<string> _luaScriptsToLoad = new List<string>();
|
2018-12-22 16:27:14 -05:00
|
|
|
|
private bool _loadLastSessionRequested = false;
|
2020-02-01 09:13:54 -05:00
|
|
|
|
private bool _openDebuggerRequested = false;
|
2018-12-22 13:25:09 -05:00
|
|
|
|
|
2018-03-25 13:34:51 -04:00
|
|
|
|
private Image _pauseButton = Resources.Pause;
|
|
|
|
|
private Image _playButton = Resources.Play;
|
2016-01-28 22:34:23 -05:00
|
|
|
|
private string _currentGame = null;
|
2016-02-07 13:05:32 -05:00
|
|
|
|
private bool _customSize = false;
|
2017-12-27 16:21:15 -05:00
|
|
|
|
private double? _switchOptionScale = null;
|
|
|
|
|
private bool _fullscreenRequested = false;
|
2016-05-23 21:35:32 -04:00
|
|
|
|
private FormWindowState _originalWindowState;
|
2017-12-27 13:18:44 -05:00
|
|
|
|
private Size _originalWindowMinimumSize;
|
2016-02-07 13:05:32 -05:00
|
|
|
|
private bool _fullscreenMode = false;
|
2017-08-08 16:10:54 -04:00
|
|
|
|
private Size? _nonNsfSize = null;
|
2017-09-16 22:02:05 -04:00
|
|
|
|
private Size _nonNsfMinimumSize;
|
2016-06-25 20:46:54 -04:00
|
|
|
|
private bool _isNsfPlayerMode = false;
|
2016-06-26 10:43:52 -04:00
|
|
|
|
private object _loadRomLock = new object();
|
|
|
|
|
private int _romLoadCounter = 0;
|
2017-08-01 19:47:19 -04:00
|
|
|
|
private bool _showUpgradeMessage = false;
|
2017-09-17 15:21:50 -04:00
|
|
|
|
private bool _enableResize = false;
|
2017-09-17 16:04:26 -04:00
|
|
|
|
private bool _overrideWindowSize = false;
|
2018-06-09 15:12:34 -04:00
|
|
|
|
private bool _shuttingDown = false;
|
2018-07-02 21:32:59 -04:00
|
|
|
|
private bool _isDualSystem = false;
|
2016-02-07 13:05:32 -05:00
|
|
|
|
|
2017-11-29 23:24:26 -05:00
|
|
|
|
private frmFullscreenRenderer _frmFullscreenRenderer = null;
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
private Dictionary<EmulatorShortcut, Func<bool>> _actionEnabledFuncs = new Dictionary<EmulatorShortcut, Func<bool>>();
|
|
|
|
|
|
2018-02-06 19:51:00 -05:00
|
|
|
|
private string[] _commandLineArgs;
|
2016-07-23 15:28:52 -04:00
|
|
|
|
private bool _noAudio = false;
|
|
|
|
|
private bool _noVideo = false;
|
|
|
|
|
private bool _noInput = false;
|
|
|
|
|
|
2015-12-27 22:05:45 -05:00
|
|
|
|
public frmMain(string[] args)
|
2015-07-01 23:17:14 -04:00
|
|
|
|
{
|
2019-01-27 01:11:25 -05:00
|
|
|
|
ThemeHelper.InitTheme(this.BackColor);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
InitializeComponent();
|
2016-07-28 17:45:18 -04:00
|
|
|
|
|
2019-01-27 01:11:25 -05:00
|
|
|
|
ThemeHelper.ExcludeFromTheme(panelInfo);
|
|
|
|
|
ThemeHelper.ExcludeFromTheme(panelRenderer);
|
|
|
|
|
|
2017-08-14 23:44:01 -04:00
|
|
|
|
this.StartPosition = FormStartPosition.CenterScreen;
|
|
|
|
|
|
2017-05-02 00:00:27 -04:00
|
|
|
|
Version currentVersion = new Version(InteropEmu.GetMesenVersion());
|
|
|
|
|
lblVersion.Text = currentVersion.ToString();
|
|
|
|
|
|
2019-12-29 14:40:20 -05:00
|
|
|
|
if(Program.IsMono) {
|
2019-01-27 10:14:35 -05:00
|
|
|
|
lblVersion.Margin = new Padding(0, 0, 3, 0);
|
|
|
|
|
picIcon.Margin = new Padding(3, 5, 3, 3);
|
|
|
|
|
}
|
2017-05-06 15:27:48 -04:00
|
|
|
|
|
2018-06-14 01:05:49 -04:00
|
|
|
|
#if AUTOBUILD
|
|
|
|
|
string devVersion = ResourceManager.ReadZippedResource("DevBuild.txt");
|
|
|
|
|
if(devVersion != null) {
|
|
|
|
|
Size versionSize = TextRenderer.MeasureText(devVersion, lblVersion.Font);
|
|
|
|
|
lblVersion.Text = devVersion;
|
2019-01-27 10:14:35 -05:00
|
|
|
|
lblVersion.Anchor = AnchorStyles.Right;
|
2018-06-14 01:05:49 -04:00
|
|
|
|
int newWidth = versionSize.Width + 30;
|
|
|
|
|
panelInfo.Left -= newWidth - panelInfo.Width;
|
|
|
|
|
panelInfo.Width = newWidth;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-02-06 19:51:00 -05:00
|
|
|
|
_commandLineArgs = (string[])args.Clone();
|
2017-07-30 09:03:54 -04:00
|
|
|
|
|
2016-07-28 17:45:18 -04:00
|
|
|
|
Application.AddMessageFilter(this);
|
2017-05-06 20:01:48 -04:00
|
|
|
|
this.Resize += ResizeRecentGames;
|
2016-07-28 17:45:18 -04:00
|
|
|
|
this.FormClosed += (s, e) => Application.RemoveMessageFilter(this);
|
2015-07-14 21:53:01 -04:00
|
|
|
|
}
|
2018-04-14 21:53:52 -04:00
|
|
|
|
|
2017-12-27 16:21:15 -05:00
|
|
|
|
public void ProcessCommandLineArguments(List<string> switches, bool forStartup)
|
|
|
|
|
{
|
2017-03-19 13:05:33 -04:00
|
|
|
|
if(forStartup) {
|
2016-07-29 19:05:15 -04:00
|
|
|
|
_noVideo = switches.Contains("/novideo");
|
|
|
|
|
_noAudio = switches.Contains("/noaudio");
|
|
|
|
|
_noInput = switches.Contains("/noinput");
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-19 13:05:33 -04:00
|
|
|
|
if(switches.Contains("/donotsavesettings")) {
|
|
|
|
|
ConfigManager.DoNotSaveSettings = true;
|
|
|
|
|
}
|
2017-12-27 16:21:15 -05:00
|
|
|
|
|
2018-12-22 16:27:14 -05:00
|
|
|
|
if(switches.Contains("/loadlastsession")) {
|
|
|
|
|
_loadLastSessionRequested = true;
|
2020-02-01 09:13:54 -05:00
|
|
|
|
} else if(switches.Contains("/debugger")) {
|
|
|
|
|
_openDebuggerRequested = true;
|
2018-12-22 16:27:14 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-22 13:25:09 -05:00
|
|
|
|
Regex recordMovieCommand = new Regex("/recordmovie=([^\"]+)");
|
|
|
|
|
foreach(string command in switches) {
|
|
|
|
|
Match match = recordMovieCommand.Match(command);
|
|
|
|
|
if(match.Success) {
|
|
|
|
|
string moviePath = match.Groups[1].Value;
|
|
|
|
|
string folder = Path.GetDirectoryName(moviePath);
|
|
|
|
|
if(string.IsNullOrWhiteSpace(folder)) {
|
|
|
|
|
moviePath = Path.Combine(ConfigManager.MovieFolder, moviePath);
|
|
|
|
|
} else if(!Path.IsPathRooted(moviePath)) {
|
|
|
|
|
moviePath = Path.Combine(Program.OriginalFolder, moviePath);
|
|
|
|
|
}
|
|
|
|
|
if(!moviePath.ToLower().EndsWith(".mmo")) {
|
|
|
|
|
moviePath += ".mmo";
|
|
|
|
|
}
|
|
|
|
|
_movieToRecord = moviePath;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-19 13:05:33 -04:00
|
|
|
|
ConfigManager.ProcessSwitches(switches);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-27 16:21:15 -05:00
|
|
|
|
public void LoadGameFromCommandLine(List<string> switches)
|
2017-03-19 13:05:33 -04:00
|
|
|
|
{
|
2018-04-14 21:53:52 -04:00
|
|
|
|
string romPath;
|
|
|
|
|
CommandLineHelper.GetRomPathFromCommandLine(switches, out romPath, out _luaScriptsToLoad);
|
2018-03-25 13:34:51 -04:00
|
|
|
|
|
2018-04-14 21:53:52 -04:00
|
|
|
|
if(romPath != null) {
|
|
|
|
|
this.LoadFile(romPath);
|
|
|
|
|
} else {
|
2018-03-25 13:34:51 -04:00
|
|
|
|
if(_emuThread == null) {
|
|
|
|
|
//When no ROM is loaded, only process Lua scripts if a ROM was specified as a command line param
|
|
|
|
|
_luaScriptsToLoad.Clear();
|
2018-12-22 13:25:09 -05:00
|
|
|
|
_movieToRecord = null;
|
2018-12-22 16:27:14 -05:00
|
|
|
|
_loadLastSessionRequested = false;
|
2018-03-25 13:34:51 -04:00
|
|
|
|
} else {
|
|
|
|
|
//No game was specified, but a game is running already, load the scripts right away
|
2018-12-22 13:25:09 -05:00
|
|
|
|
ProcessPostLoadCommandSwitches();
|
2018-03-25 13:34:51 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-22 13:25:09 -05:00
|
|
|
|
private void ProcessPostLoadCommandSwitches()
|
2018-03-25 13:34:51 -04:00
|
|
|
|
{
|
|
|
|
|
if(_luaScriptsToLoad.Count > 0) {
|
|
|
|
|
foreach(string luaScript in _luaScriptsToLoad) {
|
|
|
|
|
frmScript scriptWindow = DebugWindowManager.OpenScriptWindow(true);
|
|
|
|
|
scriptWindow.LoadScriptFile(luaScript);
|
|
|
|
|
}
|
|
|
|
|
_luaScriptsToLoad.Clear();
|
2015-12-27 22:05:45 -05:00
|
|
|
|
}
|
2018-12-22 13:25:09 -05:00
|
|
|
|
|
|
|
|
|
if(_movieToRecord != null) {
|
2018-12-22 13:31:05 -05:00
|
|
|
|
if(InteropEmu.MovieRecording()) {
|
|
|
|
|
InteropEmu.MovieStop();
|
|
|
|
|
}
|
2018-12-22 13:25:09 -05:00
|
|
|
|
RecordMovieOptions options = new RecordMovieOptions(_movieToRecord, "", "", RecordMovieFrom.StartWithSaveData);
|
|
|
|
|
InteropEmu.MovieRecord(ref options);
|
|
|
|
|
_movieToRecord = null;
|
|
|
|
|
}
|
2018-12-22 16:27:14 -05:00
|
|
|
|
|
|
|
|
|
if(_loadLastSessionRequested) {
|
|
|
|
|
_loadLastSessionRequested = false;
|
|
|
|
|
LoadLastSession();
|
|
|
|
|
}
|
2015-12-27 22:05:45 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-14 21:53:01 -04:00
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
|
|
|
{
|
2017-08-13 17:17:14 -04:00
|
|
|
|
ResourceHelper.LoadResources(ConfigManager.Config.PreferenceInfo.DisplayLanguage);
|
|
|
|
|
ResourceHelper.UpdateEmuLanguage();
|
|
|
|
|
|
2015-07-14 21:53:01 -04:00
|
|
|
|
base.OnLoad(e);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
2018-06-14 01:05:49 -04:00
|
|
|
|
#if HIDETESTMENU
|
2016-02-11 20:35:40 -05:00
|
|
|
|
mnuTests.Visible = false;
|
2018-06-14 01:05:49 -04:00
|
|
|
|
#endif
|
2018-07-08 20:22:21 -04:00
|
|
|
|
InteropEmu.InitDll();
|
2016-02-11 20:35:40 -05:00
|
|
|
|
|
2018-07-06 00:10:10 -04:00
|
|
|
|
_notifListener = new InteropEmu.NotificationListener(InteropEmu.ConsoleId.Master);
|
2015-07-01 23:17:14 -04:00
|
|
|
|
_notifListener.OnNotification += _notifListener_OnNotification;
|
|
|
|
|
|
2015-08-30 21:04:21 -04:00
|
|
|
|
menuTimer.Start();
|
2017-07-30 09:03:54 -04:00
|
|
|
|
|
2017-09-17 16:04:26 -04:00
|
|
|
|
InteropEmu.ScreenSize originalSize = InteropEmu.GetScreenSize(false);
|
|
|
|
|
VideoInfo.ApplyConfig();
|
2018-04-14 21:53:52 -04:00
|
|
|
|
this.ProcessCommandLineArguments(CommandLineHelper.PreprocessCommandLineArguments(_commandLineArgs, true), true);
|
2016-02-06 18:33:24 -05:00
|
|
|
|
VideoInfo.ApplyConfig();
|
2017-09-17 16:04:26 -04:00
|
|
|
|
InteropEmu.ScreenSize newSize = InteropEmu.GetScreenSize(false);
|
|
|
|
|
if(originalSize.Width != newSize.Width || originalSize.Height != newSize.Height) {
|
|
|
|
|
_overrideWindowSize = true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-24 20:27:07 -04:00
|
|
|
|
InitializeEmulationSpeedMenu();
|
2017-07-30 09:03:54 -04:00
|
|
|
|
|
2015-07-23 23:16:31 -04:00
|
|
|
|
UpdateVideoSettings();
|
2015-12-27 18:41:38 -05:00
|
|
|
|
|
2018-07-08 20:22:21 -04:00
|
|
|
|
InitializeCore();
|
2017-12-28 18:30:23 -05:00
|
|
|
|
PerformUpgrade();
|
2015-07-05 22:23:44 -04:00
|
|
|
|
InitializeEmu();
|
2015-07-05 19:05:33 -04:00
|
|
|
|
|
2017-12-26 12:38:30 -05:00
|
|
|
|
TopMost = ConfigManager.Config.PreferenceInfo.AlwaysOnTop;
|
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
UpdateMenus();
|
|
|
|
|
UpdateRecentFiles();
|
2015-07-03 00:12:02 -04:00
|
|
|
|
|
2016-02-07 13:05:32 -05:00
|
|
|
|
UpdateViewerSize();
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
|
|
|
|
InitializeStateMenu(mnuSaveState, true);
|
|
|
|
|
InitializeStateMenu(mnuLoadState, false);
|
|
|
|
|
|
2019-10-06 19:58:51 -04:00
|
|
|
|
RestoreLocation(ConfigManager.Config.WindowLocation);
|
2016-02-07 13:05:32 -05:00
|
|
|
|
|
2016-05-22 14:43:07 -04:00
|
|
|
|
if(ConfigManager.Config.PreferenceInfo.CloudSaveIntegration) {
|
|
|
|
|
Task.Run(() => CloudSyncHelper.Sync());
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-08 23:23:31 -05:00
|
|
|
|
if(ConfigManager.Config.PreferenceInfo.AutomaticallyCheckForUpdates) {
|
|
|
|
|
CheckForUpdates(false);
|
|
|
|
|
}
|
2017-08-08 16:10:54 -04:00
|
|
|
|
|
2017-09-17 16:04:26 -04:00
|
|
|
|
if(ConfigManager.Config.WindowSize.HasValue && !_overrideWindowSize) {
|
2017-08-08 16:10:54 -04:00
|
|
|
|
this.ClientSize = ConfigManager.Config.WindowSize.Value;
|
|
|
|
|
}
|
2019-04-03 22:43:35 -04:00
|
|
|
|
|
2018-07-06 00:10:10 -04:00
|
|
|
|
mnuDebugDualSystemSecondaryCpu.Checked = ConfigManager.Config.DebugInfo.DebugConsoleId == InteropEmu.ConsoleId.Slave;
|
2018-07-13 22:19:26 -04:00
|
|
|
|
InteropEmu.DebugSetDebuggerConsole(ConfigManager.Config.DebugInfo.DebugConsoleId);
|
2019-01-27 01:11:25 -05:00
|
|
|
|
|
|
|
|
|
BaseForm.StartBackgroundTimer();
|
2016-07-28 17:45:18 -04:00
|
|
|
|
}
|
2016-02-08 23:23:31 -05:00
|
|
|
|
|
2017-12-27 16:21:15 -05:00
|
|
|
|
private void ProcessFullscreenSwitch(List<string> switches)
|
|
|
|
|
{
|
|
|
|
|
if(switches.Contains("/fullscreen")) {
|
|
|
|
|
double scale = ConfigManager.Config.VideoInfo.VideoScale;
|
|
|
|
|
if(!ConfigManager.Config.VideoInfo.UseExclusiveFullscreen) {
|
|
|
|
|
//Go into fullscreen mode right away
|
|
|
|
|
SetFullscreenState(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_fullscreenRequested = true;
|
|
|
|
|
foreach(string option in switches) {
|
|
|
|
|
if(option.StartsWith("/videoscale=")) {
|
|
|
|
|
_switchOptionScale = scale;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-08 23:23:31 -05:00
|
|
|
|
protected override void OnShown(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnShown(e);
|
|
|
|
|
|
2019-04-03 22:43:35 -04:00
|
|
|
|
if(ConfigManager.Config.PreferenceInfo.DisableMouseResize) {
|
|
|
|
|
//This must be in the OnShown event, otherwise the application won't show up in the taskbar until it is given focus
|
|
|
|
|
this.FormBorderStyle = FormBorderStyle.Fixed3D;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
this.BindShortcuts();
|
|
|
|
|
|
2017-09-17 16:04:26 -04:00
|
|
|
|
if(ConfigManager.Config.WindowSize.HasValue && !_overrideWindowSize) {
|
2017-08-08 16:10:54 -04:00
|
|
|
|
this.Size = ConfigManager.Config.WindowSize.Value;
|
|
|
|
|
}
|
2017-08-12 00:24:37 -04:00
|
|
|
|
|
2018-04-14 21:53:52 -04:00
|
|
|
|
this.LoadGameFromCommandLine(CommandLineHelper.PreprocessCommandLineArguments(_commandLineArgs, false));
|
2017-08-13 17:17:14 -04:00
|
|
|
|
|
|
|
|
|
this.menuStrip.VisibleChanged += new System.EventHandler(this.menuStrip_VisibleChanged);
|
|
|
|
|
this.UpdateRendererLocation();
|
2017-09-02 19:03:39 -04:00
|
|
|
|
|
|
|
|
|
if(_showUpgradeMessage) {
|
|
|
|
|
MesenMsgBox.Show("UpgradeSuccess", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
_showUpgradeMessage = false;
|
|
|
|
|
}
|
2017-09-17 15:21:50 -04:00
|
|
|
|
|
|
|
|
|
//Ensure the resize event is not fired until the form is fully shown
|
|
|
|
|
//This is needed when DPI display settings is not set to 100%
|
|
|
|
|
_enableResize = true;
|
2017-12-27 16:21:15 -05:00
|
|
|
|
|
2018-04-14 21:53:52 -04:00
|
|
|
|
ProcessFullscreenSwitch(CommandLineHelper.PreprocessCommandLineArguments(_commandLineArgs, true));
|
2019-12-22 21:06:20 -05:00
|
|
|
|
|
2020-01-28 20:20:54 -05:00
|
|
|
|
if(_emuThread == null) {
|
|
|
|
|
ShowRecentGames();
|
|
|
|
|
}
|
2016-02-08 23:23:31 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-22 14:43:07 -04:00
|
|
|
|
protected override void OnClosing(CancelEventArgs e)
|
|
|
|
|
{
|
2017-08-12 18:58:38 -04:00
|
|
|
|
if(ConfigManager.Config.PreferenceInfo.ConfirmExitResetPower && MesenMsgBox.Show("ConfirmExit", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) {
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-09 18:47:11 -04:00
|
|
|
|
if(!_shuttingDown && Program.IsMono) {
|
|
|
|
|
//This appears to prevent Mono from locking up when closing the form
|
|
|
|
|
Task.Run(() => {
|
|
|
|
|
StopEmu();
|
|
|
|
|
_shuttingDown = true;
|
|
|
|
|
this.BeginInvoke((Action)(() => this.Close()));
|
|
|
|
|
});
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-09 15:12:34 -04:00
|
|
|
|
_shuttingDown = true;
|
2019-01-26 13:29:41 -05:00
|
|
|
|
CursorManager.StopTimers();
|
2018-08-05 13:22:59 -04:00
|
|
|
|
BaseForm.StopBackgroundTimer();
|
2018-07-11 18:07:13 -04:00
|
|
|
|
_logWindow?.Close();
|
|
|
|
|
_historyViewerWindow?.Close();
|
|
|
|
|
_cheatListWindow?.Close();
|
|
|
|
|
_hdPackEditorWindow?.Close();
|
|
|
|
|
_frmFullscreenRenderer?.Close();
|
2018-06-09 15:12:34 -04:00
|
|
|
|
|
2018-03-31 13:47:02 -04:00
|
|
|
|
//Stop menu update timer, and process all pending events before stopping the core
|
|
|
|
|
//This prevents some rare crashes on shutdown
|
|
|
|
|
menuTimer.Stop();
|
|
|
|
|
Application.DoEvents();
|
|
|
|
|
|
2016-05-22 14:43:07 -04:00
|
|
|
|
if(_notifListener != null) {
|
|
|
|
|
_notifListener.Dispose();
|
|
|
|
|
_notifListener = null;
|
|
|
|
|
}
|
2019-11-14 21:35:57 -05:00
|
|
|
|
|
|
|
|
|
this.Resize -= frmMain_Resize;
|
|
|
|
|
|
2017-08-14 23:44:01 -04:00
|
|
|
|
DebugWindowManager.CloseAll();
|
2016-05-22 14:43:07 -04:00
|
|
|
|
|
2016-09-11 08:29:34 -04:00
|
|
|
|
ConfigManager.Config.EmulationInfo.EmulationSpeed = InteropEmu.GetEmulationSpeed();
|
2018-06-14 20:08:03 -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;
|
|
|
|
|
|
2017-08-08 16:10:54 -04:00
|
|
|
|
if(this._nonNsfSize.HasValue) {
|
|
|
|
|
ConfigManager.Config.WindowSize = this._nonNsfSize.Value;
|
2017-05-01 23:17:51 -04:00
|
|
|
|
}
|
2017-08-08 16:10:54 -04:00
|
|
|
|
|
2016-05-22 14:43:07 -04:00
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
|
|
|
|
|
StopEmu();
|
|
|
|
|
|
|
|
|
|
if(ConfigManager.Config.PreferenceInfo.CloudSaveIntegration) {
|
|
|
|
|
CloudSyncHelper.Sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InteropEmu.Release();
|
|
|
|
|
|
2016-09-07 19:55:57 -04:00
|
|
|
|
ConfigManager.SaveConfig();
|
|
|
|
|
|
2016-05-22 14:43:07 -04:00
|
|
|
|
base.OnClosing(e);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-30 21:04:21 -04:00
|
|
|
|
private void menuTimer_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMenus();
|
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
2017-12-28 18:30:23 -05:00
|
|
|
|
void InitializeCore()
|
2015-07-05 22:23:44 -04:00
|
|
|
|
{
|
2017-11-29 23:24:26 -05:00
|
|
|
|
InteropEmu.InitializeEmu(ConfigManager.HomeFolder, this.Handle, ctrlRenderer.Handle, _noAudio, _noVideo, _noInput);
|
2017-12-28 18:30:23 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InitializeEmu()
|
|
|
|
|
{
|
2017-09-08 18:22:45 -04:00
|
|
|
|
if(ConfigManager.Config.PreferenceInfo.OverrideGameFolder && Directory.Exists(ConfigManager.Config.PreferenceInfo.GameFolder)) {
|
|
|
|
|
InteropEmu.AddKnownGameFolder(ConfigManager.Config.PreferenceInfo.GameFolder);
|
|
|
|
|
}
|
2016-06-26 10:43:52 -04:00
|
|
|
|
foreach(RecentItem recentItem in ConfigManager.Config.RecentFiles) {
|
2017-07-30 09:03:54 -04:00
|
|
|
|
InteropEmu.AddKnownGameFolder(recentItem.RomFile.Folder);
|
2015-07-05 22:23:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 17:45:18 -04:00
|
|
|
|
ConfigManager.Config.InitializeDefaults();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
2015-07-21 23:05:27 -04:00
|
|
|
|
ConfigManager.Config.ApplyConfig();
|
2017-07-30 09:03:54 -04:00
|
|
|
|
|
2015-07-17 21:18:57 -04:00
|
|
|
|
UpdateEmulationFlags();
|
|
|
|
|
}
|
2015-08-23 20:24:24 -04:00
|
|
|
|
|
2018-07-02 21:32:59 -04:00
|
|
|
|
private void UpdateViewerSize(bool forceUpdate = false)
|
2016-01-06 20:34:45 -05:00
|
|
|
|
{
|
2019-12-27 18:01:50 -05:00
|
|
|
|
if(_frmFullscreenRenderer != null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-08 16:10:54 -04:00
|
|
|
|
this.Resize -= frmMain_Resize;
|
|
|
|
|
|
2016-02-07 13:05:32 -05:00
|
|
|
|
InteropEmu.ScreenSize size = InteropEmu.GetScreenSize(false);
|
|
|
|
|
|
2018-07-02 21:32:59 -04:00
|
|
|
|
if(forceUpdate || (!_customSize && this.WindowState != FormWindowState.Maximized)) {
|
2016-12-30 16:43:49 -05:00
|
|
|
|
Size sizeGap = this.Size - this.ClientSize;
|
2016-12-22 23:08:34 -05:00
|
|
|
|
|
2018-07-02 22:44:23 -04:00
|
|
|
|
bool doubleScreenMode = _isDualSystem && ConfigManager.Config.PreferenceInfo.VsDualVideoOutput == VsDualOutputOption.Both;
|
|
|
|
|
int width = doubleScreenMode ? (size.Width * 2) : size.Width;
|
|
|
|
|
|
2016-12-30 16:43:49 -05:00
|
|
|
|
UpdateScaleMenu(size.Scale);
|
2018-07-02 21:32:59 -04:00
|
|
|
|
this.ClientSize = new Size(Math.Max(this.MinimumSize.Width - sizeGap.Width, width), Math.Max(this.MinimumSize.Height - sizeGap.Height, size.Height + (this.HideMenuStrip ? 0 : menuStrip.Height)));
|
2016-12-09 12:01:44 -05:00
|
|
|
|
}
|
2016-12-30 16:43:49 -05:00
|
|
|
|
|
|
|
|
|
ctrlRenderer.Size = new Size(size.Width, size.Height);
|
2018-07-03 23:32:46 -04:00
|
|
|
|
UpdateRendererPosition();
|
2018-07-02 22:44:23 -04:00
|
|
|
|
|
2017-04-22 16:54:45 -04:00
|
|
|
|
if(this.HideMenuStrip) {
|
|
|
|
|
this.menuStrip.Visible = false;
|
|
|
|
|
}
|
2017-08-08 16:10:54 -04:00
|
|
|
|
|
|
|
|
|
this.Resize += frmMain_Resize;
|
2016-02-07 13:05:32 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-03 23:32:46 -04:00
|
|
|
|
private void UpdateRendererPosition()
|
|
|
|
|
{
|
|
|
|
|
ctrlRenderer.Top = (panelRenderer.Height - ctrlRenderer.Height) / 2;
|
|
|
|
|
|
|
|
|
|
if(_isDualSystem) {
|
|
|
|
|
UpdateDualSystemViewer();
|
|
|
|
|
} else {
|
|
|
|
|
ctrlRenderer.Left = (panelRenderer.Width - ctrlRenderer.Width) / 2;
|
|
|
|
|
ctrlRendererDualSystem.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-02 22:44:23 -04:00
|
|
|
|
private void UpdateDualSystemViewer()
|
|
|
|
|
{
|
|
|
|
|
ctrlRendererDualSystem.Size = new Size(ctrlRenderer.Width, ctrlRenderer.Height);
|
|
|
|
|
ctrlRendererDualSystem.Top = (panelRenderer.Height - ctrlRenderer.Height) / 2;
|
|
|
|
|
|
|
|
|
|
if(ConfigManager.Config.PreferenceInfo.VsDualVideoOutput == VsDualOutputOption.Both) {
|
|
|
|
|
ctrlRenderer.Left = (panelRenderer.Width / 2 - ctrlRenderer.Width) / 2;
|
|
|
|
|
ctrlRendererDualSystem.Left = ctrlRenderer.Left + ctrlRenderer.Width;
|
|
|
|
|
|
|
|
|
|
ctrlRendererDualSystem.Visible = true;
|
|
|
|
|
} else {
|
2018-07-03 23:32:46 -04:00
|
|
|
|
ctrlRenderer.Left = (panelRenderer.Width - ctrlRenderer.Width) / 2;
|
2018-07-02 22:44:23 -04:00
|
|
|
|
ctrlRendererDualSystem.Left = (panelRenderer.Width - ctrlRenderer.Width) / 2;
|
|
|
|
|
|
|
|
|
|
if(ConfigManager.Config.PreferenceInfo.VsDualVideoOutput == VsDualOutputOption.SlaveOnly) {
|
|
|
|
|
ctrlRendererDualSystem.Visible = true;
|
|
|
|
|
ctrlRendererDualSystem.BringToFront();
|
|
|
|
|
} else {
|
|
|
|
|
ctrlRendererDualSystem.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-28 20:20:54 -05:00
|
|
|
|
private void ResizeRecentGames(object sender, EventArgs e)
|
2017-09-16 22:02:05 -04:00
|
|
|
|
{
|
2020-01-28 20:20:54 -05:00
|
|
|
|
ctrlRecentGames.Height = this.ClientSize.Height - ctrlRecentGames.Top - (ctrlRecentGames.Mode == GameScreenMode.RecentGames ? 25 : 0);
|
2017-09-16 22:02:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-28 20:20:54 -05:00
|
|
|
|
private void ShowRecentGames()
|
2017-05-06 15:27:48 -04:00
|
|
|
|
{
|
2019-12-22 21:06:20 -05:00
|
|
|
|
ctrlRecentGames.Height = this.ClientSize.Height - ctrlRecentGames.Top - 25;
|
2020-01-28 20:20:54 -05:00
|
|
|
|
ctrlRecentGames.ShowScreen(GameScreenMode.RecentGames);
|
2017-05-06 15:27:48 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-07 13:05:32 -05:00
|
|
|
|
private void frmMain_Resize(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-09-17 15:21:50 -04:00
|
|
|
|
if(_enableResize && this.WindowState != FormWindowState.Minimized) {
|
2016-02-07 13:05:32 -05:00
|
|
|
|
SetScaleBasedOnWindowSize();
|
2018-07-03 23:32:46 -04:00
|
|
|
|
UpdateRendererPosition();
|
2016-02-07 13:05:32 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-30 09:03:54 -04:00
|
|
|
|
|
2018-07-03 23:32:46 -04:00
|
|
|
|
private void SetScaleBasedOnDimensions(Size dimensions, bool allowVsDualScreen)
|
2016-02-07 13:05:32 -05:00
|
|
|
|
{
|
|
|
|
|
_customSize = true;
|
|
|
|
|
InteropEmu.ScreenSize size = InteropEmu.GetScreenSize(true);
|
2018-07-03 23:32:46 -04:00
|
|
|
|
|
|
|
|
|
if(allowVsDualScreen && _isDualSystem && ConfigManager.Config.PreferenceInfo.VsDualVideoOutput == VsDualOutputOption.Both) {
|
|
|
|
|
size = new InteropEmu.ScreenSize() {
|
|
|
|
|
Width = size.Width * 2,
|
|
|
|
|
Height = size.Height,
|
|
|
|
|
Scale = size.Scale
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 23:24:26 -05:00
|
|
|
|
double verticalScale = (double)dimensions.Height / size.Height;
|
|
|
|
|
double horizontalScale = (double)dimensions.Width / size.Width;
|
2016-02-07 13:05:32 -05:00
|
|
|
|
double scale = Math.Min(verticalScale, horizontalScale);
|
2018-07-15 18:26:08 -04:00
|
|
|
|
if(_fullscreenMode && ConfigManager.Config.VideoInfo.FullscreenForceIntegerScale) {
|
2017-08-03 21:55:31 -04:00
|
|
|
|
scale = Math.Floor(scale);
|
|
|
|
|
}
|
2016-02-07 13:05:32 -05:00
|
|
|
|
UpdateScaleMenu(scale);
|
|
|
|
|
VideoInfo.ApplyConfig();
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 23:24:26 -05:00
|
|
|
|
private void SetScaleBasedOnWindowSize()
|
|
|
|
|
{
|
2018-07-03 23:32:46 -04:00
|
|
|
|
SetScaleBasedOnDimensions(panelRenderer.ClientSize, true);
|
2017-11-29 23:24:26 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void StopExclusiveFullscreenMode()
|
|
|
|
|
{
|
|
|
|
|
if(_frmFullscreenRenderer != null) {
|
|
|
|
|
_frmFullscreenRenderer.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-26 23:31:08 -05:00
|
|
|
|
private Size GetFullscreenResolution()
|
|
|
|
|
{
|
|
|
|
|
string resolution = ConfigManager.Config.VideoInfo.FullscreenResolution;
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(resolution)) {
|
|
|
|
|
string[] resData = resolution.Split('x');
|
|
|
|
|
int width;
|
|
|
|
|
int height;
|
|
|
|
|
if(int.TryParse(resData[0], out width) && int.TryParse(resData[1], out height)) {
|
|
|
|
|
return new Size(width, height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Screen.FromControl(this).Bounds.Size;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 23:24:26 -05:00
|
|
|
|
private void StartExclusiveFullscreenMode()
|
|
|
|
|
{
|
2019-12-26 23:31:08 -05:00
|
|
|
|
Size screenSize = GetFullscreenResolution();
|
2019-12-27 18:01:50 -05:00
|
|
|
|
Size originalWindowSize = this.Size;
|
|
|
|
|
double originalScale = ConfigManager.Config.VideoInfo.VideoScale;
|
|
|
|
|
this.Resize -= frmMain_Resize;
|
2019-12-26 23:31:08 -05:00
|
|
|
|
|
2017-11-29 23:24:26 -05:00
|
|
|
|
_frmFullscreenRenderer = new frmFullscreenRenderer();
|
|
|
|
|
_frmFullscreenRenderer.Shown += (object sender, EventArgs e) => {
|
|
|
|
|
ctrlRenderer.Visible = false;
|
2019-12-26 23:31:08 -05:00
|
|
|
|
SetScaleBasedOnDimensions(screenSize, false);
|
2017-11-29 23:24:26 -05:00
|
|
|
|
InteropEmu.SetFullscreenMode(true, _frmFullscreenRenderer.Handle, (UInt32)screenSize.Width, (UInt32)screenSize.Height);
|
|
|
|
|
};
|
|
|
|
|
_frmFullscreenRenderer.FormClosing += (object sender, FormClosingEventArgs e) => {
|
|
|
|
|
InteropEmu.SetFullscreenMode(false, ctrlRenderer.Handle, (UInt32)screenSize.Width, (UInt32)screenSize.Height);
|
2019-12-27 18:01:50 -05:00
|
|
|
|
this.Resize += frmMain_Resize;
|
2017-11-29 23:24:26 -05:00
|
|
|
|
_frmFullscreenRenderer = null;
|
|
|
|
|
ctrlRenderer.Visible = true;
|
|
|
|
|
_fullscreenMode = false;
|
2019-12-27 18:01:50 -05:00
|
|
|
|
|
|
|
|
|
this.SetScale(originalScale);
|
|
|
|
|
this.Size = originalWindowSize;
|
2017-11-29 23:24:26 -05:00
|
|
|
|
};
|
2017-12-21 22:39:26 -05:00
|
|
|
|
|
|
|
|
|
Screen currentScreen = Screen.FromHandle(this.Handle);
|
|
|
|
|
_frmFullscreenRenderer.StartPosition = FormStartPosition.Manual;
|
|
|
|
|
_frmFullscreenRenderer.Top = currentScreen.Bounds.Top;
|
|
|
|
|
_frmFullscreenRenderer.Left = currentScreen.Bounds.Left;
|
2019-12-27 18:01:50 -05:00
|
|
|
|
_frmFullscreenRenderer.Size = screenSize;
|
2017-11-29 23:24:26 -05:00
|
|
|
|
_frmFullscreenRenderer.Show();
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-27 16:21:15 -05:00
|
|
|
|
private void StartFullscreenWindowMode(bool saveState)
|
2017-11-29 23:24:26 -05:00
|
|
|
|
{
|
|
|
|
|
this.menuStrip.Visible = false;
|
2017-12-27 16:21:15 -05:00
|
|
|
|
if(saveState) {
|
|
|
|
|
_originalWindowState = this.WindowState;
|
|
|
|
|
_originalWindowMinimumSize = this.MinimumSize;
|
|
|
|
|
}
|
2017-12-27 13:18:44 -05:00
|
|
|
|
this.MinimumSize = new Size(0, 0);
|
2017-11-29 23:24:26 -05:00
|
|
|
|
this.WindowState = FormWindowState.Normal;
|
|
|
|
|
this.FormBorderStyle = FormBorderStyle.None;
|
|
|
|
|
this.WindowState = FormWindowState.Maximized;
|
|
|
|
|
SetScaleBasedOnWindowSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void StopFullscreenWindowMode()
|
|
|
|
|
{
|
|
|
|
|
this.menuStrip.Visible = true;
|
|
|
|
|
this.WindowState = _originalWindowState;
|
2017-12-27 13:18:44 -05:00
|
|
|
|
this.MinimumSize = _originalWindowMinimumSize;
|
2018-06-28 17:34:19 -04:00
|
|
|
|
this.FormBorderStyle = ConfigManager.Config.PreferenceInfo.DisableMouseResize ? FormBorderStyle.Fixed3D : FormBorderStyle.Sizable;
|
2017-11-29 23:24:26 -05:00
|
|
|
|
this.frmMain_Resize(null, EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-07 13:05:32 -05:00
|
|
|
|
private void SetFullscreenState(bool enabled)
|
|
|
|
|
{
|
2017-11-29 23:24:26 -05:00
|
|
|
|
if(this._isNsfPlayerMode) {
|
|
|
|
|
enabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-26 13:02:40 -05:00
|
|
|
|
if(_fullscreenMode == enabled) {
|
|
|
|
|
//Fullscreen mode already matches, no need to do anything
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-03 14:35:54 -04:00
|
|
|
|
//Setup message to show on screen when paused while in fullscreen (instructions to revert to windowed mode)
|
|
|
|
|
InteropEmu.SetPauseScreenMessage("");
|
|
|
|
|
if(enabled) {
|
|
|
|
|
ShortcutKeyInfo shortcut = ConfigManager.Config.PreferenceInfo.ShortcutKeys1.Find(ski => ski.Shortcut == EmulatorShortcut.ToggleFullscreen);
|
|
|
|
|
if(shortcut == null || shortcut.KeyCombination.IsEmpty) {
|
|
|
|
|
shortcut = ConfigManager.Config.PreferenceInfo.ShortcutKeys2.Find(ski => ski.Shortcut == EmulatorShortcut.ToggleFullscreen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(shortcut != null && !shortcut.KeyCombination.IsEmpty) {
|
|
|
|
|
InteropEmu.SetPauseScreenMessage(ResourceHelper.GetMessage("PressToExitFullscreen", shortcut.KeyCombination.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-27 16:21:15 -05:00
|
|
|
|
bool saveState = !_fullscreenMode;
|
2017-05-01 19:03:54 -04:00
|
|
|
|
_fullscreenMode = enabled;
|
2017-11-29 23:24:26 -05:00
|
|
|
|
mnuFullscreen.Checked = enabled;
|
|
|
|
|
|
|
|
|
|
if(ConfigManager.Config.VideoInfo.UseExclusiveFullscreen) {
|
|
|
|
|
if(_emuThread != null) {
|
|
|
|
|
if(enabled) {
|
|
|
|
|
StartExclusiveFullscreenMode();
|
|
|
|
|
} else {
|
|
|
|
|
StopExclusiveFullscreenMode();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-07 13:05:32 -05:00
|
|
|
|
} else {
|
2017-11-29 23:24:26 -05:00
|
|
|
|
this.Resize -= frmMain_Resize;
|
|
|
|
|
if(enabled) {
|
2017-12-27 16:21:15 -05:00
|
|
|
|
StartFullscreenWindowMode(saveState);
|
2017-11-29 23:24:26 -05:00
|
|
|
|
} else {
|
|
|
|
|
StopFullscreenWindowMode();
|
|
|
|
|
}
|
|
|
|
|
this.Resize += frmMain_Resize;
|
|
|
|
|
UpdateViewerSize();
|
2016-02-07 13:05:32 -05:00
|
|
|
|
}
|
2015-07-23 23:16:31 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-22 16:54:45 -04:00
|
|
|
|
private bool HideMenuStrip
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-11-29 23:24:26 -05:00
|
|
|
|
return (_fullscreenMode && !ConfigManager.Config.VideoInfo.UseExclusiveFullscreen) || ConfigManager.Config.PreferenceInfo.AutoHideMenu;
|
2017-04-22 16:54:45 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-23 21:35:32 -04:00
|
|
|
|
private void ctrlRenderer_MouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2017-06-08 20:38:48 -04:00
|
|
|
|
if(sender != this.ctrlRecentGames) {
|
|
|
|
|
CursorManager.OnMouseMove((Control)sender);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-22 16:54:45 -04:00
|
|
|
|
if(this.HideMenuStrip && !this.menuStrip.ContainsFocus) {
|
|
|
|
|
if(sender == ctrlRenderer) {
|
|
|
|
|
this.menuStrip.Visible = ctrlRenderer.Top + e.Y < 30;
|
|
|
|
|
} else {
|
|
|
|
|
this.menuStrip.Visible = e.Y < 30;
|
|
|
|
|
}
|
2016-05-23 21:35:32 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctrlRenderer_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2017-04-22 16:54:45 -04:00
|
|
|
|
if(this.HideMenuStrip) {
|
2016-05-23 21:35:32 -04:00
|
|
|
|
this.menuStrip.Visible = false;
|
|
|
|
|
}
|
2017-11-19 23:08:23 -05:00
|
|
|
|
CursorManager.CaptureMouse();
|
2016-05-23 21:35:32 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-27 18:41:38 -05:00
|
|
|
|
private void _notifListener_OnNotification(InteropEmu.NotificationEventArgs e)
|
2015-07-01 23:17:14 -04:00
|
|
|
|
{
|
2016-01-28 20:47:16 -05:00
|
|
|
|
switch(e.NotificationType) {
|
2020-04-27 20:47:28 -04:00
|
|
|
|
case InteropEmu.ConsoleNotificationType.GameInitCompleted:
|
2018-06-03 16:37:36 -04:00
|
|
|
|
VideoInfo.ApplyOverscanConfig();
|
2016-06-17 20:53:05 -04:00
|
|
|
|
_currentGame = InteropEmu.GetRomInfo().GetRomName();
|
2017-05-22 11:50:21 -04:00
|
|
|
|
InteropEmu.SetNesModel(ConfigManager.Config.Region);
|
2018-12-26 11:24:08 -05:00
|
|
|
|
InitializeNsfMode(true);
|
2016-01-28 20:47:16 -05:00
|
|
|
|
CheatInfo.ApplyCheats();
|
2018-07-07 17:30:13 -04:00
|
|
|
|
GameSpecificInfo.ApplyGameSpecificConfig();
|
2017-09-08 10:38:41 -04:00
|
|
|
|
UpdateStateMenu(mnuSaveState, true);
|
|
|
|
|
UpdateStateMenu(mnuLoadState, false);
|
2017-05-22 20:14:02 -04:00
|
|
|
|
if(ConfigManager.Config.PreferenceInfo.ShowVsConfigOnLoad && InteropEmu.IsVsSystem()) {
|
|
|
|
|
this.Invoke((MethodInvoker)(() => {
|
2018-07-07 17:30:13 -04:00
|
|
|
|
this.ShowGameConfig();
|
2017-05-22 20:14:02 -04:00
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-01 09:13:54 -05:00
|
|
|
|
if(_openDebuggerRequested) {
|
|
|
|
|
InteropEmu.DebugPpuStep(1);
|
|
|
|
|
_openDebuggerRequested = false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-28 20:47:16 -05:00
|
|
|
|
this.StartEmuThread();
|
2016-12-30 18:31:50 -05:00
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => {
|
2020-05-06 18:43:27 -04:00
|
|
|
|
if(DebugWindowManager.HasOpenedWindow) {
|
|
|
|
|
DebugWorkspaceManager.GetWorkspace();
|
|
|
|
|
DebugWorkspaceManager.AutoLoadDbgFiles(true);
|
|
|
|
|
}
|
2019-12-22 21:06:20 -05:00
|
|
|
|
ctrlRecentGames.Visible = false;
|
2016-12-30 18:31:50 -05:00
|
|
|
|
UpdateViewerSize();
|
2018-12-22 13:25:09 -05:00
|
|
|
|
ProcessPostLoadCommandSwitches();
|
2016-12-30 18:31:50 -05:00
|
|
|
|
}));
|
2016-01-28 20:47:16 -05:00
|
|
|
|
break;
|
|
|
|
|
|
2019-12-24 15:14:01 -05:00
|
|
|
|
case InteropEmu.ConsoleNotificationType.GameResumed:
|
|
|
|
|
this.BeginInvoke((Action)(() => {
|
|
|
|
|
CursorManager.OnMouseMove(ctrlRenderer);
|
|
|
|
|
}));
|
|
|
|
|
break;
|
|
|
|
|
|
2016-06-25 20:46:54 -04:00
|
|
|
|
case InteropEmu.ConsoleNotificationType.GameReset:
|
|
|
|
|
InitializeNsfMode();
|
|
|
|
|
break;
|
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
|
case InteropEmu.ConsoleNotificationType.DisconnectedFromServer:
|
2017-11-14 00:00:00 -05:00
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => {
|
|
|
|
|
ConfigManager.Config.ApplyConfig();
|
|
|
|
|
}));
|
2016-02-05 23:14:27 -05:00
|
|
|
|
break;
|
|
|
|
|
|
2019-06-23 13:20:29 -04:00
|
|
|
|
case InteropEmu.ConsoleNotificationType.EmulationStopped:
|
|
|
|
|
InitializeNsfMode();
|
2019-12-22 21:06:20 -05:00
|
|
|
|
this.BeginInvoke((Action)(() => {
|
2020-01-28 20:20:54 -05:00
|
|
|
|
ShowRecentGames();
|
2019-12-22 21:06:20 -05:00
|
|
|
|
}));
|
2019-06-23 13:20:29 -04:00
|
|
|
|
break;
|
|
|
|
|
|
2016-01-28 20:47:16 -05:00
|
|
|
|
case InteropEmu.ConsoleNotificationType.GameStopped:
|
2017-05-06 15:27:48 -04:00
|
|
|
|
this._currentGame = null;
|
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => {
|
2017-06-28 19:00:08 -04:00
|
|
|
|
if(_hdPackEditorWindow != null) {
|
|
|
|
|
_hdPackEditorWindow.Close();
|
|
|
|
|
}
|
2017-11-29 23:24:26 -05:00
|
|
|
|
if(e.Parameter == IntPtr.Zero) {
|
|
|
|
|
//We are completely stopping the emulation, close fullscreen mode
|
|
|
|
|
StopExclusiveFullscreenMode();
|
|
|
|
|
}
|
2017-05-06 15:27:48 -04:00
|
|
|
|
}));
|
2016-01-28 20:47:16 -05:00
|
|
|
|
break;
|
|
|
|
|
|
2018-04-10 17:05:54 -04:00
|
|
|
|
case InteropEmu.ConsoleNotificationType.BeforeEmulationStop:
|
2019-01-27 14:31:05 -05:00
|
|
|
|
//Close all debugger windows before continuing.
|
2018-04-10 17:05:54 -04:00
|
|
|
|
this.Invoke((Action)(() => {
|
2017-10-05 21:40:25 -04:00
|
|
|
|
DebugWindowManager.CloseAll();
|
|
|
|
|
}));
|
|
|
|
|
break;
|
|
|
|
|
|
2016-01-28 20:47:16 -05:00
|
|
|
|
case InteropEmu.ConsoleNotificationType.ResolutionChanged:
|
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => {
|
2017-12-27 16:21:15 -05:00
|
|
|
|
ProcessResolutionChanged();
|
2016-01-28 20:47:16 -05:00
|
|
|
|
}));
|
|
|
|
|
break;
|
|
|
|
|
|
2019-12-31 20:23:26 -05:00
|
|
|
|
case InteropEmu.ConsoleNotificationType.BiosNotFound:
|
2016-01-28 20:47:16 -05:00
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => {
|
2019-12-31 20:23:26 -05:00
|
|
|
|
RomFormat format = ((RomFormat)e.Parameter);
|
|
|
|
|
if(format == RomFormat.Fds) {
|
|
|
|
|
SelectBiosPrompt("FdsBios.bin", 0x2000, RomFormat.Fds);
|
|
|
|
|
} else if(format == RomFormat.StudyBox) {
|
|
|
|
|
SelectBiosPrompt("StudyBox.bin", 0x40000, RomFormat.StudyBox);
|
|
|
|
|
}
|
2016-01-28 20:47:16 -05:00
|
|
|
|
}));
|
|
|
|
|
break;
|
2017-02-18 13:59:58 -05:00
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
case InteropEmu.ConsoleNotificationType.ExecuteShortcut:
|
2017-05-25 20:31:20 -04:00
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => {
|
2017-09-08 10:38:41 -04:00
|
|
|
|
ExecuteShortcut((EmulatorShortcut)e.Parameter);
|
2017-05-25 20:31:20 -04:00
|
|
|
|
}));
|
|
|
|
|
break;
|
2017-08-30 18:31:27 -04:00
|
|
|
|
|
|
|
|
|
case InteropEmu.ConsoleNotificationType.CodeBreak:
|
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => {
|
|
|
|
|
if(DebugWindowManager.GetDebugger() == null) {
|
|
|
|
|
DebugWindowManager.OpenDebugWindow(DebugWindow.Debugger);
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
break;
|
2018-07-02 21:32:59 -04:00
|
|
|
|
|
|
|
|
|
case InteropEmu.ConsoleNotificationType.VsDualSystemStarted:
|
|
|
|
|
_isDualSystem = true;
|
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => {
|
|
|
|
|
UpdateViewerSize(true);
|
|
|
|
|
InteropEmu.InitializeDualSystem(this.Handle, ctrlRendererDualSystem.Handle);
|
|
|
|
|
}));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InteropEmu.ConsoleNotificationType.VsDualSystemStopped:
|
|
|
|
|
_isDualSystem = false;
|
|
|
|
|
InteropEmu.ReleaseDualSystemAudioVideo();
|
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => {
|
|
|
|
|
UpdateViewerSize(true);
|
|
|
|
|
}));
|
|
|
|
|
break;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
2016-06-25 20:46:54 -04:00
|
|
|
|
|
|
|
|
|
if(e.NotificationType != InteropEmu.ConsoleNotificationType.PpuFrameDone) {
|
|
|
|
|
UpdateMenus();
|
|
|
|
|
}
|
2017-12-27 16:21:15 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ProcessResolutionChanged()
|
|
|
|
|
{
|
2019-12-27 18:01:50 -05:00
|
|
|
|
if(_frmFullscreenRenderer != null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-27 16:21:15 -05:00
|
|
|
|
//Force scale specified by command line options, when using /fullscreen
|
|
|
|
|
if(_fullscreenRequested) {
|
|
|
|
|
SetFullscreenState(true);
|
|
|
|
|
if(_switchOptionScale.HasValue) {
|
|
|
|
|
//If a VideoScale is specified in command line, apply it
|
|
|
|
|
SetScale(_switchOptionScale.Value);
|
|
|
|
|
}
|
|
|
|
|
_fullscreenRequested = false;
|
|
|
|
|
} else if(_switchOptionScale.HasValue) {
|
|
|
|
|
//For exclusive fullscreen, resolution changed will be called twice, need to set the scale one more time here
|
|
|
|
|
SetScale(_switchOptionScale.Value);
|
|
|
|
|
_switchOptionScale = null;
|
|
|
|
|
} else {
|
|
|
|
|
UpdateViewerSize();
|
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
|
|
|
|
private void BindShortcuts()
|
|
|
|
|
{
|
2017-09-08 11:25:10 -04:00
|
|
|
|
Func<bool> notClient = () => { return !InteropEmu.IsConnected(); };
|
2017-09-08 10:38:41 -04:00
|
|
|
|
Func<bool> runningNotClient = () => { return _emuThread != null && !InteropEmu.IsConnected(); };
|
2017-11-19 23:08:23 -05:00
|
|
|
|
Func<bool> runningNotClientNotMovie = () => { return _emuThread != null && !InteropEmu.IsConnected() && !InteropEmu.MoviePlaying(); };
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
|
|
|
|
Func<bool> runningNotNsf = () => { return _emuThread != null && !InteropEmu.IsNsf(); };
|
2017-11-19 23:08:23 -05:00
|
|
|
|
Func<bool> runningFdsNoAutoInsert = () => { return _emuThread != null && InteropEmu.FdsGetSideCount() > 0 && !InteropEmu.FdsIsAutoInsertDiskEnabled() && !InteropEmu.MoviePlaying() && !InteropEmu.IsConnected(); };
|
2018-06-03 18:20:40 -04:00
|
|
|
|
Func<bool> runningFdsMultipleDisks = () => { return runningFdsNoAutoInsert() && InteropEmu.FdsGetSideCount() > 1; };
|
2017-11-19 23:08:23 -05:00
|
|
|
|
Func<bool> runningVsSystem = () => { return _emuThread != null && InteropEmu.IsVsSystem() && !InteropEmu.MoviePlaying() && !InteropEmu.IsConnected(); };
|
2018-07-07 20:50:31 -04:00
|
|
|
|
Func<bool> runningVsDualSystem = () => { return runningVsSystem() && InteropEmu.IsVsDualSystem(); };
|
2017-11-19 23:08:23 -05:00
|
|
|
|
Func<bool> hasBarcodeReader = () => { return InteropEmu.GetAvailableFeatures().HasFlag(ConsoleFeatures.BarcodeReader) && !InteropEmu.IsConnected(); };
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
2018-03-20 23:17:39 -04:00
|
|
|
|
Func<bool> enableLoadLastSession = () => {
|
|
|
|
|
string recentGameFile = _currentRomPath.HasValue ? Path.Combine(ConfigManager.RecentGamesFolder, Path.GetFileNameWithoutExtension(_currentRomPath.Value.FileName) + ".rgd") : "";
|
|
|
|
|
return _emuThread != null && File.Exists(recentGameFile) && !ConfigManager.Config.PreferenceInfo.DisableGameSelectionScreen;
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
BindShortcut(mnuOpen, EmulatorShortcut.OpenFile);
|
|
|
|
|
BindShortcut(mnuExit, EmulatorShortcut.Exit);
|
2017-09-08 11:25:10 -04:00
|
|
|
|
BindShortcut(mnuIncreaseSpeed, EmulatorShortcut.IncreaseSpeed, notClient);
|
|
|
|
|
BindShortcut(mnuDecreaseSpeed, EmulatorShortcut.DecreaseSpeed, notClient);
|
|
|
|
|
BindShortcut(mnuEmuSpeedMaximumSpeed, EmulatorShortcut.MaxSpeed, notClient);
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
|
|
|
|
BindShortcut(mnuPause, EmulatorShortcut.Pause, runningNotClient);
|
|
|
|
|
BindShortcut(mnuReset, EmulatorShortcut.Reset, runningNotClientNotMovie);
|
|
|
|
|
BindShortcut(mnuPowerCycle, EmulatorShortcut.PowerCycle, runningNotClientNotMovie);
|
2019-11-17 18:44:36 -05:00
|
|
|
|
BindShortcut(mnuReloadRom, EmulatorShortcut.ReloadRom, runningNotClientNotMovie);
|
2017-09-08 10:38:41 -04:00
|
|
|
|
BindShortcut(mnuPowerOff, EmulatorShortcut.PowerOff, runningNotClient);
|
|
|
|
|
|
2018-06-03 18:20:40 -04:00
|
|
|
|
BindShortcut(mnuSwitchDiskSide, EmulatorShortcut.SwitchDiskSide, runningFdsMultipleDisks);
|
2017-09-08 10:38:41 -04:00
|
|
|
|
BindShortcut(mnuEjectDisk, EmulatorShortcut.EjectDisk, runningFdsNoAutoInsert);
|
|
|
|
|
|
|
|
|
|
BindShortcut(mnuInsertCoin1, EmulatorShortcut.InsertCoin1, runningVsSystem);
|
|
|
|
|
BindShortcut(mnuInsertCoin2, EmulatorShortcut.InsertCoin2, runningVsSystem);
|
2018-07-07 20:50:31 -04:00
|
|
|
|
BindShortcut(mnuInsertCoin3, EmulatorShortcut.InsertCoin3, runningVsDualSystem);
|
|
|
|
|
BindShortcut(mnuInsertCoin4, EmulatorShortcut.InsertCoin4, runningVsDualSystem);
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
|
BindShortcut(mnuInputBarcode, EmulatorShortcut.InputBarcode, hasBarcodeReader);
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
BindShortcut(mnuShowFPS, EmulatorShortcut.ToggleFps);
|
|
|
|
|
|
|
|
|
|
BindShortcut(mnuScale1x, EmulatorShortcut.SetScale1x);
|
|
|
|
|
BindShortcut(mnuScale2x, EmulatorShortcut.SetScale2x);
|
|
|
|
|
BindShortcut(mnuScale3x, EmulatorShortcut.SetScale3x);
|
|
|
|
|
BindShortcut(mnuScale4x, EmulatorShortcut.SetScale4x);
|
|
|
|
|
BindShortcut(mnuScale5x, EmulatorShortcut.SetScale5x);
|
|
|
|
|
BindShortcut(mnuScale6x, EmulatorShortcut.SetScale6x);
|
|
|
|
|
|
|
|
|
|
BindShortcut(mnuFullscreen, EmulatorShortcut.ToggleFullscreen);
|
|
|
|
|
|
2018-03-20 23:17:39 -04:00
|
|
|
|
BindShortcut(mnuLoadLastSession, EmulatorShortcut.LoadLastSession, enableLoadLastSession);
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
BindShortcut(mnuTakeScreenshot, EmulatorShortcut.TakeScreenshot, runningNotNsf);
|
|
|
|
|
BindShortcut(mnuRandomGame, EmulatorShortcut.LoadRandomGame);
|
|
|
|
|
|
2018-03-10 09:58:24 -05:00
|
|
|
|
mnuDebugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenDebugger));
|
|
|
|
|
mnuApuViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenApuViewer));
|
|
|
|
|
mnuAssembler.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenAssembler));
|
|
|
|
|
mnuMemoryViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenMemoryTools));
|
|
|
|
|
mnuEventViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenEventViewer));
|
|
|
|
|
mnuPpuViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenPpuViewer));
|
|
|
|
|
mnuScriptWindow.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenScriptWindow));
|
|
|
|
|
mnuTraceLogger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenTraceLogger));
|
2018-06-23 18:29:15 -04:00
|
|
|
|
mnuTextHooker.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenTextHooker));
|
2019-01-19 20:00:48 -05:00
|
|
|
|
mnuProfiler.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenProfiler));
|
2019-01-29 17:21:23 -05:00
|
|
|
|
mnuWatchWindow.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenWatchWindow));
|
2019-01-19 18:56:08 -05:00
|
|
|
|
|
|
|
|
|
mnuOpenNametableViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenNametableViewer));
|
|
|
|
|
mnuOpenChrViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenChrViewer));
|
|
|
|
|
mnuOpenSpriteViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenSpriteViewer));
|
|
|
|
|
mnuOpenPaletteViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenPaletteViewer));
|
2017-09-08 10:38:41 -04:00
|
|
|
|
}
|
2019-01-19 18:56:08 -05:00
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
private void BindShortcut(ToolStripMenuItem item, EmulatorShortcut shortcut, Func<bool> isActionEnabled = null)
|
|
|
|
|
{
|
|
|
|
|
item.Click += (object sender, EventArgs e) => {
|
|
|
|
|
if(isActionEnabled == null || isActionEnabled()) {
|
|
|
|
|
ExecuteShortcut(shortcut);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_actionEnabledFuncs[shortcut] = isActionEnabled;
|
|
|
|
|
|
|
|
|
|
if(item.OwnerItem is ToolStripMenuItem) {
|
|
|
|
|
Action updateShortcut = () => {
|
|
|
|
|
int keyIndex = ConfigManager.Config.PreferenceInfo.ShortcutKeys1.FindIndex((ShortcutKeyInfo shortcutInfo) => shortcutInfo.Shortcut == shortcut);
|
|
|
|
|
if(keyIndex >= 0) {
|
|
|
|
|
item.ShortcutKeyDisplayString = ConfigManager.Config.PreferenceInfo.ShortcutKeys1[keyIndex].KeyCombination.ToString();
|
|
|
|
|
} else {
|
|
|
|
|
keyIndex = ConfigManager.Config.PreferenceInfo.ShortcutKeys2.FindIndex((ShortcutKeyInfo shortcutInfo) => shortcutInfo.Shortcut == shortcut);
|
|
|
|
|
if(keyIndex >= 0) {
|
|
|
|
|
item.ShortcutKeyDisplayString = ConfigManager.Config.PreferenceInfo.ShortcutKeys2[keyIndex].KeyCombination.ToString();
|
|
|
|
|
} else {
|
|
|
|
|
item.ShortcutKeyDisplayString = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
item.Enabled = isActionEnabled == null || isActionEnabled();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateShortcut();
|
|
|
|
|
|
|
|
|
|
//Update item shortcut text when its parent opens
|
|
|
|
|
((ToolStripMenuItem)item.OwnerItem).DropDownOpening += (object sender, EventArgs e) => { updateShortcut(); };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ExecuteShortcut(EmulatorShortcut shortcut)
|
|
|
|
|
{
|
|
|
|
|
Func<bool> isActionEnabled;
|
|
|
|
|
if(_actionEnabledFuncs.TryGetValue(shortcut, out isActionEnabled)) {
|
|
|
|
|
isActionEnabled = _actionEnabledFuncs[shortcut];
|
|
|
|
|
if(isActionEnabled != null && !isActionEnabled()) {
|
|
|
|
|
//Action disabled
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 23:24:26 -05:00
|
|
|
|
bool restoreFullscreen = _frmFullscreenRenderer != null;
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
switch(shortcut) {
|
|
|
|
|
case EmulatorShortcut.Pause: PauseEmu(); break;
|
|
|
|
|
case EmulatorShortcut.Reset: this.ResetEmu(); break;
|
|
|
|
|
case EmulatorShortcut.PowerCycle: this.PowerCycleEmu(); break;
|
2019-11-17 18:44:36 -05:00
|
|
|
|
case EmulatorShortcut.ReloadRom: InteropEmu.ReloadRom(); break;
|
2018-04-10 17:05:54 -04:00
|
|
|
|
case EmulatorShortcut.PowerOff: Task.Run(() => InteropEmu.Stop()); break;
|
2017-09-08 10:38:41 -04:00
|
|
|
|
case EmulatorShortcut.Exit: this.Close(); break;
|
|
|
|
|
|
|
|
|
|
case EmulatorShortcut.ToggleCheats: ToggleCheats(); break;
|
|
|
|
|
case EmulatorShortcut.ToggleFps: ToggleFps(); break;
|
2017-10-02 18:44:36 -04:00
|
|
|
|
case EmulatorShortcut.ToggleBackground: ToggleBackground(); break;
|
|
|
|
|
case EmulatorShortcut.ToggleSprites: ToggleSprites(); break;
|
|
|
|
|
case EmulatorShortcut.ToggleGameTimer: ToggleGameTimer(); break;
|
|
|
|
|
case EmulatorShortcut.ToggleFrameCounter: ToggleFrameCounter(); break;
|
|
|
|
|
case EmulatorShortcut.ToggleLagCounter: ToggleLagCounter(); break;
|
|
|
|
|
case EmulatorShortcut.ToggleOsd: ToggleOsd(); break;
|
2017-12-26 12:38:30 -05:00
|
|
|
|
case EmulatorShortcut.ToggleAlwaysOnTop: ToggleAlwaysOnTop(); break;
|
2018-06-09 14:03:53 -04:00
|
|
|
|
case EmulatorShortcut.ToggleDebugInfo: ToggleDebugInfo(); break;
|
2017-09-08 10:38:41 -04:00
|
|
|
|
case EmulatorShortcut.MaxSpeed: ToggleMaxSpeed(); break;
|
2017-11-29 23:24:26 -05:00
|
|
|
|
case EmulatorShortcut.ToggleFullscreen: ToggleFullscreen(); restoreFullscreen = false; break;
|
2020-04-21 21:58:07 -04:00
|
|
|
|
|
|
|
|
|
case EmulatorShortcut.ToggleAudio: ToggleAudio(); break;
|
|
|
|
|
case EmulatorShortcut.IncreaseVolume: IncreaseVolume(); break;
|
|
|
|
|
case EmulatorShortcut.DecreaseVolume: DecreaseVolume(); break;
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
|
|
|
|
case EmulatorShortcut.OpenFile: OpenFile(); break;
|
|
|
|
|
case EmulatorShortcut.IncreaseSpeed: InteropEmu.IncreaseEmulationSpeed(); break;
|
|
|
|
|
case EmulatorShortcut.DecreaseSpeed: InteropEmu.DecreaseEmulationSpeed(); break;
|
|
|
|
|
case EmulatorShortcut.SwitchDiskSide: InteropEmu.FdsSwitchDiskSide(); break;
|
|
|
|
|
case EmulatorShortcut.EjectDisk: InteropEmu.FdsEjectDisk(); break;
|
|
|
|
|
|
|
|
|
|
case EmulatorShortcut.SetScale1x: SetScale(1); break;
|
|
|
|
|
case EmulatorShortcut.SetScale2x: SetScale(2); break;
|
|
|
|
|
case EmulatorShortcut.SetScale3x: SetScale(3); break;
|
|
|
|
|
case EmulatorShortcut.SetScale4x: SetScale(4); break;
|
|
|
|
|
case EmulatorShortcut.SetScale5x: SetScale(5); break;
|
|
|
|
|
case EmulatorShortcut.SetScale6x: SetScale(6); break;
|
|
|
|
|
|
|
|
|
|
case EmulatorShortcut.InsertCoin1: InteropEmu.VsInsertCoin(0); break;
|
|
|
|
|
case EmulatorShortcut.InsertCoin2: InteropEmu.VsInsertCoin(1); break;
|
2018-07-07 20:50:31 -04:00
|
|
|
|
case EmulatorShortcut.InsertCoin3: InteropEmu.VsInsertCoin(2); break;
|
|
|
|
|
case EmulatorShortcut.InsertCoin4: InteropEmu.VsInsertCoin(3); break;
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
|
case EmulatorShortcut.InputBarcode:
|
|
|
|
|
using(frmInputBarcode frm = new frmInputBarcode()) {
|
2017-11-29 23:24:26 -05:00
|
|
|
|
frm.ShowDialog(this, this);
|
2017-11-19 23:08:23 -05:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
case EmulatorShortcut.TakeScreenshot: InteropEmu.TakeScreenshot(); break;
|
|
|
|
|
case EmulatorShortcut.LoadRandomGame: LoadRandomGame(); break;
|
|
|
|
|
|
|
|
|
|
case EmulatorShortcut.LoadStateFromFile: LoadStateFromFile(); break;
|
|
|
|
|
case EmulatorShortcut.SaveStateToFile: SaveStateToFile(); break;
|
|
|
|
|
|
2020-01-28 20:20:54 -05:00
|
|
|
|
case EmulatorShortcut.LoadStateDialog:
|
|
|
|
|
if(_frmFullscreenRenderer != null) {
|
|
|
|
|
this.SetFullscreenState(false);
|
|
|
|
|
restoreFullscreen = false;
|
|
|
|
|
}
|
|
|
|
|
ctrlRecentGames.ShowScreen(GameScreenMode.LoadState);
|
|
|
|
|
ctrlRecentGames.Height = this.ClientSize.Height - ctrlRecentGames.Top;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EmulatorShortcut.SaveStateDialog:
|
|
|
|
|
if(_frmFullscreenRenderer != null) {
|
|
|
|
|
this.SetFullscreenState(false);
|
|
|
|
|
restoreFullscreen = false;
|
|
|
|
|
}
|
|
|
|
|
ctrlRecentGames.ShowScreen(GameScreenMode.SaveState);
|
|
|
|
|
ctrlRecentGames.Height = this.ClientSize.Height - ctrlRecentGames.Top;
|
|
|
|
|
break;
|
|
|
|
|
|
2017-09-08 10:38:41 -04:00
|
|
|
|
case EmulatorShortcut.SaveStateSlot1: SaveState(1); break;
|
|
|
|
|
case EmulatorShortcut.SaveStateSlot2: SaveState(2); break;
|
|
|
|
|
case EmulatorShortcut.SaveStateSlot3: SaveState(3); break;
|
|
|
|
|
case EmulatorShortcut.SaveStateSlot4: SaveState(4); break;
|
|
|
|
|
case EmulatorShortcut.SaveStateSlot5: SaveState(5); break;
|
|
|
|
|
case EmulatorShortcut.SaveStateSlot6: SaveState(6); break;
|
|
|
|
|
case EmulatorShortcut.SaveStateSlot7: SaveState(7); break;
|
2018-03-20 22:48:00 -04:00
|
|
|
|
case EmulatorShortcut.SaveStateSlot8: SaveState(8); break;
|
|
|
|
|
case EmulatorShortcut.SaveStateSlot9: SaveState(9); break;
|
|
|
|
|
case EmulatorShortcut.SaveStateSlot10: SaveState(10); break;
|
2017-09-08 10:38:41 -04:00
|
|
|
|
case EmulatorShortcut.LoadStateSlot1: LoadState(1); break;
|
|
|
|
|
case EmulatorShortcut.LoadStateSlot2: LoadState(2); break;
|
|
|
|
|
case EmulatorShortcut.LoadStateSlot3: LoadState(3); break;
|
|
|
|
|
case EmulatorShortcut.LoadStateSlot4: LoadState(4); break;
|
|
|
|
|
case EmulatorShortcut.LoadStateSlot5: LoadState(5); break;
|
|
|
|
|
case EmulatorShortcut.LoadStateSlot6: LoadState(6); break;
|
|
|
|
|
case EmulatorShortcut.LoadStateSlot7: LoadState(7); break;
|
|
|
|
|
case EmulatorShortcut.LoadStateSlot8: LoadState(8); break;
|
2018-03-20 22:48:00 -04:00
|
|
|
|
case EmulatorShortcut.LoadStateSlot9: LoadState(9); break;
|
|
|
|
|
case EmulatorShortcut.LoadStateSlot10: LoadState(10); break;
|
|
|
|
|
case EmulatorShortcut.LoadStateSlotAuto: LoadState(11); break;
|
2018-03-20 23:17:39 -04:00
|
|
|
|
|
|
|
|
|
case EmulatorShortcut.LoadLastSession: LoadLastSession(); break;
|
2017-09-08 10:38:41 -04:00
|
|
|
|
}
|
2017-11-29 23:24:26 -05:00
|
|
|
|
|
2018-06-25 16:37:05 -04:00
|
|
|
|
if(restoreFullscreen && _frmFullscreenRenderer == null && !_shuttingDown) {
|
2017-11-29 23:24:26 -05:00
|
|
|
|
//Need to restore fullscreen mode after showing a dialog
|
|
|
|
|
this.SetFullscreenState(true);
|
|
|
|
|
}
|
2017-09-08 10:38:41 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleFullscreen()
|
|
|
|
|
{
|
|
|
|
|
SetFullscreenState(!_fullscreenMode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleMaxSpeed()
|
|
|
|
|
{
|
|
|
|
|
if(ConfigManager.Config.EmulationInfo.EmulationSpeed == 0) {
|
|
|
|
|
SetEmulationSpeed(100);
|
|
|
|
|
} else {
|
|
|
|
|
SetEmulationSpeed(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleFps()
|
|
|
|
|
{
|
|
|
|
|
mnuShowFPS.Checked = !mnuShowFPS.Checked;
|
|
|
|
|
UpdateEmulationFlags();
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-02 18:44:36 -04:00
|
|
|
|
private void ToggleAudio()
|
2017-09-08 10:38:41 -04:00
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.AudioInfo.EnableAudio = !ConfigManager.Config.AudioInfo.EnableAudio;
|
|
|
|
|
AudioInfo.ApplyConfig();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 21:58:07 -04:00
|
|
|
|
private void IncreaseVolume()
|
|
|
|
|
{
|
2020-04-28 17:59:40 -04:00
|
|
|
|
ConfigManager.Config.AudioInfo.MasterVolume = (uint)Math.Min(100, (int)ConfigManager.Config.AudioInfo.MasterVolume + 5);
|
2020-04-21 21:58:07 -04:00
|
|
|
|
AudioInfo.ApplyConfig();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DecreaseVolume()
|
|
|
|
|
{
|
2020-04-28 17:59:40 -04:00
|
|
|
|
ConfigManager.Config.AudioInfo.MasterVolume = (uint)Math.Max(0, (int)ConfigManager.Config.AudioInfo.MasterVolume - 5);
|
2020-04-21 21:58:07 -04:00
|
|
|
|
AudioInfo.ApplyConfig();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-02 18:44:36 -04:00
|
|
|
|
private void ToggleFrameCounter()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.PreferenceInfo.ShowFrameCounter = !ConfigManager.Config.PreferenceInfo.ShowFrameCounter;
|
|
|
|
|
PreferenceInfo.ApplyConfig();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleLagCounter()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.EmulationInfo.ShowLagCounter = !ConfigManager.Config.EmulationInfo.ShowLagCounter;
|
|
|
|
|
EmulationInfo.ApplyConfig();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleGameTimer()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.PreferenceInfo.ShowGameTimer = !ConfigManager.Config.PreferenceInfo.ShowGameTimer;
|
|
|
|
|
PreferenceInfo.ApplyConfig();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleOsd()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.PreferenceInfo.DisableOsd = !ConfigManager.Config.PreferenceInfo.DisableOsd;
|
|
|
|
|
PreferenceInfo.ApplyConfig();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 12:38:30 -05:00
|
|
|
|
private void ToggleAlwaysOnTop()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.PreferenceInfo.AlwaysOnTop = !ConfigManager.Config.PreferenceInfo.AlwaysOnTop;
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
this.TopMost = ConfigManager.Config.PreferenceInfo.AlwaysOnTop;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-02 18:44:36 -04:00
|
|
|
|
private void ToggleSprites()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.VideoInfo.DisableSprites = !ConfigManager.Config.VideoInfo.DisableSprites;
|
|
|
|
|
VideoInfo.ApplyConfig();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleBackground()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.VideoInfo.DisableBackground = !ConfigManager.Config.VideoInfo.DisableBackground;
|
|
|
|
|
VideoInfo.ApplyConfig();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-09 14:03:53 -04:00
|
|
|
|
private void ToggleDebugInfo()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.PreferenceInfo.DisplayDebugInfo = !ConfigManager.Config.PreferenceInfo.DisplayDebugInfo;
|
|
|
|
|
PreferenceInfo.ApplyConfig();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-02 18:44:36 -04:00
|
|
|
|
private void ToggleCheats()
|
2017-09-08 10:38:41 -04:00
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.DisableAllCheats = !ConfigManager.Config.DisableAllCheats;
|
|
|
|
|
if(ConfigManager.Config.DisableAllCheats) {
|
|
|
|
|
InteropEmu.DisplayMessage("Cheats", "CheatsDisabled");
|
|
|
|
|
}
|
|
|
|
|
CheatInfo.ApplyCheats();
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
private void UpdateMenus()
|
|
|
|
|
{
|
2018-06-09 15:12:34 -04:00
|
|
|
|
if(_shuttingDown) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
try {
|
|
|
|
|
if(this.InvokeRequired) {
|
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => this.UpdateMenus()));
|
|
|
|
|
} else {
|
2017-08-14 23:44:01 -04:00
|
|
|
|
bool running = _emuThread != null;
|
2020-02-01 10:28:42 -05:00
|
|
|
|
bool runAheadEnabled = ConfigManager.Config.EmulationInfo.RunAheadFrames > 0;
|
2017-08-14 23:44:01 -04:00
|
|
|
|
|
|
|
|
|
panelInfo.Visible = !running;
|
2017-05-02 00:00:27 -04:00
|
|
|
|
|
2016-06-26 10:43:52 -04:00
|
|
|
|
ctrlLoading.Visible = (_romLoadCounter > 0);
|
|
|
|
|
|
2017-04-22 16:54:45 -04:00
|
|
|
|
UpdateWindowTitle();
|
2015-08-23 20:24:24 -04:00
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
|
bool isNetPlayClient = InteropEmu.IsConnected();
|
|
|
|
|
|
2017-08-14 23:44:01 -04:00
|
|
|
|
mnuSaveState.Enabled = (running && !isNetPlayClient && !InteropEmu.IsNsf());
|
|
|
|
|
mnuLoadState.Enabled = (running && !isNetPlayClient && !InteropEmu.IsNsf() && !InteropEmu.MoviePlaying() && !InteropEmu.MovieRecording());
|
2016-07-19 16:36:07 -04:00
|
|
|
|
|
2016-02-19 13:05:04 -05:00
|
|
|
|
mnuPause.Text = InteropEmu.IsPaused() ? ResourceHelper.GetMessage("Resume") : ResourceHelper.GetMessage("Pause");
|
2017-03-09 23:50:20 -05:00
|
|
|
|
mnuPause.Image = InteropEmu.IsPaused() ? _playButton : _pauseButton;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
|
bool netPlay = InteropEmu.IsServerRunning() || isNetPlayClient;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
|
mnuStartServer.Enabled = !isNetPlayClient;
|
|
|
|
|
mnuConnect.Enabled = !InteropEmu.IsServerRunning();
|
2016-02-06 15:33:45 -05:00
|
|
|
|
mnuNetPlaySelectController.Enabled = isNetPlayClient || InteropEmu.IsServerRunning();
|
|
|
|
|
if(mnuNetPlaySelectController.Enabled) {
|
|
|
|
|
int availableControllers = InteropEmu.NetPlayGetAvailableControllers();
|
|
|
|
|
int currentControllerPort = InteropEmu.NetPlayGetControllerPort();
|
|
|
|
|
mnuNetPlayPlayer1.Enabled = (availableControllers & 0x01) == 0x01;
|
|
|
|
|
mnuNetPlayPlayer2.Enabled = (availableControllers & 0x02) == 0x02;
|
|
|
|
|
mnuNetPlayPlayer3.Enabled = (availableControllers & 0x04) == 0x04;
|
|
|
|
|
mnuNetPlayPlayer4.Enabled = (availableControllers & 0x08) == 0x08;
|
2017-11-19 23:08:23 -05:00
|
|
|
|
|
|
|
|
|
bool isFamicom = InteropEmu.GetConsoleType() == ConsoleType.Famicom;
|
|
|
|
|
mnuNetPlayPlayer5.Visible = isFamicom;
|
|
|
|
|
mnuNetPlayPlayer5.Enabled = (availableControllers & 0x10) == 0x10 && InteropEmu.GetExpansionDevice() != InteropEmu.ExpansionPortDevice.FourPlayerAdapter;
|
|
|
|
|
|
2016-02-19 13:05:04 -05:00
|
|
|
|
mnuNetPlayPlayer1.Text = ResourceHelper.GetMessage("PlayerNumber", "1") + " (" + ResourceHelper.GetEnumText(InteropEmu.NetPlayGetControllerType(0)) + ")";
|
|
|
|
|
mnuNetPlayPlayer2.Text = ResourceHelper.GetMessage("PlayerNumber", "2") + " (" + ResourceHelper.GetEnumText(InteropEmu.NetPlayGetControllerType(1)) + ")";
|
|
|
|
|
mnuNetPlayPlayer3.Text = ResourceHelper.GetMessage("PlayerNumber", "3") + " (" + ResourceHelper.GetEnumText(InteropEmu.NetPlayGetControllerType(2)) + ")";
|
|
|
|
|
mnuNetPlayPlayer4.Text = ResourceHelper.GetMessage("PlayerNumber", "4") + " (" + ResourceHelper.GetEnumText(InteropEmu.NetPlayGetControllerType(3)) + ")";
|
2017-11-19 23:08:23 -05:00
|
|
|
|
mnuNetPlayPlayer5.Text = ResourceHelper.GetMessage("ExpansionDevice") + " (" + ResourceHelper.GetEnumText(InteropEmu.GetExpansionDevice()) + ")";
|
2016-02-06 15:33:45 -05:00
|
|
|
|
|
|
|
|
|
mnuNetPlayPlayer1.Checked = (currentControllerPort == 0);
|
|
|
|
|
mnuNetPlayPlayer2.Checked = (currentControllerPort == 1);
|
|
|
|
|
mnuNetPlayPlayer3.Checked = (currentControllerPort == 2);
|
|
|
|
|
mnuNetPlayPlayer4.Checked = (currentControllerPort == 3);
|
2017-11-19 23:08:23 -05:00
|
|
|
|
mnuNetPlayPlayer5.Checked = (currentControllerPort == 4);
|
2016-02-06 15:33:45 -05:00
|
|
|
|
mnuNetPlaySpectator.Checked = (currentControllerPort == 0xFF);
|
|
|
|
|
|
|
|
|
|
mnuNetPlaySpectator.Enabled = true;
|
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
2016-02-19 13:05:04 -05:00
|
|
|
|
mnuStartServer.Text = InteropEmu.IsServerRunning() ? ResourceHelper.GetMessage("StopServer") : ResourceHelper.GetMessage("StartServer");
|
|
|
|
|
mnuConnect.Text = isNetPlayClient ? ResourceHelper.GetMessage("Disconnect") : ResourceHelper.GetMessage("ConnectToServer");
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
|
mnuCheats.Enabled = !isNetPlayClient;
|
|
|
|
|
mnuEmulationSpeed.Enabled = !isNetPlayClient;
|
|
|
|
|
mnuInput.Enabled = !isNetPlayClient;
|
|
|
|
|
mnuRegion.Enabled = !isNetPlayClient;
|
2015-08-23 20:24:24 -04:00
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
bool moviePlaying = InteropEmu.MoviePlaying();
|
|
|
|
|
bool movieRecording = InteropEmu.MovieRecording();
|
2015-07-05 22:23:44 -04:00
|
|
|
|
mnuPlayMovie.Enabled = !netPlay && !moviePlaying && !movieRecording;
|
2017-08-14 23:44:01 -04:00
|
|
|
|
mnuStopMovie.Enabled = running && !netPlay && (moviePlaying || movieRecording);
|
2017-12-22 15:08:58 -05:00
|
|
|
|
mnuRecordMovie.Enabled = running && !moviePlaying && !movieRecording && !isNetPlayClient;
|
2018-07-07 17:30:13 -04:00
|
|
|
|
mnuGameConfig.Enabled = !moviePlaying && !movieRecording;
|
2018-12-26 13:28:17 -05:00
|
|
|
|
mnuHistoryViewer.Enabled = running && InteropEmu.HistoryViewerEnabled();
|
2017-12-28 20:27:16 -05:00
|
|
|
|
|
2016-06-05 14:36:20 -04:00
|
|
|
|
bool waveRecording = InteropEmu.WaveIsRecording();
|
2017-08-14 23:44:01 -04:00
|
|
|
|
mnuWaveRecord.Enabled = running && !waveRecording;
|
|
|
|
|
mnuWaveStop.Enabled = running && waveRecording;
|
2016-06-05 14:36:20 -04:00
|
|
|
|
|
2016-12-29 21:19:13 -05:00
|
|
|
|
bool aviRecording = InteropEmu.AviIsRecording();
|
2017-08-14 23:44:01 -04:00
|
|
|
|
mnuAviRecord.Enabled = running && !aviRecording;
|
|
|
|
|
mnuAviStop.Enabled = running && aviRecording;
|
2017-04-30 01:16:33 -04:00
|
|
|
|
mnuVideoRecorder.Enabled = !_isNsfPlayerMode;
|
2016-12-29 21:19:13 -05:00
|
|
|
|
|
2015-12-26 17:11:00 -05:00
|
|
|
|
bool testRecording = InteropEmu.RomTestRecording();
|
|
|
|
|
mnuTestRun.Enabled = !netPlay && !moviePlaying && !movieRecording;
|
2017-08-14 23:44:01 -04:00
|
|
|
|
mnuTestStopRecording.Enabled = running && testRecording;
|
|
|
|
|
mnuTestRecordStart.Enabled = running && !isNetPlayClient && !moviePlaying && !movieRecording;
|
|
|
|
|
mnuTestRecordNow.Enabled = running && !moviePlaying && !movieRecording;
|
2015-12-27 09:13:52 -05:00
|
|
|
|
mnuTestRecordMovie.Enabled = !netPlay && !moviePlaying && !movieRecording;
|
|
|
|
|
mnuTestRecordTest.Enabled = !netPlay && !moviePlaying && !movieRecording;
|
|
|
|
|
mnuTestRecordFrom.Enabled = (mnuTestRecordStart.Enabled || mnuTestRecordNow.Enabled || mnuTestRecordMovie.Enabled || mnuTestRecordTest.Enabled);
|
2015-12-26 17:11:00 -05:00
|
|
|
|
|
2017-11-24 21:38:12 -05:00
|
|
|
|
bool tapeRecording = InteropEmu.IsRecordingTapeFile();
|
|
|
|
|
mnuTapeRecorder.Enabled = !isNetPlayClient;
|
|
|
|
|
mnuLoadTapeFile.Enabled = !isNetPlayClient;
|
|
|
|
|
mnuStartRecordTapeFile.Enabled = !tapeRecording && !isNetPlayClient;
|
|
|
|
|
mnuStopRecordTapeFile.Enabled = tapeRecording;
|
|
|
|
|
|
2020-01-23 19:32:09 -05:00
|
|
|
|
mnuDebugger.Enabled = running;
|
2018-03-25 14:06:55 -04:00
|
|
|
|
mnuApuViewer.Enabled = running;
|
|
|
|
|
mnuAssembler.Enabled = running;
|
|
|
|
|
mnuMemoryViewer.Enabled = running;
|
|
|
|
|
mnuEventViewer.Enabled = running;
|
|
|
|
|
mnuPpuViewer.Enabled = running;
|
|
|
|
|
mnuScriptWindow.Enabled = running;
|
2018-06-23 18:29:15 -04:00
|
|
|
|
mnuTextHooker.Enabled = running;
|
2018-03-25 14:06:55 -04:00
|
|
|
|
mnuTraceLogger.Enabled = running;
|
2019-01-19 20:00:48 -05:00
|
|
|
|
mnuProfiler.Enabled = running;
|
2019-01-29 17:21:23 -05:00
|
|
|
|
mnuWatchWindow.Enabled = running;
|
2018-03-10 09:58:24 -05:00
|
|
|
|
|
2019-01-19 18:56:08 -05:00
|
|
|
|
mnuPpuViewerCompact.Enabled = running;
|
|
|
|
|
mnuOpenNametableViewer.Enabled = running;
|
|
|
|
|
mnuOpenChrViewer.Enabled = running;
|
|
|
|
|
mnuOpenSpriteViewer.Enabled = running;
|
|
|
|
|
mnuOpenPaletteViewer.Enabled = running;
|
|
|
|
|
|
2018-07-06 00:10:10 -04:00
|
|
|
|
#if !HIDETESTMENU
|
|
|
|
|
//Keep this option hidden for now, until some remaining issues are fixed.
|
|
|
|
|
mnuDebugDualSystemSecondaryCpu.Visible = _isDualSystem;
|
|
|
|
|
sepDebugDualSystemSecondaryCpu.Visible = _isDualSystem;
|
|
|
|
|
#else
|
|
|
|
|
mnuDebugDualSystemSecondaryCpu.Visible = false;
|
|
|
|
|
sepDebugDualSystemSecondaryCpu.Visible = false;
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-06-19 23:51:15 -04:00
|
|
|
|
mnuInstallHdPack.Enabled = running;
|
2017-08-14 23:44:01 -04:00
|
|
|
|
mnuHdPackEditor.Enabled = !netPlay && running;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
2020-02-01 10:28:42 -05:00
|
|
|
|
mnuNetPlay.Enabled = !InteropEmu.IsNsf() && !runAheadEnabled;
|
|
|
|
|
|
|
|
|
|
bool enableMovies = (!running || !InteropEmu.IsNsf()) && !runAheadEnabled;
|
|
|
|
|
mnuMovies.Enabled = mnuPlayMovie.Enabled = mnuStopMovie.Enabled = mnuRecordMovie.Enabled = enableMovies;
|
2015-07-21 23:05:27 -04:00
|
|
|
|
|
|
|
|
|
mnuRegionAuto.Checked = ConfigManager.Config.Region == NesModel.Auto;
|
|
|
|
|
mnuRegionNtsc.Checked = ConfigManager.Config.Region == NesModel.NTSC;
|
|
|
|
|
mnuRegionPal.Checked = ConfigManager.Config.Region == NesModel.PAL;
|
2016-01-30 19:33:32 -05:00
|
|
|
|
mnuRegionDendy.Checked = ConfigManager.Config.Region == NesModel.Dendy;
|
2017-05-19 20:28:00 -04:00
|
|
|
|
|
2017-07-30 09:03:54 -04:00
|
|
|
|
bool autoInsertDisabled = !InteropEmu.FdsIsAutoInsertDiskEnabled();
|
2017-05-19 20:28:00 -04:00
|
|
|
|
mnuSelectDisk.Enabled = autoInsertDisabled;
|
2017-08-15 23:59:55 -04:00
|
|
|
|
|
2017-08-19 17:51:36 -04:00
|
|
|
|
bool isHdPackLoader = InteropEmu.IsHdPpu();
|
2017-08-15 23:59:55 -04:00
|
|
|
|
mnuNtscFilter.Enabled = !isHdPackLoader;
|
|
|
|
|
mnuNtscBisqwitQuarterFilter.Enabled = !isHdPackLoader;
|
|
|
|
|
mnuNtscBisqwitHalfFilter.Enabled = !isHdPackLoader;
|
|
|
|
|
mnuNtscBisqwitFullFilter.Enabled = !isHdPackLoader;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
|
|
|
|
} catch { }
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-22 16:54:45 -04:00
|
|
|
|
private void UpdateWindowTitle()
|
|
|
|
|
{
|
|
|
|
|
string title = "Mesen";
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(_currentGame)) {
|
|
|
|
|
title += " - " + _currentGame;
|
|
|
|
|
}
|
|
|
|
|
if(ConfigManager.Config.PreferenceInfo.DisplayTitleBarInfo) {
|
|
|
|
|
title += string.Format(" - {0}x{1} ({2:0.##}x, {3}) - {4}", ctrlRenderer.Width, ctrlRenderer.Height, ConfigManager.Config.VideoInfo.VideoScale, ResourceHelper.GetEnumText(ConfigManager.Config.VideoInfo.AspectRatio), ResourceHelper.GetEnumText(ConfigManager.Config.VideoInfo.VideoFilter));
|
|
|
|
|
}
|
|
|
|
|
this.Text = title;
|
|
|
|
|
}
|
2017-08-08 19:32:50 -04:00
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
private void StartEmuThread()
|
|
|
|
|
{
|
|
|
|
|
if(_emuThread == null) {
|
|
|
|
|
_emuThread = new Thread(() => {
|
|
|
|
|
try {
|
|
|
|
|
InteropEmu.Run();
|
|
|
|
|
_emuThread = null;
|
|
|
|
|
} catch(Exception ex) {
|
2016-02-19 13:05:04 -05:00
|
|
|
|
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
|
2017-05-26 07:27:38 -04:00
|
|
|
|
_emuThread = null;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
_emuThread.Start();
|
|
|
|
|
}
|
|
|
|
|
UpdateMenus();
|
|
|
|
|
}
|
2017-07-30 09:03:54 -04:00
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
private void StopEmu()
|
|
|
|
|
{
|
|
|
|
|
InteropEmu.Stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PauseEmu()
|
|
|
|
|
{
|
2017-08-14 23:44:01 -04:00
|
|
|
|
frmDebugger debugger = DebugWindowManager.GetDebugger();
|
|
|
|
|
if(debugger != null) {
|
2018-02-23 09:28:11 -05:00
|
|
|
|
debugger.TogglePause();
|
2015-07-01 23:17:14 -04:00
|
|
|
|
} else {
|
2017-06-28 23:18:51 -04:00
|
|
|
|
if(InteropEmu.IsPaused()) {
|
|
|
|
|
InteropEmu.Resume();
|
|
|
|
|
} else {
|
|
|
|
|
InteropEmu.Pause();
|
|
|
|
|
}
|
2016-06-25 20:46:54 -04:00
|
|
|
|
|
2017-06-28 23:18:51 -04:00
|
|
|
|
ctrlNsfPlayer.UpdateText();
|
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ResetEmu()
|
|
|
|
|
{
|
2017-08-12 18:58:38 -04:00
|
|
|
|
if(!ConfigManager.Config.PreferenceInfo.ConfirmExitResetPower || MesenMsgBox.Show("ConfirmReset", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) {
|
|
|
|
|
InteropEmu.Reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PowerCycleEmu()
|
|
|
|
|
{
|
|
|
|
|
if(!ConfigManager.Config.PreferenceInfo.ConfirmExitResetPower || MesenMsgBox.Show("ConfirmPowerCycle", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) {
|
|
|
|
|
InteropEmu.PowerCycle();
|
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
2016-02-07 13:05:32 -05:00
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
|
|
|
|
{
|
2015-12-27 09:13:52 -05:00
|
|
|
|
if(!this.menuStrip.Enabled) {
|
|
|
|
|
//Make sure we disable all shortcut keys while the bar is disabled (i.e when running tests)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-22 16:54:45 -04:00
|
|
|
|
if(this.HideMenuStrip && (keyData & Keys.Alt) == Keys.Alt) {
|
2016-02-07 13:05:32 -05:00
|
|
|
|
if(this.menuStrip.Visible && !this.menuStrip.ContainsFocus) {
|
|
|
|
|
this.menuStrip.Visible = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.menuStrip.Visible = true;
|
|
|
|
|
this.menuStrip.Focus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-14 01:05:49 -04:00
|
|
|
|
#if !HIDETESTMENU
|
2016-08-27 13:25:38 -04:00
|
|
|
|
if(keyData == Keys.Pause) {
|
|
|
|
|
if(InteropEmu.RomTestRecording()) {
|
|
|
|
|
InteropEmu.RomTestStop();
|
|
|
|
|
} else {
|
|
|
|
|
InteropEmu.RomTestRecord(ConfigManager.TestFolder + "\\" + InteropEmu.GetRomInfo().GetRomName() + ".mtp", true);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-14 01:05:49 -04:00
|
|
|
|
#endif
|
2016-08-27 13:25:38 -04:00
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
|
return base.ProcessCmdKey(ref msg, keyData);
|
|
|
|
|
}
|
2017-08-08 19:32:50 -04:00
|
|
|
|
|
2019-12-31 20:23:26 -05:00
|
|
|
|
private void SelectBiosPrompt(string fileName, int fileSize, RomFormat format)
|
2016-01-28 20:47:16 -05:00
|
|
|
|
{
|
2019-12-31 20:23:26 -05:00
|
|
|
|
if(BiosHelper.RequestBiosFile(fileName, fileSize, format)) {
|
|
|
|
|
LoadROM(_currentRomPath.Value, ConfigManager.Config.PreferenceInfo.AutoLoadIpsPatches);
|
2016-01-28 20:47:16 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-28 23:01:01 -05:00
|
|
|
|
|
|
|
|
|
private void frmMain_DragDrop(object sender, DragEventArgs e)
|
|
|
|
|
{
|
2017-09-08 19:09:15 -04:00
|
|
|
|
try {
|
|
|
|
|
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
|
if(File.Exists(files[0])) {
|
|
|
|
|
LoadFile(files[0]);
|
|
|
|
|
this.Activate();
|
|
|
|
|
} else {
|
|
|
|
|
InteropEmu.DisplayMessage("Error", "File not found: " + files[0]);
|
|
|
|
|
}
|
|
|
|
|
} catch(Exception ex) {
|
|
|
|
|
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
|
2016-01-28 23:01:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void frmMain_DragEnter(object sender, DragEventArgs e)
|
|
|
|
|
{
|
2017-09-08 19:09:15 -04:00
|
|
|
|
try {
|
2018-05-09 21:50:38 -04:00
|
|
|
|
if(e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop)) {
|
2017-09-08 19:09:15 -04:00
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
} else {
|
|
|
|
|
InteropEmu.DisplayMessage("Error", "Unsupported operation.");
|
|
|
|
|
}
|
|
|
|
|
} catch(Exception ex) {
|
|
|
|
|
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
|
2016-01-28 23:01:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-06 15:33:45 -05:00
|
|
|
|
|
2016-05-23 21:35:32 -04:00
|
|
|
|
private void ctrlRenderer_DoubleClick(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-01-24 17:31:29 -05:00
|
|
|
|
if(!CursorManager.NeedMouseIcon && !CursorManager.AllowMouseCapture && !DebugWindowManager.HasOpenedWindow) {
|
|
|
|
|
//Disable double clicking (used to switch to fullscreen mode) when using a mouse-controlled device (or when debugger is opened)
|
2018-04-15 10:52:38 -04:00
|
|
|
|
ToggleFullscreen();
|
2016-09-10 09:29:02 -04:00
|
|
|
|
}
|
2016-05-23 21:35:32 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-07 13:05:32 -05:00
|
|
|
|
private void panelRenderer_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-04-22 16:54:45 -04:00
|
|
|
|
if(this.HideMenuStrip) {
|
2016-05-23 21:35:32 -04:00
|
|
|
|
this.menuStrip.Visible = false;
|
|
|
|
|
}
|
2017-11-19 23:08:23 -05:00
|
|
|
|
CursorManager.CaptureMouse();
|
2016-05-23 21:35:32 -04:00
|
|
|
|
|
2016-02-07 13:05:32 -05:00
|
|
|
|
ctrlRenderer.Focus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctrlRenderer_Enter(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-04-22 16:54:45 -04:00
|
|
|
|
if(this.HideMenuStrip) {
|
2016-02-07 13:05:32 -05:00
|
|
|
|
this.menuStrip.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void menuStrip_VisibleChanged(object sender, EventArgs e)
|
2017-08-13 17:17:14 -04:00
|
|
|
|
{
|
|
|
|
|
this.UpdateRendererLocation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateRendererLocation()
|
2016-02-07 13:05:32 -05:00
|
|
|
|
{
|
2017-04-22 16:54:45 -04:00
|
|
|
|
if(this.HideMenuStrip) {
|
2016-12-22 23:08:34 -05:00
|
|
|
|
IntPtr handle = this.Handle;
|
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => {
|
2016-12-30 16:43:49 -05:00
|
|
|
|
int rendererTop = (panelRenderer.Height + (this.menuStrip.Visible ? menuStrip.Height : 0) - ctrlRenderer.Height) / 2;
|
|
|
|
|
this.ctrlRenderer.Top = rendererTop + (this.menuStrip.Visible ? -menuStrip.Height : 0);
|
2017-05-28 10:33:09 -04:00
|
|
|
|
this.ctrlRecentGames.Top = this.menuStrip.Visible ? -menuStrip.Height : 0;
|
2016-12-22 23:08:34 -05:00
|
|
|
|
}));
|
|
|
|
|
}
|
2016-02-07 13:05:32 -05:00
|
|
|
|
}
|
2016-02-07 16:13:48 -05:00
|
|
|
|
|
2018-12-26 11:24:08 -05:00
|
|
|
|
private void InitializeNsfMode(bool gameLoaded = false)
|
2016-06-25 20:46:54 -04:00
|
|
|
|
{
|
|
|
|
|
if(this.InvokeRequired) {
|
2016-08-29 22:34:13 -04:00
|
|
|
|
if(InteropEmu.IsNsf()) {
|
|
|
|
|
if(InteropEmu.IsConnected()) {
|
|
|
|
|
InteropEmu.Disconnect();
|
|
|
|
|
}
|
|
|
|
|
if(InteropEmu.IsServerRunning()) {
|
|
|
|
|
InteropEmu.StopServer();
|
|
|
|
|
}
|
2016-08-26 17:52:30 -04:00
|
|
|
|
}
|
2018-12-26 11:24:08 -05:00
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => this.InitializeNsfMode(gameLoaded)));
|
2016-06-25 20:46:54 -04:00
|
|
|
|
} else {
|
|
|
|
|
if(InteropEmu.IsNsf()) {
|
2017-11-29 23:24:26 -05:00
|
|
|
|
this.SetFullscreenState(false);
|
|
|
|
|
|
2016-06-26 17:13:10 -04:00
|
|
|
|
if(gameLoaded) {
|
|
|
|
|
//Force emulation speed to 100 when loading a NSF
|
|
|
|
|
SetEmulationSpeed(100);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-25 20:46:54 -04:00
|
|
|
|
if(!this._isNsfPlayerMode) {
|
2018-06-14 20:08:03 -04:00
|
|
|
|
this._nonNsfSize = this.WindowState != FormWindowState.Normal ? this.RestoreBounds.Size : this.Size;
|
2017-09-16 22:02:05 -04:00
|
|
|
|
this._nonNsfMinimumSize = this.MinimumSize;
|
|
|
|
|
this.Size = ctrlNsfPlayer.WindowMinimumSize;
|
|
|
|
|
this.MinimumSize = ctrlNsfPlayer.WindowMinimumSize;
|
2016-06-25 20:46:54 -04:00
|
|
|
|
}
|
|
|
|
|
this._isNsfPlayerMode = true;
|
|
|
|
|
this.ctrlNsfPlayer.UpdateText();
|
2017-08-12 00:24:37 -04:00
|
|
|
|
this.ctrlNsfPlayer.Visible = true;
|
2016-06-25 20:46:54 -04:00
|
|
|
|
this.ctrlNsfPlayer.Focus();
|
2017-07-30 09:03:54 -04:00
|
|
|
|
|
2017-08-13 11:00:43 -04:00
|
|
|
|
NsfHeader header = InteropEmu.NsfGetHeader();
|
|
|
|
|
if(header.HasSongName) {
|
|
|
|
|
_currentGame = header.GetSongName();
|
|
|
|
|
}
|
2016-07-29 18:24:24 -04:00
|
|
|
|
} else if(this._isNsfPlayerMode) {
|
2017-09-16 22:02:05 -04:00
|
|
|
|
this.MinimumSize = this._nonNsfMinimumSize;
|
2017-08-08 16:10:54 -04:00
|
|
|
|
this.Size = this._nonNsfSize.Value;
|
|
|
|
|
this._nonNsfSize = null;
|
2016-06-25 20:46:54 -04:00
|
|
|
|
this._isNsfPlayerMode = false;
|
|
|
|
|
this.ctrlNsfPlayer.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-09 12:49:17 -05:00
|
|
|
|
|
2017-06-08 20:38:48 -04:00
|
|
|
|
private void panelRenderer_MouseLeave(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CursorManager.OnMouseLeave();
|
|
|
|
|
}
|
2017-08-20 00:26:20 -04:00
|
|
|
|
|
|
|
|
|
private void ctrlRecentGames_OnRecentGameLoaded(Controls.RecentGameInfo gameInfo)
|
|
|
|
|
{
|
|
|
|
|
_currentRomPath = gameInfo.RomPath;
|
|
|
|
|
}
|
2017-12-24 17:45:02 -05:00
|
|
|
|
|
|
|
|
|
private void ctrlNsfPlayer_MouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(this.HideMenuStrip && !this.menuStrip.ContainsFocus) {
|
|
|
|
|
Point nsfPlayerPosition = this.ctrlNsfPlayer.PointToClient(((Control)sender).PointToScreen(e.Location));
|
|
|
|
|
this.menuStrip.Visible = nsfPlayerPosition.Y < 30;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-21 21:14:51 -04:00
|
|
|
|
|
|
|
|
|
private void mnu_DropDownOpened(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_inMenu++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnu_DropDownClosed(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() => {
|
|
|
|
|
Thread.Sleep(100);
|
|
|
|
|
this.BeginInvoke((Action)(() => {
|
|
|
|
|
_inMenu--;
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
}
|
|
|
|
|
}
|