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