---@class KLShapeShiftCardSynthesisPanel:UIKmlLuaPanelBase ---@field view KLShapeShiftCardSynthesisPanelView local KLShapeShiftCardSynthesisPanel = class(UIKmlLuaPanelBase) local this = KLShapeShiftCardSynthesisPanel function this:AsyncLoadUI() end ---创建时调用一次 function this:Init() self.synthesisCount = 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.cardSynthesisList = {} self.selectCardSynthesis = {} GUI:DataListInitData(self.view.synthesis_card_list, function() return self.synthesisCount 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.Synthesis }, 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:RefreshSynthesis(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.ExSynthesis }, 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:RefreshSynthesis(self.exchangeCardInfo[realIndex + 1]) end --endregion --region SynthesisListRefresh function this:DataListItemGetFunc() ---@type KLShapeShiftCardItem local item = GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Item/KLShapeShiftCard/KLShapeShiftCardItem", self.view.synthesis_card_list, self, { type = E_ShapeShiftCardFuncType.UnSynthesis }, true) local kmlCtrl = item.view.root self.cardSynthesisList[kmlCtrl] = item return kmlCtrl end function this:DataListItemUpdateFunc(realIndex, kmlCtrl) ---@type KLShapeShiftCardItem local item = self.cardSynthesisList[kmlCtrl] item:RefreshSynthesis(self.selectCardSynthesis[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_synthesis, self, self.SynthesisOnClick) GUI:AddOnClickEvent(self.view.btn_auto_synthesis_ex, self, self.AutoSynthesisOnClick) GUI:AddOnClickEvent(self.view.btn_auto_synthesis, self, self.AutoSynthesisOnClick) GUI:AddOnClickEvent(self.view.btn_synthesis_up, self, self.RefreshSynthesisPanel) 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) 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:RefreshSynthesisPanel() self.synthesisIsShow = not self.synthesisIsShow if not self.synthesisIsShow then self:HideSynthesisPanel() else self:ShowSynthesisPanel() end end function this:HideSynthesisPanel(isChange) GUI:setVisible(self.view.panel_synthesis, false) GUI:setPositionY(self.view.btn_synthesis_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.selectCardSynthesis = {} self.attrList = {} self.synthesisCount = 1 GUI:setVisible(self.view.text_minor_1, false) GUI:setVisible(self.view.text_minor_2, false) GUI:DataListUpdateData(self.view.attr_datalist) end function this:ShowSynthesisPanel() GUI:setVisible(self.view.panel_synthesis, true) GUI:setPositionY(self.view.btn_synthesis_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.synthesis_card_list) 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:AutoSynthesisOnClick() GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardAutoUpgrade/KLShapeShiftCardAutoUpgradePanel", nil, nil, { callback = self.AutoUpgradeClick, funcType = E_ShapeShiftCardFuncType.Synthesis, cardType = self.scrollViewType, btnName = "一键合成" }) end function this.AutoUpgradeClick(autoType, autoLevel) SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_SYNTHESIS_ALL_CARD, { autoType, autoLevel }) end function this:SynthesisOnClick() if #self.selectCardSynthesis == self.synthesisCount then SL:CommonTipsMessage({ stringTblID = 20006, ui = self, callback = function() local card = {} local mainCard = self.selectCardSynthesis[1].id for i = 2, self.synthesisCount do card[#card + 1] = self.selectCardSynthesis[i].id end SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TRANSFER_CARD_SYNTHESIS, { 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 if v.tbl.upAmount ~= 0 then 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 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:HideSynthesisPanel(true) self.synthesisIsShow = false if self.scrollViewType == E_ShapeShiftCardType.Exchange then self:RefreshExchangeScrollView() else self:RefreshScrollView() end self:RefreshSynthesisRedPoint() 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_synthesis_up, true) GUI:setVisible(self.view.btn_auto_synthesis_ex, false) self.selectCardInfo = {} if not cfgid then for _, v in pairs(self.normalCardInfo) do if v.type == self.scrollViewType then if not noReset then ---显示选中光圈 v.select = false end if v.type == self.scrollViewType then self.selectCardInfo[#self.selectCardInfo + 1] = v end 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:HideSynthesisPanel(true) self.synthesisIsShow = false GUI:setVisible(self.view.loopscrollview_card_exchange, true) GUI:setVisible(self.view.loopscrollview_card, false) GUI:setVisible(self.view.btn_synthesis_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_synthesis_ex, false) else GUI:setVisible(self.view.panel_no_card, false) GUI:setVisible(self.view.btn_auto_synthesis_ex, true) end end function this:SetSynthesisInfo(info, isAdd) if isAdd then ---合成材料满了不进行后续操作 local isMax = true for i = 1, info.tbl.upAmount do if not self.selectCardSynthesis[i] or not self.selectCardSynthesis[i].id then self.selectCardSynthesis[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) end break end end if isMax then return true end else for i = 1, info.tbl.upAmount do if self.selectCardSynthesis[i] and self.selectCardSynthesis[i].id == info.id then self.selectCardSynthesis[i] = nil if i == 1 then self.attrList = {} GUI:DataListUpdateData(self.view.attr_datalist) end break end end end self.synthesisCount = 1 for i = 1, info.tbl.upAmount do if self.selectCardSynthesis[i] then self.synthesisCount = self.selectCardSynthesis[i].tbl.upAmount break end end if self.synthesisCount == 1 then GUI:setVisible(self.view.text_minor_1, false) GUI:setVisible(self.view.text_minor_2, false) elseif self.synthesisCount == 2 then GUI:setVisible(self.view.text_minor_1, true) GUI:setVisible(self.view.text_minor_2, false) elseif self.synthesisCount == 3 then GUI:setVisible(self.view.text_minor_1, true) GUI:setVisible(self.view.text_minor_2, true) end GUI:DataListUpdateData(self.view.synthesis_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.tbl.upAmount do if self.selectCardSynthesis[i] then ---选中主卡才刷新牌库,后续不刷新,防止刷新导致list位置重置 if self.needRefreshHouseList then self:RefreshScrollView(self.selectCardSynthesis[i].cfgid) self.needRefreshHouseList = false end return end end ---无卡时需要刷新全部卡牌 self.needRefreshHouseList = true self:RefreshScrollView(nil, true) end function this:RefreshSynthesisRedPoint() 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.tbl.upAmount 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.tbl.upAmount 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.tbl.upAmount then self.red_2 = true break end end GUI:setVisible(self.view.img_redPoint_god_attr, self.red_3) GUI:setVisible(self.view.img_redPoint_shift, self.red_2) GUI:setVisible(self.view.img_redPoint_attr, self.red_1) end function this:Close() self.cardItemList = nil self.selectCardInfo = nil self.normalCardInfo = nil self.cardSynthesisList = nil self.selectCardSynthesis = nil end return this