123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770 |
- ---@class KLEquipStrengthUIPanel:UIKmlLuaPanelBase
- ---@field view KLEquipStrengthUIPanelView
- --- kml代码lua化 会有较多冗余代码
- local KLEquipStrengthUIPanel = class(UIKmlLuaPanelBase)
- local this =KLEquipStrengthUIPanel
- ---创建时调用一次
- function this:Init()
- GUI:UIPanel_Open("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel",nil,nil,
- {x=-465, hideTips=true, callBack=self.CloseEquipUi,forgeGroupType=EForgeGroupType.Strength},nil,function(equipPanel)
- self.equipPanel = equipPanel
- self:Refresh()
- end)
- self.bagIndex = nil
- self.equipIndex = nil
- self.strengthAttTextList = {}
- self.costList = {}
- self.showLiuGuang = false
- GUI:setVisible(self.view.equip_show_tips, false)
- GUI:DataListInitData(self.view.strength_list, function()
- return table.count(self.strengthAttTextList)
- end,function()
- end,function()
- end,function(realIndex)
- local strengthInfo = self.strengthAttTextList[realIndex+1]
- local name = strengthInfo['attrName']
- local preValue = strengthInfo['preValue']
- local nextValue = strengthInfo['nextValue']
- local arrowShow = strengthInfo['arrowShow']
- local attControl = GUI:GetChildControl(self.view.strength_list,realIndex,'attrName')
- local preControl = GUI:GetChildControl(self.view.strength_list,realIndex,'preValue')
- local nextControl = GUI:GetChildControl(self.view.strength_list,realIndex,'nextValue')
- local arrowControl = GUI:GetChildControl(self.view.strength_list,realIndex,'arrow')
- local result = ""
- local len = utf8.len(name) -- 获取字符串的 UTF-8 长度
- local i = 1
- local j = 1
- -- 使用 utf8.offset 来逐个字符提取
- while i <= len do
- local char = utf8.sub(name, i, i+1)
- result = result .. char .. " "
- i = i+1 -- 移动到下一个字符
- end
- GUI:Text_setString(attControl, result)
- GUI:Text_setString(preControl, tostring(preValue))
- GUI:Text_setString(nextControl, tostring(nextValue))
- GUI:setVisible(arrowControl, arrowShow)
- end)
- GUI:DataListInitData(self.view.cost_list, function()
- return table.count(self.costList)
- end,function()
- end,function()
- end,function(realIndex)
- local costInfo = self.costList[realIndex+1]
- local cfgId = costInfo['cfgId']
- local needCount = costInfo['needCount']
- local itemControl = GUI:GetChildControl(self.view.cost_list,realIndex,'cost_item')
- local nameControl = GUI:GetChildControl(self.view.cost_list,realIndex,'cost_name')
- local numControl = GUI:GetChildControl(self.view.cost_list,realIndex,'cost_num')
- local costAddBtn = GUI:GetChildControl(self.view.cost_list,realIndex,'costAddBtn')
- if SL:GetConfig('cfg_item', cfgId) == nil then
- return
- end
- GUI:Item_setItemId(itemControl, cfgId)
-
- local name = SL:GetConfig('cfg_item', cfgId).name
- GUI:Text_setString(nameControl, name)
-
- local haveCount = SL:GetBagItemCount(cfgId)
- if haveCount < needCount then
- GUI:Text_setString(numControl, string.format('<color="#9b1818">%d</color>/%d', haveCount, needCount))
- else
- GUI:Text_setString(numControl, string.format('<color="#1add1f">%d</color>/%d', haveCount, needCount))
- end
- GUI:AddOnClickEvent(costAddBtn, self, self.costAddBtn, {cfgId=cfgId})
-
- end)
-
- self.updateEquipCo = nil
- end
- function this:costAddBtn(control, eventData)
- local cfgId = eventData.cfgId
- SL:CommonItemGetPath(nil, cfgId)
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- if not self.equipPanel then
- return
- end
- self.bagIndex = nil
- self.equipIndex = nil
- self:SelectEquip(self.args and self.args.equipSlot or nil)
- SL:RefreshPanelALLRedPoint("KLUIForgeGroupPanel")
- if self.args and self.args.equipSlot then
- self.args.equipSlot = nil
- end
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.CloseButton, self, self.CloseButton)
- GUI:AddOnClickEvent(self.view.strengthButton, self, self.strengthButton)
- GUI:AddOnClickEvent(self.view.closeMask, self, self.closeMask)
- GUI:AddOnClickEvent(self.view.liuGuangBtn, self, self.liuGuangBtn)
- GUI:AddOnClickEvent(self.view.strengthMasterBtn, self, self.strengthMasterBtn)
- GUI:AddOnClickEvent(self.view.item_model, self, self.item_modelOnClick)
- SL:RegisterLUAEvent(LUA_EVENT_EQUIP_GRID_CLICK, self.LUA_EVENT_EQUIP_GRID_CLICK, self)
- --SL:RegisterLUAEvent(LUA_EVENT_BAG_CHANGE_AFTER, self.LUA_EVENT_BAG_CHANGE_AFTER, self)
- --SL:RegisterLUAEvent(LUA_EVENT_MONEYCHANGE, self.LUA_EVENT_MONEYCHANGE, self)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.STRENGTH_EQUIP_RESULT, self.STRENGTH_EQUIP_RESULT, self)
-
- GUI:SetToggleOnValueChange(self.view.equipBtn, self, self.equipBtn)
- GUI:SetToggleOnValueChange(self.view.bagBtn, self, self.ClickBag)
- SL:RegisterLUAEvent(LUA_EVENT_FORGE_GROUP_PANEL_CLOSE, self.CloseButton, self)
- end
-
- function this:item_modelOnClick()
- SL:OpenTips("equip",self.equipInfo.cfgId,self.equipInfo.id,nil, self.equipInfo, {hideBtn=true})
- end
- function this:liuGuangBtn()
- if self.showLiuGuang == false then
- local stream = SL:GetConfig('cfg_equip_strengthen', self.equipInfo.cfgId).stream
- if stream then
- local strengthLevel = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
- for _, streamInfo in pairs(stream) do
- local nowStrengthLevel = streamInfo[1]
- local streamId = streamInfo[2]
- if strengthLevel < nowStrengthLevel then
- GUI:SetStreamAttr(self.view.item_model, streamId)
- GUI:setVisible(self.view.liuguangInfo, true)
- GUI:Text_setString(self.view.liuguangInfo, '+' .. nowStrengthLevel .. '流光效果')
- self.showLiuGuang = true
- return
- end
- end
-
- end
- else
- self:SetLiuGuang(self.equipInfo)
- GUI:setVisible(self.view.liuguangInfo, false)
- self.showLiuGuang = false
- end
- end
- function this:strengthMasterBtn()
- GUI:UIPanel_Open("dev/outui/Equip/Panel/KLUIForgingMaster/KLUIForgingMasterPanel", nil, nil, { uiType = 1, cfgId = self.equipInfo.cfgId })
- end
- function this:equipBtn()
- self.isOpenBag = false
- self.equipPanel = GUI:UIPanel_Open("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel",nil,nil,
- {x=-465, hideTips=true, callBack=self.CloseEquipUi,forgeGroupType=EForgeGroupType.Strength})
- GUI:UIPanel_Close("dev/outui/Bag/Panel/KLStrengthBag/KLStrengthBagPanel")
- self.selectItem = nil
- self:SelectEquip()
- end
- function this.CloseEquipUi()
- GUI:UIPanel_Close("dev/ui/UIForgeGroup/Panel/KLUIForgeGroup/KLUIForgeGroupPanel")
- GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
- GUI:UIPanel_Close("dev/outui/Equip/Panel/KLEquipStrengthUI/KLEquipStrengthUIPanel")
- end
- function this:closeMask()
- GUI:setVisible(self.view.equip_show_tips, false)
- end
- -- 强化结果回调
- ---@param message {issuccess:boolean, strengthlv:number, itemId:number}
- function this:STRENGTH_EQUIP_RESULT(id, message)
- GUI:SetActive(self.view.strength_ok, false)
- GUI:SetActive(self.view.strength_fail, false)
- if message.issuccess then
- GUI:SetActive(self.view.strength_ok, true)
- local costId = SL:GetConfig('cfg_equip_strengthen', self.equipInfo.cfgId).costId
- local firstRate = SL:GetConfigTwoKeys('cfg_equip_strengthenCost', costId, message.strengthlv, 'costGroupId', 'level').firstRate
- if firstRate == 1 then
- self:ShowEquipSuccessMask(self.equipInfo.cfgId, message.strengthlv)
- end
- else
- GUI:SetActive(self.view.strength_fail, true)
- end
- SL:onLUAEvent(LUA_EVENT_STRENGTH_OK,message)
-
- self:ClickEquip(self.equipInfo)
- SL:RefreshPanelALLRedPoint("KLUIForgeGroupPanel")
- self.equipPanel:UpdateAllItem()
- end
- -- 强化跑马灯展示(特定等级展示)
- function this:ShowEquipSuccessMask(cfgId, strengthLevel)
- GUI:setVisible(self.view.equip_show_tips, true)
- local name = SL:GetConfig("cfg_item", cfgId).name
- GUI:Text_setString(self.view.mask_text, string.format("%s+%d", name, strengthLevel))
- GUI:Item_setItemId(self.view.mask_item, cfgId)
- local liuGuangId = EquipFunc.GetEquipLiuGuangId(self.equipInfo)
- GUI:SetStreamAttr(self.view.mask_item, liuGuangId)
-
- end
- -- 点击强化按钮
- function this:strengthButton()
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_STRENGTH_EQUIP,{itemId=self.equipInfo.id})
- -- self:STRENGTH_EQUIP_RESULT(_, {isSuccess = true})
- end
- -- 背包改变后
- function this:LUA_EVENT_BAG_CHANGE_AFTER(_,message)
- if self.isOpenBag then
- return
- end
- if not message then
- return
- end
- if self.equipInfo then
- local lv = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
- local isMax = this.IsMaxEquip(self.equipInfo,lv)
- if not isMax then
- self:SetEquipCostInfo(self.equipInfo.cfgId, lv)
- end
- end
- -- 临时处理下, 等后端整合成一个消息包
- if self.updateEquipCo == nil then
- self.updateEquipCo = Coroutine.Start(function()
- Coroutine.Wait(0.2)
- self.equipPanel:UpdateAllItem()
- SL:RefreshPanelALLRedPoint("KLUIForgeGroupPanel")
- self.updateEquipCo = nil
- end)
- end
- end
- -- 货币变更
- function this:LUA_EVENT_MONEYCHANGE(_,message)
- if self.isOpenBag then
- return
- end
- if self.equipInfo then
- local lv = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
- local isMax = this.IsMaxEquip(self.equipInfo,lv)
- if not isMax then
- self:SetEquipCostInfo(self.equipInfo.cfgId, lv)
- end
- end
-
-
- if self.updateEquipCo == nil then
- self.updateEquipCo = Coroutine.Start(function()
- Coroutine.Wait(0.2)
- self.equipPanel:UpdateAllItem()
- SL:RefreshPanelALLRedPoint("KLUIForgeGroupPanel")
- self.updateEquipCo = nil
- end)
- end
- end
- -- 点击装备事件回调
- function this:LUA_EVENT_EQUIP_GRID_CLICK(_, index)
- local equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, index)
- if index == E_AppearEquipType.Weapon and equip == nil then
- equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, E_AppearEquipType.TwoHandWeapon)
- end
- if equip then
- local strength_tbl = SL:GetConfig('cfg_equip_strengthen', equip['cfgId'])
- if strength_tbl then
- self.bagIndex = nil
- self.equipPanel:SetSelectIndex(index)
- self:ClickEquip(equip)
- return
- else
- SL:TipMessage( SL:GetConfig('cfg_string',268).text, 1, NoticeType.NoticeMid )--"该装备无法被强化",
- end
- end
- end
- -- 关闭按钮回调
- function this:CloseButton()
- GUI:UIPanel_Close("dev/ui/UIForgeGroup/Panel/KLUIForgeGroup/KLUIForgeGroupPanel")
- GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
- GUI:UIPanel_Close("dev/outui/Equip/Panel/KLEquipStrengthUI/KLEquipStrengthUIPanel")
- GUI:UIPanel_Close("dev/outui/Bag/Panel/KLStrengthBag/KLStrengthBagPanel")
- self.selectItem = nil
- self.equipPanel = nil
- end
- function this:Close()
- end
- -- 选择装备
- function this:SelectEquip(_index)
- if self.selectItem then
- local strength_tbl = SL:GetConfig('cfg_equip_strengthen', self.selectItem.item.cfgId)
- if strength_tbl then
- self.bagIndex = nil
- ---@type cfg_item_column
- local part = SL:GetConfig("cfg_item",self.selectItem.item.cfgId).subType
- self.equipPanel:SetSelectIndex(part)
- self:ClickEquip(self.selectItem.item)
- return
- end
- end
- if _index then
- local equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, _index)
- if equip then
- local strength_tbl = SL:GetConfig('cfg_equip_strengthen', equip['cfgId'])
- if strength_tbl then
- self.bagIndex = nil
- self.equipPanel:SetSelectIndex(_index)
- self:ClickEquip(equip)
- return
- end
- end
- end
-
- -- 策划要求先选中武器
- local equip_boot = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, EEquipSlotType.TwoHandWeapon)
- if equip_boot then
- local strength_tbl = SL:GetConfig('cfg_equip_strengthen', equip_boot['cfgId'])
- if strength_tbl then
- self.bagIndex = nil
- self.equipPanel:SetSelectIndex(EEquipSlotType.TwoHandWeapon)
- self:ClickEquip(equip_boot)
- return
- end
- end
-
- for index=1, 15 do
- local equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, index)
- if equip then
- local strength_tbl = SL:GetConfig('cfg_equip_strengthen', equip['cfgId'])
- if strength_tbl then
- self.bagIndex = nil
- self.equipPanel:SetSelectIndex(index)
- self:ClickEquip(equip)
- return
- end
- end
- end
- GUI:setVisible(self.view.noticeText, true)
- end
- -- 初始化UI为初始状态
- function this:ResetUi()
- GUI:setVisible(self.view.maxLevelTips, false)
- GUI:setVisible(self.view.strengthIcon, false)
- GUI:setVisible(self.view.baseSuccessRatioText, false)
- GUI:setVisible(self.view.successIcon, false)
- GUI:setVisible(self.view.strengthIcon_1, false)
- GUI:setVisible(self.view.StrengthCustomScrollView, false)
- GUI:setVisible(self.view.strengthButton, false)
- GUI:setVisible(self.view.strengthLevelBg, false)
- GUI:setVisible(self.view.maxStrengthLevelBg, false)
- GUI:setVisible(self.view.item_model, false)
- GUI:setVisible(self.view.equipName, false)
- GUI:setVisible(self.view.noticeText, false)
- GUI:setVisible(self.view.liuGuangBtn, false)
- GUI:setVisible(self.view.liuguangInfo, false)
- GUI:setVisible(self.view.strengthMasterBtn, false)
- self.showLiuGuang = false
- end
- -- 点击装备(装备栏内)
- -- local testLevel = 0
- function this:ClickEquip(equipInfo)
- local strength_tbl = SL:GetConfig('cfg_equip_strengthen', equipInfo.cfgId)
- if strength_tbl then
- self.equipInfo = equipInfo
- self:ResetUi()
- GUI:setVisible(self.view.liuGuangBtn, true)
- local strengthLevel = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
- self:SetEquipName(self.equipInfo.cfgId, strengthLevel)
- self:SetEquipModel(self.equipInfo.cfgId)
- self:SetLiuGuang(self.equipInfo)
- self:SetLiuGuangBtn(self.equipInfo)
- local isMax = this.IsMaxEquip(self.equipInfo,strengthLevel)
- if isMax then
- GUI:setVisible(self.view.maxLevelTips, true)
- GUI:Text_setString(self.view.maxLevel, "+" .. strengthLevel)
- GUI:setVisible(self.view.maxStrengthLevelBg, true)
- self:SetMaxAttrInfo(self.equipInfo.cfgId, strengthLevel)
- else
- self:RefreshSuccessRatio(self.equipInfo.cfgId, strengthLevel)
- self:SetEquipLevelInfo(strengthLevel)
- self:SetEquipAttrInfo(self.equipInfo.cfgId, strengthLevel)
- self:SetEquipCostInfo(self.equipInfo.cfgId, strengthLevel)
- GUI:setVisible(self.view.strengthButton, true)
- self:SetEquipFailText(self.equipInfo.cfgId, strengthLevel)
- end
-
- -- testLevel = testLevel + 1
- end
- ---@type cfg_item_column
- local item = SL:GetConfig("cfg_item", equipInfo.cfgId)
- local masterId = tonumber(item.strPart[1] .. "01")
- ---@type cfg_equip_masterGroup_column
- local master = SL:GetConfig("cfg_equip_masterGroup", masterId)
- if master then
- GUI:setVisible(self.view.strengthMasterBtn, true)
- else
- GUI:setVisible(self.view.strengthMasterBtn, false)
- end
- end
- function this:SetLiuGuangBtn(equipInfo)
- local stream = SL:GetConfig('cfg_equip_strengthen', equipInfo.cfgId).stream
- if stream then
- local strengthLevel = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
- for _, streamInfo in pairs(stream) do
- local nowStrengthLevel = streamInfo[1]
- if strengthLevel < nowStrengthLevel then
- GUI:setVisible(self.view.liuGuangBtn, true)
- return
- end
- end
- end
- GUI:setVisible(self.view.liuGuangBtn, false)
- end
- -- 设置流光
- function this:SetLiuGuang(equipInfo)
- local liuGuangId = EquipFunc.GetEquipLiuGuangId(equipInfo)
- if liuGuangId then
- GUI:SetStreamAttr(self.view.item_model, liuGuangId)
- else
- GUI:ResetStreamAttr(self.view.item_model)
- end
- end
- -- 点击背包
- function this:ClickBag()
- self.isOpenBag = true
- self:ResetUi()
- GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
- GUI:UIPanel_Open("dev/outui/Bag/Panel/KLStrengthBag/KLStrengthBagPanel", nil, nil, {x=-481, itemClickCallBack=self.itemClickCallBack,callBackUI=self})
- end
- -- 点击道具回调(背包)
- function this:itemClickCallBack(control, item)
- if SL:HasConfig('cfg_equip_strengthen', item.cfgId) then
- local itemInfo = SL:GetItemInfoByItemId(item.id)
- self:ClickEquip(itemInfo)
- self:HideSelectItem(false)
- control.ui:SetSelect(true)
- self.selectItem = control.ui
- else
- SL:TipMessage( SL:GetConfig('cfg_string',268).text, 1, NoticeType.NoticeMid )--"该装备无法被强化",
- end
- end
- function this:HideSelectItem()
- if self.selectItem then
- self.selectItem:SetSelect(false)
- end
- end
- -- 满级属性
- function this:SetMaxAttrInfo(cfgId, strengthLevel)
- self.strengthAttTextList = {}
- GUI:setVisible(self.view.strengthIcon, true)
- local groupId = SL:GetConfig('cfg_equip_strengthen', cfgId).groupId
- local nowAttrInfo = SL:GetConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel, 'group', 'lv').att
- local now_attr_map = {}
- for _, nowAttr in pairs(nowAttrInfo) do
- now_attr_map[nowAttr[1]] = nowAttr[2]
- end
-
- local minAtk = now_attr_map[201021]
- local maxAtk = now_attr_map[201011]
- if minAtk and maxAtk then
-
- local tbl= {
- attrName = "攻击力",
- preValue = minAtk .. '~' .. maxAtk,
- nextValue = "",
- arrowShow = false
- }
- table.insert(self.strengthAttTextList, tbl)
- end
- local minMAtk = now_attr_map[202021]
- local maxMAtk = now_attr_map[202011]
- if minMAtk and maxMAtk then
- local tbl= {
- --attrName = "魔法攻击力",
- attrName = "攻击力",
- preValue = minMAtk .. '~' .. maxMAtk,
- nextValue = "",
- arrowShow = false
- }
- table.insert(self.strengthAttTextList, tbl)
- end
-
- minAtk = now_attr_map[200011]
- maxAtk = now_attr_map[200021]
- if minAtk and maxAtk then
- local tbl= {
- attrName = "攻击力",
- preValue = minAtk .. '~' .. maxAtk,
- nextValue = "",
- arrowShow = false
- }
- table.insert(self.strengthAttTextList, tbl)
- end
- for attrId, attrValue in pairs(now_attr_map) do
- if attrId ~= 201021 and attrId ~= 201011 and attrId ~= 202021 and attrId ~= 202011 and attrId ~= 200011 and attrId ~= 200021 then
- local name = SL:GetConfig("cfg_att_info", attrId).name
- local att_remark = SL:GetConfig("cfg_att_info", attrId).remarks
- local tbl = {}
- if att_remark == 1 then
- tbl = {
- attrName = name,
- preValue = attrValue,
- nextValue = "",
- arrowShow = false
- }
- else
- tbl = {
- attrName = name,
- preValue = attrValue/100 .. '%',
- nextValue = "",
- arrowShow = false
- }
- end
- table.insert(self.strengthAttTextList, tbl)
- end
- end
- GUI:DataListUpdateData(self.view.strength_list)
- end
- --失败文本
- function this:SetEquipFailText(cfgId, strengthLevel)
- local costId = SL:GetConfig('cfg_equip_strengthen', cfgId).costId
- local fail_tips = SL:GetConfigTwoKeys('cfg_equip_strengthenCost', costId, strengthLevel+1, 'costGroupId', 'level').tips
- if fail_tips then
- GUI:setVisible(self.view.failTips, true)
- GUI:Text_setString(self.view.failTips, fail_tips)
- end
- end
- -- 消耗道具
- function this:SetEquipCostInfo(cfgId, strengthLevel)
- self.costList = {}
- GUI:setVisible(self.view.strengthIcon_1, true)
- GUI:setVisible(self.view.StrengthCustomScrollView, true)
- local costId = SL:GetConfig('cfg_equip_strengthen', cfgId).costId
- local next_level = strengthLevel + 1
- local cost_info = SL:GetConfigTwoKeys('cfg_equip_strengthenCost', costId, next_level, "costGroupId", "level").cost
- for _, cost in pairs(cost_info) do
- local tbl = {
- cfgId = cost[1],
- needCount = cost[2],
- }
- table.insert(self.costList, tbl)
- end
-
- GUI:DataListUpdateData(self.view.cost_list)
- end
- -- 装备属性
- function this:SetEquipAttrInfo(cfgId, strengthLevel)
- self.strengthAttTextList = {}
- GUI:setVisible(self.view.strengthIcon, true)
- local groupId = SL:GetConfig('cfg_equip_strengthen', cfgId).groupId
- local nowAttrInfo
- if SL:HasConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel, 'group', 'lv') then
- nowAttrInfo = SL:GetConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel, 'group', 'lv')
- end
- nowAttrInfo = nowAttrInfo and nowAttrInfo.att or {}
-
- local nextAttrInfo
- if SL:HasConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel+1, 'group', 'lv') then
- nextAttrInfo = SL:GetConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel+1, 'group', 'lv')
- end
- nextAttrInfo = nextAttrInfo and nextAttrInfo.att or {}
- local now_attr_map = {}
- for _, nowAttr in pairs(nowAttrInfo) do
- now_attr_map[nowAttr[1]] = nowAttr[2]
- end
- local next_attr_map = {}
- for _, nextAttr in pairs(nextAttrInfo) do
- next_attr_map[nextAttr[1]] = tonumber(nextAttr[2])
- end
- for nextId, _ in pairs(next_attr_map) do
- if now_attr_map[nextId] == nil then
- now_attr_map[nextId] = 0
- end
- end
- local minAtk = now_attr_map[201021]
- local maxAtk = now_attr_map[201011]
- if minAtk and maxAtk then
- local nextMinAtk = next_attr_map[201021]
- local nextMaxAtk = next_attr_map[201011]
- local tbl= {
- attrName = "攻击力",
- preValue = minAtk .. '~' .. maxAtk,
- nextValue = nextMinAtk .. '~' .. nextMaxAtk,
- arrowShow = true
- }
- table.insert(self.strengthAttTextList, tbl)
- end
- local minMAtk = now_attr_map[202021]
- local maxMAtk = now_attr_map[202011]
- if minMAtk and maxMAtk then
- local nextMinAtk = next_attr_map[202021]
- local nextMaxAtk = next_attr_map[202011]
- local tbl= {
- --attrName = "魔法攻击力",
- attrName = "攻击力",
- preValue = minMAtk .. '~' .. maxMAtk,
- nextValue = nextMinAtk .. '~' .. nextMaxAtk,
- arrowShow = true
- }
- table.insert(self.strengthAttTextList, tbl)
- end
- minAtk = now_attr_map[200011]
- maxAtk = now_attr_map[200021]
- if minAtk and maxAtk then
- local nextMinAtk = next_attr_map[200011]
- local nextMaxAtk = next_attr_map[200021]
- local tbl= {
- attrName = "攻击力",
- preValue = minAtk .. '~' .. maxAtk,
- nextValue = nextMinAtk .. '~' .. nextMaxAtk,
- arrowShow = true
- }
- table.insert(self.strengthAttTextList, tbl)
- end
-
- for attrId, attrValue in pairs(now_attr_map) do
- if attrId ~= 201021 and attrId ~= 201011 and attrId ~= 202021 and attrId ~= 202011 and attrId ~= 200011 and attrId ~= 200021 then
- local nextValue = next_attr_map[attrId] or 0
- local name = SL:GetConfig("cfg_att_info", attrId).name
- local att_remark = SL:GetConfig("cfg_att_info", attrId).remarks
- local tbl = {}
- if att_remark == 1 then
- tbl = {
- attrName = name,
- preValue = attrValue,
- nextValue = nextValue,
- arrowShow = true
- }
- else
- tbl = {
- attrName = name,
- preValue = attrValue/100 .. '%',
- nextValue = nextValue/100 .. '%',
- arrowShow = true
- }
- end
- table.insert(self.strengthAttTextList, tbl)
- end
- end
-
- local tips = SL:GetConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel+1, 'group', 'lv').tips
- if not string.isNullOrEmpty(tips) then
- local tbl = {
- attrName = tips,
- preValue = '',
- nextValue = '',
- arrowShow = false
- }
- table.insert(self.strengthAttTextList, tbl)
- end
- GUI:DataListUpdateData(self.view.strength_list)
-
- end
- -- 装备等级
- function this:SetEquipLevelInfo(strengthLevel)
- GUI:setVisible(self.view.strengthLevelBg, true)
- GUI:Text_setString(self.view.preLevel, "+" .. strengthLevel)
- GUI:Text_setString(self.view.nextLevel, "+" .. strengthLevel+1)
- end
- -- 成功率
- function this:RefreshSuccessRatio(cfgId, strengthLevel)
- GUI:setVisible(self.view.baseSuccessRatioText, true)
- GUI:setVisible(self.view.successIcon, true)
- local costId = SL:GetConfig('cfg_equip_strengthen', cfgId).costId
- local next_level = strengthLevel + 1
- local rate_client = SL:GetConfigTwoKeys('cfg_equip_strengthenCost', costId, next_level, "costGroupId", "level").rateClient
- rate_client = rate_client // 100
- GUI:Text_setString(self.view.baseSuccessRatioText, rate_client .. '%')
- end
- -- 装备名字
- function this:SetEquipName(cfgId, strengthLevel)
- GUI:setVisible(self.view.equipName, true)
- local equipName = SL:GetConfig('cfg_item', cfgId).name
- local colorStr = EquipFunc.GetEquipNameColor(cfgId)
- if strengthLevel > 0 then
- equipName = equipName .. '+' .. strengthLevel
- end
- GUI:Text_setString(self.view.equipName, string.format("<color=%s>%s</color>", colorStr, equipName))
- end
- -- 装备模型
- function this:SetEquipModel(cfgId)
- GUI:setVisible(self.view.item_model, true)
- GUI:Item_setItemId(self.view.item_model, cfgId)
- end
- --是否是满级装备
- function this.IsMaxEquip(equipInfo, strength_level)
- local cfgId = equipInfo.cfgId
- --local strength_level = equipInfo["strengthlevel"]
- ---首饰换表处理
- local ornament_tbl = SL:HasConfig('cfg_equip_ornamentsMain', cfgId)
- if ornament_tbl then
- if InfoManager.equipJewelryInfo:GetCurLevelMaxStrength(equipInfo) <= strength_level then
- return true
- end
- return false
- end
- local strength_tbl = SL:GetConfig('cfg_equip_strengthen', cfgId)
- if strength_tbl then
- if strength_tbl.maxLevel <= strength_level then
- return true
- end
-
- return false
-
- end
- return false
- end
- return this
|