Decompiled source of PriceDotFormatter v1.2.4

PriceDotFormatter.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PriceDotFormatter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PriceDotFormatter")]
[assembly: AssemblyTitle("PriceDotFormatter")]
[assembly: AssemblyVersion("1.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 PriceDotFormatter
{
	[BepInPlugin("acesgaminguk.supermarkettogether.pricedotformatter", "Price Dot Formatter", "1.2.2")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
			((BaseUnityPlugin)this).Logger.LogWarning((object)"=============================================");
			((BaseUnityPlugin)this).Logger.LogMessage((object)$"Price Dot Formatter v{((BaseUnityPlugin)this).Info.Metadata.Version} Initializing...");
			((BaseUnityPlugin)this).Logger.LogWarning((object)"=============================================");
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Author: AcesGamingUK");
			((BaseUnityPlugin)this).Logger.LogMessage((object)"GitHub: https://github.com/AcesGamingUK/Price-Dot-Formatter");
			((BaseUnityPlugin)this).Logger.LogWarning((object)"=============================================");
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Price Dot Formatter Initialized successfully!");
			((BaseUnityPlugin)this).Logger.LogWarning((object)"=============================================");
		}

		[HarmonyPatch(typeof(ProductListing), "ConvertFloatToTextPrice")]
		[HarmonyPrefix]
		private static bool ConvertFloatToTextPrice_Prefix(float price, ref string __result)
		{
			price = Mathf.Round(price * 100f) / 100f;
			__result = "$" + price.ToString("0.00", CultureInfo.InvariantCulture);
			return false;
		}

		[HarmonyPatch(typeof(TMP_Text), "set_text")]
		[HarmonyPrefix]
		private static void TMPText_SetText_Prefix(TMP_Text __instance, ref string value)
		{
			if (!((Object)(object)__instance == (Object)null) && !string.IsNullOrEmpty(value) && !(((Object)__instance).name == "BoxPrice") && (!((Object)(object)__instance.transform != (Object)null) || !(((Object)__instance.transform).name == "BoxPrice")) && LooksLikePrice(value))
			{
				value = value.Replace(",", ".");
			}
		}

		private static bool LooksLikePrice(string text)
		{
			if (!text.Contains("$") && !text.Contains("€") && !text.Contains("£") && !text.Contains("Price"))
			{
				return text.Contains("price");
			}
			return true;
		}
	}
}