Also here's my updated version that uses enums rather than static class consts and optionally using reflection, so there's less typing:
Replace "// Write out the tags" section with:
// Write out the tags
// GUI
WriteEnum(writer, ORK.GUIBoxes);
// combatant
WriteEnum(writer, ORK.StatusValues, "CombatantStatusValue");
WriteEnum(writer, ORK.StatusEffects, "CombatantStatusEffect");
WriteEnum(writer, ORK.Abilities, "CombatantAbility");
WriteEnum(writer, ORK.EquipmentParts, "CombatantEquipmentPart");
Add this private method
private static void WriteEnum(StreamWriter writer, BaseSettings values, string enumTypeName = "")
{
string name = enumTypeName;
if (string.IsNullOrEmpty(enumTypeName))
{
name = values.GetType().Name;
name = name.Replace("Settings", string.Empty);
name = name.Trim();
}
writer.WriteLine(@" // Derived from " + values.GetType().FullName);
writer.WriteLine(BuildEnum(name, values.GetNames(false).ToList()));
}
Change the Build Class to
private static string BuildEnum(string enumTypeName, List<string> enumValues)
{
StringBuilder sb = new StringBuilder(" public enum ");
sb.AppendLine(enumTypeName);
sb.AppendLine(" {");
try
{
for (int i = 0; i < enumValues.Count; i++)
{
sb.AppendLine(string.Format(" {0} = {1},", MakeSafeForCode(enumValues[i].ToUpper()), i));
}
}
catch (Exception ex)
{
Debug.LogError(string.Format("Could not generate class {0}: {1}", enumTypeName, ex.Message));
}
finally
{
sb.AppendLine(" }");
sb.AppendLine();
}
return sb.ToString();
}
This produces:
// Derived from ORKFramework.GUIBoxesSettings
public enum GUIBoxes
{
MainMenu = 0,
BottomDialogue = 1,
AreaNotification = 2,
}
// Derived from ORKFramework.StatusValuesSettings
public enum CombatantStatusValue
{
MaxHealth = 0,
Health = 1,
MaxStamina = 2,
}
This allows you to use enums (personal preference), and either use the actual name (such as "StatusValues" or provide your own name such as "CombatantStatusValues" as the enum type name.
I also changed it from upper snake case to Pascal case using below in the MakeSafeForCode method
str = cultureInfo.TextInfo.ToTitleCase(str.ToLower()).Replace("_", string.Empty);
If anyone wants the full class code, just let me know and I'll post its entirety to pastebin.