123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- ---@class KLUIForgingMasterPanel:UIKmlLuaPanelBase
- ---@field view KLUIForgingMasterPanelView
- local KLUIForgingMasterPanel = class(UIKmlLuaPanelBase)
- local this =KLUIForgingMasterPanel
- ---创建时调用一次
- function this:Init()
- ---1 锻造, 2 追加
- self.uiType = self.args.uiType
- self.cfgId = self.args.cfgId
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- ---@type cfg_item_column
- local item = SL:GetConfig("cfg_item", self.cfgId)
- local tbl_id = tonumber(item.strPart[1] .. "0" .. self.uiType)
- ---@type cfg_equip_masterGroup_column
- local group = SL:GetConfig("cfg_equip_masterGroup", tbl_id)
- ---@type cfg_equip_master_column[]
- local master = SL:GetConfigTable("cfg_equip_master")
- ---@type cfg_equip_master_column[]
- local masterTbl = {}
- local masterValue, masterStrPartId, masterCount
- for i, v in pairs(master) do
- if v.group == group.group and v.type == self.uiType then
- masterTbl[#masterTbl + 1] = v
- masterCount = v.count
- masterValue = v.value
- if v.strPartId and not masterStrPartId then
- masterStrPartId = {}
- for k, part in ipairs(v.strPartId) do
- masterStrPartId[k] = part
- end
- end
- end
- end
- table.sort(masterTbl, function(a,b)
- return a.id < b.id
- end)
- local forgingLevel = self:GetShowMasterLevel(masterCount, masterStrPartId)
- local curLvId = 0
- for i, v in ipairs(masterTbl) do
- if v.lv > forgingLevel then
- self:RefreshUI(curLvId, v.id, group.strpartShow)
- return
- end
- curLvId = v.id
- end
- if curLvId > 0 then
- self:RefreshUI(curLvId, nil, group.strpartShow)
- end
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- --GUI:UIPanel_Open("dev/ui/Equip/Panel/KLUIForgingMaster/KLUIForgingMasterPanel")
- --GUI:UIPanel_Close("dev/ui/Equip/Panel/KLUIForgingMaster/KLUIForgingMasterPanel")
- GUI:AddOnClickEvent(self.view.btn_close, self, self.CloseSelf)
- end
- function this:GetShowMasterLevel(type, partStr)
- ---@type CommonProtos.Item[]
- local equipData = SL:GetMetaValue(EMetaVarGetKey.EQUIP_DATA)
- if type == 1 then
- local minForgingLevel = 100
- for i, v in pairs(equipData[1]) do
- ---@type cfg_item_column
- local item = SL:GetConfig("cfg_item", v.cfgId)
- for j, k in pairs(partStr) do
- if item.strPart[1] == k or item.strPart[2] == k then
- local forgingLevel
- if self.uiType == 1 then
- forgingLevel = EquipFunc.GetEquipStrengthLevel(v)
- else
- forgingLevel = EquipFunc.GetEquipAppendLevel(v)
- end
- if forgingLevel < minForgingLevel then
- minForgingLevel = forgingLevel
- end
- table.remove(partStr, j)
- break
- end
- end
- end
- if #partStr == 0 then
- return minForgingLevel
- else
- return 0
- end
- else
- local totalLevel = 0
- for i, v in pairs(equipData[1]) do
- ---@type cfg_item_column
- local item = SL:GetConfig("cfg_item", v.cfgId)
- for j, k in pairs(partStr) do
- if k == item.strPart[1] or k == item.strPart[2] then
- local forgingLevel = 0
- if self.uiType == 1 then
- forgingLevel = EquipFunc.GetEquipStrengthLevel(v)
- else
- forgingLevel = EquipFunc.GetEquipAppendLevel(v)
- end
- totalLevel = totalLevel + forgingLevel
- break
- end
- end
- end
- return totalLevel
- end
- end
- function this:RefreshUI(curLevel, nextLevel, strpartShow)
- local partList
- if nextLevel then
- if curLevel == 0 then
- ---未激活
- ---@type cfg_equip_master_column
- local curTbl = SL:GetConfig("cfg_equip_master", nextLevel)
- GUI:Text_setString(self.view.now_attr, "<color=#999999>" .. curTbl.note .. "+" .. curTbl.lv .. "</color>")
- GUI:Text_setString(self.view.now_bonus, self:GetAttrInfo(curTbl.att2))
- partList = curTbl.strPartId
- else
- ---激活
- local curTbl = SL:GetConfig("cfg_equip_master", curLevel)
- GUI:Text_setString(self.view.now_attr, curTbl.note .. "<color=#1ADD1F>+" .. curTbl.lv .. "</color>")
- GUI:Text_setString(self.view.now_bonus, self:GetAttrInfo(curTbl.att2, 1))
- partList = curTbl.strPartId
- end
- if curLevel == 0 then
- nextLevel = nextLevel + 1
- end
- GUI:SetActive(self.view.next_level, true)
- ---@type cfg_equip_master_column
- local nextTbl = SL:GetConfig("cfg_equip_master", nextLevel)
- GUI:Text_setString(self.view.next_attr, "<color=#999999>" .. nextTbl.note .. "+" .. nextTbl.lv .. "</color>")
- GUI:Text_setString(self.view.next_bonus, self:GetAttrInfo(nextTbl.att2))
- else
- ---满级
- ---@type cfg_equip_master_column
- local curTbl = SL:GetConfig("cfg_equip_master", curLevel)
- GUI:Text_setString(self.view.now_attr, curTbl.note .. "<color=#1ADD1F>+" .. curTbl.lv .. "</color>")
- GUI:Text_setString(self.view.now_bonus, self:GetAttrInfo(curTbl.att2, 1))
- GUI:SetActive(self.view.next_level, false)
- partList = curTbl.strPartId
- end
- if self.uiType == 1 then
- GUI:Text_setString(self.view.text_title, "强化大师")
- GUI:Text_setString(self.view.text_tips, "满足强化条件可点亮属性")
- else
- GUI:Text_setString(self.view.text_title, "追加大师")
- GUI:Text_setString(self.view.text_tips, "满足追加条件可点亮属性")
- end
- GUI:Text_setString(self.view.text_part_name, strpartShow)
- end
- function this:GetAttrInfo(attr, act)
- local value, str
- -----@type cfg_att_info_column
- --local attrTbl = SL:GetConfig("cfg_att_info", attr[1])
- --if attrTbl.remarks == 2 then
- -- value = attr[2] / 100
- -- str = value .. "%"
- --else
- -- str = attr[2]
- --end
- --if act then
- -- return attrTbl.name .. "<color=#1ADD1F>+" .. str .. "</color>"
- --else
- -- return "<color=#999999>" .. attrTbl.name .. "+" .. str .. "</color>"
- --end
- if attr[1] == 1 then
- value = "强化属性"
- elseif attr[1] == 2 then
- value = "追加属性"
- end
- str = attr[2] / 100
- if act then
- return value .. "<color=#1ADD1F>+" .. str .. "%</color>"
- else
- return "<color=#999999>" .. value .. "+" .. str .. "%</color>"
- end
- end
- function this:CloseSelf()
- GUI:UIPanel_Close("dev/outui/Equip/Panel/KLUIForgingMaster/KLUIForgingMasterPanel")
- end
- function this:Close()
- end
- return this
|