diff options
author | Elie Rodrigue <elie.rodrigue@nubik.ca> | 2017-05-10 03:44:25 +0300 |
---|---|---|
committer | Elie Rodrigue <elie.rodrigue@nubik.ca> | 2017-05-10 03:44:25 +0300 |
commit | 89a3f8808f4f3e28b7b64068be1baf0af81ac0b8 (patch) | |
tree | 46677a20eb8c309524a4a0e64073c41d375eb7be | |
parent | 737a28334e7b0461c39cda6e83d2cebef9b622a9 (diff) |
GameManager + GameSelecter + GameDetails completed
-rw-r--r-- | AboutBox.cs | 200 | ||||
-rw-r--r-- | Apps/NesMiniApplication.cs | 22 | ||||
-rw-r--r-- | FoldersManagerForm.cs | 14 | ||||
-rw-r--r-- | MainForm.Designer.cs | 66 | ||||
-rw-r--r-- | MainForm.cs | 155 | ||||
-rw-r--r-- | MainForm.resx | 104 | ||||
-rw-r--r-- | Manager/EventBus.cs | 34 | ||||
-rw-r--r-- | Manager/GameManager.cs | 59 | ||||
-rw-r--r-- | SearchForm.cs | 77 | ||||
-rw-r--r-- | UI/Components/GameDetail.cs | 23 | ||||
-rw-r--r-- | UI/Components/GameSelecter.Designer.cs | 57 | ||||
-rw-r--r-- | UI/Components/GameSelecter.resx | 3 | ||||
-rw-r--r-- | WorkerForm.cs | 57 | ||||
-rw-r--r-- | hakchi_gui.csproj | 1 |
14 files changed, 438 insertions, 434 deletions
diff --git a/AboutBox.cs b/AboutBox.cs index 968788be..08041fed 100644 --- a/AboutBox.cs +++ b/AboutBox.cs @@ -1,100 +1,100 @@ -using System;
-using System.Reflection;
-using System.Windows.Forms;
-
-namespace com.clusterrr.hakchi_gui
-{
- partial class AboutBox : Form
- {
- public AboutBox()
- {
- InitializeComponent();
- this.Text = String.Format("About {0}", AssemblyTitle);
- this.labelProductName.Text = AssemblyProduct;
- this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
- this.labelCopyright.Text = AssemblyCopyright;
- this.labelCompanyName.Text = AssemblyCompany;
- this.textBoxDescription.Text = AssemblyDescription;
- }
-
- #region Assembly Attribute Accessors
-
- public string AssemblyTitle
- {
- get
- {
- object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
- if (attributes.Length > 0)
- {
- AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
- if (titleAttribute.Title != "")
- {
- return titleAttribute.Title;
- }
- }
- return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
- }
- }
-
- public string AssemblyVersion
- {
- get
- {
- return Assembly.GetExecutingAssembly().GetName().Version.ToString();
- }
- }
-
- public string AssemblyDescription
- {
- get
- {
- object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
- if (attributes.Length == 0)
- {
- return "";
- }
- return ((AssemblyDescriptionAttribute)attributes[0]).Description;
- }
- }
-
- public string AssemblyProduct
- {
- get
- {
- object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
- if (attributes.Length == 0)
- {
- return "";
- }
- return ((AssemblyProductAttribute)attributes[0]).Product;
- }
- }
-
- public string AssemblyCopyright
- {
- get
- {
- object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
- if (attributes.Length == 0)
- {
- return "";
- }
- return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
- }
- }
-
- public string AssemblyCompany
- {
- get
- {
- object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
- if (attributes.Length == 0)
- {
- return "";
- }
- return ((AssemblyCompanyAttribute)attributes[0]).Company;
- }
- }
- #endregion
- }
-}
+using System; +using System.Reflection; +using System.Windows.Forms; + +namespace com.clusterrr.hakchi_gui +{ + partial class AboutBox : Form + { + public AboutBox() + { + InitializeComponent(); + this.Text = String.Format("About {0}", AssemblyTitle); + this.labelProductName.Text = AssemblyProduct; + this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion); + this.labelCopyright.Text = AssemblyCopyright; + this.labelCompanyName.Text = AssemblyCompany; + this.textBoxDescription.Text = AssemblyDescription; + } + + #region Assembly Attribute Accessors + + public string AssemblyTitle + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); + if (attributes.Length > 0) + { + AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; + if (titleAttribute.Title != "") + { + return titleAttribute.Title; + } + } + return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); + } + } + + public string AssemblyVersion + { + get + { + return Assembly.GetExecutingAssembly().GetName().Version.ToString(); + } + } + + public string AssemblyDescription + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyDescriptionAttribute)attributes[0]).Description; + } + } + + public string AssemblyProduct + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyProductAttribute)attributes[0]).Product; + } + } + + public string AssemblyCopyright + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + } + } + + public string AssemblyCompany + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyCompanyAttribute)attributes[0]).Company; + } + } + #endregion + } +} diff --git a/Apps/NesMiniApplication.cs b/Apps/NesMiniApplication.cs index 9c730b3a..965687b8 100644 --- a/Apps/NesMiniApplication.cs +++ b/Apps/NesMiniApplication.cs @@ -17,7 +17,27 @@ namespace com.clusterrr.hakchi_gui public readonly static string GamesDirectory = Path.Combine(Program.BaseDirectoryExternal, "games"); const string DefaultReleaseDate = "1900-01-01"; const string DefaultPublisher = "UNKNOWN"; - public bool Selected = false; + private bool selected = false; + public delegate void ValueChangedHandler(NesMiniApplication app); + + public event ValueChangedHandler SelectedChanged; + public bool Selected + { + get { return selected; } + set + { + + if(value != selected) + { + selected = value; + if (SelectedChanged != null) + { + SelectedChanged(this); + } + } + + } + } protected string code; public string Code { diff --git a/FoldersManagerForm.cs b/FoldersManagerForm.cs index f8d759b7..f3eaa347 100644 --- a/FoldersManagerForm.cs +++ b/FoldersManagerForm.cs @@ -241,7 +241,8 @@ namespace com.clusterrr.hakchi_gui } else { - if (node != null && node.Tag is NesMiniApplication) + if (node != null && node.Tag is NesMiniApplication && !(node.Tag is NesDefaultGame)) + { var game = node.Tag as NesMiniApplication; pictureBoxArt.Image = NesMiniApplication.LoadBitmap(game.IconPath); @@ -846,12 +847,17 @@ namespace com.clusterrr.hakchi_gui File.WriteAllText(FoldersXmlPath, TreeToXml()); if (mainForm != null) { - for (int i = 0; i < mainForm.checkedListBoxGames.Items.Count; i++) + List<string> codes = new List<string>(); + foreach(INesMenuElement elem in deletedGames) + { + codes.Add(elem.Code); + } + if(codes.Count() >0) { - if (deletedGames.Contains(mainForm.checkedListBoxGames.Items[i] as NesMiniApplication)) - mainForm.checkedListBoxGames.SetItemChecked(i, false); + Manager.GameManager.GetInstance().Unselect(codes.ToArray()); } + ConfigIni.Save(); } } diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 1da05612..e1029265 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -107,7 +107,6 @@ this.gitHubPageWithActualReleasesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.fAQToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.checkedListBoxGames = new System.Windows.Forms.CheckedListBox(); this.label5 = new System.Windows.Forms.Label(); this.buttonAddGames = new System.Windows.Forms.Button(); this.statusStrip = new System.Windows.Forms.StatusStrip(); @@ -116,18 +115,13 @@ this.toolStripStatusLabelSize = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripProgressBar = new System.Windows.Forms.ToolStripProgressBar(); this.openFileDialogNes = new System.Windows.Forms.OpenFileDialog(); - this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); - this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.unselectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteGameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openFileDialogImage = new System.Windows.Forms.OpenFileDialog(); this.buttonStart = new System.Windows.Forms.Button(); - this.timerCalculateGames = new System.Windows.Forms.Timer(this.components); this.timerConnectionCheck = new System.Windows.Forms.Timer(this.components); this.gameDetail1 = new com.clusterrr.hakchi_gui.UI.Components.GameDetail(); + this.gameSelecter1 = new com.clusterrr.hakchi_gui.UI.Components.GameSelecter(); this.menuStrip.SuspendLayout(); this.statusStrip.SuspendLayout(); - this.contextMenuStrip.SuspendLayout(); this.SuspendLayout(); // // menuStrip @@ -685,16 +679,6 @@ resources.ApplyResources(this.aboutToolStripMenuItem, "aboutToolStripMenuItem"); this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); // - // checkedListBoxGames - // - resources.ApplyResources(this.checkedListBoxGames, "checkedListBoxGames"); - this.checkedListBoxGames.FormattingEnabled = true; - this.checkedListBoxGames.Name = "checkedListBoxGames"; - this.checkedListBoxGames.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.checkedListBoxGames_ItemCheck); - this.checkedListBoxGames.SelectedIndexChanged += new System.EventHandler(this.checkedListBoxGames_SelectedIndexChanged); - this.checkedListBoxGames.KeyDown += new System.Windows.Forms.KeyEventHandler(this.checkedListBoxGames_KeyDown); - this.checkedListBoxGames.MouseDown += new System.Windows.Forms.MouseEventHandler(this.checkedListBoxGames_MouseDown); - // // label5 // resources.ApplyResources(this.label5, "label5"); @@ -754,33 +738,6 @@ this.openFileDialogNes.Multiselect = true; resources.ApplyResources(this.openFileDialogNes, "openFileDialogNes"); // - // contextMenuStrip - // - this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.selectAllToolStripMenuItem, - this.unselectAllToolStripMenuItem, - this.deleteGameToolStripMenuItem}); - this.contextMenuStrip.Name = "contextMenuStrip"; - resources.ApplyResources(this.contextMenuStrip, "contextMenuStrip"); - // - // selectAllToolStripMenuItem - // - this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem"; - resources.ApplyResources(this.selectAllToolStripMenuItem, "selectAllToolStripMenuItem"); - this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllToolStripMenuItem_Click); - // - // unselectAllToolStripMenuItem - // - this.unselectAllToolStripMenuItem.Name = "unselectAllToolStripMenuItem"; - resources.ApplyResources(this.unselectAllToolStripMenuItem, "unselectAllToolStripMenuItem"); - this.unselectAllToolStripMenuItem.Click += new System.EventHandler(this.unselectAllToolStripMenuItem_Click); - // - // deleteGameToolStripMenuItem - // - this.deleteGameToolStripMenuItem.Name = "deleteGameToolStripMenuItem"; - resources.ApplyResources(this.deleteGameToolStripMenuItem, "deleteGameToolStripMenuItem"); - this.deleteGameToolStripMenuItem.Click += new System.EventHandler(this.deleteGameToolStripMenuItem_Click); - // // openFileDialogImage // resources.ApplyResources(this.openFileDialogImage, "openFileDialogImage"); @@ -792,12 +749,6 @@ this.buttonStart.UseVisualStyleBackColor = true; this.buttonStart.Click += new System.EventHandler(this.buttonStart_Click); // - // timerCalculateGames - // - this.timerCalculateGames.Enabled = true; - this.timerCalculateGames.Interval = 500; - this.timerCalculateGames.Tick += new System.EventHandler(this.timerCalculateGames_Tick); - // // timerConnectionCheck // this.timerConnectionCheck.Enabled = true; @@ -809,17 +760,22 @@ resources.ApplyResources(this.gameDetail1, "gameDetail1"); this.gameDetail1.Name = "gameDetail1"; // + // gameSelecter1 + // + resources.ApplyResources(this.gameSelecter1, "gameSelecter1"); + this.gameSelecter1.Name = "gameSelecter1"; + // // MainForm // this.AllowDrop = true; resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.gameSelecter1); this.Controls.Add(this.gameDetail1); this.Controls.Add(this.buttonStart); this.Controls.Add(this.statusStrip); this.Controls.Add(this.buttonAddGames); this.Controls.Add(this.label5); - this.Controls.Add(this.checkedListBoxGames); this.Controls.Add(this.menuStrip); this.Cursor = System.Windows.Forms.Cursors.Default; this.KeyPreview = true; @@ -835,7 +791,6 @@ this.menuStrip.PerformLayout(); this.statusStrip.ResumeLayout(false); this.statusStrip.PerformLayout(); - this.contextMenuStrip.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -852,8 +807,6 @@ private System.Windows.Forms.StatusStrip statusStrip; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSelected; private System.Windows.Forms.OpenFileDialog openFileDialogNes; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip; - private System.Windows.Forms.ToolStripMenuItem deleteGameToolStripMenuItem; private System.Windows.Forms.OpenFileDialog openFileDialogImage; private System.Windows.Forms.Button buttonStart; private System.Windows.Forms.ToolStripMenuItem kernelToolStripMenuItem; @@ -861,9 +814,6 @@ private System.Windows.Forms.ToolStripMenuItem flashCustomKernelToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem flashOriginalKernelToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; - private System.Windows.Forms.Timer timerCalculateGames; - private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem unselectAllToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem uninstallToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; @@ -874,7 +824,6 @@ private System.Windows.Forms.ToolStripMenuItem addPresetToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem deletePresetToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2; - protected internal System.Windows.Forms.CheckedListBox checkedListBoxGames; private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem epilepsyProtectionToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem cloverconHackToolStripMenuItem; @@ -938,6 +887,7 @@ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem8; private System.Windows.Forms.ToolStripMenuItem takeScreenshotToolStripMenuItem; private UI.Components.GameDetail gameDetail1; + private UI.Components.GameSelecter gameSelecter1; } } diff --git a/MainForm.cs b/MainForm.cs index 1831c555..0bd48c80 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -56,7 +56,10 @@ namespace com.clusterrr.hakchi_gui KernelDump = Path.Combine(Path.Combine(Program.BaseDirectoryExternal, "dump"), "kernel.img"); InternalMods = from m in Directory.GetFiles(Path.Combine(Program.BaseDirectoryInternal, "mods/hmods")) select Path.GetFileNameWithoutExtension(m); - Manager.GameManager.GetInstance().GamesRemoved += MainForm_GamesRemoved; ; + gameSelecter1.Init(); + gameSelecter1.SelectedAppChanged += GameSelecter1_SelectedAppChanged; + Manager.GameManager.GetInstance().SelectedChanged += MainForm_SelectedChanged; + Manager.GameManager.GetInstance().GamesRemoved += MainForm_GamesRemoved; Manager.GameManager.GetInstance().NewGamesAdded += MainForm_NewGamesAdded; Manager.GameManager.GetInstance().LoadLibrary(); // LoadGames(); @@ -126,8 +129,7 @@ namespace com.clusterrr.hakchi_gui // Loading games database in background new Thread(NesGame.LoadCache).Start(); - // Recalculate games in background - new Thread(RecalculateSelectedGamesThread).Start(); + openFTPInExplorerToolStripMenuItem.Enabled = FTPToolStripMenuItem.Checked = ConfigIni.FtpServer; openTelnetToolStripMenuItem.Enabled = shellToolStripMenuItem.Checked = ConfigIni.TelnetServer; @@ -139,6 +141,16 @@ namespace com.clusterrr.hakchi_gui } } + private void MainForm_SelectedChanged(NesMiniApplication app) + { + ShowStats(); + } + + private void GameSelecter1_SelectedAppChanged(NesMiniApplication app) + { + ShowSelected(); + } + void Clovershell_OnConnected() { try @@ -183,27 +195,21 @@ namespace com.clusterrr.hakchi_gui private void MainForm_NewGamesAdded(List<NesMiniApplication> e) { - foreach (var game in e.OrderBy(o=>o.Name)) - { - checkedListBoxGames.Items.Add(game, game.Selected); - } + ShowStats(); ShowSelected(); } private void MainForm_GamesRemoved(List<NesMiniApplication> e) { - foreach (var game in e) - { - checkedListBoxGames.Items.Remove(e); - } + ShowStats(); ShowSelected(); } public void ShowSelected() { - NesMiniApplication selected = (NesMiniApplication)checkedListBoxGames.SelectedItem; + NesMiniApplication selected = gameSelecter1.GetSelectedApp(); gameDetail1.SetGame(selected); } @@ -224,11 +230,10 @@ namespace com.clusterrr.hakchi_gui ConfigIni.SelectedGames = cols[0]; ConfigIni.HiddenGames = cols[1]; var selected = ConfigIni.SelectedGames.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); - var hide = ConfigIni.HiddenGames.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); - checkedListBoxGames.SetItemChecked(0, selected.Contains("default")); - for (int j = 1; j < checkedListBoxGames.Items.Count; j++) - checkedListBoxGames.SetItemChecked(j, - selected.Contains((checkedListBoxGames.Items[j] as NesMiniApplication).Code)); + + Manager.GameManager.GetInstance().SetSelected(selected); + + })); deletePresetToolStripMenuItem.DropDownItems.Insert(i, new ToolStripMenuItem(preset, null, @@ -308,19 +313,6 @@ namespace com.clusterrr.hakchi_gui } } - private void checkedListBoxGames_SelectedIndexChanged(object sender, EventArgs e) - { - ShowSelected(); - } - - - - - - - - - private void SaveConfig() { Manager.GameManager.GetInstance().SaveChanges(); @@ -351,8 +343,7 @@ namespace com.clusterrr.hakchi_gui } catch { - timerCalculateGames.Enabled = false; - timerCalculateGames.Enabled = true; + } } void ShowStats() @@ -392,17 +383,7 @@ namespace com.clusterrr.hakchi_gui } } - private void checkedListBoxGames_MouseDown(object sender, MouseEventArgs e) - { - if (e.Button == System.Windows.Forms.MouseButtons.Right) - { - var i = checkedListBoxGames.IndexFromPoint(e.X, e.Y); - selectAllToolStripMenuItem.Tag = unselectAllToolStripMenuItem.Tag = 0; - deleteGameToolStripMenuItem.Tag = i; - deleteGameToolStripMenuItem.Enabled = i > 0; - contextMenuStrip.Show(sender as Control, e.X, e.Y); - } - } + DialogResult RequireKernelDump() @@ -499,12 +480,11 @@ namespace com.clusterrr.hakchi_gui workerForm.Config = ConfigIni.GetConfigDictionary(); workerForm.Games = new NesMenuCollection(); bool needOriginal = false; - foreach (var game in checkedListBoxGames.CheckedItems) + + foreach (var game in Manager.GameManager.GetInstance().getSelectedGames()) { - if (game is NesMiniApplication) - workerForm.Games.Add(game as NesMiniApplication); - else - needOriginal = true; + workerForm.Games.Add(game as NesMiniApplication); + } @@ -531,9 +511,7 @@ namespace com.clusterrr.hakchi_gui } Manager.GameManager.GetInstance().AddGames(addedApps); - // Schedule recalculation - timerCalculateGames.Enabled = false; - timerCalculateGames.Enabled = true; + ShowStats(); } bool FlashOriginalKernel(bool boot = true) @@ -753,20 +731,7 @@ namespace com.clusterrr.hakchi_gui ConfigIni.ExtraCommandLineArguments = form.textBox.Text; } - private void timerCalculateGames_Tick(object sender, EventArgs e) - { - new Thread(RecalculateSelectedGamesThread).Start(); // Calculate it in background - timerCalculateGames.Enabled = false; // We don't need to count games repetedly - } - - private void checkedListBoxGames_ItemCheck(object sender, ItemCheckEventArgs e) - { - NesMiniApplication app = (NesMiniApplication)checkedListBoxGames.Items[e.Index]; - app.Selected = (e.NewValue == CheckState.Checked); - Manager.GameManager.GetInstance().SaveChanges(); - timerCalculateGames.Enabled = false; - timerCalculateGames.Enabled = true; - } + private void MainForm_Shown(object sender, EventArgs e) @@ -779,56 +744,7 @@ namespace com.clusterrr.hakchi_gui } } - private void deleteGameToolStripMenuItem_Click(object sender, EventArgs e) - { - deleteGame((int)(sender as ToolStripMenuItem).Tag); - } - private void deleteGame(int pos) - { - try - { - var game = checkedListBoxGames.Items[pos] as NesMiniApplication; - if (MessageBox.Show(this, string.Format(Resources.DeleteGame, game.Name), Resources.AreYouSure, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes) - { - Manager.GameManager.GetInstance().DeleteGames(new List<NesMiniApplication>() { game }); - } - } - catch (Exception ex) - { - Debug.WriteLine(ex.Message + ex.StackTrace); - MessageBox.Show(this, ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); - } - // Schedule recalculation - timerCalculateGames.Enabled = false; - timerCalculateGames.Enabled = true; - } - - private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) - { - if ((int)(sender as ToolStripMenuItem).Tag == 0) - { - for (int i = 0; i < checkedListBoxGames.Items.Count; i++) - { - checkedListBoxGames.SetItemChecked(i, true); - var game = checkedListBoxGames.Items[i] as NesMiniApplication; - game.Selected = true; - } - } - - } - - private void unselectAllToolStripMenuItem_Click(object sender, EventArgs e) - { - if ((int)(sender as ToolStripMenuItem).Tag == 0) - for (int i = 0; i < checkedListBoxGames.Items.Count; i++) - { - checkedListBoxGames.SetItemChecked(i, false); - var game = checkedListBoxGames.Items[i] as NesMiniApplication; - game.Selected = false; - } - - } private void checkedListBoxGames_DragEnter(object sender, DragEventArgs e) { @@ -903,21 +819,16 @@ namespace com.clusterrr.hakchi_gui if (DownloadAllCovers()) MessageBox.Show(this, Resources.Done, Resources.Wow, MessageBoxButtons.OK, MessageBoxIcon.Information); ShowSelected(); - timerCalculateGames.Enabled = true; - } - private void checkedListBoxGames_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Delete && checkedListBoxGames.SelectedIndex > 0) - deleteGame(checkedListBoxGames.SelectedIndex); } + private void MainForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F5 && e.Modifiers == Keys.Shift) { int counter = 0; - foreach (var g in checkedListBoxGames.Items) + foreach (var g in Manager.GameManager.GetInstance().getAllGames()) { if (g is NesMiniApplication) { @@ -1046,7 +957,7 @@ namespace com.clusterrr.hakchi_gui if (RequirePatchedKernel() == DialogResult.No) return; var gameNames = new Dictionary<string, string>(); - foreach (var game in checkedListBoxGames.Items) + foreach (var game in Manager.GameManager.GetInstance().getAllGames()) { if (game is NesMiniApplication) gameNames[(game as NesMiniApplication).Code] = (game as NesMiniApplication).Name; diff --git a/MainForm.resx b/MainForm.resx index 2806eae8..ff144481 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -144,7 +144,7 @@ <value>$this</value> </data> <data name=">>menuStrip.ZOrder" xml:space="preserve"> - <value>7</value> + <value>6</value> </data> <data name="fileToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> <value>37, 20</value> @@ -623,30 +623,6 @@ <data name="aboutToolStripMenuItem.Text" xml:space="preserve"> <value>About...</value> </data> - <data name="checkedListBoxGames.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> - <value>None</value> - </data> - <data name="checkedListBoxGames.Location" type="System.Drawing.Point, System.Drawing"> - <value>12, 57</value> - </data> - <data name="checkedListBoxGames.Size" type="System.Drawing.Size, System.Drawing"> - <value>282, 499</value> - </data> - <data name="checkedListBoxGames.TabIndex" type="System.Int32, mscorlib"> - <value>1</value> - </data> - <data name=">>checkedListBoxGames.Name" xml:space="preserve"> - <value>checkedListBoxGames</value> - </data> - <data name=">>checkedListBoxGames.Type" xml:space="preserve"> - <value>System.Windows.Forms.CheckedListBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </data> - <data name=">>checkedListBoxGames.Parent" xml:space="preserve"> - <value>$this</value> - </data> - <data name=">>checkedListBoxGames.ZOrder" xml:space="preserve"> - <value>6</value> - </data> <data name="label5.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> <value>None</value> </data> @@ -758,36 +734,6 @@ <data name="openFileDialogNes.Title" xml:space="preserve"> <value>Select NES file(s)</value> </data> - <metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> - <value>340, 17</value> - </metadata> - <data name="contextMenuStrip.Size" type="System.Drawing.Size, System.Drawing"> - <value>141, 70</value> - </data> - <data name=">>contextMenuStrip.Name" xml:space="preserve"> - <value>contextMenuStrip</value> - </data> - <data name=">>contextMenuStrip.Type" xml:space="preserve"> - <value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </data> - <data name="selectAllToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> - <value>140, 22</value> - </data> - <data name="selectAllToolStripMenuItem.Text" xml:space="preserve"> - <value>Select all</value> - </data> - <data name="unselectAllToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> - <value>140, 22</value> - </data> - <data name="unselectAllToolStripMenuItem.Text" xml:space="preserve"> - <value>Unselect all</value> - </data> - <data name="deleteGameToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> - <value>140, 22</value> - </data> - <data name="deleteGameToolStripMenuItem.Text" xml:space="preserve"> - <value>Delete game</value> - </data> <metadata name="openFileDialogImage.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>624, 17</value> </metadata> @@ -824,9 +770,6 @@ <data name=">>buttonStart.ZOrder" xml:space="preserve"> <value>2</value> </data> - <metadata name="timerCalculateGames.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> - <value>473, 17</value> - </metadata> <metadata name="timerConnectionCheck.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>775, 17</value> </metadata> @@ -849,6 +792,27 @@ <value>$this</value> </data> <data name=">>gameDetail1.ZOrder" xml:space="preserve"> + <value>1</value> + </data> + <data name="gameSelecter1.Location" type="System.Drawing.Point, System.Drawing"> + <value>15, 49</value> + </data> + <data name="gameSelecter1.Size" type="System.Drawing.Size, System.Drawing"> + <value>285, 507</value> + </data> + <data name="gameSelecter1.TabIndex" type="System.Int32, mscorlib"> + <value>8</value> + </data> + <data name=">>gameSelecter1.Name" xml:space="preserve"> + <value>gameSelecter1</value> + </data> + <data name=">>gameSelecter1.Type" xml:space="preserve"> + <value>com.clusterrr.hakchi_gui.UI.Components.GameSelecter, hakchi, Version=2.0.17.14, Culture=neutral, PublicKeyToken=null</value> + </data> + <data name=">>gameSelecter1.Parent" xml:space="preserve"> + <value>$this</value> + </data> + <data name=">>gameSelecter1.ZOrder" xml:space="preserve"> <value>0</value> </data> <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> @@ -2496,36 +2460,12 @@ <data name=">>openFileDialogNes.Type" xml:space="preserve"> <value>System.Windows.Forms.OpenFileDialog, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </data> - <data name=">>selectAllToolStripMenuItem.Name" xml:space="preserve"> - <value>selectAllToolStripMenuItem</value> - </data> - <data name=">>selectAllToolStripMenuItem.Type" xml:space="preserve"> - <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </data> - <data name=">>unselectAllToolStripMenuItem.Name" xml:space="preserve"> - <value>unselectAllToolStripMenuItem</value> - </data> - <data name=">>unselectAllToolStripMenuItem.Type" xml:space="preserve"> - <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </data> - <data name=">>deleteGameToolStripMenuItem.Name" xml:space="preserve"> - <value>deleteGameToolStripMenuItem</value> - </data> - <data name=">>deleteGameToolStripMenuItem.Type" xml:space="preserve"> - <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </data> <data name=">>openFileDialogImage.Name" xml:space="preserve"> <value>openFileDialogImage</value> </data> <data name=">>openFileDialogImage.Type" xml:space="preserve"> <value>System.Windows.Forms.OpenFileDialog, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </data> - <data name=">>timerCalculateGames.Name" xml:space="preserve"> - <value>timerCalculateGames</value> - </data> - <data name=">>timerCalculateGames.Type" xml:space="preserve"> - <value>System.Windows.Forms.Timer, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </data> <data name=">>timerConnectionCheck.Name" xml:space="preserve"> <value>timerConnectionCheck</value> </data> diff --git a/Manager/EventBus.cs b/Manager/EventBus.cs new file mode 100644 index 00000000..a4d5854e --- /dev/null +++ b/Manager/EventBus.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace com.clusterrr.hakchi_gui.Manager +{ + public class EventBus + { + public delegate void TextRequest(string text); + + public static EventBus getInstance() + { + if(instance == null) + { + instance = new EventBus(); + } + return instance; + } + private static EventBus instance; + private EventBus() + { + + } + public event TextRequest SearchRequest; + public void Search(string text) + { + if(SearchRequest!=null) + { + SearchRequest(text); + } + } + } +} diff --git a/Manager/GameManager.cs b/Manager/GameManager.cs index e7bff70a..5e227154 100644 --- a/Manager/GameManager.cs +++ b/Manager/GameManager.cs @@ -99,6 +99,40 @@ namespace com.clusterrr.hakchi_gui.Manager { } + public void Unselect(string[] unselect) + { + foreach (var game in gameLibrary) + { + if (unselect.Contains(game.Code)) + { + if (game.Selected) + { + game.Selected = false; + } + } + + } + } + public void SetSelected(string[] gameCodes) + { + foreach(var game in gameLibrary) + { + if (gameCodes.Contains(game.Code)) + { + if (!game.Selected) + { + game.Selected = true; + } + } + else + { + if(game.Selected) + { + game.Selected = false; + } + } + } + } public CountResult GetStatistics() { CountResult stats = new CountResult(); @@ -125,6 +159,19 @@ namespace com.clusterrr.hakchi_gui.Manager } return stats; } + public IOrderedEnumerable<NesMiniApplication> getSelectedGames() + { + List<NesMiniApplication> ret = new List<NesMiniApplication>(); + foreach(NesMiniApplication app in gameLibrary) + { + if(app.Selected) + { + ret.Add(app); + } + } + + return ret.OrderBy(o => o.Name); + } public IOrderedEnumerable<NesMiniApplication> getAllGames() { return gameLibrary.OrderBy(o => o.Name); @@ -167,6 +214,7 @@ namespace com.clusterrr.hakchi_gui.Manager { if (!gameLibrary.Contains(g)) { + g.SelectedChanged += G_SelectedChanged; gameLibrary.Add(g); reallyAdded.Add(g); AppTypeCollection.AppInfo inf = AppTypeCollection.GetAppByClass(g.GetType()); @@ -185,6 +233,16 @@ namespace com.clusterrr.hakchi_gui.Manager } } } + public event NesMiniApplication.ValueChangedHandler SelectedChanged; + private void G_SelectedChanged(NesMiniApplication app) + { + SaveChanges(); + if(SelectedChanged != null) + { + SelectedChanged(app); + } + } + public void SaveChanges() { var selected = new List<string>(); @@ -213,6 +271,7 @@ namespace com.clusterrr.hakchi_gui.Manager /*Why? If a game type has change its going to be reloaded...*/ // LoadLibrary(); } + public void ReloadDefault() { string[] selectedGames = ConfigIni.SelectedGames.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); diff --git a/SearchForm.cs b/SearchForm.cs index 15ae4fdf..a6ce5976 100644 --- a/SearchForm.cs +++ b/SearchForm.cs @@ -1,41 +1,36 @@ -using System;
-using System.Windows.Forms;
-
-namespace com.clusterrr.hakchi_gui
-{
- public partial class SearchForm : Form
- {
- MainForm mainForm;
-
- public SearchForm(MainForm mainForm)
- {
- InitializeComponent();
- this.mainForm = mainForm;
- }
-
- private void textBoxSearch_TextChanged(object sender, EventArgs e)
- {
- if (textBoxSearch.Text.Length > 0)
- {
- for (int i = 1; i < mainForm.checkedListBoxGames.Items.Count; i++)
- if ((mainForm.checkedListBoxGames.Items[i] as NesMiniApplication).Name.
- ToLower().StartsWith(textBoxSearch.Text.ToLower()))
- {
- mainForm.checkedListBoxGames.SelectedIndex = i;
- break;
- }
- }
- }
-
- private void SearchForm_Deactivate(object sender, EventArgs e)
- {
- Close();
- }
-
- private void SearchForm_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Escape || e.KeyCode == Keys.Enter)
- Close();
- }
- }
-}
+using System; +using System.Windows.Forms; + +namespace com.clusterrr.hakchi_gui +{ + public partial class SearchForm : Form + { + MainForm mainForm; + + public SearchForm(MainForm mainForm) + { + InitializeComponent(); + this.mainForm = mainForm; + } + + private void textBoxSearch_TextChanged(object sender, EventArgs e) + { + if (textBoxSearch.Text.Length > 0) + { + Manager.EventBus.getInstance().Search(textBoxSearch.Text); + + } + } + + private void SearchForm_Deactivate(object sender, EventArgs e) + { + Close(); + } + + private void SearchForm_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape || e.KeyCode == Keys.Enter) + Close(); + } + } +} diff --git a/UI/Components/GameDetail.cs b/UI/Components/GameDetail.cs index 397f37b6..d44cd9d7 100644 --- a/UI/Components/GameDetail.cs +++ b/UI/Components/GameDetail.cs @@ -30,6 +30,18 @@ namespace com.clusterrr.hakchi_gui.UI.Components currentApp = app; ReloadInfo(); } + private void Disable() + { + buttonBrowseImage.Enabled = false; + buttonGoogle.Enabled = false; + groupBoxOptions.Enabled = false; + } + private void Enable() + { + buttonBrowseImage.Enabled = true; + buttonGoogle.Enabled = true; + groupBoxOptions.Enabled = true; + } private void ReloadInfo() { if (currentApp == null) @@ -46,6 +58,8 @@ namespace com.clusterrr.hakchi_gui.UI.Components textBoxPublisher.Text = ""; textBoxArguments.Text = ""; pictureBoxArt.Image = null; + buttonBrowseImage.Enabled = false; + buttonGoogle.Enabled = false; } else { @@ -75,6 +89,15 @@ namespace com.clusterrr.hakchi_gui.UI.Components buttonShowGameGenieDatabase.Enabled = textBoxGameGenie.Enabled = currentApp is NesGame; textBoxGameGenie.Text = (currentApp is NesGame) ? (currentApp as NesGame).GameGenie : ""; groupBoxOptions.Enabled = true; + + if(currentApp.GetType() != typeof(NesDefaultGame)) + { + Enable(); + } + else + { + Disable(); + } } } diff --git a/UI/Components/GameSelecter.Designer.cs b/UI/Components/GameSelecter.Designer.cs index 9d2b7f17..b5458fd1 100644 --- a/UI/Components/GameSelecter.Designer.cs +++ b/UI/Components/GameSelecter.Designer.cs @@ -28,17 +28,68 @@ /// </summary> private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.checkedListBox1 = new System.Windows.Forms.CheckedListBox(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.selectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.allToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.noneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteSelectedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // // checkedListBox1 // + this.checkedListBox1.ContextMenuStrip = this.contextMenuStrip1; this.checkedListBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.checkedListBox1.FormattingEnabled = true; this.checkedListBox1.Location = new System.Drawing.Point(0, 0); this.checkedListBox1.Name = "checkedListBox1"; this.checkedListBox1.Size = new System.Drawing.Size(495, 607); + this.checkedListBox1.Sorted = true; this.checkedListBox1.TabIndex = 0; + this.checkedListBox1.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.checkedListBox1_ItemCheck); + this.checkedListBox1.SelectedIndexChanged += new System.EventHandler(this.checkedListBox1_SelectedIndexChanged); + this.checkedListBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.checkedListBox1_KeyDown); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.selectToolStripMenuItem, + this.deleteSelectedToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(154, 70); + this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); + // + // selectToolStripMenuItem + // + this.selectToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.allToolStripMenuItem, + this.noneToolStripMenuItem}); + this.selectToolStripMenuItem.Name = "selectToolStripMenuItem"; + this.selectToolStripMenuItem.Size = new System.Drawing.Size(153, 22); + this.selectToolStripMenuItem.Text = "Select"; + // + // allToolStripMenuItem + // + this.allToolStripMenuItem.Name = "allToolStripMenuItem"; + this.allToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.allToolStripMenuItem.Text = "All"; + this.allToolStripMenuItem.Click += new System.EventHandler(this.allToolStripMenuItem_Click); + // + // noneToolStripMenuItem + // + this.noneToolStripMenuItem.Name = "noneToolStripMenuItem"; + this.noneToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.noneToolStripMenuItem.Text = "None"; + this.noneToolStripMenuItem.Click += new System.EventHandler(this.noneToolStripMenuItem_Click); + // + // deleteSelectedToolStripMenuItem + // + this.deleteSelectedToolStripMenuItem.Name = "deleteSelectedToolStripMenuItem"; + this.deleteSelectedToolStripMenuItem.Size = new System.Drawing.Size(153, 22); + this.deleteSelectedToolStripMenuItem.Text = "Delete selected"; + this.deleteSelectedToolStripMenuItem.Click += new System.EventHandler(this.deleteSelectedToolStripMenuItem_Click); // // GameSelecter // @@ -47,6 +98,7 @@ this.Controls.Add(this.checkedListBox1); this.Name = "GameSelecter"; this.Size = new System.Drawing.Size(495, 607); + this.contextMenuStrip1.ResumeLayout(false); this.ResumeLayout(false); } @@ -54,5 +106,10 @@ #endregion private System.Windows.Forms.CheckedListBox checkedListBox1; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem selectToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem allToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem noneToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem deleteSelectedToolStripMenuItem; } } diff --git a/UI/Components/GameSelecter.resx b/UI/Components/GameSelecter.resx index 7080a7d1..73b01278 100644 --- a/UI/Components/GameSelecter.resx +++ b/UI/Components/GameSelecter.resx @@ -117,4 +117,7 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> + <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> </root>
\ No newline at end of file diff --git a/WorkerForm.cs b/WorkerForm.cs index b0a64f13..88eb323a 100644 --- a/WorkerForm.cs +++ b/WorkerForm.cs @@ -900,29 +900,39 @@ namespace com.clusterrr.hakchi_gui { if (element is NesMiniApplication) { - stats.TotalGames++; - var game = element as NesMiniApplication; - var gameSize = game.Size(); - Debug.WriteLine(string.Format("Processing {0} ('{1}'), size: {2}KB", game.Code, game.Name, gameSize / 1024)); - var gameCopy = game.CopyTo(targetDirectory); - stats.TotalSize += gameSize; - stats.TransferSize += gameSize; - stats.TotalGames++; - try - { - if (gameCopy is NesGame && File.Exists((gameCopy as NesGame).GameGeniePath)) - { - (gameCopy as NesGame).ApplyGameGenie(); - File.Delete((gameCopy as NesGame).GameGeniePath); - } - } - catch (GameGenieFormatException ex) + if (element is NesDefaultGame) { - ShowError(new Exception(string.Format(Resources.GameGenieFormatError, ex.Code, game.Name)), dontStop: true); + var game = element as NesDefaultGame; + stats.TotalSize += game.Size; + originalGames[game.Code] = menuIndex == 0 ? "." : string.Format("{0:D3}", menuIndex); } - catch (GameGenieNotFoundException ex) + else { - ShowError(new Exception(string.Format(Resources.GameGenieNotFound, ex.Code, game.Name)), dontStop: true); + + stats.TotalGames++; + var game = element as NesMiniApplication; + var gameSize = game.Size(); + Debug.WriteLine(string.Format("Processing {0} ('{1}'), size: {2}KB", game.Code, game.Name, gameSize / 1024)); + var gameCopy = game.CopyTo(targetDirectory); + stats.TotalSize += gameSize; + stats.TransferSize += gameSize; + stats.TotalGames++; + try + { + if (gameCopy is NesGame && File.Exists((gameCopy as NesGame).GameGeniePath)) + { + (gameCopy as NesGame).ApplyGameGenie(); + File.Delete((gameCopy as NesGame).GameGeniePath); + } + } + catch (GameGenieFormatException ex) + { + ShowError(new Exception(string.Format(Resources.GameGenieFormatError, ex.Code, game.Name)), dontStop: true); + } + catch (GameGenieNotFoundException ex) + { + ShowError(new Exception(string.Format(Resources.GameGenieNotFound, ex.Code, game.Name)), dontStop: true); + } } } if (element is NesMenuFolder) @@ -940,12 +950,7 @@ namespace com.clusterrr.hakchi_gui stats.TransferSize += folderSize; } - if (element is NesDefaultGame) - { - var game = element as NesDefaultGame; - stats.TotalSize += game.Size; - originalGames[game.Code] = menuIndex == 0 ? "." : string.Format("{0:D3}", menuIndex); - } + } } diff --git a/hakchi_gui.csproj b/hakchi_gui.csproj index b27318a0..d618bb4d 100644 --- a/hakchi_gui.csproj +++ b/hakchi_gui.csproj @@ -320,6 +320,7 @@ <Compile Include="LibWinUsb\WinUsb\PowerPolicyType.cs" /> <Compile Include="LibWinUsb\WinUsb\WinUsbDevice.cs" /> <Compile Include="LibWinUsb\WinUsb\WinUsbRegistry.cs" /> + <Compile Include="Manager\EventBus.cs" /> <Compile Include="Manager\GameManager.cs" /> <Compile Include="MessageBoxManager.cs" /> <Compile Include="Properties\Resources.Designer.cs" /> |