Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

205 řádky
7.8 KiB

  1. -- 房间设置界面
  2. local RoomSettingView = class("RoomSettingView_53", cc.UIView)
  3. local Functions = require("pk_nanchongdoudizhu.luaScript.Functions_53")
  4. local defs = require("pk_nanchongdoudizhu.luaScript.Def_53")
  5. function RoomSettingView:ctor()
  6. RoomSettingView.super.ctor(self)
  7. self.desktopRadioManager = import("luaScript.Tools.RadioManager"):new()
  8. end
  9. local CheckBox_Nor_Color = cc.c3b(21,99,97)
  10. local CheckBox_Sel_Color = cc.c3b(213,46,11)
  11. function RoomSettingView:onEnter()
  12. RoomSettingView.super.onEnter(self)
  13. local ui = loadUI("pk_nanchongdoudizhu/res/ui/ui_fangjian/doudizhu_ui_setting.ui")
  14. self:addChild(ui)
  15. self.ui = ui
  16. -- 关闭
  17. self.ui.Items.Button_guanbi:registerClick(handler(self , self.onClickClose))
  18. --音乐
  19. self.ui.Items.CheckBox_Music:addEventListener(handler(self , self.onClickYinYue))
  20. self.ui.Items.CheckBox_Music:setSelectedState(app.systemSetting.info.music)
  21. -- 音效
  22. self.ui.Items.CheckBox_Effect:addEventListener(handler(self , self.onClickYinXiao))
  23. self.ui.Items.CheckBox_Effect:setSelectedState(app.systemSetting.info.sound)
  24. --音乐音量
  25. self.ui.Items.SliderMusic:setPercent(app.systemSetting.info.musicVolume * 100 or 100)
  26. self.ui.Items.SliderMusic:addEventListener(handler(self, self.onMusicVolumeClickSlider))
  27. --音效音量
  28. self.ui.Items.SliderEffect:setPercent(app.systemSetting.info.soundVolume * 100 or 100)
  29. self.ui.Items.SliderEffect:addEventListener(handler(self, self.onSoundVolumeClickSlider))
  30. --互动表情
  31. local faceKG = tonumber(loadUserInfo("HuDongBiaoQingKG" .. app.gameId)) or 1--0关 1开
  32. self.ui.Items.Button_face_guan:setVisible(faceKG == 0)
  33. self.ui.Items.Button_face_kai:setVisible(faceKG == 1)
  34. self.ui.Items.Button_face_guan:registerClick(handler(self , self.setHuDongBiaoQingClose))
  35. self.ui.Items.Button_face_kai:registerClick(handler(self , self.setHuDongBiaoQingOpen))
  36. --屏蔽语音
  37. local voiceKG = tonumber(loadUserInfo("PingBiYuYinKG" .. app.gameId)) or 1--0关 1开
  38. self.ui.Items.Button_voice_guan:setVisible(voiceKG == 0)
  39. self.ui.Items.Button_voice_kai:setVisible(voiceKG == 1)
  40. self.ui.Items.Button_voice_guan:registerClick(handler(self , self.setPingBiYuYinClose))
  41. self.ui.Items.Button_voice_kai:registerClick(handler(self , self.setPingBiYuYinOpen))
  42. -- 背景音乐选择
  43. self.bgmChooseRadioManager = import("luaScript.Tools.RadioManager"):new()
  44. self.bgmChooseRadioManager:addItem(self.ui.Items.CheckBox_Bgm_HuanKuai, defs.BGM_CHOOSE_TYPE.HUAN_KUAI)
  45. self.bgmChooseRadioManager:addItem(self.ui.Items.CheckBox_Bgm_JingDian, defs.BGM_CHOOSE_TYPE.JING_DIAN)
  46. local bgmChooseType = tonumber(loadUserInfo("BgmChooseType" .. app.gameId)) or defs.BGM_CHOOSE_TYPE.JING_DIAN
  47. self.bgmChooseRadioManager:setDefault(bgmChooseType)
  48. self:setYuColor(bgmChooseType)
  49. local function callback(idx)
  50. saveUserInfo("BgmChooseType" .. app.gameId, idx)
  51. self:setYuColor(idx)
  52. app:dispatchEvent({name = "onChangeBgm", idx = idx})
  53. end
  54. self.bgmChooseRadioManager:setCallback(callback)
  55. if self.desktopRadioManager then
  56. self.desktopRadioManager:addItem(self.ui.Items.CheckBox_zm_bg_1, 1)
  57. self.desktopRadioManager:addItem(self.ui.Items.CheckBox_zm_bg_2, 2)
  58. self.desktopRadioManager:addItem(self.ui.Items.CheckBox_zm_bg_3, 3)
  59. self.desktopRadioManager:addItem(self.ui.Items.CheckBox_zm_bg_4, 4)
  60. local defaultValue = Functions.getDefaultBg()
  61. self.desktopRadioManager:setDefault(defaultValue)
  62. self:setZhuoColor(defaultValue)
  63. self.desktopRadioManager:setCallback(function (value)
  64. self:setZhuoColor(value)
  65. saveUserInfo("GameBgPicture" .. app.gameId, value)
  66. --更换背景
  67. app:dispatchEvent({name = "onChangeTable", idx = value})
  68. end)
  69. end
  70. -- 扑克牌
  71. self.pokerRadioManager = import("luaScript.Tools.RadioManager"):new()
  72. local defaultPokerValue = tonumber(loadUserInfo("ddz_setting_poker")) or defs.Default_Poker_Choose
  73. if self.pokerRadioManager then
  74. self.pokerRadioManager:addItem(self.ui.Items.CheckBox_Poker_Old, 1)
  75. self.pokerRadioManager:addItem(self.ui.Items.CheckBox_Poker_New, 2)
  76. self.pokerRadioManager:setDefault(defaultPokerValue)
  77. self.pokerRadioManager:setCallback(function(value)
  78. saveUserInfo("ddz_setting_poker",value)
  79. app.room:dispatchEvent({name = "ddzNormalEvent_changePoker", idx = value})
  80. end)
  81. end
  82. self.ui.Items.Layout_face:setVisible(not Functions.isForbidProp())
  83. -- self.ui.Items.Layout_voice:setVisible(not Functions.isForbidProp())
  84. self.ui.Items.Layout_voice:setVisible(not Functions.isForbidVoice())
  85. -- 调整界面
  86. if Functions.getRuleIncludeNotChatPlayWanFa() then
  87. self.ui.Items.Layout_face:setVisible(false)
  88. self.ui.Items.Layout_voice:setVisible(false)
  89. self.ui.Items.ImageView_line_4:setVisible(false)
  90. self.ui.Items.Layout_Bg_Poker:setPositionY(self.ui.Items.Layout_Bg_Poker:getPositionY() + 95)
  91. end
  92. end
  93. -- 关闭
  94. function RoomSettingView:onClickClose()
  95. playBtnEffect()
  96. self:removeFromParent()
  97. end
  98. -- 音乐
  99. function RoomSettingView:onClickYinYue()
  100. app.systemSetting.info.music = self.ui.Items.CheckBox_Music:getSelectedState()
  101. app.systemSetting:save()
  102. end
  103. -- 音效
  104. function RoomSettingView:onClickYinXiao()
  105. app.systemSetting.info.sound = self.ui.Items.CheckBox_Effect:getSelectedState()
  106. app.systemSetting:save()
  107. end
  108. --选择桌布背景
  109. function RoomSettingView:selectBgCallBack(idx)
  110. saveUserInfo("GameBgPicture" .. app.gameId,idx)
  111. --更换牌背
  112. app:dispatchEvent({name = "onChangeTable", idx = idx})
  113. end
  114. -- 音乐音量设置回调
  115. function RoomSettingView:onMusicVolumeClickSlider()
  116. local percent = self.ui.Items.SliderMusic:getPercent()
  117. local curValue = percent / 100
  118. app.systemSetting.info.musicVolume = curValue
  119. app.systemSetting:save()
  120. end
  121. -- 音效音量设置回调
  122. function RoomSettingView:onSoundVolumeClickSlider()
  123. local percent = self.ui.Items.SliderEffect:getPercent()
  124. local curValue = percent / 100
  125. app.systemSetting.info.soundVolume = curValue
  126. app.systemSetting:save()
  127. end
  128. --选择语言时,字体变颜色
  129. function RoomSettingView:setYuColor(ttype)
  130. self.ui.Items.Text_Bgm_HuanKuai:setColor(ttype == defs.BGM_CHOOSE_TYPE.HUAN_KUAI and CheckBox_Sel_Color or CheckBox_Nor_Color)
  131. self.ui.Items.Text_Bgm_JingDian:setColor(ttype == defs.BGM_CHOOSE_TYPE.PU_TONG_HUJING_DIANA and CheckBox_Sel_Color or CheckBox_Nor_Color)
  132. end
  133. --选择桌布时,字体变颜色
  134. function RoomSettingView:setZhuoColor(ttype)
  135. self.ui.Items.Text_zm_bg_1:setColor(ttype == 1 and CheckBox_Sel_Color or CheckBox_Nor_Color)--颜色1
  136. self.ui.Items.Text_zm_bg_2:setColor(ttype == 2 and CheckBox_Sel_Color or CheckBox_Nor_Color)--颜色2
  137. self.ui.Items.Text_zm_bg_3:setColor(ttype == 3 and CheckBox_Sel_Color or CheckBox_Nor_Color)--颜色3
  138. self.ui.Items.Text_zm_bg_4:setColor(ttype == 4 and CheckBox_Sel_Color or CheckBox_Nor_Color)--颜色4
  139. end
  140. --互动表情开
  141. function RoomSettingView:setHuDongBiaoQingOpen()
  142. self.ui.Items.Button_face_guan:setVisible(true)
  143. self.ui.Items.Button_face_kai:setVisible(false)
  144. saveUserInfo("HuDongBiaoQingKG" .. app.gameId, 0)
  145. app.room:dispatchEvent({name = "ontSetPropEnabled", value = 0})
  146. end
  147. --互动表情关
  148. function RoomSettingView:setHuDongBiaoQingClose()
  149. self.ui.Items.Button_face_guan:setVisible(false)
  150. self.ui.Items.Button_face_kai:setVisible(true)
  151. saveUserInfo("HuDongBiaoQingKG" .. app.gameId, 1)
  152. app.room:dispatchEvent({name = "ontSetPropEnabled", value = 1})
  153. end
  154. --屏蔽语音开
  155. function RoomSettingView:setPingBiYuYinOpen()
  156. self.ui.Items.Button_voice_guan:setVisible(true)
  157. self.ui.Items.Button_voice_kai:setVisible(false)
  158. saveUserInfo("PingBiYuYinKG" .. app.gameId, 0)
  159. app.room:dispatchEvent({name = "onSetVoiceEnabled", value = 0})
  160. end
  161. --屏蔽语音关
  162. function RoomSettingView:setPingBiYuYinClose()
  163. self.ui.Items.Button_voice_guan:setVisible(false)
  164. self.ui.Items.Button_voice_kai:setVisible(true)
  165. saveUserInfo("PingBiYuYinKG" .. app.gameId, 1)
  166. app.room:dispatchEvent({name = "onSetVoiceEnabled", value = 1})
  167. end
  168. return RoomSettingView