63 lines
1.8 KiB
Lua
63 lines
1.8 KiB
Lua
local TalentInfoUI = class("TalentInfoUI", BaseUI)
|
|
|
|
local TALENT_CELL = "app/ui/talent/cell/talent_cell"
|
|
|
|
function TalentInfoUI:ctor(parmas)
|
|
parmas = parmas or {}
|
|
self.id = parmas.id or 1
|
|
end
|
|
|
|
function TalentInfoUI:isFullScreen()
|
|
return false
|
|
end
|
|
|
|
function TalentInfoUI:getPrefabPath()
|
|
return "assets/prefabs/ui/talent/talent_info_ui.prefab"
|
|
end
|
|
|
|
function TalentInfoUI:onLoadRootComplete()
|
|
local uiMap = self.root:genAllChildren()
|
|
|
|
self.talentCell = uiMap["talent_info_ui.node.talent_cell"]:addLuaComponent(TALENT_CELL)
|
|
self.descTx = uiMap["talent_info_ui.desc_tx"]
|
|
self.leftArrowBtn = uiMap["talent_info_ui.left_arrow_btn"]
|
|
self.rightArrowBtn = uiMap["talent_info_ui.right_arrow_btn"]
|
|
local continue = uiMap["talent_info_ui.continue"]
|
|
continue:setText(I18N:getGlobalText(I18N.GlobalConst.CLICK_TO_CONTINUE))
|
|
continue:addClickListener(function()
|
|
self:closeUI()
|
|
end)
|
|
|
|
self.leftArrowBtn:addClickListener(function()
|
|
self.idx = self.idx - 1
|
|
self:onRefresh()
|
|
end)
|
|
self.rightArrowBtn:addClickListener(function()
|
|
self.idx = self.idx + 1
|
|
self:onRefresh()
|
|
end)
|
|
self.list = DataManager.TalentData:getActiveList()
|
|
for i, cfg in ipairs(self.list) do
|
|
if cfg.id == self.id then
|
|
self.idx = i
|
|
break
|
|
end
|
|
end
|
|
end
|
|
|
|
function TalentInfoUI:onRefresh()
|
|
self.id = self.list[self.idx].id
|
|
self.talentCell:refresh(self.id, self.list[self.idx])
|
|
self.leftArrowBtn:setActive(self.idx > 1 and #self.list ~= 1)
|
|
self.rightArrowBtn:setActive(self.idx < #self.list and #self.list ~= 1)
|
|
local attr, num = DataManager.TalentData:getAttrById(self.id)
|
|
local str = I18N:getText("talent", self.id, "desc")
|
|
if attr and #attr > 0 then
|
|
str = str .. GFunc.getPerStr(attr[1].type, attr[1].num / GConst.DEFAULT_FACTOR)
|
|
-- else
|
|
-- str = str .. (num or 0)
|
|
end
|
|
self.descTx:setText(str)
|
|
end
|
|
|
|
return TalentInfoUI |