Decompiled source of IMSBigBag v1.0.1

BepInEx/plugins/BigBag.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BigBag.Configuration;
using BigBag.Localization;
using BigBag.Patches;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Localization.Settings;
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("BigBag")]
[assembly: AssemblyDescription("Big Bag mod for Island Market Simulator by Ice Box Studio")]
[assembly: AssemblyCompany("Ice Box Studio")]
[assembly: AssemblyProduct("BigBag")]
[assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5DC5CB15-271F-47F8-9755-B2A5A9738743")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("1.0.1.0")]
namespace BigBag
{
	[BepInPlugin("IceBoxStudio.IslandMarketSimulator.BigBag", "BigBag", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BigBag : BasePlugin
	{
		public static BigBag _Instance;

		private Harmony _harmony;

		private bool patchesApplied = false;

		private const string ModConfigManagerApiTypeName = "ModConfigManager.Api.ModConfigManagerAPI";

		private const string ModConfigManagerRegisterMethodName = "RegisterPluginInfo";

		public static BigBag Instance => _Instance;

		internal static ManualLogSource Logger { get; private set; }

		public override void Load()
		{
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			_Instance = this;
			Logger = ((BasePlugin)this).Log;
			bool flag = default(bool);
			try
			{
				Logger.LogInfo((object)"=============================================");
				ManualLogSource logger = Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BigBag");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(LocalizationManager.Instance.GetLocalizedText("plugin.initializing"));
				}
				logger.LogInfo(val);
				ManualLogSource logger2 = Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(54, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(LocalizationManager.Instance.GetLocalizedText("plugin.author_prefix"));
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Ice Box Studio(https://steamcommunity.com/id/ibox666/)");
				}
				logger2.LogInfo(val);
				ConfigManager.Initialize(((BasePlugin)this).Config);
				ClassInjector.RegisterTypeInIl2Cpp<BagHudFix>();
				RegisterToModConfigManager();
				ApplyPatches();
				ManualLogSource logger3 = Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BigBag");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(LocalizationManager.Instance.GetLocalizedText("plugin.initialized"));
				}
				logger3.LogInfo(val);
				Logger.LogInfo((object)"=============================================");
			}
			catch (Exception ex)
			{
				ManualLogSource logger4 = Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(9, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("BigBag");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" 初始化错误: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\n");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.StackTrace);
				}
				logger4.LogError(val2);
			}
		}

		private void ApplyPatches()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			if (!patchesApplied)
			{
				try
				{
					_harmony = new Harmony("IceBoxStudio.IslandMarketSimulator.BigBag");
					_harmony.PatchAll();
					patchesApplied = true;
					return;
				}
				catch (Exception ex)
				{
					ManualLogSource logger = Logger;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(10, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BigBag");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" 应用补丁错误: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.StackTrace);
					}
					logger.LogError(val);
					return;
				}
			}
			Logger.LogInfo((object)LocalizationManager.Instance.GetLocalizedText("plugin.patches_skipped"));
		}

		private void RegisterToModConfigManager()
		{
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.GetType("ModConfigManager.Api.ModConfigManagerAPI") != null)?.GetType("ModConfigManager.Api.ModConfigManagerAPI");
			if (!(type == null))
			{
				MethodInfo method = type.GetMethod("RegisterPluginInfo", BindingFlags.Static | BindingFlags.Public);
				if (!(method == null))
				{
					method.Invoke(null, new object[5]
					{
						"IceBoxStudio.IslandMarketSimulator.BigBag",
						LocalizationManager.Instance.GetLocalizedText("plugin.name"),
						"1.0.1",
						"Ice Box Studio",
						LocalizationManager.Instance.GetLocalizedText("plugin.description")
					});
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "IceBoxStudio.IslandMarketSimulator.BigBag";

		public const string PLUGIN_NAME = "BigBag";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace BigBag.Patches
{
	internal static class HeldItemPanelsPatch
	{
		private const int RaiseThreshold = 8;

		private static ItemManager _mgr = null;

		private static RectTransform _held = null;

		private static Vector2 _heldBase = Vector2.zero;

		private static RectTransform _evt = null;

		private static Vector2 _evtBase = Vector2.zero;

		internal static void Apply(ItemManager itemManager)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)itemManager == (Object)null)
			{
				return;
			}
			if (itemManager.availableSlots <= 8)
			{
				Restore(itemManager);
				return;
			}
			EnsureCache(itemManager);
			float num = RowH(itemManager);
			int num2 = Mathf.Max(0, BagRows(itemManager) - 1);
			float num3 = ((num2 <= 0) ? 0f : (num * (float)num2 + num * 0.5f));
			if ((Object)(object)_held != (Object)null)
			{
				_held.anchoredPosition = _heldBase + new Vector2(0f, num3);
			}
			if ((Object)(object)_evt != (Object)null)
			{
				_evt.anchoredPosition = _evtBase + new Vector2(0f, num3);
			}
		}

		private static void Restore(ItemManager itemManager)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_mgr != (Object)(object)itemManager))
			{
				if ((Object)(object)_held != (Object)null)
				{
					_held.anchoredPosition = _heldBase;
				}
				if ((Object)(object)_evt != (Object)null)
				{
					_evt.anchoredPosition = _evtBase;
				}
			}
		}

		private static void EnsureCache(ItemManager itemManager)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_mgr != (Object)(object)itemManager)
			{
				_mgr = itemManager;
				_held = null;
				_evt = null;
			}
			if ((Object)(object)_held != (Object)null)
			{
				return;
			}
			Transform val = Top(itemManager);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform val2 = FindDeep(val, "HeldItemPanels");
			if ((Object)(object)val2 != (Object)null)
			{
				RectTransform component = ((Component)val2).GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					_held = component;
					_heldBase = component.anchoredPosition;
				}
			}
			if (!((Object)(object)_evt == (Object)null))
			{
				return;
			}
			Transform val3 = FindDeep(val, "ActiveEventPanel");
			if ((Object)(object)val3 != (Object)null)
			{
				RectTransform component2 = ((Component)val3).GetComponent<RectTransform>();
				if ((Object)(object)component2 != (Object)null)
				{
					_evt = component2;
					_evtBase = component2.anchoredPosition;
				}
			}
		}

		private static Transform Top(ItemManager itemManager)
		{
			Transform val = null;
			if (itemManager.bagSlotImages != null && itemManager.bagSlotImages.Count > 0 && (Object)(object)itemManager.bagSlotImages[0] != (Object)null)
			{
				val = itemManager.bagSlotImages[0].transform;
			}
			else if ((Object)(object)itemManager.itemIndicatorImage != (Object)null)
			{
				val = ((Component)itemManager.itemIndicatorImage).transform;
			}
			else if ((Object)(object)itemManager.baseItemImage != (Object)null)
			{
				val = ((Component)itemManager.baseItemImage).transform;
			}
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Transform val2 = val;
			while ((Object)(object)val2.parent != (Object)null)
			{
				val2 = val2.parent;
			}
			return val2;
		}

		private static Transform FindDeep(Transform parent, string prefix)
		{
			if ((Object)(object)parent == (Object)null)
			{
				return null;
			}
			for (int i = 0; i < parent.childCount; i++)
			{
				Transform child = parent.GetChild(i);
				if (!((Object)(object)child == (Object)null))
				{
					if (!string.IsNullOrEmpty(((Object)child).name) && ((Object)child).name.StartsWith(prefix))
					{
						return child;
					}
					Transform val = FindDeep(child, prefix);
					if ((Object)(object)val != (Object)null)
					{
						return val;
					}
				}
			}
			return null;
		}

		private static float RowH(ItemManager itemManager)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			float num = BagPatch.Step(itemManager).y;
			if (num < 1f)
			{
				num = Mathf.Abs(itemManager.indicatorMoveValue);
			}
			if (num < 1f)
			{
				num = 125f;
			}
			return num;
		}

		private static int BagRows(ItemManager itemManager)
		{
			int num = Mathf.Max(0, itemManager.availableSlots - 1);
			int num2 = BagPatch.PerRow();
			int num3 = num2 - 1;
			if (num <= num3)
			{
				return 1;
			}
			int num4 = Mathf.CeilToInt((float)(num - num3) / (float)num2);
			return 1 + Mathf.Max(0, num4);
		}
	}
	[HarmonyPatch(typeof(ItemManager), "InitItemManager")]
	internal static class HeldItemPanelsInitPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemManager __instance)
		{
			HeldItemPanelsPatch.Apply(__instance);
		}
	}
	[HarmonyPatch(typeof(ItemManager), "HandleBagSlots")]
	internal static class HeldItemPanelsHandleBagSlotsPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemManager __instance)
		{
			HeldItemPanelsPatch.Apply(__instance);
		}
	}
	[HarmonyPatch(typeof(ItemManager), "SwitchSlot")]
	internal static class HeldItemPanelsSwitchSlotPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemManager __instance)
		{
			HeldItemPanelsPatch.Apply(__instance);
		}
	}
	[HarmonyPatch(typeof(ItemManager), "Update")]
	internal static class HeldItemPanelsUpdatePatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemManager __instance)
		{
			HeldItemPanelsPatch.Apply(__instance);
		}
	}
	internal static class BagPatch
	{
		internal const int MaxPerRow = 20;

		private static ItemManager _indMgr = null;

		private static float _indBaseY = 0f;

		private static bool _gotBaseY = false;

		private static ItemManager _colorMgr = null;

		private static Color _indBaseColor = default(Color);

		private static int _origImgCount = 0;

		private static Vector2[] _origPos = null;

		private static int _origN = 0;

		private static float _slotDx = 0f;

		private static float _slotDy = 0f;

		private static Vector2 _heldPos = Vector2.zero;

		private static float _rowY = 0f;

		internal static int ResolveCapacity(int orig)
		{
			ConfigManager instance = ConfigManager.Instance;
			if (instance == null)
			{
				return orig;
			}
			int value;
			switch (orig)
			{
			case 3:
				value = instance.SmallBagCapacity.Value;
				break;
			case 4:
				value = instance.MediumBagCapacity.Value;
				break;
			case 5:
				value = instance.LargeBagCapacity.Value;
				break;
			default:
				return orig;
			}
			return Mathf.Max(0, value - 1);
		}

		internal static int PerRow()
		{
			int num = ConfigManager.Instance?.SlotsPerRow?.Value ?? 20;
			return Mathf.Clamp(num, 2, 20);
		}

		internal static void EnsureSlots(ItemManager mgr, int count)
		{
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mgr == (Object)null || mgr.bagSlotImages == null || count <= 0 || mgr.bagSlotImages.Count == 0)
			{
				return;
			}
			if (_origImgCount <= 0)
			{
				_origImgCount = mgr.bagSlotImages.Count;
			}
			GameObject val = mgr.bagSlotImages[0];
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform parent = val.transform.parent;
			KillLayouts(parent);
			SkipLayout(val);
			int count2 = mgr.bagSlotImages.Count;
			for (int i = count2; i < count; i++)
			{
				GameObject val2 = Object.Instantiate<GameObject>(val, parent);
				((Object)val2).name = "BagSlot_Expanded_" + i;
				val2.SetActive(false);
				mgr.bagSlotImages.Add(val2);
				RectTransform component = val2.GetComponent<RectTransform>();
				RectTransform component2 = val.GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
				{
					component.anchorMin = component2.anchorMin;
					component.anchorMax = component2.anchorMax;
					component.pivot = component2.pivot;
					component.sizeDelta = component2.sizeDelta;
					((Transform)component).localScale = ((Transform)component2).localScale;
				}
				SkipLayout(val2);
			}
			HookLateUpdate(mgr, parent);
			PlaceSlots(mgr);
			WireHotkeys(mgr);
		}

		internal static void PlaceSlots(ItemManager mgr)
		{
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mgr == (Object)null || mgr.bagSlotImages == null || mgr.bagSlotImages.Count == 0)
			{
				return;
			}
			GameObject val = mgr.bagSlotImages[0];
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			KillLayouts(val.transform);
			if ((Object)(object)_indMgr != (Object)(object)mgr)
			{
				_indMgr = mgr;
				_origPos = null;
				_origN = 0;
				_gotBaseY = false;
				_slotDx = 0f;
				_slotDy = 0f;
			}
			RememberOrig(mgr);
			int num = ((_origN > 0) ? _origN : ((_origImgCount <= 0) ? 1 : _origImgCount));
			float slotDx = _slotDx;
			float num2 = ((_slotDy > 1f) ? _slotDy : Mathf.Abs(slotDx));
			if (num2 < 1f)
			{
				num2 = 125f;
			}
			int num3 = PerRow();
			for (int i = 0; i < mgr.bagSlotImages.Count; i++)
			{
				GameObject val2 = mgr.bagSlotImages[i];
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				SkipLayout(val2);
				if (i >= num)
				{
					RectTransform component = val2.GetComponent<RectTransform>();
					if (!((Object)(object)component == (Object)null))
					{
						int num4 = i + 1;
						int num5 = num4 / num3;
						int num6 = num4 % num3;
						component.anchoredPosition = new Vector2(_heldPos.x + slotDx * (float)num6, _rowY + num2 * (float)num5);
					}
				}
			}
			HeldItemPanelsPatch.Apply(mgr);
		}

		internal static void ResizeBagData(ItemManager mgr, int targetCount)
		{
			if (!((Object)(object)mgr == (Object)null))
			{
				if (targetCount < 0)
				{
					targetCount = 0;
				}
				List<GameObject> val = mgr.bagSlots ?? new List<GameObject>();
				List<GameObject> val2 = new List<GameObject>(targetCount);
				for (int i = 0; i < targetCount; i++)
				{
					val2.Add((i < val.Count) ? val[i] : null);
				}
				mgr.bagSlots = val2;
				mgr.availableSlots = targetCount + 1;
				if (mgr.currentSlotIndex >= mgr.availableSlots)
				{
					mgr.currentSlotIndex = mgr.availableSlots - 1;
				}
				if (mgr.currentSlotIndex < 0)
				{
					mgr.currentSlotIndex = 0;
				}
			}
		}

		internal static void RefreshSlots(ItemManager mgr, int activeCount)
		{
			if ((Object)(object)mgr == (Object)null || mgr.bagSlotImages == null)
			{
				return;
			}
			for (int i = 0; i < mgr.bagSlotImages.Count; i++)
			{
				GameObject val = mgr.bagSlotImages[i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				bool flag = i < activeCount;
				val.SetActive(flag);
				Image component = val.GetComponent<Image>();
				if (!((Object)(object)component == (Object)null))
				{
					if (!flag)
					{
						component.sprite = mgr.defaultSprite;
						continue;
					}
					GameObject val2 = ((i < mgr.bagSlots.Count) ? mgr.bagSlots[i] : null);
					BaseItem val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<BaseItem>() : null);
					component.sprite = (((Object)(object)val3 != (Object)null && (Object)(object)val3.itemData != (Object)null) ? val3.itemData.iconSprite : mgr.defaultSprite);
				}
			}
		}

		internal static void SyncHeldItem(ItemManager mgr)
		{
			if (!((Object)(object)mgr == (Object)null))
			{
				if (mgr.currentSlotIndex == 0)
				{
					mgr.heldItem = mgr.baseSlotItem;
					return;
				}
				int num = mgr.currentSlotIndex - 1;
				mgr.heldItem = ((num >= 0 && num < mgr.bagSlots.Count) ? mgr.bagSlots[num] : null);
			}
		}

		internal static void RefreshIndicator(ItemManager mgr)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mgr == (Object)null || (Object)(object)mgr.itemIndicatorImage == (Object)null)
			{
				return;
			}
			ApplyColor(mgr);
			RectTransform rectTransform = ((Graphic)mgr.itemIndicatorImage).rectTransform;
			if ((Object)(object)rectTransform == (Object)null)
			{
				return;
			}
			if ((Object)(object)_indMgr != (Object)(object)mgr)
			{
				_indMgr = mgr;
				_gotBaseY = false;
				_origPos = null;
				_slotDx = 0f;
				_slotDy = 0f;
			}
			if (mgr.currentSlotIndex <= 0)
			{
				if (!_gotBaseY)
				{
					_indBaseY = rectTransform.anchoredPosition.y;
					_gotBaseY = true;
				}
				rectTransform.anchoredPosition = new Vector2(mgr.indicatorStartXValue, _indBaseY);
				return;
			}
			int num = mgr.currentSlotIndex - 1;
			if (mgr.bagSlotImages != null && num >= 0 && num < mgr.bagSlotImages.Count)
			{
				RectTransform val = (((Object)(object)mgr.bagSlotImages[num] != (Object)null) ? mgr.bagSlotImages[num].GetComponent<RectTransform>() : null);
				if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy)
				{
					AlignCenters(rectTransform, val);
					return;
				}
			}
			Vector2 val2 = Step(mgr);
			var (num2, num3) = IndexRowCol(mgr.currentSlotIndex);
			if (!_gotBaseY)
			{
				_indBaseY = rectTransform.anchoredPosition.y - val2.y * (float)num2;
				_gotBaseY = true;
			}
			rectTransform.anchoredPosition = new Vector2(mgr.indicatorStartXValue + val2.x * (float)num3, _indBaseY + val2.y * (float)num2);
		}

		private static void AlignCenters(RectTransform a, RectTransform b)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = b.rect;
			Vector3 val = ((Transform)b).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center));
			rect = a.rect;
			Vector3 val2 = ((Transform)a).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center));
			((Transform)a).position = ((Transform)a).position + (val - val2);
		}

		internal static void ApplyColor(ItemManager mgr)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)mgr == (Object)null) && !((Object)(object)mgr.itemIndicatorImage == (Object)null))
			{
				if ((Object)(object)_colorMgr != (Object)(object)mgr)
				{
					_indBaseColor = ((Graphic)mgr.itemIndicatorImage).color;
					_colorMgr = mgr;
				}
				string text = ConfigManager.Instance?.BagHighlightColor?.Value;
				if (string.IsNullOrWhiteSpace(text))
				{
					((Graphic)mgr.itemIndicatorImage).color = _indBaseColor;
				}
				else
				{
					Color val = default(Color);
					((Graphic)mgr.itemIndicatorImage).color = (ColorUtility.TryParseHtmlString(text, ref val) ? val : _indBaseColor);
				}
			}
		}

		internal static void WireHotkeys(ItemManager mgr)
		{
			if ((Object)(object)mgr == (Object)null || mgr.bagSlotImages == null)
			{
				return;
			}
			List<TextMeshProUGUI> val = mgr.bagSlotHotkeyTexts;
			if (val == null)
			{
				val = (mgr.bagSlotHotkeyTexts = new List<TextMeshProUGUI>());
			}
			GameObject template = ((mgr.bagSlotImages.Count > 0) ? mgr.bagSlotImages[0] : null);
			TextMeshProUGUI templateHotkey = ((val.Count > 0) ? val[0] : null);
			while (val.Count < mgr.bagSlotImages.Count)
			{
				val.Add((TextMeshProUGUI)null);
			}
			for (int i = 0; i < mgr.bagSlotImages.Count; i++)
			{
				GameObject val3 = mgr.bagSlotImages[i];
				if (!((Object)(object)val3 == (Object)null))
				{
					if ((Object)(object)val[i] == (Object)null)
					{
						val[i] = CloneHotkey(val3, template, templateHotkey);
					}
					if (_origImgCount > 0 && i >= _origImgCount)
					{
						ClearExtraTexts(val3, val[i]);
					}
				}
			}
			HideHotkeys(mgr);
		}

		internal static void HideHotkeys(ItemManager mgr)
		{
			List<TextMeshProUGUI> val = ((mgr != null) ? mgr.bagSlotHotkeyTexts : null);
			if (val == null)
			{
				return;
			}
			for (int i = 0; i < val.Count; i++)
			{
				TextMeshProUGUI val2 = val[i];
				if (!((Object)(object)val2 == (Object)null))
				{
					if (!string.IsNullOrEmpty(((TMP_Text)val2).text))
					{
						((TMP_Text)val2).text = string.Empty;
					}
					if (((Component)val2).gameObject.activeSelf)
					{
						((Component)val2).gameObject.SetActive(false);
					}
				}
			}
		}

		private static TextMeshProUGUI CloneHotkey(GameObject clone, GameObject template, TextMeshProUGUI templateHotkey)
		{
			if ((Object)(object)clone == (Object)null)
			{
				return null;
			}
			TextMeshProUGUI[] array = Il2CppArrayBase<TextMeshProUGUI>.op_Implicit(clone.GetComponentsInChildren<TextMeshProUGUI>(true));
			if (array == null || array.Length == 0)
			{
				return null;
			}
			if ((Object)(object)templateHotkey == (Object)null || (Object)(object)template == (Object)null)
			{
				return array[0];
			}
			TextMeshProUGUI[] array2 = Il2CppArrayBase<TextMeshProUGUI>.op_Implicit(template.GetComponentsInChildren<TextMeshProUGUI>(true));
			if (array2 == null)
			{
				return array[0];
			}
			int num = -1;
			for (int i = 0; i < array2.Length; i++)
			{
				if ((Object)(object)array2[i] == (Object)(object)templateHotkey)
				{
					num = i;
					break;
				}
			}
			if (num >= 0 && num < array.Length)
			{
				return array[num];
			}
			return array[0];
		}

		private static void ClearExtraTexts(GameObject slot, TextMeshProUGUI keep)
		{
			if ((Object)(object)slot == (Object)null)
			{
				return;
			}
			TextMeshProUGUI[] array = Il2CppArrayBase<TextMeshProUGUI>.op_Implicit(slot.GetComponentsInChildren<TextMeshProUGUI>(true));
			if (array == null)
			{
				return;
			}
			foreach (TextMeshProUGUI val in array)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)keep))
				{
					((TMP_Text)val).text = string.Empty;
				}
			}
		}

		private static (int row, int col) IndexRowCol(int slotIndex)
		{
			int num = PerRow();
			return (row: slotIndex / num, col: slotIndex % num);
		}

		internal static float PromptLift(ItemManager mgr, RectTransform panel)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mgr == (Object)null || mgr.bagSlotImages == null || mgr.bagSlotImages.Count == 0 || (Object)(object)panel == (Object)null)
			{
				return 0f;
			}
			RectTransform val = null;
			float num = float.MaxValue;
			float num2 = float.MinValue;
			for (int i = 0; i < mgr.bagSlotImages.Count; i++)
			{
				GameObject val2 = mgr.bagSlotImages[i];
				if ((Object)(object)val2 == (Object)null || !val2.activeInHierarchy)
				{
					continue;
				}
				RectTransform component = val2.GetComponent<RectTransform>();
				if (!((Object)(object)component == (Object)null))
				{
					float y = ((Transform)component).position.y;
					if (y < num)
					{
						num = y;
						val = component;
					}
					if (y > num2)
					{
						num2 = y;
					}
				}
			}
			float num3 = num2 - num;
			if ((Object)(object)val == (Object)null || num3 < 1f)
			{
				return 0f;
			}
			Transform val3 = (Transform)(((Object)(object)((Transform)panel).parent != (Object)null) ? ((object)((Transform)panel).parent) : ((object)panel));
			float num4 = Mathf.Abs(val3.InverseTransformVector(new Vector3(0f, num3, 0f)).y);
			RectTransform obj = val;
			Rect rect = val.rect;
			Vector3 val4 = ((Transform)obj).TransformPoint(new Vector3(0f, ((Rect)(ref rect)).yMax, 0f));
			float num5 = Mathf.Abs(val3.InverseTransformVector(val4 - ((Transform)val).position).y);
			return num4 + num5;
		}

		internal static Vector2 Step(ItemManager mgr)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if (Mathf.Abs(_slotDx) > 0.01f && _slotDy > 0.01f)
			{
				return new Vector2(_slotDx, _slotDy);
			}
			RememberOrig(mgr);
			if (Mathf.Abs(_slotDx) > 0.01f && _slotDy > 0.01f)
			{
				return new Vector2(_slotDx, _slotDy);
			}
			float num = (((Object)(object)mgr != (Object)null) ? mgr.indicatorMoveValue : (-125f));
			if (Mathf.Abs(num) < 1f)
			{
				num = -125f;
			}
			return new Vector2(num, Mathf.Abs(num));
		}

		private static void RememberOrig(ItemManager mgr)
		{
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			if (_origPos != null || (Object)(object)mgr == (Object)null || mgr.bagSlotImages == null || mgr.bagSlotImages.Count == 0)
			{
				return;
			}
			int num = ((_origImgCount > 0) ? Mathf.Min(_origImgCount, mgr.bagSlotImages.Count) : mgr.bagSlotImages.Count);
			if (num < 1)
			{
				return;
			}
			_origN = num;
			_origPos = (Vector2[])(object)new Vector2[num];
			RectTransform val = null;
			for (int i = 0; i < num; i++)
			{
				RectTransform val2 = (((Object)(object)mgr.bagSlotImages[i] != (Object)null) ? mgr.bagSlotImages[i].GetComponent<RectTransform>() : null);
				_origPos[i] = (((Object)(object)val2 != (Object)null) ? val2.anchoredPosition : Vector2.zero);
				if ((Object)(object)val2 != (Object)null && (Object)(object)val == (Object)null)
				{
					Transform parent = ((Transform)val2).parent;
					val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
				}
			}
			_rowY = _origPos[0].y;
			float num2 = MedianGapX(_origPos);
			if (num2 < 1f)
			{
				num2 = Mathf.Abs(mgr.indicatorMoveValue);
			}
			if (num2 < 1f)
			{
				num2 = 125f;
			}
			_heldPos = HeldAnchored(mgr, val, _origPos, num2);
			_slotDx = 0f - num2;
			_slotDy = num2;
		}

		private static float MedianGapX(Vector2[] pts)
		{
			if (pts == null || pts.Length < 2)
			{
				return 0f;
			}
			float[] array = new float[pts.Length];
			for (int i = 0; i < pts.Length; i++)
			{
				array[i] = pts[i].x;
			}
			for (int j = 1; j < array.Length; j++)
			{
				float num = array[j];
				int num2 = j - 1;
				while (num2 >= 0 && array[num2] > num)
				{
					array[num2 + 1] = array[num2];
					num2--;
				}
				array[num2 + 1] = num;
			}
			float[] array2 = new float[array.Length - 1];
			int num3 = 0;
			for (int k = 0; k < array.Length - 1; k++)
			{
				float num4 = array[k + 1] - array[k];
				if (num4 > 1f)
				{
					array2[num3++] = num4;
				}
			}
			if (num3 == 0)
			{
				return 0f;
			}
			for (int l = 1; l < num3; l++)
			{
				float num5 = array2[l];
				int num6 = l - 1;
				while (num6 >= 0 && array2[num6] > num5)
				{
					array2[num6 + 1] = array2[num6];
					num6--;
				}
				array2[num6 + 1] = num5;
			}
			return array2[num3 / 2];
		}

		private static Vector2 HeldAnchored(ItemManager mgr, RectTransform slotParent, Vector2[] orig, float cell)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			float x = orig[0].x;
			for (int i = 1; i < orig.Length; i++)
			{
				if (orig[i].x > x)
				{
					x = orig[i].x;
				}
			}
			Vector2 result = default(Vector2);
			((Vector2)(ref result))..ctor(x + cell, _rowY);
			if ((Object)(object)mgr == (Object)null || (Object)(object)mgr.baseItemImage == (Object)null || (Object)(object)slotParent == (Object)null)
			{
				return result;
			}
			RectTransform rectTransform = ((Graphic)mgr.baseItemImage).rectTransform;
			if ((Object)(object)rectTransform == (Object)null)
			{
				return result;
			}
			if ((Object)(object)((Transform)rectTransform).parent == (Object)(object)slotParent)
			{
				return rectTransform.anchoredPosition;
			}
			Vector3 val = ((Transform)slotParent).InverseTransformPoint(((Transform)rectTransform).position);
			return new Vector2(val.x, val.y);
		}

		private static void SkipLayout(GameObject slot)
		{
			if (!((Object)(object)slot == (Object)null))
			{
				LayoutElement val = slot.GetComponent<LayoutElement>();
				if ((Object)(object)val == (Object)null)
				{
					val = slot.AddComponent<LayoutElement>();
				}
				val.ignoreLayout = true;
			}
		}

		private static void KillLayouts(Transform start)
		{
			Transform val = start;
			while ((Object)(object)val != (Object)null)
			{
				LayoutGroup component = ((Component)val).GetComponent<LayoutGroup>();
				if ((Object)(object)component != (Object)null)
				{
					((Behaviour)component).enabled = false;
				}
				val = val.parent;
			}
		}

		private static void HookLateUpdate(ItemManager mgr, Transform parent)
		{
			if (!((Object)(object)mgr == (Object)null) && !((Object)(object)parent == (Object)null))
			{
				BagHudFix bagHudFix = ((Component)parent).GetComponent<BagHudFix>();
				if ((Object)(object)bagHudFix == (Object)null)
				{
					bagHudFix = ((Component)parent).gameObject.AddComponent<BagHudFix>();
				}
				bagHudFix.mgr = mgr;
			}
		}
	}
	internal class BagHudFix : MonoBehaviour
	{
		internal ItemManager mgr;

		public BagHudFix(IntPtr ptr)
			: base(ptr)
		{
		}

		private void LateUpdate()
		{
			if (!((Object)(object)mgr == (Object)null))
			{
				BagPatch.PlaceSlots(mgr);
				BagPatch.RefreshIndicator(mgr);
				HeldItemPanelsPatch.Apply(mgr);
			}
		}
	}
	[HarmonyPatch(typeof(ItemManager), "InitItemManager")]
	internal static class ItemManagerInitPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemManager __instance)
		{
			BagPatch.PlaceSlots(__instance);
			BagPatch.RefreshIndicator(__instance);
			BagPatch.HideHotkeys(__instance);
		}
	}
	[HarmonyPatch(typeof(ItemManager), "HandleBagSlots")]
	internal static class ItemManagerHandleBagSlotsPatch
	{
		[HarmonyPrefix]
		private static void Prefix(ItemManager __instance, ref int count)
		{
			count = BagPatch.ResolveCapacity(count);
			BagPatch.EnsureSlots(__instance, count);
		}

		[HarmonyPostfix]
		private static void Postfix(ItemManager __instance)
		{
			BagPatch.HideHotkeys(__instance);
			BagPatch.PlaceSlots(__instance);
			BagPatch.RefreshIndicator(__instance);
		}
	}
	[HarmonyPatch(typeof(ItemManager), "UpdateBagSlotHotkeyTexts")]
	internal static class ItemManagerUpdateBagSlotHotkeyTextsPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemManager __instance)
		{
			BagPatch.HideHotkeys(__instance);
		}
	}
	[HarmonyPatch(typeof(ItemManager), "RefreshBagSlotHotkeyTexts")]
	internal static class ItemManagerRefreshBagSlotHotkeyTextsPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemManager __instance)
		{
			BagPatch.HideHotkeys(__instance);
		}
	}
	[HarmonyPatch(typeof(TestSave), "LoadItemManager")]
	internal static class TestSaveLoadItemManagerPatch
	{
		[HarmonyPostfix]
		private static void Postfix(TestSave __instance)
		{
			GameObject val = ((__instance != null) ? __instance.player : null);
			if (!((Object)(object)val == (Object)null))
			{
				PlayerSaveHelper component = val.GetComponent<PlayerSaveHelper>();
				ItemManager val2 = (((Object)(object)component != (Object)null) ? component.itemManager : null);
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.currentBag == (Object)null))
				{
					int num = BagPatch.ResolveCapacity(val2.currentBag.slotCapacity);
					BagPatch.EnsureSlots(val2, num);
					BagPatch.ResizeBagData(val2, num);
					BagPatch.RefreshSlots(val2, num);
					BagPatch.SyncHeldItem(val2);
					BagPatch.PlaceSlots(val2);
					BagPatch.RefreshIndicator(val2);
					BagPatch.HideHotkeys(val2);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemManager), "SwitchSlot")]
	internal static class ItemManagerSwitchSlotPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemManager __instance)
		{
			BagPatch.RefreshIndicator(__instance);
		}
	}
	[HarmonyPatch(typeof(ItemManager), "SwitchToSlot")]
	internal static class ItemManagerSwitchToSlotPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemManager __instance)
		{
			BagPatch.RefreshIndicator(__instance);
		}
	}
	[HarmonyPatch(typeof(ItemManager), "Update")]
	internal static class ItemManagerUpdatePatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemManager __instance)
		{
			BagPatch.PlaceSlots(__instance);
			BagPatch.RefreshIndicator(__instance);
			BagPatch.HideHotkeys(__instance);
		}
	}
}
namespace BigBag.Localization
{
	public static class LocalizationHelper
	{
		public static Dictionary<string, string> GetDefaultTranslations(string language)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			switch (language)
			{
			case "zh":
				dictionary.Add("plugin.initializing", "开始初始化...");
				dictionary.Add("plugin.author_prefix", "作者:");
				dictionary.Add("plugin.initialized", "初始化成功!");
				dictionary.Add("plugin.patches_skipped", "补丁已应用,跳过...");
				dictionary.Add("plugin.name", "大背包");
				dictionary.Add("plugin.description", "增加三种背包的背包容量并支持调整选择框颜色。");
				dictionary.Add("config.small_bag_capacity", "小型背包总槽位数量(含手持格)");
				dictionary.Add("config.medium_bag_capacity", "中型背包总槽位数量(含手持格)");
				dictionary.Add("config.large_bag_capacity", "大型背包总槽位数量(含手持格)");
				dictionary.Add("config.slots_per_row", "每行最大槽位数量(含手持格)\n超出后换行,避免挡住小地图。一行最多20格");
				dictionary.Add("config.bag_highlight_color", "背包高亮框颜色(留空使用游戏默认颜色,支持 #RRGGBB 或 #RRGGBBAA)");
				break;
			case "zh-TW":
				dictionary.Add("plugin.initializing", "開始初始化...");
				dictionary.Add("plugin.author_prefix", "作者:");
				dictionary.Add("plugin.initialized", "初始化成功!");
				dictionary.Add("plugin.patches_skipped", "補丁已套用,跳過...");
				dictionary.Add("plugin.name", "大背包");
				dictionary.Add("plugin.description", "增加三種背包的背包容量並支援調整選擇框顏色。");
				dictionary.Add("config.small_bag_capacity", "小型背包總槽位數量(含手持格)");
				dictionary.Add("config.medium_bag_capacity", "中型背包總槽位數量(含手持格)");
				dictionary.Add("config.large_bag_capacity", "大型背包總槽位數量(含手持格)");
				dictionary.Add("config.slots_per_row", "每行最大槽位數量(含手持格)\n超出後換行,避免擋住小地圖。一行最多20格");
				dictionary.Add("config.bag_highlight_color", "背包高亮框顏色(留空使用遊戲預設顏色,支援 #RRGGBB 或 #RRGGBBAA)");
				break;
			case "en":
				dictionary.Add("plugin.initializing", "Initializing...");
				dictionary.Add("plugin.author_prefix", "Author: ");
				dictionary.Add("plugin.initialized", "Initialized successfully!");
				dictionary.Add("plugin.patches_skipped", "Patches already applied, skipping...");
				dictionary.Add("plugin.name", "Big Bag");
				dictionary.Add("plugin.description", "Increases the capacity of three bag types and supports adjusting the selection frame color.");
				dictionary.Add("config.small_bag_capacity", "Total slots for Small Bag (including held slot)");
				dictionary.Add("config.medium_bag_capacity", "Total slots for Medium Bag (including held slot)");
				dictionary.Add("config.large_bag_capacity", "Total slots for Large Bag (including held slot)");
				dictionary.Add("config.slots_per_row", "Max slots per row (including held slot)\nWraps to a new row so extra slots don't cover the minimap. At most 20 slots per row");
				dictionary.Add("config.bag_highlight_color", "Bag highlight color (leave empty to use the game default, supports #RRGGBB or #RRGGBBAA)");
				break;
			case "ja":
				dictionary.Add("plugin.initializing", "初期化中...");
				dictionary.Add("plugin.author_prefix", "作者: ");
				dictionary.Add("plugin.initialized", "初期化に成功しました!");
				dictionary.Add("plugin.patches_skipped", "パッチは適用済みです。スキップします...");
				dictionary.Add("plugin.name", "ビッグバッグ");
				dictionary.Add("plugin.description", "3種類のバッグ容量を増やし、選択枠の色も調整できます。");
				dictionary.Add("config.small_bag_capacity", "小型バッグの総スロット数(手持ち枠を含む)");
				dictionary.Add("config.medium_bag_capacity", "中型バッグの総スロット数(手持ち枠を含む)");
				dictionary.Add("config.large_bag_capacity", "大型バッグの総スロット数(手持ち枠を含む)");
				dictionary.Add("config.slots_per_row", "1行あたりの最大スロット数(手持ち枠を含む)\n超えた分は折り返し、ミニマップを隠さない。1行最大20スロット");
				dictionary.Add("config.bag_highlight_color", "バッグのハイライト枠色(空欄でゲーム既定色、#RRGGBB または #RRGGBBAA 対応)");
				break;
			}
			return dictionary;
		}
	}
	public class LocalizationManager
	{
		private static LocalizationManager _instance;

		private readonly Dictionary<string, Dictionary<string, string>> _localizations = new Dictionary<string, Dictionary<string, string>>();

		private string _currentLocale = "zh";

		public static readonly string[] SupportedLanguages = new string[16]
		{
			"en", "tr", "fr", "es", "zh", "zh-TW", "de", "el", "pt-BR", "it",
			"ja", "pl", "pt-PT", "ru", "ko", "th"
		};

		public static LocalizationManager Instance => _instance ?? (_instance = new LocalizationManager());

		private LocalizationManager()
		{
			Initialize();
		}

		public void Initialize()
		{
			RefreshCurrentLocale();
			string[] supportedLanguages = SupportedLanguages;
			foreach (string text in supportedLanguages)
			{
				Dictionary<string, string> defaultTranslations = LocalizationHelper.GetDefaultTranslations(text);
				if (defaultTranslations != null && defaultTranslations.Count > 0)
				{
					_localizations[text] = defaultTranslations;
				}
			}
		}

		private void RefreshCurrentLocale()
		{
			if (PlayerPrefs.HasKey("Lang"))
			{
				int num = PlayerPrefs.GetInt("Lang");
				ILocalesProvider availableLocales = LocalizationSettings.AvailableLocales;
				if (availableLocales != null && availableLocales.Locales != null && num >= 0 && num < availableLocales.Locales.Count)
				{
					string code = availableLocales.Locales[num].Identifier.Code;
					_currentLocale = (_localizations.ContainsKey(code) ? code : "en");
				}
			}
		}

		public string GetLocalizedText(string key, params object[] args)
		{
			RefreshCurrentLocale();
			if (string.IsNullOrEmpty(_currentLocale) || !_localizations.ContainsKey(_currentLocale))
			{
				_currentLocale = "en";
			}
			if (_localizations.ContainsKey(_currentLocale) && _localizations[_currentLocale].TryGetValue(key, out var value))
			{
				return (args.Length != 0) ? string.Format(value, args) : value;
			}
			if (_currentLocale != "en" && _localizations.ContainsKey("en") && _localizations["en"].TryGetValue(key, out var value2))
			{
				return (args.Length != 0) ? string.Format(value2, args) : value2;
			}
			if (_localizations.ContainsKey("zh") && _localizations["zh"].TryGetValue(key, out var value3))
			{
				return (args.Length != 0) ? string.Format(value3, args) : value3;
			}
			return key;
		}
	}
}
namespace BigBag.Configuration
{
	public class ConfigManager
	{
		private static ConfigManager _instance;

