Decompiled source of SteamStatusSpoof v0.3.0

plugins/SteamStatusSpoof.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 SteamStatusSpoof
{
	internal static class ModConfig
	{
		public static ConfigEntry<KeyCode> MenuKey;

		public static ConfigEntry<float> LongPressDuration;

		public static void Init(ConfigFile cfg)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			MenuKey = cfg.Bind<KeyCode>("General", "MenuKey", (KeyCode)291, new ConfigDescription("长按打开菜单的按键", (AcceptableValueBase)null, Array.Empty<object>()));
			LongPressDuration = cfg.Bind<float>("General", "LongPressDuration", 0.5f, new ConfigDescription("长按触发时长(秒)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
		}
	}
	[BepInPlugin("SteamStatusSpoof", "SteamStatusSpoof", "0.3.0")]
	internal sealed class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		private float _pressTime;

		private bool _pressing;

		private void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_005c: 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)
			ModConfig.Init(((BaseUnityPlugin)this).Config);
			StatusState.InitLog(((BaseUnityPlugin)this).Logger);
			_harmony = new Harmony("SteamStatusSpoof");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[Steam状态伪装] v0.3.0 已加载");
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[Steam状态伪装] 按键=" + ((object)ModConfig.MenuKey.Value/*cast due to .constrained prefix*/).ToString() + ", 长按时长=" + ModConfig.LongPressDuration.Value + "s"));
		}

		private void Update()
		{
			//IL_000a: 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)
			StatusMenu.Tick();
			if (Input.GetKeyDown(ModConfig.MenuKey.Value))
			{
				_pressTime = Time.unscaledTime;
				_pressing = true;
			}
			if (_pressing && Input.GetKeyUp(ModConfig.MenuKey.Value))
			{
				_pressing = false;
			}
			if (_pressing && Time.unscaledTime - _pressTime >= ModConfig.LongPressDuration.Value)
			{
				_pressing = false;
				StatusMenu.Toggle();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"[Steam状态伪装] 长按触发,切换菜单");
			}
		}

		private void OnGUI()
		{
			StatusMenu.Draw();
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			StatusMenu.Close();
		}
	}
	internal static class PluginInfo
	{
		public const string GUID = "SteamStatusSpoof";

		public const string Name = "SteamStatusSpoof";

		public const string Version = "0.3.0";
	}
	[HarmonyPatch(typeof(SteamFriends), "SetRichPresence")]
	public static class SetRichPresencePatch
	{
		public static bool Prefix(ref string pchKey, ref string pchValue)
		{
			switch (StatusState.CurrentMode)
			{
			case StatusMode.Clear:
				return false;
			case StatusMode.Custom:
				if (pchKey == "steam_display" && !string.IsNullOrEmpty(StatusState.CustomDisplayKey))
				{
					StatusState.LogDebug("[Steam状态伪装] 拦截 steam_display: 原值='" + pchValue + "' → 新值='#" + StatusState.CustomDisplayKey + "'");
					pchValue = "#" + StatusState.CustomDisplayKey;
				}
				else if (pchKey == "steam_player_group" && !string.IsNullOrEmpty(StatusState.CustomPlayerGroup))
				{
					StatusState.LogDebug("[Steam状态伪装] 拦截 steam_player_group: 原值='" + pchValue + "' → 新值='" + StatusState.CustomPlayerGroup + "'");
					pchValue = StatusState.CustomPlayerGroup;
				}
				else if ((pchKey == "players" || pchKey == "steam_player_group_size") && !string.IsNullOrEmpty(StatusState.CustomPlayers))
				{
					StatusState.LogDebug("[Steam状态伪装] 拦截 " + pchKey + ": 原值='" + pchValue + "' → 新值='" + StatusState.CustomPlayers + "'");
					pchValue = StatusState.CustomPlayers;
				}
				else if (pchKey == "max_players" && !string.IsNullOrEmpty(StatusState.CustomMaxPlayers))
				{
					StatusState.LogDebug("[Steam状态伪装] 拦截 max_players: 原值='" + pchValue + "' → 新值='" + StatusState.CustomMaxPlayers + "'");
					pchValue = StatusState.CustomMaxPlayers;
				}
				break;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(SteamFriends), "ClearRichPresence")]
	public static class ClearRichPresencePatch
	{
		public static bool Prefix()
		{
			if (StatusState.CurrentMode == StatusMode.Custom)
			{
				return false;
			}
			return true;
		}
	}
	internal sealed class StatusMenu
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static WindowFunction <0>__DrawWindow;
		}

		private static Rect _rect = new Rect((float)Screen.width - 320f, 60f, 290f, 460f);

		private const int WindowId = 61800;

		private static bool _visible;

		private static bool IsCN => StatusState.IsChinese;

		public static void Toggle()
		{
			//IL_002f: 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)
			_visible = !_visible;
			if (!_visible)
			{
				_rect = new Rect((float)Screen.width - 320f, 60f, 290f, 460f);
			}
			UpdateCursor();
		}

		public static void Close()
		{
			_visible = false;
			UpdateCursor();
		}

		public static void Tick()
		{
			UpdateCursor();
		}

		private static void UpdateCursor()
		{
			if (_visible && !Cursor.visible)
			{
				Cursor.visible = true;
			}
		}

		public static void Draw()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			if (!_visible)
			{
				return;
			}
			try
			{
				StatusMenuTheme.Build();
				((Rect)(ref _rect)).x = Mathf.Clamp(((Rect)(ref _rect)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref _rect)).width));
				((Rect)(ref _rect)).y = Mathf.Clamp(((Rect)(ref _rect)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref _rect)).height));
				Rect rect = _rect;
				object obj = <>O.<0>__DrawWindow;
				if (obj == null)
				{
					WindowFunction val = DrawWindow;
					<>O.<0>__DrawWindow = val;
					obj = (object)val;
				}
				_rect = GUI.Window(61800, rect, (WindowFunction)obj, GUIContent.none, StatusMenuTheme.WindowStyle);
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[SteamStatusSpoof] Menu draw error: " + ex));
			}
		}

		private static void DrawWindow(int id)
		{
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(IsCN ? "Steam 状态伪装" : "Steam Status Spoof", StatusMenuTheme.LabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if (GUILayout.Button(IsCN ? "EN" : "中", StatusMenuTheme.GridButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(30f),
				GUILayout.Height(20f)
			}))
			{
				StatusState.ToggleLanguage();
			}
			GUILayout.EndHorizontal();
			string text = StatusState.CurrentMode switch
			{
				StatusMode.Custom => IsCN ? "自定义状态" : "Custom", 
				StatusMode.Restore => IsCN ? "还原(原生状态)" : "Restore (Native)", 
				_ => IsCN ? "已清空" : "Cleared", 
			};
			GUILayout.Label((IsCN ? "当前模式: " : "Mode: ") + text, StatusMenuTheme.ModeStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			GUILayout.Label(IsCN ? "自定义显示状态" : "Display Status", StatusMenuTheme.LabelStyle, Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			(string, string, string)[] displayKeys = StatusState.DisplayKeys;
			int num = displayKeys.Length;
			for (int i = 0; i < num; i += 3)
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				for (int j = 0; j < 3 && i + j < num; j++)
				{
					(string, string, string) tuple = displayKeys[i + j];
					string obj = (IsCN ? tuple.Item2 : tuple.Item3);
					GUIStyle val = ((StatusState.CustomDisplayKey == tuple.Item1) ? StatusMenuTheme.ButtonStyle : StatusMenuTheme.GridButtonStyle);
					if (GUILayout.Button(obj, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
					{
						(StatusState.CustomDisplayKey, _, _) = tuple;
					}
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndVertical();
			GUILayout.Label(IsCN ? "房间名" : "Room Name", StatusMenuTheme.LabelStyle, Array.Empty<GUILayoutOption>());
			StatusState.CustomPlayerGroup = GUILayout.TextField(StatusState.CustomPlayerGroup, StatusMenuTheme.TextFieldStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label(IsCN ? "当前人数" : "Players", StatusMenuTheme.LabelStyle, Array.Empty<GUILayoutOption>());
			StatusState.CustomPlayers = GUILayout.TextField(StatusState.CustomPlayers, StatusMenuTheme.IntFieldStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label(IsCN ? "人数上限" : "Max Players", StatusMenuTheme.LabelStyle, Array.Empty<GUILayoutOption>());
			StatusState.CustomMaxPlayers = GUILayout.TextField(StatusState.CustomMaxPlayers, StatusMenuTheme.IntFieldStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			if (GUILayout.Button(IsCN ? "确认更改状态" : "Apply", StatusMenuTheme.ActionButtonStyle, Array.Empty<GUILayoutOption>()))
			{
				StatusState.ApplyCustom();
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button(IsCN ? "还原状态" : "Restore", StatusMenuTheme.RestoreButtonStyle, Array.Empty<GUILayoutOption>()))
			{
				StatusState.Restore();
			}
			if (GUILayout.Button(IsCN ? "清空状态" : "Clear", StatusMenuTheme.ClearButtonStyle, Array.Empty<GUILayoutOption>()))
			{
				StatusState.Clear();
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(4f);
			GUILayout.Label(IsCN ? "Steam 富存在约 5 秒节流,频繁操作可能不生效" : "Steam Rich Presence ~5s throttle", StatusMenuTheme.HintStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label(IsCN ? "留空字段则使用游戏原生值" : "Empty fields use game native values", StatusMenuTheme.HintStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label(IsCN ? "点击按钮切换显示文本" : "Click button to set display text", StatusMenuTheme.HintStyle, Array.Empty<GUILayoutOption>());
			GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _rect)).width, 22f));
		}
	}
	internal static class StatusMenuTheme
	{
		private static bool _built;

		public static Font Font;

		public static GUIStyle WindowStyle;

		public static GUIStyle LabelStyle;

		public static GUIStyle TextFieldStyle;

		public static GUIStyle IntFieldStyle;

		public static GUIStyle ButtonStyle;

		public static GUIStyle ActionButtonStyle;

		public static GUIStyle RestoreButtonStyle;

		public static GUIStyle ClearButtonStyle;

		public static GUIStyle GridButtonStyle;

		public static GUIStyle HintStyle;

		public static GUIStyle ModeStyle;

		public static void Build()
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_0125: 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_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Expected O, but got Unknown
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Expected O, but got Unknown
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Expected O, but got Unknown
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Expected O, but got Unknown
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Expected O, but got Unknown
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Expected O, but got Unknown
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Expected O, but got Unknown
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Expected O, but got Unknown
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Expected O, but got Unknown
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Expected O, but got Unknown
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Expected O, but got Unknown
			//IL_062b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0635: Expected O, but got Unknown
			//IL_065b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0665: Expected O, but got Unknown
			//IL_068a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0720: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0744: Expected O, but got Unknown
			//IL_074d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0757: Expected O, but got Unknown
			//IL_077d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0787: Expected O, but got Unknown
			//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_081f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0837: Unknown result type (might be due to invalid IL or missing references)
			//IL_0841: Expected O, but got Unknown
			//IL_084a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0854: Expected O, but got Unknown
			//IL_0885: Unknown result type (might be due to invalid IL or missing references)
			//IL_088f: Expected O, but got Unknown
			//IL_08b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f9: Expected O, but got Unknown
			//IL_091e: Unknown result type (might be due to invalid IL or missing references)
			if (_built)
			{
				return;
			}
			_built = true;
			try
			{
				string[] oSInstalledFontNames = Font.GetOSInstalledFontNames();
				string[] array = new string[5] { "Microsoft YaHei UI", "Microsoft YaHei", "微软雅黑", "Noto Sans SC", "SimHei" };
				foreach (string text in array)
				{
					if (oSInstalledFontNames != null && Array.IndexOf(oSInstalledFontNames, text) >= 0)
					{
						Font = Font.CreateDynamicFontFromOSFont(text, 13);
						if ((Object)(object)Font != (Object)null)
						{
							((Object)Font).hideFlags = (HideFlags)61;
							break;
						}
					}
				}
			}
			catch
			{
			}
			Texture2D background = CreateRoundedBg(64, 0.08f, 0.09f, 0.11f, 0.97f, 0.23f, 0.25f, 0.31f, 10f);
			WindowStyle = new GUIStyle();
			WindowStyle.normal.background = background;
			WindowStyle.hover.background = background;
			WindowStyle.active.background = background;
			WindowStyle.focused.background = background;
			WindowStyle.normal.textColor = new Color(0.91f, 0.918f, 0.937f);
			WindowStyle.hover.textColor = new Color(0.91f, 0.918f, 0.937f);
			WindowStyle.active.textColor = new Color(0.91f, 0.918f, 0.937f);
			WindowStyle.focused.textColor = new Color(0.91f, 0.918f, 0.937f);
			WindowStyle.padding = new RectOffset(12, 12, 12, 12);
			WindowStyle.border = new RectOffset(12, 12, 12, 12);
			LabelStyle = new GUIStyle(GUI.skin.label);
			LabelStyle.fontSize = 12;
			LabelStyle.normal.textColor = new Color(0.65f, 0.68f, 0.73f);
			LabelStyle.margin = new RectOffset(0, 0, 0, 2);
			if ((Object)(object)Font != (Object)null)
			{
				LabelStyle.font = Font;
			}
			TextFieldStyle = new GUIStyle(GUI.skin.textField);
			TextFieldStyle.fontSize = 12;
			TextFieldStyle.normal.textColor = new Color(0.91f, 0.918f, 0.937f);
			TextFieldStyle.padding = new RectOffset(6, 6, 4, 4);
			TextFieldStyle.margin = new RectOffset(0, 0, 2, 0);
			if ((Object)(object)Font != (Object)null)
			{
				TextFieldStyle.font = Font;
			}
			IntFieldStyle = new GUIStyle(GUI.skin.textField);
			IntFieldStyle.fontSize = 12;
			IntFieldStyle.normal.textColor = new Color(0.91f, 0.918f, 0.937f);
			IntFieldStyle.padding = new RectOffset(6, 6, 4, 4);
			IntFieldStyle.margin = new RectOffset(0, 0, 2, 0);
			if ((Object)(object)Font != (Object)null)
			{
				IntFieldStyle.font = Font;
			}
			ButtonStyle = new GUIStyle(GUI.skin.button);
			ButtonStyle.fontSize = 11;
			ButtonStyle.normal.textColor = new Color(0.91f, 0.918f, 0.937f);
			ButtonStyle.hover.textColor = new Color(0.91f, 0.918f, 0.937f);
			ButtonStyle.padding = new RectOffset(8, 8, 4, 4);
			ButtonStyle.margin = new RectOffset(0, 2, 0, 2);
			if ((Object)(object)Font != (Object)null)
			{
				ButtonStyle.font = Font;
			}
			ActionButtonStyle = new GUIStyle(GUI.skin.button);
			ActionButtonStyle.fontSize = 12;
			ActionButtonStyle.normal.textColor = new Color(0.12f, 0.13f, 0.16f);
			ActionButtonStyle.hover.textColor = new Color(0.12f, 0.13f, 0.16f);
			ActionButtonStyle.active.textColor = new Color(0.12f, 0.13f, 0.16f);
			ActionButtonStyle.normal.background = MakeSolidTexture(new Color(1f, 0.788f, 0.298f));
			ActionButtonStyle.hover.background = MakeSolidTexture(new Color(1f, 0.83f, 0.4f));
			ActionButtonStyle.active.background = MakeSolidTexture(new Color(0.9f, 0.7f, 0.2f));
			ActionButtonStyle.padding = new RectOffset(12, 12, 6, 6);
			ActionButtonStyle.margin = new RectOffset(0, 2, 0, 2);
			if ((Object)(object)Font != (Object)null)
			{
				ActionButtonStyle.font = Font;
			}
			RestoreButtonStyle = new GUIStyle(GUI.skin.button);
			RestoreButtonStyle.fontSize = 12;
			RestoreButtonStyle.normal.textColor = new Color(0.91f, 0.918f, 0.937f);
			RestoreButtonStyle.hover.textColor = new Color(0.91f, 0.918f, 0.937f);
			RestoreButtonStyle.normal.background = MakeSolidTexture(new Color(0.18f, 0.45f, 0.35f));
			RestoreButtonStyle.hover.background = MakeSolidTexture(new Color(0.22f, 0.55f, 0.42f));
			RestoreButtonStyle.active.background = MakeSolidTexture(new Color(0.15f, 0.38f, 0.3f));
			RestoreButtonStyle.padding = new RectOffset(12, 12, 6, 6);
			RestoreButtonStyle.margin = new RectOffset(0, 2, 0, 2);
			if ((Object)(object)Font != (Object)null)
			{
				RestoreButtonStyle.font = Font;
			}
			ClearButtonStyle = new GUIStyle(GUI.skin.button);
			ClearButtonStyle.fontSize = 12;
			ClearButtonStyle.normal.textColor = new Color(0.91f, 0.918f, 0.937f);
			ClearButtonStyle.hover.textColor = new Color(0.91f, 0.918f, 0.937f);
			ClearButtonStyle.normal.background = MakeSolidTexture(new Color(0.55f, 0.2f, 0.2f));
			ClearButtonStyle.hover.background = MakeSolidTexture(new Color(0.65f, 0.25f, 0.25f));
			ClearButtonStyle.active.background = MakeSolidTexture(new Color(0.45f, 0.15f, 0.15f));
			ClearButtonStyle.padding = new RectOffset(12, 12, 6, 6);
			ClearButtonStyle.margin = new RectOffset(0, 0, 0, 2);
			if ((Object)(object)Font != (Object)null)
			{
				ClearButtonStyle.font = Font;
			}
			GridButtonStyle = new GUIStyle(GUI.skin.button);
			GridButtonStyle.fontSize = 11;
			GridButtonStyle.normal.textColor = new Color(0.82f, 0.85f, 0.9f);
			GridButtonStyle.normal.background = MakeSolidTexture(new Color(0.16f, 0.17f, 0.21f));
			GridButtonStyle.hover.background = MakeSolidTexture(new Color(0.22f, 0.23f, 0.28f));
			GridButtonStyle.active.background = MakeSolidTexture(new Color(0.3f, 0.31f, 0.38f));
			GridButtonStyle.padding = new RectOffset(4, 4, 3, 3);
			GridButtonStyle.margin = new RectOffset(1, 1, 1, 1);
			GridButtonStyle.alignment = (TextAnchor)4;
			if ((Object)(object)Font != (Object)null)
			{
				GridButtonStyle.font = Font;
			}
			HintStyle = new GUIStyle(GUI.skin.label);
			HintStyle.fontSize = 10;
			HintStyle.normal.textColor = new Color(0.47f, 0.5f, 0.55f);
			HintStyle.wordWrap = true;
			if ((Object)(object)Font != (Object)null)
			{
				HintStyle.font = Font;
			}
			ModeStyle = new GUIStyle(GUI.skin.label);
			ModeStyle.fontSize = 11;
			ModeStyle.normal.textColor = new Color(1f, 0.788f, 0.298f);
			ModeStyle.alignment = (TextAnchor)4;
			if ((Object)(object)Font != (Object)null)
			{
				ModeStyle.font = Font;
			}
		}

		private static Texture2D CreateRoundedBg(int size, float fr, float fg, float fb, float fa, float er, float eg, float eb, float radius)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_00fc: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)5, false)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1,
				hideFlags = (HideFlags)61
			};
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(fr, fg, fb, fa);
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(er, eg, eb, 1f);
			Color[] array = (Color[])(object)new Color[size * size];
			float num = Mathf.Max(0.001f, radius);
			float num2 = Mathf.Max(0f, num - 1f);
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num3 = (float)j + 0.5f;
					float num4 = (float)i + 0.5f;
					float num5 = Mathf.Max(0f, Mathf.Max(num - num3, num3 - ((float)size - num)));
					float num6 = Mathf.Max(0f, Mathf.Max(num - num4, num4 - ((float)size - num)));
					float num7 = Mathf.Sqrt(num5 * num5 + num6 * num6);
					float num8 = Mathf.Clamp01(num - num7 + 0.5f);
					float num9 = Mathf.Clamp01(num2 - num7 + 0.5f);
					Color val4 = Color.Lerp(val3, val2, num9);
					val4.a *= num8;
					array[i * size + j] = val4;
				}
			}
			val.SetPixels(array);
			val.Apply(false, false);
			return val;
		}

		private static Texture2D MakeSolidTexture(Color c)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(2, 2, (TextureFormat)5, false)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)0,
				hideFlags = (HideFlags)61
			};
			val.SetPixels((Color[])(object)new Color[4] { c, c, c, c });
			val.Apply(false, false);
			return val;
		}
	}
	internal enum StatusMode
	{
		Restore,
		Custom,
		Clear
	}
	internal static class StatusState
	{
		public static readonly (string Key, string CnName, string EnName)[] DisplayKeys = new(string, string, string)[14]
		{
			("", "无", "None"),
			("Status_MainMenu", "主菜单", "Main Menu"),
			("Status_Airport", "机场", "Airport"),
			("Status_Shore", "海滩", "Shore"),
			("Status_Tropics", "雨林", "Tropics"),
			("Status_Alpine", "雪山", "Alpine"),
			("Status_Mesa", "方山", "Mesa"),
			("Status_Caldera", "火山", "Caldera"),
			("Status_Kiln", "熔炉", "The Kiln"),
			("Status_Peak", "顶峰", "Peak"),
			("Status_Roots", "森菇", "Roots"),
			("Status_Gloom", "雾沼", "Gloom"),
			("Status_Citadel", "城塞", "The Citadel"),
			("Status_Nadir", "天底", "Void")
		};

		private static ManualLogSource _log;

		public static StatusMode CurrentMode { get; private set; } = StatusMode.Restore;

		public static string CustomDisplayKey { get; set; } = "";

		public static string CustomPlayerGroup { get; set; } = "";

		public static string CustomPlayers { get; set; } = "1";

		public static string CustomMaxPlayers { get; set; } = "4";

		public static bool IsChinese { get; set; } = true;

		public static double LastApplyTime { get; private set; } = 0.0;

		public static void InitLog(ManualLogSource log)
		{
			_log = log;
		}

		public static void LogDebug(string msg)
		{
			ManualLogSource log = _log;
			if (log != null)
			{
				log.LogInfo((object)msg);
			}
		}

		public static void ToggleLanguage()
		{
			IsChinese = !IsChinese;
			LogDebug("[SteamStatusSpoof] Language: " + (IsChinese ? "zh-CN" : "en"));
		}

		public static void ApplyCustom()
		{
			CurrentMode = StatusMode.Custom;
			LastApplyTime = Time.realtimeSinceStartup;
			LogDebug("[SteamStatusSpoof] ApplyCustom: DisplayKey='" + CustomDisplayKey + "', PlayerGroup='" + CustomPlayerGroup + "', Players='" + CustomPlayers + "', MaxPlayers='" + CustomMaxPlayers + "'");
			TryTriggerRefresh();
		}

		public static void Restore()
		{
			CurrentMode = StatusMode.Restore;
			LastApplyTime = Time.realtimeSinceStartup;
			TryTriggerRefresh();
		}

		public static void Clear()
		{
			CurrentMode = StatusMode.Clear;
			LastApplyTime = Time.realtimeSinceStartup;
			try
			{
				SteamFriends.ClearRichPresence();
			}
			catch (Exception ex)
			{
				ManualLogSource log = _log;
				if (log != null)
				{
					log.LogWarning((object)("[SteamStatusSpoof] Clear failed: " + ex.Message));
				}
			}
		}

		private static void TryTriggerRefresh()
		{
			try
			{
				RichPresenceService service = GameHandler.GetService<RichPresenceService>();
				if (service != null)
				{
					service.Dirty();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = _log;
				if (log != null)
				{
					log.LogWarning((object)("[SteamStatusSpoof] Refresh failed: " + ex.Message));
				}
			}
		}
	}
}