|
- local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
- local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
-
- local ncmajShowAllTingCardView = class("ncmajShowAllTingCardView", cc.UIView)
-
- function ncmajShowAllTingCardView:ctor()
- ncmajShowAllTingCardView.super.ctor(self)
- self._tingCardData = nil;
- self:loadUI()
- end
-
- function ncmajShowAllTingCardView:loadUI()
- local ui = loadUI("mj_ncmaj/res/ui_fangjian/mj_ncmaj_showallting_cards.ui")
- self:addChild(ui)
-
- self.ui = ui
- self.ui.Items.Button_QueDing:registerClick(handler(self, self.onClickSure))
- self.ui.Items.Button_QuXiao:registerClick(handler(self, self.onClickCancel))
-
- -- 选择了摆的牌
- self:bindEvent(app.room , MJDefine.MJEvent.ChagneBaiCards, handler(self, self.ChagneBaiCards))
- end
-
- function ncmajShowAllTingCardView:setData(tingCardData)
- logD("ncmajShowAllTingCardView:setData", table.tostring(tingCardData))
- self._tingCardData = tingCardData;
-
- if not tingCardData or table.nums(tingCardData) <= 0 then
- return
- end
- table.sort(
- tingCardData,
- function(c1, c2)
- return c1.card < c2.card
- end
- )
-
- self.ui.Items.Layout_TingCard:removeAllChildren()
-
- local count = #tingCardData
- local row = 1--math.ceil(count / 6) --几行
-
- self.ui.Items.Layout_TingCard:setSize(cc.size(70*count, 80 * row))
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setSize(cc.size(count < 5 and 400 or count * 70 + 116, 80 * row + 40))
- self.ui.Items.ImageView_Ting:setPositionY(self.ui.Items.Layout_Ting_Tip_Card_Panel:getContentSize().height - 60)
- for k, v in pairs(tingCardData) do
- --[[local layout=cc.Layout:create()
- layout:setSize(cc.size(134,80))
-
- local num = cc.Text:createNode()
- num:setDefaults()
- local config = num:getFontConfig()
- config.fontSize = 22
- config.texColor = cc.c4b(213,46,11,255)
- num:setFontConfig(config)
- num:setAnchorPoint(cc.p(0.5,0.5))
- num:setPosition(cc.p(20, 100))
- num:setString(v.count .. "张")
- layout:addChild(num)
-
- local mj = MJ:new(v.card, MJDefine.MJType.Stand, MJDefine.MyViewId, MJDefine.DesktopType.TwoD)
- mj:setPosition(cc.p(20, 50))
- mj:setScale(0.5)
- layout:addChild(mj)
- self.ui.Items.Layout_TingCard:addChild(layout)--]]
- local item = self.ui.Items.Item_Ting:getCopied()
- item:setVisible(true)
- local items = getUIItems(item)
- items.Text_Num:setString(v.count)
- local mj = MJ:new(v.card, MJDefine.MJType.Stand, MJDefine.MyViewId, MJDefine.DesktopType.TwoD)
- mj:setPosition(cc.p(30, 55))
- mj:setScale(0.6)
- items.Node:addChild(mj)
- self.ui.Items.Layout_TingCard:addChild(item)
- end
-
- self.ui.Items.Layout_TingCard:requestDoLayout()
- self.ui.Items.Layout_TingCard:doLayout()
- end
-
- function ncmajShowAllTingCardView:show()
- self:setVisible(true)
- end
-
- function ncmajShowAllTingCardView:hide()
- --self:setVisible(false)
- self.ui.Items.Layout_Bai_Tip_1:setVisible(false)
- self.ui.Items.Layout_Bai_Tip_2:setVisible(false)
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setVisible(false)
- end
-
- function ncmajShowAllTingCardView:showTips1()
- self:hide()
- self.ui.Items.Layout_Bai_Tip_1:setVisible(true)
- self.ui.Items.Button_QueDing:setEnabled(false)
- end
-
- function ncmajShowAllTingCardView:showTips2()
- self:hide()
- self.ui.Items.Layout_Bai_Tip_2:setVisible(true)
- end
-
- function ncmajShowAllTingCardView:showTingCards()
- self:hide()
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setVisible(true)
- end
-
- function ncmajShowAllTingCardView:getTingCardData ()
- return self._tingCardData;
- end
-
- -- 确定
- function ncmajShowAllTingCardView:onClickSure()
- playBtnEffect()
- self:showTips2()
- app.room:dispatchEvent({name = MJDefine.MJEvent.BaiOverOutCards,selectCards = self._selectCards})
- end
-
- -- 取消
- function ncmajShowAllTingCardView:onClickCancel()
- playBtnEffect()
- if self.quxiaoCB then
- self.quxiaoCB()
- end
- --self:hide()
- end
-
- function ncmajShowAllTingCardView:setQuXiaoCallBack(cb)
- if cb then
- self.quxiaoCB = cb
- end
- end
-
- function ncmajShowAllTingCardView:ChagneBaiCards(data)
- if not data then return end
-
- self.ui.Items.Button_QueDing:setEnabled(data.canCommit)
- self._selectCards = data.selectCards
- end
-
- return ncmajShowAllTingCardView
|