		private readonly ConfigFile _configFile;

		private readonly Dictionary<string, ConfigEntry<bool>> _boolConfigs = new Dictionary<string, ConfigEntry<bool>>();

		private readonly Dictionary<string, ConfigEntry<string>> _stringConfigs = new Dictionary<string, ConfigEntry<string>>();

		private readonly Dictionary<string, ConfigEntry<int>> _intConfigs = new Dictionary<string, ConfigEntry<int>>();

		private readonly Dictionary<string, ConfigEntry<float>> _floatConfigs = new Dictionary<string, ConfigEntry<float>>();

		private readonly Dictionary<string, ConfigEntry<KeyCode>> _keyCodeConfigs = new Dictionary<string, ConfigEntry<KeyCode>>();

		public static ConfigManager Instance => _instance;

		public ConfigEntry<int> SmallBagCapacity { get; private set; }

		public ConfigEntry<int> MediumBagCapacity { get; private set; }

		public ConfigEntry<int> LargeBagCapacity { get; private set; }

		public ConfigEntry<int> SlotsPerRow { get; private set; }

		public ConfigEntry<string> BagHighlightColor { get; private set; }

		private ConfigManager(ConfigFile configFile)
		{
			_configFile = configFile;
			InitializeDefaultConfigs();
		}

