150 lines
3.9 KiB
Lua
150 lines
3.9 KiB
Lua
require 'FairyGUI'
|
|
|
|
--region LOCAL
|
|
|
|
local function SetBigWiller(totalScore)
|
|
local s = -999
|
|
local winer = 0
|
|
for _,player in pairs(totalScore) do
|
|
if player.score > s then
|
|
s = player.score
|
|
winer = _
|
|
end
|
|
end
|
|
|
|
totalScore[winer].winer = true
|
|
end
|
|
|
|
local function list_players_Renderer(index, obj, totalScore, self)
|
|
local tex_name = obj:GetChild("tex_name")
|
|
local loader_icon = obj:GetChild("loader_icon")
|
|
local tex_id = obj:GetChild("tex_id")
|
|
local tex_score = obj:GetChild("tex_score")
|
|
|
|
local player = totalScore[index + 1]
|
|
|
|
tex_name.text = player.nick
|
|
tex_id.text = player.accId
|
|
tex_score.text = player.score
|
|
ImageLoad.Load(player.portrait, loader_icon)
|
|
|
|
if player.winer then
|
|
obj:GetController("cWiner").selectedIndex = 1
|
|
else
|
|
obj:GetController("cWiner").selectedIndex = 0
|
|
end
|
|
end
|
|
|
|
local function ChatItemRenderer(index, obj, self)
|
|
|
|
--local data = self.ChatRoomData.records[index + 1]
|
|
local data = self.ChatRoomData[1].records[index + 1]
|
|
local totalScore = json.decode(data.totalScore)
|
|
local hpData = json.decode(data.hpData)
|
|
SetBigWiller(totalScore)
|
|
|
|
local list_players = obj:GetChild("list_players")
|
|
local tex_time = obj:GetChild("tex_time")
|
|
local tex_name = obj:GetChild("tex_name")
|
|
local tex_roomIdRound = obj:GetChild("tex_roomIdRound")
|
|
|
|
tex_time.text = os.date("游戏结算:%m月%d号 %X", data.create_time) --data.create_time
|
|
tex_name.text = data.game_info.name
|
|
local roundTex = data.round .. "/" .. hpData.maxRound
|
|
tex_roomIdRound.text = data.room_id .. "\n" .. roundTex
|
|
|
|
list_players.itemRenderer = function(i, o)
|
|
list_players_Renderer(i, o, totalScore, self)
|
|
end
|
|
|
|
list_players.numItems = #totalScore
|
|
end
|
|
|
|
--[[
|
|
local function GetIsOpenChatRoom(groupId, self)
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
|
fgCtr:GetIsOpenChatRoom(groupId, function(res)
|
|
print("收到是否打开聊天室协议")
|
|
pt(res)
|
|
end)
|
|
end
|
|
]]
|
|
|
|
--endregion
|
|
|
|
local FamilyChatRoom = {}
|
|
|
|
--[[
|
|
function FamilyChatRoom.New()
|
|
--转移进family界面
|
|
--setmetatable(FamilyChatRoom, { __index = BaseWindow })
|
|
--local inst = setmetatable({}, { __index = FamilyChatRoom})
|
|
|
|
inst:Init(com)
|
|
|
|
return inst
|
|
end
|
|
]]
|
|
|
|
function FamilyChatRoom:Init(com, root)
|
|
--转移进family界面
|
|
--self._full = true
|
|
--self._full_offset = false
|
|
--self._animation = false
|
|
--BaseWindow.init(self, "ui://Family/com_chatRoom")
|
|
self.rendererData = {}
|
|
self.root = root
|
|
self._view = com
|
|
|
|
self.list_chat = self._view:GetChild("list_chat")
|
|
self.btn_quit = self._view:GetChild("btn_quit")
|
|
|
|
self.list_chat.itemRenderer = function(index, obj)
|
|
ChatItemRenderer(index, obj, self)
|
|
end
|
|
|
|
self.btn_quit.onClick:Set(function()
|
|
self:Close()
|
|
end)
|
|
|
|
return self
|
|
end
|
|
|
|
function FamilyChatRoom:Close()
|
|
local cChatRoom = self.root._view:GetController("cIsChatRoom")
|
|
cChatRoom.selectedIndex = 0
|
|
end
|
|
|
|
function FamilyChatRoom:Refalsh()
|
|
--local data = string.sub(self.ChatRoomData[1].records, 1, -2)
|
|
--data = data .. ']'
|
|
pt(self.ChatRoomData[1])
|
|
--pt(data)
|
|
--self.records = json.decode(self.ChatRoomData[1].records)
|
|
--self.records = json.decode(self.ChatRoomData[1].records)
|
|
self.list_chat.numItems = #self.ChatRoomData[1].records or 0
|
|
end
|
|
|
|
function FamilyChatRoom:Show()
|
|
local cChatRoom = self.root._view:GetController("cIsChatRoom")
|
|
cChatRoom.selectedIndex = 1
|
|
|
|
--[[
|
|
GetIsOpenChatRoom(self.root._group.id, self)
|
|
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
|
fgCtr:GetChatRoom(self.root._group.id, function(res)
|
|
self:GetChatCallBack(res)
|
|
end)
|
|
]]
|
|
end
|
|
|
|
--[[
|
|
function FamilyChatRoom:GetChatCallBack(res)
|
|
print("收到聊天室协议")
|
|
pt(res)
|
|
pt(res.Data.records.totalScore)
|
|
end
|
|
]]
|
|
|
|
return FamilyChatRoom |