Skip to content

Commit bacec43

Browse files
Config Fix
So the IniParser repo has some annoying weird thing like It wont return the actual type I actually modified it and also added support by Int search other than the string I already did a PR check below: rickyah/ini-parser#248
1 parent 65f4559 commit bacec43

File tree

10 files changed

+1019
-69
lines changed

10 files changed

+1019
-69
lines changed

Launcher DL/Core/Configuration/Config.cs

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
11
using DLLanguages.Pick;
2+
using static Launcher_DL.Core.Configuration.CONFIG_STR;
23

34
namespace Launcher_DL.Core.Configuration;
45

56
public 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

2324
public 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;

Launcher DL/Core/Debug/ConsoleDebug.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,13 @@ public static void LoadConfigDone(bool isFailed)
3333
}
3434

3535
// goddamn it I got lazy naming these parameters
36-
public static void LoadingConfig(dynamic a, dynamic b, string c)
36+
public static void LoadingConfig<T>(T a, dynamic b, string c)
3737
{
3838
Console.Write($"Loading {c}");
3939
try
4040
{
41-
switch(a.GetType().ToString())
42-
{
43-
case "System.String": a = b; break;
44-
case "System.Int32": a = int.Parse(b); break;
45-
case "System.Windows.Media.Color": a = ClrConv(b); break;
46-
case "System.Boolean": a = bool.Parse(b); break;
47-
}
41+
if(a.GetType().ToString().Contains("System.Windows.Media.Color")) a = ClrConv(b);
42+
else a = b;
4843
Console.SetCursorPosition(34,4 + count);
4944
Console.Write($"\x1b[32mLOADED! = {b}\x1b[0m\n");
5045
} catch

Launcher DL/Core/Windows/WindowsComponents.cs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,25 @@ await Task.Run(()=>{
7272
}
7373
}
7474

75-
// why does the Format combobox doesnt turn to bright red its just a dim
76-
// unlike the others.
7775
public static void FreezeComponents(bool Freeze)
7876
{
79-
buttonFileFormat.IsEnabled = true;
80-
buttonDownload.IsEnabled = true;
81-
buttonUpdate.IsEnabled = true;
82-
buttonOpenFile.IsEnabled = true;
83-
textBoxLink.IsEnabled = true;
84-
textBoxName.IsEnabled = true;
85-
comboBoxType.IsEnabled = true;
86-
comboBoxFormat.IsEnabled = true;
77+
UIElement[] ControlLists =
78+
{
79+
buttonFileFormat,
80+
buttonDownload,
81+
buttonUpdate,
82+
buttonOpenFile,
83+
textBoxLink,
84+
textBoxName,
85+
comboBoxType,
86+
comboBoxFormat
87+
};
8788

89+
foreach(UIElement CL in ControlLists)
90+
CL.IsEnabled = true;
91+
8892
if(Freeze)
89-
{
90-
buttonFileFormat.IsEnabled = false;
91-
buttonDownload.IsEnabled = false;
92-
buttonUpdate.IsEnabled = false;
93-
buttonOpenFile.IsEnabled = false;
94-
textBoxLink.IsEnabled = false;
95-
textBoxName.IsEnabled = false;
96-
comboBoxType.IsEnabled = false;
97-
comboBoxFormat.IsEnabled = false;
98-
}
93+
foreach(UIElement CL in ControlLists)
94+
CL.IsEnabled = false;
9995
}
10096
}

Launcher DL/FodyWeavers.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
22
<Costura>
33
<IncludeAssemblies>
4-
INIFileParser
4+
IniParser
55
</IncludeAssemblies>
66
</Costura>
77
</Weavers>

Launcher DL/Launcher DL.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<AssemblyName>uVad</AssemblyName>
1919
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
2020
<NoWarn>NU1701,CS8981,NU1503</NoWarn>
21+
<AllowedReferenceRelatedFileExtensions>none</AllowedReferenceRelatedFileExtensions>
2122
</PropertyGroup>
2223

2324
<PropertyGroup>
@@ -57,7 +58,10 @@
5758
<PrivateAssets>all</PrivateAssets>
5859
<IncludeAssets>compile; runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5960
</PackageReference>
60-
<PackageReference Include="ini-parser" Version="2.5.2" />
61+
62+
<Reference Include="IniParser">
63+
<HintPath>./ini-parser [modified]/IniParser.dll</HintPath>
64+
</Reference>
6165
</ItemGroup>
6266

6367
<ItemGroup>

Launcher DL/MainWindow.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public MainWindow()
5656

5757
buttonOpenFile.Click += delegate
5858
{
59-
console.AddFormattedText("<%20>Test");
59+
WindowsComponents.FreezeComponents(false);
60+
console.AddFormattedText("<%20>UNFREEZE!");
6061
};
6162
}
6263
}
33.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)