Solidify mod from config/directory errors
This commit is contained in:
parent
8e92d3a0fb
commit
2ac822a487
3 changed files with 30 additions and 17 deletions
32
Config.cs
32
Config.cs
|
@ -29,9 +29,13 @@ namespace CustomCosmeticLoader
|
|||
|
||||
public static void Init()
|
||||
{
|
||||
if (File.Exists(GetConfigPath()))
|
||||
bool configExists = File.Exists(GetConfigPath());
|
||||
if (configExists)
|
||||
ReadConfig();
|
||||
else
|
||||
|
||||
ensureSkinSelected();
|
||||
|
||||
if (!configExists && enabled)
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
|
@ -62,16 +66,6 @@ namespace CustomCosmeticLoader
|
|||
|
||||
if (data[PROPERTY_CURRENT_SKIN] != null)
|
||||
currentSkin = data[PROPERTY_CURRENT_SKIN].Value;
|
||||
if (currentSkin == null || !skins.ContainsKey(currentSkin))
|
||||
{
|
||||
if (skins.Count == 0)
|
||||
{
|
||||
Debug.LogWarning("No custom skins found, disabling");
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
currentSkin = skins.Keys.ToList()[0];
|
||||
}
|
||||
|
||||
if (data[PROPERTY_SKIN_NAME_TO_HIJACK] != null)
|
||||
skinNameToHijack = data[PROPERTY_SKIN_NAME_TO_HIJACK].Value;
|
||||
|
@ -96,5 +90,19 @@ namespace CustomCosmeticLoader
|
|||
|
||||
File.WriteAllText(GetConfigPath(), node.ToString());
|
||||
}
|
||||
|
||||
public static void ensureSkinSelected()
|
||||
{
|
||||
if (currentSkin == null || !skins.ContainsKey(currentSkin))
|
||||
{
|
||||
if (skins.Count == 0)
|
||||
{
|
||||
Debug.LogWarning("No custom skins found, disabling");
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
currentSkin = skins.Keys.ToList()[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,11 @@ namespace CustomCosmeticLoader
|
|||
{
|
||||
string skinsPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
skinsPath = Path.Combine(skinsPath, "skins");
|
||||
if (!Directory.Exists(skinsPath))
|
||||
{
|
||||
Debug.Log(skinsPath + " directory does not exist, no skins to load");
|
||||
return;
|
||||
}
|
||||
string printStr = "Loaded custom skins: ";
|
||||
foreach (string skinFile in Directory.GetFiles(skinsPath))
|
||||
{
|
||||
|
|
10
Shared.cs
10
Shared.cs
|
@ -6,21 +6,21 @@ namespace CustomCosmeticLoader
|
|||
public static class Shared
|
||||
{
|
||||
private static Cosmetic skinToHijack;
|
||||
private static bool noSkinToHijack = false;
|
||||
|
||||
public static Cosmetic SkinToHijack
|
||||
{
|
||||
get
|
||||
{
|
||||
if (noSkinToHijack)
|
||||
return null;
|
||||
if (skinToHijack == null)
|
||||
{
|
||||
DetermineSkinToHijack();
|
||||
if (skinToHijack == null)
|
||||
Debug.LogWarning("Couldn't hijack skin " + Config.skinNameToHijack);
|
||||
{
|
||||
Debug.LogWarning("Couldn't find skin " + Config.skinNameToHijack + " to hijack");
|
||||
Config.skinNameToHijack = "Swirl_M";
|
||||
DetermineSkinToHijack();
|
||||
}
|
||||
}
|
||||
|
||||
return skinToHijack;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue