using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UK_NewTitles")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UK_NewTitles")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4cc07eb4-e098-4fec-ab6a-41ebf471b003")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UK_NewTitles;
[BepInPlugin("com.exmagikguy.ukNewTitles", "New Titles", "1.0.0")]
public class NewTitles : BaseUnityPlugin
{
private Dictionary<int, Sprite> customPNGs = new Dictionary<int, Sprite>();
private readonly string rankPath = Path.Combine(Paths.PluginPath, "UK_NewTitles", "rankPNGs");
private void Start()
{
SendLog("---<===!NEW TITLES LOADED!===>---");
SceneManager.sceneLoaded += OnSceneLoad;
SendLog("---<===!New Titles' Scene loading code initialized!===>---");
}
private void OnSceneLoad(Scene scene, LoadSceneMode mode)
{
SendLog("---<===!New Titles: Loading Customs...!===>---");
LoadCustomRanks();
}
private void LoadCustomRanks()
{
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Expected O, but got Unknown
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
StyleHUD instance = MonoSingleton<StyleHUD>.Instance;
if ((Object)(object)instance == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"New Titles: Could not find style hud controller in the current scene. Returning");
return;
}
if (!Directory.Exists(rankPath))
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("NEW TITLES HAS NOT BEEN ABLE TO FIND THE PATH " + rankPath + ", RETURNING..."));
return;
}
string[] array = new string[8] { "D", "C", "B", "A", "S", "SS", "SSS", "U" };
customPNGs.Clear();
SendLog("New Titles: Clearing leftovers from previous usages of this script...");
if (customPNGs.Count <= 0)
{
SendLog("New Titles: Sucsessful.");
for (int i = 0; i < array.Length; i++)
{
string text = array[i];
string path = Path.Combine(rankPath, text + ".png");
if (File.Exists(path))
{
if (instance.ranks.Count != array.Length)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)$"New Titles: The amount of replaced ranks doesn't match the amount of registered ranks (registered: {instance.ranks.Count}; replaced: {array.Length}), the code will return for now, please, contact the creator, he will analize the situation and he will update the mod, if needed.");
return;
}
SendLog("New Titles: " + text + ".png Found, Loading it in...");
byte[] array2 = File.ReadAllBytes(path);
Texture2D val = new Texture2D(300, 100, (TextureFormat)4, false);
ImageConversion.LoadImage(val, array2);
val.Apply();
Sprite value = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
customPNGs.Add(i, value);
SendLog("New Titles: " + text + ".png: Loading Completed.");
}
}
for (int j = 0; j < instance.ranks.Count; j++)
{
StyleRank val2 = instance.ranks[j];
SendLog($"New Titles: Loading sprite created from PNG for rank no.{j}");
customPNGs.TryGetValue(j, out var value2);
if ((Object)(object)value2 != (Object)null)
{
SendLog("New Titles: Sprite loaded sucssesfully, replacing the original rank sprite with it...");
Sprite sprite = val2.sprite;
val2.sprite = value2;
if ((Object)(object)val2.sprite == (Object)(object)sprite)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"New Titles: Replacement failure, returning");
break;
}
SendLog("New Titles: Sucsses!");
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"New Titles: Loading failure, returning");
}
}
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"New Titles: Failed, returning.");
}
}
private void SendLog(string log)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)log);
}
}