c1_lua/lua/app/ui/runes/runes_suit_ui.lua
2023-09-19 18:29:59 +08:00

68 lines
2.5 KiB
Lua

local RunesSuitUI = class("RunesSuitUI", BaseUI)
function RunesSuitUI:isFullScreen()
return false
end
function RunesSuitUI:getPrefabPath()
return "assets/prefabs/ui/runes/runes_suit_ui.prefab"
end
function RunesSuitUI:onPressBackspace()
self:closeUI()
end
function RunesSuitUI:ctor(params)
self.heroEntity = params
self.runesEntity = DataManager.RunesData:getRunes(self.heroEntity:getCfgId())
self.curLevel = DataManager.RunesData:getLevel()
end
function RunesSuitUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
self.txTitle = uiMap["runes_suit_ui.bg.title.tx_title"]
self.btnClose = uiMap["runes_suit_ui.bg.close_btn"]
self.suits = {}
for i = 1, 5 do
self.suits[i] = uiMap["runes_suit_ui.bg.list.suit_cell_" .. i]
end
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_9))
self.btnClose:addClickListener(function()
self:closeUI()
end)
end
function RunesSuitUI:onRefresh()
for index, obj in ipairs(self.suits) do
local map = obj:genAllChildren()
local imgIcon = map["img_type"]
local txName = map["tx_suit_name"]
local txAttr = map["tx_suit_attr"]
local txLevel = map["tx_level"]
imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_rune_"..index)
txName:setText(DataManager.RunesData:getSuitName(index))
local attr1 = DataManager.RunesData:getSuitAttr(index, self.heroEntity:getMatchType(), 1)
local attr2 = DataManager.RunesData:getSuitAttr(index, self.heroEntity:getMatchType(), 2)
local level = self.runesEntity:getSuitLevel(index)
txLevel:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_26, level))
local strName = "<size=24>" .. DataManager.RunesData:getSuitName(index) .. "</size>"
local str1 = I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_15, GFunc.getAttrDesc(attr1.type, attr1.num))
local str2 = I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_16, GFunc.getAttrDesc(attr2.type, attr2.num))
if level == 0 then
str1 = "<color=#FFFFFF>" .. str1 .. "</color>"
str2 = "<color=#FFFFFF>" .. str2 .. "</color>"
elseif level == 1 then
str1 = "<color=#F9FF60>" .. str1 .. "</color>"
str2 = "<color=#FFFFFF>" .. str2 .. "</color>"
elseif level == 2 then
str1 = "<color=#FFFFFF>" .. str1 .. "</color>"
str2 = "<color=#F9FF60>" .. str2 .. "</color>"
end
txAttr:setText(str1 .. "\n" .. str2)
end
end
return RunesSuitUI