imagine not even being able to create ini files when loading up your app for the first time.

This commit is contained in:
Bitl 2020-07-11 17:54:39 -07:00
parent f716115f09
commit 831677c922
1 changed files with 90 additions and 72 deletions

View File

@ -21,7 +21,7 @@ public class GlobalFuncs
string versionbranch, defaultclient, defaultmap, regclient1, string versionbranch, defaultclient, defaultmap, regclient1,
regclient2, issnapshot, snapshottemplate, snapshotrevision; regclient2, issnapshot, snapshottemplate, snapshotrevision;
IConfigSource ini = new IniConfigSource(infopath); IniConfigSource ini = new IniConfigSource(infopath);
string section = "ProgramInfo"; string section = "ProgramInfo";
@ -92,8 +92,16 @@ public class GlobalFuncs
{ {
if (write) if (write)
{ {
if (!File.Exists(cfgpath))
{
IniConfigSource createINI = new IniConfigSource();
createINI.AddConfig("Config");
createINI.Save(cfgpath);
Config(cfgpath, true);
}
//WRITE //WRITE
IConfigSource ini = new IniConfigSource(cfgpath); IniConfigSource ini = new IniConfigSource(cfgpath);
string section = "Config"; string section = "Config";
@ -119,6 +127,8 @@ public class GlobalFuncs
ini.Save(); ini.Save();
} }
else else
{
try
{ {
//READ //READ
string closeonlaunch, userid, name, selectedclient, string closeonlaunch, userid, name, selectedclient,
@ -126,7 +136,7 @@ public class GlobalFuncs
disablehelpmessage, tripcode, discord, mappath, mapsnip, disablehelpmessage, tripcode, discord, mappath, mapsnip,
graphics, reshade, qualitylevel, style, savebackups; graphics, reshade, qualitylevel, style, savebackups;
IConfigSource ini = new IniConfigSource(cfgpath); IniConfigSource ini = new IniConfigSource(cfgpath);
string section = "Config"; string section = "Config";
@ -149,8 +159,6 @@ public class GlobalFuncs
style = ini.Configs[section].Get("Style", Settings.UIOptions.GetIntForStyle(GlobalVars.UserConfiguration.LauncherStyle).ToString()); style = ini.Configs[section].Get("Style", Settings.UIOptions.GetIntForStyle(GlobalVars.UserConfiguration.LauncherStyle).ToString());
savebackups = ini.Configs[section].Get("AssetLocalizerSaveBackups", GlobalVars.UserConfiguration.AssetLocalizerSaveBackups.ToString()); savebackups = ini.Configs[section].Get("AssetLocalizerSaveBackups", GlobalVars.UserConfiguration.AssetLocalizerSaveBackups.ToString());
try
{
GlobalVars.UserConfiguration.CloseOnLaunch = Convert.ToBoolean(closeonlaunch); GlobalVars.UserConfiguration.CloseOnLaunch = Convert.ToBoolean(closeonlaunch);
if (userid.Equals("0")) if (userid.Equals("0"))
@ -212,8 +220,18 @@ public class GlobalFuncs
{ {
if (write) if (write)
{ {
if (!File.Exists(cfgpath))
{
IniConfigSource createINI = new IniConfigSource();
createINI.AddConfig("Items");
createINI.AddConfig("Colors");
createINI.AddConfig("Other");
createINI.Save(cfgpath);
Customization(cfgpath, true);
}
//WRITE //WRITE
IConfigSource ini = new IniConfigSource(cfgpath); IniConfigSource ini = new IniConfigSource(cfgpath);
string section = "Items"; string section = "Items";
@ -255,13 +273,15 @@ public class GlobalFuncs
{ {
//READ //READ
try
{
string hat1, hat2, hat3, face, string hat1, hat2, hat3, face,
head, tshirt, shirt, pants, icon, head, tshirt, shirt, pants, icon,
extra, headcolorid, headcolorstring, torsocolorid, torsocolorstring, extra, headcolorid, headcolorstring, torsocolorid, torsocolorstring,
larmid, larmstring, rarmid, rarmstring, llegid, larmid, larmstring, rarmid, rarmstring, llegid,
llegstring, rlegid, rlegstring, characterid, extraishat, showhatsonextra; llegstring, rlegid, rlegstring, characterid, extraishat, showhatsonextra;
IConfigSource ini = new IniConfigSource(cfgpath); IniConfigSource ini = new IniConfigSource(cfgpath);
string section = "Items"; string section = "Items";
@ -297,8 +317,6 @@ public class GlobalFuncs
extraishat = ini.Configs[section3].Get("ExtraSelectionIsHat", GlobalVars.UserCustomization.ExtraSelectionIsHat.ToString()); extraishat = ini.Configs[section3].Get("ExtraSelectionIsHat", GlobalVars.UserCustomization.ExtraSelectionIsHat.ToString());
showhatsonextra = ini.Configs[section3].Get("ShowHatsOnExtra", GlobalVars.UserCustomization.ShowHatsInExtra.ToString()); showhatsonextra = ini.Configs[section3].Get("ShowHatsOnExtra", GlobalVars.UserCustomization.ShowHatsInExtra.ToString());
try
{
GlobalVars.UserCustomization.Hat1 = hat1; GlobalVars.UserCustomization.Hat1 = hat1;
GlobalVars.UserCustomization.Hat2 = hat2; GlobalVars.UserCustomization.Hat2 = hat2;
GlobalVars.UserCustomization.Hat3 = hat3; GlobalVars.UserCustomization.Hat3 = hat3;
@ -343,7 +361,7 @@ public class GlobalFuncs
if (write) if (write)
{ {
//WRITE //WRITE
IConfigSource ini = new IniConfigSource(cfgpath); IniConfigSource ini = new IniConfigSource(cfgpath);
string section = "GENERAL"; string section = "GENERAL";
@ -360,7 +378,7 @@ public class GlobalFuncs
//READ //READ
string framerate, frametime, performance; string framerate, frametime, performance;
IConfigSource ini = new IniConfigSource(cfgpath); IniConfigSource ini = new IniConfigSource(cfgpath);
string section = "GENERAL"; string section = "GENERAL";