Decompiled source of SimpleMarket v0.9.4
SimpleMarket.dll
Decompiled 12 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using ServerSync; using SimpleMarket.Config; using SimpleMarket.Data; using SimpleMarket.Helpers; using SimpleMarket.Network; using SimpleMarket.Patches; using SimpleMarket.UI; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.UI; [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("SimpleMarket")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyProduct("SimpleMarket")] [assembly: AssemblyTitle("SimpleMarket")] [assembly: AssemblyInformationalVersion("0.9.4")] [assembly: AssemblyDescription("Valheim Mod")] [assembly: AssemblyFileVersion("0.9.4.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.9.4.0")] [module: UnverifiableCode] [module: <cd061f31-2be8-4f4a-ba1e-eae7540b850a>RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<a26c31ca-427a-4779-92be-fbba90a42685>Embedded] internal sealed class <a26c31ca-427a-4779-92be-fbba90a42685>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [<a26c31ca-427a-4779-92be-fbba90a42685>Embedded] [CompilerGenerated] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class <cd061f31-2be8-4f4a-ba1e-eae7540b850a>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <cd061f31-2be8-4f4a-ba1e-eae7540b850a>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SimpleMarket { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("dumba.simplemarket", "SimpleMarket", "0.9.4")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class SimpleMarketPlugin : BaseUnityPlugin { public const string PluginGUID = "dumba.simplemarket"; public const string PluginName = "SimpleMarket"; public const string PluginVersion = "0.9.4"; private Harmony _harmony; private MarketUI _marketUI; private Coroutine _expiryCleanupCoroutine; private const float ExpiryCheckIntervalHours = 1f; public static SimpleMarketPlugin Instance { get; private set; } public static ManualLogSource Log { get { SimpleMarketPlugin instance = Instance; if (instance == null) { return null; } return ((BaseUnityPlugin)instance).Logger; } } public MarketDatabase MarketDB { get; private set; } public BankDatabase BankDB { get; private set; } public TransactionDatabase TransactionDB { get; private set; } private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown Instance = this; SimpleMarketConfig.Initialize(((BaseUnityPlugin)this).Config); LogInfo("SimpleMarket is loading..."); _harmony = new Harmony("dumba.simplemarket"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); MarketRPCs.RegisterRPCs(); SubscribeToRPCEvents(); PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable; InitializeUI(); LogInfo("SimpleMarket loaded successfully!"); } private void Start() { ((MonoBehaviour)this).StartCoroutine(WaitForServerAndInitialize()); } private IEnumerator WaitForServerAndInitialize() { while ((Object)(object)ZNet.instance == (Object)null) { yield return (object)new WaitForSeconds(1f); } yield return (object)new WaitForSeconds(2f); if (ZNet.instance.IsServer()) { LogInfo("Server detected - initializing databases..."); InitializeDatabases(); } else { LogInfo("Client mode - skipping database initialization"); } } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; if (_expiryCleanupCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_expiryCleanupCoroutine); _expiryCleanupCoroutine = null; } UnsubscribeFromRPCEvents(); if ((Object)(object)_marketUI != (Object)null) { Object.Destroy((Object)(object)_marketUI); _marketUI = null; } InventoryGuiPatch.Cleanup(); } private void OnVanillaPrefabsAvailable() { if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { InitializeDatabases(); } } private void InitializeUI() { if (GUIManager.IsHeadless()) { LogInfo("Headless server detected - skipping UI initialization"); return; } _marketUI = ((Component)this).gameObject.AddComponent<MarketUI>(); _marketUI.Initialize(); LogInfo("Market UI system initialized"); } public MarketUI GetMarketUI() { return _marketUI; } public void InitializeDatabases() { if (MarketDB == null) { MarketDB = new MarketDatabase(); LogInfo("Market database initialized"); } if (BankDB == null) { BankDB = new BankDatabase(); LogInfo("Bank database initialized"); } if (TransactionDB == null) { TransactionDB = new TransactionDatabase(); LogInfo("Transaction database initialized"); } StartExpiryCleanupTask(); } public bool EnsureDatabasesInitialized() { if (!IsServer()) { return false; } if (MarketDB == null || BankDB == null || TransactionDB == null) { LogInfo("Lazy-initializing databases on server (triggered by RPC)"); InitializeDatabases(); } if (MarketDB != null && BankDB != null) { return TransactionDB != null; } return false; } private void StartExpiryCleanupTask() { if (_expiryCleanupCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_expiryCleanupCoroutine); } _expiryCleanupCoroutine = ((MonoBehaviour)this).StartCoroutine(ExpiryCleanupCoroutine()); LogInfo($"Started listing expiry cleanup task (interval: {1f} hour(s))"); } private IEnumerator ExpiryCleanupCoroutine() { yield return (object)new WaitForSeconds(60f); while (true) { if (IsServer() && MarketDB != null) { int num = SimpleMarketConfig.ListingExpiryDays?.Value ?? 180; if (num > 0) { int num2 = MarketDB.CleanupExpiredListings(); if (num2 > 0) { LogInfo($"Cleaned up {num2} expired listings (older than {num} days)"); } else { LogDebug("Expiry cleanup: No expired listings found"); } } } yield return (object)new WaitForSeconds(3600f); } } public static bool IsServer() { if ((Object)(object)ZNet.instance != (Object)null) { return ZNet.instance.IsServer(); } return false; } public static bool IsInGame() { if ((Object)(object)Player.m_localPlayer != (Object)null) { return (Object)(object)ZNet.instance != (Object)null; } return false; } public static void LogInfo(string message) { if (Log != null) { Log.LogInfo((object)message); } } public static void LogWarning(string message) { if (Log != null) { Log.LogWarning((object)message); } } public static void LogError(string message) { if (Log != null) { Log.LogError((object)message); } } public static void LogDebug(string message) { if (SimpleMarketConfig.DebugLogging != null && SimpleMarketConfig.DebugLogging.Value && Log != null) { Log.LogDebug((object)message); } } private void SubscribeToRPCEvents() { MarketRPCs.OnListingsReceived += HandleListingsReceived; MarketRPCs.OnMyListingsReceived += HandleMyListingsReceived; MarketRPCs.OnBankBalanceReceived += HandleBankBalanceReceived; MarketRPCs.OnListItemResult += HandleListItemResult; MarketRPCs.OnBuyItemResult += HandleBuyItemResult; MarketRPCs.OnCancelListingResult += HandleCancelListingResult; MarketRPCs.OnDepositResult += HandleDepositResult; MarketRPCs.OnWithdrawResult += HandleWithdrawResult; MarketRPCs.OnTransactionHistoryReceived += HandleTransactionHistoryReceived; } private void UnsubscribeFromRPCEvents() { MarketRPCs.OnListingsReceived -= HandleListingsReceived; MarketRPCs.OnMyListingsReceived -= HandleMyListingsReceived; MarketRPCs.OnBankBalanceReceived -= HandleBankBalanceReceived; MarketRPCs.OnListItemResult -= HandleListItemResult; MarketRPCs.OnBuyItemResult -= HandleBuyItemResult; MarketRPCs.OnCancelListingResult -= HandleCancelListingResult; MarketRPCs.OnDepositResult -= HandleDepositResult; MarketRPCs.OnWithdrawResult -= HandleWithdrawResult; MarketRPCs.OnTransactionHistoryReceived -= HandleTransactionHistoryReceived; } private void HandleListingsReceived(List<MarketListing> listings, int totalCount, int totalPages) { LogDebug($"Received {listings.Count} listings (total: {totalCount}, pages: {totalPages})"); _marketUI?.OnListingsReceived(listings, totalCount, totalPages); } private void HandleMyListingsReceived(List<MarketListing> listings) { LogDebug($"Received {listings.Count} of my listings"); _marketUI?.OnListingsReceived(listings, listings.Count, 1); } private void HandleBankBalanceReceived(int balance) { LogDebug($"Received bank balance: {balance}"); _marketUI?.OnBankBalanceReceived(balance); } private void HandleListItemResult(bool success, string message) { LogDebug($"List item result: {success} - {message}"); _marketUI?.OnListItemComplete(success, message); } private void HandleBuyItemResult(bool success, string message, MarketListing purchasedListing) { LogDebug($"Buy item result: {success} - {message}"); if (success && purchasedListing != null) { DeliverPurchasedItem(purchasedListing); } _marketUI?.OnBuyComplete(success, message); } private void HandleCancelListingResult(bool success, string message, MarketListing cancelledListing) { LogDebug($"Cancel listing result: {success} - {message}"); if (success && cancelledListing != null) { ReturnCancelledItem(cancelledListing); } _marketUI?.OnCancelComplete(success, message); } private void ReturnCancelledItem(MarketListing listing) { if (listing == null) { LogWarning("Cannot return null listing"); return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { LogError("Cannot return item - no local player"); return; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory == null) { LogError("Cannot return item - no inventory"); return; } string localizedName = ItemHelper.GetLocalizedName(listing.ItemPrefabName); if (ItemHelper.AddItemToInventory(inventory, listing.ItemPrefabName, listing.Quality, listing.Quantity, listing.ItemData)) { LogInfo($"Returned {listing.Quantity}x {localizedName} to player from cancelled listing"); FeedbackHelper.ShowSuccess($"Returned {listing.Quantity}x {localizedName}"); return; } LogWarning($"Inventory full - dropping {listing.Quantity}x {localizedName} at player's feet"); if (DropItemAtPlayer(listing)) { FeedbackHelper.ShowError("Inventory full - " + localizedName + " dropped at your feet!"); return; } LogError($"CRITICAL: Failed to drop {listing.Quantity}x {localizedName} - item may be lost!"); FeedbackHelper.ShowError("Failed to return " + localizedName + " - contact server admin!"); } private bool DropItemAtPlayer(MarketListing listing) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_0091: Unknown result type (might be due to invalid IL or missing references) try { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return false; } ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(listing.ItemPrefabName) : null); if ((Object)(object)val == (Object)null) { LogError("DropItemAtPlayer: Cannot find prefab for " + listing.ItemPrefabName); return false; } Vector3 val2 = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 1.5f + Vector3.up * 0.5f; GameObject val3 = Object.Instantiate<GameObject>(val, val2, Quaternion.identity); if ((Object)(object)val3 == (Object)null) { return false; } ItemDrop component = val3.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { component.m_itemData.m_stack = listing.Quantity; component.m_itemData.m_quality = listing.Quality; if (!string.IsNullOrEmpty(listing.ItemData)) { ItemSerializationHelper.Deserialize(component.m_itemData, listing.ItemData); } LogInfo($"Dropped {listing.Quantity}x {listing.ItemPrefabName} at player's feet"); return true; } Object.Destroy((Object)(object)val3); return false; } catch (Exception ex) { LogError("DropItemAtPlayer exception: " + ex.Message); return false; } } private void HandleDepositResult(bool success, string message, int newBalance) { LogDebug($"Deposit result: {success} - {message}, new balance: {newBalance}"); _marketUI?.OnDepositComplete(success, newBalance, message); } private void HandleWithdrawResult(bool success, string message, int newBalance, int withdrawnAmount) { LogDebug($"Withdraw result: {success} - {message}, new balance: {newBalance}, withdrawn: {withdrawnAmount}"); if (success && withdrawnAmount > 0) { DeliverCoins(withdrawnAmount); } _marketUI?.OnWithdrawComplete(success, newBalance, message); } private void HandleTransactionHistoryReceived(List<TransactionRecord> transactions, int totalCount, int totalPages) { LogDebug($"Received {transactions.Count} transactions (total: {totalCount}, pages: {totalPages})"); _marketUI?.OnTransactionHistoryReceived(transactions, totalCount, totalPages); } private void DeliverCoins(int amount) { if (amount <= 0) { return; } if ((Object)(object)Player.m_localPlayer == (Object)null) { LogError("Cannot deliver coins - no local player"); return; } if (PlayerHelper.GiveCoins(amount)) { LogInfo($"Delivered {amount} coins to player"); FeedbackHelper.ShowSuccess($"Received {amount} coins"); return; } LogError("Failed to deliver coins to inventory - attempting rollback to bank"); string platformId = PlayerHelper.GetPlatformId(); if (!string.IsNullOrEmpty(platformId)) { MarketRPCs.RequestDeposit(platformId, amount); FeedbackHelper.ShowError("Inventory full - coins returned to bank!"); LogInfo($"Rolled back {amount} coins to bank for {platformId}"); } else { LogError($"CRITICAL: Could not rollback {amount} coins - no platform ID!"); FeedbackHelper.ShowError("Inventory full - item could not be delivered"); } } private void DeliverPurchasedItem(MarketListing listing) { if (listing == null) { LogWarning("Cannot deliver null listing"); return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { LogError("Cannot deliver item - no local player"); return; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory == null) { LogError("Cannot deliver item - no inventory"); return; } string localizedName = ItemHelper.GetLocalizedName(listing.ItemPrefabName); if (ItemHelper.AddItemToInventory(inventory, listing.ItemPrefabName, listing.Quality, listing.Quantity, listing.ItemData)) { LogInfo($"Delivered {listing.Quantity}x {localizedName} to player"); FeedbackHelper.ShowSuccess($"Received {listing.Quantity}x {localizedName}"); return; } LogError($"Failed to deliver {listing.Quantity}x {localizedName} to inventory - attempting refund"); int totalPrice = listing.GetTotalPrice(); string platformId = PlayerHelper.GetPlatformId(); if (!string.IsNullOrEmpty(platformId) && totalPrice > 0) { MarketRPCs.RequestDeposit(platformId, totalPrice); FeedbackHelper.ShowError($"Inventory full - {totalPrice} coins refunded to bank!"); LogInfo($"Refunded {totalPrice} coins to bank for failed item delivery: {localizedName}"); } else { LogError($"CRITICAL: Could not refund {totalPrice} coins for {localizedName} - no platform ID!"); FeedbackHelper.ShowError("Inventory full - item could not be delivered"); } } } } namespace SimpleMarket.UI { public class BankPanel : MonoBehaviour { private GameObject _container; private Text _balanceText; private InputField _amountInput; private Button _depositButton; private Button _withdrawButton; private Button _depositAllButton; private Button _withdrawAllButton; private Text _inventoryCoinsText; private int _currentBalance; private int _inventoryCoins; private const int MaxCoinStack = 999; public event Action<int> OnDepositRequested; public event Action<int> OnWithdrawRequested; public static BankPanel Create(Transform parent, Vector2 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0029: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("BankPanel"); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 1f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(0.5f, 1f); obj.anchoredPosition = position; obj.sizeDelta = new Vector2(-40f, 55f); ((Graphic)val.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.2f); BankPanel bankPanel = val.AddComponent<BankPanel>(); bankPanel._container = val; bankPanel.CreateUI(); return bankPanel; } private void CreateUI() { CreateBalanceDisplay(); CreateAmountInput(); CreateActionButtons(); CreateInventoryDisplay(); } private void CreateBalanceDisplay() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00e5: Unknown result type (might be due to invalid IL or missing references) ((Object)GUIManager.Instance.CreateText("\ud83d\udcb0", _container.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(25f, 0f), GUIManager.Instance.AveriaSerifBold, 20, new Color(1f, 0.85f, 0f), false, Color.black, 30f, 30f, false)).name = "BankIcon"; GameObject val = GUIManager.Instance.CreateText("Bank: 0", _container.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(110f, 0f), GUIManager.Instance.AveriaSerifBold, 18, new Color(1f, 0.85f, 0f), true, Color.black, 150f, 30f, false); ((Object)val).name = "BankBalanceText"; _balanceText = val.GetComponent<Text>(); if ((Object)(object)_balanceText != (Object)null) { _balanceText.alignment = (TextAnchor)3; } } private void CreateAmountInput() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) ((Object)GUIManager.Instance.CreateText("Amount:", _container.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-120f, 0f), GUIManager.Instance.AveriaSerif, 14, Color.white, false, Color.black, 60f, 25f, false)).name = "AmountLabel"; GameObject val = GUIManager.Instance.CreateInputField(_container.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-50f, 0f), (ContentType)2, "0", 14, 80f, 30f); ((Object)val).name = "AmountInput"; _amountInput = val.GetComponent<InputField>(); } private void CreateActionButtons() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown GameObject val = GUIManager.Instance.CreateButton("Deposit", _container.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(40f, 0f), 80f, 30f); ((Object)val).name = "DepositButton"; _depositButton = val.GetComponent<Button>(); if ((Object)(object)_depositButton != (Object)null) { ((UnityEvent)_depositButton.onClick).AddListener(new UnityAction(OnDepositClicked)); } GameObject val2 = GUIManager.Instance.CreateButton("All", _container.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(95f, 0f), 35f, 30f); ((Object)val2).name = "DepositAllButton"; _depositAllButton = val2.GetComponent<Button>(); if ((Object)(object)_depositAllButton != (Object)null) { ((UnityEvent)_depositAllButton.onClick).AddListener(new UnityAction(OnDepositAllClicked)); } Text componentInChildren = val2.GetComponentInChildren<Text>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.fontSize = 11; } GameObject val3 = GUIManager.Instance.CreateButton("Withdraw", _container.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(170f, 0f), 90f, 30f); ((Object)val3).name = "WithdrawButton"; _withdrawButton = val3.GetComponent<Button>(); if ((Object)(object)_withdrawButton != (Object)null) { ((UnityEvent)_withdrawButton.onClick).AddListener(new UnityAction(OnWithdrawClicked)); } GameObject val4 = GUIManager.Instance.CreateButton("999", _container.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(230f, 0f), 35f, 30f); ((Object)val4).name = "WithdrawMaxButton"; _withdrawAllButton = val4.GetComponent<Button>(); if ((Object)(object)_withdrawAllButton != (Object)null) { ((UnityEvent)_withdrawAllButton.onClick).AddListener(new UnityAction(OnWithdrawAllClicked)); } Text componentInChildren2 = val4.GetComponentInChildren<Text>(); if ((Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.fontSize = 11; } } private void CreateInventoryDisplay() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) GameObject val = GUIManager.Instance.CreateText("Inventory: 0 coins", _container.transform, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-90f, 0f), GUIManager.Instance.AveriaSerif, 13, new Color(0.8f, 0.8f, 0.8f), false, Color.black, 150f, 25f, false); ((Object)val).name = "InventoryCoinsText"; _inventoryCoinsText = val.GetComponent<Text>(); if ((Object)(object)_inventoryCoinsText != (Object)null) { _inventoryCoinsText.alignment = (TextAnchor)5; } } public void UpdateBalance(int balance) { _currentBalance = balance; if ((Object)(object)_balanceText != (Object)null) { _balanceText.text = $"Bank: {balance:N0}"; } } public void UpdateInventoryCoins(int coins) { _inventoryCoins = coins; if ((Object)(object)_inventoryCoinsText != (Object)null) { _inventoryCoinsText.text = $"Inventory: {coins:N0} coins"; } } public void RefreshInventoryCoins() { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); if (inventory != null) { int coins = inventory.CountItems("$item_coins", -1, true); UpdateInventoryCoins(coins); } } } private int GetInputAmount() { if ((Object)(object)_amountInput == (Object)null || string.IsNullOrEmpty(_amountInput.text)) { return 0; } if (int.TryParse(_amountInput.text, out var result)) { return Math.Max(0, result); } return 0; } private void OnDepositClicked() { int inputAmount = GetInputAmount(); if (inputAmount > 0) { if (inputAmount > _inventoryCoins) { FeedbackHelper.ShowError("Not enough coins in inventory"); } else { this.OnDepositRequested?.Invoke(inputAmount); } } else { FeedbackHelper.ShowWarning("Enter an amount to deposit"); } } private void OnDepositAllClicked() { if (_inventoryCoins > 0) { this.OnDepositRequested?.Invoke(_inventoryCoins); } else { FeedbackHelper.ShowWarning("No coins in inventory"); } } private void OnWithdrawClicked() { int inputAmount = GetInputAmount(); if (inputAmount > 0) { inputAmount = Math.Min(inputAmount, 999); if (inputAmount > _currentBalance) { FeedbackHelper.ShowError("Not enough coins in bank"); } else { this.OnWithdrawRequested?.Invoke(inputAmount); } } else { FeedbackHelper.ShowWarning("Enter an amount to withdraw"); } } private void OnWithdrawAllClicked() { if (_currentBalance > 0) { int obj = Math.Min(_currentBalance, 999); this.OnWithdrawRequested?.Invoke(obj); } else { FeedbackHelper.ShowWarning("No coins in bank"); } } public void ClearInput() { if ((Object)(object)_amountInput != (Object)null) { _amountInput.text = ""; } } private void OnDestroy() { if ((Object)(object)_depositButton != (Object)null) { ((UnityEventBase)_depositButton.onClick).RemoveAllListeners(); } if ((Object)(object)_withdrawButton != (Object)null) { ((UnityEventBase)_withdrawButton.onClick).RemoveAllListeners(); } if ((Object)(object)_depositAllButton != (Object)null) { ((UnityEventBase)_depositAllButton.onClick).RemoveAllListeners(); } if ((Object)(object)_withdrawAllButton != (Object)null) { ((UnityEventBase)_withdrawAllButton.onClick).RemoveAllListeners(); } } } public class CategoryButtons : MonoBehaviour { private GameObject _container; private List<GameObject> _categoryButtons = new List<GameObject>(); private Dictionary<string, Button> _buttonMap = new Dictionary<string, Button>(); private string _selectedCategory = "All"; private static readonly Color SelectedColor = new Color(1f, 0.8f, 0.2f, 1f); private static readonly Color UnselectedColor = new Color(0.8f, 0.8f, 0.8f, 1f); public string SelectedCategory => _selectedCategory; public event Action<string> OnCategorySelected; public static CategoryButtons Create(Transform parent, Vector2 position, float width) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0029: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("CategoryButtonsContainer"); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 1f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(0.5f, 1f); obj.anchoredPosition = position; obj.sizeDelta = new Vector2(-40f, 80f); CategoryButtons categoryButtons = val.AddComponent<CategoryButtons>(); categoryButtons._container = val; categoryButtons.CreateButtons(); return categoryButtons; } private void CreateButtons() { GameObject val = CreateButtonRow("Row1", 0f); GameObject val2 = CreateButtonRow("Row2", -40f); List<string> categoriesList = SimpleMarketConfig.GetCategoriesList(); float num = 100f; float height = 32f; float spacing = 5f; int num2 = 7; int num3 = 0; CreateCategoryButton(val.transform, "All", num3, num, height, spacing, num2); _selectedCategory = "All"; num3++; foreach (string item in categoriesList) { Transform parent = ((num3 < num2) ? val.transform : val2.transform); int index = ((num3 < num2) ? num3 : (num3 - num2)); CreateCategoryButton(parent, item, index, num, height, spacing, num2); num3++; if (num3 >= num2 * 2 - 2) { break; } } float width = num + 20f; float width2 = num; CreateCategoryButton(val2.transform, "My History", 0, width2, height, spacing, num2, alignRight: true, 55f); CreateCategoryButton(val2.transform, "My Listings", 0, width, height, spacing, num2, alignRight: true); UpdateButtonStates(); } private GameObject CreateButtonRow(string name, float yOffset) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_002e: 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) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(_container.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 1f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(0.5f, 1f); obj.anchoredPosition = new Vector2(0f, yOffset); obj.sizeDelta = new Vector2(0f, 35f); return val; } private void CreateCategoryButton(Transform parent, string category, int index, float width, float height, float spacing, int buttonsPerRow, bool alignRight = false, float rightOffset = 0f) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown float num = (float)buttonsPerRow * (width + spacing) - spacing; float num2 = (0f - num) / 2f + width / 2f; float num3 = ((!alignRight) ? (num2 + (float)index * (width + spacing)) : (num / 2f - width / 2f - 10f - rightOffset)); GameObject val = GUIManager.Instance.CreateButton(category, parent, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(num3, 0f), width, height); ((Object)val).name = "CategoryBtn_" + category.Replace(" ", ""); _categoryButtons.Add(val); Button component = val.GetComponent<Button>(); if ((Object)(object)component != (Object)null) { string cat = category; ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { SelectCategory(cat); }); _buttonMap[category] = component; } Text componentInChildren = val.GetComponentInChildren<Text>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.fontSize = ((category.Length > 10) ? 11 : 13); componentInChildren.fontStyle = (FontStyle)1; } } public void SelectCategory(string category) { if (!(_selectedCategory == category)) { _selectedCategory = category; UpdateButtonStates(); this.OnCategorySelected?.Invoke(category); SimpleMarketPlugin.LogDebug("Category selected: " + category); } } private void UpdateButtonStates() { //IL_004a: 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) foreach (KeyValuePair<string, Button> item in _buttonMap) { Text componentInChildren = ((Component)item.Value).GetComponentInChildren<Text>(); if ((Object)(object)componentInChildren != (Object)null) { bool flag = item.Key == _selectedCategory; ((Graphic)componentInChildren).color = (flag ? SelectedColor : UnselectedColor); if (flag) { componentInChildren.fontStyle = (FontStyle)1; } else { componentInChildren.fontStyle = (FontStyle)0; } } } } public void Reset() { SelectCategory("All"); } public void RebuildButtons() { string selectedCategory = _selectedCategory; foreach (GameObject categoryButton in _categoryButtons) { if ((Object)(object)categoryButton != (Object)null) { Object.Destroy((Object)(object)categoryButton); } } _categoryButtons.Clear(); _buttonMap.Clear(); Transform val = _container.transform.Find("Row1"); Transform val2 = _container.transform.Find("Row2"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)((Component)val2).gameObject); } CreateButtons(); if (_buttonMap.ContainsKey(selectedCategory)) { _selectedCategory = selectedCategory; UpdateButtonStates(); } else { _selectedCategory = "All"; UpdateButtonStates(); } SimpleMarketPlugin.LogDebug("Category buttons rebuilt. Categories: " + string.Join(",", SimpleMarketConfig.GetCategoriesList())); } private void OnDestroy() { foreach (GameObject categoryButton in _categoryButtons) { if ((Object)(object)categoryButton != (Object)null) { Object.Destroy((Object)(object)categoryButton); } } _categoryButtons.Clear(); _buttonMap.Clear(); } } public class HistoryPanel : MonoBehaviour { private GameObject _container; private ScrollRect _scrollRect; private Text _emptyText; private Text _pageInfoText; private Button _prevButton; private Button _nextButton; private List<TransactionRow> _transactionRows = new List<TransactionRow>(); private string _currentPlatformId; private List<TransactionRecord> _transactions = new List<TransactionRecord>(); private int _currentPage; private int _totalPages = 1; private int _totalCount; private const float RowHeight = 60f; private const float Padding = 10f; private int _pageSize = 10; public static HistoryPanel Create(Transform parent, string platformId) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001f: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("HistoryPanel"); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; HistoryPanel historyPanel = val.AddComponent<HistoryPanel>(); historyPanel._container = val; historyPanel._currentPlatformId = platformId; historyPanel._pageSize = SimpleMarketConfig.TransactionHistoryPageSize.Value; historyPanel.CreateUI(); return historyPanel; } private void CreateUI() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) GUIManager.Instance.CreateText("Transaction History", _container.transform, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, -20f), GUIManager.Instance.AveriaSerifBold, 18, GUIManager.Instance.ValheimOrange, true, Color.black, 300f, 30f, false).GetComponent<Text>().alignment = (TextAnchor)4; CreateScrollArea(); _emptyText = CreateCenteredText("No transaction history yet.\nPurchases and sales will appear here.", new Color(0.6f, 0.6f, 0.6f), 14); CreatePaginationControls(); } private void CreateScrollArea() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ScrollView"); val.transform.SetParent(_container.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 0f); obj.anchorMax = new Vector2(1f, 1f); obj.offsetMin = new Vector2(10f, 50f); obj.offsetMax = new Vector2(-25f, -50f); ScrollRect val2 = val.AddComponent<ScrollRect>(); val2.horizontal = false; val2.vertical = true; val2.movementType = (MovementType)2; val2.scrollSensitivity = 50f; ((Graphic)val.AddComponent<Image>()).color = new Color(0.1f, 0.1f, 0.1f, 0.3f); val.AddComponent<Mask>().showMaskGraphic = true; GameObject val3 = new GameObject("Viewport"); val3.transform.SetParent(val.transform, false); RectTransform val4 = val3.AddComponent<RectTransform>(); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; GameObject val5 = new GameObject("Content"); val5.transform.SetParent(val3.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = new Vector2(0f, 1f); val6.anchorMax = new Vector2(1f, 1f); val6.pivot = new Vector2(0.5f, 1f); val6.anchoredPosition = Vector2.zero; val6.sizeDelta = new Vector2(0f, 0f); val2.viewport = val4; val2.content = val6; _scrollRect = val2; CreateVerticalScrollbar(); } private void CreateVerticalScrollbar() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("VerticalScrollbar"); val.transform.SetParent(_container.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(1f, 0f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(1f, 0.5f); obj.anchoredPosition = new Vector2(-5f, 0f); obj.sizeDelta = new Vector2(15f, 0f); obj.offsetMin = new Vector2(-20f, 50f); obj.offsetMax = new Vector2(-5f, -50f); ((Graphic)val.AddComponent<Image>()).color = new Color(0.15f, 0.15f, 0.15f, 0.8f); Scrollbar val2 = val.AddComponent<Scrollbar>(); val2.direction = (Direction)2; GameObject val3 = new GameObject("SlidingArea"); val3.transform.SetParent(val.transform, false); RectTransform obj2 = val3.AddComponent<RectTransform>(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.offsetMin = new Vector2(2f, 2f); obj2.offsetMax = new Vector2(-2f, -2f); GameObject val4 = new GameObject("Handle"); val4.transform.SetParent(val3.transform, false); RectTransform val5 = val4.AddComponent<RectTransform>(); val5.anchorMin = Vector2.zero; val5.anchorMax = Vector2.one; val5.offsetMin = Vector2.zero; val5.offsetMax = Vector2.zero; Image val6 = val4.AddComponent<Image>(); ((Graphic)val6).color = new Color(0.5f, 0.45f, 0.35f, 1f); val2.handleRect = val5; ((Selectable)val2).targetGraphic = (Graphic)(object)val6; ((Selectable)val2).colors = GUIManager.Instance.ValheimScrollbarHandleColorBlock; _scrollRect.verticalScrollbar = val2; _scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)2; } private void CreatePaginationControls() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown GameObject val = new GameObject("Pagination"); val.transform.SetParent(_container.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 0f); obj.anchorMax = new Vector2(1f, 0f); obj.pivot = new Vector2(0.5f, 0f); obj.anchoredPosition = new Vector2(0f, 10f); obj.sizeDelta = new Vector2(0f, 35f); GameObject val2 = GUIManager.Instance.CreateButton("◀ Prev", val.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-100f, 0f), 80f, 30f); _prevButton = val2.GetComponent<Button>(); ((UnityEvent)_prevButton.onClick).AddListener(new UnityAction(OnPrevPage)); GameObject val3 = GUIManager.Instance.CreateText("Page 1 / 1", val.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerif, 14, Color.white, true, Color.black, 120f, 30f, false); _pageInfoText = val3.GetComponent<Text>(); _pageInfoText.alignment = (TextAnchor)4; GameObject val4 = GUIManager.Instance.CreateButton("Next ▶", val.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100f, 0f), 80f, 30f); _nextButton = val4.GetComponent<Button>(); ((UnityEvent)_nextButton.onClick).AddListener(new UnityAction(OnNextPage)); } private Text CreateCenteredText(string text, Color color, int fontSize) { //IL_001b: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Text component = GUIManager.Instance.CreateText(text, _container.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, GUIManager.Instance.AveriaSerif, fontSize, color, true, Color.black, 400f, 60f, false).GetComponent<Text>(); component.alignment = (TextAnchor)4; return component; } public void SetTransactions(List<TransactionRecord> transactions, int totalCount, int totalPages) { _transactions = transactions ?? new List<TransactionRecord>(); _totalCount = totalCount; _totalPages = Math.Max(1, totalPages); RefreshDisplay(); } public void Refresh() { MarketRPCs.RequestGetTransactionHistory(_currentPlatformId, _currentPage, _pageSize); } public int GetCurrentPage() { return _currentPage; } public int GetPageSize() { return _pageSize; } public void SetCurrentPlatformId(string platformId) { _currentPlatformId = platformId; } private void RefreshDisplay() { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) ClearTransactionRows(); bool flag = _transactions != null && _transactions.Count > 0; if ((Object)(object)_emptyText != (Object)null) { ((Component)_emptyText).gameObject.SetActive(!flag); } if (flag) { ScrollRect scrollRect = _scrollRect; RectTransform val = ((scrollRect != null) ? scrollRect.content : null); if ((Object)(object)val == (Object)null) { SimpleMarketPlugin.LogError("HistoryPanel: ScrollRect content is null, cannot display transactions"); return; } float num = 0f; foreach (TransactionRecord transaction in _transactions) { TransactionRow transactionRow = TransactionRow.Create(((Component)val).transform, transaction, _currentPlatformId); transactionRow.SetYPosition(num); _transactionRows.Add(transactionRow); num -= 70f; } val.sizeDelta = new Vector2(0f, Math.Abs(num)); } UpdatePagination(); } private void ClearTransactionRows() { foreach (TransactionRow transactionRow in _transactionRows) { if ((Object)(object)transactionRow != (Object)null) { Object.Destroy((Object)(object)((Component)transactionRow).gameObject); } } _transactionRows.Clear(); } private void UpdatePagination() { if ((Object)(object)_pageInfoText != (Object)null) { _pageInfoText.text = $"Page {_currentPage + 1} / {_totalPages}"; } if ((Object)(object)_prevButton != (Object)null) { ((Selectable)_prevButton).interactable = _currentPage > 0; } if ((Object)(object)_nextButton != (Object)null) { ((Selectable)_nextButton).interactable = _currentPage < _totalPages - 1; } } private void OnPrevPage() { if (_currentPage > 0) { _currentPage--; Refresh(); } } private void OnNextPage() { if (_currentPage < _totalPages - 1) { _currentPage++; Refresh(); } } private void OnDestroy() { ClearTransactionRows(); if ((Object)(object)_prevButton != (Object)null) { ((UnityEventBase)_prevButton.onClick).RemoveAllListeners(); } if ((Object)(object)_nextButton != (Object)null) { ((UnityEventBase)_nextButton.onClick).RemoveAllListeners(); } } } public class TransactionRow : MonoBehaviour { private GameObject _container; private Image _iconImage; private Text _descriptionText; private Text _priceText; private Text _timestampText; private SocketFrame _socketFrame; private Color? _socketColor; private TransactionRecord _transaction; private string _currentPlatformId; private bool _isBuyer; private const float RowHeight = 60f; private const float IconSize = 45f; private const float Padding = 8f; public static TransactionRow Create(Transform parent, TransactionRecord transaction, string currentPlatformId) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0029: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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) GameObject val = new GameObject("TransactionRow"); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 1f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(0.5f, 1f); obj.sizeDelta = new Vector2(-20f, 60f); ((Graphic)val.AddComponent<Image>()).color = new Color(0.15f, 0.15f, 0.15f, 0.7f); TransactionRow transactionRow = val.AddComponent<TransactionRow>(); transactionRow._container = val; transactionRow._currentPlatformId = currentPlatformId; transactionRow._transaction = transaction; transactionRow._isBuyer = transaction.IsBuyer(currentPlatformId); transactionRow.CreateUI(); transactionRow.UpdateDisplay(); return transactionRow; } private void CreateUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00d8: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Expected O, but got Unknown //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Expected O, but got Unknown //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("IconContainer"); val.transform.SetParent(_container.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 0.5f); obj.anchorMax = new Vector2(0f, 0.5f); obj.pivot = new Vector2(0f, 0.5f); obj.anchoredPosition = new Vector2(8f, 0f); obj.sizeDelta = new Vector2(45f, 45f); ((Graphic)val.AddComponent<Image>()).color = new Color(0.1f, 0.1f, 0.1f, 0.8f); GameObject val2 = new GameObject("ItemIcon"); val2.transform.SetParent(val.transform, false); RectTransform obj2 = val2.AddComponent<RectTransform>(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.offsetMin = new Vector2(2f, 2f); obj2.offsetMax = new Vector2(-2f, -2f); _iconImage = val2.AddComponent<Image>(); ((Graphic)_iconImage).color = Color.white; _iconImage.preserveAspect = true; _socketFrame = SocketFrame.Create(val.transform, new Vector2(45f, 45f)); GameObject val3 = new GameObject("Description"); val3.transform.SetParent(_container.transform, false); RectTransform obj3 = val3.AddComponent<RectTransform>(); obj3.anchorMin = new Vector2(0f, 0f); obj3.anchorMax = new Vector2(1f, 1f); obj3.offsetMin = new Vector2(63f, 24f); obj3.offsetMax = new Vector2(-110f, -5f); _descriptionText = val3.AddComponent<Text>(); _descriptionText.font = GUIManager.Instance.AveriaSerifBold; _descriptionText.fontSize = 13; ((Graphic)_descriptionText).color = Color.white; _descriptionText.alignment = (TextAnchor)3; _descriptionText.supportRichText = true; Outline obj4 = val3.AddComponent<Outline>(); ((Shadow)obj4).effectColor = Color.black; ((Shadow)obj4).effectDistance = new Vector2(1f, -1f); GameObject val4 = new GameObject("Price"); val4.transform.SetParent(_container.transform, false); RectTransform obj5 = val4.AddComponent<RectTransform>(); obj5.anchorMin = new Vector2(1f, 0f); obj5.anchorMax = new Vector2(1f, 1f); obj5.pivot = new Vector2(1f, 0.5f); obj5.anchoredPosition = new Vector2(-8f, 0f); obj5.sizeDelta = new Vector2(100f, 0f); _priceText = val4.AddComponent<Text>(); _priceText.font = GUIManager.Instance.AveriaSerifBold; _priceText.fontSize = 14; ((Graphic)_priceText).color = new Color(1f, 0.85f, 0f); _priceText.alignment = (TextAnchor)5; Outline obj6 = val4.AddComponent<Outline>(); ((Shadow)obj6).effectColor = Color.black; ((Shadow)obj6).effectDistance = new Vector2(1f, -1f); GameObject val5 = new GameObject("Timestamp"); val5.transform.SetParent(_container.transform, false); RectTransform obj7 = val5.AddComponent<RectTransform>(); obj7.anchorMin = new Vector2(0f, 0f); obj7.anchorMax = new Vector2(1f, 0f); obj7.pivot = new Vector2(0f, 0f); obj7.anchoredPosition = new Vector2(63f, 8f); obj7.sizeDelta = new Vector2(-120f, 20f); _timestampText = val5.AddComponent<Text>(); _timestampText.font = GUIManager.Instance.AveriaSerif; _timestampText.fontSize = 11; ((Graphic)_timestampText).color = new Color(0.5f, 0.5f, 0.5f); _timestampText.alignment = (TextAnchor)3; Outline obj8 = val5.AddComponent<Outline>(); ((Shadow)obj8).effectColor = Color.black; ((Shadow)obj8).effectDistance = new Vector2(1f, -1f); } private void UpdateDisplay() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) if (_transaction != null) { _socketColor = GetSocketColorForTransaction(); string text = ((!string.IsNullOrEmpty(_transaction.LocalizedName)) ? _transaction.LocalizedName : ItemHelper.GetLocalizedName(_transaction.ItemPrefabName)); if (_transaction.Quality > 1) { text = text + " " + _transaction.GetQualityStars(); } string otherPartyName = _transaction.GetOtherPartyName(_currentPlatformId); string text2 = ((!_socketColor.HasValue) ? text : ("<color=#" + ColorUtility.ToHtmlStringRGB(_socketColor.Value) + ">" + text + "</color>")); string arg = ((_transaction.TotalPrice == 1) ? "coin" : "coins"); if (_isBuyer) { _descriptionText.text = $"You purchased {_transaction.Quantity}x {text2} from {otherPartyName}"; ((Graphic)_descriptionText).color = new Color(0.7f, 0.9f, 1f); _priceText.text = $"-{_transaction.TotalPrice:N0} {arg}"; ((Graphic)_priceText).color = new Color(1f, 0.5f, 0.5f); } else { _descriptionText.text = $"{otherPartyName} purchased your {_transaction.Quantity}x {text2}"; ((Graphic)_descriptionText).color = new Color(0.7f, 1f, 0.7f); _priceText.text = $"+{_transaction.TotalPrice:N0} {arg}"; ((Graphic)_priceText).color = new Color(0.5f, 1f, 0.5f); } _timestampText.text = _transaction.GetAgeString(); LoadItemIcon(); } } private Color? GetSocketColorForTransaction() { if (_transaction == null) { return null; } ItemData val = ItemHelper.CreateItemFromTransaction(_transaction); if (val != null) { return JewelcraftingCompat.GetSocketColor(val); } return null; } private void LoadItemIcon() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (_transaction == null || (Object)(object)_iconImage == (Object)null) { return; } try { Sprite itemIcon = ItemHelper.GetItemIcon(_transaction.ItemPrefabName); if ((Object)(object)itemIcon != (Object)null) { _iconImage.sprite = itemIcon; ((Graphic)_iconImage).color = Color.white; ApplySocketFrame(); return; } } catch (Exception ex) { SimpleMarketPlugin.LogDebug("Failed to load icon for " + _transaction.ItemPrefabName + ": " + ex.Message); } _iconImage.sprite = null; ((Graphic)_iconImage).color = new Color(0.3f, 0.3f, 0.3f); _socketFrame?.Hide(); } private void ApplySocketFrame() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_socketFrame == (Object)null)) { if (_socketColor.HasValue) { _socketFrame.Show(_socketColor.Value); } else { _socketFrame.Hide(); } } } public void SetYPosition(float y) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) RectTransform component = _container.GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { component.anchoredPosition = new Vector2(0f, y); } } } public class ListingPanel : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { private GameObject _container; private Image _iconImage; private Text _itemNameText; private Text _quantityText; private Text _priceText; private Text _sellerText; private Text _ageText; private Button _actionButton; private Text _actionButtonText; private InputField _quantityInput; private GameObject _quantityInputContainer; private SocketFrame _socketFrame; private MarketListing _listing; private bool _isOwnListing; private string _currentPlatformId; private Color? _socketColor; private const float PanelHeight = 70f; private const float IconSize = 50f; private const float Padding = 10f; public event Action<MarketListing> OnBuyClicked; public event Action<MarketListing> OnCancelClicked; public event Action<MarketListing, int> OnBuyPartialClicked; public static ListingPanel Create(Transform parent, MarketListing listing, string currentPlatformId) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0029: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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) GameObject val = new GameObject("ListingPanel"); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 1f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(0.5f, 1f); obj.sizeDelta = new Vector2(-20f, 70f); ((Graphic)val.AddComponent<Image>()).color = new Color(0.15f, 0.15f, 0.15f, 0.7f); ListingPanel listingPanel = val.AddComponent<ListingPanel>(); listingPanel._container = val; listingPanel._currentPlatformId = currentPlatformId; listingPanel.CreateUI(); listingPanel.SetListing(listing); return listingPanel; } private void CreateUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00d8: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("IconContainer"); val.transform.SetParent(_container.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 0.5f); obj.anchorMax = new Vector2(0f, 0.5f); obj.pivot = new Vector2(0f, 0.5f); obj.anchoredPosition = new Vector2(10f, 0f); obj.sizeDelta = new Vector2(50f, 50f); ((Graphic)val.AddComponent<Image>()).color = new Color(0.1f, 0.1f, 0.1f, 0.8f); GameObject val2 = new GameObject("ItemIcon"); val2.transform.SetParent(val.transform, false); RectTransform obj2 = val2.AddComponent<RectTransform>(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.offsetMin = new Vector2(2f, 2f); obj2.offsetMax = new Vector2(-2f, -2f); _iconImage = val2.AddComponent<Image>(); ((Graphic)_iconImage).color = Color.white; _iconImage.preserveAspect = true; _socketFrame = SocketFrame.Create(val.transform, new Vector2(50f, 50f)); _itemNameText = CreateText("ItemName", new Vector2(199f, 15f), new Vector2(0f, 0.5f), 260f, 25f, 16, GUIManager.Instance.ValheimOrange, (TextAnchor)3); if ((Object)(object)_itemNameText != (Object)null) { _itemNameText.supportRichText = true; } _sellerText = CreateText("Seller", new Vector2(131f, -10f), new Vector2(0f, 0.5f), 120f, 20f, 12, new Color(0.7f, 0.7f, 0.7f), (TextAnchor)3); _quantityText = CreateText("Quantity", new Vector2(335f, -10f), new Vector2(0f, 0.5f), 80f, 20f, 14, Color.white, (TextAnchor)3); _priceText = CreateText("Price", new Vector2(430f, 0f), new Vector2(0f, 0.5f), 130f, 25f, 16, new Color(1f, 0.85f, 0f), (TextAnchor)4); _ageText = CreateText("Age", new Vector2(-180f, -10f), new Vector2(1f, 0.5f), 100f, 20f, 11, new Color(0.5f, 0.5f, 0.5f), (TextAnchor)5); CreateQuantityInput(); CreateActionButton(); } private Text CreateText(string name, Vector2 position, Vector2 anchor, float width, float height, int fontSize, Color color, TextAnchor alignment) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_004d: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GUIManager.Instance.CreateText("", _container.transform, anchor, anchor, position, GUIManager.Instance.AveriaSerifBold, fontSize, color, true, Color.black, width, height, false); ((Object)obj).name = name; Text component = obj.GetComponent<Text>(); if ((Object)(object)component != (Object)null) { component.alignment = alignment; } return component; } private void CreateQuantityInput() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) _quantityInputContainer = new GameObject("QuantityInputContainer"); _quantityInputContainer.transform.SetParent(_container.transform, false); RectTransform obj = _quantityInputContainer.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(1f, 0.5f); obj.anchorMax = new Vector2(1f, 0.5f); obj.pivot = new Vector2(1f, 0.5f); obj.anchoredPosition = new Vector2(-120f, 10f); obj.sizeDelta = new Vector2(70f, 30f); GUIManager.Instance.CreateText("Buy:", _quantityInputContainer.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(-25f, 0f), GUIManager.Instance.AveriaSerif, 12, Color.white, false, Color.black, 30f, 20f, false); GameObject val = GUIManager.Instance.CreateInputField(_quantityInputContainer.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-2f, 0f), (ContentType)2, "1", 12, 50f, 25f); _quantityInput = val.GetComponent<InputField>(); _quantityInputContainer.SetActive(false); } private void CreateActionButton() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown GameObject val = GUIManager.Instance.CreateButton("Buy", _container.transform, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-55f, 0f), 80f, 35f); ((Object)val).name = "ActionButton"; _actionButton = val.GetComponent<Button>(); _actionButtonText = val.GetComponentInChildren<Text>(); if ((Object)(object)_actionButton != (Object)null) { ((UnityEvent)_actionButton.onClick).AddListener(new UnityAction(OnActionButtonClicked)); } } public void SetListing(MarketListing listing) { _listing = listing; _isOwnListing = listing.SellerPlatformId == _currentPlatformId; UpdateDisplay(); } private void UpdateDisplay() { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (_listing == null) { return; } _socketColor = GetSocketColorForListing(); string text = GetLocalizedItemName(_listing.ItemPrefabName); if (_listing.Quality > 1) { text += $" ★{_listing.Quality}"; } if (_socketColor.HasValue) { _itemNameText.text = "<color=#" + ColorUtility.ToHtmlStringRGB(_socketColor.Value) + ">" + text + "</color>"; } else { _itemNameText.text = text; ((Graphic)_itemNameText).color = GUIManager.Instance.ValheimOrange; } _quantityText.text = $"x{_listing.Quantity}"; if (_listing.Quantity == 1) { _priceText.text = $"{_listing.Price:N0} coins"; } else { int totalPrice = _listing.GetTotalPrice(); _priceText.text = $"{totalPrice:N0} coins (stack)"; } _sellerText.text = "Seller: " + _listing.SellerName; _ageText.text = _listing.GetAgeString(); if (_isOwnListing) { _actionButtonText.text = "Cancel"; _quantityInputContainer.SetActive(false); } else { _actionButtonText.text = "Buy"; _quantityInputContainer.SetActive(_listing.Quantity > 1 && _listing.AllowsPartialPurchase()); if ((Object)(object)_quantityInput != (Object)null) { _quantityInput.text = _listing.Quantity.ToString(); } } LoadItemIcon(); } private void LoadItemIcon() { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (_listing == null || (Object)(object)_iconImage == (Object)null) { return; } try { ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(_listing.ItemPrefabName) : null); if ((Object)(object)val != (Object)null) { ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { Sprite icon = component.m_itemData.GetIcon(); if ((Object)(object)icon != (Object)null) { _iconImage.sprite = icon; ((Graphic)_iconImage).color = Color.white; ApplySocketFrame(); return; } } } } catch (Exception ex) { SimpleMarketPlugin.LogDebug("Failed to load icon for " + _listing.ItemPrefabName + ": " + ex.Message); } _iconImage.sprite = null; ((Graphic)_iconImage).color = new Color(0.3f, 0.3f, 0.3f); _socketFrame?.Hide(); } private Color? GetSocketColorForListing() { if (_listing == null) { return null; } ItemData val = ItemHelper.CreateItemFromListing(_listing); if (val != null) { return JewelcraftingCompat.GetSocketColor(val); } return null; } private void ApplySocketFrame() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_socketFrame == (Object)null)) { if (_socketColor.HasValue) { _socketFrame.Show(_socketColor.Value); } else { _socketFrame.Hide(); } } } private string GetLocalizedItemName(string prefabName) { return ItemHelper.GetLocalizedName(prefabName); } private void OnActionButtonClicked() { if (_listing != null) { int result; if (_isOwnListing) { this.OnCancelClicked?.Invoke(_listing); } else if (_quantityInputContainer.activeSelf && (Object)(object)_quantityInput != (Object)null && int.TryParse(_quantityInput.text, out result) && result > 0 && result < _listing.Quantity) { this.OnBuyPartialClicked?.Invoke(_listing, result); } else { this.OnBuyClicked?.Invoke(_listing); } } } public void OnPointerEnter(PointerEventData eventData) { if (_listing != null) { MarketListing listing = _listing; Transform transform = _container.transform; MarketTooltip.ShowTooltip(listing, (RectTransform)(object)((transform is RectTransform) ? transform : null)); } } public void OnPointerExit(PointerEventData eventData) { MarketTooltip.HideTooltip(); } public void SetYPosition(float y) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) RectTransform component = _container.GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { component.anchoredPosition = new Vector2(0f, y); } } public float GetHeight() { return 70f; } private void OnDestroy() { if ((Object)(object)_actionButton != (Object)null) { ((UnityEventBase)_actionButton.onClick).RemoveAllListeners(); } } } public class ListingsScrollView : MonoBehaviour { private GameObject _container; private GameObject _scrollArea; private ScrollRect _scrollRect; private RectTransform _contentRect; private GameObject _noListingsText; private GameObject _loadingText; private GameObject _paginationPanel; private Button _prevButton; private Button _nextButton; private Text _pageText; private GameObject _controlsPanel; private Dropdown _sortDropdown; private InputField _searchInput; private List<ListingPanel> _listingPanels = new List<ListingPanel>(); private List<MarketListing> _currentListings = new List<MarketListing>(); private string _currentPlatformId; private int _currentPage = 1; private int _totalPages = 1; private int _listingsPerPage = 10; private const float ListingHeight = 75f; private const float ListingSpacing = 5f; public event Action<MarketListing> OnBuyClicked; public event Action<MarketListing> OnCancelClicked; public event Action<MarketListing, int> OnBuyPartialClicked; public event Action<int> OnPageChanged; public static ListingsScrollView Create(Transform parent, RectTransform bounds) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) GameObject val = new GameObject("ListingsScrollView"); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = bounds.anchorMin; obj.anchorMax = bounds.anchorMax; obj.offsetMin = bounds.offsetMin; obj.offsetMax = bounds.offsetMax; ListingsScrollView listingsScrollView = val.AddComponent<ListingsScrollView>(); listingsScrollView._container = val; listingsScrollView._listingsPerPage = SimpleMarketConfig.ListingsPerPage.Value; listingsScrollView.CreateUI(); return listingsScrollView; } private void CreateUI() { CreateControlsPanel(); CreateScrollArea(); CreatePaginationPanel(); CreateNoListingsText(); CreateLoadingText(); } private void CreateControlsPanel() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) _controlsPanel = new GameObject("ControlsPanel"); _controlsPanel.transform.SetParent(_container.transform, false); RectTransform obj = _controlsPanel.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 1f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(0.5f, 1f); obj.anchoredPosition = new Vector2(0f, 0f); obj.sizeDelta = new Vector2(0f, 35f); ((Object)GUIManager.Instance.CreateText("Sort:", _controlsPanel.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(30f, 0f), GUIManager.Instance.AveriaSerif, 13, Color.white, false, Color.black, 40f, 25f, false)).name = "SortLabel"; GameObject val = GUIManager.Instance.CreateDropDown(_controlsPanel.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(120f, 0f), 12, 110f, 28f); ((Object)val).name = "SortDropdown"; _sortDropdown = val.GetComponent<Dropdown>(); if ((Object)(object)_sortDropdown != (Object)null) { _sortDropdown.ClearOptions(); _sortDropdown.AddOptions(new List<string> { "Newest", "Oldest", "Price: Low", "Price: High", "Name A-Z" }); int value = SimpleMarketConfig.DefaultSortMode.Value switch { "Oldest" => 1, "PriceLow" => 2, "PriceHigh" => 3, "Name" => 4, _ => 0, }; _sortDropdown.value = value; ((UnityEvent<int>)(object)_sortDropdown.onValueChanged).AddListener((UnityAction<int>)OnSortChanged); } ((Object)GUIManager.Instance.CreateText("Search:", _controlsPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(20f, 0f), GUIManager.Instance.AveriaSerif, 13, Color.white, false, Color.black, 55f, 25f, false)).name = "SearchLabel"; GameObject val2 = GUIManager.Instance.CreateInputField(_controlsPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(140f, 0f), (ContentType)0, "Item name...", 12, 150f, 28f); ((Object)val2).name = "SearchInput"; _searchInput = val2.GetComponent<InputField>(); if ((Object)(object)_searchInput != (Object)null) { ((UnityEvent<string>)(object)_searchInput.onEndEdit).AddListener((UnityAction<string>)OnSearchChanged); } } private void CreateScrollArea() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown _scrollArea = new GameObject("ScrollArea"); _scrollArea.transform.SetParent(_container.transform, false); RectTransform obj = _scrollArea.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 0f); obj.anchorMax = new Vector2(1f, 1f); obj.offsetMin = new Vector2(5f, 45f); obj.offsetMax = new Vector2(-25f, -40f); ((Graphic)_scrollArea.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.2f); _scrollArea.AddComponent<Mask>().showMaskGraphic = true; _scrollRect = _scrollArea.AddComponent<ScrollRect>(); _scrollRect.horizontal = false; _scrollRect.vertical = true; _scrollRect.movementType = (MovementType)2; _scrollRect.scrollSensitivity = 80f; GameObject val = new GameObject("Content"); val.transform.SetParent(_scrollArea.transform, false); _contentRect = val.AddComponent<RectTransform>(); _contentRect.anchorMin = new Vector2(0f, 1f); _contentRect.anchorMax = new Vector2(1f, 1f); _contentRect.pivot = new Vector2(0.5f, 1f); _contentRect.anchoredPosition = Vector2.zero; _contentRect.sizeDelta = new Vector2(0f, 0f); _scrollRect.content = _contentRect; val.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; VerticalLayoutGroup obj2 = val.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 5f; ((LayoutGroup)obj2).padding = new RectOffset(5, 5, 5, 5); ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = false; CreateVerticalScrollbar(); } private void CreateVerticalScrollbar() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("VerticalScrollbar"); val.transform.SetParent(_container.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(1f, 0f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(1f, 0.5f); obj.anchoredPosition = new Vector2(-5f, 0f); obj.sizeDelta = new Vector2(15f, -85f); obj.offsetMin = new Vector2(-20f, 45f); obj.offsetMax = new Vector2(-5f, -40f); ((Graphic)val.AddComponent<Image>()).color = new Color(0.15f, 0.15f, 0.15f, 0.8f); Scrollbar val2 = val.AddComponent<Scrollbar>(); val2.direction = (Direction)2; GameObject val3 = new GameObject("SlidingArea"); val3.transform.SetParent(val.transform, false); RectTransform obj2 = val3.AddComponent<RectTransform>(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.offsetMin = new Vector2(2f, 2f); obj2.offsetMax = new Vector2(-2f, -2f); GameObject val4 = new GameObject("Handle"); val4.transform.SetParent(val3.transform, false); RectTransform val5 = val4.AddComponent<RectTransform>(); val5.anchorMin = Vector2.zero; val5.anchorMax = Vector2.one; val5.offsetMin = Vector2.zero; val5.offsetMax = Vector2.zero; Image val6 = val4.AddComponent<Image>(); ((Graphic)val6).color = new Color(0.5f, 0.45f, 0.35f, 1f); val2.handleRect = val5; ((Selectable)val2).targetGraphic = (Graphic)(object)val6; ((Selectable)val2).colors = GUIManager.Instance.ValheimScrollbarHandleColorBlock; _scrollRect.verticalScrollbar = val2; _scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)2; } private void CreatePaginationPanel() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00dc: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Expected O, but got Unknown _paginationPanel = new GameObject("PaginationPanel"); _paginationPanel.transform.SetParent(_container.transform, false); RectTransform obj = _paginationPanel.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 0f); obj.anchorMax = new Vector2(1f, 0f); obj.pivot = new Vector2(0.5f, 0f); obj.anchoredPosition = new Vector2(0f, 5f); obj.sizeDelta = new Vector2(0f, 35f); GameObject val = GUIManager.Instance.CreateButton("< Prev", _paginationPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-100f, 0f), 70f, 28f); ((Object)val).name = "PrevButton"; _prevButton = val.GetComponent<Button>(); if ((Object)(object)_prevButton != (Object)null) { ((UnityEvent)_prevButton.onClick).AddListener(new UnityAction(OnPrevPage)); } GameObject val2 = GUIManager.Instance.CreateText("Page 1 of 1", _paginationPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerif, 14, Color.white, false, Color.black, 100f, 25f, false); ((Object)val2).name = "PageText"; _pageText = val2.GetComponent<Text>(); if ((Object)(object)_pageText != (Object)null) { _pageText.alignment = (TextAnchor)4; } GameObject val3 = GUIManager.Instance.CreateButton("Next >", _paginationPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100f, 0f), 70f, 28f); ((Object)val3).name = "NextButton"; _nextButton = val3.GetComponent<Button>(); if ((Object)(object)_nextButton != (Object)null) { ((UnityEvent)_nextButton.onClick).AddListener(new UnityAction(OnNextPage)); } } private void CreateNoListingsText() { //IL_0020: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) _noListingsText = GUIManager.Instance.CreateText("No listings found\n\nBe the first to list an item!", _scrollArea.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerif, 16, new Color(0.6f, 0.6f, 0.6f), false, Color.black, 300f, 100f, false); ((Object)_noListingsText).name = "NoListingsText"; Text component = _noListingsText.GetComponent<Text>(); if ((Object)(object)component != (Object)null) { component.alignment = (TextAnchor)4; } _noListingsText.SetActive(false); } private void CreateLoadingText() { //IL_0020: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) _loadingText = GUIManager.Instance.CreateText("Loading listings...", _scrollArea.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerif, 16, new Color(0.8f, 0.8f, 0.8f), false, Color.black, 200f, 30f, false); ((Object)_loadingText).name = "LoadingText"; Text component = _loadingText.GetComponent<Text>(); if ((Object)(object)component != (Object)null) { component.alignment = (TextAnchor)4; } _loadingText.SetActive(false); } public void SetCurrentPlatformId(string platformId) { _currentPlatformId = platformId; } public void SetListings(List<MarketListing> listings, int totalCount, int totalPages) { _currentListings = listings ?? new List<MarketListing>(); _totalPages = Math.Max(1, totalPages); if (_currentPage > _totalPages) { _currentPage = _totalPages; } RefreshDisplay(); } public void ShowLoading() { ClearListingPanels(); _loadingText.SetActive(tr