local UISettingBasicPanel = UIViewClass() local EventSystem = require('Event/EventSystem') local JSON = require("cjson") function UISettingBasicPanel:OnOpened(context) self:SettingBtnsInit() self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Setting_Customer, self.RefreshCustomBtnRedPoint) self:ShowPlayerInfo() -- 玩家信息 self:RefreshLanguageToggleView() -- 多语言 self:SetShowSkillInterCutType() -- 无双技能演出的次数状态 self:SetViewMode() -- 视角模式 self:RegistSystemEvent(EventID.UI_SDKUser_Unlock_Update, self.RefreshSDKUserBtn) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.RefreshUserAgreementBtn) if BattleDataGetter.IsTownLevel() or BattleDataGetter.IsOneHeroLevel() or not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SettingBack) then UIUtils.SetActive(self.event_BackTown.gameObject,false) else UIUtils.SetActive(self.event_BackTown.gameObject,true) end self:RefreshSDKUserBtn() CTL.Player.OperateGenderImage(self.image_Gender, MDL.Player.GetSelfGender()) UIUtils.SetActive(self.event_Language, Localization.IsSwitchLanguage()) UIUtils.SetActive(self.event_ChangeID, self:IsShowChangeIDButton()) UIUtils.SetActive(self.event_UserAgreement, self:IsShowUserAgreementButton()) if GameAppInfo.IsJapanesePackage() and BattleDataGetter.IsTownLevel() then UIUtils.SetActive(self.event_RegulationsForJP, true) UIUtils.SetLabelText(self.labLocal_RegulationsForJP, Const_IDS.IDS_JP_LoginAgreement_UseProtocol) UIUtils.SetActive(self.event_PrivacyForJP, true) UIUtils.SetLabelText(self.labLocal_PrivacyForJP, Const_IDS.IDS_JP_LoginAgreement_PrivacyRegulations) else UIUtils.SetActive(self.event_RegulationsForJP, false) UIUtils.SetActive(self.event_PrivacyForJP, false) end if GameAppInfo.IsPCOrMacPackage() then AuxUtil.StartChangeKeyMap() end end function UISettingBasicPanel:SettingBtnsInit() self.settingBtnList = {} self:InitBtn(self.btn_Horse, true, self.Horse_Close, self.Horse_Open, LuaConst.BattleSettingEnum.AutoRide, MDL.Setting.GetSettingRideState, nil, MDL.Setting.PrepareSetSettingState, nil) self:InitBtn(self.btn_ReleaseMusooSkill, true, self.ReleaseMusooSkill_Close, self.ReleaseMusooSkill_Open, LuaConst.BattleSettingEnum.AutoMusou, MDL.Setting.GetSettingAutoMusouState, nil, MDL.Setting.PrepareSetSettingState, nil) self:InitBtn(self.btn_ReleaseLieutenantSkill, true, self.ReleaseLieutenantSkill_Close, self.ReleaseLieutenantSkill_Open, LuaConst.BattleSettingEnum.AutoAdjutantSkill, MDL.Setting.GetSettingAutoAdjutantSkillState, nil, MDL.Setting.PrepareSetSettingState, nil) self:InitBtn(self.btn_PetAutoAttack, true, self.PetAutoAttack_Close, self.PetAutoAttack_Open, LuaConst.BattleSettingEnum.NotAutoPetAttack, MDL.Setting.GetSettingAutoPetAttackState, nil, MDL.Setting.PrepareSetSettingState, nil) self:InitBtn(self.btn_AdjutantLockAttackDir, true, self.AdjutantLockAttackDir_Close, self.AdjutantLockAttackDir_Open, LuaConst.BattleSettingEnum.AdjutantLockAttackDir, MDL.Setting.GetSettingAdjutantAttackDirState, nil, MDL.Setting.PrepareSetSettingState, nil) self:InitBtn(self.btn_BossViewLock ,LuaConst.DefaultTargetCameraLock, self.BossViewLock_Close, self.BossViewLock_Open, LuaConst.SettingKeyEnum.BossViewLock, nil, true, nil, function(state) NotSyncBattleSetter.ChangeCameraTargetPattern(state) end) self:InitBtn(self.btn_PassTimeLine, true, self.PassTimeLine_Close, self.PassTimeLine_Open, LuaConst.SettingKeyEnum.PassTimeLine, nil, true, MDL.Setting.SetKeyValue, function(state) NotSyncBattleSetter.SetCutsceneAutoPass(state) end) self:InitBtn(self.btn_Vibration, true, self.Vibration_Close, self.Vibration_Open, LuaConst.SettingKeyEnum.Vibrate, nil, true, MDL.Setting.SetKeyValue, nil) self:InitBtn(self.btn_SkillCameraShake, true, self.SkillCameraShake_Close, self.SkillCameraShake_Open, LuaConst.SettingKeyEnum.SkillCameraShake, nil, true, MDL.Setting.SetKeyValue, function(state) SettingAPI.EnableCameraShake = state end) self:InitBtn(self.btn_Adaptive, CTL.Optimize.GetAdaptiveLODState(), self.Adaptive_Close, self.Adaptive_Open, nil, nil, nil, nil, function(state) CTL.Optimize.EnableAdaptiveLOD(state) end) end function UISettingBasicPanel:IsShowChangeIDButton() if GameAppInfo.IsPCPackage() then return true end if GameAppInfo.IsChinesePackage() then if SDKUtil.ChannelID == LuaConst.SDKChannelId.Game4399 then return false elseif SDKUtil.ChannelID == LuaConst.SDKChannelId.Hero_Android then return false elseif SDKUtil.ChannelID == LuaConst.SDKChannelId.HuaWei then return false elseif SDKUtil.ChannelID == LuaConst.SDKChannelId.NuBiYa then return false end end return Localization.IsShowNTSDKSwichAccountBtn() end --隐私政策GMS开关变化时刷新 function UISettingBasicPanel:RefreshUserAgreementBtn(funcId, isUnlock) if funcId == MDL.Unlock.FunctionType.AndroidPrivary or funcId == MDL.Unlock.FunctionType.IOSPrivacy then UIUtils.SetActive(self.event_UserAgreement, self:IsShowUserAgreementButton()) end end function UISettingBasicPanel:IsShowUserAgreementButton() logging.log(LTAG.LOG,"AndroidPrivary ", MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.AndroidPrivary), "IOSPrivacy ", MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.IOSPrivacy)) if GameAppInfo.IsChinesePackage() then return not GameAppInfo.IsPCPackage() elseif GameAppInfo.IsOverseaPackage() and not GameAppInfo.IsPCPackage() then if GameAppInfo.IsAndroidPackage() then return MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.AndroidPrivary) elseif GameAppInfo.IsiOSPackage() then return MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.IOSPrivacy) end return false end return false end function UISettingBasicPanel:IsShowPrivacyButton() if GameAppInfo.IsChinesePackage() then return not GameAppInfo.IsPCPackage() end return false end function UISettingBasicPanel:RefreshSDKUserBtn() UIUtils.SetActive(self.event_UserCenter, not GameAppInfo.IsPCOrMacPackage() and MDL.Unlock.GetDebugSwitchState(MDL.Unlock.DebugSwitchType.UserCenter)) if GameAppInfo.IsChinesePackage() and GameAppInfo.IsPCPackage() then UIUtils.SetActive(self.event_Custom, false) else UIUtils.SetActive(self.event_Custom, MDL.Unlock.GetDebugSwitchState(MDL.Unlock.DebugSwitchType.UserCustom)) end if MDL.Unlock.GetDebugSwitchState(MDL.Unlock.DebugSwitchType.TypeCdKey) then if GameAppInfo.IsPCPackage() then UIUtils.SetActive(self.event_CDKey, CTL.WinLogin.IsUsePCNtSdk()) else UIUtils.SetActive(self.event_CDKey, true) end else UIUtils.SetActive(self.event_CDKey, false) end UIUtils.SetActive(self.event_LoginCode, CTL.PayMall.IsShowLoginCodeButton()) self:RefreshCustomBtnRedPoint() self:RefreshDeleteAccountBtn() end function UISettingBasicPanel:RefreshCustomBtnRedPoint() if MDL.Unlock.GetDebugSwitchState(MDL.Unlock.DebugSwitchType.UserCustom) then self.event_Custom:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Setting_Customer)) end end function UISettingBasicPanel:RefreshDeleteAccountBtn() if GameAppInfo.IsPCPackage() or GameAppInfo.IsVietnamPackage() then UIUtils.SetActive(self.event_DeleteAccount, false) return end UIUtils.SetActive(self.event_DeleteAccount, MDL.Unlock.GetDebugSwitchState(MDL.Unlock.DebugSwitchType.DeleteAccount)) end --[[ comp为对应的点击按钮,btnValue为选择的初始化bool,btnClose和open为对应的开关图片物体 constEnum为对应功能在配置表中对应需要的常量 getStateFunc为战斗中自动功能模块的获取初始bool的无参方法 isGetValue表示该功能模块是否从二进制文件DeviceData里获取初始bool --]] function UISettingBasicPanel:InitBtn(comp, btnValue, btnClose, btnOpen, constEnum, getStateFunc, isGetValue, execFunc, extraFunc) local btnAttr = {} self.settingBtnList[comp] = btnAttr btnAttr.isChosen = btnValue btnAttr.close_checkMark = btnClose btnAttr.open_checkMark = btnOpen btnAttr.constValue = constEnum btnAttr.execFunc = execFunc btnAttr.extraFunc = extraFunc if getStateFunc ~= nil then btnAttr.isChosen = getStateFunc() end if isGetValue then if MDL.Setting.HasKey(constEnum) then btnAttr.isChosen = MDL.Setting.GetKeyValue(constEnum) else MDL.Setting.SetKeyValue(constEnum, btnAttr.isChosen) end end UIUtils.SetActive(btnClose, not btnAttr.isChosen) UIUtils.SetActive(btnOpen, btnAttr.isChosen) end function UISettingBasicPanel:ProcessAction(comp) local btnAttr = self.settingBtnList[comp] if btnAttr == nil then return false end local constValue = btnAttr.constValue local close_checkMark = btnAttr.close_checkMark local open_checkMark = btnAttr.open_checkMark local execFunc = btnAttr.execFunc local extraFunc = btnAttr.extraFunc local chosen = not btnAttr.isChosen btnAttr.isChosen = chosen if execFunc then execFunc(constValue,chosen) end if extraFunc then extraFunc(chosen) end UIUtils.SetActive(close_checkMark, not chosen) UIUtils.SetActive(open_checkMark, chosen) return true end function UISettingBasicPanel:OnButtonClicked(comp) if comp == self.event_BackTown then -- 返回主城 if CTL.Setting.IsCantReturnTownLevel() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_system_escapeforbid"]) else CTL.Setting.BackToTown() end elseif comp == self.event_Escape then -- 脱离卡死 MDL.Setting.SendOutOfStuck() elseif comp == self.event_ChangeID then -- 切换账号 if GameAppInfo.IsPCPackageWithSdk() then CTL.WinLogin.SwitchAccount() else CTL.Notification.UnregisteAllNotification() SDKUtil.SwitchAccount() end elseif comp == self.event_CDKey then -- 礼包码 local t = {areaId = GameAppInfo.Global_ProductId, serverId = tostring(MDL.Login.GetServerId()), roleId = BattleDataGetter.GetAcID()} local str = JSON.encode(t) SDKUtil.OpenGiftChange(str) elseif comp == self.event_Language then -- 打开多语言弹窗 UIUtils.SetActive(self.loop_Language, true) UIUtils.SetActive(self.event_CloseLanguage, true) CTL.Sound.PlayGameSound("UI_expand") UIUtils.SetActive(self.img_Arrow01, true) UIUtils.SetActive(self.img_Arrow02, false) self:ShowLanguages() elseif comp == self.event_CloseLanguage then -- 关闭多语言弹窗 UIUtils.SetActive(self.loop_Language, false) UIUtils.SetActive(self.event_CloseLanguage, false) CTL.Sound.PlayGameSound("UI_fold") UIUtils.SetActive(self.img_Arrow01, false) UIUtils.SetActive(self.img_Arrow02, true) elseif self:ProcessAction(comp) then elseif comp == self.event_Custom then SDKUtil.OpenService(CTL.Setting.GetSdkServiceCustom()) elseif comp == self.event_UserCenter then SDKUtil.OpenUserCenter(CTL.Setting.GetSdkServiceCustom()) elseif comp == self.event_DeleteAccount then if SDKUtil.ChannelID == LuaConst.SDKChannelId.HuaWei then UTL.MessageBox.ShowOnlyOkBox(Const_IDS.IDS_DeleteAccount, Const_IDS.IDS_BindAccount_DeleteCharacter, nil, nil) else SDKUtil.OpenDeleteAccountService(CTL.Setting.GetSdkServiceCustom()) end elseif comp == self.event_UserAgreement then if GameAppInfo.IsChinesePackage() then UIManager.OpenView(Const_UI_Lua.UIEnum.UIUserAgreementPanel) elseif GameAppInfo.IsOverseaPackage() then UIManager.OpenView(Const_UI_Lua.UIEnum.UIUserAgreementPanel) elseif UNITY_ANDROID then SDKUtil.OpenPlatWebActivity() elseif UNITY_IOS then SDKUtil.OpenPlatWebUrl("https://www.newtypegames.com/privacy?lang=zh-hmt&orientation=1", "") end elseif comp == self.event_RegulationsForJP then SDKUtil.LoadUseRegulations() elseif comp == self.event_PrivacyForJP then SDKUtil.LoadPrivateRegulations() elseif comp == self.event_LoginCode then CTL.PayMall.SdkOpenLoginCode() end end function UISettingBasicPanel:OnValueChanged(comp, state) if comp == self.group_Musoo then -- 无双技能演出的次数状态 MDL.Setting.SetSkillInterCutType(state + 1) elseif comp == self.group_ViewMode then -- 视角模式 self.CameraCtrl:SetViewMode(state) self.CameraCtrl:ChangeFreePattern(true) self.CameraCtrl:SetRecordFreeInfo() end end --region -------------------------------- 玩家信息 -------------------------- function UISettingBasicPanel:ShowPlayerInfo() -- 名字 UIUtils.SetLabel(self.txt_HeroName, BattleDataGetter.GetPlayerName()) -- 等级 local tlData = DataSheetManager.TeamLevelData:GetDataByTeamLevel(MDL.Player.GetRoleLevel()) local roleLevel = tlData and tlData.TeamLevel or nil -- 头像 CTL.Character.SetSelfPortraitAndFrame(self.UIHeroHead190, roleLevel) -- 势力 if MDL.Guild.IsHasGuild() then UIUtils.SetLabel(self.txt_Guild, MDL.Guild.GetMyGuildInfo().guildName) else UIUtils.SetLabelText(self.txt_Guild, Const_IDS.IDS_None) end -- 官职 local titleData = MDL.OfficialPosition.GetCurTitleData() if titleData then local txt = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[titleData.Name1]), titleData.QualityColor) UIUtils.SetLabel(self.txt_Official, txt) else UIUtils.SetLabelText(self.txt_Official, Const_IDS.IDS_OfficialPosition_Civilian) end -- 编号 UIUtils.SetLabel(self.txt_Num, tostring(MDL.Player.GetRoleId())) -- 服务器 local curServer = MDL.Login.GetServerInfoByID(MDL.Login.GetServerId()) UIUtils.SetLabel(self.txt_Server, string.FormatByIdsId(Const_IDS.IDS_Rank_ServerIDS, MDL.Login.GetFirstName(curServer))) end --endregion -------------------------------- 玩家信息 -------------------------- --region -------------------------------- 刷新多语言 -------------------------- function UISettingBasicPanel:RefreshLanguageToggleView() local languageID = Localization.GetLanguage() UIUtils.SetLabelText(self.labLocal_Language, Const_IDS[Localization.GetLanguageIDS(languageID)]) UIUtils.SetActive(self.loop_Language, false) UIUtils.SetActive(self.event_CloseLanguage, false) UIUtils.SetActive(self.img_Arrow01, false) UIUtils.SetActive(self.img_Arrow02, true) UIUtils.SetActive(self.event_Language, BattleDataGetter.IsTownLevel()) --UIUtils.SetActive(self.event_Language.gameObject, false) --四测不开 end --endregion -------------------------------- 刷新多语言 -------------------------- --region -------------------------------- 无双技能演出的次数状态 -------------------------- function UISettingBasicPanel:SetShowSkillInterCutType() local _index = MDL.Setting.GetSkillInterCutType() self.group_Musoo:SelectIndex(_index - 1) end --endregion -------------------------------- 无双技能演出的次数状态 -------------------------- --region -------------------------------- 视角模式 -------------------------- function UISettingBasicPanel:SetViewMode() -- 视角模式 self.CameraCtrl = CameraController.Instance self.group_ViewMode:SelectIndex(self.CameraCtrl:GetViewMode()) end --endregion -------------------------------- 视角模式 -------------------------- function UISettingBasicPanel:OnCellClicked(scrollRect, index, cellTable, target, data) local language = Localization.GetLanguageByIndex(index + 1) if Localization.GetLanguage() == language then self:RefreshLanguageToggleView() else MDL.Setting.SendSetLanguage(language) CTL.Setting.SwitchLanguage(language,true) end end function UISettingBasicPanel:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetLabelText(cellTable.txt_Uncheck, Const_IDS[Localization.GetLanguageIDS(data)]) local languageID = Localization.GetLanguage() cellTable.stateSwitch:SetState(data == languageID and 1 or 0) end function UISettingBasicPanel:ShowLanguages() if self.loop_Language.Count == 0 then for i,v in ipairs(Localization.GetSwitchLanguages()) do self.loop_Language:AddData(v,0) end end end return UISettingBasicPanel