Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of QuietPause Mono v1.0.0
Mods/QuietPause_Mono.dll
Decompiled 15 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using HarmonyLib; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using QuietPause; using S1Shared; using S1Shared.UI; using ScheduleOne; using ScheduleOne.Audio; using ScheduleOne.Core.Audio; using ScheduleOne.DevUtilities; using ScheduleOne.UI; using ScheduleOne.UI.MainMenu; using ScheduleOne.UI.Tooltips; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(QuietPauseMod), "QuietPause", "1.0.0", "BbIJABNPOBATEJb", "https://github.com/BbIJABNPOBATEJb/ScheduleI-Mods")] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: HarmonyDontPatchAll] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("QuietPause_Mono")] [assembly: AssemblyConfiguration("Mono")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e0261b1ee92870c45f3968e601d5a49616ce0ce0")] [assembly: AssemblyProduct("QuietPause_Mono")] [assembly: AssemblyTitle("QuietPause_Mono")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace S1Shared { internal sealed class CoRunner { private sealed class Routine { public readonly Stack<IEnumerator> Stack = new Stack<IEnumerator>(); public float WaitUntil; } private readonly List<Routine> _routines = new List<Routine>(); private readonly Action<Exception> _onError; public CoRunner(Action<Exception> onError) { _onError = onError; } public void Start(IEnumerator routine) { Routine routine2 = new Routine(); routine2.Stack.Push(routine); _routines.Add(routine2); } public void StopAll() { _routines.Clear(); } public void Tick() { float realtimeSinceStartup = Time.realtimeSinceStartup; for (int num = _routines.Count - 1; num >= 0; num--) { Routine routine = _routines[num]; if (!(realtimeSinceStartup < routine.WaitUntil)) { try { if (!Step(routine, realtimeSinceStartup)) { _routines.RemoveAt(num); } } catch (Exception obj) { _routines.RemoveAt(num); _onError(obj); } } } } private static bool Step(Routine r, float now) { while (r.Stack.Count > 0) { IEnumerator enumerator = r.Stack.Peek(); if (!enumerator.MoveNext()) { r.Stack.Pop(); continue; } object current = enumerator.Current; if (!(current is IEnumerator item)) { if (!(current is float num)) { if (current is int num2) { r.WaitUntil = now + (float)num2; return true; } return true; } r.WaitUntil = now + num; return true; } r.Stack.Push(item); } return false; } } internal static class SafePatcher { public static int Apply(Harmony harmony, Instance log) { int num = 0; Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(Assembly.GetExecutingAssembly()); foreach (Type type in typesFromAssembly) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Any()) { try { harmony.CreateClassProcessor(type).Patch(); } catch (Exception ex) { num++; log.Warning("Patch " + type.FullName + " not applied: " + (ex.InnerException ?? ex).Message); } } } return num; } } internal static class UiKit { public static void OnClick(Button button, Action action) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown button.onClick = new ButtonClickedEvent(); ((UnityEvent)button.onClick).AddListener(new UnityAction(action.Invoke)); } public static void OnValueChanged(Slider slider, Action<float> action) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown slider.onValueChanged = new SliderEvent(); ((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)action.Invoke); } public static void AddListener(Toggle toggle, Action<bool> action) { ((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)action.Invoke); } public static T? Get<T>(Component c) where T : Component { return c.GetComponent<T>(); } public static T? Get<T>(GameObject go) where T : Component { return Get<T>((Component)(object)go.transform); } public static T? InChildren<T>(Component c) where T : Component { return UnityQuery.GetComponentsInChildren<T>(c, includeInactive: true).FirstOrDefault(); } public static Transform? Find(Transform root, string name) { for (int i = 0; i < root.childCount; i++) { Transform child = root.GetChild(i); if (((Object)child).name == name) { return child; } Transform val = Find(child, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } public static List<Transform> Children(Transform t) { List<Transform> list = new List<Transform>(); for (int i = 0; i < t.childCount; i++) { list.Add(t.GetChild(i)); } return list; } public static string Namespace(Component c) { return ((object)c).GetType().Namespace ?? ""; } public static void SetMember(object target, string name, object? value) { Type type = target.GetType(); PropertyInfo propertyInfo = AccessTools.Property(type, name); if (propertyInfo != null && propertyInfo.CanWrite) { propertyInfo.SetValue(target, value); } else { AccessTools.Field(type, name)?.SetValue(target, value); } } } internal static class UnityQuery { public static List<T> ToManaged<T>(List<T>? list) { if (list != null) { return new List<T>(list); } return new List<T>(); } public static List<T> FindAllIncludingAssets<T>() where T : Object { List<T> list = new List<T>(); list.AddRange(Resources.FindObjectsOfTypeAll<T>()); return list; } public static List<T> FindInScenes<T>() where T : Component { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) List<T> list = new List<T>(); foreach (T item in UnityQuery.FindAllIncludingAssets<T>()) { Scene scene = ((Component)item).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { list.Add(item); } } return list; } public static T? GetComponentInParent<T>(Component component) where T : Component { return component.GetComponentInParent<T>(); } public static List<T> GetComponentsInChildren<T>(Component root, bool includeInactive) where T : Component { List<T> list = new List<T>(); list.AddRange(root.GetComponentsInChildren<T>(includeInactive)); return list; } public static bool TryCastTo<T>(Object? obj, out T result) where T : Object { result = (T)(object)((obj is T) ? obj : null); return (Object)(object)result != (Object)null; } public static string TypeName(Object obj) { return ((object)obj).GetType().Name; } public static string DumpHierarchy(Transform root, int maxDepth = 12) { StringBuilder sb = new StringBuilder(); Walk(root, 0); return sb.ToString(); void Walk(Transform t, int depth) { sb.Append(' ', depth * 2).Append(((Object)t).name).Append(((Component)t).gameObject.activeSelf ? "" : " [inactive]") .Append(" {"); Component[] components = ((Component)t).GetComponents<Component>(); foreach (Component val in components) { if (!((Object)(object)val == (Object)null)) { sb.Append(TypeName((Object)(object)val)).Append(' '); if (UnityQuery.TryCastTo<TMP_Text>((Object?)(object)val, out TMP_Text result)) { sb.Append("\"").Append(result.text?.Replace("\n", "\\n")).Append("\" "); } } } sb.Append("}\n"); if (depth < maxDepth) { for (int j = 0; j < t.childCount; j++) { Walk(t.GetChild(j), depth + 1); } } } } public static string PathOf(Transform t) { List<string> list = new List<string>(); Transform val = t; while ((Object)(object)val != (Object)null) { list.Add(((Object)val).name); val = val.parent; } list.Reverse(); return string.Join("/", list); } } } namespace S1Shared.UI { internal sealed class HudCanvas { private readonly string _name; private Canvas? _canvas; private CanvasScaler? _scaler; private TMP_FontAsset? _font; private Material? _outlineMaterial; public RectTransform? Root { get; private set; } public bool Visible { get { if ((Object)(object)_canvas != (Object)null) { return ((Behaviour)_canvas).enabled; } return false; } } public bool ShowWhilePaused { get; set; } public TMP_FontAsset? Font { get { if ((Object)(object)_font == (Object)null) { _font = FindHudFont(); } return _font; } } public Material? OutlineMaterial { get { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_outlineMaterial == (Object)null && (Object)(object)Font != (Object)null) { _outlineMaterial = new Material(((TMP_Asset)Font).material) { name = _name + " Outline" }; _outlineMaterial.EnableKeyword("OUTLINE_ON"); _outlineMaterial.SetFloat("_OutlineWidth", 0.22f); _outlineMaterial.SetColor("_OutlineColor", new Color(0f, 0f, 0f, 0.9f)); _outlineMaterial.SetFloat("_FaceDilate", 0.1f); } return _outlineMaterial; } } public float ScaleFactor { get { if (!((Object)(object)_scaler != (Object)null) || !(_scaler.scaleFactor > 0.01f)) { return 1f; } return _scaler.scaleFactor; } } public Vector2 Size { get { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Root != (Object)null)) { return new Vector2((float)Screen.width, (float)Screen.height); } Rect rect = Root.rect; return ((Rect)(ref rect)).size; } } public HudCanvas(string name) { _name = name; } public bool Tick() { HUD instance = Singleton<HUD>.Instance; if ((Object)(object)_canvas == (Object)null) { if ((Object)(object)instance == (Object)null) { return false; } Create(); } Canvas val = (((Object)(object)instance != (Object)null) ? instance.canvas : null); PauseMenu instance2 = Singleton<PauseMenu>.Instance; bool flag = (Object)(object)instance2 != (Object)null && instance2.IsPaused; bool flag2 = (Object)(object)val != (Object)null && (ShowWhilePaused || (((Behaviour)val).enabled && !flag)); if (((Behaviour)_canvas).enabled != flag2) { ((Behaviour)_canvas).enabled = flag2; } if ((Object)(object)val != (Object)null) { _canvas.sortingOrder = (ShowWhilePaused ? 30000 : (val.sortingOrder + 1)); float scaleFactor = val.scaleFactor; if (scaleFactor > 0.01f && !Mathf.Approximately(_scaler.scaleFactor, scaleFactor)) { _scaler.scaleFactor = scaleFactor; } } return flag2; } private void Create() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject(_name); Object.DontDestroyOnLoad((Object)(object)val); _canvas = val.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _scaler = val.AddComponent<CanvasScaler>(); _scaler.uiScaleMode = (ScaleMode)0; Root = UiKit.Get<RectTransform>(val); } public RectTransform NewRect(string name, Transform? parent = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = new GameObject(name).AddComponent<RectTransform>(); ((Transform)obj).SetParent((Transform)(((object)parent) ?? ((object)Root)), false); return obj; } public Image NewImage(string name, Transform? parent, Color color, Sprite? sprite = null) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Image val = ((Component)NewRect(name, parent)).gameObject.AddComponent<Image>(); val.sprite = sprite; if ((Object)(object)sprite != (Object)null && sprite.border != Vector4.zero) { val.type = (Type)1; } ((Graphic)val).color = color; ((Graphic)val).raycastTarget = false; return val; } public TextMeshProUGUI NewText(string name, Transform? parent, float size, Color color, bool outline = true) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = ((Component)NewRect(name, parent)).gameObject.AddComponent<TextMeshProUGUI>(); if ((Object)(object)Font != (Object)null) { ((TMP_Text)val).font = Font; } if (outline && (Object)(object)OutlineMaterial != (Object)null) { ((TMP_Text)val).fontSharedMaterial = OutlineMaterial; } ((TMP_Text)val).fontSize = size; ((Graphic)val).color = color; ((TMP_Text)val).alignment = (TextAlignmentOptions)514; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val).overflowMode = (TextOverflowModes)0; ((Graphic)val).raycastTarget = false; return val; } public Vector2 ScreenToCanvas(Vector2 screen) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) float num = (((Object)(object)_scaler != (Object)null && _scaler.scaleFactor > 0.01f) ? _scaler.scaleFactor : 1f); return screen / num; } private static TMP_FontAsset? FindHudFont() { HUD instance = Singleton<HUD>.Instance; if ((Object)(object)instance != (Object)null) { TMP_Text val = ((IEnumerable<TMP_Text>)UnityQuery.GetComponentsInChildren<TMP_Text>((Component)(object)instance, includeInactive: true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => (Object)(object)t.font != (Object)null)); if ((Object)(object)val != (Object)null) { return val.font; } } return TMP_Settings.defaultFontAsset; } } internal sealed class HudElement { private readonly Func<Vector2> _getPos; private readonly Action<Vector2> _setPos; private readonly Func<float> _getScale; private readonly Action<float> _setScale; public string Label { get; } public Vector2 DefaultPos { get; } public float DefaultScale { get; } public float MinScale { get; set; } = 0.4f; public float MaxScale { get; set; } = 3f; public RectTransform? Rect { get; set; } public Vector2 Position { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _getPos(); } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) _setPos(new Vector2(Mathf.Clamp01(value.x), Mathf.Clamp01(value.y))); } } public float Scale { get { return _getScale(); } set { _setScale(Mathf.Clamp(value, MinScale, MaxScale)); } } public HudElement(string label, Vector2 defaultPos, float defaultScale, Func<Vector2> getPos, Action<Vector2> setPos, Func<float> getScale, Action<float> setScale) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Label = label; DefaultPos = defaultPos; DefaultScale = defaultScale; _getPos = getPos; _setPos = setPos; _getScale = getScale; _setScale = setScale; } public void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Rect == (Object)null)) { Vector2 position = Position; RectTransform? rect = Rect; Vector2 anchorMin = (Rect.anchorMax = position); rect.anchorMin = anchorMin; Rect.pivot = new Vector2(0.5f, 0.5f); Rect.anchoredPosition = Vector2.zero; ((Transform)Rect).localScale = Vector3.one * Scale; } } public void Reset() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Position = DefaultPos; Scale = DefaultScale; Apply(); } } internal sealed class HudEditor { private static readonly Color FrameColor = new Color(1f, 0.82f, 0.25f, 1f); private readonly HudCanvas _canvas; private readonly SettingsWindow _window; private readonly IReadOnlyList<HudElement> _elements; private readonly List<GameObject> _decorations = new List<GameObject>(); private RectTransform? _panel; private RectTransform? _doneButton; private RectTransform? _resetButton; private HudElement? _dragging; private Vector2 _dragOffset; private bool _changed; public bool Active { get; private set; } public event Action? Started; public event Action<bool>? Finished; public HudEditor(HudCanvas canvas, SettingsWindow window, IReadOnlyList<HudElement> elements) { _canvas = canvas; _window = window; _elements = elements; } public void Begin() { if (Active || (Object)(object)_canvas.Root == (Object)null) { return; } Active = true; _changed = false; _window.SetHidden(hidden: true); _canvas.ShowWhilePaused = true; this.Started?.Invoke(); foreach (HudElement element in _elements) { Decorate(element); } BuildPanel(); } public void End() { if (!Active) { return; } Active = false; _dragging = null; foreach (GameObject decoration in _decorations) { if ((Object)(object)decoration != (Object)null) { Object.Destroy((Object)(object)decoration); } } _decorations.Clear(); _canvas.ShowWhilePaused = false; _window.SetHidden(hidden: false); this.Finished?.Invoke(_changed); } public void Tick() { if (!Active) { return; } if (!_window.IsOpen || (Object)(object)_canvas.Root == (Object)null) { End(); return; } try { HandleInput(); } catch (Exception ex) { MelonLogger.Warning("HUD editor input failed: " + ex.Message); End(); } } private void HandleInput() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) Vector2 val = Vector2.op_Implicit(Input.mousePosition); if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) { End(); return; } if (Input.GetMouseButtonDown(0)) { if (Contains(_doneButton, val)) { End(); return; } if (Contains(_resetButton, val)) { foreach (HudElement element in _elements) { element.Reset(); } _changed = true; return; } HudElement hudElement = ElementAt(val); if (hudElement != null) { _dragging = hudElement; _dragOffset = val - Vector2.op_Implicit(((Transform)hudElement.Rect).position); } } if (_dragging != null) { if (Input.GetMouseButton(0)) { Vector2 val2 = val - _dragOffset; Vector2 position = default(Vector2); ((Vector2)(ref position))..ctor(val2.x / (float)Screen.width, val2.y / (float)Screen.height); if (Mathf.Abs(val2.x - (float)Screen.width * 0.5f) < 10f) { position.x = 0.5f; } _dragging.Position = position; _dragging.Apply(); _changed = true; } else { _dragging = null; } } HudElement hudElement2 = ElementAt(val); if (hudElement2 != null) { float y = Input.mouseScrollDelta.y; if (Mathf.Abs(y) > 0.01f) { hudElement2.Scale *= 1f + 0.08f * Mathf.Sign(y); hudElement2.Apply(); _changed = true; } if (Input.GetMouseButtonDown(1)) { hudElement2.Reset(); _changed = true; } } } private HudElement? ElementAt(Vector2 mouse) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) for (int num = _elements.Count - 1; num >= 0; num--) { HudElement hudElement = _elements[num]; if ((Object)(object)hudElement.Rect != (Object)null && ((Component)hudElement.Rect).gameObject.activeInHierarchy && Contains(hudElement.Rect, mouse)) { return hudElement; } } return null; } private static bool Contains(RectTransform? rect, Vector2 screen) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rect != (Object)null) { return RectTransformUtility.RectangleContainsScreenPoint(rect, screen, (Camera)null); } return false; } private void Decorate(HudElement element) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)element.Rect == (Object)null)) { RectTransform val = _canvas.NewRect("EditorFrame", (Transform?)(object)element.Rect); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = new Vector2(-6f, -6f); val.offsetMax = new Vector2(6f, 6f); Image obj = ((Component)val).gameObject.AddComponent<Image>(); obj.sprite = SpriteKit.RoundedRect(6); obj.type = (Type)1; ((Graphic)obj).color = new Color(1f, 0.82f, 0.25f, 0.12f); ((Graphic)obj).raycastTarget = false; AddEdge(val, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, -2f), Vector2.zero); AddEdge(val, Vector2.zero, new Vector2(1f, 0f), Vector2.zero, new Vector2(0f, 2f)); AddEdge(val, Vector2.zero, new Vector2(0f, 1f), Vector2.zero, new Vector2(2f, 0f)); AddEdge(val, new Vector2(1f, 0f), Vector2.one, new Vector2(-2f, 0f), Vector2.zero); TextMeshProUGUI obj2 = _canvas.NewText("EditorLabel", (Transform?)(object)val, 18f, FrameColor); RectTransform rectTransform = ((TMP_Text)obj2).rectTransform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 1f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.anchoredPosition = new Vector2(0f, 4f); rectTransform.sizeDelta = new Vector2(300f, 24f); ((TMP_Text)obj2).text = element.Label; _decorations.Add(((Component)val).gameObject); } } private void AddEdge(RectTransform frame, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((Graphic)_canvas.NewImage("Edge", (Transform?)(object)frame, FrameColor)).rectTransform; rectTransform.anchorMin = anchorMin; rectTransform.anchorMax = anchorMax; rectTransform.offsetMin = offsetMin; rectTransform.offsetMax = offsetMax; } private void BuildPanel() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) Image val = _canvas.NewImage("HUD Editor", null, new Color(0.08f, 0.08f, 0.1f, 0.88f), SpriteKit.RoundedRect(10)); _panel = ((Graphic)val).rectTransform; RectTransform? panel = _panel; RectTransform? panel2 = _panel; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.66f); panel2.anchorMax = val2; panel.anchorMin = val2; _panel.pivot = new Vector2(0.5f, 0.5f); _panel.anchoredPosition = Vector2.zero; _panel.sizeDelta = new Vector2(760f, 104f); _decorations.Add(((Component)val).gameObject); TextMeshProUGUI obj = _canvas.NewText("Help", (Transform?)(object)_panel, 19f, Color.white, outline: false); RectTransform rectTransform = ((TMP_Text)obj).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.anchoredPosition = new Vector2(0f, -10f); rectTransform.sizeDelta = new Vector2(-24f, 30f); ((TMP_Text)obj).text = "Drag to move • Mouse wheel to resize • Right-click to reset"; _resetButton = MakeButton("Reset all", new Vector2(-110f, 14f), new Color(0.35f, 0.35f, 0.38f, 1f)); _doneButton = MakeButton("Done", new Vector2(110f, 14f), new Color(0.2f, 0.55f, 0.95f, 1f)); } private RectTransform MakeButton(string title, Vector2 pos, Color color) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((Graphic)_canvas.NewImage(title, (Transform?)(object)_panel, color, SpriteKit.RoundedRect(8))).rectTransform; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0f); rectTransform.anchorMax = val; rectTransform.anchorMin = val; rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.anchoredPosition = pos; rectTransform.sizeDelta = new Vector2(190f, 40f); TextMeshProUGUI obj = _canvas.NewText("Label", (Transform?)(object)rectTransform, 20f, Color.white, outline: false); RectTransform rectTransform2 = ((TMP_Text)obj).rectTransform; rectTransform2.anchorMin = Vector2.zero; rectTransform2.anchorMax = Vector2.one; val = (rectTransform2.offsetMin = (rectTransform2.offsetMax = Vector2.zero)); ((TMP_Text)obj).text = title; return rectTransform; } } internal sealed class PrefsFile { private readonly MelonPreferences_Category _category; private readonly List<Action> _resets = new List<Action>(); private readonly List<Action> _originals = new List<Action>(); private float _saveAt = -1f; public bool SavingDisabled { get; set; } public PrefsFile(string name) { _category = MelonPreferences.CreateCategory(name); } public MelonPreferences_Entry<T> Entry<T>(string id, T defaultValue, string description) { return _category.CreateEntry<T>(id, defaultValue, (string)null, description, false, false, (ValueValidator)null, (string)null); } public Setting<T> Add<T>(string id, T defaultValue, string description) { MelonPreferences_Entry<T> entry = Entry(id, defaultValue, description); Setting<T> setting = new Setting<T>(this, entry, defaultValue); _resets.Add(setting.Reset); T loaded = entry.Value; _originals.Add(delegate { entry.Value = loaded; }); return setting; } public void RestoreLoadedValues() { foreach (Action original in _originals) { original(); } } public void ResetAll() { foreach (Action reset in _resets) { reset(); } MarkDirty(); } public void MarkDirty() { _saveAt = Time.realtimeSinceStartup + 1f; } public void Tick() { if (_saveAt > 0f && Time.realtimeSinceStartup >= _saveAt) { SaveNow(); } } public void SaveNow() { _saveAt = -1f; if (!SavingDisabled) { _category.SaveToFile(false); } } } internal sealed class Setting<T> { private readonly PrefsFile _file; private readonly MelonPreferences_Entry<T> _entry; public T Default { get; } public T Value { get { return _entry.Value; } set { _entry.Value = value; _file.MarkDirty(); } } public Setting(PrefsFile file, MelonPreferences_Entry<T> entry, T defaultValue) { _file = file; _entry = entry; Default = defaultValue; } public void Reset() { _entry.Value = Default; } } internal static class Keys { private static bool _broken; public static bool Down(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if ((int)key == 0 || _broken) { return false; } try { if (GameInput.IsTyping) { return false; } return Input.GetKeyDown(key); } catch (Exception ex) { _broken = true; MelonLogger.Warning("Hotkeys disabled, legacy input unavailable: " + ex.Message); return false; } } } internal sealed class SettingsWindow { internal sealed class RowTemplates { public Transform? Slider; public Transform? Toggle; public Transform? Choice; public Transform? Button; public Transform? Hint; } private const int MaxTabs = 6; private const string CloneSuffix = "ModScreen"; private readonly string _screenName; private readonly string _buttonName; private readonly string _title; private readonly string? _pauseButtonTitle; private readonly List<SettingsTab> _tabs = new List<SettingsTab>(); private SettingsScreen? _screen; private RectTransform? _screenRect; private bool _buildFailed; private bool _openWhenPaused; private bool _wasOpen; private int _fitIn; private string? _subtitle; private TMP_Text? _subtitleLabel; public bool IsOpen { get { if ((Object)(object)_screen != (Object)null) { return ((MenuScreen)_screen).IsOpen; } return false; } } internal bool Syncing { get; private set; } public event Action? Closed; public event Action? Changed; public SettingsWindow(string id, string title, string? pauseButtonTitle) { _screenName = id + "ModScreen"; _buttonName = id + "Button"; _title = title; _pauseButtonTitle = pauseButtonTitle; } public SettingsTab Tab(string title) { if (_tabs.Count >= 6) { throw new InvalidOperationException("The settings screen has room for " + 6 + " tabs"); } SettingsTab settingsTab = new SettingsTab(this, title); _tabs.Add(settingsTab); return settingsTab; } public void SetSubtitle(string? text) { _subtitle = text; if ((Object)(object)_subtitleLabel != (Object)null) { _subtitleLabel.text = text ?? ""; } } public void Tick() { PauseMenu instance = Singleton<PauseMenu>.Instance; if ((Object)(object)_screen == (Object)null) { if (_wasOpen) { _wasOpen = false; this.Closed?.Invoke(); } if ((Object)(object)instance != (Object)null && !_buildFailed) { TryBuild(instance); } if ((Object)(object)instance == (Object)null) { _buildFailed = false; } return; } if (_openWhenPaused && (Object)(object)instance != (Object)null && instance.IsPaused) { _openWhenPaused = false; Open(); } bool isOpen = ((MenuScreen)_screen).IsOpen; if (_wasOpen && !isOpen) { this.Closed?.Invoke(); } _wasOpen = isOpen; if (_fitIn > 0 && --_fitIn == 0) { PlaceHints(); } } public void Toggle() { PauseMenu instance = Singleton<PauseMenu>.Instance; if (!((Object)(object)_screen == (Object)null) && !((Object)(object)instance == (Object)null)) { if (((MenuScreen)_screen).IsOpen) { ((MenuScreen)_screen).Close(); } else if (!instance.IsPaused) { instance.Pause(); _openWhenPaused = true; } else { Open(); } } } public void Open() { if ((Object)(object)_screen == (Object)null) { return; } Refresh(); foreach (ScrollRect componentsInChild in UnityQuery.GetComponentsInChildren<ScrollRect>((Component)(object)_screen, includeInactive: true)) { componentsInChild.verticalNormalizedPosition = 1f; } _fitIn = 2; ((MenuScreen)_screen).Open(); } public void SetHidden(bool hidden) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_screenRect == (Object)null)) { _screenRect.anchoredPosition = (Vector2)(hidden ? new Vector2(0f, 100000f) : Vector2.zero); } } public void Refresh() { if ((Object)(object)_screen == (Object)null) { return; } Syncing = true; try { foreach (SettingsTab tab in _tabs) { foreach (SettingsRow row in tab.Rows) { row.Sync(); } } } finally { Syncing = false; } } internal void NotifyChanged() { Refresh(); this.Changed?.Invoke(); } private void TryBuild(PauseMenu pause) { try { Build(pause); } catch (Exception arg) { _buildFailed = true; _screen = null; MelonLogger.Error($"{_title} window could not be built: {arg}"); } } private void Build(PauseMenu pause) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown SettingsScreen val = ((IEnumerable<SettingsScreen>)UnityQuery.GetComponentsInChildren<SettingsScreen>((Component)(object)pause, includeInactive: true)).FirstOrDefault((Func<SettingsScreen, bool>)((SettingsScreen s) => !((Object)s).name.EndsWith("ModScreen", StringComparison.Ordinal) && ((Object)s).name != "WorldRatesScreen")) ?? throw new InvalidOperationException("in-game Settings screen not found"); GameObject val2 = new GameObject(_title + " Holder"); val2.SetActive(false); GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, val2.transform); ((Object)val3).name = _screenName; SettingsScreen val4 = UiKit.Get<SettingsScreen>(val3); GameObject val5 = new GameObject("Unused"); val5.transform.SetParent(val3.transform, false); val5.SetActive(false); RowTemplates rowTemplates = new RowTemplates { Slider = FindRow(val3.transform, "Master"), Toggle = (FindRow(val3.transform, "VSync") ?? FindRow(val3.transform, "PauseOnLoseFocus")), Choice = FindRow(val3.transform, "Units"), Button = UiKit.Find(val3.transform, "ViewCommands"), Hint = UiKit.Find(val3.transform, "Hint") }; if ((Object)(object)rowTemplates.Slider == (Object)null) { throw new InvalidOperationException("slider template not found"); } StripSettingsBindings(val3.transform); Transform[] array = (Transform[])(object)new Transform[5] { rowTemplates.Slider, rowTemplates.Toggle, rowTemplates.Choice, rowTemplates.Button, rowTemplates.Hint }; foreach (Transform obj in array) { if (obj != null) { obj.SetParent(val5.transform, false); } } Transform val6 = UiKit.Find(val3.transform, "Blocker"); if ((Object)(object)val6 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val6).gameObject); } SettingsCategory[] categories = val4.Categories; for (int num2 = 0; num2 < categories.Length; num2++) { Transform val7 = UiKit.Find(categories[num2].Panel.transform, "Vertical Layout"); if ((Object)(object)val7 == (Object)null) { continue; } foreach (Transform item in UiKit.Children(val7)) { item.SetParent(val5.transform, false); } } val4.HostOnlyGameObjects = (GameObject[])(object)new GameObject[0]; SetText(val3.transform, "Title", _title); Transform val8 = UiKit.Find(val3.transform, "Version"); _subtitleLabel = ((val8 != null) ? UiKit.Get<TMP_Text>((Component)(object)val8) : null); if ((Object)(object)_subtitleLabel != (Object)null) { _subtitleLabel.text = _subtitle ?? ""; } for (int num3 = 0; num3 < categories.Length; num3++) { Toggle toggle = categories[num3].Toggle; if (num3 >= _tabs.Count) { ((Component)toggle).gameObject.SetActive(false); continue; } TMP_Text val9 = UiKit.InChildren<TMP_Text>((Component)(object)toggle); if ((Object)(object)val9 != (Object)null) { val9.text = _tabs[num3].Title; } UiKit.AddListener(toggle, delegate(bool on) { if (on) { _fitIn = 2; } }); Transform val10 = UiKit.Find(categories[num3].Panel.transform, "Vertical Layout"); if ((Object)(object)val10 == (Object)null) { continue; } foreach (SettingsRow row in _tabs[num3].Rows) { row.Build(val10, rowTemplates); } } val3.transform.SetParent(((Component)val).transform.parent, false); val3.transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex() + 1); Object.Destroy((Object)(object)val2); val3.SetActive(true); _screen = val4; _screenRect = UiKit.Get<RectTransform>(val3); if (_pauseButtonTitle != null) { AddPauseButton(pause); } Refresh(); MelonLogger.Msg(_title + " window ready"); } private static void StripSettingsBindings(Transform root) { foreach (MonoBehaviour componentsInChild in UnityQuery.GetComponentsInChildren<MonoBehaviour>((Component)(object)root, includeInactive: true)) { if (!((Object)(object)componentsInChild == (Object)null)) { string text = UiKit.Namespace((Component)(object)componentsInChild); string text2 = UnityQuery.TypeName((Object)(object)componentsInChild); if (text.EndsWith("ScheduleOne.UI.Settings", StringComparison.Ordinal) || text2 == "GameSettingsWindow" || text2 == "VersionText") { Object.DestroyImmediate((Object)(object)componentsInChild); } } } } private static Transform? FindRow(Transform root, string name) { Transform val = UiKit.Find(root, name); if (!((Object)(object)val != (Object)null) || !((Object)(object)val.parent != (Object)null) || !(((Object)val.parent).name == "Vertical Layout")) { return null; } return val; } private void AddPauseButton(PauseMenu pause) { Transform val = UiKit.Find((Transform)(object)pause.Container, "Panel"); Transform val2 = ((val != null) ? val.Find("Settings") : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && !((Object)(object)val.Find(_buttonName) != (Object)null)) { GameObject obj = Object.Instantiate<GameObject>(((Component)val2).gameObject, val, false); ((Object)obj).name = _buttonName; obj.transform.SetSiblingIndex(val2.GetSiblingIndex() + 1); TMP_Text val3 = UiKit.Get<TMP_Text>((Component)(object)obj.transform.Find("ButtonText")); if ((Object)(object)val3 != (Object)null) { val3.text = _pauseButtonTitle; } UiKit.OnClick(UiKit.Get<Button>(obj), Open); } } private void PlaceHints() { foreach (SettingsTab tab in _tabs) { foreach (SettingsRow row in tab.Rows) { row.PlaceHint(); } } } private static void SetText(Transform root, string name, string text) { Transform val = UiKit.Find(root, name); TMP_Text val2 = (((Object)(object)val != (Object)null) ? UiKit.Get<TMP_Text>((Component)(object)val) : null); if ((Object)(object)val2 != (Object)null) { val2.text = text; } } } internal sealed class SettingsTab { private readonly SettingsWindow _window; internal readonly List<SettingsRow> Rows = new List<SettingsRow>(); public string Title { get; } internal SettingsTab(SettingsWindow window, string title) { _window = window; Title = title; } public SettingsTab Slider(string label, string? hint, float min, float max, float step, Func<float> get, Action<float> set, Func<float, string> format) { Rows.Add(new SliderRow(_window, label, hint, min, max, step, get, set, format)); return this; } public SettingsTab Toggle(string label, string? hint, Func<bool> get, Action<bool> set) { Rows.Add(new ToggleRow(_window, label, hint, get, set)); return this; } public SettingsTab Choice(string label, string? hint, string[] options, Func<int> get, Action<int> set) { Rows.Add(new ChoiceRow(_window, label, hint, options, get, set)); return this; } public SettingsTab Button(string title, Action onClick) { Rows.Add(new ButtonRow(title, onClick)); return this; } public SettingsTab Text(string text, bool header = false) { Rows.Add(new TextRow(text, header)); return this; } } internal abstract class SettingsRow { protected TMP_Text? LabelText; protected RectTransform? HintRect; public abstract void Build(Transform layout, SettingsWindow.RowTemplates templates); public virtual void Sync() { } public void PlaceHint() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)HintRect == (Object)null) && !((Object)(object)LabelText == (Object)null) && ((Behaviour)LabelText).isActiveAndEnabled) { LabelText.ForceMeshUpdate(false, false); Bounds textBounds = LabelText.textBounds; float x = ((Bounds)(ref textBounds)).size.x; Rect rect = LabelText.rectTransform.rect; float num = Mathf.Min(x, ((Rect)(ref rect)).width); HintRect.anchoredPosition = new Vector2(num + 8f, 0f); } } protected static GameObject Clone(Transform template, Transform layout, string name) { GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject, layout, false); ((Object)obj).name = name; obj.SetActive(true); return obj; } protected void AddHint(Transform? template, TMP_Text label, string? hint) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)template == (Object)null) && !string.IsNullOrEmpty(hint)) { GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject, label.transform, false); obj.SetActive(true); Tooltip val = UiKit.Get<Tooltip>(obj); if ((Object)(object)val != (Object)null) { val.text = hint; } RectTransform val2 = UiKit.Get<RectTransform>(obj); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f, 0.5f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(0f, 0.5f); val2.anchoredPosition = new Vector2(label.preferredWidth + 8f, 0f); HintRect = val2; } } private static float LeftEdgeIn(Transform row, RectTransform control) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Rect rect = control.rect; float num = ((Rect)(ref rect)).xMin; Transform val = (Transform)(object)control; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)row) { num = val.localPosition.x + val.localScale.x * num; val = val.parent; } return num; } internal static void FitLabelColumn(Transform row, TMP_Text label, RectTransform control, bool roomForHint = true) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) RectTransform val = UiKit.Get<RectTransform>((Component)(object)row); RectTransform rectTransform = label.rectTransform; float x = ((Transform)rectTransform).localPosition.x; Rect rect = rectTransform.rect; float num = x + ((Rect)(ref rect)).xMin; float num2 = LeftEdgeIn(row, control) - (roomForHint ? 30f : 12f); rect = rectTransform.rect; float height = ((Rect)(ref rect)).height; float y = ((Transform)rectTransform).localPosition.y; rect = rectTransform.rect; float num3 = y + ((Rect)(ref rect)).center.y; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 0.5f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.pivot = new Vector2(0f, 0.5f); rectTransform.sizeDelta = new Vector2(Mathf.Max(60f, num2 - num), height); rect = val.rect; float num4 = num - ((Rect)(ref rect)).xMin; rect = val.rect; rectTransform.anchoredPosition = new Vector2(num4, num3 - ((Rect)(ref rect)).center.y); label.textWrappingMode = (TextWrappingModes)0; label.fontSizeMax = label.fontSize; label.fontSizeMin = label.fontSize * 0.6f; label.enableAutoSizing = true; } } internal sealed class SliderRow : SettingsRow { private readonly SettingsWindow _window; private readonly string _label; private readonly string? _hint; private readonly float _min; private readonly float _max; private readonly float _step; private readonly Func<float> _get; private readonly Action<float> _set; private readonly Func<float, string> _format; private Slider? _slider; private TMP_Text? _value; public SliderRow(SettingsWindow window, string label, string? hint, float min, float max, float step, Func<float> get, Action<float> set, Func<float, string> format) { _window = window; _label = label; _hint = hint; _min = min; _max = max; _step = step; _get = get; _set = set; _format = format; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { GameObject obj = SettingsRow.Clone(templates.Slider, layout, _label); UISlider val = UiKit.Get<UISlider>(obj); if ((Object)(object)val != (Object)null) { UiKit.SetMember(val, "optionName", _label); UiKit.SetMember(val, "canUpdateValueText", false); } TMP_Text val2 = UiKit.Get<TMP_Text>((Component)(object)obj.transform.Find("Label")); val2.text = _label; Slider val3 = UiKit.InChildren<Slider>((Component)(object)obj.transform); SettingsRow.FitLabelColumn(obj.transform, val2, UiKit.Get<RectTransform>((Component)(object)((Component)val3).transform)); _value = UiKit.Get<TMP_Text>((Component)(object)((Component)val3).transform.Find("Value")); val3.wholeNumbers = true; val3.minValue = Mathf.Round(_min / _step); val3.maxValue = Mathf.Round(_max / _step); UiKit.OnValueChanged(val3, delegate(float v) { if (!_window.Syncing) { _set(v * _step); _window.NotifyChanged(); } }); _slider = val3; LabelText = val2; AddHint(templates.Hint, val2, _hint); } public override void Sync() { if (!((Object)(object)_slider == (Object)null)) { float num = _get(); _slider.value = Mathf.Round(num / _step); if ((Object)(object)_value != (Object)null) { _value.text = _format(num); } } } } internal sealed class ToggleRow : SettingsRow { private readonly SettingsWindow _window; private readonly string _label; private readonly string? _hint; private readonly Func<bool> _get; private readonly Action<bool> _set; private UIToggle? _toggle; public ToggleRow(SettingsWindow window, string label, string? hint, Func<bool> get, Action<bool> set) { _window = window; _label = label; _hint = hint; _get = get; _set = set; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { if (!((Object)(object)templates.Toggle == (Object)null)) { GameObject val = SettingsRow.Clone(templates.Toggle, layout, _label); UIToggle val2 = UiKit.Get<UIToggle>(val); UiKit.SetMember(val2, "optionName", _label); TMP_Text val3 = UnityQuery.GetComponentsInChildren<TMP_Text>((Component)(object)val.transform, includeInactive: true).First((TMP_Text t) => ((Object)t).name.StartsWith("Option Name", StringComparison.Ordinal)); val3.text = _label; Transform val4 = val.transform.Find("Toggle (OffOn)"); if ((Object)(object)val4 != (Object)null) { SettingsRow.FitLabelColumn(val.transform, val3, UiKit.Get<RectTransform>((Component)(object)val4)); } val2.OnChanged.AddListener((UnityAction<bool>)OnChanged); _toggle = val2; LabelText = val3; AddHint(templates.Hint, val3, _hint); } } private void OnChanged(bool value) { if (!_window.Syncing) { _set(value); _window.NotifyChanged(); } } public override void Sync() { UIToggle? toggle = _toggle; if (toggle != null) { toggle.SetStateWithoutNotify(_get()); } } } internal sealed class ChoiceRow : SettingsRow { private readonly SettingsWindow _window; private readonly string _label; private readonly string? _hint; private readonly string[] _options; private readonly Func<int> _get; private readonly Action<int> _set; private TMP_Dropdown? _dropdown; public ChoiceRow(SettingsWindow window, string label, string? hint, string[] options, Func<int> get, Action<int> set) { _window = window; _label = label; _hint = hint; _options = options; _get = get; _set = set; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown if (!((Object)(object)templates.Choice == (Object)null)) { GameObject obj = SettingsRow.Clone(templates.Choice, layout, _label); TMP_Dropdown val = UnityQuery.GetComponentsInChildren<TMP_Dropdown>((Component)(object)obj.transform, includeInactive: true).First(); TMP_Text val2 = UnityQuery.GetComponentsInChildren<TMP_Text>((Component)(object)obj.transform, includeInactive: true).First((TMP_Text t) => ((Object)t).name.StartsWith("Option Name", StringComparison.Ordinal)); val2.text = _label; SettingsRow.FitLabelColumn(obj.transform, val2, UiKit.Get<RectTransform>((Component)(object)((Component)val).transform)); ((UnityEventBase)val.onValueChanged).RemoveAllListeners(); val.ClearOptions(); string[] options = _options; foreach (string text in options) { val.options.Add(new OptionData(text)); } ((UnityEvent<int>)(object)val.onValueChanged).AddListener((UnityAction<int>)OnSelected); _dropdown = val; LabelText = val2; AddHint(templates.Hint, val2, _hint); } } private void OnSelected(int index) { if (!_window.Syncing && index >= 0 && index < _options.Length) { _set(index); _window.NotifyChanged(); } } public override void Sync() { if (!((Object)(object)_dropdown == (Object)null)) { _dropdown.SetValueWithoutNotify(Mathf.Clamp(_get(), 0, _options.Length - 1)); _dropdown.RefreshShownValue(); } } } internal sealed class ButtonRow : SettingsRow { private const float ButtonWidth = 460f; private readonly string _title; private readonly Action _onClick; public ButtonRow(string title, Action onClick) { _title = title; _onClick = onClick; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)templates.Button == (Object)null)) { GameObject val = SettingsRow.Clone(templates.Button, layout, "Button " + _title); TMP_Text val2 = UiKit.InChildren<TMP_Text>((Component)(object)val.transform); if ((Object)(object)val2 != (Object)null) { val2.text = _title; val2.enableAutoSizing = true; val2.fontSizeMax = val2.fontSize; val2.fontSizeMin = val2.fontSize * 0.65f; } RectTransform val3 = UiKit.Get<RectTransform>(val); val3.sizeDelta = new Vector2(Mathf.Max(val3.sizeDelta.x, 460f), val3.sizeDelta.y); LayoutElement? obj = UiKit.Get<LayoutElement>(val) ?? val.AddComponent<LayoutElement>(); float minWidth = (obj.preferredWidth = 460f); obj.minWidth = minWidth; UiKit.OnClick(UiKit.Get<Button>(val), _onClick); } } } internal sealed class TextRow : SettingsRow { private readonly string _text; private readonly bool _header; public TextRow(string text, bool header) { _text = text; _header = header; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) GameObject obj = SettingsRow.Clone(templates.Slider, layout, _header ? "Header" : "Text"); UISlider val = UiKit.Get<UISlider>(obj); if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } Slider val2 = UiKit.InChildren<Slider>((Component)(object)obj.transform); if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val2).gameObject); } TMP_Text val3 = UiKit.Get<TMP_Text>((Component)(object)obj.transform.Find("Label")); RectTransform rectTransform = val3.rectTransform; rectTransform.anchorMin = new Vector2(0f, rectTransform.anchorMin.y); rectTransform.anchorMax = new Vector2(1f, rectTransform.anchorMax.y); rectTransform.offsetMax = new Vector2(-10f, rectTransform.offsetMax.y); val3.textWrappingMode = (TextWrappingModes)1; if (_header) { val3.fontStyle = (FontStyles)(val3.fontStyle | 1); } else { val3.fontStyle = (FontStyles)(val3.fontStyle | 2); } val3.text = _text; } } internal static class SpriteKit { private static readonly Dictionary<int, Sprite> Rounded = new Dictionary<int, Sprite>(); private static Sprite? _glow; private static Sprite? _arrow; public static Sprite RoundedRect(int radius) { //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) if (Rounded.TryGetValue(radius, out Sprite value) && (Object)(object)value != (Object)null) { return value; } int num = radius * 2 + 4; Color32[] array = (Color32[])(object)new Color32[num * num]; Rect val = default(Rect); ((Rect)(ref val))..ctor((float)radius + 0.5f, (float)radius + 0.5f, (float)(num - 2 * radius) - 1f, (float)(num - 2 * radius) - 1f); for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num2 = (float)j + 0.5f; float num3 = (float)i + 0.5f; float num4 = Mathf.Max(new float[3] { ((Rect)(ref val)).xMin - num2, 0f, num2 - ((Rect)(ref val)).xMax }); float num5 = Mathf.Max(new float[3] { ((Rect)(ref val)).yMin - num3, 0f, num3 - ((Rect)(ref val)).yMax }); float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5); float num7 = Mathf.Clamp01((float)radius - num6 + 0.5f); array[i * num + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num7 * 255f)); } } float num8 = (float)radius + 1f; Sprite val2 = MakeSprite("Rounded" + radius, num, num, array, new Vector4(num8, num8, num8, num8)); Rounded[radius] = val2; return val2; } public static Sprite Glow() { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_glow != (Object)null) { return _glow; } Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = ((float)j + 0.5f) / 64f * 2f - 1f; float num2 = ((float)i + 0.5f) / 64f * 2f - 1f; float num3 = Mathf.Clamp01(Mathf.Sqrt(num * num + num2 * num2)); float num4 = (1f - num3) * (1f - num3); array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num4 * 255f)); } } _glow = MakeSprite("Glow", 64, 64, array, Vector4.zero); return _glow; } public static Sprite FlatArrow() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_arrow != (Object)null) { return _arrow; } Vector2[] poly = (Vector2[])(object)new Vector2[4] { new Vector2(32f, 62f), new Vector2(58f, 6f), new Vector2(32f, 20f), new Vector2(6f, 6f) }; Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = 0; for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { if (Inside(poly, new Vector2((float)j + ((float)l + 0.5f) / 4f, (float)i + ((float)k + 0.5f) / 4f))) { num++; } } } array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num * 255 / 16)); } } _arrow = MakeSprite("FlatArrow", 64, 64, array, Vector4.zero); return _arrow; } private static bool Inside(Vector2[] poly, Vector2 p) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) bool flag = false; int num = 0; int num2 = poly.Length - 1; while (num < poly.Length) { if (poly[num].y > p.y != poly[num2].y > p.y && p.x < (poly[num2].x - poly[num].x) * (p.y - poly[num].y) / (poly[num2].y - poly[num].y) + poly[num].x) { flag = !flag; } num2 = num++; } return flag; } private static Sprite MakeSprite(string name, int width, int height, Color32[] pixels, Vector4 border) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height, (TextureFormat)4, false) { name = "S1Mods " + name, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; val.SetPixels32(pixels); val.Apply(false, true); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, border); ((Object)obj).name = ((Object)val).name; ((Object)obj).hideFlags = (HideFlags)61; return obj; } } } namespace QuietPause { internal static class AudioGate { private const float FadeInSeconds = 0.35f; private static float _volume = 1f; private static bool _ownsVolume; private static bool _pauseApplied; private static bool _appliedMusic; public static bool Paused => _pauseApplied; public static float Volume => _volume; public static void Tick() { try { UpdateVolume(); UpdatePause(); } catch (Exception ex) { MelonLogger.Warning("Audio update failed: " + ex.Message); } } public static void Reset() { if (_pauseApplied) { AudioListener.pause = false; _pauseApplied = false; } } private static void UpdateVolume() { float num = ((!Application.isFocused && Config.MuteInBackground) ? ((float)Config.BackgroundVolume / 100f) : 1f); if (num < _volume) { _volume = num; } else if (num > _volume) { _volume = Mathf.MoveTowards(_volume, num, Time.unscaledDeltaTime / 0.35f); } if (_ownsVolume || !(_volume >= 1f)) { AudioListener.volume = _volume; _ownsVolume = _volume < 1f; } } private static void UpdatePause() { PauseMenu instance = Singleton<PauseMenu>.Instance; bool flag = Config.MuteWhenPaused && (Object)(object)instance != (Object)null && instance.IsPaused; if (flag && (!_pauseApplied || _appliedMusic != Config.MusicWhenPaused)) { KeepMenuSoundsAudible(); } if (flag != _pauseApplied) { AudioListener.pause = flag; _pauseApplied = flag; } } private static void KeepMenuSoundsAudible() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 _appliedMusic = Config.MusicWhenPaused; foreach (AudioSourceController item in UnityQuery.FindInScenes<AudioSourceController>()) { try { AudioSource val = UiKit.Get<AudioSource>((Component)(object)item); if (!((Object)(object)val == (Object)null)) { EAudioType audioType = item.ExtractAudioSettings().AudioType; val.ignoreListenerPause = (int)audioType == 3 || ((int)audioType == 4 && _appliedMusic); } } catch (Exception) { } } } } internal static class AudioSettingsRows { [HarmonyPatch(typeof(SettingsScreen), "Awake")] private static class SettingsAwakePatch { private static void Postfix(SettingsScreen __instance) { try { Inject(__instance); } catch (Exception arg) { MelonLogger.Error($"Audio settings rows failed: {arg}"); } } } private const string Marker = "QuietPause Mute In Background"; private static void Inject(SettingsScreen screen) { if (((Object)screen).name.EndsWith("ModScreen", StringComparison.Ordinal) || ((Object)screen).name == "WorldRatesScreen") { return; } Transform val = UiKit.Find(((Component)screen).transform, "Master"); Transform val2 = ((val != null) ? val.parent : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || ((Object)val2).name != "Vertical Layout" || (Object)(object)val2.Find("QuietPause Mute In Background") != (Object)null) { return; } Transform val3 = UiKit.Find(((Component)screen).transform, "PauseOnLoseFocus") ?? UiKit.Find(((Component)screen).transform, "VSync"); if (!((Object)(object)val3 == (Object)null)) { AddToggle(val2, val3, "QuietPause Mute In Background", "Mute in background", () => Config.MuteInBackground, delegate(bool v) { Config.MuteInBackground = v; }); AddSlider(val2, val, "QuietPause Background Volume", "Background volume", () => Config.BackgroundVolume, delegate(int v) { Config.BackgroundVolume = v; }); AddToggle(val2, val3, "QuietPause Mute When Paused", "Mute when paused", () => Config.MuteWhenPaused, delegate(bool v) { Config.MuteWhenPaused = v; }); AddToggle(val2, val3, "QuietPause Music When Paused", "Music in pause menu", () => Config.MusicWhenPaused, delegate(bool v) { Config.MusicWhenPaused = v; }); } } private static GameObject CloneStripped(Transform template, Transform layout, string name) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown GameObject val = new GameObject("QuietPause Holder"); val.SetActive(false); GameObject val2 = Object.Instantiate<GameObject>(((Component)template).gameObject, val.transform); ((Object)val2).name = name; foreach (MonoBehaviour componentsInChild in UnityQuery.GetComponentsInChildren<MonoBehaviour>((Component)(object)val2.transform, includeInactive: true)) { if ((Object)(object)componentsInChild != (Object)null && UiKit.Namespace((Component)(object)componentsInChild).EndsWith("ScheduleOne.UI.Settings", StringComparison.Ordinal)) { Object.DestroyImmediate((Object)(object)componentsInChild); } } return val2; } private static void Activate(GameObject row, GameObject holder, Transform layout) { row.transform.SetParent(layout, false); row.transform.SetAsLastSibling(); Object.Destroy((Object)(object)holder); } private static void AddToggle(Transform layout, Transform template, string name, string label, Func<bool> get, Action<bool> set) { GameObject val = CloneStripped(template, layout, name); GameObject gameObject = ((Component)val.transform.parent).gameObject; UIToggle val2 = UiKit.Get<UIToggle>(val); if ((Object)(object)val2 == (Object)null) { Object.Destroy((Object)(object)gameObject); return; } UiKit.SetMember(val2, "optionName", label); TMP_Text val3 = ((IEnumerable<TMP_Text>)UnityQuery.GetComponentsInChildren<TMP_Text>((Component)(object)val.transform, includeInactive: true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => ((Object)t).name.StartsWith("Option Name", StringComparison.Ordinal))); Transform val4 = val.transform.Find("Toggle (OffOn)"); Activate(val, gameObject, layout); if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null) { SettingsRow.FitLabelColumn(val.transform, val3, UiKit.Get<RectTransform>((Component)(object)val4), roomForHint: false); } val2.SetStateWithoutNotify(get()); Action<bool> action = set.Invoke; val2.OnChanged.AddListener((UnityAction<bool>)action.Invoke); } private static void AddSlider(Transform layout, Transform template, string name, string label, Func<int> get, Action<int> set) { GameObject val = CloneStripped(template, layout, name); GameObject gameObject = ((Component)val.transform.parent).gameObject; UISlider val2 = UiKit.Get<UISlider>(val); if ((Object)(object)val2 != (Object)null) { UiKit.SetMember(val2, "optionName", label); } TMP_Text val3 = UiKit.Get<TMP_Text>((Component)(object)val.transform.Find("Label")); if ((Object)(object)val3 != (Object)null) { val3.text = label; } Slider val4 = UiKit.InChildren<Slider>((Component)(object)val.transform); if ((Object)(object)val4 == (Object)null) { Object.Destroy((Object)(object)gameObject); return; } val4.wholeNumbers = true; val4.minValue = 0f; val4.maxValue = 100f; val4.SetValueWithoutNotify((float)get()); UiKit.OnValueChanged(val4, delegate(float v) { set(Mathf.RoundToInt(v)); }); Activate(val, gameObject, layout); if ((Object)(object)val3 != (Object)null) { SettingsRow.FitLabelColumn(val.transform, val3, UiKit.Get<RectTransform>((Component)(object)((Component)val4).transform), roomForHint: false); } } } internal static class Config { public static PrefsFile Prefs; private static MelonPreferences_Entry<bool> _muteInBackground; private static MelonPreferences_Entry<int> _backgroundVolume; private static MelonPreferences_Entry<bool> _muteWhenPaused; private static MelonPreferences_Entry<bool> _musicWhenPaused; public static bool MuteInBackground { get { return _muteInBackground.Value; } set { Set(_muteInBackground, value); } } public static int BackgroundVolume { get { return Mathf.Clamp(_backgroundVolume.Value, 0, 100); } set { Set(_backgroundVolume, Mathf.Clamp(value, 0, 100)); } } public static bool MuteWhenPaused { get { return _muteWhenPaused.Value; } set { Set(_muteWhenPaused, value); } } public static bool MusicWhenPaused { get { return _musicWhenPaused.Value; } set { Set(_musicWhenPaused, value); } } public static void Init() { Prefs = new PrefsFile("QuietPause"); _muteInBackground = Prefs.Entry("MuteInBackground", defaultValue: true, "Mute the game while its window is minimized or another window has focus."); _backgroundVolume = Prefs.Entry("BackgroundVolume", 0, "Volume (0-100 %) while the game is in the background. 0 = silent."); _muteWhenPaused = Prefs.Entry("MuteWhenPaused", defaultValue: true, "Pause world sounds (ambience, footsteps, vehicles, voices...) while the pause menu is open. Menu clicks stay audible."); _musicWhenPaused = Prefs.Entry("MusicWhenPaused", defaultValue: false, "Keep the music playing in the pause menu."); } private static void Set<T>(MelonPreferences_Entry<T> entry, T value) { entry.Value = value; Prefs.MarkDirty(); } } internal static class ModInfo { public const string Name = "QuietPause"; public const string Version = "1.0.0"; public const string Author = "BbIJABNPOBATEJb"; public const string DownloadLink = "https://github.com/BbIJABNPOBATEJb/ScheduleI-Mods"; } public sealed class QuietPauseMod : MelonMod { private CoRunner _runner; public override void OnInitializeMelon() { SafePatcher.Apply(((MelonBase)this).HarmonyInstance, ((MelonBase)this).LoggerInstance); Config.Init(); _runner = new CoRunner(delegate(Exception ex) { ((MelonBase)this).LoggerInstance.Error((object)ex); }); ((MelonBase)this).LoggerInstance.Msg("QuietPause 1.0.0 loaded"); } public override void OnUpdate() { _runner.Tick(); AudioGate.Tick(); Config.Prefs.Tick(); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { AudioGate.Reset(); } public override void OnApplicationQuit() { AudioGate.Reset(); Config.Prefs.SaveNow(); } } }