示例#1
0
 public static void RefreshDisplay(ItemDetailsDisplay __instance, IItemDisplay _itemDisplay)
 {
     try
     {
         if (_itemDisplay != null && _itemDisplay.RefItem != null && _itemDisplay.RefItem.GetType().Name == "WaterContainer")
         {
             //WorkInProgress.Instance.MyLogger.LogDebug($"InitDisplayedStats");
             //Perishable m_perishScript = (Perishable)AccessTools.Field(typeof(Item), "m_perishScript").GetValue(_itemDisplay.RefItem);
             //WorkInProgress.Instance.MyLogger.LogDebug($" > IsPerishable={_itemDisplay.RefItem.IsPerishable}");
             //WorkInProgress.Instance.MyLogger.LogDebug($" > m_perishScript={m_perishScript != null}");
             //if (m_perishScript != null)
             //    WorkInProgress.Instance.MyLogger.LogDebug($" > DepletionRate={m_perishScript.DepletionRate}");
             //WorkInProgress.Instance.MyLogger.LogDebug($" > CurrentDurability={_itemDisplay.RefItem.CurrentDurability}");
             ItemDetailsDisplay.DisplayedInfos[] m_displayedInfos = (ItemDetailsDisplay.DisplayedInfos[])AccessTools.Field(typeof(Item), "m_displayedInfos").GetValue(_itemDisplay.RefItem);
             m_displayedInfos = new ItemDetailsDisplay.DisplayedInfos[3]
             {
                 ItemDetailsDisplay.DisplayedInfos.QuickSlot,
                 ItemDetailsDisplay.DisplayedInfos.Capacity,
                 ItemDetailsDisplay.DisplayedInfos.Content
             };
             AccessTools.Field(typeof(Item), "m_displayedInfos").SetValue(_itemDisplay.RefItem, m_displayedInfos);
         }
     }
     catch (Exception ex)
     {
         WorkInProgress.Instance.MyLogger.LogError("HideWaterDurability: " + ex.Message);
     }
 }
 public static void RefreshDisplay(ItemDetailsDisplay __instance, IItemDisplay _itemDisplay)
 {
     try
     {
         AreaEnum areaN         = (AreaEnum)AreaManager.Instance.GetAreaIndexFromSceneName(SceneManagerHelper.ActiveSceneName);
         Text     m_lblItemName = (Text)AccessTools.Field(typeof(ItemDetailsDisplay), "m_lblItemName").GetValue(__instance);
         if (m_lblItemName == null || _itemDisplay == null || _itemDisplay.RefItem == null)
         {
             return;
         }
         #region Show inventory and stash quantities in the name
         if (!(_itemDisplay.RefItem is Skill))
         {
             int invQty   = __instance.LocalCharacter.Inventory.ItemCount(_itemDisplay.RefItem.ItemID);
             int stashQty = 0;
             if (InnRentStash.StashAreaToStashUID.ContainsKey(areaN) && InnRentStash.Instance.ConfigStashSharing.Value)
             {
                 TreasureChest stash = (TreasureChest)ItemManager.Instance.GetItem(InnRentStash.StashAreaToStashUID[areaN]);
                 if (stash != null)
                 {
                     stashQty = stash.ItemStackCount(_itemDisplay.RefItem.ItemID);
                 }
             }
             if (invQty + stashQty > 0)
             {
                 //InnRentStash.MyLogger.LogDebug($"{_itemDisplay.RefItem.DisplayName}: invQty={invQty} / stashQty={stashQty}");
                 m_lblItemName.text += $" ({invQty + stashQty})";
             }
         }
         #endregion
         #region Add Value/Weight Ratio information
         if (_itemDisplay.RefItem.Value > 0 && _itemDisplay.RefItem.Weight > 0 && _itemDisplay.RefItem.IsSellable)
         {
             List <ItemDetailRowDisplay> m_detailRows = (List <ItemDetailRowDisplay>)AccessTools.Field(typeof(ItemDetailsDisplay), "m_detailRows").GetValue(__instance);
             //ItemDetailRowDisplay row = (ItemDetailRowDisplay)AccessTools.Method(typeof(ItemDetailsDisplay), "GetRow").Invoke(__instance, new object[] { m_detailRows.Count });
             //row.SetInfo("Value rate", Math.Round(_itemDisplay.RefItem.Value / _itemDisplay.RefItem.Weight, 2).ToString());
         }
         #endregion
         #region Add Durability information
         if (_itemDisplay.RefItem.IsPerishable && _itemDisplay.RefItem.CurrentDurability > 0 &&
             !_itemDisplay.RefItem.DisplayedInfos.ToList().Contains(DisplayedInfos.Durability))
         {
             List <ItemDetailRowDisplay> m_detailRows = (List <ItemDetailRowDisplay>)AccessTools.Field(typeof(ItemDetailsDisplay), "m_detailRows").GetValue(__instance);
             //ItemDetailRowDisplay row = (ItemDetailRowDisplay)AccessTools.Method(typeof(ItemDetailsDisplay), "GetRow").Invoke(__instance, new object[] { m_detailRows.Count });
             //row.SetInfo(LocalizationManager.Instance.GetLoc("ItemStat_Durability"), GameTimetoDays(_itemDisplay.RefItem.CurrentDurability / _itemDisplay.RefItem.PerishScript.DepletionRate));
         }
         #endregion
     }
     catch (Exception ex)
     {
         //InnRentStash.MyLogger.LogError("RefreshDisplay: " + ex.Message);
     }
 }
