Decompiled source of MusicDisplay v1.0.1

RoR2MusicNotification.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
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.Bootstrap;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("RoR2MusicNotification")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Mod for Risk of Rain 2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+df64a6a9cb48da6a600d059eaa5ea864413406ac")]
[assembly: AssemblyProduct("RoR2MusicNotification")]
[assembly: AssemblyTitle("RoR2MusicNotification")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
}
namespace RoR2MusicNotification
{
	internal class ModConfig
	{
		public static ConfigEntry<int> cfgXHeight;

		public static ConfigEntry<int> cfgYHeight;

		public static ConfigEntry<float> cfgScale;

		public static ConfigEntry<HorizontalAlignmentOptions> cfgTextAlignment;

		public static void Initialize(ConfigFile config)
		{
			cfgXHeight = config.Bind<int>("Display", "Position X", 810, "");
			cfgYHeight = config.Bind<int>("Display", "Position Y", -200, "");
			cfgScale = config.Bind<float>("Display", "Scale Multiplier", 1f, "");
			cfgTextAlignment = config.Bind<HorizontalAlignmentOptions>("Display", "Text Alignment", (HorizontalAlignmentOptions)4, "");
			cfgXHeight.SettingChanged += CfgXHeight_SettingChanged;
			cfgYHeight.SettingChanged += CfgYHeight_SettingChanged;
			cfgScale.SettingChanged += CfgScale_SettingChanged;
			cfgTextAlignment.SettingChanged += CfgTextAlignment_SettingChanged;
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				ModSupport_RiskOfOptions.Initialize();
			}
		}

		private static void CfgTextAlignment_SettingChanged(object sender, EventArgs e)
		{
			Plugin.SetNotifAlignment();
		}

		private static void CfgScale_SettingChanged(object sender, EventArgs e)
		{
			Plugin.SetNotifScale();
		}

		private static void CfgYHeight_SettingChanged(object sender, EventArgs e)
		{
			Plugin.SetNotifPosition();
		}

		private static void CfgXHeight_SettingChanged(object sender, EventArgs e)
		{
			Plugin.SetNotifPosition();
		}
	}
	internal class ModSupport_RiskOfOptions
	{
		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void Initialize()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Adds a persistent music notification.", "com.DestroyedClone.MusicDisplay", "Music Display");
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(ModConfig.cfgXHeight, false));
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(ModConfig.cfgYHeight, false));
			ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ModConfig.cfgScale, false));
			ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)ModConfig.cfgTextAlignment, false));
		}
	}
	[BepInPlugin("com.DestroyedClone.MusicDisplay", "Music Display", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private class FadeOutText : MonoBehaviour
		{
			public float stopwatch = 0f;

			public float fadeDuration = 0f;

			public HGTextMeshProUGUI textMesh;

			public void Update()
			{
				stopwatch += Time.deltaTime;
				if (!(stopwatch > fadeDuration))
				{
				}
			}
		}

		public static MusicController musicController;

		public static GameObject notif;

		public static HGTextMeshProUGUI notifTextMesh;

		public static GameObject ReferenceGameObject;

		public static Dictionary<string, string> trackNames = new Dictionary<string, string>
		{
			{ "muBossfightDLC1_10", "Having Fallen, It Was Blood" },
			{ "muBossfightDLC1_12", "A Boat Made from a Sheet of Newspaper" },
			{ "muEscape", "Escape (Unnamed Track)" },
			{ "muFULLSong02", "Into the Doldrums" },
			{ "muFULLSong06", "Nocturnal Emission" },
			{ "muFULLSong07", "Evapotranspiration" },
			{ "muFULLSong18", "Disdrometer" },
			{ "muFULLSong19", "Terra Pluviam" },
			{ "muGameplayBase_09", "They Might As Well Be Dead" },
			{ "muGameplayDLC1_01", "Once in a Lullaby" },
			{ "muGameplayDLC1_03", "Out of Whose Womb Came the Ice?" },
			{ "muGameplayDLC1_06", "Who Can Fathom the Soundless Depths?" },
			{ "muGameplayDLC1_08", "A Placid Island of Ignorance" },
			{ "muGameplayDLC2_01", "It Can't Rain All the Time" },
			{ "muGameplayDLC2_02", "A Tempestuous Noise of Thunder and Lightning Heard" },
			{ "muIntroCutscene", "Through a Cloud, Darkly" },
			{ "muLogbook", "The Dehydration of Risk of Rain 2" },
			{ "muMainEndingFull", "Lacrimosum" },
			{ "muMainEndingOutroA", "Lacrimosum" },
			{ "muMainEndingOutroB", "Lacrimosum" },
			{ "muMenu", "Risk of Rain 2" },
			{ "muMenuDLC1", "Prelude in D flat major" },
			{ "muNone", "" },
			{ "muRaidfightDLC1_07", "The Face of the Deep" },
			{ "muSong04", "Parjanya" },
			{ "muSong05", "Thermodynamic Equilibrium" },
			{ "muSong08", "A Glacier Eventually Farts (And Don't You Listen to the Song of Life)" },
			{ "muSong13", "The Raindrop that Fell to the Sky" },
			{ "muSong14", "The Rain Formerly Known as Purple" },
			{ "muSong16", "Hydrophobia" },
			{ "muSong21", "Petrichor V" },
			{ "muSong22", "Köppen As Fuck" },
			{ "muSong23", "Antarctic Oscillation" },
			{ "muSong24", "...con lentitud poderosa" },
			{ "muSong25", "You're Gonna Need A Bigger Ukulele" }
		};

		public void Awake()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			ModConfig.Initialize(((BaseUnityPlugin)this).Config);
			MusicTrackDef.Play += new hook_Play(MusicTrackDef_Play);
			ReferenceGameObject = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/HGCreditNameLabel.prefab").WaitForCompletion();
		}

		private void MusicTrackDef_Play(orig_Play orig, MusicTrackDef self)
		{
			orig.Invoke(self);
			if (!Object.op_Implicit((Object)(object)notif))
			{
				Canvas userCanvas = AchievementNotificationPanel.GetUserCanvas(LocalUserManager.GetFirstLocalUser());
				if (!Object.op_Implicit((Object)(object)userCanvas))
				{
					return;
				}
				notif = Object.Instantiate<GameObject>(ReferenceGameObject);
				notif.transform.parent = ((Component)userCanvas).transform;
				((Object)notif).name = "MusicNameDisplay";
			}
			notifTextMesh = notif.GetComponent<HGTextMeshProUGUI>();
			((TMP_Text)notifTextMesh).text = GetTrackInfo(self.cachedName);
			SetNotifAlignment();
			SetNotifPosition();
			SetNotifScale();
		}

		public static void SetNotifAlignment()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)notifTextMesh))
			{
				((TMP_Text)notifTextMesh).horizontalAlignment = ModConfig.cfgTextAlignment.Value;
			}
		}

		public static void SetNotifPosition()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)notif))
			{
				notif.transform.localPosition = new Vector3((float)ModConfig.cfgXHeight.Value, (float)ModConfig.cfgYHeight.Value);
			}
		}

		public static void SetNotifScale()
		{
			//IL_001e: 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)
			if (Object.op_Implicit((Object)(object)notif))
			{
				notif.transform.localScale = Vector3.one * ModConfig.cfgScale.Value;
			}
		}

		public static string GetTrackInfo(string trackDefName)
		{
			if (trackNames.TryGetValue(trackDefName, out var value))
			{
				if (value == "muNone")
				{
					return string.Empty;
				}
				return value + "\nChris Christodoulou";
			}
			return trackDefName;
		}
	}
}