		public static void Initialize(ConfigFile configFile)
		{
			if (_instance == null)
			{
				_instance = new ConfigManager(configFile);
			}
		}

		private void InitializeDefaultConfigs()
		{
			SmallBagCapacity = RegisterIntMax("背包扩容 - Bag Capacity", "SmallBagCapacity", GetLocalizedDescription("config.small_bag_capacity"), 4, 1, 240);
			MediumBagCapacity = RegisterIntMax("背包扩容 - Bag Capacity", "MediumBagCapacity", GetLocalizedDescription("config.medium_bag_capacity"), 5, 1, 240);
			LargeBagCapacity = RegisterIntMax("背包扩容 - Bag Capacity", "LargeBagCapacity", GetLocalizedDescription("config.large_bag_capacity"), 6, 1, 240);
			SlotsPerRow = RegisterIntMax("背包扩容 - Bag Capacity", "SlotsPerRow", GetLocalizedDescription("config.slots_per_row"), 20, 2, 20);
			BagHighlightColor = RegisterString("背包高亮 - Bag Highlight", "BagHighlightColor", GetLocalizedDescription("config.bag_highlight_color"), "");
		}

		private string GetLocalizedDescription(string key)
		{
			return LocalizationManager.Instance?.GetLocalizedText(key) ?? key;
		}

