---@class KLShapeShiftCardUnLockPanel:UIKmlLuaPanelBase ---@field view KLShapeShiftCardUnLockPanelView local KLShapeShiftCardUnLockPanel = class(UIKmlLuaPanelBase) local this = KLShapeShiftCardUnLockPanel function this:AsyncLoadUI() end ---创建时调用一次 function this:Init() self.upgradeType = 1 end ---注册UI事件和服务器消息 function this:RegistEvents() GUI:AddOnClickEvent(self.view.btn_close, self, self.CloseSelf) --GUI:SetToggleOnValueChange(self.view.toggle_first, self, self.FirstToggleOnChange) --GUI:SetToggleOnValueChange(self.view.toggle_second, self, self.SecondToggleOnChange) GUI:AddOnClickEvent(self.view.btn_first_add, self, self.BuyTokens, 1) GUI:AddOnClickEvent(self.view.btn_second_add, self, self.BuyTokens, 2) GUI:AddOnClickEvent(self.view.btn_open, self, self.UnlockCardGrid) GUI:AddOnClickEvent(self.view.btn_help, self, self.FuncHelp) GUI:AddOnClickEvent(self.view.item_first, self, self.BtnTipsOnClick) end ---界面显示时调用一次 function this:Show() --GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardUnLock/KLShapeShiftCardUnLockPanel") end ---创建或者刷新界面数据时调用 function this:Refresh() ---@type cfg_card_inlay_column local cfg_card_inlay = SL:GetConfig("cfg_card_inlay", self.args.part) if cfg_card_inlay.holeAmount == #cfg_card_inlay.unlockFree then self.canUnlock = false ---@type cfg_card_inlay_column local cfg = SL:GetConfig("cfg_card_inlay", self.args.part) local rank = InfoManager.shapeShiftCardInfo:GetEquipRankByPart(self.args.part) local needRank for _, v in ipairs(cfg.unlockParameter) do if self.args.index == v[1] then needRank = v[2] if rank >= v[2] then self.canUnlock = true end end end if cfg.unlockType == 1 then local text if self.canUnlock then text = "当前品阶" .. rank .. "" else text = "当前品阶" .. rank .. "" end GUI:Text_setString(self.view.text_rank, text .. "/所需品阶" .. needRank) GUI:Text_setString(self.view.text_tips, "穿戴装备品阶") self.stringId = 20003 else local text if self.canUnlock then text = "当前等级" .. rank .. "" else text = "当前等级" .. rank .. "" end GUI:Text_setString(self.view.text_rank, text .. "/所需等级" .. needRank) GUI:Text_setString(self.view.text_tips, "穿戴首饰等级") self.stringId = 500 end else self.costNormalId = cfg_card_inlay.unlockNormal[self.args.index - 1][2] self.costNormalCost = cfg_card_inlay.unlockNormal[self.args.index - 1][3] local costNormalLuck = cfg_card_inlay.unlockNormal[self.args.index - 1][4] if #cfg_card_inlay.unlockSpecial > 0 then self.costSpecialId = cfg_card_inlay.unlockSpecial[self.args.index - 1][2] self.costSpecialCost = cfg_card_inlay.unlockSpecial[self.args.index - 1][3] GUI:setVisible(self.view.img_second, true) else GUI:setVisible(self.view.img_second, false) end GUI:Text_setString(self.view.text_first_success, math.floor(costNormalLuck / 100) .. "%") GUI:Item_setItemId(self.view.item_first, self.costNormalId) local normalHave = SL:GetBagItemCount(self.costNormalId) if normalHave < self.costNormalCost then normalHave = "" .. normalHave .. "" else normalHave = "" .. normalHave .. "" end GUI:Text_setString(self.view.text_first_cost, normalHave .. "/" .. self.costNormalCost) if self.costSpecialId then GUI:Item_setItemId(self.view.item_second, self.costSpecialId) local specialHave = SL:GetBagItemCount(self.costSpecialId) if specialHave < self.costSpecialCost then specialHave = "" .. specialHave .. "" else specialHave = "" .. specialHave .. "" end GUI:Text_setString(self.view.text_second_cost, specialHave .. "/" .. self.costSpecialCost) end end --GUI:Text_setString(self.view.text_bar_value, self.args.info.luck .. "/100") --GUI:SetLoadingbar_startper(self.view.loadingbar_value, self.args.info.luck) end function this:FirstToggleOnChange(_, _, eventData) if eventData[1] then self.upgradeType = 1 end end function this:SecondToggleOnChange(_, _, eventData) if eventData[1] then self.upgradeType = 2 end end function this:BuyTokens(_, eventData) if eventData == 1 then SL:CommonItemGetPath(nil, self.costNormalId, nil, nil, self) elseif eventData == 2 then SL:CommonItemGetPath(nil, self.costSpecialId, nil, nil, self) end end function this:UnlockCardGrid() if self.canUnlock then SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TRANSFER_CARD_UNLOCK, { self.args.part, self.args.index, self.upgradeType }) self:CloseSelf() else --if self.upgradeType == 1 then -- if self.costNormalCost > SL:GetBagItemCount(self.costNormalId) then -- SL:TipMessage({ SL:GetConfig('cfg_string',437).text,1, NoticeType.NoticeMid }) --材料不足,无法开启 -- return -- end --else -- if self.costSpecialCost > SL:GetBagItemCount(self.costSpecialId) then -- SL:TipMessage({ SL:GetConfig('cfg_string',437).text,1, NoticeType.NoticeMid }) --材料不足,无法开启 -- return -- end --end SL:TipMessage(SL:GetConfig('cfg_string', self.stringId).text, 1, NoticeType.NoticeMid) --材料不足,无法开启 end end function this:FuncHelp() local helpCfg = SL:GetConfig("cfg_rule_text", 104) if helpCfg then SL:CommonStrTipsMessage({ title = helpCfg.menutxt, str = helpCfg.location }) end end function this:BtnTipsOnClick() SL:OpenTips(nil, self.costNormalId) end function this:CloseSelf() GUI:UIPanel_Close("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardUnLock/KLShapeShiftCardUnLockPanel") end function this:Close() end return this