Changes for multi-platform support

This commit is contained in:
Michael J. Seiferling
2016-02-29 12:24:56 -06:00
parent ec47697434
commit de7a993abe
7 changed files with 108 additions and 86 deletions
+36 -25
View File
@@ -23,6 +23,7 @@ Public Class frmMain
Private eCurrentOperation As eOperation = eOperation.None
Private bCancelledByUser As Boolean = False
Private bShutdown As Boolean = False
Private bInitFail As Boolean = False
Private bMenuEnabled As Boolean = True
Private bLockdown As Boolean = True
Private bFirstRun As Boolean = False
@@ -812,15 +813,13 @@ Public Class frmMain
Private Sub ToggleState()
'Toggle State with Tray Clicks
If Me.WindowState = FormWindowState.Minimized Then
If Me.Visible = False Then
Me.Visible = True
Me.ShowInTaskbar = True
Me.WindowState = FormWindowState.Normal
Me.Focus()
Else
Me.Visible = False
Me.ShowInTaskbar = False
Me.WindowState = FormWindowState.Minimized
End If
End Sub
@@ -1173,8 +1172,8 @@ Public Class frmMain
Private Sub VerifyGameDataPath()
'Important: This function cannot access mgrPath for settings, as that will trigger a database creation and destroy the reason for this function
Dim sSettingsRoot As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\gbm"
Dim sDBLocation As String = sSettingsRoot & "\gbm.s3db"
Dim sSettingsRoot As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "/gbm"
Dim sDBLocation As String = sSettingsRoot & "/gbm.s3db"
If Not IO.Directory.Exists(sSettingsRoot) Then
Try
@@ -1400,7 +1399,6 @@ Public Class frmMain
Private Sub gMonTray_BalloonTipClicked(sender As System.Object, e As System.EventArgs) Handles gMonTray.BalloonTipClicked
Me.Visible = True
Me.ShowInTaskbar = True
Me.WindowState = FormWindowState.Normal
Me.Focus()
End Sub
@@ -1422,8 +1420,7 @@ Public Class frmMain
If bShutdown = False Then
e.Cancel = True
Me.Visible = False
Me.ShowInTaskbar = False
Me.WindowState = FormWindowState.Minimized
Me.ShowInTaskbar = False
End If
End Sub
@@ -1537,32 +1534,46 @@ Public Class frmMain
End Sub
Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
SetForm()
VerifyGameDataPath()
LoadAndVerify()
VerifyCustomPathVariables()
If oSettings.StartToTray Then
Me.Visible = False
Me.ShowInTaskbar = False
Me.WindowState = FormWindowState.Minimized
End If
'Init
Try
SetForm()
VerifyGameDataPath()
LoadAndVerify()
VerifyCustomPathVariables()
If oSettings.MonitorOnStartup Then
eCurrentStatus = eStatus.Stopped
Else
eCurrentStatus = eStatus.Running
End If
If oSettings.StartToTray Then
Me.Visible = False
Me.ShowInTaskbar = False
End If
HandleScan()
CheckForNewBackups()
If oSettings.MonitorOnStartup Then
eCurrentStatus = eStatus.Stopped
Else
eCurrentStatus = eStatus.Running
End If
HandleScan()
CheckForNewBackups()
Catch niex As NotImplementedException
'Ignore for Mono runtime tests
Catch ex As Exception
mgrCommon.ShowMessage(frmMain_ErrorInitFailure, ex.Message, MsgBoxStyle.Critical)
bInitFail = True
End Try
End Sub
Private Sub frmMain_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
If bFirstRun Then
If bFirstRun And Not bInitFail Then
OpenStartupWizard()
End If
If bInitFail Then
bShutdown = True
Me.Close()
End If
End Sub
Private Sub txtGameInfo_Enter(sender As Object, e As EventArgs)
+5 -5
View File
@@ -42,7 +42,7 @@ Public Class mgrBackup
'Create manifest item
oItem.Name = oGameInfo.Name
'Keep the path relative to the manifest location
oItem.FileName = sBackupFile.Replace(Path.GetDirectoryName(mgrPath.RemoteDatabaseLocation) & "\", "")
oItem.FileName = sBackupFile.Replace(Path.GetDirectoryName(mgrPath.RemoteDatabaseLocation) & Path.DirectorySeparatorChar, "")
oItem.RestorePath = oGameInfo.TruePath
oItem.AbsolutePath = oGameInfo.AbsolutePath
oItem.DateUpdated = dTimeStamp
@@ -75,7 +75,7 @@ Public Class mgrBackup
Using oStream
If sList <> String.Empty Then
For Each sTypeItem As String In sList.Split(":")
oStream.WriteLine("""" & sBackupPath & "\" & sTypeItem & """")
oStream.WriteLine("""" & sBackupPath & Path.DirectorySeparatorChar & sTypeItem & """")
Next
End If
oStream.Flush()
@@ -129,9 +129,9 @@ Public Class mgrBackup
End If
If oGame.AppendTimeStamp Then
sBackupFile = sBackupFile & "\" & oGame.Name & sTimeStamp & ".7z"
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & sTimeStamp & ".7z"
Else
sBackupFile = sBackupFile & "\" & oGame.Name & ".7z"
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & ".7z"
End If
If oSettings.ShowOverwriteWarning And File.Exists(sBackupFile) Then
@@ -144,7 +144,7 @@ Public Class mgrBackup
If bDoBackup Then
If oGame.AbsolutePath = False Then
If oGame.Path <> String.Empty Then
sSavePath = oGame.ProcessPath & "\" & oGame.Path
sSavePath = oGame.ProcessPath & Path.DirectorySeparatorChar & oGame.Path
Else
sSavePath = oGame.ProcessPath
End If
-2
View File
@@ -160,8 +160,6 @@ Public Class mgrCommon
End Try
End Function
'Handles no extra parameters
Public Shared Function ShowMessage(ByVal sMsg As String, ByVal oType As MsgBoxStyle) As MsgBoxResult
Dim oResult As MsgBoxResult
+24 -23
View File
@@ -5,11 +5,11 @@ Imports System.Reflection
Public Class mgrPath
'Important Note: Any changes to sSettingsRoot & sDBLocation need to be mirrored in frmMain.vb -> VerifyGameDataPath
Private Shared sSettingsRoot As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\gbm"
Private Shared sDBLocation As String = sSettingsRoot & "\gbm.s3db"
Private Shared sIncludeFile As String = sSettingsRoot & "\gbm_include.txt"
Private Shared sExcludeFile As String = sSettingsRoot & "\gbm_exclude.txt"
Private Shared sLogFile As String = sSettingsRoot & "\gbm_log_" & Date.Now.ToString("dd-MM-yyyy-HH-mm-ss") & ".txt"
Private Shared sSettingsRoot As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "/gbm"
Private Shared sDBLocation As String = sSettingsRoot & "/gbm.s3db"
Private Shared sIncludeFile As String = sSettingsRoot & "/gbm_include.txt"
Private Shared sExcludeFile As String = sSettingsRoot & "/gbm_exclude.txt"
Private Shared sLogFile As String = sSettingsRoot & "/gbm_log_" & Date.Now.ToString("dd-MM-yyyy-HH-mm-ss") & ".txt"
Private Shared sRemoteDatabaseLocation As String
Private Shared hshCustomVariables As Hashtable
Private Shared oReleaseType As ProcessorArchitecture = AssemblyName.GetAssemblyName(Application.ExecutablePath()).ProcessorArchitecture
@@ -41,18 +41,18 @@ Public Class mgrPath
Get
Select Case oReleaseType
Case ProcessorArchitecture.Amd64
Return Application.StartupPath & "\Utilities\x64\7za.exe"
Return Application.StartupPath & "/Utilities/x64/7za.exe"
Case ProcessorArchitecture.IA64
Return Application.StartupPath & "\Utilities\x64\7za.exe"
Return Application.StartupPath & "/Utilities/x64/7za.exe"
Case ProcessorArchitecture.MSIL
Return Application.StartupPath & "\Utilities\x86\7za.exe"
Return Application.StartupPath & "/Utilities/x86/7za.exe"
Case ProcessorArchitecture.X86
Return Application.StartupPath & "\Utilities\x86\7za.exe"
Return Application.StartupPath & "/Utilities/x86/7za.exe"
Case ProcessorArchitecture.None
Return Application.StartupPath & "\Utilities\x86\7za.exe"
Return Application.StartupPath & "/Utilities/x86/7za.exe"
End Select
Return Application.StartupPath & "\Utilities\x86\7za.exe"
Return Application.StartupPath & "/Utilities/x86/7za.exe"
End Get
End Property
@@ -119,19 +119,20 @@ Public Class mgrPath
Dim iRemove As Integer = 0
Dim iBackFolders As Integer = 0
Dim bDeep As Boolean
Dim cPathChars As Char() = {"\", "/"}
'We are working with a case insenstive file system, ensure a uniform case
sProcessPath = sProcessPath.ToLower
sSavePath = sSavePath.ToLower
'We need to ensure we have a single trailing slash on the parameters
sProcessPath = sProcessPath.TrimEnd("\")
sSavePath = sSavePath.TrimEnd("\")
sProcessPath &= "\"
sSavePath &= "\"
sProcessPath = sProcessPath.TrimEnd(cPathChars)
sSavePath = sSavePath.TrimEnd(cPathChars)
sProcessPath &= "/"
sSavePath &= "/"
'Determines the direction we need to go, we always want to be relative to the process location
If sSavePath.Split("\").Length > sProcessPath.Split("\").Length Then
If sSavePath.Split(cPathChars).Length > sProcessPath.Split(cPathChars).Length Then
sPath1 = sProcessPath
sPath2 = sSavePath
bDeep = True
@@ -142,8 +143,8 @@ Public Class mgrPath
End If
'Build an array of folders to work with from each path
sPath1Array = sPath1.Split("\")
sPath2Array = sPath2.Split("\")
sPath1Array = sPath1.Split(cPathChars)
sPath2Array = sPath2.Split(cPathChars)
'Take the shortest path and remove the common folders from both
For Each s As String In sPath1Array
@@ -155,25 +156,25 @@ Public Class mgrPath
Next
'Remove the trailing slashes
sPath1 = sPath1.TrimEnd("\")
sPath2 = sPath2.TrimEnd("\")
sPath1 = sPath1.TrimEnd(cPathChars)
sPath2 = sPath2.TrimEnd(cPathChars)
'Determine which way we go
If bDeep Then
If sPath1.Length > 0 Then
iBackFolders = sPath1.Split("\").Length
iBackFolders = sPath1.Split(cPathChars).Length
End If
sResult = sPath2
Else
If sPath2.Length > 0 Then
iBackFolders = sPath2.Split("\").Length
iBackFolders = sPath2.Split(cPathChars).Length
End If
sResult = sPath1
End If
'Insert direction modifiers based on how many folders are left
For i = 1 To iBackFolders
sResult = "..\" & sResult
sResult = ".." & Path.DirectorySeparatorChar & sResult
Next i
'Done
+3 -3
View File
@@ -60,7 +60,7 @@ Public Class mgrRestore
If Not oRestoreInfo.AbsolutePath Then
If oGame.ProcessPath <> String.Empty Then
oRestoreInfo.RelativeRestorePath = oGame.ProcessPath & "\" & oRestoreInfo.RestorePath
oRestoreInfo.RelativeRestorePath = oGame.ProcessPath & Path.DirectorySeparatorChar & oRestoreInfo.RestorePath
Else
sProcess = oGame.TrueProcess
If mgrCommon.IsProcessNotSearchable(oGame) Then bNoAuto = True
@@ -73,7 +73,7 @@ Public Class mgrRestore
bTriggerReload = True
'Set path for restore
oRestoreInfo.RelativeRestorePath = sRestorePath & "\" & oRestoreInfo.RestorePath
oRestoreInfo.RelativeRestorePath = sRestorePath & Path.DirectorySeparatorChar & oRestoreInfo.RestorePath
Else
Return False
End If
@@ -183,7 +183,7 @@ Public Class mgrRestore
For Each oBackupInfo In oRestoreList
'Init
prs7z = New Process
sBackupFile = oSettings.BackupFolder & "\" & oBackupInfo.FileName
sBackupFile = oSettings.BackupFolder & Path.DirectorySeparatorChar & oBackupInfo.FileName
sExtractPath = String.Empty
bDoRestore = True
bRestoreCompleted = False
+37 -28
View File
@@ -2111,7 +2111,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_CommandFail", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to The command was executed successfully..
'''</summary>
@@ -2120,7 +2120,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_CommandSucess", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Do you wish to backup data from [PARAM]?.
'''</summary>
@@ -2129,7 +2129,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ConfirmBackup", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Are you sure you want to clear the log?.
'''</summary>
@@ -2138,7 +2138,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ConfirmLogClear", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to This tool removes orphaned backup information from the local manifest based on the current backup folder. Data can become orphaned when backups are deleted by various computers that share the same backup folder on a cloud or network.[BR][BR]When alternating between different backup folders you should NOT use this tool.[BR][BR]Do you wish to proceed?.
'''</summary>
@@ -2147,7 +2147,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ConfirmManifestClean", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Do you wish to cancel the monitoring of [PARAM]?[BR][BR]Warning: When monitoring is cancelled, session time is NOT saved..
'''</summary>
@@ -2156,7 +2156,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ConfirmMonitorCancel", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to This will rebuild all databases and shrink them to an optimal size.[BR]This should only be used if your gbm.s3db files are becoming very large.[BR][BR]Do you wish to continue?.
'''</summary>
@@ -2165,7 +2165,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ConfirmRebuild", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Do you want to restart Game Backup Monitor as Administrator?.
'''</summary>
@@ -2174,7 +2174,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ConfirmRunAsAdmin", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Game Backup Monitor Log.
'''</summary>
@@ -2183,7 +2183,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_DefaultLogFileName", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Developer Console.
'''</summary>
@@ -2192,7 +2192,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_DeveloperConsole", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Enter Command.
'''</summary>
@@ -2201,7 +2201,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_EnterCommand", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to [PARAM] is a 64-bit game, GBM cannot detect the required information to save your backup..
'''</summary>
@@ -2210,7 +2210,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_Error64Backup", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to 7-Zip was not found in the Game Backup Monitor utilities folder. The application cannot continue..
'''</summary>
@@ -2219,7 +2219,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_Error7zip", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to [PARAM] is running as Administrator and GBM is not, GBM cannot detect the required information to save your backup..
'''</summary>
@@ -2228,7 +2228,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorAdminBackup", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to [PARAM] is running as Administrator and GBM is not.[BR]You cannot cancel monitoring at this time.[BR][BR]Run GBM as Administrator to prevent this issue..
'''</summary>
@@ -2237,7 +2237,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorAdminDetect", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Game Backup Monitor is already running as Administrator..
'''</summary>
@@ -2246,7 +2246,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorAlreadyAdmin", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to GBM is running from a new location, the Windows startup entry has been updated..
'''</summary>
@@ -2255,7 +2255,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorAppLocationChanged", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to [PARAM] backup was cancelled..
'''</summary>
@@ -2264,7 +2264,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorBackupCancel", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to [PARAM] backup was cancelled due to session length..
'''</summary>
@@ -2273,7 +2273,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorBackupSessionLength", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to [PARAM] backup was cancelled due to unknown path..
'''</summary>
@@ -2282,7 +2282,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorBackupUnknownPath", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Bad parameter ([PARAM]) for command [PARAM]..
'''</summary>
@@ -2291,7 +2291,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorCommandBadParam", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to The command [PARAM] was not recognized..
'''</summary>
@@ -2300,7 +2300,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorCommandInvalid", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to The following monitored game(s) contain a custom path variable that is not set.[BR][PARAM][BR][BR]You will encounter backup/restore errors with these games until the variables are set..
'''</summary>
@@ -2309,7 +2309,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorCustomVariable", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Your local GBM data (Version [PARAM]) is too new for your version of GBM (Version [PARAM]).[BR][BR]Please upgrade GBM or restore the database file appropriate for your version. The application cannot proceed..
'''</summary>
@@ -2318,7 +2318,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorDBVerLocal", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to The GBM data (Version [PARAM]) in your backup folder is too new for your version of GBM (Version [PARAM])[BR][BR]All computers sharing a backup folder must use the same version of GBM. The application cannot proceed..
'''</summary>
@@ -2327,7 +2327,16 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorDBVerRemote", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to An unexpected error occured while initializing GBM.[BR][BR][PARAM][BR][BR]The application will now exit..
'''</summary>
Friend ReadOnly Property frmMain_ErrorInitFailure() As String
Get
Return ResourceManager.GetString("frmMain_ErrorInitFailure", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to The command [PARAM] requires more parameters..
'''</summary>
@@ -2336,7 +2345,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorMissingParams", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Multiple possible 64-bit games have been detected, GBM cannot detect the path to identify your game or save your backup.[BR][BR]Please install the 64-bit version of GBM to detect and backup this game properly..
'''</summary>
@@ -2345,7 +2354,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorMulti64", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Multiple possible games have been detected running as Administrator and GBM is not, GBM cannot detect the path to identify your game or save your backup.[BR][BR]Please run GBM as Administrator to properly detect and backup this game..
'''</summary>
@@ -2354,7 +2363,7 @@ Namespace My.Resources
Return ResourceManager.GetString("frmMain_ErrorMultiAdmin", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to [PARAM] uses a relative path and has never been detected on this computer..
'''</summary>
+3
View File
@@ -1558,4 +1558,7 @@
<data name="frmMain_ErrorMissingParams" xml:space="preserve">
<value>The command [PARAM] requires more parameters.</value>
</data>
<data name="frmMain_ErrorInitFailure" xml:space="preserve">
<value>An unexpected error occured while initializing GBM.[BR][BR][PARAM][BR][BR]The application will now exit.</value>
</data>
</root>