Convert all related operations to use new wine data fields

This commit is contained in:
Michael J. Seiferling
2019-02-08 14:59:22 -06:00
parent e1f2aef863
commit f872e5d62e
7 changed files with 108 additions and 17 deletions
+6
View File
@@ -1370,8 +1370,14 @@ Public Class frmGameManager
oApp.Parameter = txtParameter.Text oApp.Parameter = txtParameter.Text
oApp.OS = CType(cboOS.SelectedValue, clsGame.eOS) oApp.OS = CType(cboOS.SelectedValue, clsGame.eOS)
oApp.Path = mgrPath.ValidatePathForOS(txtSavePath.Text) oApp.Path = mgrPath.ValidatePathForOS(txtSavePath.Text)
'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 '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) oApp.AbsolutePath = Path.IsPathRooted(oApp.Path)
End If
oApp.FileType = txtFileType.Text oApp.FileType = txtFileType.Text
oApp.ExcludeList = txtExclude.Text oApp.ExcludeList = txtExclude.Text
oApp.FolderSave = chkFolderSave.Checked oApp.FolderSave = chkFolderSave.Checked
+61 -11
View File
@@ -167,11 +167,46 @@ Public Class frmMain
OperationEnded() OperationEnded()
End Sub 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) Private Sub RunRestore(ByVal oRestoreList As Hashtable)
Dim oGame As clsGame Dim oGame As clsGame
Dim oReadyList As New List(Of clsBackup) Dim oReadyList As New List(Of clsBackup)
Dim oRestoreInfo As clsBackup Dim oRestoreInfo As clsBackup
Dim bTriggerReload As Boolean = False Dim bTriggerReload As Boolean = False
Dim bOSVerified As Boolean
Dim bPathVerified As Boolean Dim bPathVerified As Boolean
eCurrentOperation = eOperation.Restore eCurrentOperation = eOperation.Restore
OperationStarted() OperationStarted()
@@ -179,16 +214,19 @@ Public Class frmMain
'Build Restore List 'Build Restore List
For Each de As DictionaryEntry In oRestoreList For Each de As DictionaryEntry In oRestoreList
bPathVerified = False bPathVerified = False
bOSVerified = False
oGame = DirectCast(de.Key, clsGame) oGame = DirectCast(de.Key, clsGame)
oRestoreInfo = DirectCast(de.Value, clsBackup) oRestoreInfo = DirectCast(de.Value, clsBackup)
bOSVerified = VerifyBackupForOS(oGame, oRestoreInfo.RestorePath)
If mgrRestore.CheckPath(oRestoreInfo, oGame, bTriggerReload) Then If mgrRestore.CheckPath(oRestoreInfo, oGame, bTriggerReload) Then
bPathVerified = True bPathVerified = True
Else Else
UpdateLog(mgrCommon.FormatString(frmMain_ErrorRestorePath, oRestoreInfo.Name), False, ToolTipIcon.Error, True) UpdateLog(mgrCommon.FormatString(frmMain_ErrorRestorePath, oRestoreInfo.Name), False, ToolTipIcon.Error, True)
End If End If
If bPathVerified Then If bOSVerified And bPathVerified Then
If oRestore.CheckRestorePrereq(oRestoreInfo, oGame.CleanFolder) Then If oRestore.CheckRestorePrereq(oRestoreInfo, oGame.CleanFolder) Then
oReadyList.Add(oRestoreInfo) oReadyList.Add(oRestoreInfo)
End If End If
@@ -212,6 +250,7 @@ Public Class frmMain
Private Sub RunManualBackup(ByVal oBackupList As List(Of clsGame)) Private Sub RunManualBackup(ByVal oBackupList As List(Of clsGame))
Dim oGame As clsGame Dim oGame As clsGame
Dim bNoAuto As Boolean Dim bNoAuto As Boolean
Dim bOSVerified As Boolean
Dim bPathVerified As Boolean Dim bPathVerified As Boolean
Dim oReadyList As New List(Of clsGame) Dim oReadyList As New List(Of clsGame)
@@ -221,11 +260,14 @@ Public Class frmMain
'Build Backup List 'Build Backup List
For Each oGame In oBackupList For Each oGame In oBackupList
bNoAuto = False bNoAuto = False
bOSVerified = False
bPathVerified = False bPathVerified = False
gMonStripStatusButton.Enabled = False gMonStripStatusButton.Enabled = False
UpdateLog(mgrCommon.FormatString(frmMain_ManualBackup, oGame.Name), False) UpdateLog(mgrCommon.FormatString(frmMain_ManualBackup, oGame.Name), False)
bOSVerified = VerifyBackupForOS(oGame, oGame.Path)
If oGame.AbsolutePath = False Then If oGame.AbsolutePath = False Then
If oGame.ProcessPath = String.Empty Then If oGame.ProcessPath = String.Empty Then
If mgrCommon.IsProcessNotSearchable(oGame) Then bNoAuto = True If mgrCommon.IsProcessNotSearchable(oGame) Then bNoAuto = True
@@ -241,7 +283,7 @@ Public Class frmMain
bPathVerified = True bPathVerified = True
End If End If
If bPathVerified Then If bOSVerified And bPathVerified Then
If oBackup.CheckBackupPrereq(oGame) Then If oBackup.CheckBackupPrereq(oGame) Then
oReadyList.Add(oGame) oReadyList.Add(oGame)
End If End If
@@ -1936,15 +1978,18 @@ Public Class frmMain
If bWineProcess Then If bWineProcess Then
'Attempt a path conversion if the game configuration is using an absolute windows path that we can convert '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 If mgrVariables.CheckForReservedVariables(oProcess.GameInfo.TruePath) Then
Dim sWinePrefix As String = mgrPath.GetWinePrefix(oProcess.FoundProcess) Dim oWineData As New clsWineData
Dim sWineSavePath As String oWineData.MonitorID = oProcess.GameInfo.ID
If Not sWinePrefix = String.Empty Then oWineData.Prefix = mgrPath.GetWinePrefix(oProcess.FoundProcess)
UpdateLog(mgrCommon.FormatString(frmMain_WinePrefix, New String() {oProcess.GameInfo.Name, sWinePrefix}), False) oWineData.BinaryPath = Path.GetDirectoryName(oProcess.FoundProcess.MainModule.FileName)
sWineSavePath = mgrPath.GetWineSavePath(sWinePrefix, oProcess.GameInfo.TruePath) UpdateLog(mgrCommon.FormatString(frmMain_WineBinaryPath, New String() {oProcess.GameInfo.Name, oWineData.BinaryPath}), False)
If Not sWineSavePath = oProcess.GameInfo.TruePath Then If Not oWineData.Prefix = String.Empty Then
oProcess.GameInfo.TruePath = sWineSavePath UpdateLog(mgrCommon.FormatString(frmMain_WinePrefix, New String() {oProcess.GameInfo.Name, oWineData.Prefix}), False)
oProcess.GameInfo.AbsolutePath = True oWineData.SavePath = mgrPath.GetWineSavePath(oWineData.Prefix, oProcess.GameInfo.TruePath)
UpdateLog(mgrCommon.FormatString(frmMain_WineSavePath, New String() {oProcess.GameInfo.Name, sWineSavePath}), False) 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 Else
bContinue = False bContinue = False
End If End If
@@ -2031,6 +2076,10 @@ Public Class frmMain
UpdateLog(mgrCommon.FormatString(frmMain_GameEnded, oProcess.GameInfo.Name), False) UpdateLog(mgrCommon.FormatString(frmMain_GameEnded, oProcess.GameInfo.Name), False)
If oSettings.TimeTracking Then HandleTimeSpent() If oSettings.TimeTracking Then HandleTimeSpent()
If oSettings.SessionTracking Then HandleSession() 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() RunBackup()
Else Else
UpdateLog(frmMain_UnknownGameEnded, False) UpdateLog(frmMain_UnknownGameEnded, False)
@@ -2045,6 +2094,7 @@ Public Class frmMain
bPathDetectionFailure = False bPathDetectionFailure = False
sPathDetectionError = String.Empty sPathDetectionError = String.Empty
bCancelledByUser = False bCancelledByUser = False
oProcess.WineData = Nothing
oProcess.StartTime = Now : oProcess.EndTime = Now oProcess.StartTime = Now : oProcess.EndTime = Now
End Sub End Sub
+1
View File
@@ -497,6 +497,7 @@ Public Class mgrPath
'Don't use these in Unix 'Don't use these in Unix
If Not mgrCommon.IsUnix Then If Not mgrCommon.IsUnix Then
hshFolders.Add(Guid.NewGuid.ToString, Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)) 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)) hshFolders.Add(Guid.NewGuid.ToString, Environment.GetFolderPath(Environment.SpecialFolder.UserProfile))
End If End If
+10
View File
@@ -8,6 +8,7 @@ Public Class mgrProcessDetection
Private dStartTime As DateTime = Now, dEndTime As DateTime = Now Private dStartTime As DateTime = Now, dEndTime As DateTime = Now
Private lTimeSpent As Long = 0 Private lTimeSpent As Long = 0
Private oGame As clsGame Private oGame As clsGame
Private oWineData As clsWineData
Private oDuplicateGames As New ArrayList Private oDuplicateGames As New ArrayList
Private bDuplicates As Boolean Private bDuplicates As Boolean
Private bVerified As Boolean = False Private bVerified As Boolean = False
@@ -63,6 +64,15 @@ Public Class mgrProcessDetection
End Set End Set
End Property 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 Property Duplicate As Boolean
Get Get
Return bDuplicates Return bDuplicates
+2 -2
View File
@@ -5,8 +5,8 @@
oWineGame.MonitorID = CStr(dr("MonitorID")) oWineGame.MonitorID = CStr(dr("MonitorID"))
If Not IsDBNull(dr("Prefix")) Then oWineGame.Prefix = CStr(dr("Prefix")) 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("SavePath")) Then oWineGame.SavePath = CStr(dr("SavePath"))
If Not IsDBNull(dr("BinaryPath")) Then oWineGame.Prefix = CStr(dr("BinaryPath")) If Not IsDBNull(dr("BinaryPath")) Then oWineGame.BinaryPath = CStr(dr("BinaryPath"))
Return oWineGame Return oWineGame
End Function End Function
+19 -1
View File
@@ -3336,6 +3336,15 @@ Namespace My.Resources
End Get End Get
End Property End Property
'''<summary>
''' Looks up a localized string similar to [PARAM] uses a Windows configuration and requires a Wine save path to perform this operation..
'''</summary>
Friend ReadOnly Property frmMain_ErrorNoWineSavePath() As String
Get
Return ResourceManager.GetString("frmMain_ErrorNoWineSavePath", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to [PARAM] uses a relative path and has never been detected on this computer.. ''' Looks up a localized string similar to [PARAM] uses a relative path and has never been detected on this computer..
'''</summary> '''</summary>
@@ -4056,6 +4065,15 @@ Namespace My.Resources
End Get End Get
End Property End Property
'''<summary>
''' Looks up a localized string similar to [PARAM] Wine Binary Path: [PARAM].
'''</summary>
Friend ReadOnly Property frmMain_WineBinaryPath() As String
Get
Return ResourceManager.GetString("frmMain_WineBinaryPath", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to [PARAM] Wine Prefix: [PARAM]. ''' Looks up a localized string similar to [PARAM] Wine Prefix: [PARAM].
'''</summary> '''</summary>
@@ -4066,7 +4084,7 @@ Namespace My.Resources
End Property End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to [PARAM] Converted Save Path: [PARAM]. ''' Looks up a localized string similar to [PARAM] Wine Save Path: [PARAM].
'''</summary> '''</summary>
Friend ReadOnly Property frmMain_WineSavePath() As String Friend ReadOnly Property frmMain_WineSavePath() As String
Get Get
+7 -1
View File
@@ -2207,7 +2207,7 @@
<value>[PARAM] Wine Prefix: [PARAM]</value> <value>[PARAM] Wine Prefix: [PARAM]</value>
</data> </data>
<data name="frmMain_WineSavePath" xml:space="preserve"> <data name="frmMain_WineSavePath" xml:space="preserve">
<value>[PARAM] Converted Save Path: [PARAM]</value> <value>[PARAM] Wine Save Path: [PARAM]</value>
</data> </data>
<data name="mgrPath_ErrorBuildingWinePath" xml:space="preserve"> <data name="mgrPath_ErrorBuildingWinePath" xml:space="preserve">
<value>An error occured when building a Wine path.[BR][BR][PARAM]</value> <value>An error occured when building a Wine path.[BR][BR][PARAM]</value>
@@ -2296,4 +2296,10 @@
<data name="frmFilter_FieldOS" xml:space="preserve"> <data name="frmFilter_FieldOS" xml:space="preserve">
<value>OS</value> <value>OS</value>
</data> </data>
<data name="frmMain_WineBinaryPath" xml:space="preserve">
<value>[PARAM] Wine Binary Path: [PARAM]</value>
</data>
<data name="frmMain_ErrorNoWineSavePath" xml:space="preserve">
<value>[PARAM] uses a Windows configuration and requires a Wine save path to perform this operation.</value>
</data>
</root> </root>