Decompiled source of BlueSage QoL Tweaks Beta v0.2.7
BepInEx/plugins/BlueSage_QoL_Tweaks_Beta/BlueSage_QoL_Tweaks_Beta.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BlueSage.QoLTweaks.Contracts; using BlueSage.QoLTweaks.Core; using BlueSage.QoLTweaks.Data; using BlueSage.QoLTweaks.Patches; using Cinemachine; using HarmonyLib; using Microsoft.CodeAnalysis; using PurrNet; using PurrNet.Modules; using PurrNet.Packing; using PurrNet.Steam; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Profiling; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("BlueSage_QoL_Tweaks_Beta")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.7.0")] [assembly: AssemblyInformationalVersion("0.2.7+f24b9e7a283857b1065342f3ab7b0a623b76b9e2")] [assembly: AssemblyProduct("BlueSage_QoL_Tweaks_Beta")] [assembly: AssemblyTitle("BlueSage_QoL_Tweaks_Beta")] [assembly: AssemblyVersion("0.2.7.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [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 BlueSage.QoLTweaks { internal static class AvatarSlotStore { private const int BackupCount = 3; internal static string[] FilesInTrustOrder(string mainPath) { string[] array = new string[4] { mainPath, null, null, null }; for (int i = 1; i <= 3; i++) { array[i] = mainPath + ".bak" + i; } return array; } internal static bool AnyFileExists(string mainPath) { string[] array = FilesInTrustOrder(mainPath); for (int i = 0; i < array.Length; i++) { if (File.Exists(array[i])) { return true; } } return false; } private static string ReadOrNull(string path) { try { return File.Exists(path) ? File.ReadAllText(path, Encoding.UTF8) : null; } catch (Exception) { return null; } } internal static bool TryLoad(string mainPath, int slotCount, out int selectedSlot, out string[] names, out string[] payloads, out string usedFile) { string legacyConfigHash; return TryLoad(mainPath, slotCount, out selectedSlot, out legacyConfigHash, out names, out payloads, out usedFile); } internal static bool TryLoad(string mainPath, int slotCount, out int selectedSlot, out string legacyConfigHash, out string[] names, out string[] payloads, out string usedFile) { selectedSlot = -1; legacyConfigHash = null; names = new string[slotCount]; payloads = new string[slotCount]; usedFile = null; string[] array = FilesInTrustOrder(mainPath); string[] array2 = new string[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = ReadOrNull(array[i]); } int num = AvatarSlotStoreFormat.ChooseFirstValid(array2, slotCount); if (num < 0) { return false; } usedFile = array[num]; return AvatarSlotStoreFormat.TryParse(array2[num], slotCount, out selectedSlot, out legacyConfigHash, out names, out payloads); } internal static string BackupBeforeReimport(string mainPath, string loadedFile, DateTime stamp) { string text = mainPath + ".pre-reimport-" + stamp.ToString("yyyyMMdd-HHmmss", CultureInfo.InvariantCulture); File.Copy(loadedFile, text, overwrite: true); return text; } internal static void Save(string mainPath, int selectedSlot, IReadOnlyList<string> names, IReadOnlyList<string> payloads) { Save(mainPath, selectedSlot, null, names, payloads); } internal static void Save(string mainPath, int selectedSlot, string legacyConfigHash, IReadOnlyList<string> names, IReadOnlyList<string> payloads) { string directoryName = Path.GetDirectoryName(mainPath); if (!string.IsNullOrEmpty(directoryName)) { Directory.CreateDirectory(directoryName); } string text = AvatarSlotStoreFormat.Format(selectedSlot, legacyConfigHash, names, payloads); string text2 = ReadOrNull(mainPath); if (string.Equals(text2, text, StringComparison.Ordinal)) { return; } string text3 = mainPath + ".tmp"; WriteToDisk(text3, text); string text4 = null; KeyValuePair<string, string>[] array = AvatarSlotStoreFormat.RotationPlan(FilesInTrustOrder(mainPath)); int i; string[] names2; string[] payloads2; for (i = 0; i < array.Length; i++) { KeyValuePair<string, string> keyValuePair = array[i]; int selectedSlot2; if (string.Equals(keyValuePair.Key, mainPath, StringComparison.Ordinal)) { text4 = keyValuePair.Value; } else if (AvatarSlotStoreFormat.TryParse(ReadOrNull(keyValuePair.Key), names.Count, out selectedSlot2, out names2, out payloads2)) { MoveOver(keyValuePair.Key, keyValuePair.Value); } } if (!File.Exists(mainPath)) { File.Move(text3, mainPath); return; } bool flag = AvatarSlotStoreFormat.TryParse(text2, names.Count, out i, out payloads2, out names2); File.Replace(text3, mainPath, flag ? text4 : null); } private static void WriteToDisk(string path, string text) { byte[] bytes = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false).GetBytes(text); using FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None); fileStream.Write(bytes, 0, bytes.Length); fileStream.Flush(flushToDisk: true); } private static void MoveOver(string source, string destination) { if (File.Exists(destination)) { File.Delete(destination); } File.Move(source, destination); } } public static class BlueSageExtensionRegistry { private sealed class ChainloaderExtensionCatalog : IBlueSageLoadedExtensionCatalogV1 { public bool TryGetLoaded(string pluginGuid, out BlueSageLoadedExtensionV1 extension) { extension = default(BlueSageLoadedExtensionV1); if (!string.IsNullOrWhiteSpace(pluginGuid) && Chainloader.PluginInfos.TryGetValue(pluginGuid, out var value) && !((Object)(object)((value != null) ? value.Instance : null) == (Object)null)) { BepInPlugin metadata = value.Metadata; if (!(((metadata != null) ? metadata.Version : null) == null)) { Assembly assembly = ((object)value.Instance).GetType().Assembly; extension = new BlueSageLoadedExtensionV1(assembly, value.Metadata.Version, loaded: true); return true; } } return false; } } private sealed class DynamicDiagnosticsProvider : IBlueSageDiagnosticsProviderV1, IBlueSageDiagnosticsControlV2 { private const int PayloadLength = 5; private readonly Func<long, long[]> _provider; private readonly Func<bool, bool> _overlayVisibilitySetter; internal DynamicDiagnosticsProvider(Func<long, long[]> provider, Func<bool, bool> overlayVisibilitySetter = null) { _provider = provider ?? throw new ArgumentNullException("provider"); _overlayVisibilitySetter = overlayVisibilitySetter; } public BlueSageDiagnosticsSnapshotV1 GetSnapshot(long nowUtcTicks) { long[] array = _provider(nowUtcTicks); if (array == null || array.Length != 5 || array[0] < 0 || array[0] > 2 || array[1] < 0 || array[1] > 2 || array[2] < 100 || array[2] > 5000) { throw new InvalidOperationException("Diagnostics payload failed the public ABI bounds."); } return new BlueSageDiagnosticsSnapshotV1((BlueSageDiagnosticsOverlayStateV1)array[0], (BlueSageDiagnosticsFreshnessV1)array[1], (int)array[2], array[3], array[4]); } public bool TrySetOverlayVisible(bool visible) { if (_overlayVisibilitySetter != null) { return _overlayVisibilitySetter(visible); } return false; } } private static readonly object Sync = new object(); private static readonly BlueSageExtensionRegistryCore Core = new BlueSageExtensionRegistryCore(new ChainloaderExtensionCatalog()); public static BlueSageExtensionRegistrationTokenV1 RegisterBadgeContributionV1(IBlueSageBadgeContributionV1 provider, string ownerGuid, Version ownerVersion, int abiVersion) { lock (Sync) { return Core.RegisterBadgeContribution(provider, ownerGuid, ownerVersion, abiVersion); } } public static bool UnregisterBadgeContributionV1(BlueSageExtensionRegistrationTokenV1 token) { lock (Sync) { return Core.UnregisterBadgeContribution(token); } } public static BlueSageExtensionRegistrationTokenV1 RegisterDiagnosticsProviderV1(IBlueSageDiagnosticsProviderV1 provider, string ownerGuid, Version ownerVersion, int abiVersion) { lock (Sync) { return Core.RegisterDiagnostics(provider, ownerGuid, ownerVersion, abiVersion); } } public static bool UnregisterDiagnosticsProviderV1(BlueSageExtensionRegistrationTokenV1 token) { lock (Sync) { return Core.UnregisterDiagnostics(token); } } public static BlueSageExtensionRegistrationTokenV1 RegisterHostCapabilityProviderV1(IBlueSageHostCapabilityProviderV1 provider, string ownerGuid, Version ownerVersion, int abiVersion) { lock (Sync) { return Core.RegisterHostCapability(provider, ownerGuid, ownerVersion, abiVersion); } } public static bool UnregisterHostCapabilityProviderV1(BlueSageExtensionRegistrationTokenV1 token) { lock (Sync) { return Core.UnregisterHostCapability(token); } } public static long RegisterDiagnosticsProviderDynamicV1(Func<long, long[]> provider, string ownerGuid, Version ownerVersion, int abiVersion) { if (provider == null || provider.Target != null || !provider.Method.IsStatic || provider.Method.DeclaringType == null) { return 0L; } Assembly assembly = provider.Method.DeclaringType.Assembly; lock (Sync) { return Core.RegisterDiagnostics(new DynamicDiagnosticsProvider(provider), ownerGuid, ownerVersion, abiVersion, assembly).Generation; } } public static bool UnregisterDiagnosticsProviderDynamicV1(long generation) { lock (Sync) { return Core.UnregisterDiagnostics(new BlueSageExtensionRegistrationTokenV1(generation)); } } public static long RegisterDiagnosticsProviderDynamicV2(Func<long, long[]> provider, Func<bool, bool> overlayVisibilitySetter, string ownerGuid, Version ownerVersion, int abiVersion) { if (provider == null || overlayVisibilitySetter == null || provider.Target != null || overlayVisibilitySetter.Target != null || !provider.Method.IsStatic || !overlayVisibilitySetter.Method.IsStatic || provider.Method.DeclaringType == null || overlayVisibilitySetter.Method.DeclaringType == null || provider.Method.DeclaringType.Assembly != overlayVisibilitySetter.Method.DeclaringType.Assembly) { return 0L; } Assembly assembly = provider.Method.DeclaringType.Assembly; lock (Sync) { return Core.RegisterDiagnostics(new DynamicDiagnosticsProvider(provider, overlayVisibilitySetter), ownerGuid, ownerVersion, abiVersion, assembly).Generation; } } internal static void BeginLobby(long lobbyEpoch, long evidenceGeneration) { lock (Sync) { Core.SetEvidenceContext(lobbyEpoch, evidenceGeneration); } } internal static void BeginBadgePresentation(long lobbyEpoch, long evidenceGeneration) { lock (Sync) { Core.SetBadgeEvidenceContext(lobbyEpoch, evidenceGeneration); } } internal static bool TryReadBadgeContribution(BlueSageBadgeContributionRequestV1 request, long nowUtcTicks, out BlueSageBadgeContributionResponseV1 response) { lock (Sync) { return Core.TryReadBadgeContribution(request, nowUtcTicks, out response); } } internal static bool TryReadDiagnostics(long nowUtcTicks, out BlueSageDiagnosticsSnapshotV1 snapshot) { lock (Sync) { return Core.TryReadDiagnostics(nowUtcTicks, out snapshot); } } internal static bool TrySetDiagnosticsOverlayVisible(bool visible) { lock (Sync) { return Core.TrySetDiagnosticsOverlayVisible(visible); } } internal static bool TryReadHostCapability(bool isHost, long nonce, long nowUtcTicks, out BlueSageHostCapabilitySnapshotV1 snapshot) { lock (Sync) { snapshot = default(BlueSageHostCapabilitySnapshotV1); BlueSageHostCapabilityRequestV1 request; return Core.TryCreateHostCapabilityRequest(isHost, nonce, nowUtcTicks, out request) && Core.TryReadHostCapability(request, nowUtcTicks, out snapshot); } } internal static bool TryExecuteHostCapability(BlueSageHostCapabilityActionV1 action, bool isHost, long nonce, long nowUtcTicks, out BlueSageHostCapabilityReceiptV1 receipt) { lock (Sync) { receipt = default(BlueSageHostCapabilityReceiptV1); BlueSageHostCapabilityRequestV1 request; return Core.TryCreateHostCapabilityRequest(isHost, nonce, nowUtcTicks, out request) && Core.TryExecuteHostCapability(action, request, nowUtcTicks, out receipt); } } internal static bool HasLiveHostCapabilityProvider() { lock (Sync) { return Core.HasLiveHostCapabilityProvider(); } } internal static void ClearLobbyState() { lock (Sync) { Core.SetEvidenceContext(0L, 0L); Core.SetBadgeEvidenceContext(0L, 0L); } } internal static void ClearAll() { lock (Sync) { Core.Clear(); } } } internal static class BlueSageHelpFrame { internal static HelpFrameLayout Resolve(BlueSageHelpFrameKind kind, Rect window) { return HelpFramePolicy.Resolve(kind, ((Rect)(ref window)).width, ((Rect)(ref window)).height); } internal static void BeginFooter(GUIStyle footerStyle, HelpFrameLayout layout) { GUILayout.BeginVertical(footerStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(layout.FooterHeight), GUILayout.MaxHeight(layout.FooterHeight) }); } internal static void DrawStateAndHelp(GUIStyle textStyle, HelpFrameLayout layout, string stateLine, string helpLine) { GUILayout.Label(stateLine ?? string.Empty, textStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(layout.StateLineHeight), GUILayout.MaxHeight(layout.StateLineHeight) }); GUILayout.Label(helpLine ?? string.Empty, textStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(layout.HelpLineHeight), GUILayout.MaxHeight(layout.HelpLineHeight) }); } internal static void EndFooter() { GUILayout.EndVertical(); } } internal sealed class BlueSageReportWindow : MonoBehaviour { private const int WindowId = 47061; private const float DefaultWindowWidth = 1180f; private const float DefaultWindowHeight = 900f; private const float MinWindowWidth = 920f; private const float MinWindowHeight = 640f; private const float HeaderHeight = 42f; private const float FooterHeight = 72f; private const float ResizeGripSize = 42f; private const int AchievementBatchSize = 12; private Rect _window = new Rect(135f, 75f, 1180f, 900f); private Vector2 _scroll; private bool _visible; private bool _hasOpened; private bool _isResizing; private bool _hasPendingResize; private float _pendingResizeWidth; private float _pendingResizeHeight; private bool _detailsExpanded; private BlueSageReportFilter _filter; private BlueSageReportProjection? _projection; private Dictionary<string, Sprite> _achievementSprites = new Dictionary<string, Sprite>(StringComparer.Ordinal); private const float IconCellSize = 22f; private const float LockedIconAlpha = 0.35f; private readonly BlueSageReportStatusPresenter _status = new BlueSageReportStatusPresenter(); private int _allocationMetricIndex; private string _allocationAmount = "1"; private GUIStyle _windowStyle; private GUIStyle _headerBoxStyle; private GUIStyle _headerStyle; private GUIStyle _labelStyle; private GUIStyle _smallStyle; private GUIStyle _buttonStyle; private GUIStyle _activeButtonStyle; private GUIStyle _sectionStyle; private GUIStyle _footerStyle; private GUIStyle _footerTextStyle; private GUIStyle _textFieldStyle; private Texture2D _windowBackgroundTexture; private string _renderedThemeKey = string.Empty; private int _renderedTextureGeneration; private BlueSageUiThemePalette _theme; private Coroutine? _refreshCoroutine; private static string? _spriteDrawDiagnostic; private static readonly HashSet<string> SpriteDrawFailuresLogged = new HashSet<string>(StringComparer.Ordinal); internal void Open() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!_hasOpened) { _window = GetInitialWindowRect(); _hasOpened = true; } ClampWindowToScreen(); _visible = true; RequestRefresh(); } internal void CloseReport() { _visible = false; if (_refreshCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_refreshCoroutine); _refreshCoroutine = null; } BlueSageWindowHoverScope.UnregisterWindow(47061); } private void OnGUI() { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_005e: Expected O, but got Unknown //IL_0059: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (!_visible) { return; } EnsureStyles(); ClampWindowToScreen(); BlueSageWindowHoverScope.RegisterWindow(47061, MenuDisplayScaleRuntime.ToPhysicalRect(_window), 0); ImGuiTextFocusTracker.BlurOnClickOutsideWindows(); MenuDisplayScaleRuntime.Apply(out var previous); try { Rect val = GUI.Window(47061, _window, new WindowFunction(DrawWindow), string.Empty, _windowStyle); ImGuiTextFocusTracker.ReportWindowDrawn(); WindowFitResult windowFitResult = ReportWindowResizePolicy.MergeGuiWindowResult(new WindowFitResult(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _hasPendingResize, _pendingResizeWidth, _pendingResizeHeight); _hasPendingResize = false; _window = new Rect(windowFitResult.X, windowFitResult.Y, windowFitResult.Width, windowFitResult.Height); ClampWindowToScreen(); } finally { MenuDisplayScaleRuntime.Restore(previous); } } private void DrawWindow(int id) { //IL_002f: 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_008b: 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_00db: Unknown result type (might be due to invalid IL or missing references) ImGuiTextFocusTracker.BlurOnClickInsideWindow(); GUI.tooltip = string.Empty; GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref _window)).width, ((Rect)(ref _window)).height), (Texture)(object)_windowBackgroundTexture); DrawHeader(); GUILayout.Space(8f); DrawFilters(); GUILayout.Space(8f); _scroll = GUILayout.BeginScrollView(_scroll, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(GetContentScrollHeight()) }); DrawReportContent(); GUILayout.EndScrollView(); GUILayout.FlexibleSpace(); DrawFooter(); DrawResizeGrip(); GUI.DragWindow(new Rect(0f, 0f, Math.Max(1f, ((Rect)(ref _window)).width - 150f), 42f)); } private void DrawHeader() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) GUI.Box(new Rect(0f, 0f, ((Rect)(ref _window)).width, 42f), GUIContent.none, _headerBoxStyle); GUI.Label(new Rect(16f, 8f, Math.Max(1f, ((Rect)(ref _window)).width - 210f), 26f), "▣ BlueSage Report", _headerStyle); if (GUI.Button(new Rect(((Rect)(ref _window)).width - 184f, 6f, 104f, 30f), "Refresh", _buttonStyle)) { RequestRefresh(); } if (GUI.Button(new Rect(((Rect)(ref _window)).width - 72f, 6f, 56f, 30f), "Close", _buttonStyle)) { Plugin.CloseBlueSageReport(); } } private void DrawFilters() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); DrawFilter(BlueSageReportFilter.All, "ALL"); Sprite pomodoro; Sprite breakSprite; bool num = BlueSagePomodoroIconResolver.TryResolve(out pomodoro, out breakSprite); DrawFilterIcon(num ? pomodoro : null); DrawFilter(BlueSageReportFilter.Work, "WORK"); DrawFilterIcon(num ? breakSprite : null); DrawFilter(BlueSageReportFilter.Relax, "RELAX"); DrawFilter(BlueSageReportFilter.Unclassified, "UNCLASSIFIED"); GUILayout.EndHorizontal(); } private static void DrawFilterIcon(Sprite? sprite) { //IL_002a: 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_003a: Unknown result type (might be due to invalid IL or missing references) Rect rect = GUILayoutUtility.GetRect(22f, 22f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(22f), GUILayout.Height(22f) }); if ((Object)(object)sprite != (Object)null) { TryDrawSprite(sprite, rect); } } private void DrawReportContent() { if (_projection == null) { GUILayout.BeginVertical(_sectionStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label(_status.Text, _smallStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); return; } BlueSageReportView view = _projection.Select(_filter); DrawMetricSection("Overview", view, "TotalFocusDuration", "TotalSessionCount", "TotalCompleteSessions", "LongestStreak", "ToDoCompleted", "SecondsPlayed"); DrawMetricSection("Activity Snapshot", view, "TodayFocusDuration", "TodaySessionCount", "WeekFocusDuration", "WeekFocusCount", "MonthFocusDuration", "MonthFocusCount", "AverageDailyFocus", "CurrentStreak"); DrawMetricSection("Detailed Analysis", view, "FocusSessionsPerDay", "ArtFocusCount", "ConnectFocusCount", "EatFocusCount", "ExerciseFocusCount", "ListenFocusCount", "MeditateFocusCount", "ReadFocusCount", "WriteFocusCount", "ChoreFocusCount", "PlayFocusCount", "ArtFocusDuration", "ConnectFocusDuration", "EatFocusDuration", "ExerciseFocusDuration", "ListenFocusDuration", "MeditateFocusDuration", "ReadFocusDuration", "WriteFocusDuration", "ChoreFocusDuration", "PlayFocusDuration", "SyncedFocus", "DailyMaxFocus", "TotalDayOfFocus", "DayOfYear", "CurrentWeek", "CurrentMonth"); DrawMood(view); DrawAchievements(view); DrawHistory(); } private void DrawFilter(BlueSageReportFilter filter, string label) { bool flag = _filter == filter; if (GUILayout.Toggle(flag, label, flag ? _activeButtonStyle : _buttonStyle, Array.Empty<GUILayoutOption>()) && !flag) { _filter = filter; } } private void DrawMetricSection(string title, BlueSageReportView view, params string[] keys) { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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) GUILayout.Space(8f); GUILayout.BeginVertical(_sectionStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label(title, _labelStyle, Array.Empty<GUILayoutOption>()); Sprite pomodoro; Sprite breakSprite; bool flag = BlueSagePomodoroIconResolver.TryResolve(out pomodoro, out breakSprite); foreach (string key in keys) { BlueSageReportMetric blueSageReportMetric = view.Get(key); string text = ((blueSageReportMetric.WeekdayValues.Count > 0) ? string.Join(" ", blueSageReportMetric.WeekdayValues.Select((double number) => number.ToString("0.##", CultureInfo.InvariantCulture))) : blueSageReportMetric.Value.ToString("0.##", CultureInfo.InvariantCulture)); bool num = ReportIconPolicy.IsPomodoroMetric(WorkRelaxMetricCatalog.Get(key).Family); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (num) { Rect rect = GUILayoutUtility.GetRect(22f, 22f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(22f), GUILayout.Height(22f) }); if (flag && (Object)(object)pomodoro != (Object)null) { TryDrawSprite(pomodoro, rect); } } GUILayout.Label(BlueSageMetricPresentation.FriendlyLabel(key) + ": " + text + " " + blueSageReportMetric.UnitLabel + (string.IsNullOrEmpty(blueSageReportMetric.Qualifier) ? string.Empty : (" - " + blueSageReportMetric.Qualifier)), _smallStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } private void DrawMood(BlueSageReportView view) { GUILayout.Space(8f); GUILayout.BeginVertical(_sectionStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Journal Mood Check-ins", _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("These are the five faces chosen in On-Together's Journal.", _smallStyle, Array.Empty<GUILayoutOption>()); DrawJournalMoodFaces(view); BlueSageMoodUiModel blueSageMoodUiModel = BlueSageMoodUiModel.Build(view.MoodStats); GUILayout.Label("Overview distribution", _smallStyle, Array.Empty<GUILayoutOption>()); foreach (string overviewLine in blueSageMoodUiModel.OverviewLines) { GUILayout.Label(overviewLine, _smallStyle, Array.Empty<GUILayoutOption>()); } if (blueSageMoodUiModel.OverviewLines.Count == 0) { GUILayout.Label("No mood observations in this view.", _smallStyle, Array.Empty<GUILayoutOption>()); } GUILayout.Label("Current calendar month", _smallStyle, Array.Empty<GUILayoutOption>()); foreach (string monthLine in blueSageMoodUiModel.MonthLines) { GUILayout.Label(monthLine, _smallStyle, Array.Empty<GUILayoutOption>()); } GUILayout.Label("Current-year daily history", _smallStyle, Array.Empty<GUILayoutOption>()); foreach (string yearLine in blueSageMoodUiModel.YearLines) { GUILayout.Label(yearLine, _smallStyle, Array.Empty<GUILayoutOption>()); } if (blueSageMoodUiModel.YearLines.Count == 0) { GUILayout.Label("No check-ins this year.", _smallStyle, Array.Empty<GUILayoutOption>()); } GUILayout.Label("Only the Journal's saved face choice and time are read. BlueSage does not guess how you felt.", _smallStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); } private void DrawJournalMoodFaces(BlueSageReportView view) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) IReadOnlyList<Sprite> faces; bool flag = BlueSageJournalMoodTextureResolver.TryResolve(out faces); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int i = 0; i <= 4; i++) { GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); if (flag && i < faces.Count && (Object)(object)faces[i] != (Object)null) { Rect rect = GUILayoutUtility.GetRect(48f, 48f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(48f), GUILayout.Height(48f) }); GUIStyle headerBoxStyle = _headerBoxStyle; object obj; if (headerBoxStyle == null) { obj = null; } else { GUIStyleState normal = headerBoxStyle.normal; obj = ((normal != null) ? normal.background : null); } Texture2D val = (Texture2D)obj; if ((Object)(object)val != (Object)null) { GUI.DrawTexture(rect, (Texture)(object)val); } TryDrawSprite(faces[i], rect); } int value; int num = (view.MoodStats.OverviewCounts.TryGetValue(i, out value) ? value : 0); GUILayout.Label(BlueSageJournalMoodPresentation.Label(i) + ": " + num, _smallStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); if (!flag) { GUILayout.Label("The game's Journal faces aren't available right now, so the names are shown instead.", _smallStyle, Array.Empty<GUILayoutOption>()); } } private unsafe static bool TryDrawSprite(Sprite sprite, Rect target) { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_019a: 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_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00d6: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)sprite == (Object)null) { return false; } Texture2D texture = sprite.texture; if ((Object)(object)texture == (Object)null || ((Texture)texture).width <= 0 || ((Texture)texture).height <= 0) { LogSpriteDrawFailureOnce("texture missing for sprite '" + ((Object)sprite).name + "'"); return false; } Vector2[] uv = sprite.uv; Rect val2 = default(Rect); if (uv != null && uv.Length != 0) { float x = uv[0].x; float x2 = uv[0].x; float y = uv[0].y; float y2 = uv[0].y; for (int i = 1; i < uv.Length; i++) { Vector2 val = uv[i]; if (val.x < x) { x = val.x; } if (val.x > x2) { x2 = val.x; } if (val.y < y) { y = val.y; } if (val.y > y2) { y2 = val.y; } } ((Rect)(ref val2))..ctor(x, y, x2 - x, y2 - y); } else { Rect textureRect = sprite.textureRect; ((Rect)(ref val2))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height); } GUI.DrawTextureWithTexCoords(target, (Texture)(object)texture, val2, true); if (_spriteDrawDiagnostic == null && Event.current != null && (int)Event.current.type == 7) { Color color = GUI.color; string[] obj = new string[24] { "drew sprite '", ((Object)sprite).name, "' from texture '", ((Object)texture).name, "' ", ((Texture)texture).width.ToString(), "x", ((Texture)texture).height.ToString(), " format=", ((object)texture.format/*cast due to .constrained prefix*/).ToString(), " packed=", sprite.packed.ToString(), " uv=", null, null, null, null, null, null, null, null, null, null, null }; Rect val3 = val2; obj[13] = ((object)(*(Rect*)(&val3))/*cast due to .constrained prefix*/).ToString(); obj[14] = " guiColor=("; obj[15] = color.r.ToString("0.00", CultureInfo.InvariantCulture); obj[16] = ","; obj[17] = color.g.ToString("0.00", CultureInfo.InvariantCulture); obj[18] = ","; obj[19] = color.b.ToString("0.00", CultureInfo.InvariantCulture); obj[20] = ","; obj[21] = color.a.ToString("0.00", CultureInfo.InvariantCulture); obj[22] = ") cell="; val3 = target; obj[23] = ((object)(*(Rect*)(&val3))/*cast due to .constrained prefix*/).ToString(); _spriteDrawDiagnostic = string.Concat(obj); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("BlueSage Report sprite draw: " + _spriteDrawDiagnostic + ".")); } } return true; } catch (Exception ex) { LogSpriteDrawFailureOnce("draw failed with " + ex.GetType().Name + " for sprite '" + (((Object)(object)sprite != (Object)null) ? ((Object)sprite).name : "null") + "'"); return false; } } private static void LogSpriteDrawFailureOnce(string reason) { if (SpriteDrawFailuresLogged.Add(reason)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("BlueSage Report sprite draw: " + reason + ".")); } } } private void DrawAchievements(BlueSageReportView view) { //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) GUILayout.Space(8f); GUILayout.BeginVertical(_sectionStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Achievements", _labelStyle, Array.Empty<GUILayoutOption>()); if (view.AchievementProgress.IsOverallNative) { GUILayout.Label(view.AchievementProgress.Unlocked + " / " + view.AchievementProgress.Total + " unlocked in the game", _smallStyle, Array.Empty<GUILayoutOption>()); } else { GUILayout.Label(view.Achievements.Count + " unlocked while this label was on. That's when they happened, not why.", _smallStyle, Array.Empty<GUILayoutOption>()); } foreach (BlueSageAchievementObservation achievement in view.Achievements) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Rect rect = GUILayoutUtility.GetRect(22f, 22f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(22f), GUILayout.Height(22f) }); if (_achievementSprites.TryGetValue(achievement.Key, out Sprite value) && (Object)(object)value != (Object)null) { Color color = GUI.color; if (!achievement.Unlocked) { GUI.color = new Color(color.r, color.g, color.b, color.a * 0.35f); } TryDrawSprite(value, rect); GUI.color = color; } GUILayout.Label(achievement.Key + " - " + achievement.ObservationLabel, _smallStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } private void DrawHistory() { GUILayout.Space(8f); GUILayout.BeginVertical(_sectionStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Classification History", _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Newest first. Changing a label here only changes BlueSage's Work / Relax label, never your game stats.", _smallStyle, Array.Empty<GUILayoutOption>()); _detailsExpanded = GUILayout.Toggle(_detailsExpanded, "Show technical details", _buttonStyle, Array.Empty<GUILayoutOption>()); foreach (BlueSageReportHistoryItem item in _projection.History.Take(30)) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label(item.Render(_detailsExpanded), _smallStyle, Array.Empty<GUILayoutOption>()); foreach (string displayLine in item.DisplayLines) { GUILayout.Label(" " + displayLine, _smallStyle, Array.Empty<GUILayoutOption>()); } GUILayout.EndVertical(); if (item.Members.Count > 0) { if (item.Mode != WorkRelaxAttributionMode.Work && GUILayout.Button("Work", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(62f) })) { Reclassify(item, WorkRelaxAttributionMode.Work); } if (item.Mode != WorkRelaxAttributionMode.Relax && GUILayout.Button("Relax", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(62f) })) { Reclassify(item, WorkRelaxAttributionMode.Relax); } if (item.Mode != WorkRelaxAttributionMode.Unclassified && GUILayout.Button("Unclassified", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(96f) })) { Reclassify(item, WorkRelaxAttributionMode.Unclassified); } } GUILayout.EndHorizontal(); } string[] array = BlueSageAllocationCatalog.Options.Select((BlueSageAllocationOption item) => item.Label).ToArray(); if (ReportWindowLayoutPolicy.UseStackedAllocationLayout(Math.Max(1f, ((Rect)(ref _window)).width - 48f))) { GUILayout.Label("Move Unclassified", _smallStyle, Array.Empty<GUILayoutOption>()); _allocationMetricIndex = GUILayout.SelectionGrid(_allocationMetricIndex, array, 3, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); } else { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Move Unclassified", _smallStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) }); _allocationMetricIndex = GUILayout.SelectionGrid(_allocationMetricIndex, array, 3, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(570f) }); } _allocationAmount = GUILayout.TextField(_allocationAmount, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); if (GUILayout.Button("to Work", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(85f) })) { Allocate(WorkRelaxAttributionMode.Work); } if (GUILayout.Button("to Relax", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(85f) })) { Allocate(WorkRelaxAttributionMode.Relax); } if (GUILayout.Button("Undo latest", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) })) { ShowResult(WorkRelaxRuntimeController.TryUndoLatestReportCorrection(out string reason) ? "Last change undone." : reason); RequestRefresh(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } private void ShowResult(string result) { _status.ShowActionResult(result); Plugin.Instance?.ShowToast(ToastPolicy.Summarize(result)); } private void Reclassify(BlueSageReportHistoryItem item, WorkRelaxAttributionMode to) { ShowResult(WorkRelaxRuntimeController.TryApplyReportCorrections(item.Members, to, out string reason) ? "Label updated." : reason); RequestRefresh(); } private void Allocate(WorkRelaxAttributionMode to) { if (!double.TryParse(_allocationAmount, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { ShowResult("Type a number first."); return; } ShowResult(WorkRelaxRuntimeController.TryApplyReportCorrection(BlueSageAllocationCatalog.Options[_allocationMetricIndex].MetricKey, WorkRelaxAttributionMode.Unclassified, to, result, "aggregate-unclassified", out string reason) ? "Moved." : reason); RequestRefresh(); } private void RequestRefresh() { if (_refreshCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_refreshCoroutine); } _status.BeginProjectionRefresh(); _refreshCoroutine = ((MonoBehaviour)this).StartCoroutine(RefreshRoutine()); } private IEnumerator RefreshRoutine() { Stopwatch total = Stopwatch.StartNew(); int yieldedFrames = 1; yield return null; Stopwatch phase = Stopwatch.StartNew(); BlueSageReportNativeReader.ReadMoods(out NativeMoodObservation[] moods, out bool moodsAvailable, out string moodWarning); long moodMilliseconds = phase.ElapsedMilliseconds; yield return null; yieldedFrames++; phase.Restart(); BlueSageAchievementReadSession achievementRead = BlueSageReportNativeReader.BeginAchievementRead(); while (!achievementRead.Complete) { achievementRead.ReadNextAchievementBatch(12); if (!achievementRead.Complete) { yield return null; yieldedFrames++; } } long elapsedMilliseconds = phase.ElapsedMilliseconds; _achievementSprites = achievementRead.Sprites; phase.Restart(); BlueSageReportProjection projection; string reason; bool flag = WorkRelaxRuntimeController.TryRefreshReport(moods, moodsAvailable, achievementRead.Observations, achievementRead.Available, out projection, out reason); long elapsedMilliseconds2 = phase.ElapsedMilliseconds; string warning = string.Join(" ", new string[2] { moodWarning, achievementRead.Warning }.Where((string item) => !string.IsNullOrWhiteSpace(item))); if (flag) { _projection = projection; } _status.CompleteProjectionRefresh(flag, warning, reason); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("BlueSage Report refresh trace: total=" + total.ElapsedMilliseconds + "ms mood=" + moodMilliseconds + "ms achievements=" + elapsedMilliseconds + "ms projection=" + elapsedMilliseconds2 + "ms yieldedFrames=" + yieldedFrames + " achievementCount=" + achievementRead.Observations.Length + ".")); } _refreshCoroutine = null; } private void DrawFooter() { GUILayout.BeginVertical(_footerStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinHeight(72f) }); GUILayout.Label(_status.Text, _footerTextStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Your game's saved stats never change. The filters show the same totals split by Work and Relax.", _footerTextStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); } private float GetContentScrollHeight() { return Mathf.Max(120f, ((Rect)(ref _window)).height - 42f - 72f - 52f); } private Rect GetInitialWindowRect() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) float logicalScreenWidth = MenuDisplayScaleRuntime.LogicalScreenWidth; float logicalScreenHeight = MenuDisplayScaleRuntime.LogicalScreenHeight; float num = Mathf.Min(1180f, WindowFitPolicy.GetUsableWidth(logicalScreenWidth)); float num2 = Mathf.Min(900f, WindowFitPolicy.GetUsableHeight(logicalScreenHeight)); return new Rect((logicalScreenWidth - num) / 2f, (logicalScreenHeight - num2) / 2f, num, num2); } private void ClampWindowToScreen() { //IL_0063: 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) WindowFitResult windowFitResult = WindowFitPolicy.FitToScreen(((Rect)(ref _window)).x, ((Rect)(ref _window)).y, ((Rect)(ref _window)).width, ((Rect)(ref _window)).height, 920f, 640f, MenuDisplayScaleRuntime.LogicalScreenWidth, MenuDisplayScaleRuntime.LogicalScreenHeight); _window = new Rect(windowFitResult.X, windowFitResult.Y, windowFitResult.Width, windowFitResult.Height); } private void DrawResizeGrip() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Invalid comparison between Unknown and I4 //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Invalid comparison between Unknown and I4 //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref _window)).width - 42f - 8f, ((Rect)(ref _window)).height - 42f - 8f, 42f, 42f); GUI.Box(val, new GUIContent("↘", "Drag this corner to resize BlueSage Report."), _buttonStyle); Event current = Event.current; if (current != null) { if ((int)current.type == 0 && ((Rect)(ref val)).Contains(current.mousePosition)) { _isResizing = true; current.Use(); } else if (_isResizing && (int)current.type == 3) { WindowFitResult windowFitResult = WindowFitPolicy.FitToScreen(((Rect)(ref _window)).x, ((Rect)(ref _window)).y, ((Rect)(ref _window)).width + current.delta.x, ((Rect)(ref _window)).height + current.delta.y, 920f, 640f, MenuDisplayScaleRuntime.LogicalScreenWidth, MenuDisplayScaleRuntime.LogicalScreenHeight); _pendingResizeWidth = windowFitResult.Width; _pendingResizeHeight = windowFitResult.Height; _hasPendingResize = true; current.Use(); } else if (_isResizing && (int)current.rawType == 1) { _isResizing = false; current.Use(); } } } private void EnsureStyles() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00b7: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_00ee: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_0128: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Expected O, but got Unknown //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Expected O, but got Unknown //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Expected O, but got Unknown //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Expected O, but got Unknown _theme = BlueSageUiTheme.Current; if (_windowStyle == null || !string.Equals(_renderedThemeKey, _theme.Key, StringComparison.Ordinal) || _renderedTextureGeneration != BlueSageUiTheme.RuntimeTextureGeneration || !BlueSageUiTheme.AreRuntimeTexturesAlive()) { _renderedThemeKey = _theme.Key; _windowBackgroundTexture = BlueSageUiTheme.GetSolidTexture(_theme.Window); GUIStyle val = new GUIStyle(GUI.skin.window) { padding = new RectOffset(16, 16, 52, 14) }; val.normal.background = _windowBackgroundTexture; val.normal.textColor = _theme.LabelText; _windowStyle = val; GUIStyle val2 = new GUIStyle(_windowStyle); val2.normal.background = BlueSageUiTheme.GetSolidTexture(_theme.Header); _headerBoxStyle = val2; GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = 18, fontStyle = (FontStyle)1 }; val3.normal.textColor = _theme.HeaderText; _headerStyle = val3; GUIStyle val4 = new GUIStyle(GUI.skin.label) { fontSize = 16, fontStyle = (FontStyle)1, wordWrap = true }; val4.normal.textColor = _theme.LabelText; _labelStyle = val4; GUIStyle val5 = new GUIStyle(GUI.skin.label) { fontSize = 14, fontStyle = (FontStyle)1, wordWrap = true }; val5.normal.textColor = _theme.LabelText; _smallStyle = val5; _buttonStyle = BlueSageUiTheme.CreateNeutralButtonStyle(GUI.skin.button, _theme, 13); _activeButtonStyle = BlueSageUiTheme.CreateStateButtonStyle(_buttonStyle, _theme.ActiveAccent, _theme.FieldFocusedBorder, _theme.ActiveStateText, 13); GUIStyle val6 = new GUIStyle(_windowStyle) { padding = new RectOffset(14, 14, 12, 12), border = new RectOffset(1, 1, 1, 1) }; val6.normal.background = BlueSageUiTheme.GetPanelTexture(_theme.SectionPanel, _theme.SectionBorder); val6.normal.textColor = _theme.LabelText; _sectionStyle = val6; GUIStyle val7 = new GUIStyle(_sectionStyle) { padding = new RectOffset(14, 56, 10, 10) }; val7.normal.background = BlueSageUiTheme.GetPanelTexture(_theme.FooterBackground, _theme.FooterBorder); val7.normal.textColor = _theme.FooterText; _footerStyle = val7; GUIStyle val8 = new GUIStyle(_smallStyle); val8.normal.textColor = _theme.FooterText; _footerTextStyle = val8; _textFieldStyle = BlueSageUiTheme.CreateTextInputStyle(GUI.skin.textField, _theme, 14, wordWrap: false); _renderedTextureGeneration = BlueSageUiTheme.RuntimeTextureGeneration; } } private void OnDisable() { if (_refreshCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_refreshCoroutine); _refreshCoroutine = null; } BlueSageWindowHoverScope.UnregisterWindow(47061); } } internal static class BlueSageReportNativeReader { private const BindingFlags Flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; internal static void ReadMoods(out NativeMoodObservation[] moods, out bool moodsAvailable, out string warning) { moods = Array.Empty<NativeMoodObservation>(); moodsAvailable = false; warning = string.Empty; Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly item) => string.Equals(item.GetName().Name, "Assembly-CSharp", StringComparison.Ordinal)); try { Type type = assembly?.GetType("DataManager", throwOnError: false); if (type == null) { warning = "This game version doesn't share Journal check-ins."; return; } Object val = NativeManagerCache.FindLiveObject(type); object obj = ((val == (Object)null) ? null : Read(val, type, "PlayerData")); object? obj2 = ((obj == null) ? null : Read(obj, obj.GetType(), "JournalDatas2")); List<NativeMoodObservation> list = new List<NativeMoodObservation>(); if (obj2 is IEnumerable enumerable) { foreach (object item in enumerable) { if (item != null) { object obj3 = Read(item, item.GetType(), "Feel"); object obj4 = Read(item, item.GetType(), "Time"); if (obj3 != null && obj4 != null) { list.Add(new NativeMoodObservation(Convert.ToInt32(obj3, CultureInfo.InvariantCulture), ToTicks(obj4))); } } } moods = list.ToArray(); moodsAvailable = true; } else { warning = "Journal check-ins can't be read right now; try Refresh in a moment."; } } catch (Exception ex) { warning = "Journal check-ins couldn't be read this time; nothing was changed (" + ex.GetType().Name + ")."; } } internal static BlueSageAchievementReadSession BeginAchievementRead() { return new BlueSageAchievementReadSession(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } private static object? Read(object target, Type type, string name) { if (!BlueSageReportPrivacyPolicy.IsAllowedJournalMember(name)) { return ReadNonJournalMember(target, type, name); } object obj = type.GetField(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(target); if (obj == null) { PropertyInfo? property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if ((object)property == null) { return null; } obj = property.GetValue(target, null); } return obj; } private static object? ReadNonJournalMember(object target, Type type, string name) { if (string.Equals(type.Name, "JournalData2", StringComparison.Ordinal) || string.Equals(type.Name, "JournalData", StringComparison.Ordinal)) { return null; } object obj = type.GetField(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(target); if (obj == null) { PropertyInfo? property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if ((object)property == null) { return null; } obj = property.GetValue(target, null); } return obj; } private static long ToTicks(object value) { if (value is DateTime dateTime) { return dateTime.ToUniversalTime().Ticks; } if (value is long) { return (long)value; } if (DateTime.TryParse(Convert.ToString(value, CultureInfo.InvariantCulture), CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeLocal, out var result)) { return result.Ticks; } return 0L; } } internal sealed class BlueSageAchievementReadSession { private readonly object[] _values = Array.Empty<object>(); private readonly Object? _manager; private readonly MethodInfo? _getAchievement; private readonly List<NativeAchievementObservation> _observations = new List<NativeAchievementObservation>(); private readonly Dictionary<string, Sprite> _sprites = new Dictionary<string, Sprite>(StringComparer.Ordinal); private readonly IList? _achievementInfos; private readonly FieldInfo? _achievementSpriteField; private int _next; internal bool Complete { get; private set; } internal bool Available { get; private set; } internal string Warning { get; private set; } = string.Empty; internal NativeAchievementObservation[] Observations => _observations.ToArray(); internal Dictionary<string, Sprite> Sprites => new Dictionary<string, Sprite>(_sprites, StringComparer.Ordinal); internal BlueSageAchievementReadSession(BindingFlags flags) { try { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly item) => string.Equals(item.GetName().Name, "Assembly-CSharp", StringComparison.Ordinal)); Type type = assembly?.GetType("AchievementManager", throwOnError: false); Type type2 = assembly?.GetType("Achievement", throwOnError: false); if (type == null || type2 == null || !type2.IsEnum) { Warning = "This game version doesn't share achievements."; Complete = true; return; } _manager = NativeManagerCache.FindLiveObject(type); _getAchievement = type.GetMethod("GetAchievement", flags, null, new Type[1] { type2 }, null); if (_manager == (Object)null || _getAchievement == null) { Warning = "Achievements can't be read right now; try Refresh in a moment."; Complete = true; return; } _values = Enum.GetValues(type2).Cast<object>().ToArray(); Complete = _values.Length == 0; Available = true; try { object obj = type.GetProperty("AchievementContainer", BindingFlags.Instance | BindingFlags.Public)?.GetValue(_manager); _achievementInfos = (obj?.GetType().GetField("AchievementInfos", BindingFlags.Instance | BindingFlags.Public))?.GetValue(obj) as IList; _achievementSpriteField = (assembly?.GetType("AchievementInfo", throwOnError: false))?.GetField("AchievementSprite", BindingFlags.Instance | BindingFlags.Public); } catch (Exception) { _achievementInfos = null; _achievementSpriteField = null; } } catch (Exception ex2) { Warning = "Achievements couldn't be read this time; nothing was changed (" + ex2.GetType().Name + ")."; Complete = true; } } private void TryReadSprite(object value, string key) { if (_achievementInfos == null || _achievementSpriteField == null) { return; } try { int num = Convert.ToInt32(value, CultureInfo.InvariantCulture); if (num < 0 || num >= _achievementInfos.Count) { return; } object obj = _achievementInfos[num]; if (obj != null) { object? value2 = _achievementSpriteField.GetValue(obj); Sprite val = (Sprite)((value2 is Sprite) ? value2 : null); if (val != null && (Object)(object)val != (Object)null) { _sprites[key] = val; } } } catch (Exception) { } } internal void ReadNextAchievementBatch(int maximum) { if (Complete) { return; } int num = Math.Min(_values.Length, _next + Math.Max(1, maximum)); try { bool flag = default(bool); while (_next < num) { object obj = _values[_next]; object obj2 = _getAchievement.Invoke(_getAchievement.IsStatic ? null : _manager, new object[1] { obj }); int num2; if (obj2 is bool) { flag = (bool)obj2; num2 = 1; } else { num2 = 0; } bool unlocked = (byte)((uint)num2 & (flag ? 1u : 0u)) != 0; string key = obj.ToString() ?? string.Empty; _observations.Add(new NativeAchievementObservation(key, unlocked)); TryReadSprite(obj, key); _next++; } Complete = _next >= _values.Length; } catch (Exception ex) { Warning = "Achievements couldn't be read this time; nothing was changed (" + ex.GetType().Name + ")."; Available = false; Complete = true; _observations.Clear(); } } } internal static class BlueSageJournalMoodTextureResolver { private const BindingFlags Flags = BindingFlags.Instance | BindingFlags.NonPublic; private const float SingletonProbeCooldownSeconds = 5f; private static Component? _statisticManager; private static IReadOnlyList<Sprite>? _cached; private static string? _loggedReason; private static float _nextSingletonProbeAt; internal static void ObserveStatisticManager(Component? statisticManager) { if (!((Object)(object)statisticManager == (Object)null) && !((Object)(object)statisticManager == (Object)(object)_statisticManager)) { _statisticManager = statisticManager; _cached = null; } } internal static bool TryResolve(out IReadOnlyList<Sprite> faces) { if (_cached != null && _cached.Count == 5 && _cached.All((Sprite item) => (Object)(object)item != (Object)null)) { faces = _cached; return true; } faces = Array.Empty<Sprite>(); Component val = _statisticManager; if ((Object)(object)val == (Object)null) { val = TryProbeSceneSingleton(); if ((Object)(object)val != (Object)null) { _statisticManager = val; } } bool fieldFound = false; int spriteCount = 0; int num = 0; try { if ((Object)(object)val != (Object)null) { FieldInfo? field = ((object)val).GetType().GetField("_moodIcons", BindingFlags.Instance | BindingFlags.NonPublic); fieldFound = field != null; if (field?.GetValue(val) is IEnumerable source) { List<Sprite> list = source.Cast<object>().OfType<Sprite>().ToList(); spriteCount = list.Count; List<Sprite> list2 = list.Take(5).ToList(); num = list2.Count((Sprite item) => (Object)(object)item == (Object)null); if (list2.Count == 5 && num == 0) { _cached = list2.AsReadOnly(); _loggedReason = null; faces = _cached; return true; } } } } catch (Exception ex) { LogReasonOnce("reading the game's _moodIcons failed: " + ex.GetType().Name); return false; } LogReasonOnce(JournalMoodFaceResolutionPolicy.Describe((Object)(object)val != (Object)null, fieldFound, spriteCount, num)); return false; } private static Component? TryProbeSceneSingleton() { float unscaledTime = Time.unscaledTime; if (unscaledTime < _nextSingletonProbeAt) { return null; } _nextSingletonProbeAt = unscaledTime + 5f; try { StatisticManager i = MonoSingleton<StatisticManager>.I; return (Component?)(object)(((Object)(object)i != (Object)null) ? i : null); } catch (Exception) { return null; } } private static void LogReasonOnce(string reason) { if (!string.IsNullOrEmpty(reason) && !string.Equals(reason, _loggedReason, StringComparison.Ordinal)) { _loggedReason = reason; ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("BlueSage Report Journal faces fell back to plain labels because " + reason + ".")); } } } } internal static class BlueSagePomodoroIconResolver { private const float ProbeCooldownSeconds = 5f; private static Sprite? _pomodoro; private static Sprite? _break; private static float _nextProbeAt; internal static bool TryResolve(out Sprite? pomodoro, out Sprite? breakSprite) { if ((Object)(object)_pomodoro != (Object)null && (Object)(object)_break != (Object)null) { pomodoro = _pomodoro; breakSprite = _break; return true; } pomodoro = _pomodoro; breakSprite = _break; float unscaledTime = Time.unscaledTime; if (unscaledTime < _nextProbeAt) { return (Object)(object)pomodoro != (Object)null; } _nextProbeAt = unscaledTime + 5f; try { PomodoroController i = MonoSingleton<PomodoroController>.I; if ((Object)(object)i == (Object)null) { return (Object)(object)pomodoro != (Object)null; } if ((Object)(object)i.PomoSprite != (Object)null) { _pomodoro = i.PomoSprite; } object? obj = typeof(PomodoroController).GetField("_breakBgSprite", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(i); Sprite val = (Sprite)((obj is Sprite) ? obj : null); if (val != null && (Object)(object)val != (Object)null) { _break = val; } } catch (Exception) { } pomodoro = _pomodoro; breakSprite = _break; return (Object)(object)pomodoro != (Object)null; } } internal sealed class BlueSageUiThemePalette { public string Key { get; } public string DisplayName { get; } public Color Window { get; } public Color Panel { get; } public Color Header { get; } public Color HeaderText { get; } public Color LabelText { get; } public Color SmallText { get; } public Color ButtonText { get; } public Color ActiveButtonText { get; } public Color FieldText { get; } public Color PreviewBackground { get; } public bool IsMidnightDock => string.Equals(Key, "Midnight Dock", StringComparison.OrdinalIgnoreCase); public bool UsesWarmContent { get { if (!string.Equals(Key, "BlueSage Harbor", StringComparison.OrdinalIgnoreCase) && !string.Equals(Key, "Vanilla Cream OT", StringComparison.OrdinalIgnoreCase)) { return string.Equals(Key, "OG", StringComparison.OrdinalIgnoreCase); } return true; } } public Color SectionPanel { get { //IL_003e: 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_001a: 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) if (!string.Equals(Key, "BlueSage Harbor", StringComparison.OrdinalIgnoreCase)) { return Color.Lerp(Panel, Window, 0.16f); } return new Color(0.975f, 0.945f, 0.885f, 1f); } } public Color SectionBorder { get { //IL_0068: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!string.Equals(Key, "BlueSage Harbor", StringComparison.OrdinalIgnoreCase)) { if (!string.Equals(Key, "Vanilla Cream OT", StringComparison.OrdinalIgnoreCase)) { return Color.Lerp(Header, LabelText, 0.3f); } return Color.Lerp(Header, FieldText, 0.4f); } return new Color(0.65f, 0.52f, 0.39f, 1f); } } public Color FieldBackground { get { //IL_0041: 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_000e: 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) if (!IsMidnightDock) { return Color.Lerp(SectionPanel, Color.white, UsesWarmContent ? 0.44f : 0.1f); } return new Color(0.045f, 0.065f, 0.105f, 1f); } } public Color FieldHoverBackground { get { //IL_0033: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!IsMidnightDock) { return Color.Lerp(FieldBackground, Header, 0.1f); } return new Color(0.075f, 0.115f, 0.165f, 1f); } } public Color FieldFocusedBackground { get { //IL_0032: 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_000e: 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 (!IsMidnightDock) { return Color.Lerp(FieldBackground, Color.white, 0.16f); } return new Color(0.055f, 0.135f, 0.165f, 1f); } } public Color FieldBorder { get { //IL_0023: 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) if (!IsMidnightDock) { return SectionBorder; } return new Color(0.28f, 0.42f, 0.56f, 1f); } } public Color FieldFocusedBorder { get { //IL_0033: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!IsMidnightDock) { return Color.Lerp(ActiveAccent, DarkStateText, 0.18f); } return new Color(0.24f, 0.72f, 0.78f, 1f); } } public Color ActiveAccent { get { //IL_002e: 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) if (!string.Equals(Key, "BlueSage Harbor", StringComparison.OrdinalIgnoreCase)) { return Header; } return new Color(0.91f, 0.49f, 0.39f, 1f); } } public Color EnabledAccent { get { //IL_0051: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!string.Equals(Key, "BlueSage Harbor", StringComparison.OrdinalIgnoreCase)) { return Color.Lerp(Header, new Color(0.45f, 0.8f, 0.36f, 1f), 0.58f); } return new Color(0.39f, 0.55f, 0.24f, 1f); } } public string NavigationKeywordHex { get { if (!IsMidnightDock) { return "005A85"; } return "70D6FF"; } } public Color DisabledAccent { get { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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) //IL_0022: 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) if (!string.Equals(Key, "BlueSage Harbor", StringComparison.OrdinalIgnoreCase)) { if (!IsMidnightDock) { return Color.Lerp(ButtonText, Window, 0.58f); } return new Color(0.26f, 0.31f, 0.39f, 1f); } return new Color(0.68f, 0.65f, 0.61f, 1f); } } public Color DarkStateText { get { //IL_002a: 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_001c: Unknown result type (might be due to invalid IL or missing references) if (!IsMidnightDock) { if (!string.Equals(Key, "BlueSage Harbor", StringComparison.OrdinalIgnoreCase)) { return FieldText; } return Header; } return Window; } } public Color ActiveStateText { get { //IL_0010: 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) if (!IsMidnightDock) { return DarkStateText; } return ActiveButtonText; } } public Color EnabledButtonText => DarkStateText; public Color DisabledButtonText { get { //IL_0023: 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) if (!IsMidnightDock) { return DarkStateText; } return new Color(0.84f, 0.89f, 0.94f, 1f); } } public Color ExperimentalButtonText => DarkStateText; public Color NeutralButtonAccent { get { //IL_0020: 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) //IL_002f: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!IsMidnightDock) { return Color.Lerp(Panel, ButtonText, 0.3f); } return Color.Lerp(Panel, Color.white, 0.12f); } } public Color NeutralButtonText { get { //IL_0010: 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) if (!IsMidnightDock) { return DarkStateText; } return ButtonText; } } public Color PreviewText { get { //IL_002d: 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) if (!string.Equals(Key, "OG", StringComparison.OrdinalIgnoreCase) && !string.Equals(Key, "Vanilla Cream OT", StringComparison.OrdinalIgnoreCase)) { return LabelText; } return Color.white; } } public Color PopupHeaderText { get { //IL_0010: 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) if (!IsMidnightDock) { return DarkStateText; } return ActiveButtonText; } } public Color PopupBodyText { get { //IL_0010: 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) if (!IsMidnightDock) { return DarkStateText; } return LabelText; } } public Color PopupHintText { get { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) if (!IsMidnightDock) { return DarkStateText; } return Color.Lerp(SmallText, LabelText, 0.35f); } } public Color ComfortAccent { get { //IL_0036: 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) if (!IsMidnightDock) { return new Color(0.39f, 0.55f, 0.24f, 1f); } return new Color(0.42f, 0.76f, 0.49f, 1f); } } public Color ChatAccent { get { //IL_0036: 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) if (!IsMidnightDock) { return new Color(0.1f, 0.56f, 0.62f, 1f); } return new Color(0.32f, 0.72f, 0.82f, 1f); } } public Color IdentityAccent { get { //IL_0036: 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) if (!IsMidnightDock) { return new Color(0.47f, 0.4f, 0.68f, 1f); } return new Color(0.55f, 0.63f, 0.91f, 1f); } } public Color PersonalizationAccent { get { //IL_0036: 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) if (!IsMidnightDock) { return new Color(0.72f, 0.39f, 0.5f, 1f); } return new Color(0.82f, 0.55f, 0.73f, 1f); } } public Color AccessibilityAccent { get { //IL_0036: 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) if (!IsMidnightDock) { return new Color(0.5f, 0.3f, 0.8f, 1f); } return new Color(0.66f, 0.45f, 0.98f, 1f); } } public Color ExperimentalAccent => new Color(1f, 0.42f, 0.08f, 1f); public Color ExperimentalBorder { get { //IL_0020: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!IsMidnightDock) { return Color.Lerp(ExperimentalAccent, DarkStateText, 0.35f); } return ExperimentalAccent; } } public Color FooterBackground { get { //IL_003e: 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_001a: 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) if (!string.Equals(Key, "BlueSage Harbor", StringComparison.OrdinalIgnoreCase)) { return Color.Lerp(Header, Window, 0.3f); } return new Color(0.055f, 0.075f, 0.115f, 1f); } } public Color FooterText { get { //IL_002e: 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) if (!string.Equals(Key, "BlueSage Harbor", StringComparison.OrdinalIgnoreCase)) { return HeaderText; } return new Color(0.84f, 0.93f, 0.98f, 1f); } } public Color FooterBorder { get { //IL_002a: 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_001c: Unknown result type (might be due to invalid IL or missing references) if (!IsMidnightDock) { if (!string.Equals(Key, "BlueSage Harbor", StringComparison.OrdinalIgnoreCase)) { return DarkStateText; } return SectionBorder; } return FieldFocusedBorder; } } public BlueSageUiThemePalette(string key, string displayName, Color window, Color panel, Color header, Color headerText, Color labelText, Color smallText, Color buttonText, Color activeButtonText, Color fieldText, Color previewBackground) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) //IL_001e: 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_0026: 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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0056: 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_005e: Unknown result type (might be due to invalid IL or missing references) Key = key; DisplayName = displayName; Window = window; Panel = panel; Header = header; HeaderText = headerText; LabelText = labelText; SmallText = smallText; ButtonText = buttonText; ActiveButtonText = activeButtonText; FieldText = fieldText; PreviewBackground = previewBackground; } } internal static class BlueSageUiTheme { public const string DefaultThemeKey = "BlueSage Harbor"; private static readonly Dictionary<string, Texture2D> SolidTextures = new Dictionary<string, Texture2D>(StringComparer.Ordinal); private static readonly Dictionary<string, Texture2D> PanelTextures = new Dictionary<string, Texture2D>(StringComparer.Ordinal); private static readonly BlueSageUiThemePalette[] Palettes = new BlueSageUiThemePalette[4] { new BlueSageUiThemePalette("BlueSage Harbor", "BlueSage Harbor", new Color(0.93f, 0.875f, 0.79f, 0.995f), new Color(0.985f, 0.95f, 0.88f, 0.995f), new Color(0.055f, 0.075f, 0.115f, 1f), new Color(0.84f, 0.95f, 0.98f, 1f), new Color(0.2f, 0.16f, 0.15f, 1f), new Color(0.35f, 0.29f, 0.27f, 1f), new Color(0.22f, 0.18f, 0.17f, 1f), new Color(1f, 0.96f, 0.88f, 1f), new Color(0.12f, 0.1f, 0.1f, 1f), new Color(0.985f, 0.95f, 0.88f, 0.98f)), new BlueSageUiThemePalette("OG", "OG", new Color(0.93f, 0.9f, 0.83f, 0.99f), new Color(0.84f, 0.8f, 0.72f, 0.98f), new Color(0.55f, 0.52f, 0.47f, 1f), new Color(0.12f, 0.09f, 0.1f, 1f), new Color(0.22f, 0.14f, 0.17f, 1f), new Color(0.34f, 0.26f, 0.29f, 1f), new Color(0.24f, 0.17f, 0.2f, 1f), Color.white, new Color(0.14f, 0.11f, 0.12f, 1f), new Color(0.28f, 0.27f, 0.25f, 0.96f)), new BlueSageUiThemePalette("Vanilla Cream OT", "Vanilla Cream OT", new Color(0.98f, 0.93f, 0.84f, 0.99f), new Color(0.91f, 0.82f, 0.69f, 0.98f), new Color(0.91f, 0.49f, 0.42f, 1f), new Color(0.23f, 0.14f, 0.16f, 1f), new Color(0.32f, 0.22f, 0.25f, 1f), new Color(0.43f, 0.31f, 0.33f, 1f), new Color(0.31f, 0.22f, 0.25f, 1f), Color.white, new Color(0.15f, 0.11f, 0.12f, 1f), new Color(0.39f, 0.31f, 0.27f, 0.96f)), new BlueSageUiThemePalette("Midnight Dock", "Midnight Dock", new Color(0.08f, 0.1f, 0.16f, 0.99f), new Color(0.13f, 0.16f, 0.24f, 0.98f), new Color(0.08f, 0.36f, 0.42f, 1f), new Color(0.88f, 0.98f, 1f, 1f), new Color(0.91f, 0.96f, 1f, 1f), new Color(0.72f, 0.82f, 0.9f, 1f), new Color(0.89f, 0.94f, 1f, 1f), new Color(1f, 0.91f, 0.42f, 1f), new Color(0.96f, 0.98f, 1f, 1f), new Color(0.04f, 0.05f, 0.08f, 0.97f)) }; public static int RuntimeTextureGeneration { get; private set; } = 1; public static BlueSageUiThemePalette Current => Get(Plugin.UiThemePreset?.Value); public static string[] Names => Array.ConvertAll(Palettes, (BlueSageUiThemePalette palette) => palette.DisplayName); public static BlueSageUiThemePalette Get(string requested) { string b = Normalize(requested); BlueSageUiThemePalette[] palettes = Palettes; foreach (BlueSageUiThemePalette blueSageUiThemePalette in palettes) { if (string.Equals(blueSageUiThemePalette.Key, b, StringComparison.OrdinalIgnoreCase) || string.Equals(blueSageUiThemePalette.DisplayName, b, StringComparison.OrdinalIgnoreCase)) { return blueSageUiThemePalette; } } return GetDefaultPalette(); } public static string Normalize(string requested) { string text = (requested ?? string.Empty).Trim(); if (text.Length == 0) { return "BlueSage Harbor"; } BlueSageUiThemePalette[] palettes = Palettes; foreach (BlueSageUiThemePalette blueSageUiThemePalette in palettes) { if (string.Equals(blueSageUiThemePalette.Key, text, StringComparison.OrdinalIgnoreCase) || string.Equals(blueSageUiThemePalette.DisplayName, text, StringComparison.OrdinalIgnoreCase)) { return blueSageUiThemePalette.Key; } } return "BlueSage Harbor"; } public static string Next(string requested) { string b = Normalize(requested); for (int i = 0; i < Palettes.Length; i++) { if (string.Equals(Palettes[i].Key, b, StringComparison.OrdinalIgnoreCase)) { return Palettes[(i + 1) % Palettes.Length].Key; } } return GetDefaultPalette().Key; } private static BlueSageUiThemePalette GetDefaultPalette() { BlueSageUiThemePalette[] palettes = Palettes; foreach (BlueSageUiThemePalette blueSageUiThemePalette in palettes) { if (string.Equals(blueSageUiThemePalette.Key, "BlueSage Harbor", StringComparison.OrdinalIgnoreCase)) { return blueSageUiThemePalette; } } return Palettes[0]; } public static GUIStyle CreateTextInputStyle(GUIStyle source, BlueSageUiThemePalette palette, int fontSize, bool wordWrap) { //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_000d: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_002a: 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: Expected O, but got Unknown //IL_0039: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0086: 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_0097: 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_00a3: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown GUIStyle val = new GUIStyle(source) { richText = false, fontSize = fontSize, wordWrap = wordWrap, border = new RectOffset(1, 1, 1, 1), padding = new RectOffset(8, 8, 5, 5) }; ApplyState(val.normal, palette.FieldBackground, palette.FieldBorder, palette.FieldText); ApplyState(val.hover, palette.FieldHoverBackground, palette.FieldBorder, palette.FieldText); ApplyState(val.active, palette.FieldFocusedBackground, palette.FieldFocusedBorder, palette.FieldText); ApplyState(val.focused, palette.FieldFocusedBackground, palette.FieldFocusedBorder, palette.FieldText); ApplyState(val.onNormal, palette.FieldBackground, palette.FieldBorder, palette.FieldText); ApplyState(val.onHover, palette.FieldHoverBackground, palette.FieldBorder, palette.FieldText); ApplyState(val.onActive, palette.FieldFocusedBackground, palette.FieldFocusedBorder, palette.FieldText); ApplyState(val.onFocused, palette.FieldFocusedBackground, palette.FieldFocusedBorder, palette.FieldText); return val; } public static GUIStyle CreateStateButtonStyle(GUIStyle source, Color fill, Color border, Color text, int fontSize) { //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_000e: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0024: 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) //IL_0040: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0065: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00dd: 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_00e9: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown GUIStyle val = new GUIStyle(source) { fontSize = fontSize, fontStyle = (FontStyle)1, border = new RectOffset(1, 1, 1, 1) }; bool flag = RelativeLuminance(text) >= 0.5f; Color fill2 = Color.Lerp(fill, flag ? Color.black : Color.white, flag ? 0.08f : 0.11f); Color fill3 = Color.Lerp(fill, flag ? Color.black : Color.white, flag ? 0.18f : 0.2f); ApplyState(val.normal, fill, border, text); ApplyState(val.hover, fill2, Color.Lerp(border, Color.white, 0.16f), text); ApplyState(val.active, fill3, border, text); ApplyState(val.focused, fill2, Color.Lerp(border, Color.white, 0.16f), text); ApplyState(val.onNormal, fill, border, text); ApplyState(val.onHover, fill2, Color.Lerp(border, Color.white, 0.16f), text); ApplyState(val.onActive, fill3, border, text); ApplyState(val.onFocused, fill2, Color.Lerp(border, Color.white, 0.16f), text); return val; } public static GUIStyle CreateNeutralButtonStyle(GUIStyle source, BlueSageUiThemePalette palette, int fontSize) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return CreateStateButtonStyle(source, palette.NeutralButtonAccent, palette.FieldBorder, palette.NeutralButtonText, fontSize); } public static GUIStyle CreateSwatchButtonStyle(GUIStyle source, int fontSize) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unkno