		public ConfigEntry<bool> RegisterBool(string section, string key, string description, bool defaultValue)
		{
			ConfigEntry<bool> val = _configFile.Bind<bool>(section, key, defaultValue, description);
			_boolConfigs[key] = val;
			return val;
		}

		public ConfigEntry<string> RegisterString(string section, string key, string description, string defaultValue)
		{
			ConfigEntry<string> val = _configFile.Bind<string>(section, key, defaultValue, description);
			_stringConfigs[key] = val;
			return val;
		}

		public ConfigEntry<KeyCode> RegisterKeyCode(string section, string key, string description, KeyCode defaultValue)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			ConfigEntry<KeyCode> val = _configFile.Bind<KeyCode>(section, key, defaultValue, description);
			_keyCodeConfigs[key] = val;
			return val;
		}

		public ConfigEntry<int> RegisterInt(string section, string key, string description, int defaultValue)
		{
			ConfigEntry<int> val = _configFile.Bind<int>(section, key, defaultValue, description);
			_intConfigs[key] = val;
			return val;
		}

		public ConfigEntry<int> RegisterIntMax(string section, string key, string description, int defaultValue, int minValue, int maxValue)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			ConfigEntry<int> val = _configFile.Bind<int>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<int>(minValue, maxValue), Array.Empty<object>()));
			_intConfigs[key] = val;
			return val;
		}

		public ConfigEntry<float> RegisterFloat(string section, string key, string description, float defaultValue)
		{
			ConfigEntry<float> val = _configFile.Bind<float>(section, key, defaultValue, description);
			_floatConfigs[key] = val;
			return val;
		}

		public ConfigEntry<float> RegisterFloatMax(string section, string key, string description, float defaultValue, float minValue, float maxValue)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			ConfigEntry<float> val = _configFile.Bind<float>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(minValue, maxValue), Array.Empty<object>()));
			_floatConfigs[key] = val;
			return val;
		}
	}
}