From f9b325ae6784b641046c36fe1d767dc3906f0afc Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Sun, 30 Sep 2018 14:58:53 -0600 Subject: [PATCH] Import tag mods for #148 --- GBM/Forms/frmAdvancedImport.vb | 79 ++++++++++++++++++++++++++++++++++ GBM/Forms/frmGameManager.vb | 10 +++-- GBM/Managers/mgrMonitorList.vb | 9 ++-- 3 files changed, 90 insertions(+), 8 deletions(-) diff --git a/GBM/Forms/frmAdvancedImport.vb b/GBM/Forms/frmAdvancedImport.vb index c6a6d35..60d0a6b 100644 --- a/GBM/Forms/frmAdvancedImport.vb +++ b/GBM/Forms/frmAdvancedImport.vb @@ -6,6 +6,7 @@ Public Class frmAdvancedImport Private oImportData As ExportData Private hshImportData As Hashtable Private hshFinalData As New Hashtable + Private bModWinConfigsForLinux As Boolean Private bSelectAll As Boolean = True Private bIsLoading As Boolean = False Private iCurrentSort As Integer = 0 @@ -30,12 +31,23 @@ Public Class frmAdvancedImport End Get End Property + Public Property ModWinConfigsForLinux As Boolean + Set(value As Boolean) + bModWinConfigsForLinux = value + End Set + Get + Return bModWinConfigsForLinux + End Get + End Property + Public ReadOnly Property FinalData As Hashtable Get Return hshFinalData End Get End Property + + Private Sub SelectToggle() Cursor.Current = Cursors.WaitCursor lstGames.BeginUpdate() @@ -56,6 +68,62 @@ Public Class frmAdvancedImport End If End Sub + Private Sub ModTags(ByRef oTags As List(Of Tag)) + Dim bExists As Boolean + Dim oTag As Tag + Dim oNewTag As Tag + Dim oRemoveTag As New Tag + Dim sTag As String + Dim sAddTags() As String = {"Wine"} + Dim sRemoveTags() As String = {"Official"} + + For Each sTag In sAddTags + bExists = False + For Each oTag In oTags + If oTag.Name = sTag Then + bExists = True + Exit For + End If + Next + If Not bExists Then + oNewTag = New Tag + oNewTag.Name = sTag + oTags.Add(oNewTag) + End If + Next + + For Each sTag In sRemoveTags + bExists = False + For Each oTag In oTags + If oTag.Name = sTag Then + bExists = True + oRemoveTag = oTag + Exit For + End If + Next + If bExists Then + oTags.Remove(oRemoveTag) + End If + Next + + End Sub + + Private Function CheckIgnoreTags(ByVal oTags As List(Of Tag)) As Boolean + Dim oTag As Tag + Dim sTag As String + Dim sIgnoreTags() As String = {"DOSBox", "ScummVM"} + + For Each oTag In oTags + For Each sTag In sIgnoreTags + If oTag.Name = sTag Then + Return False + End If + Next + Next + + Return True + End Function + Private Sub LoadData(Optional ByVal sFilter As String = "", Optional ByVal bAutoDetect As Boolean = False) Dim oApp As clsGame Dim oListViewItem As ListViewItem @@ -75,6 +143,12 @@ Public Class frmAdvancedImport For Each de As DictionaryEntry In ImportData bAddItem = False oApp = DirectCast(de.Value, clsGame) + + 'Run any required tag mods + If ModWinConfigsForLinux Then + ModTags(oApp.ImportTags) + End If + sTags = String.Empty oApp.ImportTags.Sort(AddressOf mgrCommon.CompareImportTagsByName) For Each oTag As Tag In oApp.ImportTags @@ -119,6 +193,11 @@ Public Class frmAdvancedImport End If End If + 'Check for hardcoded ignore tags + If ModWinConfigsForLinux Then + bAddItem = CheckIgnoreTags(oApp.ImportTags) + End If + If bAddItem Then If oListViewItem.Checked Then bResetSelectAll = True lstGames.Items.Add(oListViewItem) diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index 913ca68..d45b4b1 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -1704,9 +1704,9 @@ Public Class frmGameManager End Sub - Private Sub ImportOfficialGameList(ByVal sImportUrl As String) + Private Sub ImportOfficialGameList(ByVal sImportUrl As String, ByVal bWinConfigsInLinux As Boolean) If mgrCommon.ShowMessage(frmGameManager_ConfirmOfficialImport, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then - If mgrMonitorList.DoImport(sImportUrl, True, Settings) Then + If mgrMonitorList.DoImport(sImportUrl, True, Settings,, bWinConfigsInLinux) Then mgrMonitorList.SyncMonitorLists(Settings) LoadData() LoadBackupData() @@ -1971,6 +1971,7 @@ Public Class frmGameManager End Sub Private Sub cmsOfficialWindows_Click(sender As Object, e As EventArgs) Handles cmsOfficialWindows.Click, cmsOfficial.Click + Dim bWinConfigsinLinux As Boolean = False 'Show one time warning about Windows configs in Linux If mgrCommon.IsUnix Then If Not (oSettings.SuppressMessages And mgrSettings.eSuppressMessages.WinConfigsInLinux) = mgrSettings.eSuppressMessages.WinConfigsInLinux Then @@ -1978,13 +1979,14 @@ Public Class frmGameManager oSettings.SuppressMessages = oSettings.SetMessageField(oSettings.SuppressMessages, mgrSettings.eSuppressMessages.WinConfigsInLinux) oSettings.SaveSettings() End If + bWinConfigsinLinux = True End If - ImportOfficialGameList(App_URLImport) + ImportOfficialGameList(App_URLImport, bWinConfigsinLinux) End Sub Private Sub cmsOfficialLinux_Click(sender As Object, e As EventArgs) Handles cmsOfficialLinux.Click - ImportOfficialGameList(App_URLImportLinux) + ImportOfficialGameList(App_URLImportLinux, False) End Sub Private Sub cmsFile_Click(sender As Object, e As EventArgs) Handles cmsFile.Click diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index 232cc80..d66f33e 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -788,13 +788,13 @@ Public Class mgrMonitorList Return True End Function - Public Shared Function DoImport(ByVal sPath As String, ByVal bOfficial As Boolean, ByRef oSettings As mgrSettings, Optional ByVal bStartUpWizard As Boolean = False) As Boolean + Public Shared Function DoImport(ByVal sPath As String, ByVal bOfficial As Boolean, ByRef oSettings As mgrSettings, Optional ByVal bStartUpWizard As Boolean = False, Optional ByVal bWinConfigsInLinux As Boolean = False) As Boolean If mgrCommon.IsAddress(sPath) Then If mgrCommon.CheckAddress(sPath) Then If bOfficial And Not bStartUpWizard And Not ((oSettings.SuppressMessages And mgrSettings.eSuppressMessages.GameIDSync) = mgrSettings.eSuppressMessages.GameIDSync) Then SyncGameIDs(sPath, oSettings, True) End If - ImportMonitorList(sPath, True) + ImportMonitorList(sPath, True, bWinConfigsInLinux) Return True Else mgrCommon.ShowMessage(mgrMonitorList_WebNoReponse, sPath, MsgBoxStyle.Exclamation) @@ -802,7 +802,7 @@ Public Class mgrMonitorList End If Else If File.Exists(sPath) Then - ImportMonitorList(sPath) + ImportMonitorList(sPath,, bWinConfigsInLinux) Return True Else mgrCommon.ShowMessage(mgrMonitorList_FileNotFound, sPath, MsgBoxStyle.Exclamation) @@ -812,7 +812,7 @@ Public Class mgrMonitorList Return True End Function - Private Shared Sub ImportMonitorList(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) + Private Shared Sub ImportMonitorList(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False, Optional ByVal bWinConfigsInLinux As Boolean = False) Dim hshCompareFrom As New Hashtable Dim hshCompareTo As Hashtable Dim hshSyncItems As Hashtable @@ -859,6 +859,7 @@ Public Class mgrMonitorList Dim frm As New frmAdvancedImport frm.ImportInfo = oExportInfo frm.ImportData = hshSyncItems + frm.ModWinConfigsForLinux = bWinConfigsInLinux If frm.ShowDialog() = DialogResult.OK Then Cursor.Current = Cursors.WaitCursor