--接houmee实习日记22-30<1> --rankingList_ui --rankingList_ui --排行榜 --created by gun on 20i5-4-2i module(...,package.seeall) local rRankingConfig = require(gUIPath.."/rankingList/rankingList_data") -- local ---------- RankingListUI = class("RankingListUI",BaseClass) function RankingListUI:ctor( ... ) self.root = nil self.rObjList = {} self.currentPage = nil end gRankingListUI = RankingListUI:new() ----------- function RankingListUI:Init( oRoot ) self.root = oRoot self.rObjList ={ --等级模版 [rRankingConfig.GRADE] = {root = nil,refreshFunc = self.refreshNewGR}, --通用多个对象模版 [rRankingConfig.RANKS] = {root = nil,refreshFunc = self.refreshNewAS}, [rRankingConfig.A_COPY_OF_THE_CLEARANCE] = {root = nil,refreshFunc = self.refreshNewAS}, [rRankingConfig.COMPETITIVE] = {root = nil,refreshFunc = self.refreshNewAS}, [rRankingConfig.CARD] = {root = nil,refreshFunc = self.refreshNewAS}, [rRankingConfig.WEEK_BOSS] = {root = nil,refreshFunc = self.refreshNewAS}, [rRankingConfig.WORLD_BOSS] = {root = nil,refreshFunc = self.refreshNewAS}, --公会战,公会模版 [rRankingConfig.ASSOCIATION] = {root = nil,refreshFunc = self.refreshNewGH}, [rRankingConfig.WAR_ASSOCIATION] = {root = nil,refreshFunc = self.refreshNewGHZ}, } -- self.InitNetEvent() end ------------传入一个参数nindex 判断root不存在,添加他, function RankingListUI:GetRootByIndex( nIndex ) self.currentPage = nIndex if not self.rObjList[self.currentPage].root then --加载data里面的纹理 self.rObjList[self.currentPage].root = GUIReader:shareReader(): widgetFromJsonFile(rRankingConfig.gRankingListUIConfig[self.currentPage].rootFile) self.rObjList[self.currentPage].root:retain()--添加计数 end self.rObjList[self.currentPage].refreshFunc(self) return self:GetCurrentRoot() -- return self.rObjList[self.currentPage].root end -------------上面添加root后,root肯定存在,这里用完后来释放他 function RankingListUI:Destroy( ... ) print("RankingListUI:destroy") for i,v in ipairs(self.rObjList) do if v.root then print("id为"..i.."有值,释放该资源") v.root:release() v.root = nil end end if self.root then self.RemoveNetEvent() self.root = nil end -- self.firstOpenVip = nil end -- -------------- -- function RankingListUI:GetCurrentRoot( ... ) -- return self.rObjList[self.currentPage].root -- e防御 -------------- , -----------界面刷新-------------- local tData = { [1] = {heroLabel3 = "rank3" ,heroLabel2 = "nicai通用" ,heroPhoto = gImagesPath.."/common/pub_replace.png" , heroRank = "第一名" , heroName = "小毛驴" , defense = "防守队伍总防御:1001 " , attack = "进攻队伍总攻击:1000 " } , [2] = {heroLabel3 = "rank3" ,heroLabel2 = "nicai通用" ,heroPhoto = gImagesPath.."/common/pub_replace.png" , heroRank = "第二名" , heroName = "紫莍月" , defense = "防守队伍总防御:2002 " , attack = "进攻队伍总攻击:2000 " } , [3] = {heroLabel3 = "rank3" ,heroLabel2 = "nicai通用" ,heroPhoto = gImagesPath.."/common/pub_replace.png" , heroRank = "第三名" , heroName = "小惠" , defense = "防守队伍总防御:3003 " , attack = "进攻队伍总攻击:3000 " } , [4] = {heroLabel3 = "rank3" ,heroLabel2 = "nicai通用" ,heroPhoto = gImagesPath.."/common/pub_replace.png" , heroRank = "第四名" , heroName = "叫你浪" , defense = "防守队伍总防御:4004 " , attack = "进攻队伍总攻击:4000 " } , [5] = {heroLabel3 = "rank3" ,heroLabel2 = "nicai通用" ,heroPhoto = gImagesPath.."/common/pub_replace.png" , heroRank = "第五名" , heroName = "送一血" , defense = "防守队伍总防御:5005 " , attack = "进攻队伍总攻击:5000 " } , [6] = {heroLabel3 = "rank3" ,heroLabel2 = "nicai通用" ,heroPhoto = gImagesPath.."/common/pub_replace.png" , heroRank = "第六名" , heroName = "么么哒" , defense = "防守队伍总防御:6006 " , attack = "进攻队伍总攻击:6000 " } , [7] = {heroLabel3 = "rank3" ,heroLabel2 = "nicai通用" ,heroPhoto = gImagesPath.."/common/pub_replace.png" , heroRank = "第七名" , heroName = "啊绿" , defense = "防守队伍总防御:7007 " , attack = "进攻队伍总攻击:7000 " } , } function RankingListUI:allRefreshWillUseIt( npage ) --大框 print("我当前的界面是:" , npage) -- local self.root = self:GetCurrentRoot() tolua.cast(UIHelper:seekWidgetByName(self.root,"Label_mysort"),"Label"):setText("我的排名 : 9999") -------不完整 -- local self.root = self:GetCurrentRoot() tolua.cast(UIHelper:seekWidgetByName(self.root,"Label_nowCount"),"Label"):setText("当前积分 : 10000") -------不完整 -- local self.root = self:GetCurrentRoot() tolua.cast(UIHelper:seekWidgetByName(self.root,"Label_refresh"),"Label"):setText("每小时刷新") -------不完整 tolua.cast(UIHelper:seekWidgetByName(self.root,"Button_sure"),"Button"):addTouchEventListener( function ( sender , eventType ) if eventType == TOUCH_EVENT_ENDED then print("挂上了") self:GoToMUIAndCloseMe() end end ) end ---------------------------------------- ------排位战---------------------------- function RankingListUI:refreshNewWindows( npage ) self:allRefreshWillUseIt(npage) ---------------- --右边 local Panel_2 = tolua.cast(UIHelper:seekWidgetByName(self.root,"Panel_2"),"Layout") --容器 local ListView_right = tolua.cast(UIHelper:seekWidgetByName(self.root,"ListView_right"),"ListView") --列表容器、 -- local Slider_right = tolua.cast( UIHelper:seekWidgetByName( self.root, "Slider_right" ) , "Slider") --右边滑动条 self.initHandlerSilder = CCDirector:sharedDirector():getScheduler():scheduleScriptFunc( function ( ) CCDirector:sharedDirector():getScheduler():unscheduleScriptEntry( self.initHandlerSilder ) gUtils:SetupScrollIndicator( ListView_right, tolua.cast( UIHelper:seekWidgetByName( self.root , "Slider_right" ) , "Slider") ) end, 0, false ) ---子节点循环添加 local panelChild = tolua.cast(UIHelper:seekWidgetByName(self.root,"Panel_table1"),"Layout") --容器 ListView_right:setItemModel(panelChild) panelChild:removeFromParentAndCleanup(true) -- ListView_right:removeAllChildren() ListView_right:removeAllItems() for i,v in ipairs(tData) do print("第几个 :",i) print("把这个值打印一下 :",v) ListView_right:pushBackDefaultItem() --添加一个默认项 local item = tolua.cast(ListView_right:getItem(ListView_right:getItems():count()-1),"Layout") -- addTabelModel() local Pimage = tolua.cast(UIHelper:seekWidgetByName(item,"Image_28"),"ImageView") Pimage:loadTexture(v.heroPhoto) --wenben local NLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_name"),"Label") NLabel:setText(v.heroName) local RLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_rank"),"Label") RLabel:setText(v.heroRank) local AtLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_attack"),"Label") AtLabel:setText(v.attack) AtLabel:setVisible(true) local DeLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_defense"),"Label") DeLabel:setText(v.defense) DeLabel:setVisible(true) -- DeLabel:setVisible(false) local _2Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label2_Ordinary"),"Label") _2Label:setText(v.heroLabel2) _2Label:setVisible(false) local _3Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label3_Rank"),"Label") _3Label:setText(v.heroLabel3) _3Label:setVisible(false) local _4Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label4_Ghui"),"Label") _4Label:setVisible(false) -------------这里添加一个判断,对添加的显示的问题进行限制15条-----多于15则需要刷新 -- if i > 15 then -- print("显示到达上限,等待刷新") -- break -- end end ------------- -- local function addTabelModel(...) -- print("###########",item) -- --tupian -- end end ----------队伍,副本,竞技,BOSS,card------ -------------------------------------------- function RankingListUI:refreshNewAS( npage ) self:allRefreshWillUseIt(npage) ---------------- --右边 local Panel_2 = tolua.cast(UIHelper:seekWidgetByName(self.root,"Panel_2"),"Layout") --容器 local ListView_right = tolua.cast(UIHelper:seekWidgetByName(self.root,"ListView_right"),"ListView") --列表容器、 -- local Slider_right = tolua.cast( UIHelper:seekWidgetByName( self.root, "Slider_right" ) , "Slider") --右边滑动条 self.initHandlerSilder = CCDirector:sharedDirector():getScheduler():scheduleScriptFunc( function ( ) CCDirector:sharedDirector():getScheduler():unscheduleScriptEntry( self.initHandlerSilder ) gUtils:SetupScrollIndicator( ListView_right, tolua.cast( UIHelper:seekWidgetByName( self.root , "Slider_right" ) , "Slider") ) end, 0, false ) ---子节点循环添加 local panelChild = tolua.cast(UIHelper:seekWidgetByName(self.root,"Panel_table1"),"Layout") --容器 ListView_right:setItemModel(panelChild) panelChild:removeFromParentAndCleanup(true) -- ListView_right:removeAllChildren() ListView_right:removeAllItems() for i,v in ipairs(tData) do print("第几个 :",i) print("把这个值打印一下 :",v) ListView_right:pushBackDefaultItem() --添加一个默认项 local item = tolua.cast(ListView_right:getItem(ListView_right:getItems():count()-1),"Layout") -- addTabelModel() local Pimage = tolua.cast(UIHelper:seekWidgetByName(item,"Image_28"),"ImageView") Pimage:loadTexture(v.heroPhoto) --wenben local NLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_name"),"Label") NLabel:setText(v.heroName) local RLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_rank"),"Label") RLabel:setText(v.heroRank) local AtLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_attack"),"Label") AtLabel:setText(v.attack) AtLabel:setVisible(false) local DeLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_defense"),"Label") DeLabel:setText(v.defense) DeLabel:setVisible(false) local _2Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label2_Ordinary"),"Label") _2Label:setText(v.heroLabel2) _2Label:setVisible(true) local _3Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label3_Rank"),"Label") _3Label:setText(v.heroLabel3) _3Label:setVisible(false) local _4Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label4_Ghui"),"Label") _4Label:setVisible(false) end end ----------等级----------- ------------------------- function RankingListUI:refreshNewGR( npage ) self:allRefreshWillUseIt(npage) ---------------- --右边 local Panel_2 = tolua.cast(UIHelper:seekWidgetByName(self.root,"Panel_2"),"Layout") --容器 local ListView_right = tolua.cast(UIHelper:seekWidgetByName(self.root,"ListView_right"),"ListView") --列表容器、 -- local Slider_right = tolua.cast( UIHelper:seekWidgetByName( self.root, "Slider_right" ) , "Slider") --右边滑动条 self.initHandlerSilder = CCDirector:sharedDirector():getScheduler():scheduleScriptFunc( function ( ) CCDirector:sharedDirector():getScheduler():unscheduleScriptEntry( self.initHandlerSilder ) gUtils:SetupScrollIndicator( ListView_right, tolua.cast( UIHelper:seekWidgetByName( self.root , "Slider_right" ) , "Slider") ) end, 0, false ) ---子节点循环添加 local panelChild = tolua.cast(UIHelper:seekWidgetByName(self.root,"Panel_table1"),"Layout") --容器 ListView_right:setItemModel(panelChild) panelChild:removeFromParentAndCleanup(true) -- ListView_right:removeAllChildren() ListView_right:removeAllItems() for i,v in ipairs(tData) do print("第几个 :",i) print("把这个值打印一下 :",v) ListView_right:pushBackDefaultItem() --添加一个默认项 local item = tolua.cast(ListView_right:getItem(ListView_right:getItems():count()-1),"Layout") -- addTabelModel() local Pimage = tolua.cast(UIHelper:seekWidgetByName(item,"Image_28"),"ImageView") Pimage:loadTexture(v.heroPhoto) --wenben local NLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_name"),"Label") NLabel:setText(v.heroName) local RLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_rank"),"Label") RLabel:setText(v.heroRank) local AtLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_attack"),"Label") AtLabel:setText(v.attack) AtLabel:setVisible(false) local DeLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_defense"),"Label") DeLabel:setText(v.defense) DeLabel:setVisible(false) local _2Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label2_Ordinary"),"Label") _2Label:setText(v.heroLabel2) _2Label:setVisible(true) local _3Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label3_Rank"),"Label") _3Label:setText(v.heroLabel3) _3Label:setVisible(true) local _4Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label4_Ghui"),"Label") _4Label:setVisible(false) end end -----公会--------- ------------------ function RankingListUI:refreshNewGH( npage ) self:allRefreshWillUseIt(npage) ---------------- --右边 local Panel_2 = tolua.cast(UIHelper:seekWidgetByName(self.root,"Panel_2"),"Layout") --容器 local ListView_right = tolua.cast(UIHelper:seekWidgetByName(self.root,"ListView_right"),"ListView") --列表容器、 -- local Slider_right = tolua.cast( UIHelper:seekWidgetByName( self.root, "Slider_right" ) , "Slider") --右边滑动条 self.initHandlerSilder = CCDirector:sharedDirector():getScheduler():scheduleScriptFunc( function ( ) CCDirector:sharedDirector():getScheduler():unscheduleScriptEntry( self.initHandlerSilder ) gUtils:SetupScrollIndicator( ListView_right, tolua.cast( UIHelper:seekWidgetByName( self.root , "Slider_right" ) , "Slider") ) end, 0, false ) ---子节点循环添加 local panelChild = tolua.cast(UIHelper:seekWidgetByName(self.root,"Panel_table1"),"Layout") --容器 ListView_right:setItemModel(panelChild) panelChild:removeFromParentAndCleanup(true) -- ListView_right:removeAllChildren() ListView_right:removeAllItems() for i,v in ipairs(tData) do print("第几个 :",i) print("把这个值打印一下 :",v) ListView_right:pushBackDefaultItem() --添加一个默认项 local item = tolua.cast(ListView_right:getItem(ListView_right:getItems():count()-1),"Layout") -- addTabelModel() local Pimage = tolua.cast(UIHelper:seekWidgetByName(item,"Image_28"),"ImageView") Pimage:loadTexture(v.heroPhoto) --wenben local NLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_name"),"Label") NLabel:setText(v.heroName) local RLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_rank"),"Label") RLabel:setText(v.heroRank) local AtLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_attack"),"Label") AtLabel:setText(v.attack) AtLabel:setVisible(false) local DeLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_defense"),"Label") DeLabel:setText(v.defense) DeLabel:setVisible(false) local _2Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label2_Ordinary"),"Label") _2Label:setText(v.heroLabel2) _2Label:setVisible(true) local _3Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label3_Rank"),"Label") _3Label:setText(v.heroLabel3) _3Label:setVisible(true) local _4Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label4_Ghui"),"Label") _4Label:setVisible(true) end end ---公会战-------- ----------------- function RankingListUI:refreshNewGHZ( npage ) self:allRefreshWillUseIt(npage) ---------------- --右边 local Panel_2 = tolua.cast(UIHelper:seekWidgetByName(self.root,"Panel_2"),"Layout") --容器 local ListView_right = tolua.cast(UIHelper:seekWidgetByName(self.root,"ListView_right"),"ListView") --列表容器、 -- local Slider_right = tolua.cast( UIHelper:seekWidgetByName( self.root, "Slider_right" ) , "Slider") --右边滑动条 self.initHandlerSilder = CCDirector:sharedDirector():getScheduler():scheduleScriptFunc( function ( ) CCDirector:sharedDirector():getScheduler():unscheduleScriptEntry( self.initHandlerSilder ) gUtils:SetupScrollIndicator( ListView_right, tolua.cast( UIHelper:seekWidgetByName( self.root , "Slider_right" ) , "Slider") ) end, 0, false ) ---子节点循环添加 local panelChild = tolua.cast(UIHelper:seekWidgetByName(self.root,"Panel_table1"),"Layout") --容器 ListView_right:setItemModel(panelChild) panelChild:removeFromParentAndCleanup(true) -- ListView_right:removeAllChildren() ListView_right:removeAllItems() for i,v in ipairs(tData) do print("第几个 :",i) print("把这个值打印一下 :",v) ListView_right:pushBackDefaultItem() --添加一个默认项 local item = tolua.cast(ListView_right:getItem(ListView_right:getItems():count()-1),"Layout") -- addTabelModel() local Pimage = tolua.cast(UIHelper:seekWidgetByName(item,"Image_28"),"ImageView") Pimage:loadTexture(v.heroPhoto) --wenben local NLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_name"),"Label") NLabel:setText(v.heroName) local RLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_rank"),"Label") RLabel:setText(v.heroRank) local AtLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_attack"),"Label") AtLabel:setText(v.attack) AtLabel:setVisible(false) local DeLabel = tolua.cast(UIHelper:seekWidgetByName(item,"Label_defense"),"Label") DeLabel:setText(v.defense) DeLabel:setVisible(false) local _2Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label2_Ordinary"),"Label") _2Label:setText(v.heroLabel2) _2Label:setVisible(true) local _3Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label3_Rank"),"Label") _3Label:setText(v.heroLabel3) _3Label:setVisible(false) local _4Label = tolua.cast(UIHelper:seekWidgetByName(item,"Label4_Ghui"),"Label") _4Label:setVisible(true) end end function RankingListUI:GoToMUIAndCloseMe() gUIMgr.CloseAllRankUI() -- gUIMgr.OpenMainScene( nUId ) --调到子界面 end --------------->请看houmee实习日记22-30<3>