Decompiled source of ClockFix v0.1.0

ClockFix.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
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: AssemblyTitle("ClockFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClockFix")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e8221cf7-76a3-480d-b374-4080d9c5f0b7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ClockFix;

[BepInPlugin("randyknapp.mods.clockfix", "Clock Fix", "0.1.0")]
public class ClockFix : BaseUnityPlugin
{
	public const string GUID = "randyknapp.mods.clockfix";

	public const string NAME = "Clock Fix";

	public const string VERSION = "0.1.0";

	public static ConfigEntry<bool> Use12HourTime;

	public void Awake()
	{
		Use12HourTime = ((BaseUnityPlugin)this).Config.Bind<bool>("Config", "Use 12 Hour Time", true, "If true, displays the clock using 12 hour time with AM/PM indicators. If false, displays 24 hour time.");
		((BaseUnityPlugin)this).Logger.LogWarning((object)"Clock Fix Loaded");
		((BaseUnityPlugin)this).Logger.LogWarning((object)$"- {((ConfigEntryBase)Use12HourTime).Definition.Key}: {Use12HourTime.Value}");
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "randyknapp.mods.clockfix");
	}
}
[HarmonyPatch(typeof(UICombat), "Update")]
public static class UICombat_Update_Patch
{
	public static void Postfix(Text ___txtHour, Text ___txtTimer)
	{
		int currentHour = EnviroSkyMgr.instance.GetCurrentHour();
		int currentMinute = EnviroSkyMgr.instance.GetCurrentMinute();
		if (ClockFix.Use12HourTime.Value)
		{
			int num = currentHour % 12;
			if (num == 0)
			{
				num = 12;
			}
			___txtHour.text = string.Format("{0}:{1:D2} {2}", num, currentMinute, (currentHour >= 12) ? "PM" : "AM");
		}
		else
		{
			___txtHour.text = $"{currentHour}:{currentMinute:D2}";
		}
		((Component)___txtTimer).gameObject.SetActive(false);
	}
}