From 609ee09cfa85a76caf06e4c3239f4cdaee97943a Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Fri, 2 Mar 2018 12:00:00 -0600 Subject: [PATCH] Added ability to edit game ID and updated validation --- GBM/Forms/frmAddWizard.vb | 19 ++------- GBM/Forms/frmGameManager.Designer.vb | 48 +++++++++++++-------- GBM/Forms/frmGameManager.vb | 63 ++++++++++++++++++++++++---- GBM/Managers/mgrMonitorList.vb | 28 +++++++------ GBM/My Project/Resources.Designer.vb | 29 ++++++++++++- GBM/My Project/Resources.resx | 11 ++++- 6 files changed, 143 insertions(+), 55 deletions(-) diff --git a/GBM/Forms/frmAddWizard.vb b/GBM/Forms/frmAddWizard.vb index 2740b5d..57bbe29 100644 --- a/GBM/Forms/frmAddWizard.vb +++ b/GBM/Forms/frmAddWizard.vb @@ -264,22 +264,11 @@ Public Class frmAddWizard End Function Private Sub DoSave() - Dim hshDupeCheck As New Hashtable - Dim sNewGame As String = oGameToSave.CompoundKey - - For Each o As clsGame In GameData.Values - hshDupeCheck.Add(o.CompoundKey, String.Empty) - Next - - If hshDupeCheck.Contains(sNewGame) Then - mgrCommon.ShowMessage(frmAddWizard_ErrorGameDupe, MsgBoxStyle.Exclamation) - Else - mgrMonitorList.DoListAdd(oGameToSave) - If mgrCommon.ShowMessage(frmAddWizard_ConfirmSaveTags, New String() {oGameToSave.Name, oGameToSave.Name}, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then - OpenTags(oGameToSave) - End If - Me.Close() + mgrMonitorList.DoListAdd(oGameToSave) + If mgrCommon.ShowMessage(frmAddWizard_ConfirmSaveTags, New String() {oGameToSave.Name, oGameToSave.Name}, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + OpenTags(oGameToSave) End If + Me.Close() End Sub Private Sub ValidateBack() diff --git a/GBM/Forms/frmGameManager.Designer.vb b/GBM/Forms/frmGameManager.Designer.vb index e69e342..b2c2604 100644 --- a/GBM/Forms/frmGameManager.Designer.vb +++ b/GBM/Forms/frmGameManager.Designer.vb @@ -101,6 +101,7 @@ Partial Class frmGameManager Me.cmsDeleteBackup = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.cmsDeleteOne = New System.Windows.Forms.ToolStripMenuItem() Me.cmsDeleteAll = New System.Windows.Forms.ToolStripMenuItem() + Me.btnGameID = New System.Windows.Forms.Button() Me.grpConfig.SuspendLayout() CType(Me.nudLimit, System.ComponentModel.ISupportInitialize).BeginInit() Me.grpExtra.SuspendLayout() @@ -157,6 +158,7 @@ Partial Class frmGameManager 'grpConfig ' Me.grpConfig.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.grpConfig.Controls.Add(Me.btnGameID) Me.grpConfig.Controls.Add(Me.chkRegEx) Me.grpConfig.Controls.Add(Me.lblComments) Me.grpConfig.Controls.Add(Me.txtComments) @@ -194,7 +196,7 @@ Partial Class frmGameManager Me.chkRegEx.Location = New System.Drawing.Point(402, 46) Me.chkRegEx.Name = "chkRegEx" Me.chkRegEx.Size = New System.Drawing.Size(117, 17) - Me.chkRegEx.TabIndex = 5 + Me.chkRegEx.TabIndex = 6 Me.chkRegEx.Text = "Regular Expression" Me.chkRegEx.UseVisualStyleBackColor = True ' @@ -204,7 +206,7 @@ Partial Class frmGameManager Me.lblComments.Location = New System.Drawing.Point(7, 181) Me.lblComments.Name = "lblComments" Me.lblComments.Size = New System.Drawing.Size(59, 13) - Me.lblComments.TabIndex = 18 + Me.lblComments.TabIndex = 19 Me.lblComments.Text = "Comments:" ' 'txtComments @@ -214,14 +216,14 @@ Partial Class frmGameManager Me.txtComments.Name = "txtComments" Me.txtComments.ScrollBars = System.Windows.Forms.ScrollBars.Vertical Me.txtComments.Size = New System.Drawing.Size(413, 71) - Me.txtComments.TabIndex = 19 + Me.txtComments.TabIndex = 20 ' 'txtParameter ' Me.txtParameter.Location = New System.Drawing.Point(70, 71) Me.txtParameter.Name = "txtParameter" Me.txtParameter.Size = New System.Drawing.Size(414, 20) - Me.txtParameter.TabIndex = 7 + Me.txtParameter.TabIndex = 8 ' 'lblParameter ' @@ -229,7 +231,7 @@ Partial Class frmGameManager Me.lblParameter.Location = New System.Drawing.Point(7, 74) Me.lblParameter.Name = "lblParameter" Me.lblParameter.Size = New System.Drawing.Size(58, 13) - Me.lblParameter.TabIndex = 6 + Me.lblParameter.TabIndex = 7 Me.lblParameter.Text = "Parameter:" ' 'chkCleanFolder @@ -248,7 +250,7 @@ Partial Class frmGameManager Me.lblLimit.Location = New System.Drawing.Point(376, 157) Me.lblLimit.Name = "lblLimit" Me.lblLimit.Size = New System.Drawing.Size(68, 13) - Me.lblLimit.TabIndex = 17 + Me.lblLimit.TabIndex = 18 Me.lblLimit.Text = "Backup Limit" Me.lblLimit.Visible = False ' @@ -258,7 +260,7 @@ Partial Class frmGameManager Me.nudLimit.Minimum = New Decimal(New Integer() {2, 0, 0, 0}) Me.nudLimit.Name = "nudLimit" Me.nudLimit.Size = New System.Drawing.Size(40, 20) - Me.nudLimit.TabIndex = 16 + Me.nudLimit.TabIndex = 17 Me.nudLimit.Value = New Decimal(New Integer() {2, 0, 0, 0}) Me.nudLimit.Visible = False ' @@ -267,7 +269,7 @@ Partial Class frmGameManager Me.btnExclude.Location = New System.Drawing.Point(10, 152) Me.btnExclude.Name = "btnExclude" Me.btnExclude.Size = New System.Drawing.Size(175, 23) - Me.btnExclude.TabIndex = 12 + Me.btnExclude.TabIndex = 15 Me.btnExclude.Text = "E&xclude Items..." Me.btnExclude.UseVisualStyleBackColor = True ' @@ -276,14 +278,14 @@ Partial Class frmGameManager Me.btnInclude.Location = New System.Drawing.Point(10, 123) Me.btnInclude.Name = "btnInclude" Me.btnInclude.Size = New System.Drawing.Size(175, 23) - Me.btnInclude.TabIndex = 11 + Me.btnInclude.TabIndex = 12 Me.btnInclude.Text = "In&clude Items..." Me.btnInclude.UseVisualStyleBackColor = True ' 'txtID ' Me.txtID.Enabled = False - Me.txtID.Location = New System.Drawing.Point(489, 19) + Me.txtID.Location = New System.Drawing.Point(489, 180) Me.txtID.Name = "txtID" Me.txtID.Size = New System.Drawing.Size(30, 20) Me.txtID.TabIndex = 0 @@ -295,7 +297,7 @@ Partial Class frmGameManager Me.btnSavePathBrowse.Location = New System.Drawing.Point(490, 97) Me.btnSavePathBrowse.Name = "btnSavePathBrowse" Me.btnSavePathBrowse.Size = New System.Drawing.Size(30, 20) - Me.btnSavePathBrowse.TabIndex = 10 + Me.btnSavePathBrowse.TabIndex = 11 Me.btnSavePathBrowse.Text = "..." Me.btnSavePathBrowse.UseVisualStyleBackColor = True ' @@ -304,7 +306,7 @@ Partial Class frmGameManager Me.btnProcessBrowse.Location = New System.Drawing.Point(366, 44) Me.btnProcessBrowse.Name = "btnProcessBrowse" Me.btnProcessBrowse.Size = New System.Drawing.Size(30, 20) - Me.btnProcessBrowse.TabIndex = 4 + Me.btnProcessBrowse.TabIndex = 5 Me.btnProcessBrowse.Text = "..." Me.btnProcessBrowse.UseVisualStyleBackColor = True ' @@ -314,7 +316,7 @@ Partial Class frmGameManager Me.lblSavePath.Location = New System.Drawing.Point(7, 101) Me.lblSavePath.Name = "lblSavePath" Me.lblSavePath.Size = New System.Drawing.Size(60, 13) - Me.lblSavePath.TabIndex = 8 + Me.lblSavePath.TabIndex = 9 Me.lblSavePath.Text = "Save Path:" ' 'lblProcess @@ -323,7 +325,7 @@ Partial Class frmGameManager Me.lblProcess.Location = New System.Drawing.Point(7, 47) Me.lblProcess.Name = "lblProcess" Me.lblProcess.Size = New System.Drawing.Size(48, 13) - Me.lblProcess.TabIndex = 2 + Me.lblProcess.TabIndex = 3 Me.lblProcess.Text = "Process:" ' 'lblName @@ -359,7 +361,7 @@ Partial Class frmGameManager Me.chkTimeStamp.Location = New System.Drawing.Point(191, 156) Me.chkTimeStamp.Name = "chkTimeStamp" Me.chkTimeStamp.Size = New System.Drawing.Size(133, 17) - Me.chkTimeStamp.TabIndex = 15 + Me.chkTimeStamp.TabIndex = 16 Me.chkTimeStamp.Text = "Save multiple backups" Me.chkTimeStamp.UseVisualStyleBackColor = True ' @@ -378,20 +380,20 @@ Partial Class frmGameManager Me.txtSavePath.Location = New System.Drawing.Point(70, 97) Me.txtSavePath.Name = "txtSavePath" Me.txtSavePath.Size = New System.Drawing.Size(414, 20) - Me.txtSavePath.TabIndex = 9 + Me.txtSavePath.TabIndex = 10 ' 'txtProcess ' Me.txtProcess.Location = New System.Drawing.Point(70, 44) Me.txtProcess.Name = "txtProcess" Me.txtProcess.Size = New System.Drawing.Size(290, 20) - Me.txtProcess.TabIndex = 3 + Me.txtProcess.TabIndex = 4 ' 'txtName ' Me.txtName.Location = New System.Drawing.Point(70, 19) Me.txtName.Name = "txtName" - Me.txtName.Size = New System.Drawing.Size(414, 20) + Me.txtName.Size = New System.Drawing.Size(326, 20) Me.txtName.TabIndex = 1 ' 'chkMonitorOnly @@ -873,6 +875,15 @@ Partial Class frmGameManager Me.cmsDeleteAll.Size = New System.Drawing.Size(114, 22) Me.cmsDeleteAll.Text = "&All Files" ' + 'btnGameID + ' + Me.btnGameID.Location = New System.Drawing.Point(402, 17) + Me.btnGameID.Name = "btnGameID" + Me.btnGameID.Size = New System.Drawing.Size(117, 23) + Me.btnGameID.TabIndex = 2 + Me.btnGameID.Text = "&Game ID..." + Me.btnGameID.UseVisualStyleBackColor = True + ' 'frmGameManager ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -1000,4 +1011,5 @@ Partial Class frmGameManager Friend WithEvents lblComments As Label Friend WithEvents txtComments As TextBox Friend WithEvents chkRegEx As CheckBox + Friend WithEvents btnGameID As Button End Class diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index 386c7fb..3c15590 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -430,6 +430,28 @@ Public Class frmGameManager IsLoading = False End Sub + Private Sub OpenGameIDEdit() + Dim sCurrentID As String + Dim sNewID As String + + If txtID.Text = String.Empty Then + txtID.Text = Guid.NewGuid.ToString + End If + + sCurrentID = txtID.Text + + sNewID = InputBox(frmGameManager_GameIDEditInfo, frmGameManager_GameIDEditTitle, sCurrentID) + + If sNewID <> String.Empty Then + txtID.Text = sNewID + + If sCurrentID <> sNewID Then + UpdateGenericButtonLabel(frmGameManager_btnGameID, btnGameID, True) + End If + End If + + End Sub + Private Sub OpenBackupFile() Dim sFileName As String Dim oProcessStartInfo As ProcessStartInfo @@ -463,6 +485,16 @@ Public Class frmGameManager End If End Sub + Private Sub UpdateGenericButtonLabel(ByVal sLabel As String, ByVal btn As Button, ByVal bDirty As Boolean) + btn.Text = sLabel + + If bDirty Then + btn.Font = New Font(FontFamily.GenericSansSerif, 8.25, FontStyle.Bold) + Else + btn.Font = New Font(FontFamily.GenericSansSerif, 8.25, FontStyle.Regular) + End If + End Sub + Private Function GetBuilderRoot() As String Dim sRoot As String = String.Empty @@ -750,6 +782,7 @@ Public Class frmGameManager 'Update Buttons UpdateBuilderButtonLabel(oApp.FileType, frmGameManager_IncludeShortcut, btnInclude, False) UpdateBuilderButtonLabel(oApp.ExcludeList, frmGameManager_ExcludeShortcut, btnExclude, False) + UpdateGenericButtonLabel(frmGameManager_btnGameID, btnGameID, False) 'Extra txtAppPath.Text = oApp.ProcessPath @@ -975,6 +1008,9 @@ Public Class frmGameManager btnExclude.Text = frmGameManager_btnExclude btnImport.Enabled = True btnExport.Enabled = True + UpdateGenericButtonLabel(frmGameManager_IncludeShortcut, btnInclude, False) + UpdateGenericButtonLabel(frmGameManager_ExcludeShortcut, btnExclude, False) + UpdateGenericButtonLabel(frmGameManager_btnGameID, btnGameID, False) Case eModes.MultiSelect lstGames.Enabled = True lblQuickFilter.Enabled = False @@ -1163,17 +1199,17 @@ Public Class frmGameManager Select Case eCurrentMode Case eModes.Add - If CoreValidatation(oApp) Then + If CoreValidatation(oApp, True) Then bSuccess = True mgrMonitorList.DoListAdd(oApp) SaveTags(oApp.ID) eCurrentMode = eModes.View End If Case eModes.Edit - If CoreValidatation(oApp) Then + If CoreValidatation(oApp, False) Then bSuccess = True - mgrMonitorList.DoListUpdate(oApp) CheckManifestandUpdate(oCurrentGame, oApp) + mgrMonitorList.DoListUpdate(oApp, CurrentGame.ID) eCurrentMode = eModes.View End If Case eModes.MultiSelect @@ -1250,7 +1286,15 @@ Public Class frmGameManager End If End Sub - Private Function CoreValidatation(ByVal oApp As clsGame) As Boolean + Private Function CoreValidatation(ByVal oApp As clsGame, ByVal bNewGame As Boolean) As Boolean + Dim sCurrentID As String + + If bNewGame Then + sCurrentID = String.Empty + Else + sCurrentID = CurrentGame.ID + End If + If txtName.Text.Trim = String.Empty Then mgrCommon.ShowMessage(frmGameManager_ErrorValidName, MsgBoxStyle.Exclamation) txtName.Focus() @@ -1269,14 +1313,14 @@ Public Class frmGameManager Return False End If - If mgrMonitorList.DoDuplicateListCheck(oApp.Name, oApp.ProcessName, , oApp.ID) Then - mgrCommon.ShowMessage(frmGameManager_ErrorGameDupe, MsgBoxStyle.Exclamation) + If mgrMonitorList.DoDuplicateListCheck(oApp.ID, , sCurrentID) Then + mgrCommon.ShowMessage(frmGameManager_ErrorGameDupe, oApp.ID, MsgBoxStyle.Exclamation) txtName.Focus() Return False End If If oApp.Parameter <> String.Empty Then - If mgrMonitorList.DoDuplicateParameterCheck(oApp.ProcessName, oApp.Parameter, , oApp.ID) Then + If mgrMonitorList.DoDuplicateParameterCheck(oApp.ProcessName, oApp.Parameter, , sCurrentID) Then mgrCommon.ShowMessage(frmGameManager_ErrorProcessParameterDupe, MsgBoxStyle.Exclamation) Return False End If @@ -1537,6 +1581,7 @@ Public Class frmGameManager cmsDeleteAll.Text = frmGameManager_cmsDeleteAll lblComments.Text = frmGameManager_lblComments chkRegEx.Text = frmGameManager_chkRegEx + btnGameID.Text = frmGameManager_btnGameID 'Init Filter Timer tmFilterTimer = New Timer() @@ -1716,6 +1761,10 @@ Public Class frmGameManager ExportGameList() End Sub + Private Sub btnGameID_Click(sender As Object, e As EventArgs) Handles btnGameID.Click + OpenGameIDEdit() + End Sub + Private Sub txtQuickFilter_TextChanged(sender As Object, e As EventArgs) Handles txtQuickFilter.TextChanged If Not tmFilterTimer.Enabled Then tmFilterTimer.Enabled = True diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index eb1b16e..100db25 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -142,18 +142,23 @@ Public Class mgrMonitorList End Sub - Public Shared Sub DoListUpdate(ByVal oGame As clsGame, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) + Public Shared Sub DoListUpdate(ByVal oGame As clsGame, Optional ByVal sQueryID As String = "", Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) Dim oDatabase As New mgrSQLite(iSelectDB) Dim sSQL As String Dim hshParams As Hashtable - sSQL = "UPDATE monitorlist SET Name=@Name, Process=@Process, Path=@Path, AbsolutePath=@AbsolutePath, FolderSave=@FolderSave, " + sSQL = "UPDATE monitorlist SET MonitorID=@ID, Name=@Name, Process=@Process, Path=@Path, AbsolutePath=@AbsolutePath, FolderSave=@FolderSave, " sSQL &= "FileType=@FileType, TimeStamp=@TimeStamp, ExcludeList=@ExcludeList, ProcessPath=@ProcessPath, Icon=@Icon, " sSQL &= "Hours=@Hours, Version=@Version, Company=@Company, Enabled=@Enabled, MonitorOnly=@MonitorOnly, BackupLimit=@BackupLimit, " - sSQL &= "CleanFolder=@CleanFolder, Parameter=@Parameter, Comments=@Comments, IsRegEx=@IsRegEx WHERE MonitorID=@ID" + sSQL &= "CleanFolder=@CleanFolder, Parameter=@Parameter, Comments=@Comments, IsRegEx=@IsRegEx WHERE MonitorID=@QueryID" 'Parameters hshParams = SetCoreParameters(oGame) + If sQueryID <> String.Empty Then + hshParams.Add("QueryID", sQueryID) + Else + hshParams.Add("QueryID", oGame.ID) + End If oDatabase.RunParamQuery(sSQL, hshParams) @@ -295,7 +300,7 @@ Public Class mgrMonitorList Dim hshParams As New Hashtable Dim iCounter As Integer = 0 - sSQL = "SELECT * from monitorlist " + sSQL = "SELECT * FROM monitorlist " sSQL &= "WHERE MonitorID = @MonitorID" hshParams.Add("MonitorID", sMonitorID) @@ -311,20 +316,19 @@ Public Class mgrMonitorList Return hshGames End Function - Public Shared Function DoDuplicateListCheck(ByVal sName As String, ByVal sProcess As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local, Optional ByVal sExcludeID As String = "") As Boolean + Public Shared Function DoDuplicateListCheck(ByVal sMonitorID As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local, Optional ByVal sExcludeID As String = "") As Boolean Dim oDatabase As New mgrSQLite(iSelectDB) Dim sSQL As String Dim oData As DataSet Dim hshParams As New Hashtable - sSQL = "SELECT * FROM monitorlist WHERE Name = @Name AND Process= @Process" + sSQL = "SELECT * FROM monitorlist WHERE MonitorID = @MonitorID" - hshParams.Add("Name", sName) - hshParams.Add("Process", sProcess) + hshParams.Add("MonitorID", sMonitorID) If sExcludeID <> String.Empty Then - sSQL &= " AND MonitorID <> @MonitorID" - hshParams.Add("MonitorID", sExcludeID) + sSQL &= " AND MonitorID <> @QueryID" + hshParams.Add("QueryID", sExcludeID) End If oData = oDatabase.ReadParamData(sSQL, hshParams) @@ -478,13 +482,11 @@ Public Class mgrMonitorList sSQL &= "WHERE MonitorID = @MonitorID;" End If sSQL &= "DELETE FROM monitorlist " - sSQL &= "WHERE Name = @Name AND Process= @Process;" + sSQL &= "WHERE MonitorID = @MonitorID;" For Each oGame As clsGame In hshGames.Values hshParams = New Hashtable hshParams.Add("MonitorID", oGame.ID) - hshParams.Add("Name", oGame.Name) - hshParams.Add("Process", oGame.TrueProcess) oParamList.Add(hshParams) Next diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 891c4dc..7aa4b64 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -1500,6 +1500,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to &Game ID.... + ''' + Friend ReadOnly Property frmGameManager_btnGameID() As String + Get + Return ResourceManager.GetString("frmGameManager_btnGameID", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to .... ''' @@ -1906,7 +1915,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to A game with this exact name and process already exists.. + ''' Looks up a localized string similar to A game with the same ID ([PARAM]) already exists.. ''' Friend ReadOnly Property frmGameManager_ErrorGameDupe() As String Get @@ -2040,6 +2049,24 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to The unique Game ID is generated by GBM. Changing this value is not recommended.. + ''' + Friend ReadOnly Property frmGameManager_GameIDEditInfo() As String + Get + Return ResourceManager.GetString("frmGameManager_GameIDEditInfo", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Edit Game ID. + ''' + Friend ReadOnly Property frmGameManager_GameIDEditTitle() As String + Get + Return ResourceManager.GetString("frmGameManager_GameIDEditTitle", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Configuration. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 4bddb10..cebb1c5 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -554,7 +554,7 @@ [PARAM] is already up to date.[BR][BR]Would you like to restore this backup anyway? - A game with this exact name and process already exists. + A game with the same ID ([PARAM]) already exists. The selected game(s) have no backup data or can't be restored with their current configuration. @@ -2023,4 +2023,13 @@ The process is not a a valid regular expression.[BR][BR]Would you like help validating and testing your regular expression? [BR][BR]This will open your web browser and requires the internet. + + &Game ID... + + + The unique Game ID is generated by GBM. Changing this value is not recommended. + + + Edit Game ID + \ No newline at end of file