11using DLLanguages . Pick ;
2+ using static Launcher_DL . Core . Configuration . CONFIG_STR ;
23
34namespace Launcher_DL . Core . Configuration ;
45
56public class DefaultConfig
67{
7- public string background = "background.png" ;
8- public string DefaultOutput = "output" ;
9- public string BrowserCookie = "chrome" ;
8+ public string background = CONFIG_DEFAULT_BACKGROUND ;
9+ public string DefaultOutput = CONFIG_DEFAULT_OUTPUT ;
10+ public string BrowserCookie = CONFIG_DEFAULT_COOKIE ;
1011
11- public Color backgroundColor = ClrConv ( "#FF161438" ) ;
12- public Color backgroundGlow = ClrConv ( "#FF7DB5FF" ) ;
12+ public Color backgroundColor = ClrConv ( CONFIG_DEFAULT_BACKGROUND_COLOR ) ;
13+ public Color backgroundGlow = ClrConv ( CONFIG_DEFAULT_BACKGROUND_GLOW ) ;
1314
14- public bool ShowSystemOutput = true ;
15- public bool EnablePlaylist = true ;
16- public bool EpicAnimations = true ;
17- public bool AllowCookies = false ;
15+ public bool ShowSystemOutput = CONFIG_DEFAULT_SYSTEM_OUTPUT ;
16+ public bool EnablePlaylist = CONFIG_DEFAULT_PLAYLIST ;
17+ public bool EpicAnimations = CONFIG_DEFAULT_ANIMATIONS ;
18+ public bool AllowCookies = CONFIG_DEFAULT_COOKIES ;
1819
19- public int DefaultFileTypeOnStartUp = 0 ;
20+ public int DefaultFileTypeOnStartUp = CONFIG_DEFAULT_FILE_TYPE ;
2021 public LanguageName Language = 0 ;
2122}
2223
2324public class Config
2425{
2526 static bool error = false ;
2627 static DefaultConfig DefaultConfiguration ;
27- public static DefaultConfig ReadConfigINI ( string Name = "Config.ini" )
28+ public static DefaultConfig ReadConfigINI ( )
2829 {
29- FileIniDataParser parser = new ( ) ;
30+ string ConfigString = File . ReadAllText ( CONFIG_NAME ) ;
31+ IniDataParser parser = new ( ) ;
3032 DefaultConfiguration = new ( ) ;
31- IniData Data = parser . ReadFile ( Name ) ;
33+ IniData Data = parser . Parse ( ConfigString ) ;
3234
33- string LanguageCheck = Data [ "App" ] [ "Language" ] ;
35+ string LanguageCheck = Data [ CONFIG_SECTION_APP ] [ CONFIG_LANGUAGE ] ;
3436
3537 switch ( LanguageCheck . ToLower ( ) )
3638 {
@@ -41,20 +43,17 @@ public static DefaultConfig ReadConfigINI(string Name = "Config.ini")
4143 case "bruh" : DefaultConfiguration . Language = LanguageName . bruh ; break ;
4244 }
4345
44- // HOLY FUCKING SHIT I JUST NEEDED TO ADD THE "REF" BECAUSE ITS JUST PASSING ITS VALUE
45- // SO IF I TRIED TO CHANGE THE VALUE FROM THAT METHOD IT WONT CHANGE UNLESS I REFERENCE IT
46- // THANKS TO THIS SAVIOR:
47- // https://codeeasy.io/lesson/passing_parameters_to_functions
48- CheckError ( ref DefaultConfiguration . background , Data [ "Background" ] [ "backgroundName" ] , "backgroundName" ) ;
49- CheckError ( ref DefaultConfiguration . backgroundColor , Data [ "Background" ] [ "backgroundColor" ] , "backgroundColor" ) ;
50- CheckError ( ref DefaultConfiguration . backgroundGlow , Data [ "Background" ] [ "backgroundGlowColor" ] , "backgroundGlowColor" ) ;
51- CheckError ( ref DefaultConfiguration . DefaultOutput , Data [ "File" ] [ "DefaultOutput" ] , "DefaultOutput" ) ;
52- CheckError ( ref DefaultConfiguration . ShowSystemOutput , Data [ "Console" ] [ "ShowSystemOutput" ] , "ShowSystemOutput" ) ;
53- CheckError ( ref DefaultConfiguration . DefaultFileTypeOnStartUp , Data [ "DropDown" ] [ "DefaultFileTypeOnStartUp" ] , "DefaultFileTypeOnStartUp" ) ;
54- CheckError ( ref DefaultConfiguration . EnablePlaylist , Data [ "Playlist" ] [ "EnablePlaylist" ] , "EnablePlaylist" ) ;
55- CheckError ( ref DefaultConfiguration . EpicAnimations , Data [ "graphics" ] [ "EpicAnimations" ] , "EpicAnimations" ) ;
56- CheckError ( ref DefaultConfiguration . AllowCookies , Data [ "Cookies" ] [ "AllowCookies" ] , "AllowCookies" ) ;
57- CheckError ( ref DefaultConfiguration . BrowserCookie , Data [ "Cookies" ] [ "BrowserCookie" ] , "BrowserCookie" ) ;
46+ // I am pleased on this
47+ CheckError ( ref DefaultConfiguration . background , Data [ CONFIG_SECTION_BACKROUND ] [ 0 ] , CONFIG_BACKGROUND_NAME ) ;
48+ CheckError ( ref DefaultConfiguration . backgroundColor , Data [ CONFIG_SECTION_BACKROUND ] [ 1 ] , CONFIG_BACKGROUND_COLOR ) ;
49+ CheckError ( ref DefaultConfiguration . backgroundGlow , Data [ CONFIG_SECTION_BACKROUND ] [ 2 ] , CONFIG_BACKGROUND_GLOW ) ;
50+ CheckError ( ref DefaultConfiguration . AllowCookies , Data [ CONFIG_SECTION_COOKIES ] [ 0 ] , CONFIG_ALLOW_COOKIES ) ;
51+ CheckError ( ref DefaultConfiguration . BrowserCookie , Data [ CONFIG_SECTION_COOKIES ] [ 1 ] , CONFIG_BROWSER_COOKIES ) ;
52+ CheckError ( ref DefaultConfiguration . DefaultOutput , Data [ CONFIG_SECTION_FILE ] [ 0 ] , CONFIG_OUTPUT ) ;
53+ CheckError ( ref DefaultConfiguration . ShowSystemOutput , Data [ CONFIG_SECTION_CONSOLE ] [ 0 ] , CONFIG_SYSTEM_OUTPUT ) ;
54+ CheckError ( ref DefaultConfiguration . DefaultFileTypeOnStartUp , Data [ CONFIG_SECTION_DROPDOWN ] [ 0 ] , CONFIG_FILE_TYPE ) ;
55+ CheckError ( ref DefaultConfiguration . EnablePlaylist , Data [ CONFIG_SECTION_PLAYLIST ] [ 0 ] , CONFIG_ENABLE_PLAYLIST ) ;
56+ CheckError ( ref DefaultConfiguration . EpicAnimations , Data [ CONFIG_SECTION_GRAPHICS ] [ 0 ] , CONFIG_ANIMATIONS ) ;
5857
5958 if ( ! error )
6059 {
@@ -73,22 +72,16 @@ public static DefaultConfig ReadConfigINI(string Name = "Config.ini")
7372 return DefaultConfiguration ;
7473 }
7574
76- private static void CheckError < T > ( ref T a , dynamic b , string c )
75+ private static void CheckError < T > ( ref T a , dynamic b , string c )
7776 {
7877 #if DEBUG
7978 ConsoleDebug . LoadingConfig ( a , b , c ) ;
8079 #endif
8180
8281 try
8382 {
84- switch ( a . GetType ( ) . ToString ( ) )
85- {
86- case "System.String" : a = b ; break ;
87- case "System.Int32" : a = int . Parse ( b ) ; break ;
88- case "System.Windows.Media.Color" : a = ClrConv ( b ) ; break ;
89- case "System.Boolean" : a = bool . Parse ( b ) ; break ;
90- }
91-
83+ if ( a . GetType ( ) . ToString ( ) . Contains ( CONFIG_COLOR_CONTAINS ) ) a = ClrConv ( b ) ;
84+ else a = b ;
9285 } catch ( Exception e )
9386 {
9487 error = true ;
0 commit comments