Files
minecraft-modpack-updater/ModpackUpdater/AppConfig.vb

55 lines
1.7 KiB
VB.net

Imports System.IO
Imports Newtonsoft.Json.Linq
Public Class AppConfig
Public Property LastMinecraftProfilePath As String
Public Property LastConfigFilePath As String
Public Property KeepLocalFiles As New List(Of String) From {
"OptiFine_1.7.10_HD_U_E7.jar"
}
Public Property RemoveLocalFiles As Boolean
Public Shared ReadOnly Property Instance As AppConfig
Get
Static myInstance As AppConfig = Nothing
If myInstance Is Nothing Then
If File.Exists(SettingsPath) Then
myInstance = LoadConfig(SettingsPath)
Else
myInstance = New AppConfig
End If
End If
Return myInstance
End Get
End Property
Private Shared ReadOnly Property SettingsPath As string
Get
Static myPath As String = String.Empty
Const AppDataDirectoryName As String = "MinecraftModpackUpdater"
Const SettingsFileName As String = "Settings.json"
If String.IsNullOrEmpty(myPath) Then
myPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataDirectoryName)
Directory.CreateDirectory(myPath)
myPath = Path.Combine(myPath, SettingsFileName)
End If
Return myPath
End Get
End Property
Public Sub SaveConfig()
File.WriteAllText(SettingsPath, JObject.FromObject(Me).ToString)
End Sub
Private Shared Function LoadConfig(filePath As String) As AppConfig
Return JObject.Parse(File.ReadAllText(filePath)).ToObject(Of AppConfig)
End Function
End Class