using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LLBML.Utils;
using LLHandlers;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("TourneyInfo")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+236593781eaaf5c3915b18ad54fd9f4c92fd3716")]
[assembly: AssemblyProduct("TourneyInfo")]
[assembly: AssemblyTitle("TourneyInfo")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 TourneyInfo
{
public class Configs
{
private static ConfigFile config;
internal static ConfigEntry<string> TourneyName { get; private set; }
internal static ConfigEntry<string> TourneyDescriptionLine1 { get; private set; }
internal static ConfigEntry<string> TourneyDescriptionLine2 { get; private set; }
internal static ConfigEntry<bool> UseCustomLogo { get; private set; }
internal static void Init()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
config = ((BaseUnityPlugin)Plugin.Instance).Config;
config.Bind<string>("Headers", "mm_header_tourney", "Tourney Info", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_header" }));
TourneyName = config.Bind<string>("Tourney Info", "TourneyName", "LAN Tourney", (ConfigDescription)null);
TourneyDescriptionLine1 = config.Bind<string>("Tourney Info", "TourneyDescriptionLine1", "LLB Stadium", (ConfigDescription)null);
TourneyDescriptionLine2 = config.Bind<string>("Tourney Info", "TourneyDescriptionLine2", "discord.gg/llbstadium", (ConfigDescription)null);
UseCustomLogo = config.Bind<bool>("Tourney Info", "UseCustomLogo", true, (ConfigDescription)null);
ModDependenciesUtils.RegisterToModMenu(((BaseUnityPlugin)Plugin.Instance).Info, new List<string>(2) { "Allows you to display a custom description, name, and logo for your tournament", "The logo file must be a png or jpg image, and should be placed in the TourneyInfo Modding Folder" });
}
}
internal static class HarmonyPatches
{
private static class PlayerInfoPatch
{
[HarmonyPatch(typeof(ScreenMenu), "OnOpen")]
[HarmonyPostfix]
private static void OnOpen_Postfix(ScreenMenu __instance)
{
((BaseUnityPlugin)Plugin.Instance).Config.SettingChanged += delegate
{
LogoIO.UpdateLogoCustom();
__instance.UpdatePlayerInfo();
};
__instance.lbLevel.enableWordWrapping = false;
}
[HarmonyPatch(typeof(ScreenMenu), "UpdatePlayerInfo")]
[HarmonyPostfix]
private static void UpdatePlayerInfo_Postfix(ScreenMenu __instance)
{
//IL_0088: 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_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
__instance.btAccount.SetText(Configs.TourneyName.Value, -1, true);
TextHandler.SetText(__instance.lbLevel, Configs.TourneyDescriptionLine1.Value + "\n" + Configs.TourneyDescriptionLine2.Value);
if ((Object)(object)LogoIO.LogoCustom != (Object)null && Configs.UseCustomLogo.Value)
{
__instance.imAvatar.texture = (Texture)(object)LogoIO.LogoCustom;
((Transform)((Graphic)__instance.imAvatar).rectTransform).localScale = Vector2.op_Implicit(new Vector2(1f, -1f));
}
else if ((Object)(object)LogoIO.LogoDefault != (Object)null)
{
__instance.imAvatar.texture = (Texture)(object)LogoIO.LogoDefault;
((Transform)((Graphic)__instance.imAvatar).rectTransform).localScale = Vector2.op_Implicit(new Vector2(1f, -1f));
}
else
{
__instance.imAvatar.texture = (Texture)(object)JPLELOFJOOH.BNFIDCAPPDK("avatarImageDefault").texture;
((Transform)((Graphic)__instance.imAvatar).rectTransform).localScale = Vector2.op_Implicit(new Vector2(1f, 1f));
}
}
}
internal static void PatchAll()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("avgduck.plugins.llb.tourneyinfo");
val.PatchAll(typeof(PlayerInfoPatch));
Plugin.LogGlobal.LogInfo((object)"Player info patches applied");
}
}
internal static class LogoIO
{
private static DirectoryInfo LogoDirectoryDefault;
private static DirectoryInfo LogoDirectoryCustom;
internal static Texture2D LogoDefault { get; private set; }
internal static Texture2D LogoCustom { get; private set; }
internal static void Init()
{
string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location), "assets");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
LogoDirectoryDefault = new DirectoryInfo(path);
DirectoryInfo modSubFolder = ModdingFolder.GetModSubFolder(((BaseUnityPlugin)Plugin.Instance).Info);
string fullName = modSubFolder.FullName;
if (!Directory.Exists(fullName))
{
Directory.CreateDirectory(fullName);
}
LogoDirectoryCustom = new DirectoryInfo(fullName);
UpdateLogoDefault();
UpdateLogoCustom();
}
private static void CopyStream(Stream input, Stream output)
{
byte[] array = new byte[8192];
int count;
while ((count = input.Read(array, 0, array.Length)) > 0)
{
output.Write(array, 0, count);
}
}
private static Texture2D LoadImageFile(FileInfo file)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
using FileStream input = file.OpenRead();
using MemoryStream memoryStream = new MemoryStream();
CopyStream(input, memoryStream);
Texture2D val = new Texture2D(1, 1);
ImageConversion.LoadImage(val, memoryStream.ToArray());
return val;
}
private static void UpdateLogoDefault()
{
IOrderedEnumerable<FileInfo> source = from f in LogoDirectoryDefault.GetFiles()
orderby f.Name
select f;
if (!source.Any())
{
LogoDefault = null;
return;
}
FileInfo file = source.First();
Texture2D logoDefault = LoadImageFile(file);
LogoDefault = logoDefault;
}
internal static void UpdateLogoCustom()
{
IOrderedEnumerable<FileInfo> source = from f in LogoDirectoryCustom.GetFiles()
orderby f.Name
select f;
if (!source.Any())
{
LogoCustom = null;
return;
}
FileInfo file = source.First();
Texture2D logoCustom = LoadImageFile(file);
LogoCustom = logoCustom;
}
}
[BepInPlugin("avgduck.plugins.llb.tourneyinfo", "TourneyInfo", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "avgduck.plugins.llb.tourneyinfo";
public static Plugin Instance { get; private set; }
internal static ManualLogSource LogGlobal { get; private set; }
private void Awake()
{
Instance = this;
LogGlobal = ((BaseUnityPlugin)this).Logger;
Configs.Init();
HarmonyPatches.PatchAll();
LogoIO.Init();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "TourneyInfo";
public const string PLUGIN_NAME = "TourneyInfo";
public const string PLUGIN_VERSION = "1.0.1";
}
}