local MainViewGameGroupView = class("MainViewGameGroupView",cc.UIView) function MainViewGameGroupView:ctor(groupConfig) local ui = loadUI("res/ui/ui_dating/ui_dating_group_view.ui") self.ui = ui self:addChild(ui) self.groupConfig = groupConfig local pid = nil if app.php.mypropdata then for k,v in pairs(app.php.mypropdata) do if v.prop_id and v.prop_id >= 200 and v.prop_id < 300 then pid = v.prop_id end end end if pid then self.ui.Items.ImageView_1:loadTexture(string.format("res/ui/zy_dating/dating/dating_mohu_di_%d.jpg",pid)) end if groupConfig.webgame then self:initWebGame() else self:init() end end function MainViewGameGroupView:init() self.ui.Items.ScrollView:hideAllBar() self.ui.Items.Text_GropName:setText(self.groupConfig.name or "") for k,gameId in pairs(self.groupConfig.games) do local item = self.ui.Items.Layout_Item:getCopied() local uiSubGame = import("luaScript.Views.Main.MainViewGameIcon"):new(gameId) local width = item:getContentSize().width - uiSubGame.ui:getContentSize().width uiSubGame.ui:setPositionX(width/2) item:addChild(uiSubGame.ui) self.ui.Items.Layout_Content:addChild(item) end end function MainViewGameGroupView:initWebGame() self.ui.Items.ScrollView:hideAllBar() self.ui.Items.Text_GropName:setText(self.groupConfig.name or "") --[[for k,gameId in pairs(self.groupConfig.games) do local item = self.ui.Items.Layout_Item:getCopied() local uiSubGame = import("luaScript.Views.Main.MainViewGameIcon"):new(gameId) local width = item:getContentSize().width - uiSubGame.ui:getContentSize().width uiSubGame.ui:setPositionX(width/2) item:addChild(uiSubGame.ui) self.ui.Items.Layout_Content:addChild(item) end--]] for k,gameId in pairs(self.groupConfig.games) do local webGame = app.serverConfigs:getWebGameConfig(gameId) local item = self.ui.Items.Layout_Item:getCopied() local gameLayout = cc.Layout:create() gameLayout:setSize(cc.size(152,188)) local webGameIcon = cc.ImageView:create() webGameIcon:setAutoSize(false) webGameIcon:setSize(cc.size(134,156)) setImageFromUrl(webGameIcon,webGame.icon) webGameIcon:registerClick(function() playBtnEffect() if not app.serverConfigs:isOpenWebGame(webGame.gameId) then showTooltip("敬请期待!") return end webGameIcon:setTouchEnabled(false) app.serverConfigs:requestWebGameUrl(webGame.gameId,function (url, orientation) if webGameIcon and not tolua.isnull(webGameIcon) then webGameIcon:setTouchEnabled(true) if not url or url =="" then showTooltip("敬请期待!") return end local function openWebGame () local view = import("luaScript.Views.Main.WebViews.WebGameView"):new(webGame.gameId,url, orientation) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view,nil,true) self:removeFromParent() end if webGame.gameId == 10006 then local str = "根据剑荡江湖运营合作计划,公司将于3月10日停服,届时游戏将无法登录。给您带了的不便,深表歉意。点击确定继续游戏。"; showConfirmDialog(str, function () openWebGame() end) else openWebGame() end end end) end) if app.serverConfigs:isNewWebGame(webGame.gameId) then local newIcon = cc.ImageView:create() newIcon:loadTexture("res/ui/zy_dating/dating/img_newTag.png") webGameIcon:addChild(newIcon) newIcon:setPosition(cc.p(40,125)) end local size = gameLayout:getContentSize() webGameIcon:setPosition(cc.p(size.width/2,size.height/2)) gameLayout:addChild(webGameIcon) item:addChild(gameLayout) self.ui.Items.Layout_Content:addChild(item) end end return MainViewGameGroupView