|
- local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
- local MJSound = MJFramework.MJImport("mj.luaScript.MJSound")
- local MJFunction = MJFramework.MJImport("mj.luaScript.MJFunction")
-
- local MJRoomSettingView = MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Room.MJRoomSettingView")
-
- local hongzhongRoomSettingView = class("hongzhongRoomSettingView", MJRoomSettingView)
-
- local CheckBox_Nor_Color = cc.c3b(21,99,97)
- local CheckBox_Sel_Color = cc.c3b(213,46,11)
-
- function hongzhongRoomSettingView:ctor()
- hongzhongRoomSettingView.super.ctor(self);
- self:loadUi()
- self.languageRadioManager = import("luaScript.Tools.RadioManager"):new()
- self.desktopRadioManager = import("luaScript.Tools.RadioManager"):new()
- self.mjcolorRadioManager = import("luaScript.Tools.RadioManager"):new()
- end
-
- function hongzhongRoomSettingView:loadUi()
- local ui = loadUI("hongzhong/res/ui_fangjian/hongzhong_ui_shezhi.ui")
- self.ui = ui
- self:addChild(ui)
- end
-
- function hongzhongRoomSettingView:onEnter()
- if self.languageRadioManager then
- self.languageRadioManager:addItem(self.ui.Items.CheckBox_PuTongHua, 1)
- self.languageRadioManager:addItem(self.ui.Items.CheckBox_Fangyan, 2)
- local defaultValue = tonumber(loadUserInfo("hongzhong_mj_sound")) or 1
- self.languageRadioManager:setDefault(defaultValue)
- self:setYuColor(defaultValue)
- self.languageRadioManager:setCallback(function ( value )
- saveUserInfo("hongzhong_mj_sound", value)
- self:setYuColor(value)
- MJSound.setSoundType(value)
- end)
- end
-
-
- --麻将子颜色
- local hongzhong_mj_color = loadUserInfo("hongzhong_mj_color") or MJDefine.DesktopType.TwoD
- if hongzhong_mj_color == "" then
- hongzhong_mj_color = MJDefine.DesktopType.TwoD
- end
-
- if self.mjcolorRadioManager then
- self.mjcolorRadioManager:addItem(self.ui.Items.CheckBox_jinghuang_2d,MJDefine.DesktopType.TwoDGold)
- self.mjcolorRadioManager:addItem(self.ui.Items.CheckBox_molv_2d,MJDefine.DesktopType.TwoD)
- self.mjcolorRadioManager:addItem(self.ui.Items.CheckBox_molv_3d,MJDefine.DesktopType.ThreeD)
-
-
- self.mjcolorRadioManager:setDefault(hongzhong_mj_color)
- self.mjcolorRadioManager:setCallback(function(value)
- app:dispatchEvent({name = MJDefine.MJEvent.ChangeViewType,desktopType = value})
- saveUserInfo("hongzhong_mj_color",value)
- --showTooltip("设置将在下一局生效!")
- end)
- end
-
- if self.desktopRadioManager then
- self.desktopRadioManager:addItem(self.ui.Items.CheckBox_desktop_1, 1)
- self.desktopRadioManager:addItem(self.ui.Items.CheckBox_desktop_2, 2)
- self.desktopRadioManager:addItem(self.ui.Items.CheckBox_desktop_3, 3)
- local defaultValue = tonumber(loadUserInfo("hongzhong_mj_desktop_group")) or 1
- self.desktopRadioManager:setDefault(defaultValue)
- self:setZhuoColor(defaultValue)
- self.desktopRadioManager:setCallback(function ( value )
- saveUserInfo("hongzhong_mj_desktop_group", value)
- self:setZhuoColor(value)
- app:dispatchEvent({name = MJDefine.MJEvent.ChangeTableBg})
- --showTooltip("设置将在下一局生效!")
- end)
- end
-
- self.ui.Items.ImageView_BG:setTouchEnabled(true)
- -- 关闭
- self.ui.Items.Button_guanbi:registerClick(handler(self , self.onClickClose))
-
- -- 音乐
- self.ui.Items.CheckBox_Music:addEventListener(handler(self , self.onClickYinYue))
- self.ui.Items.CheckBox_Music:setSelectedState(app.systemSetting.info.music);
-
- --音乐音量
- self.ui.Items.Slider_Music:setPercent(app.systemSetting.info.musicVolume * 100 or 100)
- self.ui.Items.Slider_Music:addEventListener(handler(self, self.onMusicVolumeClickSlider))
-
- -- 音效
- self.ui.Items.CheckBox_Effect:addEventListener(handler(self , self.onClickYinXiao))
- self.ui.Items.CheckBox_Effect:setSelectedState(app.systemSetting.info.sound);
- --音效音量
-
- self.ui.Items.Slider_Effect:setPercent(app.systemSetting.info.soundVolume * 100 or 100)
- self.ui.Items.Slider_Effect:addEventListener(handler(self, self.onSoundVolumeClickSlider))
-
- --2D
- local function listener2D()
- if self.isFobidChangeDesktop then
- showTooltip("操作太频繁,请稍候再试!")
- self.ui.Items.CheckBox_2D:setSelectedState(false)
- return
- end
- self.ui.Items.CheckBox_3D:setSelectedState(false)
- self.ui.Items.CheckBox_3D:setTouchEnabled(true)
- self.ui.Items.CheckBox_2D:setTouchEnabled(false)
- self.ui.Items.CheckBox_2D:setSelectedState(true)
- app.systemSetting.info.viewType=MJDefine.DesktopType.TwoD
- app.systemSetting:save()
- self:setZhuoBuText(2)
- self:setLanColor(2)
- app:dispatchEvent({name = MJDefine.MJEvent.ChangeViewType,desktopType = MJDefine.DesktopType.TwoD})
- --showTooltip("设置将在下一局生效!")
-
- saveUserInfo("hongzhong_mj_color", MJDefine.DesktopType.TwoD)
- --2d可以选择麻将颜色
- self.ui.Items.Layout_color_2:setVisible(true)
- self.ui.Items.Layout_color_3:setVisible(false)
- self.mjcolorRadioManager:setDefault(MJDefine.DesktopType.TwoD)
-
- self.isFobidChangeDesktop = true
- self:runDelay(1.0, function ()
- self.isFobidChangeDesktop = false
- end)
- end
- self.ui.Items.CheckBox_2D:addEventListener(listener2D)
- --self.ui.Items.ImageView_img2d:setTouchEnabled(true)
- --self.ui.Items.ImageView_img2d:registerClick(listener2D)
- --3D
- local function listener3D()
- if self.isFobidChangeDesktop then
- showTooltip("操作太频繁,请稍候再试!")
- self.ui.Items.CheckBox_3D:setSelectedState(false)
- return
- end
- self.ui.Items.CheckBox_3D:setSelectedState(true)
- self.ui.Items.CheckBox_3D:setTouchEnabled(false)
- self.ui.Items.CheckBox_2D:setTouchEnabled(true)
- self.ui.Items.CheckBox_2D:setSelectedState(false)
- app.systemSetting.info.viewType=MJDefine.DesktopType.ThreeD
- app.systemSetting:save()
- self:setZhuoBuText(3)
- self:setLanColor(3)
- app:dispatchEvent({name = MJDefine.MJEvent.ChangeViewType,desktopType = MJDefine.DesktopType.ThreeD})
- --showTooltip("设置将在下一局生效!")
-
- --3d不可以选择麻将颜色
- self.ui.Items.Layout_color_2:setVisible(false)
- self.ui.Items.Layout_color_3:setVisible(true)
- self.mjcolorRadioManager:setDefault(MJDefine.DesktopType.ThreeD)
- self.isFobidChangeDesktop = true
- self:runDelay(1.0, function ()
- self.isFobidChangeDesktop = false
- end)
- end
- self.ui.Items.CheckBox_3D:addEventListener(listener3D)
- --self.ui.Items.ImageView_img3d:setTouchEnabled(true)
- --self.ui.Items.ImageView_img3d:registerClick(listener3D)
-
-
- --互动表情
- local faceKG = tonumber(loadUserInfo("propEnable")) or 1--0关 1开 hongzhongHuDongBiaoQingKG
- self.ui.Items.Button_face_guan:setVisible(faceKG==0)
- self.ui.Items.Button_face_kai:setVisible(faceKG==1)
- self.ui.Items.Button_face_guan:registerClick(handler(self , self.setHuDongBiaoQingClose))
- self.ui.Items.Button_face_kai:registerClick(handler(self , self.setHuDongBiaoQingOpen))
- --屏蔽语音
- local voiceKG = tonumber(loadUserInfo("voiceEnable")) or 1--0关 1开 hongzhongPingBiYuYinKG
- self.ui.Items.Button_voice_guan:setVisible(voiceKG==0)
- self.ui.Items.Button_voice_kai:setVisible(voiceKG==1)
- self.ui.Items.Button_voice_guan:registerClick(handler(self , self.setPingBiYuYinClose))
- self.ui.Items.Button_voice_kai:registerClick(handler(self , self.setPingBiYuYinOpen))
-
- if hongzhong_mj_color==MJDefine.DesktopType.ThreeD then
- self.ui.Items.CheckBox_3D:setSelectedState(true)
- self.ui.Items.CheckBox_3D:setTouchEnabled(false)
- self.ui.Items.CheckBox_2D:setTouchEnabled(true)
- self.ui.Items.CheckBox_2D:setSelectedState(false)
- self:setZhuoBuText(3)
- self:setLanColor(3)
- self.ui.Items.Layout_color_2:setVisible(false)
- self.ui.Items.Layout_color_3:setVisible(true)
- else
- self.ui.Items.CheckBox_3D:setSelectedState(false)
- self.ui.Items.CheckBox_3D:setTouchEnabled(true)
- self.ui.Items.CheckBox_2D:setTouchEnabled(false)
- self.ui.Items.CheckBox_2D:setSelectedState(true)
- self:setZhuoBuText(2)
- self:setLanColor(2)
- self.ui.Items.Layout_color_2:setVisible(true)
- self.ui.Items.Layout_color_3:setVisible(false)
- end
-
- self.ui.Items.Layout_Prop:setVisible(not MJFunction.isPropFobided())
- self.ui.Items.Layout_Voice:setVisible(not MJFunction.isVoiceFobided())
-
- end
-
- function hongzhongRoomSettingView:setZhuoBuText(zbType)--根据2d 3d设置桌布text 默认用红色2D 音效默认普通话
- if zbType == 2 then
- self.ui.Items.Text_16:setText("红色")
- self.ui.Items.Text_17:setText("绿色")
- self.ui.Items.Text_18:setText("蓝色")
- saveUserInfo("hongzhong_ZhuoMian_BG_Type", MJDefine.DesktopType.TwoD)
- else
- self.ui.Items.Text_16:setText("绿色")
- self.ui.Items.Text_17:setText("墨绿")
- self.ui.Items.Text_18:setText("经典")
- saveUserInfo("hongzhong_ZhuoMian_BG_Type", MJDefine.DesktopType.ThreeD)
- end
- end
-
- --选择23D时,字体变颜色
- function hongzhongRoomSettingView:setLanColor(ttype)
- --self.ui.Items.Text_2D:setColor(ttype == 2 and CheckBox_Sel_Color or CheckBox_Nor_Color)
- --self.ui.Items.Text_2D_1:setColor(ttype == 3 and CheckBox_Sel_Color or CheckBox_Nor_Color)
- end
-
- --选择语言时,字体变颜色
- function hongzhongRoomSettingView:setYuColor(ttype)
- self.ui.Items.Text_13:setColor(ttype == 1 and CheckBox_Sel_Color or CheckBox_Nor_Color)--普通话
- self.ui.Items.Text_12:setColor(ttype == 2 and CheckBox_Sel_Color or CheckBox_Nor_Color)--长沙话
- end
-
- --选择桌布时,字体变颜色
- function hongzhongRoomSettingView:setZhuoColor(ttype)
- self.ui.Items.Text_16:setColor(ttype == 1 and CheckBox_Sel_Color or CheckBox_Nor_Color)--颜色1
- self.ui.Items.Text_17:setColor(ttype == 2 and CheckBox_Sel_Color or CheckBox_Nor_Color)--颜色2
- self.ui.Items.Text_18:setColor(ttype == 3 and CheckBox_Sel_Color or CheckBox_Nor_Color)--颜色3
- end
-
- function hongzhongRoomSettingView:setHuDongBiaoQingClose()
- self.ui.Items.Button_face_guan:setVisible(false)
- self.ui.Items.Button_face_kai:setVisible(true)
- saveUserInfo("hongzhongHuDongBiaoQingKG",1)
- app.room:dispatchEvent({name = "ontSetPropEnabled", value = 1});
-
- if self.onClickProp then
- self:onClickProp()
- end
- end
-
- function hongzhongRoomSettingView:setHuDongBiaoQingOpen()
- self.ui.Items.Button_face_guan:setVisible(true)
- self.ui.Items.Button_face_kai:setVisible(false)
- saveUserInfo("hongzhongHuDongBiaoQingKG",0)
- app.room:dispatchEvent({name = "ontSetPropEnabled", value = 0});
-
- if self.onClickProp then
- self:onClickProp()
- end
- end
-
- function hongzhongRoomSettingView:setPingBiYuYinClose()
- self.ui.Items.Button_voice_guan:setVisible(false)
- self.ui.Items.Button_voice_kai:setVisible(true)
- saveUserInfo("hongzhongPingBiYuYinKG",1)
- app.room:dispatchEvent({name = "onSetVoiceEnabled", value = 1});
-
- if self.onClickVoice then
- self:onClickVoice()
- end
- end
-
- function hongzhongRoomSettingView:setPingBiYuYinOpen()
- self.ui.Items.Button_voice_guan:setVisible(true)
- self.ui.Items.Button_voice_kai:setVisible(false)
- saveUserInfo("hongzhongPingBiYuYinKG",0)
- app.room:dispatchEvent({name = "onSetVoiceEnabled", value = 0});
-
- if self.onClickVoice then
- self:onClickVoice()
- end
- end
- -- 音乐
- function hongzhongRoomSettingView:onClickYinYue()
- app.systemSetting.info.music = self.ui.Items.CheckBox_Music:getSelectedState();
- app.systemSetting:save()
- end
-
- -- 音效
- function hongzhongRoomSettingView:onClickYinXiao()
- app.systemSetting.info.sound = self.ui.Items.CheckBox_Effect:getSelectedState();
- app.systemSetting:save()
- end
-
- -- 音乐音量设置回调
- function hongzhongRoomSettingView:onMusicVolumeClickSlider()
- local percent = self.ui.Items.Slider_Music:getPercent();
- local curValue = percent / 100;
- app.systemSetting.info.musicVolume = curValue;
- app.systemSetting:save()
- end
-
- -- 音效音量设置回调
- function hongzhongRoomSettingView:onSoundVolumeClickSlider()
- local percent = self.ui.Items.Slider_Effect:getPercent();
- local curValue = percent / 100;
- app.systemSetting.info.soundVolume = curValue;
- app.systemSetting:save()
- end
- return hongzhongRoomSettingView
|