From f872e5d62e5056895a89d4b31a7604dca5e1ceaa Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Fri, 8 Feb 2019 14:59:22 -0600 Subject: [PATCH] Convert all related operations to use new wine data fields --- GBM/Forms/frmGameManager.vb | 10 +++- GBM/Forms/frmMain.vb | 72 +++++++++++++++++++++++----- GBM/Managers/mgrPath.vb | 1 + GBM/Managers/mgrProcessDetection.vb | 10 ++++ GBM/Managers/mgrWineData.vb | 4 +- GBM/My Project/Resources.Designer.vb | 20 +++++++- GBM/My Project/Resources.resx | 8 +++- 7 files changed, 108 insertions(+), 17 deletions(-) diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index 6e42cbd..6454dd9 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -1370,8 +1370,14 @@ Public Class frmGameManager oApp.Parameter = txtParameter.Text oApp.OS = CType(cboOS.SelectedValue, clsGame.eOS) oApp.Path = mgrPath.ValidatePathForOS(txtSavePath.Text) - 'Only do a simple root check here in case the user doesn't really understand creating a proper configuration - oApp.AbsolutePath = Path.IsPathRooted(oApp.Path) + 'We need to handle a special case here when working with Windows configurations in Linux + If mgrCommon.IsUnix And mgrVariables.CheckForReservedVariables(oApp.Path) And oApp.OS = clsGame.eOS.Windows Then + oApp.AbsolutePath = True + Else + 'Only do a simple root check here in case the user doesn't really understand creating a proper configuration + oApp.AbsolutePath = Path.IsPathRooted(oApp.Path) + End If + oApp.FileType = txtFileType.Text oApp.ExcludeList = txtExclude.Text oApp.FolderSave = chkFolderSave.Checked diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index f18f1ec..38deaa5 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -167,11 +167,46 @@ Public Class frmMain OperationEnded() End Sub + Private Function VerifyBackupForOS(ByVal oGame As clsGame, ByRef sPath As String) As Boolean + Dim bOSVerified As Boolean + + 'Handle Windows configurations in Linux + If mgrCommon.IsUnix Then + If oGame.OS = clsGame.eOS.Windows Then + If mgrVariables.CheckForReservedVariables(oGame.TruePath) Then + 'Absolute Path + Dim oWineData As clsWineData = mgrWineData.DoWineDataGetbyID(oGame.ID) + If oWineData.SavePath <> String.Empty Then + sPath = oWineData.SavePath + bOSVerified = True + UpdateLog(mgrCommon.FormatString(frmMain_WineSavePath, New String() {oGame.Name, oWineData.SavePath}), False) + Else + bOSVerified = False + UpdateLog(mgrCommon.FormatString(frmMain_ErrorNoWineSavePath, oGame.Name), True, ToolTipIcon.Error, True) + End If + Else + 'Relative Path + bOSVerified = True + End If + mgrPath.ModWinePathData(oGame) + Else + 'Linux Configuration + bOSVerified = True + End If + Else + 'Windows + bOSVerified = True + End If + + Return bOSVerified + End Function + Private Sub RunRestore(ByVal oRestoreList As Hashtable) Dim oGame As clsGame Dim oReadyList As New List(Of clsBackup) Dim oRestoreInfo As clsBackup Dim bTriggerReload As Boolean = False + Dim bOSVerified As Boolean Dim bPathVerified As Boolean eCurrentOperation = eOperation.Restore OperationStarted() @@ -179,16 +214,19 @@ Public Class frmMain 'Build Restore List For Each de As DictionaryEntry In oRestoreList bPathVerified = False + bOSVerified = False oGame = DirectCast(de.Key, clsGame) oRestoreInfo = DirectCast(de.Value, clsBackup) + bOSVerified = VerifyBackupForOS(oGame, oRestoreInfo.RestorePath) + If mgrRestore.CheckPath(oRestoreInfo, oGame, bTriggerReload) Then bPathVerified = True Else UpdateLog(mgrCommon.FormatString(frmMain_ErrorRestorePath, oRestoreInfo.Name), False, ToolTipIcon.Error, True) End If - If bPathVerified Then + If bOSVerified And bPathVerified Then If oRestore.CheckRestorePrereq(oRestoreInfo, oGame.CleanFolder) Then oReadyList.Add(oRestoreInfo) End If @@ -212,6 +250,7 @@ Public Class frmMain Private Sub RunManualBackup(ByVal oBackupList As List(Of clsGame)) Dim oGame As clsGame Dim bNoAuto As Boolean + Dim bOSVerified As Boolean Dim bPathVerified As Boolean Dim oReadyList As New List(Of clsGame) @@ -221,11 +260,14 @@ Public Class frmMain 'Build Backup List For Each oGame In oBackupList bNoAuto = False + bOSVerified = False bPathVerified = False gMonStripStatusButton.Enabled = False UpdateLog(mgrCommon.FormatString(frmMain_ManualBackup, oGame.Name), False) + bOSVerified = VerifyBackupForOS(oGame, oGame.Path) + If oGame.AbsolutePath = False Then If oGame.ProcessPath = String.Empty Then If mgrCommon.IsProcessNotSearchable(oGame) Then bNoAuto = True @@ -241,7 +283,7 @@ Public Class frmMain bPathVerified = True End If - If bPathVerified Then + If bOSVerified And bPathVerified Then If oBackup.CheckBackupPrereq(oGame) Then oReadyList.Add(oGame) End If @@ -1936,15 +1978,18 @@ Public Class frmMain If bWineProcess Then 'Attempt a path conversion if the game configuration is using an absolute windows path that we can convert If mgrVariables.CheckForReservedVariables(oProcess.GameInfo.TruePath) Then - Dim sWinePrefix As String = mgrPath.GetWinePrefix(oProcess.FoundProcess) - Dim sWineSavePath As String - If Not sWinePrefix = String.Empty Then - UpdateLog(mgrCommon.FormatString(frmMain_WinePrefix, New String() {oProcess.GameInfo.Name, sWinePrefix}), False) - sWineSavePath = mgrPath.GetWineSavePath(sWinePrefix, oProcess.GameInfo.TruePath) - If Not sWineSavePath = oProcess.GameInfo.TruePath Then - oProcess.GameInfo.TruePath = sWineSavePath - oProcess.GameInfo.AbsolutePath = True - UpdateLog(mgrCommon.FormatString(frmMain_WineSavePath, New String() {oProcess.GameInfo.Name, sWineSavePath}), False) + Dim oWineData As New clsWineData + oWineData.MonitorID = oProcess.GameInfo.ID + oWineData.Prefix = mgrPath.GetWinePrefix(oProcess.FoundProcess) + oWineData.BinaryPath = Path.GetDirectoryName(oProcess.FoundProcess.MainModule.FileName) + UpdateLog(mgrCommon.FormatString(frmMain_WineBinaryPath, New String() {oProcess.GameInfo.Name, oWineData.BinaryPath}), False) + If Not oWineData.Prefix = String.Empty Then + UpdateLog(mgrCommon.FormatString(frmMain_WinePrefix, New String() {oProcess.GameInfo.Name, oWineData.Prefix}), False) + oWineData.SavePath = mgrPath.GetWineSavePath(oWineData.Prefix, oProcess.GameInfo.TruePath) + If Not oWineData.SavePath = oProcess.GameInfo.TruePath Then + oProcess.GameInfo.TruePath = oWineData.SavePath + oProcess.WineData = oWineData + UpdateLog(mgrCommon.FormatString(frmMain_WineSavePath, New String() {oProcess.GameInfo.Name, oWineData.SavePath}), False) Else bContinue = False End If @@ -2031,6 +2076,10 @@ Public Class frmMain UpdateLog(mgrCommon.FormatString(frmMain_GameEnded, oProcess.GameInfo.Name), False) If oSettings.TimeTracking Then HandleTimeSpent() If oSettings.SessionTracking Then HandleSession() + If Not oProcess.WineData Is Nothing Then + oProcess.WineData.MonitorID = oProcess.GameInfo.ID + mgrWineData.DoWineDataAddUpdate(oProcess.WineData) + End If RunBackup() Else UpdateLog(frmMain_UnknownGameEnded, False) @@ -2045,6 +2094,7 @@ Public Class frmMain bPathDetectionFailure = False sPathDetectionError = String.Empty bCancelledByUser = False + oProcess.WineData = Nothing oProcess.StartTime = Now : oProcess.EndTime = Now End Sub diff --git a/GBM/Managers/mgrPath.vb b/GBM/Managers/mgrPath.vb index 05bd10c..bee4047 100644 --- a/GBM/Managers/mgrPath.vb +++ b/GBM/Managers/mgrPath.vb @@ -497,6 +497,7 @@ Public Class mgrPath 'Don't use these in Unix If Not mgrCommon.IsUnix Then hshFolders.Add(Guid.NewGuid.ToString, Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)) + hshFolders.Add(Guid.NewGuid.ToString, Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)) hshFolders.Add(Guid.NewGuid.ToString, Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)) End If diff --git a/GBM/Managers/mgrProcessDetection.vb b/GBM/Managers/mgrProcessDetection.vb index 0aa19ce..cad4b8f 100644 --- a/GBM/Managers/mgrProcessDetection.vb +++ b/GBM/Managers/mgrProcessDetection.vb @@ -8,6 +8,7 @@ Public Class mgrProcessDetection Private dStartTime As DateTime = Now, dEndTime As DateTime = Now Private lTimeSpent As Long = 0 Private oGame As clsGame + Private oWineData As clsWineData Private oDuplicateGames As New ArrayList Private bDuplicates As Boolean Private bVerified As Boolean = False @@ -63,6 +64,15 @@ Public Class mgrProcessDetection End Set End Property + Property WineData As clsWineData + Get + Return oWineData + End Get + Set(value As clsWineData) + oWineData = value + End Set + End Property + Property Duplicate As Boolean Get Return bDuplicates diff --git a/GBM/Managers/mgrWineData.vb b/GBM/Managers/mgrWineData.vb index 151904f..3bc4c82 100644 --- a/GBM/Managers/mgrWineData.vb +++ b/GBM/Managers/mgrWineData.vb @@ -5,8 +5,8 @@ oWineGame.MonitorID = CStr(dr("MonitorID")) If Not IsDBNull(dr("Prefix")) Then oWineGame.Prefix = CStr(dr("Prefix")) - If Not IsDBNull(dr("SavePath")) Then oWineGame.Prefix = CStr(dr("SavePath")) - If Not IsDBNull(dr("BinaryPath")) Then oWineGame.Prefix = CStr(dr("BinaryPath")) + If Not IsDBNull(dr("SavePath")) Then oWineGame.SavePath = CStr(dr("SavePath")) + If Not IsDBNull(dr("BinaryPath")) Then oWineGame.BinaryPath = CStr(dr("BinaryPath")) Return oWineGame End Function diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 6bc4674..e8a91d6 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -3336,6 +3336,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to [PARAM] uses a Windows configuration and requires a Wine save path to perform this operation.. + ''' + Friend ReadOnly Property frmMain_ErrorNoWineSavePath() As String + Get + Return ResourceManager.GetString("frmMain_ErrorNoWineSavePath", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to [PARAM] uses a relative path and has never been detected on this computer.. ''' @@ -4056,6 +4065,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to [PARAM] Wine Binary Path: [PARAM]. + ''' + Friend ReadOnly Property frmMain_WineBinaryPath() As String + Get + Return ResourceManager.GetString("frmMain_WineBinaryPath", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to [PARAM] Wine Prefix: [PARAM]. ''' @@ -4066,7 +4084,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to [PARAM] Converted Save Path: [PARAM]. + ''' Looks up a localized string similar to [PARAM] Wine Save Path: [PARAM]. ''' Friend ReadOnly Property frmMain_WineSavePath() As String Get diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 2094202..2ae56a7 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -2207,7 +2207,7 @@ [PARAM] Wine Prefix: [PARAM] - [PARAM] Converted Save Path: [PARAM] + [PARAM] Wine Save Path: [PARAM] An error occured when building a Wine path.[BR][BR][PARAM] @@ -2296,4 +2296,10 @@ OS + + [PARAM] Wine Binary Path: [PARAM] + + + [PARAM] uses a Windows configuration and requires a Wine save path to perform this operation. + \ No newline at end of file