From 100c08c2e338b467a0da48fba47424e665eb7dc1 Mon Sep 17 00:00:00 2001 From: Souryo Date: Sun, 26 Jun 2016 10:43:52 -0400 Subject: [PATCH] Archives: Improved recent files list (now lists the file selected in the archive and relods it automatically) + Added progress bar when extraction files, since large archives can take a while to extract --- GUI.NET/Config/Configuration.cs | 21 +++- GUI.NET/Controls/ctrlLoadingRom.Designer.cs | 96 ++++++++++++++++ GUI.NET/Controls/ctrlLoadingRom.cs | 20 ++++ GUI.NET/Controls/ctrlLoadingRom.resx | 120 ++++++++++++++++++++ GUI.NET/Dependencies/resources.fr.xml | 3 + GUI.NET/Dependencies/resources.ja.xml | 3 + GUI.NET/Forms/Cheats/frmCheat.cs | 4 +- GUI.NET/Forms/frmMain.Designer.cs | 77 +++++++------ GUI.NET/Forms/frmMain.cs | 60 +++++++--- GUI.NET/Forms/frmSelectRom.cs | 28 ++++- GUI.NET/GUI.NET.csproj | 9 ++ InteropDLL/ConsoleWrapper.cpp | 4 + 12 files changed, 381 insertions(+), 64 deletions(-) create mode 100644 GUI.NET/Controls/ctrlLoadingRom.Designer.cs create mode 100644 GUI.NET/Controls/ctrlLoadingRom.cs create mode 100644 GUI.NET/Controls/ctrlLoadingRom.resx diff --git a/GUI.NET/Config/Configuration.cs b/GUI.NET/Config/Configuration.cs index 2d3181b3..ee7d0902 100644 --- a/GUI.NET/Config/Configuration.cs +++ b/GUI.NET/Config/Configuration.cs @@ -18,7 +18,7 @@ namespace Mesen.GUI.Config public VideoInfo VideoInfo; public InputInfo InputInfo; public EmulationInfo EmulationInfo; - public List RecentFiles; + public List RecentFiles; public List VsConfig; public List Cheats; public bool ShowOnlyCheatsForCurrentGame; @@ -37,7 +37,7 @@ namespace Mesen.GUI.Config VideoInfo = new VideoInfo(); PreferenceInfo = new PreferenceInfo(); EmulationInfo = new EmulationInfo(); - RecentFiles = new List(); + RecentFiles = new List(); InputInfo = new InputInfo(); Cheats = new List(); VsConfig = new List(); @@ -60,12 +60,15 @@ namespace Mesen.GUI.Config InputInfo.InitializeDefaults(); } - public void AddRecentFile(string filepath) + public void AddRecentFile(string filepath, string romName, int archiveFileIndex) { - if(RecentFiles.Contains(filepath)) { - RecentFiles.Remove(filepath); + RecentItem existingItem = RecentFiles.Where((item) => item.Path == filepath && item.ArchiveFileIndex == archiveFileIndex).FirstOrDefault(); + if(existingItem != null) { + RecentFiles.Remove(existingItem); } - RecentFiles.Insert(0, filepath); + RecentItem recentItem = new RecentItem { RomName = romName, Path = filepath, ArchiveFileIndex = archiveFileIndex }; + + RecentFiles.Insert(0, recentItem); if(RecentFiles.Count > Configuration.MaxRecentFiles) { RecentFiles.RemoveAt(Configuration.MaxRecentFiles); } @@ -108,4 +111,10 @@ namespace Mesen.GUI.Config } } + public class RecentItem + { + public string Path; + public string RomName; + public int ArchiveFileIndex; + } } diff --git a/GUI.NET/Controls/ctrlLoadingRom.Designer.cs b/GUI.NET/Controls/ctrlLoadingRom.Designer.cs new file mode 100644 index 00000000..f3178b5e --- /dev/null +++ b/GUI.NET/Controls/ctrlLoadingRom.Designer.cs @@ -0,0 +1,96 @@ +namespace Mesen.GUI.Controls +{ + partial class ctrlLoadingRom + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.pbLoading = new System.Windows.Forms.ProgressBar(); + this.lblExtractingFile = new System.Windows.Forms.Label(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 200F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Controls.Add(this.pbLoading, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.lblExtractingFile, 0, 2); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(261, 107); + this.tableLayoutPanel1.TabIndex = 0; + // + // pbLoading + // + this.pbLoading.Dock = System.Windows.Forms.DockStyle.Fill; + this.pbLoading.Location = new System.Drawing.Point(33, 35); + this.pbLoading.Name = "pbLoading"; + this.pbLoading.Size = new System.Drawing.Size(194, 23); + this.pbLoading.Style = System.Windows.Forms.ProgressBarStyle.Marquee; + this.pbLoading.TabIndex = 0; + // + // lblExtractingFile + // + this.lblExtractingFile.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.lblExtractingFile.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.lblExtractingFile, 3); + this.lblExtractingFile.ForeColor = System.Drawing.Color.White; + this.lblExtractingFile.Location = new System.Drawing.Point(61, 61); + this.lblExtractingFile.Name = "lblExtractingFile"; + this.lblExtractingFile.Size = new System.Drawing.Size(138, 13); + this.lblExtractingFile.TabIndex = 1; + this.lblExtractingFile.Text = "Extracting file, please wait..."; + // + // ctrlLoadingRom + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; + this.Controls.Add(this.tableLayoutPanel1); + this.Name = "ctrlLoadingRom"; + this.Size = new System.Drawing.Size(261, 107); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.ProgressBar pbLoading; + private System.Windows.Forms.Label lblExtractingFile; + } +} diff --git a/GUI.NET/Controls/ctrlLoadingRom.cs b/GUI.NET/Controls/ctrlLoadingRom.cs new file mode 100644 index 00000000..7efe3c25 --- /dev/null +++ b/GUI.NET/Controls/ctrlLoadingRom.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Mesen.GUI.Controls +{ + public partial class ctrlLoadingRom : UserControl + { + public ctrlLoadingRom() + { + InitializeComponent(); + } + } +} diff --git a/GUI.NET/Controls/ctrlLoadingRom.resx b/GUI.NET/Controls/ctrlLoadingRom.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/GUI.NET/Controls/ctrlLoadingRom.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GUI.NET/Dependencies/resources.fr.xml b/GUI.NET/Dependencies/resources.fr.xml index 47f2fe6e..9ed1f3b5 100644 --- a/GUI.NET/Dependencies/resources.fr.xml +++ b/GUI.NET/Dependencies/resources.fr.xml @@ -88,6 +88,9 @@ Recherche de mises-à-jour À propos de... + + Extraction en cours, veuillez patienter... + Titre Artiste diff --git a/GUI.NET/Dependencies/resources.ja.xml b/GUI.NET/Dependencies/resources.ja.xml index a0f3e24d..57a8eef8 100644 --- a/GUI.NET/Dependencies/resources.ja.xml +++ b/GUI.NET/Dependencies/resources.ja.xml @@ -88,6 +88,9 @@ アップデートの確認 Mesenとは + + ファイルを抽出中です。しばらく待ってください。 + タイトル 作者 diff --git a/GUI.NET/Forms/Cheats/frmCheat.cs b/GUI.NET/Forms/Cheats/frmCheat.cs index 7d3c8321..ed041abd 100644 --- a/GUI.NET/Forms/Cheats/frmCheat.cs +++ b/GUI.NET/Forms/Cheats/frmCheat.cs @@ -73,8 +73,8 @@ namespace Mesen.GUI.Forms.Cheats private void LoadGame(string romPath) { - int archiveFileIndex; - if(frmSelectRom.SelectRom(romPath, out archiveFileIndex)) { + int archiveFileIndex = -1; + if(frmSelectRom.SelectRom(romPath, ref archiveFileIndex)) { RomInfo romInfo = InteropEmu.GetRomInfo(romPath, archiveFileIndex); _gameCrc = romInfo.GetCrcString(); if(_gameCrc != null) { diff --git a/GUI.NET/Forms/frmMain.Designer.cs b/GUI.NET/Forms/frmMain.Designer.cs index f8cdead8..5483d366 100644 --- a/GUI.NET/Forms/frmMain.Designer.cs +++ b/GUI.NET/Forms/frmMain.Designer.cs @@ -33,8 +33,8 @@ namespace Mesen.GUI.Forms this.components = new System.ComponentModel.Container(); this.menuTimer = new System.Windows.Forms.Timer(this.components); this.panelRenderer = new System.Windows.Forms.Panel(); - this.ctrlRenderer = new Mesen.GUI.Controls.ctrlRenderer(); this.ctrlNsfPlayer = new Mesen.GUI.Controls.ctrlNsfPlayer(); + this.ctrlRenderer = new Mesen.GUI.Controls.ctrlRenderer(); this.menuStrip = new System.Windows.Forms.MenuStrip(); this.mnuFile = new System.Windows.Forms.ToolStripMenuItem(); this.mnuOpen = new System.Windows.Forms.ToolStripMenuItem(); @@ -158,6 +158,7 @@ namespace Mesen.GUI.Forms this.mnuCheckForUpdates = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator(); this.mnuAbout = new System.Windows.Forms.ToolStripMenuItem(); + this.ctrlLoading = new Mesen.GUI.Controls.ctrlLoadingRom(); this.panelRenderer.SuspendLayout(); this.menuStrip.SuspendLayout(); this.SuspendLayout(); @@ -169,17 +170,28 @@ namespace Mesen.GUI.Forms // panelRenderer // this.panelRenderer.BackColor = System.Drawing.Color.Black; + this.panelRenderer.Controls.Add(this.ctrlLoading); this.panelRenderer.Controls.Add(this.ctrlNsfPlayer); this.panelRenderer.Controls.Add(this.ctrlRenderer); this.panelRenderer.Dock = System.Windows.Forms.DockStyle.Fill; this.panelRenderer.Location = new System.Drawing.Point(0, 24); this.panelRenderer.Name = "panelRenderer"; - this.panelRenderer.Size = new System.Drawing.Size(304, 218); + this.panelRenderer.Size = new System.Drawing.Size(360, 239); this.panelRenderer.TabIndex = 2; this.panelRenderer.Click += new System.EventHandler(this.panelRenderer_Click); this.panelRenderer.DoubleClick += new System.EventHandler(this.ctrlRenderer_DoubleClick); this.panelRenderer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ctrlRenderer_MouseMove); // + // ctrlNsfPlayer + // + this.ctrlNsfPlayer.BackColor = System.Drawing.Color.Black; + this.ctrlNsfPlayer.Dock = System.Windows.Forms.DockStyle.Fill; + this.ctrlNsfPlayer.Location = new System.Drawing.Point(0, 0); + this.ctrlNsfPlayer.Name = "ctrlNsfPlayer"; + this.ctrlNsfPlayer.Size = new System.Drawing.Size(360, 239); + this.ctrlNsfPlayer.TabIndex = 2; + this.ctrlNsfPlayer.Visible = false; + // // ctrlRenderer // this.ctrlRenderer.BackColor = System.Drawing.Color.Black; @@ -193,15 +205,6 @@ namespace Mesen.GUI.Forms this.ctrlRenderer.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ctrlRenderer_MouseClick); this.ctrlRenderer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ctrlRenderer_MouseMove); // - // ctrlNsfPlayer - // - this.ctrlNsfPlayer.Dock = System.Windows.Forms.DockStyle.Fill; - this.ctrlNsfPlayer.Location = new System.Drawing.Point(0, 0); - this.ctrlNsfPlayer.Name = "ctrlNsfPlayer"; - this.ctrlNsfPlayer.Size = new System.Drawing.Size(304, 218); - this.ctrlNsfPlayer.TabIndex = 2; - this.ctrlNsfPlayer.Visible = false; - // // menuStrip // this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -212,7 +215,7 @@ namespace Mesen.GUI.Forms this.mnuHelp}); this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; - this.menuStrip.Size = new System.Drawing.Size(304, 24); + this.menuStrip.Size = new System.Drawing.Size(360, 24); this.menuStrip.TabIndex = 0; this.menuStrip.Text = "menuStrip1"; this.menuStrip.VisibleChanged += new System.EventHandler(this.menuStrip_VisibleChanged); @@ -238,50 +241,50 @@ namespace Mesen.GUI.Forms this.mnuOpen.Image = global::Mesen.GUI.Properties.Resources.FolderOpen; this.mnuOpen.Name = "mnuOpen"; this.mnuOpen.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); - this.mnuOpen.Size = new System.Drawing.Size(146, 22); + this.mnuOpen.Size = new System.Drawing.Size(152, 22); this.mnuOpen.Text = "Open"; this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click); // // toolStripMenuItem4 // this.toolStripMenuItem4.Name = "toolStripMenuItem4"; - this.toolStripMenuItem4.Size = new System.Drawing.Size(143, 6); + this.toolStripMenuItem4.Size = new System.Drawing.Size(149, 6); // // mnuSaveState // this.mnuSaveState.Name = "mnuSaveState"; - this.mnuSaveState.Size = new System.Drawing.Size(146, 22); + this.mnuSaveState.Size = new System.Drawing.Size(152, 22); this.mnuSaveState.Text = "Save State"; this.mnuSaveState.DropDownOpening += new System.EventHandler(this.mnuSaveState_DropDownOpening); // // mnuLoadState // this.mnuLoadState.Name = "mnuLoadState"; - this.mnuLoadState.Size = new System.Drawing.Size(146, 22); + this.mnuLoadState.Size = new System.Drawing.Size(152, 22); this.mnuLoadState.Text = "Load State"; this.mnuLoadState.DropDownOpening += new System.EventHandler(this.mnuLoadState_DropDownOpening); // // toolStripMenuItem7 // this.toolStripMenuItem7.Name = "toolStripMenuItem7"; - this.toolStripMenuItem7.Size = new System.Drawing.Size(143, 6); + this.toolStripMenuItem7.Size = new System.Drawing.Size(149, 6); // // mnuRecentFiles // this.mnuRecentFiles.Name = "mnuRecentFiles"; - this.mnuRecentFiles.Size = new System.Drawing.Size(146, 22); + this.mnuRecentFiles.Size = new System.Drawing.Size(152, 22); this.mnuRecentFiles.Text = "Recent Files"; // // toolStripMenuItem6 // this.toolStripMenuItem6.Name = "toolStripMenuItem6"; - this.toolStripMenuItem6.Size = new System.Drawing.Size(143, 6); + this.toolStripMenuItem6.Size = new System.Drawing.Size(149, 6); // // mnuExit // this.mnuExit.Image = global::Mesen.GUI.Properties.Resources.Exit; this.mnuExit.Name = "mnuExit"; - this.mnuExit.Size = new System.Drawing.Size(146, 22); + this.mnuExit.Size = new System.Drawing.Size(152, 22); this.mnuExit.Text = "Exit"; this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click); // @@ -426,7 +429,7 @@ namespace Mesen.GUI.Forms this.mnuShowFPS}); this.mnuEmulationSpeed.Image = global::Mesen.GUI.Properties.Resources.Speed; this.mnuEmulationSpeed.Name = "mnuEmulationSpeed"; - this.mnuEmulationSpeed.Size = new System.Drawing.Size(135, 22); + this.mnuEmulationSpeed.Size = new System.Drawing.Size(152, 22); this.mnuEmulationSpeed.Text = "Speed"; // // mnuEmuSpeedNormal @@ -527,7 +530,7 @@ namespace Mesen.GUI.Forms this.mnuFullscreen}); this.mnuVideoScale.Image = global::Mesen.GUI.Properties.Resources.Fullscreen; this.mnuVideoScale.Name = "mnuVideoScale"; - this.mnuVideoScale.Size = new System.Drawing.Size(135, 22); + this.mnuVideoScale.Size = new System.Drawing.Size(152, 22); this.mnuVideoScale.Text = "Video Size"; // // mnuScale1x @@ -631,7 +634,7 @@ namespace Mesen.GUI.Forms this.toolStripMenuItem19, this.mnuBilinearInterpolation}); this.mnuVideoFilter.Name = "mnuVideoFilter"; - this.mnuVideoFilter.Size = new System.Drawing.Size(135, 22); + this.mnuVideoFilter.Size = new System.Drawing.Size(152, 22); this.mnuVideoFilter.Text = "Video Filter"; // // mnuNoneFilter @@ -788,7 +791,7 @@ namespace Mesen.GUI.Forms this.mnuRegionDendy}); this.mnuRegion.Image = global::Mesen.GUI.Properties.Resources.Globe; this.mnuRegion.Name = "mnuRegion"; - this.mnuRegion.Size = new System.Drawing.Size(135, 22); + this.mnuRegion.Size = new System.Drawing.Size(152, 22); this.mnuRegion.Text = "Region"; // // mnuRegionAuto @@ -822,13 +825,13 @@ namespace Mesen.GUI.Forms // toolStripMenuItem10 // this.toolStripMenuItem10.Name = "toolStripMenuItem10"; - this.toolStripMenuItem10.Size = new System.Drawing.Size(132, 6); + this.toolStripMenuItem10.Size = new System.Drawing.Size(149, 6); // // mnuAudioConfig // this.mnuAudioConfig.Image = global::Mesen.GUI.Properties.Resources.Audio; this.mnuAudioConfig.Name = "mnuAudioConfig"; - this.mnuAudioConfig.Size = new System.Drawing.Size(135, 22); + this.mnuAudioConfig.Size = new System.Drawing.Size(152, 22); this.mnuAudioConfig.Text = "Audio"; this.mnuAudioConfig.Click += new System.EventHandler(this.mnuAudioConfig_Click); // @@ -836,7 +839,7 @@ namespace Mesen.GUI.Forms // this.mnuInput.Image = global::Mesen.GUI.Properties.Resources.Controller; this.mnuInput.Name = "mnuInput"; - this.mnuInput.Size = new System.Drawing.Size(135, 22); + this.mnuInput.Size = new System.Drawing.Size(152, 22); this.mnuInput.Text = "Input"; this.mnuInput.Click += new System.EventHandler(this.mnuInput_Click); // @@ -844,7 +847,7 @@ namespace Mesen.GUI.Forms // this.mnuVideoConfig.Image = global::Mesen.GUI.Properties.Resources.Video; this.mnuVideoConfig.Name = "mnuVideoConfig"; - this.mnuVideoConfig.Size = new System.Drawing.Size(135, 22); + this.mnuVideoConfig.Size = new System.Drawing.Size(152, 22); this.mnuVideoConfig.Text = "Video"; this.mnuVideoConfig.Click += new System.EventHandler(this.mnuVideoConfig_Click); // @@ -852,20 +855,20 @@ namespace Mesen.GUI.Forms // this.mnuEmulationConfig.Image = global::Mesen.GUI.Properties.Resources.DipSwitches; this.mnuEmulationConfig.Name = "mnuEmulationConfig"; - this.mnuEmulationConfig.Size = new System.Drawing.Size(135, 22); + this.mnuEmulationConfig.Size = new System.Drawing.Size(152, 22); this.mnuEmulationConfig.Text = "Emulation"; this.mnuEmulationConfig.Click += new System.EventHandler(this.mnuEmulationConfig_Click); // // toolStripMenuItem11 // this.toolStripMenuItem11.Name = "toolStripMenuItem11"; - this.toolStripMenuItem11.Size = new System.Drawing.Size(132, 6); + this.toolStripMenuItem11.Size = new System.Drawing.Size(149, 6); // // mnuPreferences // this.mnuPreferences.Image = global::Mesen.GUI.Properties.Resources.Cog; this.mnuPreferences.Name = "mnuPreferences"; - this.mnuPreferences.Size = new System.Drawing.Size(135, 22); + this.mnuPreferences.Size = new System.Drawing.Size(152, 22); this.mnuPreferences.Text = "Preferences"; this.mnuPreferences.Click += new System.EventHandler(this.mnuPreferences_Click); // @@ -1209,13 +1212,22 @@ namespace Mesen.GUI.Forms this.mnuAbout.Text = "About"; this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click); // + // ctrlLoading + // + this.ctrlLoading.Dock = System.Windows.Forms.DockStyle.Fill; + this.ctrlLoading.Location = new System.Drawing.Point(0, 0); + this.ctrlLoading.Name = "ctrlLoading"; + this.ctrlLoading.Size = new System.Drawing.Size(360, 239); + this.ctrlLoading.TabIndex = 4; + this.ctrlLoading.Visible = false; + // // frmMain // this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Maroon; - this.ClientSize = new System.Drawing.Size(304, 242); + this.ClientSize = new System.Drawing.Size(360, 263); this.Controls.Add(this.panelRenderer); this.Controls.Add(this.menuStrip); this.MainMenuStrip = this.menuStrip; @@ -1362,6 +1374,7 @@ namespace Mesen.GUI.Forms private System.Windows.Forms.ToolStripMenuItem mnuLogWindow; private System.Windows.Forms.ToolStripMenuItem mnuEmulationConfig; private Controls.ctrlNsfPlayer ctrlNsfPlayer; + private Controls.ctrlLoadingRom ctrlLoading; } } diff --git a/GUI.NET/Forms/frmMain.cs b/GUI.NET/Forms/frmMain.cs index 9766f139..7761862e 100644 --- a/GUI.NET/Forms/frmMain.cs +++ b/GUI.NET/Forms/frmMain.cs @@ -34,6 +34,8 @@ namespace Mesen.GUI.Forms private double _regularScale = ConfigManager.Config.VideoInfo.VideoScale; private bool _needScaleUpdate = false; private bool _isNsfPlayerMode = false; + private object _loadRomLock = new object(); + private int _romLoadCounter = 0; public frmMain(string[] args) { @@ -141,8 +143,8 @@ namespace Mesen.GUI.Forms void InitializeEmu() { InteropEmu.InitializeEmu(ConfigManager.HomeFolder, this.Handle, this.ctrlRenderer.Handle); - foreach(string romPath in ConfigManager.Config.RecentFiles) { - InteropEmu.AddKnowGameFolder(Path.GetDirectoryName(romPath).ToLowerInvariant()); + foreach(RecentItem recentItem in ConfigManager.Config.RecentFiles) { + InteropEmu.AddKnowGameFolder(Path.GetDirectoryName(recentItem.Path).ToLowerInvariant()); } ConfigManager.Config.ApplyConfig(); @@ -379,7 +381,7 @@ namespace Mesen.GUI.Forms OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = ResourceHelper.GetMessage("FilterRomIps"); if(ConfigManager.Config.RecentFiles.Count > 0) { - ofd.InitialDirectory = Path.GetDirectoryName(ConfigManager.Config.RecentFiles[0]); + ofd.InitialDirectory = Path.GetDirectoryName(ConfigManager.Config.RecentFiles[0].Path); } if(ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { LoadFile(ofd.FileName); @@ -420,7 +422,7 @@ namespace Mesen.GUI.Forms OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = ResourceHelper.GetMessage("FilterRom"); if(ConfigManager.Config.RecentFiles.Count > 0) { - ofd.InitialDirectory = Path.GetDirectoryName(ConfigManager.Config.RecentFiles[0]); + ofd.InitialDirectory = Path.GetDirectoryName(ConfigManager.Config.RecentFiles[0].Path); } if(ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { LoadROM(ofd.FileName); @@ -433,21 +435,41 @@ namespace Mesen.GUI.Forms } } - private void LoadROM(string filename, bool autoLoadIps = false) + private void LoadROM(string filename, bool autoLoadIps = false, int archiveFileIndex = -1) { _romToLoad = filename; if(File.Exists(filename)) { - ConfigManager.Config.AddRecentFile(filename); - - int archiveFileIndex; - if(frmSelectRom.SelectRom(filename, out archiveFileIndex)) { - InteropEmu.LoadROM(filename, archiveFileIndex); - UpdateRecentFiles(); - - string ipsFile = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename)) + ".ips"; - if(File.Exists(ipsFile)) { - InteropEmu.ApplyIpsPatch(ipsFile); + string romName; + if(frmSelectRom.SelectRom(filename, ref archiveFileIndex, out romName)) { + if(archiveFileIndex >= 0) { + Interlocked.Increment(ref _romLoadCounter); + ctrlNsfPlayer.Visible = false; + ctrlLoading.Visible = true; } + + Task loadRomTask = new Task(() => { + lock(_loadRomLock) { + InteropEmu.LoadROM(filename, archiveFileIndex); + } + }); + + loadRomTask.ContinueWith((Task prevTask) => { + this.BeginInvoke((MethodInvoker)(() => { + if(archiveFileIndex >= 0) { + Interlocked.Decrement(ref _romLoadCounter); + } + + string ipsFile = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename)) + ".ips"; + if(File.Exists(ipsFile)) { + InteropEmu.ApplyIpsPatch(ipsFile); + } + + ConfigManager.Config.AddRecentFile(filename, romName, archiveFileIndex); + UpdateRecentFiles(); + })); + }); + + loadRomTask.Start(); } } else { MesenMsgBox.Show("FileNotFound", MessageBoxButtons.OK, MessageBoxIcon.Error, filename); @@ -479,6 +501,8 @@ namespace Mesen.GUI.Forms if(this.InvokeRequired) { this.BeginInvoke((MethodInvoker)(() => this.UpdateMenus())); } else { + ctrlLoading.Visible = (_romLoadCounter > 0); + UpdateFocusFlag(); if(string.IsNullOrWhiteSpace(_currentGame)) { @@ -571,11 +595,11 @@ namespace Mesen.GUI.Forms private void UpdateRecentFiles() { mnuRecentFiles.DropDownItems.Clear(); - foreach(string filepath in ConfigManager.Config.RecentFiles) { + foreach(RecentItem recentItem in ConfigManager.Config.RecentFiles) { ToolStripMenuItem tsmi = new ToolStripMenuItem(); - tsmi.Text = Path.GetFileName(filepath); + tsmi.Text = recentItem.RomName; tsmi.Click += (object sender, EventArgs args) => { - LoadROM(filepath); + LoadROM(recentItem.Path, false, recentItem.ArchiveFileIndex); }; mnuRecentFiles.DropDownItems.Add(tsmi); } diff --git a/GUI.NET/Forms/frmSelectRom.cs b/GUI.NET/Forms/frmSelectRom.cs index 2c8430da..8f2b89d4 100644 --- a/GUI.NET/Forms/frmSelectRom.cs +++ b/GUI.NET/Forms/frmSelectRom.cs @@ -72,18 +72,34 @@ namespace Mesen.GUI.Forms txtSearch.Focus(); } - public static bool SelectRom(string filename, out int archiveFileIndex) + public static bool SelectRom(string filename, ref int archiveFileIndex) { - archiveFileIndex = -1; + string romName; + return SelectRom(filename, ref archiveFileIndex, out romName); + } + + public static bool SelectRom(string filename, ref int archiveFileIndex, out string romName) + { + romName = ""; List archiveRomList = InteropEmu.GetArchiveRomList(filename); if(archiveRomList.Count > 1) { - frmSelectRom frm = new frmSelectRom(archiveRomList); - if(frm.ShowDialog(null, Application.OpenForms[0]) == DialogResult.OK) { - archiveFileIndex = frm.SelectedIndex; + if(archiveFileIndex >= 0 && archiveFileIndex < archiveRomList.Count) { + romName = System.IO.Path.GetFileName(archiveRomList[archiveFileIndex]); + return true; } else { - return false; + frmSelectRom frm = new frmSelectRom(archiveRomList); + if(frm.ShowDialog(null, Application.OpenForms[0]) == DialogResult.OK) { + archiveFileIndex = frm.SelectedIndex; + romName = System.IO.Path.GetFileName(frm.lstRoms.SelectedItem.ToString()); + } else { + return false; + } } + } else if(archiveRomList.Count == 1) { + romName = System.IO.Path.GetFileName(archiveRomList[0]); + } else { + romName = System.IO.Path.GetFileName(filename); } return true; diff --git a/GUI.NET/GUI.NET.csproj b/GUI.NET/GUI.NET.csproj index f8988072..1b6c1543 100644 --- a/GUI.NET/GUI.NET.csproj +++ b/GUI.NET/GUI.NET.csproj @@ -227,6 +227,12 @@ ctrlHorizontalTrackbar.cs + + UserControl + + + ctrlLoadingRom.cs + UserControl @@ -514,6 +520,9 @@ ctrlHorizontalTrackbar.cs + + ctrlLoadingRom.cs + ctrlNsfPlayer.cs diff --git a/InteropDLL/ConsoleWrapper.cpp b/InteropDLL/ConsoleWrapper.cpp index c2a52e1c..75a83f98 100644 --- a/InteropDLL/ConsoleWrapper.cpp +++ b/InteropDLL/ConsoleWrapper.cpp @@ -144,6 +144,10 @@ namespace InteropEmu { _returnString = romData.RomName; romInfo.RomName = _returnString.c_str(); romInfo.Crc32 = romData.Crc32; + } else { + _returnString = ""; + romInfo.RomName = _returnString.c_str(); + romInfo.Crc32 = 0; } } }