73 lines
2.3 KiB
Lua
73 lines
2.3 KiB
Lua
local StarInfoComp = class("StarInfoComp", LuaComponent)
|
|
|
|
local STAR_CELL = "app/ui/hero/cell/star_cell"
|
|
|
|
function StarInfoComp:init()
|
|
local uiMap = self:getUIMap()
|
|
|
|
self.upBtn = uiMap["star_info.upgrade.up_btn"]
|
|
self.upBtnTx = uiMap["star_info.upgrade.up_btn.text"]
|
|
self.lvBtn = uiMap["star_info.upgrade.lv_btn"]
|
|
self.lvBtnTx = uiMap["star_info.upgrade.lv_btn.text"]
|
|
self.costCells = {}
|
|
for i = 1, 2 do
|
|
self.costCells[i] = uiMap["star_info.upgrade.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
|
end
|
|
|
|
-- self.upBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
|
|
self.upBtnTx:setText("升星")
|
|
self.lvBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
|
|
self.upBtn:addClickListener(function()
|
|
-- ModuleManager.EquipManager:reqUpgrade(self.heroEntity:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON)
|
|
end)
|
|
|
|
self.lvBtn:addClickListener(function()
|
|
self.parentUI:changePage(GConst.HeroConst.PANEL_TYPE.HERO)
|
|
end)
|
|
|
|
self.scrollRectComp = uiMap["star_info.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
|
self.scrollRectComp:addInitCallback(function()
|
|
return STAR_CELL
|
|
end)
|
|
self.scrollRectComp:addRefreshCallback(function(index, cell)
|
|
cell:refresh(self.heroEntity, index)
|
|
end)
|
|
self.scrollRectComp:clearCells()
|
|
-- self.scrollRectComp:refillCells(count)
|
|
end
|
|
|
|
function StarInfoComp:setParentUI(parentUI)
|
|
self.parentUI = parentUI
|
|
end
|
|
|
|
function StarInfoComp:refresh(heroEntity)
|
|
self.heroEntity = heroEntity or self.heroEntity
|
|
if not self.heroEntity then
|
|
return
|
|
end
|
|
self.scrollRectComp:refillCells(5)
|
|
|
|
if self.heroEntity:getIsStarMax() then
|
|
self.upBtn:setActive(false)
|
|
self.lvBtn:setActive(false)
|
|
for i,v in ipairs(self.costCells) do
|
|
v:setActive(false)
|
|
end
|
|
elseif self.heroEntity:getIsCurLvMax() then
|
|
self.upBtn:setActive(false)
|
|
self.lvBtn:setActive(true)
|
|
else
|
|
self.upBtn:setActive(true)
|
|
self.lvBtn:setActive(false)
|
|
local materials = self.heroEntity:getStarUpMaterials()
|
|
local costs = {}
|
|
costs[1] = {id = self.heroEntity:getFragmentId(), num = materials[1], type = 1}
|
|
costs[2] = {id = self.heroEntity:getStarUpCostId(), num = materials[2], type = 1}
|
|
for i,v in ipairs(self.costCells) do
|
|
v:setActive(true)
|
|
v:refreshByConfig(costs[i])
|
|
end
|
|
end
|
|
end
|
|
|
|
return StarInfoComp |