//********************* // create by 流云 // time: Mon Nov 03 2025 // desc: //********************* import { _decorator, Node, find, Label, sp } from 'cc'; import { Auto_ItemDetailBox } from './Auto_ItemDetailBox'; import { SpriteLoad } from 'db://assets/mx/components/SpriteLoad'; import { GPath, GBundle } from '../../game/ConfigRes'; import { applyItemQualityFrame } from '../../com/ItemQualityFrame'; import { ItemData } from '../../game/ConfigProjectData'; import { ItemGrid } from '../../com/ItemGrid'; const { ccclass } = _decorator; @ccclass('UIItemDetailBox') export class UIItemDetailBox extends Auto_ItemDetailBox { nameLab: Label; descLab: Label; desc2Lab: Label; grid: ItemGrid; onLoad(): void { super.onLoad(); this.nameLab = find('center/nameLab', this.node)?.getComponent(Label); this.descLab = find('center/descLab', this.node)?.getComponent(Label); this.desc2Lab = find('center/desc2Lab', this.node)?.getComponent(Label); this.grid = find('center/grid', this.node)?.getComponent(ItemGrid); // ItemDetailBox2 无关闭按钮,仅遮罩关闭 if (!this.btnClose) { this.btnClose = find('center/btnClose', this.node); } } onEnable(): void { // 不调 Auto.onEnable:ItemDetailBox2 无 btnClose,会对 null 调 on this.bgMask.on(Node.EventType.TOUCH_END, this.click_bgMask, this); if (this.btnClose) { this.btnClose.on(Node.EventType.TOUCH_END, this.click_btnClose, this); } } onDisable(): void { this.bgMask.off(Node.EventType.TOUCH_END, this.click_bgMask, this); if (this.btnClose) { this.btnClose.off(Node.EventType.TOUCH_END, this.click_btnClose, this); } } onInit(): void { let data = this.prema if (data) { this.updateUI(data) } } updateUI(data) { let id = data.id let itemData = null; if (data.isFragment) { let conf = gg.data.project.getWeaponData(data.id); if (!conf) { console.error('[UIItemDetailBox] missing Weapon1 for fragment', data.id); return; } let suipianId = gg.data.project.getWeaponScrapId(conf.id); itemData = gg.data.table.getItemData(suipianId) } else { itemData = gg.data.table.getItemData(id) if (!itemData) { console.error('[UIItemDetailBox] missing Item', id); return; } //let res = id; if (itemData.type == 8) { let conf = gg.data.project.getWeaponData(itemData.weapon_type); if (!conf) { console.error('[UIItemDetailBox] missing Weapon1 for item.weapon_type', itemData.weapon_type); return; } let suipianId = gg.data.project.getWeaponScrapId(conf.id); itemData = gg.data.table.getItemData(suipianId) //res = id - 200 + 20; data.isFragment = true } } let num = data?.num ?? 1; let item = new ItemData(num); item.id = id; item.staticData = itemData; item.isFragment = data.isFragment; this.grid.setData(item); if (data.isFragment) { this.nameLab.string = gg.lang.get(itemData.name) //名字去掉碎片两个字 let isHaveWeaponEquipped = gg.data.project.isWeaponUnlocked(id); let desc = itemData.name.replace('碎片', '') this.nameLab.string = gg.lang.get(desc) this.descLab.string = gg.lang.get(itemData.desc2) if (isHaveWeaponEquipped) { this.desc2Lab.string = gg.lang.get('拥有数量:{1}', [1]) } else { this.desc2Lab.string = gg.lang.get('拥有数量:{1}', [0]) } } else { this.nameLab.string = gg.lang.get(itemData.name) //名字去掉碎片两个字 // let desc = itemData.name.replace('碎片', '') this.descLab.string = itemData.desc1 let haveNum = gg.data.getItemNum(data.id) this.desc2Lab.string = gg.lang.get('拥有数量:{1}', [haveNum]) } } click_bgMask(): void { this.close(2) } click_btnClose(): void { this.close(2); } }