local UISettingMainPanel = UIViewClass() function UISettingMainPanel:OnOpened(context) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Setting_Notification, self.RefreshNotificationRedPoint) self:RegistSystemEvent(EventID.UI_NotificationStateChange, self.NotificationStateChange) self:RegistSystemEvent(EventID.Setting_ShowPCKeyMapEditing, self.ChangeKeyMapShowingState) self:RegistSystemEvent(EventID.Game_ScreenResolutionChanged, self.ScreenResolutionChanged) -- 界面标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_Setting"]) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) UIUtils.SetActive(self.UITemplateTitlePanel.fit_Right, false) self.toggle_Left = self.group_LeftBtn.toggles_Group UTL.Toggle.InitToggleGroupByIDS(self.toggle_Left, "txt",{Const_IDS.IDS_Setting_Basic, Const_IDS.IDS_Setting_Image, Const_IDS.IDS_Setting_Voice, Const_IDS.IDS_APPPUSH_NOTICE,Const_IDS.IDS_PCPackage_Key}) self.toggle_Left:SelectIndex(MDL.Setting.curOpenView) self.toggle_Left:SetToggleActive(4, not GameAppInfo.IsPCPackage() and not GameAppInfo.IsMacPackage()) self.toggle_Left:SetToggleActive(5, GameAppInfo.IsPCPackage() or GameAppInfo.IsMacPackage()) if BattleDataGetter.IsStandaloneBattleLevel() then NotSyncBattleSetter.PauseLevel(true) end self:RefreshNotificationRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Setting_Notification)) self.versionInfo = MDL.HotFix.GetVersionInfo() self.txt_Version.text = self.versionInfo --如果开启预下载,监听下载进度 if CTL.HotFix.GetIsPreHotfix() then self:RegistSystemEvent(EventID.UI_Loading_UpdateDownloadProgress, self.UpdateDownloadProgress) end end function UISettingMainPanel:UpdateDownloadProgress(curSize, maxSize, speed) local progress = curSize / maxSize if progress == 1 then self.txt_Version.text = MDL.HotFix.GetVersionInfo() else self.txt_Version.text = string.format("%s(%.1f)", self.versionInfo, progress) end end function UISettingMainPanel:RefreshNotificationRedPoint(active) self.toggle_Left:SetRedPoint(3, active) end function UISettingMainPanel:OnClosed() if BattleDataGetter.IsStandaloneBattleLevel() then NotSyncBattleSetter.PauseLevel(false) end UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) UIUtils.SetActive(self.UITemplateTitlePanel.fit_Right, true) end function UISettingMainPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UISettingMainPanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then MDL.Setting.SendPlayerSetting() self:CloseView() MDL.Setting.curOpenView = 0 end end function UISettingMainPanel:OnValueChanged(comp, index) if comp == self.toggle_Left then self.subView:CloseAll() MDL.Setting.curOpenView = index if index == 0 then self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISettingBasicPanel)) elseif index == 1 then self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISettingQualityPanel)) elseif index == 2 then self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISettingSoundPanel)) elseif index == 3 then if CTL.Notification.IsShowNoticeSettingOpen() then CTL.Notification.SetHasOpenNotificationPanel() self.subView:OpenView(GetViewClass("Setting/UISettingNoticeOpenPanel")) else self.subView:OpenView(GetViewClass("Setting/UISettingNoticePanel")) end elseif index == 4 then self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISettingPCKeyMapping)) end end end function UISettingMainPanel:NotificationStateChange(isPause) if isPause then return end if not CTL.Notification.IsShowNoticeSettingOpen() then if self.subView:IsViewOpened("Setting/UISettingNoticeOpenPanel") then self.subView:CloseAll() self.subView:OpenView(GetViewClass("Setting/UISettingNoticePanel")) end end end function UISettingMainPanel:ChangeKeyMapShowingState(isShowEditing) MDL.Setting.isEditing = isShowEditing if isShowEditing then self.subView:CloseAll() self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISettingPCKeyMapEditing)) else self.subView:CloseAll() self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISettingPCKeyMapping)) end end function UISettingMainPanel:ScreenResolutionChanged() UTL.UIRender.AdaptiveImageSizeFit(self.img_Bottom, true) end return UISettingMainPanel