-- 仇敌设置 local UIRivalSetting = UIViewClass() -------------------- function UIRivalSetting:OnCreated() self.rivalSloganView = nil self.isInitEnd = false self.rivalShoutingStrLimit = DataSheetManager.ConstData:GetDataByID("RivalRevengeShoutoutCharNumLimit").IntValue self.commonShoutingStrLimit = DataSheetManager.ConstData:GetDataByID("RivalKillShoutoutCharNumLimit").IntValue end function UIRivalSetting:OnOpened(context) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_Rival_RivalSetting) self:RegistSystemEvent(EventID.UI_Rival_RefreshSetting, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_Rival_CloseSlogan, self.CloseRivalSloganView) self.isInitEnd = false self:InitPanel() self:RefreshPanel() self.isInitEnd = true end function UIRivalSetting:OnBackButtonPressed() if self.rivalSloganView then self:CloseRivalSloganView() else self:OnButtonClicked(self.UICommonPopUp.btn_Close) end end function UIRivalSetting:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_RevengeShoutoutEdit then if not self.rivalSloganView then local inputTextStr = self.txt_RevengeShoutoutContent.text self.rivalSloganView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIRivalslogan), { parentView = self, inputText = inputTextStr, parentComp = self.btn_RevengeShoutoutEdit, contentStrLimit = self.rivalShoutingStrLimit, emptyHintText = Const_IDS.IDS_Rival_EditShoutoutText, titleText = Const_IDS.IDS_Rival_RevengeShoutout, tipText = Const_IDS.IDS_Rival_RevengeShoutoutDesc, }) end elseif comp == self.btn_KillShoutoutEdit then if not self.rivalSloganView then local inputTextStr = self.txt_KillShoutoutContent.text self.rivalSloganView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIRivalslogan), { parentView = self, inputText = inputTextStr, parentComp = self.btn_KillShoutoutEdit, contentStrLimit = self.commonShoutingStrLimit, emptyHintText = Const_IDS.IDS_Rival_EditShoutoutText, titleText = Const_IDS.IDS_Rival_KillShoutout, tipText = Const_IDS.IDS_Rival_KillShoutoutDesc, }) end end end function UIRivalSetting:OnValueChanged(comp, index) if not self.isInitEnd then return end -- 开关状态:index == 0 为关,== 1 为开 local isOpen = false if index == 1 then isOpen = true end if comp == self.group_EnemySettingOpt then MDL.Rival.RivalSettingRequest({OpenAutoConvert = isOpen}) elseif comp == self.group_RevengeShoutoutOpt then MDL.Rival.RivalSettingRequest({OpenRivalShoutingBlistering = isOpen}) elseif comp == self.group_KillShoutoutOpt then MDL.Rival.RivalSettingRequest({OpenCommonShoutingBlistering = isOpen}) end end -------------------- function UIRivalSetting:CloseRivalSloganView() if not self.rivalSloganView then return end self.rivalSloganView:CloseView() self.rivalSloganView = nil end function UIRivalSetting:ExcuteRivalSloganBack(comp, rivalSloganStr) if comp == self.btn_RevengeShoutoutEdit then MDL.Rival.RivalSettingRequest({RivalShoutingContent = rivalSloganStr}) elseif comp == self.btn_KillShoutoutEdit then MDL.Rival.RivalSettingRequest({CommonShoutingContent = rivalSloganStr}) end end -- 静态数据 function UIRivalSetting:InitPanel() local autoAddEnemyValue = DataSheetManager.ConstData:GetDataByID("RivalSettingsAutoAddEnemyValue").IntValue UIUtils.SetLabel(self.txt_EnemySettingTitleText, string.FormatByIdsId(Const_IDS.IDS_Rival_AutoAddEnemyDesc, autoAddEnemyValue)) end -- 动态数据 function UIRivalSetting:RefreshPanel() for k, v in MDL.Rival.GetRivalSettingIterator() do if k == MDL.Rival.RivalSettingKeyList.OpenAutoConvert then self.group_EnemySettingOpt:GetToggle(v and 1 or 0).isOn = true elseif k == MDL.Rival.RivalSettingKeyList.OpenRivalShoutingBlistering then self.group_RevengeShoutoutOpt:GetToggle(v and 1 or 0).isOn = true elseif k == MDL.Rival.RivalSettingKeyList.OpenCommonShoutingBlistering then self.group_KillShoutoutOpt:GetToggle(v and 1 or 0).isOn = true elseif k == MDL.Rival.RivalSettingKeyList.RivalShoutingContent then UIUtils.SetLabel(self.txt_RevengeShoutoutContent, v) elseif k == MDL.Rival.RivalSettingKeyList.CommonShoutingContent then UIUtils.SetLabel(self.txt_KillShoutoutContent, v) end end end return UIRivalSetting