Property name refactor

This commit is contained in:
Terry Hearst 2023-09-03 00:06:26 -04:00
parent d848346421
commit 4514dc5f90

View file

@ -13,6 +13,10 @@ namespace CustomCosmeticLoader
public const string CONFIG_FILE_NAME = "config.json";
public const string SKINS_DIR_NAME = "skins";
public const string PROPERTY_ENABLED = "enabled";
public const string PROPERTY_CURRENT_SKIN = "currentSkin";
public const string PROPERTY_SKIN_TO_HIJACK = "skinToHijack";
public static bool enabled = true;
public static string currentSkin;
public static string skinToHijack = "Swirl_M"; // Mirage, simple skin with nice properties
@ -49,11 +53,11 @@ namespace CustomCosmeticLoader
return;
}
if (data["enabled"] != null)
enabled = data["enabled"].AsBool;
if (data[PROPERTY_ENABLED] != null)
enabled = data[PROPERTY_ENABLED].AsBool;
if (data["currentSkin"] != null)
currentSkin = data["currentSkin"].Value;
if (data[PROPERTY_CURRENT_SKIN] != null)
currentSkin = data[PROPERTY_CURRENT_SKIN].Value;
if (currentSkin == null || !skins.ContainsKey(currentSkin))
{
if (skins.Count == 0)
@ -65,17 +69,17 @@ namespace CustomCosmeticLoader
currentSkin = skins.Keys.ToList()[0];
}
if (data["skinToHijack"] != null)
skinToHijack = data["skinToHijack"].Value;
if (data[PROPERTY_SKIN_TO_HIJACK] != null)
skinToHijack = data[PROPERTY_SKIN_TO_HIJACK].Value;
}
public static void SaveConfig()
{
JSONNode node = new JSONClass
{
{ "enabled", enabled ? "true" : "false" },
{ "currentSkin", currentSkin },
{ "skinToHijack", skinToHijack }
{ PROPERTY_ENABLED, enabled ? "true" : "false" },
{ PROPERTY_CURRENT_SKIN, currentSkin },
{ PROPERTY_SKIN_TO_HIJACK, skinToHijack }
};
File.WriteAllText(GetConfigPath(), node.ToString());