Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TimeAndDayDisplay v1.2.0
Time&DayDisplay.dll
Decompiled 2 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.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 TimeAndDayDisplay { [BepInPlugin("TimeAndDayDisplay", "Time&DayDisplay", "1.2.0")] public class TimeDisplayPlugin : BaseUnityPlugin { private ConfigEntry<bool> use24HourTime; private ConfigEntry<float> horizontalPosition; private ConfigEntry<float> verticalPosition; private ConfigEntry<int> fontSize; private ConfigEntry<bool> showDay; private ConfigEntry<bool> outlineEnabled; private ConfigEntry<int> outlineSize; private ConfigEntry<bool> hideWhenMenusOpen; private ConfigEntry<float> menuHorizontalPosition; private ConfigEntry<float> menuVerticalPosition; private GUIStyle style; private Font valheimFont; private float nextFontLookupTime; private bool loggedFontFound; private void Awake() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown use24HourTime = ((BaseUnityPlugin)this).Config.Bind<bool>("Time", "Use24HourTime", false, "false = 12-hour time with AM/PM; true = 24-hour time."); horizontalPosition = ((BaseUnityPlugin)this).Config.Bind<float>("Location", "HorizontalPosition", 1f, new ConfigDescription("Horizontal screen position. 0 = far left, 1 = far right.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); verticalPosition = ((BaseUnityPlugin)this).Config.Bind<float>("Location", "VerticalPosition", 0.01f, new ConfigDescription("Vertical screen position. 0 = top, 1 = bottom.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); fontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Appearance", "FontSize", 22, new ConfigDescription("Clock font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 72), Array.Empty<object>())); showDay = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "ShowDay", true, "Show the current Valheim day."); outlineEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "OutlineEnabled", true, "Enable or disable the black text outline."); outlineSize = ((BaseUnityPlugin)this).Config.Bind<int>("Appearance", "OutlineSize", 2, new ConfigDescription("Black outline size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>())); hideWhenMenusOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("Behavior", "HideWhenMenusOpen", true, "Hide the clock while inventory, menu, or the large map is open."); menuHorizontalPosition = ((BaseUnityPlugin)this).Config.Bind<float>("Menu Location", "HorizontalPosition", 1f, new ConfigDescription("Horizontal screen position while a menu is open. 0 = far left, 1 = far right.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); menuVerticalPosition = ((BaseUnityPlugin)this).Config.Bind<float>("Menu Location", "VerticalPosition", 0.01f, new ConfigDescription("Vertical screen position while a menu is open. 0 = top, 1 = bottom.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); } private void OnGUI() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)EnvMan.instance == (Object)null) { return; } bool flag = InventoryGui.IsVisible() || Menu.IsVisible() || ((Object)(object)Minimap.instance != (Object)null && (int)Minimap.instance.m_mode != 1); if (flag && hideWhenMenusOpen.Value) { return; } EnsureStyle(); style.fontSize = Mathf.Clamp(fontSize.Value, 8, 72); float num = EnvMan.instance.GetDayFraction() * 1440f; int num2 = Mathf.FloorToInt(num / 60f) % 24; int num3 = Mathf.FloorToInt(num % 60f); string text = (use24HourTime.Value ? $"{num2:00}:{num3:00}" : string.Format("{0}:{1:00} {2}", (num2 % 12 == 0) ? 12 : (num2 % 12), num3, (num2 >= 12) ? "PM" : "AM")); string text2 = (showDay.Value ? $"Day {EnvMan.instance.GetDay()} {text}" : text); Vector2 val = style.CalcSize(new GUIContent(text2)); float num4 = Mathf.Clamp(val.x + 8f, 1f, (float)Screen.width); float num5 = Mathf.Clamp(val.y + 4f, 1f, (float)Screen.height); float num6 = (flag ? menuHorizontalPosition.Value : horizontalPosition.Value); float num7 = (flag ? menuVerticalPosition.Value : verticalPosition.Value); num6 = Mathf.Clamp01(num6); num7 = Mathf.Clamp01(num7); float num8 = Mathf.Max(0f, (float)Screen.width - num4); float num9 = Mathf.Max(0f, (float)Screen.height - num5); float num10 = Mathf.Clamp(num8 * num6, 0f, num8); float num11 = Mathf.Clamp(num9 * num7, 0f, num9); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num10, num11, num4, num5); if (outlineEnabled.Value) { int num12 = Mathf.Clamp(outlineSize.Value, 1, 5); Color textColor = style.normal.textColor; style.normal.textColor = Color.black; for (int i = -num12; i <= num12; i++) { for (int j = -num12; j <= num12; j++) { if ((i != 0 || j != 0) && (Mathf.Abs(i) == num12 || Mathf.Abs(j) == num12)) { GUI.Label(new Rect(((Rect)(ref val2)).x + (float)i, ((Rect)(ref val2)).y + (float)j, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), text2, style); } } } style.normal.textColor = textColor; } GUI.Label(val2, text2, style); } private bool FindValheimFont() { try { Font[] array = Resources.FindObjectsOfTypeAll<Font>(); string[] array2 = new string[2] { "AveriaSerifLibre-Bold", "Averia Serif Libre Bold" }; string[] array3 = array2; foreach (string b in array3) { Font[] array4 = array; foreach (Font val in array4) { if ((Object)(object)val != (Object)null && string.Equals(((Object)val).name, b, StringComparison.OrdinalIgnoreCase)) { valheimFont = val; if (!loggedFontFound) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Time&DayDisplay: using Valheim in-game font: " + ((Object)val).name)); loggedFontFound = true; } return true; } } } Font[] array5 = array; foreach (Font val2 in array5) { if ((Object)(object)val2 == (Object)null || string.IsNullOrEmpty(((Object)val2).name)) { continue; } bool flag = ((Object)val2).name.IndexOf("AveriaSerifLibre", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)val2).name.IndexOf("Averia Serif Libre", StringComparison.OrdinalIgnoreCase) >= 0; bool flag2 = ((Object)val2).name.IndexOf("Bold", StringComparison.OrdinalIgnoreCase) >= 0; if (flag && flag2) { valheimFont = val2; if (!loggedFontFound) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Time&DayDisplay: using Valheim in-game font fallback: " + ((Object)val2).name)); loggedFontFound = true; } return true; } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Time&DayDisplay: Valheim font lookup failed: " + ex.Message)); } return false; } private void EnsureStyle() { //IL_001a: 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) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if (style == null) { style = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)0, alignment = (TextAnchor)0 }; } if ((Object)(object)valheimFont == (Object)null && Time.unscaledTime >= nextFontLookupTime) { nextFontLookupTime = Time.unscaledTime + 1f; if (FindValheimFont()) { style.font = valheimFont; } } else if ((Object)(object)valheimFont != (Object)null && (Object)(object)style.font != (Object)(object)valheimFont) { style.font = valheimFont; } } } }