---@class KLSettingBasicPanel:UIKmlLuaPanelBase ---@field view KLSettingBasicPanelView local KLSettingBasicPanel = class(UIKmlLuaPanelBase) local this = KLSettingBasicPanel this.currentFightState = nil this.pkName = { ["全体"] = 0, ["和平"] = 1, ["组队"] = 4, ["战盟"] = 5, } ---创建时调用一次 function this:Init() end ---创建或者刷新界面数据时调用 function this:Refresh() local bgSound = SL:GetMetaValue(EMetaVarGetKey.GET_BACKGROUND_SOUND) local soundEffect = SL:GetMetaValue(EMetaVarGetKey.GET_SOUND_EFFECT) --第一次进游戏没有设置默认勾选 local clickFloorMove = SL:GetMetaValue(EMetaVarGetKey.GET_CLICK_FLOOR_IS_SELECT) GUI:Slider_setPercent(self.view.bgSlider, bgSound) GUI:Slider_setPercent(self.view.soundSlider, soundEffect) GUI:SetIsOnWithoutNotify(self.view.clickFloor, clickFloorMove ~= EScreen.True) local pkMode = SL:GetMetaValue(EMetaVarGetKey.PKMODE) if tostring(pkMode) == "0" then this.currentFightState = self.view.toggle10 elseif tostring(pkMode) == "1" then this.currentFightState = self.view.toggle12 elseif tostring(pkMode) == "2" then this.currentFightState = self.view.toggle14 elseif tostring(pkMode) == "3" then this.currentFightState = self.view.toggle16 end GUI:SetIsOnWithoutNotify(this.currentFightState, true) end ---注册UI事件和服务器消息 function this:RegistEvents() GUI:SetToggleOnValueChange(self.view.clickFloor, self, self.ClickFloorValueChange) GUI:AddOnClickEvent(self.view.BtnRoleChose, self, self.BtnRoleChoseOnClick) GUI:AddOnClickEvent(self.view.BtnExitGame, self, self.BtnExitGameOnClick) GUI:AddOnClickEvent(self.view.BtnReDefault, self, self.BtnReDefaultOnClick) GUI:SetSliderOnValueChange(self.view.bgSlider, self, self.BgSliderOnValueChange) GUI:SetSliderOnValueChange(self.view.soundSlider, self, self.SoundSliderOnValueChange) GUI:SetToggleOnValueChange(self.view.toggle10, self, self.PkMode2AllOnValueChange) GUI:SetToggleOnValueChange(self.view.toggle12, self, self.PkMode2PeaceOnValueChange) GUI:SetToggleOnValueChange(self.view.toggle14, self, self.PkMode2TeamOnValueChange) GUI:SetToggleOnValueChange(self.view.toggle16, self, self.PkMode2UnionOnValueChange) end function this:PkMode2AllOnValueChange(control, _, data) local isToggle = data[1] if isToggle then if self:SwitchPkMode(this.pkName["全体"]) then this.currentFightState = self.view.toggle10 return end GUI:SetIsOnWithoutNotify(this.currentFightState, true) end end function this:PkMode2PeaceOnValueChange(control, _, data) local isToggle = data[1] if isToggle then if self:SwitchPkMode(this.pkName["和平"]) then this.currentFightState = self.view.toggle12 return end GUI:SetIsOnWithoutNotify(this.currentFightState, true) end end function this:PkMode2TeamOnValueChange(control, _, data) local isToggle = data[1] if isToggle then if self:SwitchPkMode(this.pkName["组队"]) then this.currentFightState = self.view.toggle14 return end GUI:SetIsOnWithoutNotify(this.currentFightState, true) end end function this:PkMode2UnionOnValueChange(control, _, data) local isToggle = data[1] if isToggle then if self:SwitchPkMode(this.pkName["战盟"]) then this.currentFightState = self.view.toggle16 return end GUI:SetIsOnWithoutNotify(this.currentFightState, true) end end function this:SwitchPkMode(index) if GlobalLuaEventManager.isCrossServer and GlobalLuaEventManager.isCrossServer == 1 then if not SL:MeData_GetUnionId() or SL:MeData_GetUnionId() == 0 then if index ~= 0 then SL:TipMessage("当前地图无法切换pk模式", 1, NoticeType.NoticeMid) return false end else if index ~= 5 then SL:TipMessage("当前地图无法切换pk模式", 1, NoticeType.NoticeMid) return false end end end local tip = SL:GetMetaValue(EMetaVarGetKey.PKMODE_CAN_USE, index) if not string.isNullOrEmpty(tip) then SL:TipMessage(tip, 1, NoticeType.NoticeMid) return false end SL:SetMetaValue(EMetaVarSetKey.SET_PKMODE, index) return true end function this:ClickFloorValueChange(control, _, data) local isToggle = data[1] if not isToggle then SL:SetMetaValue(EMetaVarSetKey.SET_IS_CLICK_FLOOR_MOVE, EScreen.True) SL:TipMessage("已解除禁止角色位移", 1, NoticeType.NoticeMid) else SL:SetMetaValue(EMetaVarSetKey.SET_IS_CLICK_FLOOR_MOVE, EScreen.False) SL:TipMessage("已禁止角色位移", 1, NoticeType.NoticeMid) end end function this:FixedJoyStickOnValueChange(control, _, data) local isToggle = data[1] if isToggle then SL:SetMetaValue(EMetaVarSetKey.SET_ROCKER_TYPE, ETickModel.fixed) end end function this:MoveJoyStickOnValueChange(control, _, data) local isToggle = data[1] if isToggle then SL:SetMetaValue(EMetaVarSetKey.SET_ROCKER_TYPE, ETickModel.Move) end end function this:BtnLockOnClick() GUI:UIPanel_Open("dev/ui/Setting/Panel/KLLock/KLLockPanel") end function this:BtnRoleChoseOnClick() SL:QuitSelectRoleUI() end function this:BtnExitGameOnClick() if LoginManager.isSdk and not Main.isWindows then MuInterface.Instance:LogoutAccount() else SL:QuitGame() end end function this:BtnReDefaultOnClick() SL:ReplyDefaultBaseSetting() self:Refresh() end function this:BgSliderOnValueChange(control, _, data) local value = math.ceil(data[1]) SL:SetMetaValue(EMetaVarSetKey.SET_BACKGROUND_SOUND, value) end function this:SoundSliderOnValueChange(control, _, data) local value = math.ceil(data[1]) SL:SetMetaValue(EMetaVarSetKey.SET_SOUND_EFFECT, value) end function this:VoiceSliderOnValueChange(control, _, data) local value = math.ceil(data[1]) SL:SetMetaValue(EMetaVarSetKey.SET_VOICE, value) end function this:Close() end return this