local UIPKCreatePanel = UIViewClass() function UIPKCreatePanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_PK_FailClearInfo, self.ResetFillInfo) self.activityID = context.activityID self.filterRankLevel = 0 self.toggle_Code.isOn = false if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.PKRoomWatch) == false then UIUtils.SetActive(self.toggle_Watch, false) else UIUtils.SetActive(self.toggle_Watch, true) self.toggle_Watch.isOn = true end UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, context.activityID == LuaConst.ActivityType.SyncSoloPK and Const_IDS["IDS_PK_CreateRoom_Title_1"] or Const_IDS["IDS_PK_CreateRoom_Title_2"]) -- 初始化设置 UIUtils.SetActive(self.img_Arrow01, true) UIUtils.SetActive(self.img_Arrow02, false) UIUtils.SetActive(self.loop_LevelSelect, false) self:RefreshFilterInfo() local defaultRoomName = string.FormatByIdsId( Const_IDS["IDS_PK_CreateRoom_DefaultName"], CTL.CustomRoom.GetLimitRoomName(BattleDataGetter.GetPlayerName()) ) self.obj_RoomNameInputField.text = defaultRoomName end function UIPKCreatePanel:ResetFillInfo() self.obj_RoomNameInputField.text = nil end function UIPKCreatePanel:OnValueChanged(comp, index) if comp == self.toggle_Code then UIUtils.SetActive(self.obj_CodeInputField, index) if index == false then self.obj_CodeInputField.text = nil end elseif comp == self.obj_CodeInputField then self.obj_CodeInputField.text = UTL.String.CutStrByLength(index, 6) elseif comp == self.obj_RoomNameInputField then self.obj_RoomNameInputField.text = CTL.CustomRoom.GetLimitRoomName(self.obj_RoomNameInputField.text) end end function UIPKCreatePanel:OnBackButtonPressed() self:OnButtonClicked(self.btn_Cancel) end function UIPKCreatePanel:OnButtonClicked(comp) if comp == self.btn_Cancel or comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.event_Close then UIUtils.SetActive(self.img_Arrow01, true) UIUtils.SetActive(self.img_Arrow02, false) UIUtils.SetActive(self.loop_LevelSelect, false) elseif comp == self.event_Level then UIUtils.SetActive(self.img_Arrow01, false) UIUtils.SetActive(self.img_Arrow02, true) UIUtils.SetActive(self.loop_LevelSelect, true) elseif comp == self.btn_Sure then if self.toggle_Code.isOn and not CTL.CustomRoom.IsValidPWD(self.obj_CodeInputField.text) then -- 密码输入检测 -- 设置密码失败重置信息 self.obj_CodeInputField.text = nil return end if CTL.Team.IsInTeam() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_PK_InRanksToCreateRoom"]) return end if CTL.GuildEscort.IsTransport() then -- 势力押运中 CTL.Tips.AddTipsMsg(Const_IDS["IDS_Escort_Escorting"]) return end local canWatch = self.toggle_Watch.isOn MDL.CustomRoom.CreateCustomRoomReq( self.activityID, self.obj_RoomNameInputField.text, self.filterRankLevel, self.obj_CodeInputField.text, canWatch) self.obj_CodeInputField.text = nil end end function UIPKCreatePanel:RefreshFilterInfo() local desc = self.filterRankLevel == 0 and UIUtils.GetLocalizedTxt(Const_IDS["IDS_PK_Hall_EnterLimit_Null"]) or CTL.CustomRoom.GetLevelDescByActivityID(self.activityID, self.filterRankLevel) UIUtils.SetLabel(self.labLocal_Level, desc) self.loop_LevelSelect:ReloadAll(CTL.CustomRoom.GetPKLimitRankLevelList(self.activityID)) end function UIPKCreatePanel:OnCellClicked(scrollRect, index, cellTable, target, data) self.filterRankLevel = data.level UIUtils.SetLabel(self.labLocal_Level, data.desc) self:OnButtonClicked(self.event_Close) self:RefreshFilterInfo() end function UIPKCreatePanel:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetLabel(cellTable.txt_Uncheck, data.desc) UIUtils.SetActive(cellTable.img_Selected, self.filterRankLevel == data.level) end return UIPKCreatePanel