57 lines
1.7 KiB
Lua
57 lines
1.7 KiB
Lua
local HeroAttrUI = class("HeroAttrUI", BaseUI)
|
|
local ATTR_NODE_CELL = "app/ui/hero/cell/attr_node_cell"
|
|
local ATTR_NODE_CELL_PATH = "assets/prefabs/ui/hero/cell/attr_node_cell.prefab"
|
|
|
|
local ATTR_CELLS_PADDING = 60
|
|
local ATTR_CELL_HEIGHT = 80
|
|
local ATTR_CELL_SPACING_Y = 8
|
|
|
|
function HeroAttrUI:isFullScreen()
|
|
return false
|
|
end
|
|
|
|
function HeroAttrUI:getPrefabPath()
|
|
return "assets/prefabs/ui/hero/hero_attr_ui.prefab"
|
|
end
|
|
|
|
function HeroAttrUI:onPressBackspace()
|
|
self:closeUI()
|
|
end
|
|
|
|
function HeroAttrUI:onClose()
|
|
self.rootNodes:removeAllChildren()
|
|
end
|
|
|
|
function HeroAttrUI:ctor(parmas)
|
|
self.heroId = parmas
|
|
end
|
|
|
|
function HeroAttrUI:onLoadRootComplete()
|
|
local uiMap = self.root:genAllChildren()
|
|
|
|
self.txTitle = uiMap["hero_attr_ui.content.tx_title"]
|
|
self.btnClose = uiMap["hero_attr_ui.content.btn_close"]
|
|
self.rootNodes = uiMap["hero_attr_ui.content.ScrollView.Viewport.Content"]
|
|
|
|
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_18))
|
|
|
|
self.btnClose:addClickListener(function()
|
|
self:closeUI()
|
|
end)
|
|
end
|
|
|
|
function HeroAttrUI:onRefresh()
|
|
local totalHeight = 0
|
|
for index, node in ipairs(GConst.HeroConst.SHOW_NODE) do
|
|
CellManager:loadCellAsync(ATTR_NODE_CELL_PATH, ATTR_NODE_CELL, self.rootNodes, function(cell)
|
|
local nodeHeight = math.ceil(#node / 2) * ATTR_CELL_HEIGHT + (math.ceil(#node / 2) - 1) * ATTR_CELL_SPACING_Y + ATTR_CELLS_PADDING
|
|
cell.baseObject:setLocalPositionY(-totalHeight)
|
|
cell.baseObject:setSizeDeltaY(nodeHeight)
|
|
cell:refresh(self.heroId, node)
|
|
totalHeight = totalHeight + nodeHeight
|
|
self.rootNodes:setSizeDeltaY(totalHeight)
|
|
end)
|
|
end
|
|
end
|
|
|
|
return HeroAttrUI |