local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine") local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ") local xueliuFlowView = class("xueliuFlowView", cc.UIView); function xueliuFlowView:ctor(data) xueliuFlowView.super.ctor(self); self.desktopType = MJDefine.DesktopType.TwoD; self.data = data or {}; end function xueliuFlowView:loadUI( ) local ui = loadUI("mj_xueliu/res/ui_fangjian/mj_xueliu_flow.ui"); self.ui = ui; self:addChild(ui); end function xueliuFlowView:onEnter( ) self:loadUI(); self:initViews(); self:initFlowView(self.data.liushuiDetail); self:bindEvent(app.room, MJDefine.MJEvent.EVENT_XIAOJU_VIEW_SHOWED, handler(self, self.onEventXiaoJuViewShowed)); self:bindEvent(app.room, MJDefine.MJEvent.EVENT_DAJU_VIEW_SHOWED, handler(self, self.onEventXiaoJuViewShowed)); end function xueliuFlowView:onEventXiaoJuViewShowed( ) self:onBtnCloseClicked(); end function xueliuFlowView:initViews () self.ui.Items.Button_Close:registerClick(handler(self, self.onBtnCloseClicked)); self.ui.Items.ScrollView_Detail:hideAllBar(); self.ui.Items.Layout_1:setTouchEnabled(true); local color = self.data.totalScore >= 0 and cc.c3b(235,72,15) or cc.c3b(113,113,113); self.ui.Items.Text_Sum_Score:setString(self.data.totalScore > 0 and "+" .. self.data.totalScore or self.data.totalScore) self.ui.Items.Text_Sum_Score:setColor(color); end function xueliuFlowView:createItem(data) local ui = loadUI("mj_xueliu/res/ui_fangjian/mj_xueliu_flow_item.ui"); ui.Items.ScrollView_ItemDetail:hideAllBar(); ui.Items.Text_Detail:setString(data.title or ""); ui.Items.Text_Score:setString(data.score or 0); local color = data.score >= 0 and cc.c3b(235,72,15) or cc.c3b(113,113,113); ui.Items.Text_Score:setColor(color); local mj = MJ:new(data.card, MJDefine.MJType.Out, MJDefine.MyViewId, self.desktopType); mj:setAnchorPoint(cc.p(0.5, 0.5)); mj:setPositionY(25); mj:setScale(0.80); ui.Items.Layout_HuCard:addChild(mj); local nodes = {}; for k, v in ipairs(data.seats) do if v and v ~= "" then local viewOrder = tonumber(v) + 1; local img = cc.ImageView:create(); nodes[viewOrder] = img; end end local index = 0; for viewOrder, v in pairs(nodes) do index = index + 1; v:loadTexture(string.format("mj_xueliu/res/zy_fangjian/flow/xueliu_seat_%s.png", viewOrder)); v:setPosition(cc.p((index - 1) * 30 - (table.nums(data.seats) - 1) * 30 / 2 + 15, 25)); ui.Items.Layout_Seats:addChild(v); end return ui; end function xueliuFlowView:getDeFenType(defenType) local operateTypeName ={ [0] = "", [0x01] = "自摸", [0x02] = "接炮", [0x03] = "暗杠", [0x04] = "直杠", [0x05] = "巴杠", [0x06] = "呼叫转移", [0x07] = "退还杠", [0x09] = '大叫', [0x10] = '花猪' } return operateTypeName[defenType] or ""; end function xueliuFlowView:getPaiType( paiType ) return MJDefine.MJGameHuStr[paiType] or ""; end function xueliuFlowView:getSubPaiType(subPaiType) local subPaiTypeName = { [0] = "", [0x01] = "天胡", [0x02] = "地胡", } return subPaiTypeName[subPaiType] or ""; end function xueliuFlowView:getbSubType(data) local str = "" if data.bIsJinGouDiao > 0 then str = str .. "金钩钩" .. " " end if data.bIsHaiDiLaoYue > 0 then str = str .. "海底捞月" .. " " end if data.bIsHaiDiPao > 0 then str = str .. "海底炮" .. " " end if data.bGangShangKaiHua > 0 then str = str .. "杠上开花" .. " " end if data.bGangShangPao > 0 then str = str .. "杠上炮" .. " " end if data.bQiangGangHu > 0 then str = str .. "抢杠胡" .. " " end if data.bMenQing > 0 then str = str .. "门清" .. " " end if data.bZhongZhang > 0 then str = str .. "中张" .. " " end return str end function xueliuFlowView:getItemTitle (itemData) local opType = self:getDeFenType(itemData.type) or ""; local paiType = self:getPaiType(itemData.paiType) or ""; local subPaiType = self:getSubPaiType(itemData.subPaiType) or ""; local bSubType = self:getbSubType(itemData) or ""; local genNum = tonumber(itemData.genShu) > 0 and string.format("%s根", itemData.genShu) or ""; local gangType = tonumber(itemData.fanshu) > 0 and string.format("%s番", itemData.fanshu) or ""; local str = "" if opType ~= "" then str = str..opType..' ' end if paiType ~= "" then str = str..paiType..' ' end if subPaiType ~= "" then str = str..subPaiType..' ' end if bSubType ~= "" then str = str..bSubType..' ' end if genNum ~= "" then str = str..genNum..' ' end if gangType ~= "" then str = str..gangType..' ' end return str; end function xueliuFlowView:initFlowView( data ) local scrollView = self.ui.Items.ScrollView_Detail; -- scrollView:removeAllChildren(); local result = {}; --分数解析 for k, v in ipairs(data) do local obj = {}; obj.title = self:getItemTitle(v); obj.card = v.card or 0; obj.score = v.score; obj.seats = string.split(v.seat, ";"); table.insert(result, obj); end for k, v in ipairs(result) do local ui = self:createItem(v); scrollView:addChild(ui); end local size = scrollView:getContentSize(); size.height = 70 * table.nums(result); scrollView:setInnerContainerSize(size); end function xueliuFlowView:onBtnCloseClicked( ) self:removeFromParent(); self = nil; end return xueliuFlowView;