c1_lua/lua/app/ui/common/cell/equip_cell.lua
2025-10-26 18:10:13 +08:00

188 lines
4.8 KiB
Lua

local EquipCell = class("EquipCell", BaseCell)
function EquipCell:init()
local uiMap = self:getUIMap()
self.qltImg = uiMap["equip_cell.content.qlt_img"]
self.iconImg = uiMap["equip_cell.content.icon_img"]
self.lvTx = uiMap["equip_cell.content.lv_tx"]
self.mask = uiMap["equip_cell.mask"]
self.check = uiMap["equip_cell.check"]
self.lock = uiMap["equip_cell.lock"]
self.select = uiMap["equip_cell.select"]
self.light = uiMap["equip_cell.light"]
self.refineBg = uiMap["equip_cell.content.refine_bg"]
self.refineBgTx = uiMap["equip_cell.content.refine_bg.refine_tx"]
self.starNode = uiMap["equip_cell.content.star_cell"]
self.starImgs = {}
for i = 1, 5 do
self.starImgs[i] = uiMap["equip_cell.content.star_cell.star_img_" .. i]
end
-- self:hideEffectUp()
end
-- function EquipCell:setParentUI(parent)
-- self.parentUI = parent
-- end
function EquipCell:refresh(entity, slotId, showMask, showCheck, showLock)
if entity == nil then
return
end
self:_refresh(entity, showMask, showCheck, showLock)
local lv = entity:getPartLv(slotId)
if lv then
self.lvTx:setText(I18N:getGlobalText(I18N.GlobalConst.LV_POINT) .. lv)
else
self.lvTx:setText("")
end
if slotId then
local part = entity:getPart()
local uid = entity:getUid()
if uid and uid > 0 then
local equipUid = DataManager.EquipData:getPartEquipUid(slotId, part)
if equipUid and equipUid == uid then
self.refineBg:setActive(true)
self.refineBgTx:setText(DataManager.EquipData:getPartRefine(slotId, part))
else
self.refineBg:setActive(false)
end
else
self.refineBg:setActive(false)
end
else
self.lvTx:setText("")
self.refineBg:setActive(false)
end
end
function EquipCell:refreshByCfg(id, showMask, showCheck, showLock)
if id == nil then
return
end
local entity = DataManager.EquipData:getEquipByCfgId(id)
self:_refresh(entity, showMask, showCheck, showLock)
self.lvTx:setText("")
self.refineBg:setActive(false)
end
function EquipCell:_refresh(entity, showMask, showCheck, showLock)
local qlt = entity:getQlt()
local icon = entity:getIconRes()
local star = entity:getStar()
self.qltImg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. qlt)
self.iconImg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, icon)
self.iconImg:setActive(true)
for i, v in ipairs(self.starImgs) do
if i <= star then
v:setActive(true)
v:setSprite(GConst.ATLAS_PATH.COMMON, "common_star_1")
else
v:setActive(false)
end
end
self.starNode:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout()
self:showMask(showMask)
self:showCheck(showCheck)
self:showLock(showLock)
self:showSelect(false)
self:showLight(false)
end
function EquipCell:refreshEmpty(part, showSelect)
-- self.qltImg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_0")
self.iconImg:setActive(false)
self.qltImg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "force_frame_" .. part)
self.lvTx:setText("")
self.refineBg:setActive(false)
self.starNode:setActive(false)
self:showMask(false)
self:showCheck(false)
self:showLock(false)
self:showSelect(showSelect or false)
self:showLight(false)
end
function EquipCell:setShowLv(show)
self.levelNode:setActive(show)
end
function EquipCell:showMask(show)
self.mask:setActive(show)
end
function EquipCell:showCheck(show)
self.check:setActive(show)
end
function EquipCell:showLock(show)
self.lock:setActive(show)
end
function EquipCell:showSelect(show)
self.select:setActive(show)
end
function EquipCell:showLight(show)
self.light:setActive(show)
end
function EquipCell:setTouchEnable(enable)
self:getBaseObject():setTouchEnable(enable == true)
end
function EquipCell:addClickListener(func)
self:getBaseObject():addClickListener(func)
end
function EquipCell:removeClickListener()
self:getBaseObject():removeClickListener()
end
function EquipCell:getAnchoredPositionX()
return self:getBaseObject():getAnchoredPositionX()
end
function EquipCell:setVisible(visible, scale)
self:getBaseObject():setVisible(visible, scale)
end
function EquipCell:setActive(active)
self:getBaseObject():setActive(active)
end
function EquipCell:addRedPoint(offsetX, offsetY, scale)
self:getBaseObject():addRedPoint(offsetX, offsetY, scale)
end
function EquipCell:removeRedPoint()
self:getBaseObject():removeRedPoint()
end
-- function EquipCell:showEffectUp()
-- if self.effectUp == nil and self.parentUI then
-- EffectManager:loadUIEffectAsync("assets/prefabs/effects/ui/vfx_ui_b9_yjqh_b01.prefab", self.parentUI, self.baseObject, GConst.UI_EFFECT_ORDER.LEVEL5, function(obj)
-- obj:setLocalScale(1, 1, 1)
-- obj:setAnchoredPosition(0, 0, 0)
-- obj:play()
-- self.effectUp = obj
-- self.baseObject:performWithDelayGlobal(function()
-- self:hideEffectUp()
-- end, 0.5)
-- end)
-- end
-- end
-- function EquipCell:hideEffectUp()
-- if self.effectUp then
-- self.effectUp:setActive(false)
-- end
-- end
return EquipCell