diff --git a/GBM/Forms/frmVariableManager.vb b/GBM/Forms/frmVariableManager.vb index da90901..a3d18d9 100644 --- a/GBM/Forms/frmVariableManager.vb +++ b/GBM/Forms/frmVariableManager.vb @@ -289,6 +289,12 @@ Public Class frmVariableManager Return False End If + If mgrVariables.GetReservedVariables.Contains(txtName.Text.ToUpper) Then + mgrCommon.ShowMessage(frmVariableManager_ErrorVariableReserved, txtName.Text, MsgBoxStyle.Exclamation) + txtName.Focus() + Return False + End If + Return True End Function diff --git a/GBM/Managers/mgrPath.vb b/GBM/Managers/mgrPath.vb index 3eff9e3..d3c371e 100644 --- a/GBM/Managers/mgrPath.vb +++ b/GBM/Managers/mgrPath.vb @@ -501,6 +501,8 @@ Public Class mgrPath Public Shared Function VerifyCustomVariables(ByVal hshScanlist As Hashtable, ByRef sGames As String) As Boolean Dim hshCustomVariables As Hashtable = mgrVariables.ReadVariables + 'Reserved variables will be resolved on Windows, but not on a Linux. Therefore we an ignore list here, otherwise GBM will bitch about them when using Windows configurations for Wine. + Dim oReservedVariables As List(Of String) = mgrVariables.GetReservedVariables Dim sVariableCheck As String Dim sPattern As String = "\%(.*)\%" Dim oGame As clsGame @@ -511,7 +513,7 @@ Public Class mgrPath oMatch = Regex.Match(oGame.Path, sPattern) If oMatch.Success Then sVariableCheck = oMatch.Value.Replace("%", String.Empty) - If Not hshCustomVariables.ContainsKey(sVariableCheck) Then + If Not hshCustomVariables.ContainsKey(sVariableCheck) And Not oReservedVariables.Contains(sVariableCheck) Then sGames &= vbCrLf & oGame.Name & " (" & sVariableCheck & ")" bClean = False End If diff --git a/GBM/Managers/mgrVariables.vb b/GBM/Managers/mgrVariables.vb index 04613a9..72befd2 100644 --- a/GBM/Managers/mgrVariables.vb +++ b/GBM/Managers/mgrVariables.vb @@ -154,4 +154,16 @@ Return hshList End Function + + Public Shared Function GetReservedVariables() As List(Of String) + Dim oList As New List(Of String) + + oList.Add("APPDATA") + oList.Add("LOCALAPPDATA") + oList.Add("USERDOCUMENTS") + oList.Add("COMMONDOCUMENTS") + oList.Add("USERPROFILE") + + Return oList + End Function End Class diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 367cd36..c41fcd1 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -5442,6 +5442,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to [PARAM] is a reserved variable, you must enter a different name.. + ''' + Friend ReadOnly Property frmVariableManager_ErrorVariableReserved() As String + Get + Return ResourceManager.GetString("frmVariableManager_ErrorVariableReserved", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Custom Variable Manager. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index a4b39cb..c4bff63 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -2251,4 +2251,7 @@ This feature is intended to import 7-Zip backup archives compatible with the selected game configuration.[BR][BR]GBM does NOT verify these files, you should only use files created by GBM or other compatible archives that were created using the same settings as the current game configuration.[BR][BR]This message will only be shown once. + + [PARAM] is a reserved variable, you must enter a different name. + \ No newline at end of file