示例#3
0
        public static void RefreshDisplay(ItemDetailsDisplay __instance, IItemDisplay _itemDisplay)
        {
            try
            {
                //Item m_lastItem = (Item)AccessTools.Field(typeof(ItemDetailsDisplay), "m_lastItem").GetValue(self);
                //OLogger.Log($"RefreshDisplay={m_lastItem.DisplayName}");

                //Item it = (Item)AccessTools.Field(typeof(ItemDetailsDisplay), "m_lastItem").GetValue(self);
                if (_itemDisplay != null && _itemDisplay.RefItem != null &&
                    _itemDisplay.RefItem.Value > 0 && _itemDisplay.RefItem.Weight > 0 && _itemDisplay.RefItem.IsSellable)
                {
                    //OLogger.Log(m_lblItemName.text);
                    //int invQty = self.LocalCharacter.Inventory.GetOwnedItems(_itemDisplay.RefItem.ItemID).Count;
                    //int stashQty = 0;
                    //if (StashAreaToStashUID.ContainsKey(m_currentArea))
                    //{
                    //    TreasureChest stash = (TreasureChest)ItemManager.Instance.GetItem(StashAreaToStashUID[m_currentArea]);
                    //    if (stash != null)
                    //    {
                    //        stashQty = stash.GetItemsFromID(_itemDisplay.RefItem.ItemID).Count;
                    //    }
                    //}
                    //m_lblItemName.text += $" ({invQty + stashQty})";
                    //List<ItemDetailRowDisplay> m_detailRows = (List<ItemDetailRowDisplay>)AccessTools.Field(typeof(ItemDetailsDisplay), "m_detailRows").GetValue(__instance);
                    //ItemDetailRowDisplay row = (ItemDetailRowDisplay)AccessTools.Method(typeof(ItemDetailsDisplay), "GetRow").Invoke(__instance, new object[] { m_detailRows.Count });
                    //row.SetInfo("Ratio", Math.Round(_itemDisplay.RefItem.Value / _itemDisplay.RefItem.Weight, 2).ToString());
                    //m_lblItemName.text += $" ({_itemDisplay.RefItem.Value}/{_itemDisplay.RefItem.Weight} = {_itemDisplay.RefItem.Value/_itemDisplay.RefItem.Weight})";
                }
                //if (m_lblItemName != null && _itemDisplay != null && _itemDisplay.RefItem != null &&
                //    _itemDisplay.RefItem.Value > 0)
                //{
                //    List<ItemDetailRowDisplay> m_detailRows = (List<ItemDetailRowDisplay>)AccessTools.Field(typeof(ItemDetailsDisplay), "m_detailRows").GetValue(self);
                //    ItemDetailRowDisplay row = (ItemDetailRowDisplay)AccessTools.Method(typeof(ItemDetailsDisplay), "GetRow").Invoke(self, new object[] { m_detailRows.Count });
                //    row.SetInfo("Value", _itemDisplay.RefItem.Value.ToString());
                //}
                //if (m_lblItemName != null && _itemDisplay != null && _itemDisplay.RefItem != null &&
                //    _itemDisplay.RefItem.IsPerishable)
                //{
                //    List<ItemDetailRowDisplay> m_detailRows = (List<ItemDetailRowDisplay>)AccessTools.Field(typeof(ItemDetailsDisplay), "m_detailRows").GetValue(__instance);
                //    ItemDetailRowDisplay row = (ItemDetailRowDisplay)AccessTools.Method(typeof(ItemDetailsDisplay), "GetRow").Invoke(__instance, new object[] { m_detailRows.Count });
                //    row.SetInfo("Durability", GameTimetoDays(_itemDisplay.RefItem.CurrentDurability / _itemDisplay.RefItem.PerishScript.DepletionRate));
                //}
                //if (m_lblItemName != null && _itemDisplay != null && _itemDisplay.RefItem != null)
                //{
                //    try
                //    {
                //        EffectSynchronizer2 test = new EffectSynchronizer2(_itemDisplay.RefItem);
                //        List<string> lstEffects = new List<string>();
                //        foreach (var item in test.LstEffects)
                //        {
                //            // AddStatusEffect
                //            // AffectStamina
                //            // AffectBurntHealth
                //            // AffectBurntStamina
                //            //
                //            //OLogger.Log(item.GetType().Name);
                //            if (item is AddStatusEffect)
                //            {
                //                //OLogger.Log((item as AddStatusEffect).Status);
                //                //OLogger.Log((item as AddStatusEffect).Status.StatusName);
                //                lstEffects.Add((item as AddStatusEffect).Status.StatusName);
                //            }
                //        }
                //        if (lstEffects.Count > 0)
                //        {
                //            //row.SetInfo("Effects", string.Join("\r\n", lstEffects.ToArray()));
                //            Text m_lblItemDesc = (Text)AccessTools.Field(typeof(ItemDetailsDisplay), "m_lblItemDesc").GetValue(self);
                //            if (m_lblItemDesc != null)
                //            {
                //                m_lblItemDesc.text += "\r\n\r\n" + string.Join("\r\n", lstEffects.ToArray());
                //            }
                //        }
                //        //OLogger.Log("DONE");
                //    }
                //    catch (Exception ex)
                //    {
                //        OLogger.Error("Item_OnUse:" + ex.Message);
                //    }
                //}
            }
            catch (Exception ex)
            {
                WorkInProgress.Instance.MyLogger.LogError("RefreshDisplay: " + ex.Message);
            }
        }//*/