---@class KLShapeShiftCardBreakPanel:UIKmlLuaPanelBase ---@field view KLShapeShiftCardBreakPanelView local KLShapeShiftCardBreakPanel = class(UIKmlLuaPanelBase) local this = KLShapeShiftCardBreakPanel function this:AsyncLoadUI() end ---创建时调用一次 function this:Init() self.breakCount = 1 self.cardItemList = {} GUI:DataListInitData(self.view.datalist_card, function() return self:ItemCountFunc() end, function(realIndex) return self:ItemGetFunc(realIndex) end, nil, function(realIndex, kmlCtrl) return self:ItemUpdateFunc(realIndex, kmlCtrl) end ) self.cardExchangeItemList = {} GUI:DataListInitData(self.view.datalist_card_exchange, function() return self:ExchangeItemCountFunc() end, function(realIndex) return self:ExchangeItemGetFunc(realIndex) end, nil, function(realIndex, kmlCtrl) return self:ExchangeItemUpdateFunc(realIndex, kmlCtrl) end ) self.cardBreakList = {} self.selectCardBreak = {} GUI:DataListInitData(self.view.break_card_list, function() return self.breakCount end, function(realIndex) return self:DataListItemGetFunc(realIndex) end, nil, function(realIndex, kmlCtrl) return self:DataListItemUpdateFunc(realIndex, kmlCtrl) end) self.attrList = {} GUI:DataListInitData(self.view.attr_datalist, function() return #self.attrList end, nil, nil, function(realIndex) local attr = GUI:GetChildControl(self.view.attr_datalist, realIndex, 'attr') local attrInfo = self.attrList[realIndex + 1] local preValue local tbl = SL:GetConfig("cfg_att_info", tonumber(attrInfo.attrId)) local attrName = tbl.name local att_remark = tbl.remarks if att_remark == 1 then preValue = attrInfo.attrValue else preValue = tonumber(attrInfo.attrValue) / 100 .. '%' end GUI:Text_setString(attr, attrName .. ":" .. preValue) local cfg = SL:GetConfig("cfg_card_att", tonumber(attrInfo.attrCfgId)) GUI:Text_setTextColor(attr, tostring(cfg.color)) end ) self.scrollViewType = E_ShapeShiftCardType.Exchange end --region NormalListRefresh function this:ItemCountFunc() return #self.selectCardInfo end function this:ItemGetFunc() ---@type KLShapeShiftCardItem local item = GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Item/KLShapeShiftCard/KLShapeShiftCardItem", self.view.datalist_card, self, { type = E_ShapeShiftCardFuncType.Break }, true) local kmlCtrl = item.view.root self.cardItemList[kmlCtrl] = item return kmlCtrl end ---@param realIndex number ---@param kmlCtrl KingML.KmlControl function this:ItemUpdateFunc(realIndex, kmlCtrl) ---@type KLShapeShiftCardItem local item = self.cardItemList[kmlCtrl] item:RefreshBreak(self.selectCardInfo[realIndex + 1]) end --endregion --region ExchangeListRefresh function this:ExchangeItemCountFunc() return #self.exchangeCardInfo end function this:ExchangeItemGetFunc() ---@type KLShapeShiftCardItem local item = GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Item/KLShapeShiftCard/KLShapeShiftCardItem", self.view.datalist_card_exchange, self, { type = E_ShapeShiftCardFuncType.ExBreak }, true) local kmlCtrl = item.view.root self.cardExchangeItemList[kmlCtrl] = item return kmlCtrl end ---@param realIndex number ---@param kmlCtrl KingML.KmlControl function this:ExchangeItemUpdateFunc(realIndex, kmlCtrl) ---@type KLShapeShiftCardItem local item = self.cardExchangeItemList[kmlCtrl] item:RefreshBreak(self.exchangeCardInfo[realIndex + 1]) end --endregion --region BreakListRefresh function this:DataListItemGetFunc() ---@type KLShapeShiftCardItem local item = GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Item/KLShapeShiftCard/KLShapeShiftCardItem", self.view.break_card_list, self, { type = E_ShapeShiftCardFuncType.UnBreak }, true) local kmlCtrl = item.view.root self.cardBreakList[kmlCtrl] = item return kmlCtrl end function this:DataListItemUpdateFunc(realIndex, kmlCtrl) ---@type KLShapeShiftCardItem local item = self.cardBreakList[kmlCtrl] item:RefreshBreak(self.selectCardBreak[realIndex + 1]) end --endregion ---注册UI事件和服务器消息 function this:RegistEvents() GUI:AddOnClickEvent(self.view.btn_go, self, self.SwitchCardShop) GUI:AddOnClickEvent(self.view.btn_tips, self, self.FuncTips) GUI:AddOnClickEvent(self.view.btn_break, self, self.BreakOnClick) GUI:AddOnClickEvent(self.view.btn_auto_break_ex, self, self.AutoBreakOnClick) GUI:AddOnClickEvent(self.view.btn_auto_break, self, self.AutoBreakOnClick) GUI:AddOnClickEvent(self.view.btn_break_up, self, self.RefreshBreakPanel) GUI:SetToggleOnValueChange(self.view.toggle_shift, self, self.ToggleShiftOnChange) GUI:SetToggleOnValueChange(self.view.toggle_attr, self, self.ToggleAttrOnChange) GUI:SetToggleOnValueChange(self.view.toggle_god_attr, self, self.ToggleGodAttrOnChange) SL:RegisterLUAEvent(LUA_SHAPE_CARD_BAG_CHANGE, self.RES_TRANSFER_CARD_BAG, self) SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_CARD_BREAKTHROUGH_FAIL, self.RES_CARD_BREAKTHROUGH_FAIL, self) end ---界面显示时调用一次 function this:Show() end ---创建或者刷新界面数据时调用 function this:Refresh() self.selectCardInfo = {} self.normalCardInfo = {} self.exchangeCardInfo = {} self:RES_TRANSFER_CARD_BAG() end function this:SwitchCardShop() local ui = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardMain/KLShapeShiftCardMainPanel") if ui then GUI:Toggle_setIsOn(ui.view.toggle_shop, true) end end function this:FuncTips() local helpCfg = SL:GetConfig("cfg_rule_text", 103) if helpCfg then SL:CommonStrTipsMessage({ title = helpCfg.menutxt, str = helpCfg.location }) end end function this:RefreshBreakPanel() self.breakIsShow = not self.breakIsShow if not self.breakIsShow then self:HideBreakPanel() else self:ShowBreakPanel() end end function this:HideBreakPanel(isChange) GUI:setVisible(self.view.panel_break, false) GUI:setPositionY(self.view.btn_break_up, -22) GUI:setContentSize(self.view.loopscrollview_card, 825, 463) GUI:Image_loadTexture(self.view.img_btn_icon, "house_up", "Atlas/KLShapeShiftCard.spriteatlas") if not isChange then if #self.selectCardInfo == 0 then GUI:setVisible(self.view.panel_no_card, true) end self:RefreshScrollView() end self.selectCardBreak = {} self.attrList = {} self.breakCount = 1 GUI:setVisible(self.view.text_minor_1, false) GUI:setVisible(self.view.text_minor_2, false) GUI:DataListUpdateData(self.view.attr_datalist) GUI:SetLoadingbar_startper(self.view.loadingbar_luck, 0) end function this:ShowBreakPanel() GUI:setVisible(self.view.panel_break, true) GUI:setPositionY(self.view.btn_break_up, 190) GUI:setContentSize(self.view.loopscrollview_card, 825, 254) GUI:Image_loadTexture(self.view.img_btn_icon, "house_down", "Atlas/KLShapeShiftCard.spriteatlas") if #self.selectCardInfo == 0 then GUI:setVisible(self.view.panel_no_card, false) end GUI:DataListUpdateData(self.view.break_card_list) GUI:DataListUpdateData(self.view.datalist_card) self.needRefreshHouseList = true end function this:ToggleShiftOnChange(_, _, eventData) if eventData[1] then self:RefreshExchangeScrollView() end end function this:ToggleAttrOnChange(_, _, eventData) if eventData[1] then self.scrollViewType = E_ShapeShiftCardType.Attr self:RefreshScrollView() end end function this:ToggleGodAttrOnChange(_, _, eventData) if eventData[1] then self.scrollViewType = E_ShapeShiftCardType.GodAttr self:RefreshScrollView() end end function this:AutoBreakOnClick() GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardAutoUpgrade/KLShapeShiftCardAutoUpgradePanel", nil, nil, { callback = self.AutoUpgradeClick, funcType = E_ShapeShiftCardFuncType.Break, cardType = self.scrollViewType, btnName = "一键突破" }) end function this.AutoUpgradeClick(autoType, autoLevel) SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_BREAKTHROUGH_CARD_ALL, { autoType, autoLevel }) end function this:BreakOnClick() if #self.selectCardBreak == self.breakCount then SL:CommonTipsMessage({ stringTblID = 20008, ui = self, callback = function() local card = {} local mainCard = self.selectCardBreak[1].id for i = 2, self.breakCount do card[#card + 1] = self.selectCardBreak[i].id end SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_BREAKTHROUGH_CARD, { mainCard, card }) end }) else SL:TipMessage(SL:GetConfig('cfg_string', 20004).text, 1, NoticeType.NoticeMid) --"卡牌数量不足" end end function this:RES_TRANSFER_CARD_BAG() self.normalCardInfo = {} self.exchangeCardInfo = {} ---@type BagShapeShiftCard[] local message = InfoManager.shapeShiftCardInfo.allCardInfo if message then for _, v in pairs(message) do ---@type cfg_card_breakthrough_column if SL:HasConfig("cfg_card_breakthrough", v.cfgid) then local card_break_tbl = SL:GetConfig("cfg_card_breakthrough", v.cfgid) if card_break_tbl and card_break_tbl.expend ~= 0 then v.breakTbl = card_break_tbl if v.type == E_ShapeShiftCardType.Exchange then local isHave = true for _, vv in pairs(self.exchangeCardInfo) do if vv.cfgid == v.cfgid then vv.count[#vv.count + 1] = v.id isHave = false end end if isHave then v.count = {} v.count[1] = v.id self.exchangeCardInfo[#self.exchangeCardInfo + 1] = v end elseif v.type == E_ShapeShiftCardType.Attr or v.type == E_ShapeShiftCardType.GodAttr then self.normalCardInfo[#self.normalCardInfo + 1] = v end end end end end table.sort(self.normalCardInfo, function(a, b) if a.subType ~= b.subType then return a.subType < b.subType else if a.quality ~= b.quality then return a.quality > b.quality else return a.cfgid > b.cfgid end end end) table.sort(self.exchangeCardInfo, function(a, b) if a.subType ~= b.subType then return a.subType < b.subType else if a.quality ~= b.quality then return a.quality > b.quality else return a.cfgid > b.cfgid end end end) self:HideBreakPanel(true) self.breakIsShow = false if self.scrollViewType == E_ShapeShiftCardType.Exchange then self:RefreshExchangeScrollView() else self:RefreshScrollView() end self:RefreshBreakRedPoint() end ---刷新赋能卡牌 function this:RefreshScrollView(cfgid, noReset) GUI:setVisible(self.view.loopscrollview_card_exchange, false) GUI:setVisible(self.view.loopscrollview_card, true) GUI:setVisible(self.view.btn_break_up, true) GUI:setVisible(self.view.btn_auto_break_ex, false) self.selectCardInfo = {} if not cfgid then for _, v in pairs(self.normalCardInfo) do if not noReset then ---显示选中光圈 v.select = false end if v.type == self.scrollViewType then self.selectCardInfo[#self.selectCardInfo + 1] = v end end else for _, v in pairs(self.normalCardInfo) do if v.type == self.scrollViewType and v.cfgid == cfgid then self.selectCardInfo[#self.selectCardInfo + 1] = v end end end GUI:DataListUpdateData(self.view.datalist_card) if #self.selectCardInfo == 0 and not cfgid then GUI:setVisible(self.view.panel_no_card, true) else GUI:setVisible(self.view.panel_no_card, false) end if self.scrollViewType == E_ShapeShiftCardType.Attr then GUI:setVisible(self.view.img_redPoint, self.red_1) elseif self.scrollViewType == E_ShapeShiftCardType.GodAttr then GUI:setVisible(self.view.img_redPoint, self.red_3) end end ---刷新变身卡牌 function this:RefreshExchangeScrollView() self.scrollViewType = E_ShapeShiftCardType.Exchange ---隐藏突破副窗口且不刷新赋能卡牌数据 self:HideBreakPanel(true) self.breakIsShow = false GUI:setVisible(self.view.loopscrollview_card_exchange, true) GUI:setVisible(self.view.loopscrollview_card, false) GUI:setVisible(self.view.btn_break_up, false) GUI:DataListUpdateData(self.view.datalist_card_exchange) if #self.exchangeCardInfo == 0 then GUI:setVisible(self.view.panel_no_card, true) GUI:setVisible(self.view.btn_auto_break_ex, false) else GUI:setVisible(self.view.panel_no_card, false) GUI:setVisible(self.view.btn_auto_break_ex, true) end end function this:SetBreakInfo(info, isAdd) if isAdd then ---突破材料满了不进行后续操作 local isMax = true for i = 1, info.breakTbl.expend do if not self.selectCardBreak[i] or not self.selectCardBreak[i].id then self.selectCardBreak[i] = info isMax = false if i == 1 then self.attrList = {} GUI:setVisible(self.view.attr_layout, true) if info and table.count(info.entry) then for _, v in pairs(info.entry) do self.attrList[#self.attrList + 1] = { ["attrId"] = v.attrid, ["attrValue"] = v.attrvalue, ["attrCfgId"] = v.entryid } end end GUI:DataListUpdateData(self.view.attr_datalist) GUI:SetLoadingbar_startper(self.view.loadingbar_luck, info.breakLuck) end break end end if isMax then return true end else for i = 1, info.breakTbl.expend do if self.selectCardBreak[i] and self.selectCardBreak[i].id == info.id then self.selectCardBreak[i] = nil if i == 1 then self.attrList = {} GUI:DataListUpdateData(self.view.attr_datalist) GUI:SetLoadingbar_startper(self.view.loadingbar_luck, 0) end break end end end self.breakCount = 1 for i = 1, info.breakTbl.expend do if self.selectCardBreak[i] then self.breakCount = self.selectCardBreak[i].breakTbl.expend break end end if self.breakCount == 1 then GUI:setVisible(self.view.text_minor_1, false) GUI:setVisible(self.view.text_minor_2, false) elseif self.breakCount == 2 then GUI:setVisible(self.view.text_minor_1, true) GUI:setVisible(self.view.text_minor_2, false) elseif self.breakCount == 3 then GUI:setVisible(self.view.text_minor_1, true) GUI:setVisible(self.view.text_minor_2, true) end GUI:DataListUpdateData(self.view.break_card_list) ---刷新单个卡牌选中框,不刷全部卡牌,防止刷新导致list位置重置 if not self.needRefreshHouseList then ---@param v KLShapeShiftCardItem for _, v in pairs(self.cardItemList) do v:ShowSelectShow(info.id, isAdd) end end ---刷新数据正确性 for _, v in pairs(self.selectCardInfo) do if v.id == info.id then v.select = isAdd break end end for i = 1, info.breakTbl.expend do if self.selectCardBreak[i] then ---选中主卡才刷新牌库,后续不刷新,防止刷新导致list位置重置 if self.needRefreshHouseList then self:RefreshScrollView(self.selectCardBreak[i].cfgid) self.needRefreshHouseList = false end return end end ---无卡时需要刷新全部卡牌 self.needRefreshHouseList = true self:RefreshScrollView(nil, true) end function this:RefreshBreakRedPoint() self.red_1 = false self.red_2 = false self.red_3 = false for _, v in pairs(self.normalCardInfo) do if v.type == E_ShapeShiftCardType.Attr and not self.red_1 then local cardCount = InfoManager.shapeShiftCardInfo:GetBagCardCountByCfgId(v.cfgid) if cardCount >= v.breakTbl.expend then self.red_1 = true if self.red_3 then break end end elseif v.type == E_ShapeShiftCardType.GodAttr and not self.red_3 then local cardCount = InfoManager.shapeShiftCardInfo:GetBagCardCountByCfgId(v.cfgid) if cardCount >= v.breakTbl.expend then self.red_3 = true if self.red_1 then break end end end end for _, v in pairs(self.exchangeCardInfo) do local cardCount = InfoManager.shapeShiftCardInfo:GetBagCardCountByCfgId(v.cfgid) if cardCount >= v.breakTbl.expend then self.red_2 = true break end end GUI:setVisible(self.view.img_redPoint_shift, self.red_2) GUI:setVisible(self.view.img_redPoint_attr, self.red_1) GUI:setVisible(self.view.img_redPoint_god_attr, self.red_3) end function this:RES_CARD_BREAKTHROUGH_FAIL() GUI:setVisible(self.view.img_fail, false) GUI:setVisible(self.view.img_fail, true) end function this:Close() if self.timer then SL:UnSchedule(self.timer) self.timer = nil end self.cardItemList = nil self.selectCardInfo = nil self.normalCardInfo = nil self.cardBreakList = nil self.selectCardBreak = nil end return this