update ui DlgInstall.prefab
This commit is contained in:
@@ -31,3 +31,5 @@ MonoBehaviour:
|
||||
prefab: {fileID: 5750242998044155948, guid: ecf0d8daf08db6f4a8d94a4bb07847ec, type: 3}
|
||||
- id: Win_Inventory
|
||||
prefab: {fileID: 5910006447059157136, guid: 22d3972b131ebdb4288f9cbdf996d691, type: 3}
|
||||
- id: Win_Enchase
|
||||
prefab: {fileID: 5636724581774400035, guid: de6ac6f2630425044a55299c703670f1, type: 3}
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
using BrewMonster.Network;
|
||||
using BrewMonster.Scripts.Managers;
|
||||
using BrewMonster.Scripts.Task;
|
||||
using BrewMonster.UI;
|
||||
using CSNetwork;
|
||||
using ModelRenderer.Scripts.Common;
|
||||
using PerfectWorld.Scripts.Managers;
|
||||
using PerfectWorld.Scripts.Task;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace BrewMonster
|
||||
{
|
||||
public class DlgInstall : AUIDialog
|
||||
{
|
||||
[Header("Slot First")]
|
||||
[SerializeField] private Transform m_SlotFirstParent;
|
||||
[SerializeField] private TextMeshProUGUI m_TxtFirstName;
|
||||
|
||||
[Header("Slot Second")]
|
||||
[SerializeField] private Transform m_SlotSecondlParent;
|
||||
[SerializeField] private TextMeshProUGUI m_TxtSecondName;
|
||||
|
||||
[Header("Buttons and Money")]
|
||||
[SerializeField] private TextMeshProUGUI m_TxtMoney;
|
||||
[SerializeField] private Button m_BtnInstall;
|
||||
[SerializeField] private Button m_BtnCancel;
|
||||
|
||||
[Header("Item Info Panel")]
|
||||
public Transform itemInfoRoot;
|
||||
public TextMeshProUGUI infoNameText;
|
||||
public TextMeshProUGUI infoDescText;
|
||||
public TextMeshProUGUI infoExtraText;
|
||||
|
||||
private EC_IvtrItem m_SelectedEquip;
|
||||
private EC_IvtrItem m_SelectedMaterial;
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
RegisterDrop(m_SlotFirstParent, OnDropEquip);
|
||||
RegisterDrop(m_SlotSecondlParent, OnDropMaterial);
|
||||
RegisterClick(m_SlotFirstParent, OnClickEquipSlot);
|
||||
RegisterClick(m_SlotSecondlParent, OnClickMaterialSlot);
|
||||
|
||||
// Hide item info panel initially
|
||||
if (itemInfoRoot != null)
|
||||
itemInfoRoot.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void OnpenInstall(uint npcId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void CloseInstall()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void RegisterDrop(Transform target, Action<PointerEventData> callback)
|
||||
{
|
||||
var trigger = target.GetComponent<EventTrigger>();
|
||||
if (trigger == null)
|
||||
trigger = target.gameObject.AddComponent<EventTrigger>();
|
||||
|
||||
trigger.triggers.Clear();
|
||||
|
||||
var entry = new EventTrigger.Entry
|
||||
{
|
||||
eventID = EventTriggerType.Drop
|
||||
};
|
||||
entry.callback.AddListener((data) =>
|
||||
{
|
||||
callback((PointerEventData)data);
|
||||
});
|
||||
|
||||
trigger.triggers.Add(entry);
|
||||
}
|
||||
|
||||
private void RegisterClick(Transform target, Action<PointerEventData> callback)
|
||||
{
|
||||
var trigger = target.GetComponent<EventTrigger>();
|
||||
if (trigger == null)
|
||||
trigger = target.gameObject.AddComponent<EventTrigger>();
|
||||
|
||||
var entry = new EventTrigger.Entry
|
||||
{
|
||||
eventID = EventTriggerType.PointerClick
|
||||
};
|
||||
entry.callback.AddListener((data) =>
|
||||
{
|
||||
callback((PointerEventData)data);
|
||||
});
|
||||
|
||||
trigger.triggers.Add(entry);
|
||||
}
|
||||
|
||||
private void OnClickEquipSlot(PointerEventData eventData)
|
||||
{
|
||||
if (m_SelectedEquip != null)
|
||||
{
|
||||
ShowItemInfo(m_SelectedEquip);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickMaterialSlot(PointerEventData eventData)
|
||||
{
|
||||
if (m_SelectedMaterial != null)
|
||||
{
|
||||
ShowItemInfo(m_SelectedMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowItemInfo(EC_IvtrItem item)
|
||||
{
|
||||
if (item == null || itemInfoRoot == null)
|
||||
return;
|
||||
|
||||
itemInfoRoot.gameObject.SetActive(true);
|
||||
|
||||
if (infoDescText != null)
|
||||
{
|
||||
string rawDesc = item.GetDesc();
|
||||
|
||||
// Process the description: replace \\r with newlines and handle color codes
|
||||
string processedDesc = EC_Utility.ProcessColorCodes(new StringBuilder(rawDesc.Replace("\\r", "\n")));
|
||||
|
||||
infoDescText.text = processedDesc;
|
||||
|
||||
Debug.Log($"[Install] Raw desc: {rawDesc}");
|
||||
Debug.Log($"[Install] Processed desc: {processedDesc}");
|
||||
}
|
||||
|
||||
// Force rebuild layout to ensure proper sizing
|
||||
ForceRefreshItemInfoLayout();
|
||||
|
||||
Debug.Log($"[Install] Showing info for item: {item.GetName()}");
|
||||
}
|
||||
|
||||
private void ForceRefreshItemInfoLayout()
|
||||
{
|
||||
if (itemInfoRoot == null)
|
||||
return;
|
||||
|
||||
var rt = itemInfoRoot.GetComponent<RectTransform>();
|
||||
if (rt != null)
|
||||
{
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(rt);
|
||||
}
|
||||
}
|
||||
|
||||
private void HideItemInfo()
|
||||
{
|
||||
if (itemInfoRoot != null)
|
||||
itemInfoRoot.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private EC_IvtrItem GetItemFromDrag(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.pointerDrag == null)
|
||||
return null;
|
||||
|
||||
var btn = eventData.pointerDrag.GetComponent<Button>();
|
||||
if (btn == null)
|
||||
return null;
|
||||
|
||||
// Slot index
|
||||
int slotIndex = btn.transform.GetSiblingIndex();
|
||||
|
||||
// Inventory package = 0
|
||||
var host = CECGameRun.Instance?.GetHostPlayer();
|
||||
if (host == null)
|
||||
return null;
|
||||
|
||||
var inv = host.GetInventory(0);
|
||||
if (inv == null)
|
||||
return null;
|
||||
|
||||
return inv.GetItem(slotIndex, false);
|
||||
}
|
||||
|
||||
private void OnDropEquip(PointerEventData eventData)
|
||||
{
|
||||
var item = GetItemFromDrag(eventData);
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
m_SelectedEquip = item;
|
||||
m_TxtFirstName.text = item.GetName();
|
||||
SetSlotIcon(m_SlotFirstParent, item);
|
||||
|
||||
Debug.Log($"[Install] Equiment: {item.m_tid}");
|
||||
}
|
||||
|
||||
private void OnDropMaterial(PointerEventData eventData)
|
||||
{
|
||||
var item = GetItemFromDrag(eventData);
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
m_SelectedMaterial = item;
|
||||
m_TxtSecondName.text = item.GetName();
|
||||
|
||||
SetSlotIcon(m_SlotSecondlParent, item);
|
||||
|
||||
Debug.Log($"[Install] Attached material: {item.m_tid}");
|
||||
}
|
||||
|
||||
private void SetSlotIcon(Transform slot, EC_IvtrItem item)
|
||||
{
|
||||
if (slot == null || item == null)
|
||||
return;
|
||||
|
||||
var img = slot.GetComponentInChildren<Image>(true);
|
||||
if (img == null)
|
||||
return;
|
||||
|
||||
img.sprite = EC_IvtrItemUtils.Instance.ResolveItemIconSprite(item.m_tid);
|
||||
img.enabled = img.sprite != null;
|
||||
|
||||
img.color = Color.white;
|
||||
img.SetNativeSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0785d9ccbdc425a44b6ae1f4a3afad06
|
||||
@@ -3403,8 +3403,33 @@ namespace BrewMonster.UI
|
||||
}
|
||||
else if (idFunction == (int)SERVICE_TYPE.NPC_INSTALL)
|
||||
{
|
||||
pShow1 = m_pAUIManager.GetDialog("Win_Enchase");
|
||||
pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
|
||||
if (pCurNPCEssence.HasValue)
|
||||
{
|
||||
uint npcID = pCurNPCEssence.Value.id;
|
||||
DlgInstall dlgInstall = FindFirstObjectByType<DlgInstall>();
|
||||
if (dlgInstall == null)
|
||||
{
|
||||
CECGameUIMan gameUIMan = GetGameUIMan();
|
||||
DialogScriptTableObject dialogResource = gameUIMan.GetDialogResource();
|
||||
Canvas canvas = gameUIMan.GetCanvas();
|
||||
|
||||
if(dialogResource != null && canvas != null)
|
||||
{
|
||||
GameObject ob = dialogResource.GetPrefabDialog("Win_Enchase");
|
||||
if (ob != null)
|
||||
{
|
||||
dlgInstall = GameObject.Instantiate(ob, canvas.transform).GetComponent<DlgInstall>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(dlgInstall != null)
|
||||
{
|
||||
dlgInstall.OnpenInstall(npcID);
|
||||
}
|
||||
}
|
||||
//pShow1 = m_pAUIManager.GetDialog("Win_Enchase");
|
||||
//pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
|
||||
}
|
||||
else if (idFunction == (int)SERVICE_TYPE.NPC_UNINSTALL)
|
||||
{
|
||||
|
||||
@@ -11582,13 +11582,12 @@ MonoBehaviour:
|
||||
detailPanelRoot: {fileID: 1753167144210994885}
|
||||
detailPanelOffset: {x: 20, y: 0}
|
||||
hideDetailOnStart: 1
|
||||
itemInfoRoot: {fileID: 0}
|
||||
nameText:
|
||||
legacy: {fileID: 0}
|
||||
tmp: {fileID: 4926468606842631984}
|
||||
tmp: {fileID: 7304082661431364846}
|
||||
descriptionText:
|
||||
legacy: {fileID: 0}
|
||||
tmp: {fileID: 0}
|
||||
tmp: {fileID: 4926468606842631984}
|
||||
extendedDescText:
|
||||
legacy: {fileID: 0}
|
||||
tmp: {fileID: 0}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de6ac6f2630425044a55299c703670f1
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user