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.

128 lines
3.7 KiB

  1. local MainViewGameGroupView = class("MainViewGameGroupView",cc.UIView)
  2. function MainViewGameGroupView:ctor(groupConfig)
  3. local ui = loadUI("res/ui/ui_dating/ui_dating_group_view.ui")
  4. self.ui = ui
  5. self:addChild(ui)
  6. self.groupConfig = groupConfig
  7. local pid = nil
  8. if app.php.mypropdata then
  9. for k,v in pairs(app.php.mypropdata) do
  10. if v.prop_id and v.prop_id >= 200 and v.prop_id < 300 then
  11. pid = v.prop_id
  12. end
  13. end
  14. end
  15. if pid then
  16. self.ui.Items.ImageView_1:loadTexture(string.format("res/ui/zy_dating/dating/dating_mohu_di_%d.jpg",pid))
  17. end
  18. if groupConfig.webgame then
  19. self:initWebGame()
  20. else
  21. self:init()
  22. end
  23. end
  24. function MainViewGameGroupView:init()
  25. self.ui.Items.ScrollView:hideAllBar()
  26. self.ui.Items.Text_GropName:setText(self.groupConfig.name or "")
  27. for k,gameId in pairs(self.groupConfig.games) do
  28. local item = self.ui.Items.Layout_Item:getCopied()
  29. local uiSubGame = import("luaScript.Views.Main.MainViewGameIcon"):new(gameId)
  30. local width = item:getContentSize().width - uiSubGame.ui:getContentSize().width
  31. uiSubGame.ui:setPositionX(width/2)
  32. item:addChild(uiSubGame.ui)
  33. self.ui.Items.Layout_Content:addChild(item)
  34. end
  35. end
  36. function MainViewGameGroupView:initWebGame()
  37. self.ui.Items.ScrollView:hideAllBar()
  38. self.ui.Items.Text_GropName:setText(self.groupConfig.name or "")
  39. --[[for k,gameId in pairs(self.groupConfig.games) do
  40. local item = self.ui.Items.Layout_Item:getCopied()
  41. local uiSubGame = import("luaScript.Views.Main.MainViewGameIcon"):new(gameId)
  42. local width = item:getContentSize().width - uiSubGame.ui:getContentSize().width
  43. uiSubGame.ui:setPositionX(width/2)
  44. item:addChild(uiSubGame.ui)
  45. self.ui.Items.Layout_Content:addChild(item)
  46. end--]]
  47. for k,gameId in pairs(self.groupConfig.games) do
  48. local webGame = app.serverConfigs:getWebGameConfig(gameId)
  49. local item = self.ui.Items.Layout_Item:getCopied()
  50. local gameLayout = cc.Layout:create()
  51. gameLayout:setSize(cc.size(152,188))
  52. local webGameIcon = cc.ImageView:create()
  53. webGameIcon:setAutoSize(false)
  54. webGameIcon:setSize(cc.size(134,156))
  55. setImageFromUrl(webGameIcon,webGame.icon)
  56. webGameIcon:registerClick(function()
  57. playBtnEffect()
  58. if not app.serverConfigs:isOpenWebGame(webGame.gameId) then
  59. showTooltip("敬请期待!")
  60. return
  61. end
  62. webGameIcon:setTouchEnabled(false)
  63. app.serverConfigs:requestWebGameUrl(webGame.gameId,function (url, orientation)
  64. if webGameIcon and not tolua.isnull(webGameIcon) then
  65. webGameIcon:setTouchEnabled(true)
  66. if not url or url =="" then
  67. showTooltip("敬请期待!")
  68. return
  69. end
  70. local function openWebGame ()
  71. local view = import("luaScript.Views.Main.WebViews.WebGameView"):new(webGame.gameId,url, orientation)
  72. view:setAnchorPoint(cc.p(0.5, 0.5))
  73. app:showWaitDialog(view,nil,true)
  74. self:removeFromParent()
  75. end
  76. if webGame.gameId == 10006 then
  77. local str = "根据剑荡江湖运营合作计划,公司将于3月10日停服,届时游戏将无法登录。给您带了的不便,深表歉意。点击确定继续游戏。";
  78. showConfirmDialog(str, function ()
  79. openWebGame()
  80. end)
  81. else
  82. openWebGame()
  83. end
  84. end
  85. end)
  86. end)
  87. if app.serverConfigs:isNewWebGame(webGame.gameId) then
  88. local newIcon = cc.ImageView:create()
  89. newIcon:loadTexture("res/ui/zy_dating/dating/img_newTag.png")
  90. webGameIcon:addChild(newIcon)
  91. newIcon:setPosition(cc.p(40,125))
  92. end
  93. local size = gameLayout:getContentSize()
  94. webGameIcon:setPosition(cc.p(size.width/2,size.height/2))
  95. gameLayout:addChild(webGameIcon)
  96. item:addChild(gameLayout)
  97. self.ui.Items.Layout_Content:addChild(item)
  98. end
  99. end
  100. return MainViewGameGroupView