You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

331 lines
9.4 KiB

  1. local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
  2. local ZPFunctions = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions")
  3. local ZPWanFa=ZPFramework.ImportWanFa("luaScript.SubGameDefine.ZiPai.ZPWanFa")
  4. local ZPRoomToolView = class("ZPRoomToolView", cc.UIView)
  5. function ZPRoomToolView:ctor()
  6. ZPRoomToolView.super.ctor(self);
  7. --是否是该场景点了准备
  8. self.isTouchCurScene = false
  9. end
  10. function ZPRoomToolView:loadUi()
  11. local ui = loadUI("zp_base/res/ui/ui_fangjian/zipai_ui_Tool.ui");
  12. self.ui = ui;
  13. self:addChild(ui);
  14. end
  15. function ZPRoomToolView:onEnter()
  16. ZPRoomToolView.super.onEnter(self)
  17. self:loadUi()
  18. --测试开关
  19. self.ui.Items.Layout_Test:setVisible(false)
  20. --播放队列
  21. self.ui.Items.Button_Play:registerClick(function ()
  22. app.net:onMsgResume()
  23. end)
  24. --停止队列
  25. self.ui.Items.Button_Stop:registerClick(function ()
  26. app.net:onMsgPause()
  27. end)
  28. -- 复制功能
  29. self.ui.Items.btnCopy:registerClick(function ()
  30. --playBtnEffect()
  31. self:onClickFriends(true)
  32. end)
  33. -- --上传日记
  34. -- local day = os.date("%Y-%m-%d")
  35. -- local key = string.format("dingdinglog-%s",day)
  36. -- local isShow = cc.UserDefault:getInstance():getBoolForKey(key,false)
  37. -- if isShow or isReviewVersion() then
  38. -- self.ui.Items.Button_updateLog:setVisible(false)
  39. -- end
  40. -- if isDebug() or cc.Application:getInstance():getTargetPlatform() == 0 then
  41. -- self.ui.Items.Button_updateLog:setVisible(true)
  42. -- end
  43. -- self.ui.Items.Button_updateLog:registerClick(handler(self , self.onClickLog))
  44. -- 邀请微信好友
  45. self.ui.Items.btnInvite:registerClick(handler(self , self.onClickFriends))
  46. -- 准备按钮
  47. self.ui.Items.Button_Ready:registerClick(handler(self , self.onClickReady))
  48. -- 详情
  49. self.ui.Items.Button_ruleIntro:registerClick(handler(self , self.onClickRule))
  50. self.ui.Items.Button_ruleIntro:setVisible(false)
  51. --邀请俱乐部成员
  52. self.ui.Items.Button_Invite_Club:registerClick(handler(self , self.onClickInviteClub))
  53. -- 快速开始
  54. self.ui.Items.Button_EarlyStart:registerClick(handler(self , self.onClickQuickStart))
  55. self.ui.Items.Button_EarlyStart:setVisible(false)
  56. if self.ui.Items.Button_club then
  57. self.ui.Items.Button_club:setVisible(false)
  58. end
  59. if isReviewVersion() then
  60. self.ui.Items.btnInvite:setVisible(false)
  61. self.ui.Items.Button_Invite_Club:setVisible(false)
  62. end
  63. self:initButtonFace()
  64. self:initButtonVoice()
  65. end
  66. function ZPRoomToolView:hideOther()
  67. -- 通知游戏场景关掉一些界面
  68. if app and app.room then
  69. app.room:dispatchEvent({name = "onHideOther"});
  70. end
  71. end
  72. function ZPRoomToolView:onClickReady()
  73. self.ui:sendMsg(app.room, "callReadyRequest");
  74. playVoice("res/sound/room/sit.ogg")
  75. self.isTouchCurScene = true
  76. end
  77. -- 聊天界面
  78. function ZPRoomToolView:onClickChat()
  79. playBtnEffect()
  80. local view = import("zp_base.luaScript.Views.Room.ZPRoomSettingView"):new();
  81. view:setAnchorPoint(cc.p(0.5, 0.5));
  82. app:showWaitDialog(view);
  83. end
  84. --点击玩法
  85. function ZPRoomToolView:onClickLog()
  86. print("=========================DingDingLog===============================")
  87. local uiTechnialView
  88. uiTechnialView = import("luaScript.Views.Room.UplogView"):new()
  89. self:addChild(uiTechnialView)
  90. end
  91. -- 邀请好友
  92. function ZPRoomToolView:onClickFriends(iscopy)--是否是复制功能
  93. local roomInfo = app.room.roomInfo;
  94. local tt =
  95. {
  96. [0] = "零缺三",
  97. [1] = "一缺二",
  98. [2] = "二缺一",
  99. [3] = "满座",
  100. }
  101. local tt2 =
  102. {
  103. [0] = "零缺二",
  104. [1] = "一缺一",
  105. [2] = "满座",
  106. }
  107. local tt3 =
  108. {
  109. [0] = "零缺四",
  110. [1] = "一缺三",
  111. [2] = "二缺二",
  112. [3] = "三缺一",
  113. [4] = "满座",
  114. }
  115. local jsonInfo = json.decode(roomInfo.strGameInfo)
  116. local num = table.nums(app.room.roomInfo.memberList)
  117. local strNum = tt[num]
  118. if tonumber(jsonInfo.playnum) == 2 then
  119. strNum = tt2[num]
  120. elseif tonumber(jsonInfo.playnum) == 4 or tonumber(jsonInfo.playnum) == -1 then
  121. strNum = tt3[num]
  122. end
  123. --局数
  124. local strGameNum = string.format("%s局", app.room.roomInfo.nTotalGameNum)
  125. local title = string.format("%s 房号[%s] %s %s" , ZPDef.GameName,app.room.roomInfo.nShowTableId,strNum,strGameNum)
  126. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  127. title = string.format("%s %sID[%d]", title,(app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME), tonumber(app.club_php.clubID))
  128. end
  129. local strGameMode = ZPWanFa.getRuleInfo(app.room.roomInfo.strGameInfo)
  130. local strNames = ""
  131. local index = 0
  132. for k,v in pairs(app.room.roomInfo.memberList) do
  133. index = index + 1
  134. local userInfo = json.decode(v.userInfo)
  135. local name = getSubStringNickname(userInfo.nickname)
  136. strNames = strNames..name
  137. if index < num then
  138. strNames = strNames..","
  139. end
  140. end
  141. local desc = string.format("%s \n玩家:%s", strGameMode, strNames)
  142. print(desc)
  143. local info = {}
  144. info.title = title
  145. info.description = desc
  146. info.copyData={type=2}
  147. local view = import("luaScript.Views.Main.ShareView"):new(info)
  148. view:setAnchorPoint(cc.p(0.5, 0.5))
  149. app:showWaitDialog(view)
  150. if iscopy and true == iscopy then
  151. view:onClickCopy()
  152. else
  153. playBtnEffect()
  154. end
  155. end
  156. function ZPRoomToolView:onClickRule()
  157. self.ui.Items.ImageView_Rule_bg:setVisible(not self.ui.Items.ImageView_Rule_bg:isVisible())
  158. end
  159. function ZPRoomToolView:showFastStart(is)
  160. local roomInfo = app.room.roomInfo
  161. local curCount = roomInfo.nGameStartCount or 0
  162. if curCount > 0 or (roomInfo.nStatus and roomInfo.nStatus>=ZPDef.ReconnectState.GAME_STATUS_WAIT_OUT_CARDS and roomInfo.nStatus<=ZPDef.ReconnectState.GAME_STATUS_GAME_OVER) then
  163. self.ui.Items.Button_EarlyStart:setVisible(false)
  164. else
  165. local gameInfo=json.decode(roomInfo.strGameInfo)
  166. local playnum = gameInfo.playnum or 0
  167. if playnum == -1 then
  168. playnum = 4
  169. end
  170. local isShowEarlyStart = table.nums(app.room.roomInfo.memberList) < playnum and table.nums(app.room.roomInfo.memberList) > 1
  171. if true == is and isShowEarlyStart and curCount<=0 then
  172. self.ui.Items.Button_EarlyStart:setVisible(true)
  173. else
  174. self.ui.Items.Button_EarlyStart:setVisible(false)
  175. end
  176. if gameInfo.startMode and gameInfo.startMode == 0 then--不是快速组局
  177. self.ui.Items.Button_EarlyStart:setVisible(false)
  178. end
  179. end
  180. end
  181. function ZPRoomToolView:onClickQuickStart()
  182. playBtnEffect()
  183. app.room:requestQuickStart(1)
  184. end
  185. function ZPRoomToolView:onClickInviteClub()
  186. playBtnEffect()
  187. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  188. local roomInfo = app.room.roomInfo;
  189. local strInvite = ZPFunctions.getClubInviteWanFa(roomInfo.gameId or app.gameId, roomInfo)
  190. local view = import("luaScript.Views.Club.ClubInvite"):new(roomInfo.nShowTableId, strInvite)
  191. view:setAnchorPoint(cc.p(0.5, 0.5))
  192. app:showWaitDialog(view)
  193. end
  194. end
  195. --设置邀请茶馆成员显示
  196. function ZPRoomToolView:setInviteClubVisible(bVisible)
  197. if self.ui.Items.Button_Invite_Club then
  198. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  199. self.ui.Items.Button_Invite_Club:setVisible(bVisible)
  200. else
  201. self.ui.Items.Button_Invite_Club:setVisible(false)
  202. end
  203. --self.ui.Items.Button_Invite_Club:setVisible(false)
  204. local roomInfo = app.room.roomInfo or {}
  205. local gameId = roomInfo.gameId or app.gameId
  206. local gameConfig = getSubGameConfig(gameId)
  207. if gameConfig.isOpenClubInvite == false then
  208. self.ui.Items.Button_Invite_Club:getParent():setVisible(false)
  209. end
  210. end
  211. end
  212. --按钮位置调整
  213. function ZPRoomToolView:updateButtonPosition()
  214. if not self.ui.Items.Layout_Button then return end
  215. if not self.ui.Items.Button_Invite_Club then return end
  216. self.ui.Items.Button_Ready:getParent():setVisible(self.ui.Items.Button_Ready:isVisible())
  217. self.ui.Items.btnInvite:getParent():setVisible(self.ui.Items.btnInvite:isVisible())
  218. if self.ui.Items.Button_Invite_Club then
  219. self.ui.Items.Button_Invite_Club:getParent():setVisible(self.ui.Items.Button_Invite_Club:isVisible())
  220. end
  221. local roomInfo = app.room.roomInfo or {}
  222. local gameId = roomInfo.gameId or app.gameId
  223. local gameConfig = getSubGameConfig(gameId)
  224. if gameConfig.isOpenClubInvite == false then
  225. self.ui.Items.Button_Invite_Club:getParent():setVisible(false)
  226. end
  227. if self.ui.Items.Layout_Button then
  228. self.ui.Items.Layout_Button:requestDoLayout()
  229. self.ui.Items.Layout_Button:doLayout()
  230. end
  231. end
  232. ---
  233. -- 初始化语音
  234. -- @return
  235. --
  236. function ZPRoomToolView:initButtonVoice ()
  237. if self.ui.Items.Button_Voice then
  238. self:initVoiceComponent()
  239. self.ui.Items.Button_Voice:setVisible(not ZPFunctions.isVoiceFobided())
  240. end
  241. end
  242. ---
  243. -- 初始化语音聊天功能
  244. -- @return
  245. --
  246. function ZPRoomToolView:initVoiceComponent()
  247. local voiceComponentView = import("luaScript.Views.Room.RoomVoiceComponentView"):new(self.ui.Items.Button_Voice)
  248. self:addChild(voiceComponentView)
  249. end
  250. ---
  251. -- 初始化聊天
  252. -- @return
  253. --
  254. function ZPRoomToolView:initButtonFace ()
  255. if self.ui.Items.Button_Face then
  256. self.ui.Items.Button_Face:registerClick(handler(self,self.onClickFace))
  257. self.ui.Items.Button_Face:setVisible(not ZPFunctions.isPropFobided())
  258. end
  259. end
  260. ---
  261. -- 聊天按钮点击事件
  262. -- @return
  263. --
  264. function ZPRoomToolView:onClickFace()
  265. local chatView = import("luaScript.Views.Room.RoomChatView"):new(ZPDef.ChatTxt or {}, nil)
  266. chatView:setAnchorPoint(cc.p(0.5, 0.5))
  267. app:showWaitDialog(chatView,0,true)
  268. end
  269. ---
  270. -- 隐藏语音按钮
  271. -- @return
  272. --
  273. function ZPRoomToolView:hideVoiceButton ()
  274. self.ui.Items.Button_Voice:setVisible(false)
  275. end
  276. ---
  277. -- 隐藏聊天按钮
  278. -- @return
  279. --
  280. function ZPRoomToolView:hideFaceButton ()
  281. self.ui.Items.Button_Face:setVisible(false)
  282. end
  283. return ZPRoomToolView;