This commit is contained in:
puxuan 2025-10-08 10:56:11 +08:00
parent 45e600be69
commit 4936a7502e
2 changed files with 67 additions and 71 deletions

View File

@ -32,33 +32,32 @@ end
function HeroDetailUI:onLoadRootComplete() function HeroDetailUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
self.root:addClickListener(function() -- self.root:addClickListener(function()
self:closeUI() -- self:closeUI()
end) -- end)
-- uiMap["hero_detail_ui.mask"]:addClickListener(function() -- uiMap["hero_detail_ui.mask"]:addClickListener(function()
-- self:closeUI() -- self:closeUI()
-- end) -- end)
uiMap["hero_detail_ui.common.close_btn"]:addClickListener(function() uiMap["hero_detail_ui.bottom.close_btn"]:addClickListener(function()
self:closeUI() self:closeUI()
end) end)
self.heroInfo = uiMap["hero_detail_ui.hero_info"] self.heroInfo = uiMap["hero_detail_ui.middle.hero_info"]
self.starInfo = uiMap["hero_detail_ui.star_info"] self.starInfo = uiMap["hero_detail_ui.middle.star_info"]
self.equipInfo = uiMap["hero_detail_ui.equip_info"] self.equipInfo = uiMap["hero_detail_ui.middle.equip_info"]
self.titleTx = uiMap["hero_detail_ui.common.name_tx"] self.titleTx = uiMap["hero_detail_ui.top.name_tx"]
self.bg = uiMap["hero_detail_ui.common.bg"] self.leftBtn = uiMap["hero_detail_ui.top.left_btn"]
self.leftBtn = uiMap["hero_detail_ui.common.left_btn"] self.rightBtn = uiMap["hero_detail_ui.top.right_btn"]
self.rightBtn = uiMap["hero_detail_ui.common.right_btn"]
self.heroNode = uiMap["hero_detail_ui.hero_node"] self.heroNode = uiMap["hero_detail_ui.hero_node"]
self.elementBg = uiMap["hero_detail_ui.common.hero_node.element_bg"] -- self.elementBg = uiMap["hero_detail_ui.top.hero_node.element_bg"]
self.elementDesc = uiMap["hero_detail_ui.common.hero_node.element_bg.element_desc_tx"] -- self.elementDesc = uiMap["hero_detail_ui.top.hero_node.element_bg.element_desc_tx"]
self.heroElement = uiMap["hero_detail_ui.common.hero_node.hero_element"] self.heroElement = uiMap["hero_detail_ui.top.hero_element"]
self.spineObjAvatar = uiMap["hero_detail_ui.common.hero_node.ui_spine_obj_avatar"] self.spineObjAvatar = uiMap["hero_detail_ui.top.hero_node.ui_spine_obj_avatar"]
self.powerTx = uiMap["hero_detail_ui.common.power_img.power_tx"] self.powerTx = uiMap["hero_detail_ui.top.power_img.power_tx"]
self.qltBg = uiMap["hero_detail_ui.common.qlt_bg"] self.qltBg = uiMap["hero_detail_ui.top.qlt_bg"]
self.qltBgTx = uiMap["hero_detail_ui.common.qlt_bg.qlt_tx"] self.qltBgTx = uiMap["hero_detail_ui.top.qlt_bg.qlt_tx"]
self.starComp = uiMap["hero_detail_ui.common.hero_node.star_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.STAR_CELL) self.starComp = uiMap["hero_detail_ui.top.star_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.STAR_CELL)
self.btnTxs = {I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4), I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_16), I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1)} self.btnTxs = {I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4), I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_16), I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1)}
self.pageBtns = {} self.pageBtns = {}
@ -67,9 +66,9 @@ function HeroDetailUI:onLoadRootComplete()
self.pageRedBgs = {} self.pageRedBgs = {}
self.pageRedImgs = {} self.pageRedImgs = {}
for i = 1, 3 do for i = 1, 3 do
self.pageBtns[i] = uiMap["hero_detail_ui.common.btns.page_btn_" .. i] self.pageBtns[i] = uiMap["hero_detail_ui.bottom.btns.page_btn_" .. i]
self.pageBtnTxs[i] = uiMap["hero_detail_ui.common.btns.page_btn_" .. i .. ".text"] self.pageBtnTxs[i] = uiMap["hero_detail_ui.bottom.btns.page_btn_" .. i .. ".text"]
self.pageBtnLocks[i] = uiMap["hero_detail_ui.common.btns.page_btn_" .. i .. ".lock_img"] self.pageBtnLocks[i] = uiMap["hero_detail_ui.bottom.btns.page_btn_" .. i .. ".lock_img"]
self.pageRedBgs[i] = uiMap["hero_detail_ui.red_node.red_img_" .. i] self.pageRedBgs[i] = uiMap["hero_detail_ui.red_node.red_img_" .. i]
self.pageRedImgs[i] = uiMap["hero_detail_ui.red_node.red_img_" .. i .. ".red_img"] self.pageRedImgs[i] = uiMap["hero_detail_ui.red_node.red_img_" .. i .. ".red_img"]
if self.pageBtnLocks[i] then if self.pageBtnLocks[i] then
@ -165,16 +164,16 @@ end
function HeroDetailUI:updateHero() function HeroDetailUI:updateHero()
local matchType = self.heroEntity:getMatchType() local matchType = self.heroEntity:getMatchType()
self.elementDesc:setText(ModuleManager.HeroManager:getMatchTypeName(matchType)) -- self.elementDesc:setText(ModuleManager.HeroManager:getMatchTypeName(matchType))
local elementTxRectWidth = self.elementDesc:getRectWidth() -- local elementTxRectWidth = self.elementDesc:getRectWidth()
local elementTxWidth = self.elementDesc:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth -- local elementTxWidth = self.elementDesc:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth
if elementTxWidth > elementTxRectWidth then -- if elementTxWidth > elementTxRectWidth then
self.elementBg:setSizeDeltaX(52 + elementTxWidth) -- self.elementBg:setSizeDeltaX(52 + elementTxWidth)
else -- else
self.elementBg:setSizeDeltaX(52 + elementTxRectWidth) -- self.elementBg:setSizeDeltaX(52 + elementTxRectWidth)
end -- end
self.elementBg:setSprite(ModuleManager.HeroManager:getMatchTypeBg(matchType)) -- self.elementBg:setSprite(ModuleManager.HeroManager:getMatchTypeBg(matchType))
self.heroElement:setSprite(GConst.ATLAS_PATH.ICON_HERO, ModuleManager.HeroManager:getMatchTypeIcon(matchType)) self.heroElement:setSprite(GConst.ATLAS_PATH.ICON_HERO, ModuleManager.HeroManager:getMatchTypeIcon(matchType))
self.spineObjAvatar:getSkeletonGraphic().enabled = false self.spineObjAvatar:getSkeletonGraphic().enabled = false
self.spineObjAvatar:loadAssetAsync(self.heroEntity:getModelId(), function() self.spineObjAvatar:loadAssetAsync(self.heroEntity:getModelId(), function()
@ -231,7 +230,6 @@ function HeroDetailUI:showHeroInfo()
self.heroInfo:setActive(true) self.heroInfo:setActive(true)
self.starInfo:setActive(false) self.starInfo:setActive(false)
self.equipInfo:setActive(false) self.equipInfo:setActive(false)
self.bg:setActive(true)
local power = self.heroEntity:getPower() local power = self.heroEntity:getPower()
self.powerTx:setText(GFunc.num2Str2(power, 2)) self.powerTx:setText(GFunc.num2Str2(power, 2))
@ -250,7 +248,6 @@ function HeroDetailUI:showStarInfo()
self.heroInfo:setActive(false) self.heroInfo:setActive(false)
self.starInfo:setActive(true) self.starInfo:setActive(true)
self.equipInfo:setActive(false) self.equipInfo:setActive(false)
self.bg:setActive(true)
if not self.compStar then if not self.compStar then
self.starInfo:initPrefabHelper() self.starInfo:initPrefabHelper()
@ -267,7 +264,6 @@ function HeroDetailUI:showEquipInfo()
self.heroInfo:setActive(false) self.heroInfo:setActive(false)
self.starInfo:setActive(false) self.starInfo:setActive(false)
self.equipInfo:setActive(true) self.equipInfo:setActive(true)
self.bg:setActive(true)
if not self.compEquip then if not self.compEquip then
self.equipInfo:initPrefabHelper() self.equipInfo:initPrefabHelper()

View File

@ -15,7 +15,7 @@ function HeroInfoComp:init()
self.txUpdesc = uiMap["hero_info.up.up_btn.text"] self.txUpdesc = uiMap["hero_info.up.up_btn.text"]
self.btnUp5 = uiMap["hero_info.up.up_5_btn"] self.btnUp5 = uiMap["hero_info.up.up_5_btn"]
self.txUpdesc5 = uiMap["hero_info.up.up_5_btn.text"] self.txUpdesc5 = uiMap["hero_info.up.up_5_btn.text"]
self.txLv = uiMap["hero_info.lv_desc"] self.lvTx = uiMap["hero_info.bg_4.lv_tx"]
self.txElement = uiMap["hero_info.element_bg.element_desc"] self.txElement = uiMap["hero_info.element_bg.element_desc"]
self.txSkill = uiMap["hero_info.skill_desc"] self.txSkill = uiMap["hero_info.skill_desc"]
self.btnskillDescTxs = uiMap["hero_info.skill_desc.btn_skill_desc"] self.btnskillDescTxs = uiMap["hero_info.skill_desc.btn_skill_desc"]
@ -30,15 +30,15 @@ function HeroInfoComp:init()
self.bgElement = uiMap["hero_info.element_bg"] self.bgElement = uiMap["hero_info.element_bg"]
self.btnAttr = uiMap["hero_info.bg_6.attr_btn"] self.btnAttr = uiMap["hero_info.bg_6.attr_btn"]
self.gotoBtn = uiMap["hero_info.up.goto_btn"] self.gotoBtn = uiMap["hero_info.up.goto_btn"]
self.needStarNode = uiMap["hero_info.up.need_star_node"] -- self.needStarNode = uiMap["hero_info.up.need_star_node"]
self.needStarNodeDescTx1 = uiMap["hero_info.up.need_star_node.desc_tx_1"] -- self.needStarNodeDescTx1 = uiMap["hero_info.up.need_star_node.desc_tx_1"]
self.needStarNodeStarImg = uiMap["hero_info.up.need_star_node.star_img"] -- self.needStarNodeStarImg = uiMap["hero_info.up.need_star_node.star_img"]
self.needStarNodeDescTx2 = uiMap["hero_info.up.need_star_node.desc_tx_2"] -- self.needStarNodeDescTx2 = uiMap["hero_info.up.need_star_node.desc_tx_2"]
uiMap["hero_info.up.goto_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_22)) -- uiMap["hero_info.up.goto_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_22))
self.needStarNodeDescTx2:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_20)) -- self.needStarNodeDescTx2:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_20))
local meshProComp = self.needStarNodeDescTx2:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO) -- local meshProComp = self.needStarNodeDescTx2:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO)
local contentWidth = meshProComp.preferredWidth -- local contentWidth = meshProComp.preferredWidth
self.needStarNodeDescTx2:setSizeDeltaX(contentWidth) -- self.needStarNodeDescTx2:setSizeDeltaX(contentWidth)
self.bg5Vfx01 = uiMap["hero_info.bg_5.vfx_c1_ui_up_b01"] self.bg5Vfx01 = uiMap["hero_info.bg_5.vfx_c1_ui_up_b01"]
self.bg6Vfx01 = uiMap["hero_info.bg_6.vfx_c1_ui_up_b01"] self.bg6Vfx01 = uiMap["hero_info.bg_6.vfx_c1_ui_up_b01"]
@ -46,9 +46,9 @@ function HeroInfoComp:init()
self.skillIcon = {} self.skillIcon = {}
self.skillDescTxs = {} self.skillDescTxs = {}
for i = 1, 4 do for i = 1, 4 do
self.skill[i] = uiMap["hero_info.skill_up_" .. i] self.skill[i] = uiMap["hero_info.skill_node.skill_up_" .. i]
self.skillIcon[i] = uiMap["hero_info.skill_up_" .. i .. ".icon"] self.skillIcon[i] = uiMap["hero_info.skill_node.skill_up_" .. i .. ".icon"]
self.skillDescTxs[i] = uiMap["hero_info.skill_up_" .. i .. ".desc_tx"] self.skillDescTxs[i] = uiMap["hero_info.skill_node.skill_up_" .. i .. ".desc_tx"]
end end
self.costCells = {} self.costCells = {}
@ -56,10 +56,10 @@ function HeroInfoComp:init()
self.costCells[i] = uiMap["hero_info.up.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL) self.costCells[i] = uiMap["hero_info.up.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
end end
self.lvUpVfxs = {} -- self.lvUpVfxs = {}
for i = 1, 5 do -- for i = 1, 5 do
self.lvUpVfxs[i] = uiMap["hero_info.vfx_c1_ui_uplight_b0" .. i] -- self.lvUpVfxs[i] = uiMap["hero_info.vfx_c1_ui_uplight_b0" .. i]
end -- end
self.spineObj:setVisible(false) self.spineObj:setVisible(false)
self.txUpdesc:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_15, 1)) self.txUpdesc:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_15, 1))
@ -108,9 +108,9 @@ end
function HeroInfoComp:refresh(checkLevel) function HeroInfoComp:refresh(checkLevel)
local isLvChange = checkLevel and self.curLevel ~= self.heroEntity:getLv() local isLvChange = checkLevel and self.curLevel ~= self.heroEntity:getLv()
self.txLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, self.heroEntity:getLv())) self.lvTx:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_26, self.heroEntity:getLv()))
-- local lvTxW = self.txLv:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth -- local lvTxW = self.lvTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth
-- self.txLv:setSizeDeltaX(lvTxW) -- self.lvTx:setSizeDeltaX(lvTxW)
self.txSkill:setText(ModuleManager.HeroManager:getSkillDesc(self.heroEntity:getBaseSkill())) self.txSkill:setText(ModuleManager.HeroManager:getSkillDesc(self.heroEntity:getBaseSkill()))
self.txHpName:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2)) self.txHpName:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2))
@ -177,7 +177,7 @@ function HeroInfoComp:refresh(checkLevel)
self.btnUp:setActive(false) self.btnUp:setActive(false)
self.btnUp5:setActive(false) self.btnUp5:setActive(false)
self.gotoBtn:setActive(false) self.gotoBtn:setActive(false)
self.needStarNode:setActive(false) -- self.needStarNode:setActive(false)
for i,v in ipairs(self.costCells) do for i,v in ipairs(self.costCells) do
v:setActive(false) v:setActive(false)
end end
@ -202,7 +202,7 @@ function HeroInfoComp:refresh(checkLevel)
self.btnUp:setActive(false) self.btnUp:setActive(false)
self.btnUp5:setActive(false) self.btnUp5:setActive(false)
self.gotoBtn:setActive(false) self.gotoBtn:setActive(false)
self.needStarNode:setActive(false) -- self.needStarNode:setActive(false)
for i,v in ipairs(self.costCells) do for i,v in ipairs(self.costCells) do
v:setActive(false) v:setActive(false)
end end
@ -210,16 +210,16 @@ function HeroInfoComp:refresh(checkLevel)
self.btnUp:setActive(false) self.btnUp:setActive(false)
self.btnUp5:setActive(false) self.btnUp5:setActive(false)
self.gotoBtn:setActive(true) self.gotoBtn:setActive(true)
self.needStarNode:setActive(true) -- self.needStarNode:setActive(true)
local star = self.heroEntity:getStar() -- local star = self.heroEntity:getStar()
local currStar = star%5 + 1 -- local currStar = star%5 + 1
self.needStarNodeDescTx1:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_19, currStar)) -- self.needStarNodeDescTx1:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_19, currStar))
local meshProComp = self.needStarNodeDescTx1:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO) -- local meshProComp = self.needStarNodeDescTx1:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO)
local contentWidth = meshProComp.preferredWidth -- local contentWidth = meshProComp.preferredWidth
self.needStarNodeDescTx1:setSizeDeltaX(contentWidth) -- self.needStarNodeDescTx1:setSizeDeltaX(contentWidth)
self.needStarNode:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout() -- self.needStarNode:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout()
local starType = math.ceil(currStar / 5) -- local starType = math.ceil(currStar / 5)
self.needStarNodeStarImg:setSprite(GFunc.getStarImg(starType)) -- self.needStarNodeStarImg:setSprite(GFunc.getStarImg(starType))
for i,v in ipairs(self.costCells) do for i,v in ipairs(self.costCells) do
v:setActive(false) v:setActive(false)
@ -228,7 +228,7 @@ function HeroInfoComp:refresh(checkLevel)
self.btnUp:setActive(true) self.btnUp:setActive(true)
self.btnUp5:setActive(true) self.btnUp5:setActive(true)
self.gotoBtn:setActive(false) self.gotoBtn:setActive(false)
self.needStarNode:setActive(false) -- self.needStarNode:setActive(false)
local costs = {} local costs = {}
costs[1] = {id = self.heroEntity:getFragmentId(), num = materials[1], type = 1} costs[1] = {id = self.heroEntity:getFragmentId(), num = materials[1], type = 1}
@ -268,14 +268,14 @@ function HeroInfoComp:refresh(checkLevel)
-- self.needStarNodeStarImg = uiMap["hero_info.up.need_star_node.star_img"] -- self.needStarNodeStarImg = uiMap["hero_info.up.need_star_node.star_img"]
-- self.needStarNodeDescTx2 = uiMap["hero_info.up.need_star_node.desc_tx_2"] -- self.needStarNodeDescTx2 = uiMap["hero_info.up.need_star_node.desc_tx_2"]
for i,v in ipairs(self.lvUpVfxs) do -- for i,v in ipairs(self.lvUpVfxs) do
v:setActive(false) -- v:setActive(false)
end -- end
if isLvChange then if isLvChange then
local match = self.heroEntity:getMatchType() local match = self.heroEntity:getMatchType()
-- self.spineObj:setVisible(true) -- self.spineObj:setVisible(true)
-- self.spineObj:playAnim("idle", false, true) -- self.spineObj:playAnim("idle", false, true)
self.lvUpVfxs[match]:setActive(true) -- self.lvUpVfxs[match]:setActive(true)
self.bg5Vfx01:setActive(true) self.bg5Vfx01:setActive(true)
self.bg6Vfx01:setActive(true) self.bg6Vfx01:setActive(true)
else else