diff --git a/hakchi_gui/Apps/NesGame.cs b/hakchi_gui/Apps/NesGame.cs index 90230efb..b255daf6 100644 --- a/hakchi_gui/Apps/NesGame.cs +++ b/hakchi_gui/Apps/NesGame.cs @@ -105,6 +105,14 @@ public bool TryAutofill(uint crc32) if (releaseDate.Length == 7) releaseDate += "-01"; desktop.ReleaseDate = releaseDate; desktop.Publisher = gameinfo.Publisher.ToUpper(); + + var match = data.Region.RegionList.Where(r => r.DefaultNames.Contains(gameinfo.Region)).Select(g => g); + + if (match.Count() > 0) + { + desktop.Country = match.First().DesktopName; + } + return true; } return false; diff --git a/hakchi_gui/Apps/SnesGame.cs b/hakchi_gui/Apps/SnesGame.cs index 78778e0f..cd7a878e 100644 --- a/hakchi_gui/Apps/SnesGame.cs +++ b/hakchi_gui/Apps/SnesGame.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Drawing; using System.IO; +using System.Linq; using System.Runtime.InteropServices; using System.Text; @@ -697,6 +698,13 @@ public bool TryAutofill(uint crc32) if (!string.IsNullOrEmpty(gameinfo.Publisher)) desktop.Publisher = gameinfo.Publisher.ToUpper(); + var match = data.Region.RegionList.Where(r => r.DefaultNames.Contains(gameinfo.Region)).Select(g => g); + + if (match.Count() > 0) + { + desktop.Country = match.First().DesktopName; + } + return true; } return false; diff --git a/hakchi_gui/FoldersManagerForm.Designer.cs b/hakchi_gui/FoldersManagerForm.Designer.cs index 354b83f0..a073fc36 100644 --- a/hakchi_gui/FoldersManagerForm.Designer.cs +++ b/hakchi_gui/FoldersManagerForm.Designer.cs @@ -73,6 +73,7 @@ private void InitializeComponent() this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.panel1 = new System.Windows.Forms.Panel(); + this.buttonFoldersRegion = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); this.splitContainer.Panel1.SuspendLayout(); this.splitContainer.Panel2.SuspendLayout(); @@ -228,6 +229,7 @@ private void InitializeComponent() this.tableLayoutPanelSplit.Controls.Add(this.buttonNoFoldersOriginal, 1, 0); this.tableLayoutPanelSplit.Controls.Add(this.buttonFoldersEqually, 0, 2); this.tableLayoutPanelSplit.Controls.Add(this.buttonFoldersGenre, 0, 5); + this.tableLayoutPanelSplit.Controls.Add(this.buttonFoldersRegion, 0, 6); this.tableLayoutPanelSplit.Name = "tableLayoutPanelSplit"; // // buttonFoldersApp @@ -278,6 +280,14 @@ private void InitializeComponent() this.buttonFoldersGenre.UseVisualStyleBackColor = true; this.buttonFoldersGenre.Click += new System.EventHandler(this.buttonFoldersGenre_Click); // + // buttonFoldersRegion + // + this.tableLayoutPanelSplit.SetColumnSpan(this.buttonFoldersRegion, 2); + resources.ApplyResources(this.buttonFoldersRegion, "buttonFoldersRegion"); + this.buttonFoldersRegion.Name = "buttonFoldersRegion"; + this.buttonFoldersRegion.UseVisualStyleBackColor = true; + this.buttonFoldersRegion.Click += new System.EventHandler(this.buttonFoldersRegion_Click); + // // groupBoxArt // this.groupBoxArt.Controls.Add(this.pictureBoxArt); @@ -540,5 +550,6 @@ private void InitializeComponent() private System.Windows.Forms.TableLayoutPanel tableLayoutPanelSplit; private System.Windows.Forms.Button buttonFoldersGenre; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Button buttonFoldersRegion; } } \ No newline at end of file diff --git a/hakchi_gui/FoldersManagerForm.cs b/hakchi_gui/FoldersManagerForm.cs index 0fc80480..0b1a0f3c 100644 --- a/hakchi_gui/FoldersManagerForm.cs +++ b/hakchi_gui/FoldersManagerForm.cs @@ -248,6 +248,7 @@ void AddNodes(TreeNodeCollection treeNodeCollection, NesMenuCollection nesMenuCo private void buttonFoldersLettersOriginal_Click(object sender, EventArgs e) => DrawSplitTree(NesMenuCollection.SplitStyle.Original_FoldersAlphabetic_FoldersEqual); private void buttonFoldersApp_Click(object sender, EventArgs e) => DrawSplitTree(NesMenuCollection.SplitStyle.FoldersGroupByApp); private void buttonFoldersGenre_Click(object sender, EventArgs e) => DrawSplitTree(NesMenuCollection.SplitStyle.FoldersGroupByGenre); + private void buttonFoldersRegion_Click(object sender, EventArgs e) => DrawSplitTree(NesMenuCollection.SplitStyle.FoldersGroupByRegion); private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { ShowSelected(); diff --git a/hakchi_gui/FoldersManagerForm.resx b/hakchi_gui/FoldersManagerForm.resx index fb02e76b..5b26a97d 100644 --- a/hakchi_gui/FoldersManagerForm.resx +++ b/hakchi_gui/FoldersManagerForm.resx @@ -140,7 +140,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD0 - IwAAAk1TRnQBSQFMAgEBJgEAAeQBAQHkAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + IwAAAk1TRnQBSQFMAgEBJgEAAewBAQHsAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAAaADAAEBAQABCAYAASgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -456,10 +456,10 @@ NoControl - 3, 139 + 3, 115 - 242, 30 + 242, 26 10 @@ -489,7 +489,7 @@ 3, 3 - 118, 58 + 118, 42 4 @@ -516,10 +516,10 @@ NoControl - 3, 103 + 3, 83 - 242, 30 + 242, 26 8 @@ -546,7 +546,7 @@ 127, 3 - 118, 58 + 118, 42 12 @@ -573,10 +573,10 @@ NoControl - 3, 67 + 3, 51 - 242, 30 + 242, 26 6 @@ -600,10 +600,10 @@ Fill - 3, 175 + 3, 147 - 242, 30 + 242, 26 13 @@ -623,6 +623,36 @@ 5 + + Fill + + + NoControl + + + 3, 179 + + + 242, 26 + + + 14 + + + Split by region + + + buttonFoldersRegion + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanelSplit + + + 6 + Fill @@ -630,7 +660,7 @@ 3, 16 - 6 + 7 248, 208 @@ -651,7 +681,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="buttonFoldersApp" Row="4" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="buttonNoFolders" Row="0" RowSpan="2" Column="0" ColumnSpan="1" /><Control Name="buttonFoldersLetters" Row="3" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="buttonNoFoldersOriginal" Row="0" RowSpan="2" Column="1" ColumnSpan="1" /><Control Name="buttonFoldersEqually" Row="2" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="buttonFoldersGenre" Row="5" RowSpan="1" Column="0" ColumnSpan="2" /></Controls><Columns Styles="Percent,50,Percent,50" /><Rows Styles="Percent,50,Percent,50,Absolute,36,Absolute,36,Absolute,36,Absolute,36" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="buttonFoldersApp" Row="4" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="buttonNoFolders" Row="0" RowSpan="2" Column="0" ColumnSpan="1" /><Control Name="buttonFoldersLetters" Row="3" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="buttonNoFoldersOriginal" Row="0" RowSpan="2" Column="1" ColumnSpan="1" /><Control Name="buttonFoldersEqually" Row="2" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="buttonFoldersGenre" Row="5" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="buttonFoldersRegion" Row="6" RowSpan="1" Column="0" ColumnSpan="2" /></Controls><Columns Styles="Percent,50,Percent,50" /><Rows Styles="Percent,50,Percent,50,Absolute,32,Absolute,32,Absolute,32,Absolute,32,Absolute,32" /></TableLayoutSettings> 305, 12 diff --git a/hakchi_gui/MainForm.Designer.cs b/hakchi_gui/MainForm.Designer.cs index 69dbf320..05baff4c 100644 --- a/hakchi_gui/MainForm.Designer.cs +++ b/hakchi_gui/MainForm.Designer.cs @@ -91,6 +91,7 @@ private void InitializeComponent() this.nameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.coreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.systemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.regionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showGamesWithoutBoxArtToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.languageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -136,9 +137,9 @@ private void InitializeComponent() this.saveSettingsToNESMiniNowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveStateManagerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.importGamesFromMiniToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.takeScreenshotToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveDmesgOutputToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.importGamesFromMiniToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator(); this.openFTPInExplorerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openTelnetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -171,6 +172,8 @@ private void InitializeComponent() this.addPrefixToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.removePrefixToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem14 = new System.Windows.Forms.ToolStripSeparator(); + this.setRegionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.scrapeSelectedGamesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.scanForNewBoxArtForSelectedGamesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.downloadBoxArtForSelectedGamesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -712,7 +715,8 @@ private void InitializeComponent() this.sortByToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.nameToolStripMenuItem, this.coreToolStripMenuItem, - this.systemToolStripMenuItem}); + this.systemToolStripMenuItem, + this.regionToolStripMenuItem}); this.sortByToolStripMenuItem.Name = "sortByToolStripMenuItem"; resources.ApplyResources(this.sortByToolStripMenuItem, "sortByToolStripMenuItem"); // @@ -737,6 +741,13 @@ private void InitializeComponent() this.systemToolStripMenuItem.Tag = "2"; this.systemToolStripMenuItem.Click += new System.EventHandler(this.sortByToolStripMenuItem_Click); // + // regionToolStripMenuItem + // + this.regionToolStripMenuItem.Name = "regionToolStripMenuItem"; + resources.ApplyResources(this.regionToolStripMenuItem, "regionToolStripMenuItem"); + this.regionToolStripMenuItem.Tag = "3"; + this.regionToolStripMenuItem.Click += new System.EventHandler(this.sortByToolStripMenuItem_Click); + // // showGamesWithoutBoxArtToolStripMenuItem // this.showGamesWithoutBoxArtToolStripMenuItem.Checked = true; @@ -1111,6 +1122,12 @@ private void InitializeComponent() resources.ApplyResources(this.saveStateManagerToolStripMenuItem, "saveStateManagerToolStripMenuItem"); this.saveStateManagerToolStripMenuItem.Click += new System.EventHandler(this.saveStateManagerToolStripMenuItem_Click); // + // importGamesFromMiniToolStripMenuItem + // + this.importGamesFromMiniToolStripMenuItem.Name = "importGamesFromMiniToolStripMenuItem"; + resources.ApplyResources(this.importGamesFromMiniToolStripMenuItem, "importGamesFromMiniToolStripMenuItem"); + this.importGamesFromMiniToolStripMenuItem.Click += new System.EventHandler(this.importGamesFromMiniToolStripMenuItem_Click); + // // takeScreenshotToolStripMenuItem // this.takeScreenshotToolStripMenuItem.Name = "takeScreenshotToolStripMenuItem"; @@ -1123,12 +1140,6 @@ private void InitializeComponent() resources.ApplyResources(this.saveDmesgOutputToolStripMenuItem, "saveDmesgOutputToolStripMenuItem"); this.saveDmesgOutputToolStripMenuItem.Click += new System.EventHandler(this.saveDmesgOutputToolStripMenuItem_Click); // - // importGamesFromMiniToolStripMenuItem - // - this.importGamesFromMiniToolStripMenuItem.Name = "importGamesFromMiniToolStripMenuItem"; - resources.ApplyResources(this.importGamesFromMiniToolStripMenuItem, "importGamesFromMiniToolStripMenuItem"); - this.importGamesFromMiniToolStripMenuItem.Click += new System.EventHandler(this.importGamesFromMiniToolStripMenuItem_Click); - // // toolStripMenuItem6 // this.toolStripMenuItem6.Name = "toolStripMenuItem6"; @@ -1311,6 +1322,8 @@ private void InitializeComponent() this.addPrefixToolStripMenuItem, this.removePrefixToolStripMenuItem, this.toolStripMenuItem14, + this.setRegionToolStripMenuItem, + this.toolStripSeparator3, this.scrapeSelectedGamesToolStripMenuItem, this.scanForNewBoxArtForSelectedGamesToolStripMenuItem, this.downloadBoxArtForSelectedGamesToolStripMenuItem, @@ -1356,6 +1369,16 @@ private void InitializeComponent() this.toolStripMenuItem14.Name = "toolStripMenuItem14"; resources.ApplyResources(this.toolStripMenuItem14, "toolStripMenuItem14"); // + // setRegionToolStripMenuItem + // + this.setRegionToolStripMenuItem.Name = "setRegionToolStripMenuItem"; + resources.ApplyResources(this.setRegionToolStripMenuItem, "setRegionToolStripMenuItem"); + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + resources.ApplyResources(this.toolStripSeparator3, "toolStripSeparator3"); + // // scrapeSelectedGamesToolStripMenuItem // resources.ApplyResources(this.scrapeSelectedGamesToolStripMenuItem, "scrapeSelectedGamesToolStripMenuItem"); @@ -2483,6 +2506,9 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripMenuItem enableInformationScrapeOnImportToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem importGamesFromMiniToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem regionToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripMenuItem setRegionToolStripMenuItem; } } diff --git a/hakchi_gui/MainForm.cs b/hakchi_gui/MainForm.cs index 9fcd0c69..0e527a67 100644 --- a/hakchi_gui/MainForm.cs +++ b/hakchi_gui/MainForm.cs @@ -48,7 +48,7 @@ private bool GameGenieEnabled } public enum OriginalGamesPosition { AtTop = 0, AtBottom = 1, Sorted = 2, Hidden = 3 } - public enum GamesSorting { Name = 0, Core = 1, System = 2 } + public enum GamesSorting { Name = 0, Core = 1, System = 2, Region = 3 } public static string GetConsoleTypeName() { return GetConsoleTypeName(hakchi.DetectedConsoleType); @@ -134,6 +134,52 @@ public static void PopulateGenres(ComboBox comboBoxGenre) comboBoxGenre.Items.Add(new NameValuePair(genre.LocalizedName, genre.DesktopName)); } } + public static void PopulateRegionsComboBox(ComboBox comboBoxCountry) + { + comboBoxCountry.Items.Clear(); + comboBoxCountry.Items.Add(new NameValuePair("", "")); + foreach (var region in data.Region.RegionList) + { + comboBoxCountry.Items.Add(new NameValuePair(region.LocalizedName, region.DesktopName)); + } + } + + private void PopulateRegionsMenu() + { + var menuRegions = setRegionToolStripMenuItem.DropDownItems; + + menuRegions.Clear(); + foreach (var region in data.Region.RegionList) + { + var menuItem = new System.Windows.Forms.ToolStripMenuItem(); + menuItem.Text = region.LocalizedName; + menuItem.Click += (sender, e) => + { + if (listViewGames.SelectedItems.Count > 0) + { + foreach (var game in listViewGames.SelectedItems.Cast()) + { + if (game.Tag != null && game.Tag is NesApplication) + { + var tag = (NesApplication)(game.Tag); + tag.Desktop.Country = region.DesktopName; + tag.Save(); + } + } + listViewGames.BeginUpdate(); + LoadGames(false); + listViewGames.EndUpdate(); + } + }; + menuRegions.Add(menuItem); + } + } + + private static void MenuItem_Click(object sender, EventArgs e) + { + throw new NotImplementedException(); + } + private void FormInitialize() { try @@ -144,15 +190,8 @@ private void FormInitialize() enableInformationScrapeOnImportToolStripMenuItem.Checked = ConfigIni.Instance.EnableImportScraper; PopulateMaxPlayers(maxPlayersComboBox); PopulateGenres(comboBoxGenre); - - comboBoxCountry.Items.Clear(); - comboBoxCountry.Items.AddRange(new object[] - { - new NameValuePair("", ""), - new NameValuePair(Resources.UnitedStates, "us"), - new NameValuePair(Resources.Europe, "eu"), - new NameValuePair(Resources.Japan, "jp") - }); + PopulateRegionsComboBox(comboBoxCountry); + PopulateRegionsMenu(); // prepare collections LoadLanguages(); @@ -637,6 +676,7 @@ private void SyncConsoleType(bool force = false) nameToolStripMenuItem.Checked = ConfigIni.Instance.GamesSorting == GamesSorting.Name; coreToolStripMenuItem.Checked = ConfigIni.Instance.GamesSorting == GamesSorting.Core; systemToolStripMenuItem.Checked = ConfigIni.Instance.GamesSorting == GamesSorting.System; + regionToolStripMenuItem.Checked = ConfigIni.Instance.GamesSorting == GamesSorting.Region; showGamesWithoutBoxArtToolStripMenuItem.Checked = ConfigIni.Instance.ShowGamesWithoutCoverArt; // folders modes @@ -3212,6 +3252,7 @@ private void sortByToolStripMenuItem_Click(object sender, EventArgs e) nameToolStripMenuItem.Checked = newSorting == GamesSorting.Name; coreToolStripMenuItem.Checked = newSorting == GamesSorting.Core; systemToolStripMenuItem.Checked = newSorting == GamesSorting.System; + regionToolStripMenuItem.Checked = newSorting == GamesSorting.Region; LoadGames(false); } diff --git a/hakchi_gui/MainForm.resx b/hakchi_gui/MainForm.resx index 8f52b724..97f97c6f 100644 --- a/hakchi_gui/MainForm.resx +++ b/hakchi_gui/MainForm.resx @@ -345,7 +345,7 @@ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - wwAADsMBx2+oZAAAAcxJREFUOE+Vk0uL01AAhW8fFEqhUKiBarUaq21SJ9MhQ2lnQtJMqTojLl00i8GF + vgAADr4B6kKxwAAAAcxJREFUOE+Vk0uL01AAhW8fFEqhUKiBarUaq21SJ9MhQ2lnQtJMqTojLl00i8GF P8KFCLMQdBaR0YUD4x9wI4ig+KK6VHAxgiIjxbULXdw/cMxJ6SPtbBr4yM0957vkhhvBq1ar+QFyQfxQ 1jTN13Vdep6HRaBDV1SrVdnr9dDtdkO2Nof349i8OhnToSvK5bLsdDogN70N/Oq3cWt7I3yehtmPt214 NyYZXaGqqnRdF9evuRh8dCAPHRy+coKCC84Tjr+8GGbf3zi4cnk4T1eUSiVp2zYOdoeFEXs7NjhPdu/Y @@ -438,23 +438,29 @@ Original games - 117, 22 + 180, 22 Name - 117, 22 + 180, 22 Core - 117, 22 + 180, 22 Console + + 180, 22 + + + Region + 209, 22 @@ -835,7 +841,7 @@ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - wwAADsMBx2+oZAAAAcxJREFUOE+Vk0uL01AAhW8fFEqhUKiBarUaq21SJ9MhQ2lnQtJMqTojLl00i8GF + vgAADr4B6kKxwAAAAcxJREFUOE+Vk0uL01AAhW8fFEqhUKiBarUaq21SJ9MhQ2lnQtJMqTojLl00i8GF P8KFCLMQdBaR0YUD4x9wI4ig+KK6VHAxgiIjxbULXdw/cMxJ6SPtbBr4yM0957vkhhvBq1ar+QFyQfxQ 1jTN13Vdep6HRaBDV1SrVdnr9dDtdkO2Nof349i8OhnToSvK5bLsdDogN70N/Oq3cWt7I3yehtmPt214 NyYZXaGqqnRdF9evuRh8dCAPHRy+coKCC84Tjr+8GGbf3zi4cnk4T1eUSiVp2zYOdoeFEXs7NjhPdu/Y @@ -1035,6 +1041,15 @@ 281, 6 + + 284, 22 + + + Set Region + + + 281, 6 + False @@ -1156,7 +1171,7 @@ Select emulation core... - 285, 342 + 285, 392 contextMenuStrip @@ -3867,6 +3882,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + regionToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + showGamesWithoutBoxArtToolStripMenuItem @@ -4137,6 +4158,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + importGamesFromMiniToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + takeScreenshotToolStripMenuItem @@ -4149,12 +4176,6 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - importGamesFromMiniToolStripMenuItem - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - toolStripMenuItem6 @@ -4237,7 +4258,7 @@ bluetoothToolStripMenuItem - com.clusterrr.hakchi_gui.Wireless.Bluetooth.BluetoothMenuItem, hakchi, Version=3.8.0.1, Culture=neutral, PublicKeyToken=null + com.clusterrr.hakchi_gui.Wireless.Bluetooth.BluetoothMenuItem, hakchi, Version=3.9.3.0, Culture=neutral, PublicKeyToken=null helpToolStripMenuItem @@ -4335,6 +4356,18 @@ System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + setRegionToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + toolStripSeparator3 + + + System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + scrapeSelectedGamesToolStripMenuItem diff --git a/hakchi_gui/NesMenuCollection.cs b/hakchi_gui/NesMenuCollection.cs index bd29b900..a42b361e 100644 --- a/hakchi_gui/NesMenuCollection.cs +++ b/hakchi_gui/NesMenuCollection.cs @@ -27,6 +27,7 @@ public enum SplitStyle Original_FoldersAlphabetic_PagesEqual = 11, FoldersGroupByApp = 12, FoldersGroupByGenre = 13, + FoldersGroupByRegion = 14, Custom = 99 } @@ -272,6 +273,45 @@ public void Split(SplitStyle style, int maxElements = 35) root.Add(folder); } } + else if (style == SplitStyle.FoldersGroupByRegion) + { + var apps = new SortedDictionary(); + + foreach (var game in root.Where(e => e is NesApplication)) + { + NesApplication app = game as NesApplication; + + var region = app.Desktop.Country; + if ((region ?? "") == "") region = "Unknown Region"; + + if (!apps.ContainsKey(region)) + { + apps[region] = new NesMenuCollection(); + } + + apps[region].Add(game); + } + + root.Clear(); + + foreach (var app in apps.Where(e => e.Value.Count > 0)) + { + string folderImageId = "folder"; + string folderName = app.Key; + + data.Region regionInfo = null; + if (data.Region.RegionDictionary.TryGetValue(app.Key, out regionInfo)) + { + //Presumably we want the folder names to be localised. Not sure why genre folders forces the English name... + folderName = regionInfo.LocalizedName; + } + + var folder = new NesMenuFolder() { ChildMenuCollection = app.Value, Name = folderName, Position = NesMenuFolder.Priority.Right, ImageId = folderImageId }; + + folder.ChildMenuCollection.Add(new NesMenuFolder() { Name = Resources.FolderNameBack, ImageId = "folder_back", Position = ConfigIni.Instance.BackFolderPosition, ChildMenuCollection = root }); + root.Add(folder); + } + } if (originalToRoot) { if (style != SplitStyle.PagesEqual) diff --git a/hakchi_gui/Tasks/LoadGamesTask.cs b/hakchi_gui/Tasks/LoadGamesTask.cs index ac5a3074..a327ad1a 100644 --- a/hakchi_gui/Tasks/LoadGamesTask.cs +++ b/hakchi_gui/Tasks/LoadGamesTask.cs @@ -78,7 +78,7 @@ public Tasker.Conclusion CreateListViewGroups(Tasker tasker, Object syncObject = normalGroups.Add(ViewGroup.All, new ListViewGroup(Resources.ListCategoryAll, h)); normalGroups.Add(ViewGroup.Unknown, new ListViewGroup(Resources.ListCategoryUnknown, h)); - // order by system/core groups + // order by system/core/region groups if (ConfigIni.Instance.GamesSorting == MainForm.GamesSorting.System) { foreach (var system in CoreCollection.Systems) @@ -94,6 +94,11 @@ public Tasker.Conclusion CreateListViewGroups(Tasker tasker, Object syncObject = foreach (var core in CoreCollection.Cores) sortedGroups[core.Bin] = new ListViewGroup(core.Name, h); } + else if (ConfigIni.Instance.GamesSorting == MainForm.GamesSorting.Region) + { + foreach (var region in data.Region.RegionList) + sortedGroups[region.DesktopName] = new ListViewGroup(region.LocalizedName, h); + } return Tasker.Conclusion.Success; } @@ -255,6 +260,10 @@ public Tasker.Conclusion AssignGroupsToGames(Tasker tasker, Object syncObject = else if (sortedGroups.ContainsKey(game.Metadata.Core)) group = sortedGroups[game.Metadata.Core]; break; + case MainForm.GamesSorting.Region: + if (sortedGroups.ContainsKey(game.Desktop.Country)) + group = sortedGroups[game.Desktop.Country]; + break; } } if (group == null) diff --git a/hakchi_gui/data/Region.cs b/hakchi_gui/data/Region.cs new file mode 100644 index 00000000..03d28460 --- /dev/null +++ b/hakchi_gui/data/Region.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace com.clusterrr.hakchi_gui.data +{ + public class Region + { + public string LocalizedName => Properties.Resources.ResourceManager.GetString(LocalizedNameKey); + + public string DesktopName { get; set; } + public string LocalizedNameKey { get; set; } + public string[] DefaultNames { get; set; } = new string[] { }; //Considered from database when importing (and possible scraping?). + + //DefaulNames have been populated with ones seen in the database but really this should be properly data driven... + public static IReadOnlyList RegionList = new List() + { + new Region(){ + DesktopName = "us", + LocalizedNameKey = "UnitedStates", + DefaultNames = new string[] { "United States", "US", "USA" } + }, + new Region(){ + DesktopName = "eu", + LocalizedNameKey = "Europe", + DefaultNames = new string[] { "Europe", "France", "Germany", "Spain", "Italy", "Sweden", "Netherlands", "Scandinavia", "United Kingdom", "UK" } + }, + new Region(){ + DesktopName = "jp", + LocalizedNameKey = "Japan", + DefaultNames = new string[] { "Japan" } + } + }; + public static Dictionary _RegionDictionary = null; + public static IReadOnlyDictionary RegionDictionary + { + get + { + if (_RegionDictionary == null) + { + _RegionDictionary = new Dictionary(); + + foreach (var region in RegionList.OrderBy(e => e.DesktopName)) + { + _RegionDictionary[region.DesktopName] = region; + } + } + + return _RegionDictionary; + } + } + } +}