Update item detail
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,8 @@ using BrewMonster;
|
||||
using ModelRenderer.Scripts.Common;
|
||||
using ModelRenderer.Scripts.GameData;
|
||||
using UnityEngine;
|
||||
using PerfectWorld.Scripts.Managers;
|
||||
using BrewMonster.Network;
|
||||
|
||||
namespace BrewMonster.Scripts.Managers
|
||||
{
|
||||
@@ -1178,7 +1180,35 @@ namespace BrewMonster.Scripts.Managers
|
||||
/// </summary>
|
||||
protected virtual string GetNormalDesc(bool bRepair)
|
||||
{
|
||||
return string.IsNullOrEmpty(m_strDesc) ? null : m_strDesc;
|
||||
// Build a simple but centralized description:
|
||||
// - Name
|
||||
// - String-table description (if any)
|
||||
// - Extended description (if any)
|
||||
m_strDesc = string.Empty;
|
||||
|
||||
// Item name line
|
||||
string name = GetName();
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
AddDescText(0, true, name);
|
||||
}
|
||||
|
||||
// Core description from item_desc.txt (via EC_Game / TryGetItemMsg)
|
||||
string mainDesc = TryGetItemMainDesc();
|
||||
if (!string.IsNullOrEmpty(mainDesc))
|
||||
{
|
||||
AddDescText(0, true, mainDesc);
|
||||
}
|
||||
|
||||
// Extended description from item_ext_desc.txt
|
||||
string extDesc = TryGetItemExtDesc();
|
||||
if (!string.IsNullOrEmpty(extDesc))
|
||||
{
|
||||
AddDescText(0, true, extDesc);
|
||||
}
|
||||
|
||||
TrimLastReturn();
|
||||
return m_strDesc;
|
||||
}
|
||||
|
||||
protected virtual string GetBoothBuyDesc()
|
||||
@@ -1193,7 +1223,10 @@ namespace BrewMonster.Scripts.Managers
|
||||
|
||||
protected virtual void AddPriceDesc(int col, bool bRepair)
|
||||
{
|
||||
// Full text/color building uses string tables; keep a minimal stub for now.
|
||||
// Basic price string using scaled price; color is ignored at this level.
|
||||
int price = GetScaledPrice();
|
||||
if (price <= 0) return;
|
||||
AddDescText(col, true, "Price: {0}", price);
|
||||
}
|
||||
|
||||
protected virtual void AddProfReqDesc(int iProfReq)
|
||||
@@ -1219,27 +1252,47 @@ namespace BrewMonster.Scripts.Managers
|
||||
|
||||
protected void AddExtDescText()
|
||||
{
|
||||
// Extension description comes from game configs; keep stubbed for now.
|
||||
// Extend description from item_ext_desc.txt via EC_Game
|
||||
string ext = TryGetItemExtDesc();
|
||||
if (!string.IsNullOrEmpty(ext))
|
||||
{
|
||||
AddDescText(0, true, ext);
|
||||
}
|
||||
}
|
||||
|
||||
protected void AddExpireTimeDesc()
|
||||
{
|
||||
// Placeholder: expiry description can be added here when time system is fully wired.
|
||||
}
|
||||
|
||||
protected void AddExpireTimeDesc(int expire_date)
|
||||
{
|
||||
// Overwrite, call standard one; we don't change m_expire_date in this simplified port.
|
||||
AddExpireTimeDesc();
|
||||
}
|
||||
|
||||
protected void AddIDDescText()
|
||||
{
|
||||
// Optional: show internal id for debugging
|
||||
AddDescText(0, true, "ID: {0}", m_tid);
|
||||
}
|
||||
|
||||
protected void AddBindDescText()
|
||||
{
|
||||
// Simple binding flags display based on ProcType
|
||||
if ((m_iProcType & (int)ProcType.PROC_BINDING) != 0)
|
||||
{
|
||||
AddDescText(0, true, "[Bound]");
|
||||
}
|
||||
else if ((m_iProcType & (int)ProcType.PROC_BIND) != 0)
|
||||
{
|
||||
AddDescText(0, true, "[Bind on Use]");
|
||||
}
|
||||
}
|
||||
|
||||
protected void AddActionTypeDescText(int action_type)
|
||||
{
|
||||
// Action/weapon type formatting can be added later as needed.
|
||||
}
|
||||
|
||||
protected void TrimLastReturn()
|
||||
@@ -1247,7 +1300,10 @@ namespace BrewMonster.Scripts.Managers
|
||||
if (string.IsNullOrEmpty(m_strDesc))
|
||||
return;
|
||||
|
||||
if (m_strDesc.EndsWith("\n", StringComparison.Ordinal))
|
||||
// Remove trailing "\r" or "\n" for consistency with C++ style
|
||||
if (m_strDesc.EndsWith("\\r", StringComparison.Ordinal))
|
||||
m_strDesc = m_strDesc.Substring(0, m_strDesc.Length - 2);
|
||||
else if (m_strDesc.EndsWith("\n", StringComparison.Ordinal))
|
||||
m_strDesc = m_strDesc.Substring(0, m_strDesc.Length - 1);
|
||||
}
|
||||
|
||||
@@ -1263,6 +1319,7 @@ namespace BrewMonster.Scripts.Managers
|
||||
|
||||
protected int GetColorStrID(int tid)
|
||||
{
|
||||
// Placeholder: color index lookup; return -1 (white) by default.
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1273,6 +1330,77 @@ namespace BrewMonster.Scripts.Managers
|
||||
return (int)(f * 100.0f + 0.5f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to get the main description line for this item from item_desc.txt via EC_Game.
|
||||
/// This mirrors the behaviour used by Inventory UI and NPC shop, but centralised here.
|
||||
/// </summary>
|
||||
private string TryGetItemMainDesc()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (EC_Game.TryGetItemMsg(m_tid, out int messageId, out int displayMode))
|
||||
{
|
||||
var tab = EC_Game.GetItemDesc();
|
||||
if (tab != null && tab.IsInitialized())
|
||||
{
|
||||
var s = tab.GetWideString(messageId);
|
||||
if (!string.IsNullOrEmpty(s)) return s;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: direct template id lookup
|
||||
{
|
||||
var tab = EC_Game.GetItemDesc();
|
||||
if (tab != null && tab.IsInitialized())
|
||||
{
|
||||
var s = tab.GetWideString(m_tid);
|
||||
if (!string.IsNullOrEmpty(s)) return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[EC_IvtrItem] Error getting main description for tid={m_tid}: {ex.Message}");
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to get the extended description line from item_ext_desc.txt.
|
||||
/// </summary>
|
||||
private string TryGetItemExtDesc()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (EC_Game.TryGetItemMsg(m_tid, out int messageId, out int displayMode))
|
||||
{
|
||||
var tab = EC_Game.GetItemExtDesc();
|
||||
if (tab != null && tab.IsInitialized())
|
||||
{
|
||||
var s = tab.GetWideString(messageId);
|
||||
if (!string.IsNullOrEmpty(s)) return s;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: direct id
|
||||
{
|
||||
var tab = EC_Game.GetItemExtDesc();
|
||||
if (tab != null && tab.IsInitialized())
|
||||
{
|
||||
var s = tab.GetWideString(m_tid);
|
||||
if (!string.IsNullOrEmpty(s)) return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[EC_IvtrItem] Error getting extended description for tid={m_tid}: {ex.Message}");
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -114,31 +114,35 @@ public class NPCShopDetailPanel : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
string GetItemDescription(int itemId)
|
||||
string GetItemDescription(int itemId)
|
||||
{
|
||||
// First check if description is already in the item data
|
||||
if (!string.IsNullOrEmpty(currentItem.desc))
|
||||
{
|
||||
return currentItem.desc;
|
||||
}
|
||||
|
||||
// Otherwise, get description from EC_IvtrItem
|
||||
try
|
||||
{
|
||||
EC_IvtrItem item = EC_IvtrItem.CreateItem(itemId, 0, 1);
|
||||
if (item != null)
|
||||
|
||||
// Otherwise, build description using the same central pipeline as inventory:
|
||||
try
|
||||
{
|
||||
item.GetDetailDataFromLocal();
|
||||
string description = item.GetDesc();
|
||||
return !string.IsNullOrEmpty(description) ? description : "No description available.";
|
||||
EC_IvtrItem item = EC_IvtrItem.CreateItem(itemId, 0, 1);
|
||||
if (item != null)
|
||||
{
|
||||
// For NPC shop, we typically have static data only, so load from local DB
|
||||
item.GetDetailDataFromLocal();
|
||||
string description = item.GetDesc();
|
||||
if (!string.IsNullOrEmpty(description))
|
||||
{
|
||||
return description.Replace("\\r", "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[NPCShopDetailPanel] Failed to get description for item {itemId}: {ex.Message}");
|
||||
}
|
||||
|
||||
return "No description available.";
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[NPCShopDetailPanel] Failed to get description for item {itemId}: {ex.Message}");
|
||||
}
|
||||
|
||||
return "No description available.";
|
||||
}
|
||||
|
||||
void OnCloseClicked()
|
||||
|
||||
Reference in New Issue
Block a user