11using Hypermc . Services ;
2+ using Microsoft . Extensions . Configuration ;
23using System ;
34using System . Collections . Generic ;
45using System . IO ;
56using System . Linq ;
67using System . Text ;
78using System . Text . Json ;
89using System . Threading . Tasks ;
10+ using System . Windows . Forms ;
911
1012namespace Hypermc . Settings
1113{
@@ -15,18 +17,21 @@ public class UserSettings : IUserSettings
1517 private readonly string _settingsFile ;
1618 private readonly IFileManager _fileManager ;
1719
18- public string MinecraftPath { get ; set ; }
19- public string ModPacksPath { get ; set ; }
20+ public string MinecraftPath { get ; private set ; }
21+ public string ModPacksPath { get ; private set ; }
22+ public string ModPacksFile { get ; }
2023
21- public UserSettings ( IFileManager fileManager )
24+ public UserSettings ( IFileManager fileManager , IConfiguration config )
2225 {
23- // TODO: possibly move the file names to the appsettings.
24- _appPath = $@ "{ Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) } \.hypermc";
25- _settingsFile = $@ "{ _appPath } \settings.json";
26+ var settings = config . Get < ApplicationSettings > ( ) . AppSettings ;
27+ _appPath = string . Format ( settings . AppPath , Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ) ;
28+ _settingsFile = string . Format ( settings . SettingsFile , _appPath ) ;
29+
2630 _fileManager = fileManager ;
2731
28- MinecraftPath = $@ "{ Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) } \.minecraft";
29- ModPacksPath = $@ "{ MinecraftPath } \ModPacks";
32+ MinecraftPath = string . Format ( settings . DeafultMinecraftPath , Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ) ;
33+ ModPacksPath = string . Format ( settings . DefaultModPacksPath , MinecraftPath ) ;
34+ ModPacksFile = string . Format ( settings . ModPacksFile , ModPacksPath ) ;
3035 }
3136
3237 public async Task Initialize ( )
0 commit comments