local UIPKChangeConfirmPanel = UIViewClass() local AUTO_CANCEL_TIME = DataSheetManager.ConstData:GetDataByID("PK_TeamPVP_ExchangeCountdown").IntValue local TEXT_COLOR = "FFC54A" local LERP_STEP = AUTO_CANCEL_TIME / 100 function UIPKChangeConfirmPanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_UpdateRoomInfo, self.OnCloseByTargetLeave) self.reqName = MDL.CustomRoom.GetMemberDataByACID(context.ReqACID).BriefInfo.Name self.timerCount = AUTO_CANCEL_TIME self.slider_ProgressBar.value = 1 self:StartRepeatFunc(self.UpdateCountDown, 1, -1) self:StartRepeatFunc(self.UpdateProgressBar, LERP_STEP, -1) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS["IDS_PK_ExchangingWindowTitle"]) UIUtils.SetLabel(self.txt_Info, string.FormatByIdsId(Const_IDS["IDS_PK_Room_Tips_11"], UTL.Color.FormatTextByColor(TEXT_COLOR, self.reqName), self.timerCount)) UIUtils.SetLabel(self.txt_Time, string.FormatByIdsId(Const_IDS["IDS_PK_Room_Tips_12"], UTL.Color.FormatTextByColor(TEXT_COLOR, self.timerCount))) end function UIPKChangeConfirmPanel:UpdateProgressBar(deltaTime, timeSinceUpdate) self.slider_ProgressBar.value = self.slider_ProgressBar.value - 0.01 end function UIPKChangeConfirmPanel:UpdateCountDown(deltaTime, timeSinceUpdate) self.timerCount = self.timerCount - 1 UIUtils.SetLabel(self.txt_Info, string.FormatByIdsId(Const_IDS["IDS_PK_Room_Tips_11"], UTL.Color.FormatTextByColor(TEXT_COLOR, self.reqName), self.timerCount)) UIUtils.SetLabel(self.txt_Time, string.FormatByIdsId(Const_IDS["IDS_PK_Room_Tips_12"], UTL.Color.FormatTextByColor(TEXT_COLOR, self.timerCount))) if self.timerCount <= 0 then self:OnButtonClicked(self.btn_Cancel) return end end function UIPKChangeConfirmPanel:OnCloseByTargetLeave() local isLeave = true for _, v in ipairs(MDL.CustomRoom.GetInRoomMemberDic()) do if v.ACID == self.context.ReqACID then isLeave = false break end end if isLeave then self:CloseView() end end function UIPKChangeConfirmPanel:OnButtonClicked(comp) if comp == self.btn_Cancel then MDL.CustomRoom.MemberOptEXPositionReq(false) elseif comp == self.btn_Sure then MDL.CustomRoom.MemberOptEXPositionReq(true) end self:CloseView() end return UIPKChangeConfirmPanel