c1_lua/lua/app/ui/tips/legacy_up_tips.lua
2023-04-03 10:59:13 +08:00

129 lines
4.0 KiB
Lua

local BaseTips = require "app/ui/tips/base_tips"
local LegacyTips = class("LegacyTips", BaseTips)
function LegacyTips:ctor(params)
self.params = params
end
function LegacyTips:getPrefabPath()
return "assets/prefabs/ui/tips/legacy_up_tips.prefab"
end
function LegacyTips:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
self.descTx = uiMap["legacy_up_tips.bg.desc_tx"]
self.legacyFrameBg = uiMap["legacy_up_tips.bg.frame_bg"]
self.legacyIcon = uiMap["legacy_up_tips.bg.icon"]
self.nameTx = uiMap["legacy_up_tips.bg.name_tx"]
self.lvTx = uiMap["legacy_up_tips.bg.lv_tx"]
self.btn1 = uiMap["legacy_up_tips.bg.btn_1"]
self.btnTx1 = uiMap["legacy_up_tips.bg.btn_1.tx"]
self.btn2 = uiMap["legacy_up_tips.bg.btn_2"]
self.btnTx2 = uiMap["legacy_up_tips.bg.btn_2.tx"]
self.slider = uiMap["legacy_up_tips.bg.slider_bg.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
self.sliderTx = uiMap["legacy_up_tips.bg.slider_bg.slider_tx"]
self.qltTx = uiMap["legacy_up_tips.bg.qlt_tx"]
self.attrTx = uiMap["legacy_up_tips.bg.attr_tx"]
self.btnTx2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_4))
uiMap["legacy_up_tips.bg.desc_tx_1"]:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
uiMap["legacy_up_tips.bg.close_btn"]:addClickListener(function ()
self:closeUI()
end)
self.btn1:addClickListener(function ()
if self.params.callback1 then
self.params.callback1()
end
self:closeUI()
end)
self.btn2:addClickListener(function ()
if self.params.callback2 then
self.params.callback2()
end
end)
self:_bindData()
end
function LegacyTips:_bindData()
self:bind(DataManager.BagData.LegacyData, "isDirty", function(binder, value)
self:onRefresh()
end)
end
function LegacyTips:onRefresh()
self.root:addClickListener(function ()
self:closeUI()
end)
local qlt = self.params.entity:getQuality()
local lv = self.params.entity:getLv()
self.nameTx:setText(self.params.entity:getName())
self.legacyFrameBg:setSprite(self.params.entity:getFrameRes())
self.legacyIcon:setSprite(self.params.entity:getIconRes())
local skillIds = self.params.entity:getSkills()
local str
for i,v in ipairs(skillIds) do
if not str then
str = GFunc.getSkillEffectStr(v, lv)
else
str = str .. "\n" .. GFunc.getSkillEffectStr(v, lv)
end
end
self.descTx:setText(str)
local attrCfg = ConfigManager:getConfig("attr")
local attrs = self.params.entity:getAllOwnAttr()
local attrStr
local valueStr
for i = 1, #attrCfg do
if attrs[i] then
if not attrStr then
attrStr = GFunc.getAttrName(i)
else
attrStr = attrStr .. "&" .. GFunc.getAttrName(i)
end
if not valueStr then
valueStr = string.format("<color=%s>%s</color>", GConst.COLOR_CODE.GREEN, " +" .. GFunc.getFinalPerStr(i, attrs[i]))
end
end
end
attrStr = attrStr .. valueStr
self.attrTx:setText(attrStr)
local str = string.format("<color=%s>%s</color>", GConst.QUALITY_TYPE[qlt], I18N:getGlobalText("QLT_DESC_" .. qlt))
self.qltTx:setText(str)
self.lvTx:setText(I18N:getGlobalText(I18N.GlobalConst.LV_POINT, lv))
local num = self.params.entity:getCount()
local needNum = self.params.entity:getNeedNum()
self.sliderTx:setText(num .. "/" .. needNum)
self.slider.value = num / needNum
local equiped = DataManager.FightInfoData:isLegacyWeared(self.params.entity:getId())
if equiped then
self.btnTx1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_8))
else
self.btnTx1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3))
end
if self.params.entity:isLock() then
self.btn1:setTouchEnable(false)
self.btn1:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_grey")
else
self.btn1:setTouchEnable(true)
self.btn1:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_1")
end
if self.params.entity:lvUpCostEnough() then
self.btn2:setTouchEnable(true)
self.btn2:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_2")
else
self.btn2:setTouchEnable(false)
self.btn2:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_grey")
end
end
return LegacyTips