private static void StopError(On.RoR2.UI.BaseSettingsControl.orig_Awake orig, BaseSettingsControl self) { if (self.gameObject.name.Contains("VRModSetting")) { self.eventSystemLocator = self.GetComponent <MPEventSystemLocator>(); if (self.nameLabel && !string.IsNullOrEmpty(self.nameToken)) { self.nameLabel.token = self.nameToken; } return; } orig(self); }
private static void SubmitConfig(On.RoR2.UI.BaseSettingsControl.orig_SubmitSettingInternal orig, BaseSettingsControl self, string newValue) { if (self.gameObject.name.Contains("VRModSetting")) { ModConfig.ConfigSetting setting; if (ModConfig.settings.TryGetValue(self.settingName, out setting)) { ConfigEntryBase entry = setting.entry; if (entry.SettingType == typeof(bool)) { (entry as ConfigEntry <bool>).Value = newValue == "1"; } else if (entry.SettingType == typeof(int)) { float parsedValue = float.Parse(newValue); (entry as ConfigEntry <int>).Value = (int)parsedValue; } else if (entry.SettingType == typeof(float)) { float parsedValue = float.Parse(newValue, System.Globalization.CultureInfo.InvariantCulture); (entry as ConfigEntry <float>).Value = parsedValue; } else if (entry.SettingType == typeof(string)) { (entry as ConfigEntry <string>).Value = newValue; } } RoR2.RoR2Application.onNextUpdate += self.OnUpdateControls; return; } orig(self, newValue); }
private static string GetVRSettingValue(On.RoR2.UI.BaseSettingsControl.orig_GetCurrentValue orig, BaseSettingsControl self) { if (self.gameObject.name.Contains("VRModSetting")) { ModConfig.ConfigSetting setting; if (ModConfig.settings.TryGetValue(self.settingName, out setting)) { ConfigEntryBase entry = setting.entry; if (entry.SettingType == typeof(bool)) { return((entry as ConfigEntry <bool>).Value ? "1" : "0"); } else if (entry.SettingType == typeof(int)) { return(TextSerialization.ToStringInvariant((entry as ConfigEntry <int>).Value)); } else if (entry.SettingType == typeof(float)) { return(TextSerialization.ToStringInvariant((entry as ConfigEntry <float>).Value)); } else if (entry.SettingType == typeof(string)) { string value = (entry as ConfigEntry <string>).Value; if (Array.Exists((self as CarouselController).choices, x => x.convarValue == value)) { return(value); } else { return("#FFFFFF"); } } } else { return("0"); } } return(orig(self)); }