diff --git a/lua_probject/base_project/Game/View/Family/FamilAllRank.lua b/lua_probject/base_project/Game/View/Family/FamilAllRank.lua new file mode 100644 index 00000000..46291f3f --- /dev/null +++ b/lua_probject/base_project/Game/View/Family/FamilAllRank.lua @@ -0,0 +1,169 @@ +local FamilAllRank = {} + +local M = FamilAllRank + +function FamilAllRank.New(root, groupId) + local self = setmetatable({}, { __index = M }) + self._father = root + self.group_id = groupId + self:init() + return self +end + +function M:init() + local root = self._father + self._lastTpe = root.familyType.selectedIndex + root.familyType.selectedIndex = 0 + local comp_rank = UIPackage.CreateObjectFromURL("ui://Family/comp_rank") + root._view:AddChild(comp_rank) + comp_rank.width = root._view.width + comp_rank.height = root._view.height + comp_rank:Center() + self._view = comp_rank + + local viewBox_leftTime = comp_rank:GetChild('left_time') + local viewBox_rightTime = comp_rank:GetChild('right_time') + local viewBtn_search = comp_rank:GetChild('btn_search') + local viewBtn_close = comp_rank:GetChild('btn_close') + + self._viewList_round = comp_rank:GetChild('list_round') + self._viewList_score = comp_rank:GetChild('list_score') + self._viewList_win = comp_rank:GetChild('list_win') + + viewBtn_close.onClick:Set(function() + root.familyType.selectedIndex = self._lastTpe + self._lastTpe = nil + comp_rank.visible = false + end) + + local serverDayValues, serverDayItems = self:InitTime() + viewBox_leftTime.items = serverDayItems + viewBox_leftTime.values = serverDayValues + viewBox_rightTime.items = serverDayItems + viewBox_rightTime.values = serverDayValues + self.leftTimes = tonumber(serverDayValues[1]) + self.rightTimes = tonumber(serverDayValues[1]) + + viewBox_leftTime.onChanged:Set(function() + self.leftTimes = tonumber(viewBox_leftTime.value) + end) + viewBox_rightTime.onChanged:Set(function() + self.rightTimes = tonumber(viewBox_rightTime.value) + end) + + self._viewList_round:SetVirtual() + self._viewList_round.itemRenderer = handler(self, self.RoundListRenderer) + + self._viewList_score:SetVirtual() + self._viewList_score.itemRenderer = handler(self, self.ScoreListRenderer) + + self._viewList_win:SetVirtual() + self._viewList_win.itemRenderer = handler(self, self.WinListRenderer) + + viewBtn_search.onClick:Set(function() + self:SearchRank() + end) + + self:SearchRank() +end + +function M:InitTime() + local timeTable = os.date("*t", os.time()) + timeTable.hour = 0 + timeTable.min = 0 + timeTable.sec = 0 + + local serverDayItems = {} + local serverDayValues = {} + for i = 0, 6 do + local tempValue = os.time(timeTable) - 86400 * i + print(tempValue) + local tempItems = os.date("%Y-%m-%d", tempValue) + table.insert(serverDayItems, tempItems) + table.insert(serverDayValues, tostring(tempValue)) + end + + return serverDayValues, serverDayItems +end + +function M:RoundListRenderer(index, obj) + local rankTable = self.roundRanks + obj:GetChild('text_rank').text = index + obj:GetChild('text_id').text = rankTable[index + 1].rankTable + obj:GetChild('text_name').text = rankTable[index + 1].nick + obj:GetChild('text_other').text = rankTable[index + 1].round + ImageLoad.Load(rankTable[index + 1].portrait, obj:GetChild('btn_head')._iconObject) +end + +function M:WinListRenderer(index, obj) + local rankTable = self.winRanks + obj:GetChild('text_rank').text = index + obj:GetChild('text_id').text = rankTable[index + 1].rankTable + obj:GetChild('text_name').text = rankTable[index + 1].nick + obj:GetChild('text_other').text = rankTable[index + 1].win + ImageLoad.Load(rankTable[index + 1].portrait, obj:GetChild('btn_head')._iconObject) +end + +function M:ScoreListRenderer(index, obj) + local rankTable = self.scoreRanks + obj:GetChild('text_rank').text = index + obj:GetChild('text_id').text = rankTable[index + 1].rankTable + obj:GetChild('text_name').text = rankTable[index + 1].nick + obj:GetChild('text_other').text = d2ad(rankTable[index + 1].score) + ImageLoad.Load(rankTable[index + 1].portrait, obj:GetChild('btn_head')._iconObject) +end + +function M:SearchRank() + local fgCtr = ControllerManager.GetController(NewGroupController) + local begin_time = math.min(self.leftTimes, self.rightTimes) + local end_time = math.max(self.leftTimes, self.rightTimes) + self:ClearingTable() + self:RecursionSearchRank(fgCtr, 0, begin_time, end_time) +end + +function M:RecursionSearchRank(fgCtr, index, begin_time, end_time) + fgCtr:FG_GetMemberRank(self.group_id, 0, index * 2, 2, begin_time, end_time, nil, function(res) + if res.ReturnCode ~= 0 then + ViewUtil.ErrorTip(res.ReturnCode, "获取排行榜失败") + return + else + local info = res.Data + if info.ranks and #info.ranks > 0 then + self:RankTableInsert(info.ranks) + self:RecursionSearchRank(fgCtr, index + 1, begin_time, end_time) + else + table.sort(self.roundRanks, function(a, b) + return a.round > b.round + end) + table.sort(self.winRanks, function(a, b) + return a.win > b.win + end) + table.sort(self.scoreRanks, function(a, b) + return a.score > b.score + end) + self._viewList_round.numItems = #self.roundRanks + self._viewList_score.numItems = #self.winRanks + self._viewList_win.numItems = #self.scoreRanks + end + end + end) +end + +function M:RankTableInsert(ranks) + for i = 1, #ranks do + table.insert(self.roundRanks, ranks[i]) + table.insert(self.winRanks, ranks[i]) + table.insert(self.scoreRanks, ranks[i]) + end +end + +function M:ClearingTable() + self.roundRanks = {} + self.winRanks = {} + self.scoreRanks = {} + self._viewList_round.numItems = 0 + self._viewList_score.numItems = 0 + self._viewList_win.numItems = 0 +end + +return M diff --git a/lua_probject/base_project/Game/View/FamilyView.lua b/lua_probject/base_project/Game/View/FamilyView.lua index bbe20d26..b1dcd80d 100644 --- a/lua_probject/base_project/Game/View/FamilyView.lua +++ b/lua_probject/base_project/Game/View/FamilyView.lua @@ -2,6 +2,7 @@ local FamilyInviteFamilyView = import('.Family.FamilyInviteFamilyView') local CreatePlayView = import('.Family.CreatePlayView') local GroupGameSettingView = import(".NewGroup.MngView.GroupGameSettingView_jaingxi") local LobbyShopView = import(".Lobby.LobbyShopView") +local FamilAllRank = import(".Family.FamilAllRank") ---无窗口 local FamilyAllNumbers = import(".Family.FamilyAllNumbers") @@ -129,6 +130,12 @@ function M:ShowShop() self._child_familyLobbyShopView:Show() end +function M:ShowAllRank() + if not self._ViewChild_AllRank then + self._ViewChild_AllRank = FamilAllRank.New(self, self._group.id) + end +end + function M:MoreBtn() local ctr_more = self._view:GetController('moreBtn') self._view:GetChild('bg_moreBtnBack').onClick:Set(function() @@ -325,6 +332,7 @@ function M:UpdateFamilyRoom(fgCtr, id) end list_gamePlay.itemRenderer = function(index, obj) if index == 0 then + obj:GetController('type').selectedIndex = 0 obj:GetChild('num').text = string.format("%d/7", #playList) obj:GetChild('btn_addPlay').onClick:Set(function() local tem = GroupGameSettingView.new(self.blur_view, id, 0, nil, function(play) @@ -342,11 +350,13 @@ function M:UpdateFamilyRoom(fgCtr, id) obj:GetChild('text_title').text = playList[index].game_name local mode = ExtendManager.GetExtendConfig(playList[index].gameId):GetGameInfo() obj:GetChild('Label_details'):GetChild('title').text = mode:LoadConfigToDetail(playList[index].config) + obj:GetChild('text_playName').text = playList[index].name obj:GetController('type').selectedIndex = 1 - obj:GetChild('btn_del').onClick:Add(function() - fgCtr:FG_DelPlay(id, playList[index].id, function() - ViewUtil.ShowBannerOnScreenCenter("删除成功") - self:UpdateFamilyRoom(fgCtr, id) + obj:GetChild('btn_del').onClick:Set(function() + ViewUtil.ShowTwoChooose("是否要删除该玩法", function() + fgCtr:FG_DelPlay(id, playList[index].id, function() + self:UpdateFamilyRoom(fgCtr, id) + end) end) end) end @@ -505,7 +515,7 @@ local IDENTITY_LIST = { }, { name = "亲友圈排行榜", - Fct = M.CreateFamily + Fct = M.ShowAllRank } } @@ -547,7 +557,7 @@ local IDENTITY_LIST = { }, { name = "亲友圈排行榜", - Fct = M.CreateFamily + Fct = M.ShowAllRank } } diff --git a/lua_probject/base_project/Game/View/MainView.lua b/lua_probject/base_project/Game/View/MainView.lua index d187102f..80dff40c 100644 --- a/lua_probject/base_project/Game/View/MainView.lua +++ b/lua_probject/base_project/Game/View/MainView.lua @@ -822,16 +822,16 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.WitnessPlayerLeave, function(...) - ---- print("刷新托管数据=====") + -- print("刷新托管数据=====") local arg = { ... } local player = arg[1] local witnessPlayerList = _room.witness_player_list - for i, _player in ipairs(witnessPlayerList) do - if _player.uid == player then - table.remove(witnessPlayerList, i) - return - end - end + -- for i, _player in ipairs(witnessPlayerList) do + -- if _player.uid == player then + -- table.remove(witnessPlayerList, i) + -- return + -- end + -- end end ) end diff --git a/wb_new_ui/assets/Common/component/pop_twoChooser/btn_leftChoose.xml b/wb_new_ui/assets/Common/component/pop_twoChooser/btn_leftChoose.xml index b1332c6f..d204c50d 100644 --- a/wb_new_ui/assets/Common/component/pop_twoChooser/btn_leftChoose.xml +++ b/wb_new_ui/assets/Common/component/pop_twoChooser/btn_leftChoose.xml @@ -2,8 +2,8 @@ - - + +