using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FishNet.Object;
using HarmonyLib;
using J_axonText.Data;
using Microsoft.CodeAnalysis;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("J_axonText")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("1.3.0.0")]
[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 J_axonText
{
internal static class MainMenuViewSync
{
private sealed class OriginalProfile
{
internal string Name;
internal string Rank;
internal Color NameColor;
internal Color RankColor;
internal bool NameRichText;
internal bool RankRichText;
internal bool Modified;
}
private static readonly Dictionary<PlayerProfileSetter, OriginalProfile> profiles = new Dictionary<PlayerProfileSetter, OriginalProfile>();
private static float nextCheck;
internal static void Tick()
{
if (!(Time.unscaledTime < nextCheck))
{
nextCheck = Time.unscaledTime + 1f;
ApplyAll();
}
}
internal static void ApplyAll()
{
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
List<PlayerProfileSetter> list = new List<PlayerProfileSetter>();
foreach (KeyValuePair<PlayerProfileSetter, OriginalProfile> profile in profiles)
{
if ((Object)(object)profile.Key == (Object)null)
{
list.Add(profile.Key);
}
}
foreach (PlayerProfileSetter item in list)
{
profiles.Remove(item);
}
PlayerProfileSetter[] array = Object.FindObjectsByType<PlayerProfileSetter>((FindObjectsSortMode)0);
foreach (PlayerProfileSetter val in array)
{
if (!((Object)(object)val == (Object)null) && !((Object)(object)val.nametext == (Object)null) && !((Object)(object)val.lvlandrank == (Object)null) && !string.IsNullOrEmpty(((TMP_Text)val.nametext).text) && !string.IsNullOrEmpty(((TMP_Text)val.lvlandrank).text))
{
if (!profiles.TryGetValue(val, out var value))
{
value = new OriginalProfile
{
Name = ((TMP_Text)val.nametext).text,
Rank = ((TMP_Text)val.lvlandrank).text,
NameColor = ((Graphic)val.nametext).color,
RankColor = ((Graphic)val.lvlandrank).color,
NameRichText = ((TMP_Text)val.nametext).richText,
RankRichText = ((TMP_Text)val.lvlandrank).richText
};
profiles.Add(val, value);
}
if (ConfigManager.ChangeMainMenuView)
{
Apply(val, value);
}
else if (value.Modified)
{
Restore(val, value);
}
}
}
}
private static void Apply(PlayerProfileSetter profile, OriginalProfile original)
{
//IL_0026: 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_0068: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI nametext = profile.nametext;
string nameStyle = ConfigManager.NameStyle;
Color color = default(Color);
if (nameStyle == "R")
{
Set(nametext, ConfigManager.Rainbow(original.Name), Color.white, richText: true);
}
else if (nameStyle.Length == 7 && nameStyle[0] == 'C' && ColorUtility.TryParseHtmlString("#" + nameStyle.Substring(1), ref color))
{
Set(nametext, original.Name, color, original.NameRichText);
}
else
{
Set(nametext, original.Name, original.NameColor, original.NameRichText);
}
string value = ConfigManager.RankForDisplay();
bool flag = ConfigManager.RankRainbow || ConfigManager.RankColor != "A2A19A";
Set(profile.lvlandrank, value, flag ? Color.white : original.RankColor, flag || original.RankRichText);
original.Modified = true;
}
private static void Restore(PlayerProfileSetter profile, OriginalProfile original)
{
//IL_000d: 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)
Set(profile.nametext, original.Name, original.NameColor, original.NameRichText);
Set(profile.lvlandrank, original.Rank, original.RankColor, original.RankRichText);
original.Modified = false;
}
private static void Set(TextMeshProUGUI label, string value, Color color, bool richText)
{
//IL_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references)
if (((TMP_Text)label).richText != richText)
{
((TMP_Text)label).richText = richText;
}
if (((Graphic)label).color != color)
{
((Graphic)label).color = color;
}
if (((TMP_Text)label).text != value)
{
((TMP_Text)label).text = value;
}
}
}
internal static class NameColorSync
{
private sealed class PlayerInfo
{
internal string Name;
internal string SteamId;
internal string WireStyle;
internal bool MemberSynchronized;
internal string AppliedStyle;
}
private const string MemberDataKey = "J_axonText.NameStyle";
private static readonly Dictionary<PlayerMovement, PlayerInfo> players = new Dictionary<PlayerMovement, PlayerInfo>();
private static readonly FieldInfo steamIdField = AccessTools.Field(typeof(PlayerMovement), "playersteamid");
private static ulong publishedLobby;
private static string publishedStyle;
private static float nextPublishRefresh;
private static float nextCheck;
internal static void Register(PlayerMovement player, string name, string steamId, string wireStyle)
{
if (!((Object)(object)player == (Object)null) && !((Object)(object)player.playerNameText == (Object)null))
{
players[player] = new PlayerInfo
{
Name = (name ?? ""),
SteamId = (steamId ?? ""),
WireStyle = wireStyle
};
Plugin.Log.LogInfo((object)("Name label registered for " + (((NetworkBehaviour)player).IsOwner ? "local" : "remote") + " player; rank style data " + ((wireStyle == null) ? "absent" : "present") + "."));
Apply(player, players[player], force: true);
}
}
internal static void Tick()
{
if (Time.unscaledTime < nextCheck || !SteamAPI.IsSteamRunning())
{
return;
}
nextCheck = Time.unscaledTime + 1f;
Publish();
DiscoverPlayers();
List<PlayerMovement> list = new List<PlayerMovement>();
foreach (KeyValuePair<PlayerMovement, PlayerInfo> player in players)
{
if ((Object)(object)player.Key == (Object)null)
{
list.Add(player.Key);
}
else
{
Apply(player.Key, player.Value, force: false);
}
}
foreach (PlayerMovement item in list)
{
players.Remove(item);
}
}
internal static void ApplyAll()
{
foreach (KeyValuePair<PlayerMovement, PlayerInfo> player in players)
{
if ((Object)(object)player.Key != (Object)null)
{
Apply(player.Key, player.Value, force: true);
}
}
}
internal static void Reapply(PlayerMovement player)
{
if ((Object)(object)player != (Object)null && players.TryGetValue(player, out var value))
{
Apply(player, value, force: true);
}
}
internal static void Publish()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (!SteamAPI.IsSteamRunning() || (Object)(object)BootstrapManager.instance == (Object)null)
{
return;
}
ulong currentLobbyID = BootstrapManager.instance.CurrentLobbyID;
if (currentLobbyID == 0L)
{
publishedLobby = 0uL;
publishedStyle = null;
nextPublishRefresh = 0f;
return;
}
string nameStyle = ConfigManager.NameStyle;
if (publishedLobby != currentLobbyID || !(publishedStyle == nameStyle) || !(Time.unscaledTime < nextPublishRefresh))
{
SteamMatchmaking.SetLobbyMemberData(new CSteamID(currentLobbyID), "J_axonText.NameStyle", nameStyle);
if (publishedLobby != currentLobbyID || publishedStyle != nameStyle)
{
Plugin.Log.LogInfo((object)"Name color preference published to Steam lobby.");
}
publishedLobby = currentLobbyID;
publishedStyle = nameStyle;
nextPublishRefresh = Time.unscaledTime + 10f;
}
}
private static void DiscoverPlayers()
{
PlayerMovement[] array = Object.FindObjectsByType<PlayerMovement>((FindObjectsSortMode)0);
foreach (PlayerMovement val in array)
{
if (!((Object)(object)val == (Object)null) && !players.ContainsKey(val) && !((Object)(object)val.playerNameText == (Object)null) && !string.IsNullOrEmpty(val.playername) && !string.IsNullOrEmpty(val.playerNameText.text))
{
string rankText = (((Object)(object)val.lvlandrank != (Object)null) ? val.lvlandrank.text : null);
string text = ConfigManager.TakeNameStyleHeader(ref rankText);
if (text != null && (Object)(object)val.lvlandrank != (Object)null)
{
val.lvlandrank.text = rankText;
}
string steamId = ((steamIdField != null) ? (steamIdField.GetValue(val) as string) : null);
Register(val, val.playername, steamId, text);
}
}
}
private static void Apply(PlayerMovement player, PlayerInfo info, bool force)
{
//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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: 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_00a2: 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_012e: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)player.playerNameText == (Object)null)
{
return;
}
string style = GetStyle(player, info);
if (style == null)
{
return;
}
string text = ((info.Name.Length > 10) ? info.Name.Substring(0, 10) : info.Name);
string text2 = ((style == "R") ? ConfigManager.Rainbow(text) : text);
Color val = DefaultNameColor(player);
Color val2 = default(Color);
if (style == "R")
{
val = Color.white;
}
else if (style.Length == 7 && style[0] == 'C' && ColorUtility.TryParseHtmlString("#" + style.Substring(1), ref val2))
{
val = val2;
}
if (force || !(style == info.AppliedStyle) || !player.playerNameText.supportRichText || !(player.playerNameText.text == text2) || !(((Graphic)player.playerNameText).color == val))
{
player.playerNameText.supportRichText = true;
if (player.playerNameText.text != text2)
{
player.playerNameText.text = text2;
}
if (((Graphic)player.playerNameText).color != val)
{
((Graphic)player.playerNameText).color = val;
}
if (info.AppliedStyle != style)
{
Plugin.Log.LogInfo((object)("Applied name color to " + (((NetworkBehaviour)player).IsOwner ? "local" : "remote") + " name label: " + style));
}
info.AppliedStyle = style;
}
}
private static string GetStyle(PlayerMovement player, PlayerInfo info)
{
//IL_0048: 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)
if (((NetworkBehaviour)player).IsOwner)
{
return ConfigManager.NameStyle;
}
string text = null;
if ((Object)(object)BootstrapManager.instance != (Object)null && BootstrapManager.instance.CurrentLobbyID != 0L && ulong.TryParse(info.SteamId, out var result))
{
string lobbyMemberData = SteamMatchmaking.GetLobbyMemberData(new CSteamID(BootstrapManager.instance.CurrentLobbyID), new CSteamID(result), "J_axonText.NameStyle");
if (lobbyMemberData == "D" || lobbyMemberData == "R")
{
text = lobbyMemberData;
}
Color val = default(Color);
if (!string.IsNullOrEmpty(lobbyMemberData) && lobbyMemberData.Length == 7 && lobbyMemberData[0] == 'C' && ColorUtility.TryParseHtmlString("#" + lobbyMemberData.Substring(1), ref val))
{
text = lobbyMemberData;
}
}
if (info.WireStyle == null)
{
return text;
}
if (!info.MemberSynchronized)
{
if (text == info.WireStyle)
{
info.MemberSynchronized = true;
}
return info.WireStyle;
}
return text ?? info.WireStyle;
}
private static Color DefaultNameColor(PlayerMovement player)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
BootstrapManager instance = BootstrapManager.instance;
if ((Object)(object)instance == (Object)null)
{
return player.defaultnamecolor;
}
if ((!instance.isSorcerer || player.playerTeam == 0) && (instance.isSorcerer || player.playerTeam != 0))
{
return player.defaultnamecolor;
}
return player.RedName;
}
}
[BepInPlugin("J_axonText", "MA-CustomColors", "1.3.0")]
public sealed class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private Harmony harmony;
private TextFXUI ui;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"MA-CustomColors 1.3.0 loaded. Name colors are rendered on clients running this mod.");
ConfigManager.Init(((BaseUnityPlugin)this).Config);
ui = new TextFXUI();
((MonoBehaviour)this).StartCoroutine(Initialize());
}
private IEnumerator Initialize()
{
while (!SteamAPI.IsSteamRunning())
{
yield return null;
}
harmony = new Harmony("J_axonText");
harmony.PatchAll(typeof(Plugin).Assembly);
Log.LogInfo((object)"MA-CustomColors 1.3.0 patched current Mage Arena text paths.");
}
private void Update()
{
if (ui != null)
{
ui.Update();
}
try
{
NameColorSync.Tick();
}
catch (Exception ex)
{
Log.LogError((object)("Name color sync failed: " + ex));
}
try
{
MainMenuViewSync.Tick();
}
catch (Exception ex2)
{
Log.LogError((object)("Main menu view update failed: " + ex2));
}
}
private void OnGUI()
{
if (ui != null)
{
ui.OnGUI();
}
}
private void OnDestroy()
{
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
[HarmonyPatch(typeof(PlayerMovement), "ServerSetupPlayer")]
internal static class PlayerRankPatch
{
private static void Prefix(PlayerMovement __instance, ref string levelandranktex)
{
try
{
if (((NetworkBehaviour)__instance).IsOwner)
{
levelandranktex = ConfigManager.RankToSend();
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Rank send failed: " + ex));
}
}
}
[HarmonyPatch(typeof(PlayerMovement), "RpcLogic___ObsSetupPlayer_776344189")]
internal static class PlayerNamePatch
{
private static void Prefix(ref string levelandrank, out string __state)
{
__state = ConfigManager.TakeNameStyleHeader(ref levelandrank);
}
private static void Postfix(PlayerMovement __instance, string namee, string steamid, string __state)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)__instance.lvlandrank != (Object)null)
{
string text = __instance.lvlandrank.text;
if (text != null && text.IndexOf("<color=", StringComparison.OrdinalIgnoreCase) >= 0)
{
__instance.lvlandrank.supportRichText = true;
((Graphic)__instance.lvlandrank).color = Color.white;
}
}
NameColorSync.Register(__instance, namee, steamid, __state);
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Name color setup failed: " + ex));
}
}
}
[HarmonyPatch(typeof(PlayerMovement), "SwapTeam")]
internal static class PlayerTeamPatch
{
private static void Postfix(PlayerMovement __instance)
{
try
{
NameColorSync.Reapply(__instance);
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Name color team update failed: " + ex));
}
}
}
[HarmonyPatch(typeof(BootstrapManager), "OnLobbyCreated")]
internal static class LobbyCreatedPatch
{
private static void Postfix(LobbyCreated_t callback)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
try
{
if ((int)callback.m_eResult == 1)
{
ConfigManager.UpdateHostedLobbyName();
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Lobby name update failed: " + ex));
}
}
}
internal sealed class TextFXUI
{
private bool visible;
private Rect window = new Rect(80f, 80f, 470f, 390f);
private string rank;
private string rankColor;
private string nameColor;
private string lobbyColor;
private string error = "";
private bool rankRainbow;
private bool nameRainbow;
private bool lobbyRainbow;
private bool mainMenuView;
internal TextFXUI()
{
//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)
Reload();
}
private void Reload()
{
rank = ConfigManager.Rank;
rankColor = ConfigManager.RankColor;
nameColor = ConfigManager.NameColor;
lobbyColor = ConfigManager.LobbyColor;
rankRainbow = ConfigManager.RankRainbow;
nameRainbow = ConfigManager.NameRainbow;
lobbyRainbow = ConfigManager.LobbyRainbow;
mainMenuView = ConfigManager.ChangeMainMenuView;
}
internal void Update()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(ConfigManager.Key))
{
visible = !visible;
}
if (visible && Input.GetKeyDown((KeyCode)27))
{
visible = false;
}
}
internal void OnGUI()
{
//IL_000f: 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_002f: 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)
if (visible)
{
window = GUILayout.Window(17041, window, new WindowFunction(Draw), "MA-CustomColors", Array.Empty<GUILayoutOption>());
}
}
private void Draw(int id)
{
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
GUILayout.Label("Custom rank (DefaultRank uses your Steam rank)", Array.Empty<GUILayoutOption>());
rank = GUILayout.TextField(rank, 160, Array.Empty<GUILayoutOption>());
ColorRow("Change rank color", ref rankColor, ref rankRainbow);
ColorRow("Change name color", ref nameColor, ref nameRainbow);
DrawNamePreview();
ColorRow("Hosted lobby name", ref lobbyColor, ref lobbyRainbow);
mainMenuView = GUILayout.Toggle(mainMenuView, "Change main menu view", Array.Empty<GUILayoutOption>());
GUILayout.Label("Use your custom name and rank styling on the main menu profile.", Array.Empty<GUILayoutOption>());
GUILayout.Label("Viewers need J_axonText installed to see name colors.", Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
if (GUILayout.Button("Apply", Array.Empty<GUILayoutOption>()))
{
try
{
ConfigManager.Apply(rank, rankColor, nameColor, lobbyColor, rankRainbow, nameRainbow, lobbyRainbow, mainMenuView);
error = "Saved. Rank changes appear when you next join a game.";
}
catch (Exception ex)
{
error = ex.Message;
Plugin.Log.LogError((object)("Apply failed: " + ex));
}
}
if (GUILayout.Button("Reset", Array.Empty<GUILayoutOption>()))
{
ConfigManager.Reset();
Reload();
error = "Defaults restored.";
}
GUILayout.EndHorizontal();
GUILayout.Label(error, Array.Empty<GUILayoutOption>());
GUI.DragWindow(new Rect(0f, 0f, 10000f, 22f));
}
private static void ColorRow(string label, ref string hex, ref bool rainbow)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(175f) });
hex = GUILayout.TextField(hex, 8, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(95f) });
rainbow = GUILayout.Toggle(rainbow, "Rainbow", Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
}
private void DrawNamePreview()
{
//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)
//IL_0017: Expected O, but got Unknown
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
GUIStyle val = new GUIStyle(GUI.skin.label)
{
richText = true
};
string text = "Name preview";
Color val2 = default(Color);
if (nameRainbow)
{
text = ConfigManager.Rainbow(text);
}
else if (ColorUtility.TryParseHtmlString("#" + nameColor.TrimStart('#'), ref val2))
{
text = "<color=#" + ColorUtility.ToHtmlStringRGB(val2) + ">" + text + "</color>";
}
GUILayout.Label(text, val, Array.Empty<GUILayoutOption>());
}
}
}
namespace J_axonText.Data
{
internal static class ConfigManager
{
internal const string DefaultColor = "A2A19A";
private static ConfigEntry<KeyCode> key;
private static ConfigEntry<string> rank;
private static ConfigEntry<string> rankColor;
private static ConfigEntry<string> nameColor;
private static ConfigEntry<string> lobbyColor;
private static ConfigEntry<bool> rankRainbow;
private static ConfigEntry<bool> nameRainbow;
private static ConfigEntry<bool> lobbyRainbow;
private static ConfigEntry<bool> mainMenuView;
internal static KeyCode Key => key.Value;
internal static string Rank => rank.Value;
internal static string RankColor => rankColor.Value;
internal static string NameColor => nameColor.Value;
internal static string LobbyColor => lobbyColor.Value;
internal static bool RankRainbow => rankRainbow.Value;
internal static bool NameRainbow => nameRainbow.Value;
internal static bool LobbyRainbow => lobbyRainbow.Value;
internal static bool ChangeMainMenuView => mainMenuView.Value;
internal static string NameStyle
{
get
{
if (!NameRainbow)
{
return "C" + NameColor;
}
return "R";
}
}
internal static void Init(ConfigFile config)
{
key = config.Bind<KeyCode>("J_axonText", "UIToggleKey", (KeyCode)282, "Key to toggle the J_axonText UI");
rank = config.Bind<string>("J_axonText", "CustomRank", "DefaultRank", "Custom rank; DefaultRank uses your current Steam level and rank");
rankColor = config.Bind<string>("J_axonText", "RankColor", "A2A19A", "Color of the rank text");
nameColor = config.Bind<string>("J_axonText", "NameColor", "A2A19A", "Color of the actual player name on modded clients");
lobbyColor = config.Bind<string>("J_axonText", "LobbyNameColor", "A2A19A", "Hosted lobby name color");
rankRainbow = config.Bind<bool>("J_axonText", "IsRankColorRainbow", false, "Rainbow rank text");
nameRainbow = config.Bind<bool>("J_axonText", "IsNameColorRainbow", false, "Rainbow actual player name on modded clients");
lobbyRainbow = config.Bind<bool>("J_axonText", "IsLobbyNameColorRainbow", false, "Rainbow hosted lobby name");
mainMenuView = config.Bind<bool>("J_axonText", "ChangeMainMenuView", false, "Show custom name and rank styling on the main menu profile");
}
internal static void Apply(string newRank, string newRankColor, string newNameColor, string newLobbyColor, bool newRankRainbow, bool newNameRainbow, bool newLobbyRainbow, bool newMainMenuView)
{
string value = NormalizeColor(newRankColor);
string value2 = NormalizeColor(newNameColor);
string value3 = NormalizeColor(newLobbyColor);
string text = (newRank ?? "").Trim();
if (text.Length > 160)
{
throw new ArgumentException("Rank must be 160 characters or less.");
}
rank.Value = ((text.Length == 0) ? "DefaultRank" : text);
rankColor.Value = value;
nameColor.Value = value2;
lobbyColor.Value = value3;
rankRainbow.Value = newRankRainbow;
nameRainbow.Value = newNameRainbow;
lobbyRainbow.Value = newLobbyRainbow;
mainMenuView.Value = newMainMenuView;
UpdateHostedLobbyName();
NameColorSync.Publish();
NameColorSync.ApplyAll();
MainMenuViewSync.ApplyAll();
}
internal static void Reset()
{
rank.Value = "DefaultRank";
ConfigEntry<string> obj = rankColor;
ConfigEntry<string> obj2 = nameColor;
string text = (lobbyColor.Value = "A2A19A");
string value = (obj2.Value = text);
obj.Value = value;
ConfigEntry<bool> obj3 = rankRainbow;
ConfigEntry<bool> obj4 = nameRainbow;
bool flag = (lobbyRainbow.Value = false);
bool value2 = (obj4.Value = flag);
obj3.Value = value2;
mainMenuView.Value = false;
UpdateHostedLobbyName();
NameColorSync.Publish();
NameColorSync.ApplyAll();
MainMenuViewSync.ApplyAll();
}
private static string NormalizeColor(string value)
{
string text = (value ?? "").Trim().TrimStart('#').ToUpperInvariant();
if (!Regex.IsMatch(text, "^[0-9A-F]{6}$"))
{
throw new ArgumentException("Colors must have six hex digits (RRGGBB).");
}
return text;
}
internal static string RankToSend()
{
return NameStyleHeader() + RankForDisplay();
}
internal static string RankForDisplay()
{
string text = ((Rank == "DefaultRank") ? DefaultRank() : Rank);
text = Regex.Replace(text.Replace("_", " "), "</?color(?:=[^>]*)?>", "", RegexOptions.IgnoreCase);
if (!RankRainbow)
{
if (!(RankColor == "A2A19A"))
{
return "<color=#" + RankColor + ">" + text + "</color>";
}
return text;
}
return RainbowVisibleText(text);
}
private static string NameStyleHeader()
{
string nameStyle = NameStyle;
string text = ((nameStyle[0] == 'C') ? nameStyle.Substring(1) : "000000");
char c = ((nameStyle[0] == 'R') ? '2' : ((nameStyle[0] == 'C') ? '1' : '0'));
return "<color=#4A6178></color><color=#" + text + "></color><color=#00000" + c + "></color>";
}
internal static string TakeNameStyleHeader(ref string rankText)
{
if (rankText == null)
{
return null;
}
Match match = Regex.Match(rankText, "^<color=#4A6178></color><color=#([0-9A-F]{6})></color><color=#00000([012])></color>", RegexOptions.IgnoreCase);
if (!match.Success)
{
return null;
}
rankText = rankText.Substring(match.Length);
return match.Groups[2].Value[0] switch
{
'1' => "C" + match.Groups[1].Value.ToUpperInvariant(),
'2' => "R",
_ => "D",
};
}
private static string DefaultRank()
{
int num = default(int);
if (!SteamUserStats.GetStat("level", ref num))
{
num = 0;
}
int num2 = default(int);
if (!SteamUserStats.GetStat("rank", ref num2))
{
num2 = 0;
}
string[] array = new string[10] { "Lackey", "Sputterer", "Novice", "Apprentice", "Savant", "Master", "Grand Master", "Archmagus", "Magus Prime", "Supreme Archmagus" };
return "lvl " + num + " " + array[Mathf.Clamp(num2, 0, array.Length - 1)];
}
internal static string Rainbow(string value)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(value))
{
return value ?? "";
}
StringBuilder stringBuilder = new StringBuilder(value.Length * 30);
for (int i = 0; i < value.Length; i++)
{
string value2 = ColorUtility.ToHtmlStringRGB(Color.HSVToRGB((float)i / (float)value.Length, 1f, 1f));
stringBuilder.Append("<color=#").Append(value2).Append('>')
.Append(value[i])
.Append("</color>");
}
return stringBuilder.ToString();
}
private static string RainbowVisibleText(string value)
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
int length = Regex.Replace(value, "<[^>]*>", "").Length;
if (length == 0)
{
return value;
}
StringBuilder stringBuilder = new StringBuilder(value.Length * 25);
int num = 0;
for (int i = 0; i < value.Length; i++)
{
if (value[i] == '<')
{
int num2 = value.IndexOf('>', i);
if (num2 >= 0)
{
stringBuilder.Append(value, i, num2 - i + 1);
i = num2;
continue;
}
}
string value2 = ColorUtility.ToHtmlStringRGB(Color.HSVToRGB((float)num++ / (float)length, 1f, 1f));
stringBuilder.Append("<color=#").Append(value2).Append('>')
.Append(value[i])
.Append("</color>");
}
return stringBuilder.ToString();
}
internal static void UpdateHostedLobbyName()
{
//IL_0025: 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_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
BootstrapManager instance = BootstrapManager.instance;
if ((Object)(object)instance == (Object)null || instance.CurrentLobbyID == 0L)
{
return;
}
CSteamID val = default(CSteamID);
((CSteamID)(ref val))..ctor(instance.CurrentLobbyID);
if (!(SteamMatchmaking.GetLobbyOwner(val) != SteamUser.GetSteamID()))
{
string lobbyData = SteamMatchmaking.GetLobbyData(val, "name");
if (!string.IsNullOrEmpty(lobbyData))
{
string text = Regex.Replace(lobbyData, "</?color(?:=[^>]*)?>", "", RegexOptions.IgnoreCase);
string text2 = (LobbyRainbow ? Rainbow(text) : ((LobbyColor == "A2A19A") ? text : ("<color=#" + LobbyColor + ">" + text + "</color>")));
SteamMatchmaking.SetLobbyData(val, "name", text2);
}
}
}
}
}