/// <summary> /// Gets a <see langword="bool"/> value saved in the loaded settings /// </summary> /// <param name="mod">The <see cref="Mod"/> that owns the setting</param> /// <param name="id">The id of the setting</param> /// <param name="defaultValue">The value that should be returned if no saved setting could be found</param> /// <returns>The value of the setting, will be the value of defaultValue if the option could not be found</returns> public static bool GetModdedSettingsBoolValue(Mod mod, string id, bool defaultValue) { object value = OptionsSaver.LoadSetting(mod, id); if (value != null && value is bool boolValue) { return(boolValue); } return(defaultValue); }
/// <summary> /// Gets a <see cref="string"/> value saved in the loaded settings /// </summary> /// <param name="mod">The <see cref="Mod"/> that owns the setting</param> /// <param name="id">The id of the setting</param> /// <param name="defaultValue">The value that should be returned if no saved setting could be found</param> /// <returns>The value of the setting, will be the value of defaultValue if the option could not be found</returns> public static string GetModdedSettingsStringValue(Mod mod, string id, string defaultValue) { object value = OptionsSaver.LoadSetting(mod, id); if (value != null && value is string) { return(value as string); } return(defaultValue); }
/// <summary> /// Gets a <see cref="KeyCode"/> value saved in the loaded settings /// </summary> /// <param name="mod">The <see cref="Mod"/> that owns the setting</param> /// <param name="id">The id of the setting</param> /// <param name="defaultValue">The value that should be returned if no saved setting could be found</param> /// <returns>The value of the setting, will be the value of defaultValue if the option could not be found</returns> public static KeyCode GetModdedSettingsKeyCodeValue(Mod mod, string id, KeyCode defaultValue) { object value = OptionsSaver.LoadSetting(mod, id); if (value != null && value is int intValue) { return((KeyCode)intValue); } return(defaultValue); }
/// <summary> /// Gets a <see langword="int"/> value saved in the loaded settings /// </summary> /// <param name="mod">The <see cref="Mod"/> that owns the setting</param> /// <param name="id">The id of the setting</param> /// <param name="defaultValue">The value that should be returned if no saved setting could be found</param> /// <returns>The value of the setting, will be the value of defaultValue if the option could not be found</returns> public static int GetModdedSettingsIntValue(Mod mod, string id, int defaultValue) { object value = OptionsSaver.LoadSetting(mod, id); if (value != null) { if (value is int intValue) { return(intValue); } if (value is long longValue) { return((int)longValue); } } return(defaultValue); }
/// <summary> /// Gets a <see langword="float"/> value saved in the loaded settings /// </summary> /// <param name="mod">The <see cref="Mod"/> that owns the setting</param> /// <param name="id">The id of the setting</param> /// <param name="defaultValue">The value that should be returned if no saved setting could be found</param> /// <returns>The value of the setting, will be the value of defaultValue if the option could not be found</returns> public static float GetModdedSettingsFloatValue(Mod mod, string id, float defaultValue) { object value = OptionsSaver.LoadSetting(mod, id); if (value != null) { if (value is float floatValue) { return(floatValue); } if (value is double doubleValue) { return((float)doubleValue); } } return(defaultValue); }