public void Awake() { this.scaleVar = RoR2.Console.instance.FindConVar("hud_scale"); this.RecalcBarRect(); // NEXT: Hook to pause screen to detect pause //RoR2.RoR2Application.ononPauseStartGlobal += () => this.paused = true; //RoR2.RoR2Application.onPauseEndGlobal += () => this.paused = false; }
// Token: 0x06000985 RID: 2437 RVA: 0x000296BC File Offset: 0x000278BC private void RegisterConVarInternal(BaseConVar conVar) { if (conVar == null) { Debug.LogWarning("Attempted to register null ConVar"); return; } this.allConVars[conVar.name] = conVar; if ((conVar.flags & ConVarFlags.Archive) != ConVarFlags.None) { this.archiveConVars.Add(conVar); } }
// Token: 0x06002333 RID: 9011 RVA: 0x00099DAC File Offset: 0x00097FAC private void SetScale() { BaseConVar baseConVar = Console.instance.FindConVar("hud_scale"); float num; if (baseConVar != null && TextSerialization.TryParseInvariant(baseConVar.GetString(), out num)) { Vector3 localScale = new Vector3(num / 100f, num / 100f, num / 100f); RectTransform[] array = this.rectTransforms; for (int i = 0; i < array.Length; i++) { array[i].localScale = localScale; } } }
public BaseCustomSetting(BaseConVar boolConvar, string settingName, string settingText = null) { conVar = boolConvar; settingname = settingName; if (settingText == null) { settingtext = settingName; } else { settingtext = settingText; } }
// Token: 0x060009A0 RID: 2464 RVA: 0x0002A224 File Offset: 0x00028424 private static string GetHelpText(string commandName) { Console.ConCommand conCommand; if (Console.instance.concommandCatalog.TryGetValue(commandName, out conCommand)) { return(string.Format(CultureInfo.InvariantCulture, "<color=#FF7F7F>\"{0}\"</color>\n- {1}", commandName, conCommand.helpText)); } BaseConVar baseConVar = Console.instance.FindConVar(commandName); if (baseConVar != null) { return(string.Format(CultureInfo.InvariantCulture, "<color=#FF7F7F>\"{0}\" = \"{1}\"</color>\n - {2}", commandName, baseConVar.GetString(), baseConVar.helpText)); } return(""); }
private void LoadConVars() { if (ConvarsToAdd.Count > 0) { Logger.LogInfo($"Registering {ConvarsToAdd.Count} ConVars"); } MethodInfo convarAddMethod = typeof(RoR2.Console).GetMethod("RegisterConVarInternal", BindingFlags.NonPublic | BindingFlags.Instance); if (convarAddMethod != null) { while (ConvarsToAdd.Count > 0) { BaseConVar convar = ConvarsToAdd.Dequeue(); convarAddMethod.Invoke(RoR2.Console.instance, new object[] { convar }); } } }
public BaseCustomSetting(BaseConVar boolConvar, string settingName, string settingText = null, string optionalText = "") { conVar = boolConvar; settingname = settingName; if (settingText == null) { settingtext = settingName; } else { settingtext = settingText; } this.optionalText = optionalText; listSettings.Add(this); }
// Token: 0x060020AF RID: 8367 RVA: 0x00099C6C File Offset: 0x00097E6C public string GetCurrentValue() { BaseSettingsControl.SettingSource settingSource = this.settingSource; if (settingSource != BaseSettingsControl.SettingSource.ConVar) { if (settingSource != BaseSettingsControl.SettingSource.UserProfilePref) { return(""); } UserProfile currentUserProfile = this.GetCurrentUserProfile(); return(((currentUserProfile != null) ? currentUserProfile.GetSaveFieldString(this.settingName) : null) ?? ""); } else { BaseConVar conVar = this.GetConVar(); if (conVar == null) { return(null); } return(conVar.GetString()); } }
// Token: 0x06000998 RID: 2456 RVA: 0x00029D98 File Offset: 0x00027F98 public void SaveArchiveConVars() { using (MemoryStream memoryStream = new MemoryStream()) { using (TextWriter textWriter = new StreamWriter(memoryStream, Encoding.UTF8)) { for (int i = 0; i < this.archiveConVars.Count; i++) { BaseConVar baseConVar = this.archiveConVars[i]; textWriter.Write(baseConVar.name); textWriter.Write(" "); textWriter.Write(baseConVar.GetString()); textWriter.Write(";\r\n"); } textWriter.Write("echo \"Loaded archived convars.\";"); textWriter.Flush(); RoR2Application.fileSystem.CreateDirectory("/Config/"); try { using (Stream stream = RoR2Application.fileSystem.OpenFile("/Config/config.cfg", FileMode.Create, FileAccess.Write, FileShare.None)) { if (stream != null) { stream.Write(memoryStream.GetBuffer(), 0, (int)memoryStream.Length); stream.Close(); } } } catch (IOException ex) { Debug.LogFormat("Failed to write archived convars: {0}", new object[] { ex.Message }); } } } }
// Token: 0x060020AD RID: 8365 RVA: 0x00099ACC File Offset: 0x00097CCC private void SubmitSettingInternal(string newValue) { if (this.originalValue == null) { this.originalValue = this.GetCurrentValue(); } if (this.originalValue == newValue) { this.originalValue = null; } BaseSettingsControl.SettingSource settingSource = this.settingSource; if (settingSource != BaseSettingsControl.SettingSource.ConVar) { if (settingSource == BaseSettingsControl.SettingSource.UserProfilePref) { UserProfile currentUserProfile = this.GetCurrentUserProfile(); if (currentUserProfile != null) { currentUserProfile.SetSaveFieldString(this.settingName, newValue); } UserProfile currentUserProfile2 = this.GetCurrentUserProfile(); if (currentUserProfile2 != null) { currentUserProfile2.RequestSave(false); } } } else { BaseConVar conVar = this.GetConVar(); if (conVar != null) { conVar.SetString(newValue); } } RoR2Application.onNextUpdate += this.UpdateControls; }
// Token: 0x06000984 RID: 2436 RVA: 0x0002946C File Offset: 0x0002766C private void InitConVars() { this.allConVars = new Dictionary <string, BaseConVar>(); this.archiveConVars = new List <BaseConVar>(); foreach (Type type in typeof(BaseConVar).Assembly.GetTypes()) { foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) { if (fieldInfo.FieldType.IsSubclassOf(typeof(BaseConVar))) { if (fieldInfo.IsStatic) { BaseConVar conVar = (BaseConVar)fieldInfo.GetValue(null); this.RegisterConVarInternal(conVar); } else if (type.GetCustomAttribute <CompilerGeneratedAttribute>() == null) { Debug.LogErrorFormat("ConVar defined as {0}.{1} could not be registered. ConVars must be static fields.", new object[] { type.Name, fieldInfo.Name }); } } } foreach (MethodInfo methodInfo in type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) { if (methodInfo.GetCustomAttribute <ConVarProviderAttribute>() != null) { if (methodInfo.ReturnType != typeof(IEnumerable <BaseConVar>) || methodInfo.GetParameters().Length != 0) { Debug.LogErrorFormat("ConVar provider {0}.{1} does not match the signature \"static IEnumerable<ConVar.BaseConVar>()\".", new object[] { type.Name, methodInfo.Name }); } else if (!methodInfo.IsStatic) { Debug.LogErrorFormat("ConVar provider {0}.{1} could not be invoked. Methods marked with the ConVarProvider attribute must be static.", new object[] { type.Name, methodInfo.Name }); } else { foreach (BaseConVar conVar2 in ((IEnumerable <BaseConVar>)methodInfo.Invoke(null, Array.Empty <object>()))) { this.RegisterConVarInternal(conVar2); } } } } } foreach (KeyValuePair <string, BaseConVar> keyValuePair in this.allConVars) { BaseConVar value = keyValuePair.Value; if ((value.flags & ConVarFlags.Engine) != ConVarFlags.None) { value.defaultValue = value.GetString(); } else if (value.defaultValue != null) { value.AttemptSetString(value.defaultValue); } } }
// Token: 0x0600098A RID: 2442 RVA: 0x00029854 File Offset: 0x00027A54 private void RunCmd(NetworkUser sender, string concommandName, List <string> userArgs) { bool flag = sender != null && !sender.isLocalPlayer; Console.ConCommand conCommand = null; BaseConVar baseConVar = null; ConVarFlags flags; if (this.concommandCatalog.TryGetValue(concommandName, out conCommand)) { flags = conCommand.flags; } else { baseConVar = this.FindConVar(concommandName); if (baseConVar == null) { Debug.LogFormat("\"{0}\" is not a recognized ConCommand or ConVar.", new object[] { concommandName }); return; } flags = baseConVar.flags; } bool flag2 = (flags & ConVarFlags.ExecuteOnServer) > ConVarFlags.None; if (!NetworkServer.active && flag2) { this.ForwardCmdToServer(new ConCommandArgs { sender = sender, commandName = concommandName, userArgs = userArgs }); return; } if (flag && (flags & ConVarFlags.SenderMustBeServer) != ConVarFlags.None) { Debug.LogFormat("Blocked server-only command {0} from remote user {1}.", new object[] { concommandName, sender.userName }); return; } if (flag && !flag2) { Debug.LogFormat("Blocked non-transmittable command {0} from remote user {1}.", new object[] { concommandName, sender.userName }); return; } if ((flags & ConVarFlags.Cheat) != ConVarFlags.None && !RoR2Application.cvCheats.boolValue) { Debug.LogFormat("Command \"{0}\" cannot be used while cheats are disabled.", new object[] { concommandName }); return; } if (conCommand != null) { try { conCommand.action(new ConCommandArgs { sender = sender, commandName = concommandName, userArgs = userArgs }); } catch (ConCommandException ex) { Debug.LogFormat("Command \"{0}\" failed: {1}", new object[] { concommandName, ex.Message }); } return; } if (baseConVar == null) { return; } if (userArgs.Count > 0) { baseConVar.AttemptSetString(userArgs[0]); return; } Debug.LogFormat("\"{0}\" = \"{1}\"\n{2}", new object[] { concommandName, baseConVar.GetString(), baseConVar.helpText }); }
// Token: 0x06000DEB RID: 3563 RVA: 0x00044880 File Offset: 0x00042A80 private void RunCmd(NetworkUser sender, string concommandName, List <string> userArgs) { bool active = NetworkServer.active; Console.ConCommand conCommand; if (this.concommandCatalog.TryGetValue(concommandName, out conCommand)) { if (!active && (conCommand.flags & ConVarFlags.ExecuteOnServer) > ConVarFlags.None) { this.ForwardCmdToServer(new ConCommandArgs { sender = sender, commandName = concommandName, userArgs = userArgs }); return; } if (NetworkServer.active && sender && !sender.isLocalPlayer && (conCommand.flags & ConVarFlags.SenderMustBeServer) != ConVarFlags.None) { return; } if ((conCommand.flags & ConVarFlags.Cheat) != ConVarFlags.None && !RoR2Application.cvCheats.boolValue) { Debug.LogFormat("Command \"{0}\" cannot be used while cheats are disabled.", new object[] { concommandName }); return; } try { conCommand.action(new ConCommandArgs { sender = sender, commandName = concommandName, userArgs = userArgs }); } catch (ConCommandException ex) { Debug.LogFormat("Command \"{0}\" failed: {1}", new object[] { concommandName, ex.Message }); } return; } else { BaseConVar baseConVar = this.FindConVar(concommandName); if (baseConVar == null) { Debug.LogFormat("\"{0}\" is not a recognized ConCommand or ConVar.", new object[] { concommandName }); return; } if (!active && (baseConVar.flags & ConVarFlags.ExecuteOnServer) > ConVarFlags.None) { this.ForwardCmdToServer(new ConCommandArgs { sender = sender, commandName = concommandName, userArgs = userArgs }); return; } if (NetworkServer.active && sender && !sender.isLocalPlayer && (baseConVar.flags & ConVarFlags.SenderMustBeServer) != ConVarFlags.None) { return; } if (userArgs.Count <= 0) { Debug.LogFormat("\"{0}\" = \"{1}\"\n{2}", new object[] { concommandName, baseConVar.GetString(), baseConVar.helpText }); return; } if ((baseConVar.flags & ConVarFlags.Cheat) != ConVarFlags.None && !RoR2Application.cvCheats.boolValue) { Debug.LogFormat("Command \"{0}\" cannot be changed while cheats are disabled.", new object[] { concommandName }); return; } baseConVar.SetString(userArgs[0]); return; } }