Decompiled source of TotalDailyProfit v1.4.1

TotalDailyProfit.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Money;
using Il2CppScheduleOne.UI;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Preferences;
using ModManagerPhoneApp;
using TotalDailyProfit;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(global::TotalDailyProfit.TotalDailyProfit), "TotalDailyProfit", "1.4.1", "Jc Dock", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("TotalDailyProfit")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TotalDailyProfit")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("63a40101-5f59-4ad6-80a1-99068522f033")]
[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 TotalDailyProfit;

public class TotalDailyProfit : MelonMod
{
	[HarmonyPatch(typeof(DailySummary), "DailySummary")]
	public class DailySummaryPatch
	{
		[HarmonyPatch("Open")]
		[HarmonyPostfix]
		public static void Postfix(DailySummary __instance)
		{
			float moneyEarnedByPlayer = __instance.moneyEarnedByPlayer;
			float moneyEarnedByDealers = __instance.moneyEarnedByDealers;
			float num = moneyEarnedByPlayer + moneyEarnedByDealers;
			((TMP_Text)__instance.DealerEarningsLabel).text = MoneyManager.FormatAmount(moneyEarnedByDealers, false, true) + " (" + MoneyManager.FormatAmount(num, false, true) + ")";
		}
	}

	private static MelonPreferences_Category KeybindCategory;

	private static MelonPreferences_Entry<KeyCode> Keybind;

	private static MelonPreferences_Entry<bool> CrtlModifier;

	private static MelonPreferences_Entry<bool> ShiftModifier;

	private static MelonPreferences_Entry<bool> AltModifier;

	public Harmony harmony;

	public override void OnInitializeMelon()
	{
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Expected O, but got Unknown
		KeybindCategory = MelonPreferences.CreateCategory("TotalDailyProfit_Main", "Total Daily Profit Keybind Settings");
		Keybind = KeybindCategory.CreateEntry<KeyCode>("Keybind", (KeyCode)290, "Keybind to open/close the Daily Summary window.", (string)null, false, false, (ValueValidator)null, (string)null);
		CrtlModifier = KeybindCategory.CreateEntry<bool>("CrtlModifier", false, "Use Ctrl + Keybind.", (string)null, false, false, (ValueValidator)null, (string)null);
		ShiftModifier = KeybindCategory.CreateEntry<bool>("ShiftModifier", false, "Use Shift + Keybind.", (string)null, false, false, (ValueValidator)null, (string)null);
		AltModifier = KeybindCategory.CreateEntry<bool>("AltModifier", false, "Use Alt + Keybind.", (string)null, false, false, (ValueValidator)null, (string)null);
		SubscribeToModManagerEvents();
		harmony = new Harmony("com.jcdock.totaldailyprofit");
		harmony.PatchAll();
		((MelonBase)this).LoggerInstance.Msg(((MelonBase)this).Info.Name + " v" + ((MelonBase)this).Info.Version + " Initialized");
	}

	public override void OnDeinitializeMelon()
	{
		UnsubscribeFromModManagerEvents();
	}

	public override void OnUpdate()
	{
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: 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_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		bool value = CrtlModifier.Value;
		bool value2 = ShiftModifier.Value;
		bool value3 = AltModifier.Value;
		if (value && value2 && value3)
		{
			if (Input.GetKey((KeyCode)306) && Input.GetKey((KeyCode)304) && Input.GetKey((KeyCode)308) && Input.GetKeyDown(Keybind.Value))
			{
				ToggleDailySummary();
			}
		}
		else if (value && value2)
		{
			if (Input.GetKey((KeyCode)306) && Input.GetKey((KeyCode)304) && Input.GetKeyDown(Keybind.Value))
			{
				ToggleDailySummary();
			}
		}
		else if (value && value3)
		{
			if (Input.GetKey((KeyCode)306) && Input.GetKey((KeyCode)308) && Input.GetKeyDown(Keybind.Value))
			{
				ToggleDailySummary();
			}
		}
		else if (value2 && value3)
		{
			if (Input.GetKey((KeyCode)304) && Input.GetKey((KeyCode)308) && Input.GetKeyDown(Keybind.Value))
			{
				ToggleDailySummary();
			}
		}
		else if (value)
		{
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown(Keybind.Value))
			{
				ToggleDailySummary();
			}
		}
		else if (value2)
		{
			if (Input.GetKey((KeyCode)304) && Input.GetKeyDown(Keybind.Value))
			{
				ToggleDailySummary();
			}
		}
		else if (value3)
		{
			if (Input.GetKey((KeyCode)308) && Input.GetKeyDown(Keybind.Value))
			{
				ToggleDailySummary();
			}
		}
		else if (Input.GetKeyDown(Keybind.Value))
		{
			ToggleDailySummary();
		}
	}

	public static void ToggleDailySummary()
	{
		if (NetworkSingleton<DailySummary>.Instance.IsOpen)
		{
			NetworkSingleton<DailySummary>.Instance.Close();
		}
		else
		{
			NetworkSingleton<DailySummary>.Instance.Open();
		}
	}

	private void UnsubscribeFromModManagerEvents()
	{
		try
		{
			ModSettingsEvents.OnPhonePreferencesSaved -= HandleSettingsUpdate;
		}
		catch
		{
		}
		try
		{
			ModSettingsEvents.OnMenuPreferencesSaved -= HandleSettingsUpdate;
		}
		catch
		{
		}
	}

	private void SubscribeToModManagerEvents()
	{
		try
		{
			ModSettingsEvents.OnPhonePreferencesSaved += HandleSettingsUpdate;
		}
		catch (Exception arg)
		{
			((MelonBase)this).LoggerInstance.Error($"Error subscribing to OnPhonePreferencesSaved: {arg}");
		}
		try
		{
			ModSettingsEvents.OnMenuPreferencesSaved += HandleSettingsUpdate;
		}
		catch (Exception arg2)
		{
			((MelonBase)this).LoggerInstance.Error($"Error subscribing to OnMenuPreferencesSaved: {arg2}");
		}
	}

	private void HandleSettingsUpdate()
	{
		try
		{
			Keybind = KeybindCategory.GetEntry<KeyCode>("Keybind");
			CrtlModifier = KeybindCategory.GetEntry<bool>("CrtlModifier");
			ShiftModifier = KeybindCategory.GetEntry<bool>("ShiftModifier");
			AltModifier = KeybindCategory.GetEntry<bool>("AltModifier");
			((MelonBase)this).LoggerInstance.Msg("Settings reloaded successfully.");
		}
		catch (Exception arg)
		{
			((MelonBase)this).LoggerInstance.Error($"Error applying updated settings after save: {arg}");
		}
	}
}