diff --git a/Themes/Til Death/BGAnimations/ScreenNetRoom decorations/default.lua b/Themes/Til Death/BGAnimations/ScreenNetRoom decorations/default.lua index 61781600ad..e1e2fec71a 100644 --- a/Themes/Til Death/BGAnimations/ScreenNetRoom decorations/default.lua +++ b/Themes/Til Death/BGAnimations/ScreenNetRoom decorations/default.lua @@ -5,6 +5,7 @@ end t[#t + 1] = LoadActor("profile") t[#t + 1] = LoadActor("roomsearch") t[#t + 1] = LoadActor("tabs") +t[#t + 1] = LoadActor("../_lobbyuserlist") local g = Def.ActorFrame { diff --git a/Themes/Til Death/BGAnimations/_lobbyuserlist.lua b/Themes/Til Death/BGAnimations/_lobbyuserlist.lua new file mode 100644 index 0000000000..2294131ca2 --- /dev/null +++ b/Themes/Til Death/BGAnimations/_lobbyuserlist.lua @@ -0,0 +1,102 @@ +local usersZoom = 0.45 +local usersWidth = 50 +local usersWidthSmall = 25 +local usersWidthZoom = 50 * (1 / usersZoom) +local usersWidthSmallZoom = 25 * (1 / usersZoom) +local usersRowSize = 4 +local usersX = SCREEN_WIDTH / 4 +local usersY = SCREEN_TOP + 15 +local usersHeight = 10 + +local top = SCREENMAN:GetTopScreen() +local qty = 0 +local posit = getMainColor("positive") +local negat = getMainColor("negative") +local enable = getMainColor("enabled") +local r = + Def.ActorFrame { + BeginCommand = function(self) + self:queuecommand("Set") + end, + InitCommand = function(self) + self:queuecommand("Set") + end, + SetCommand = function(self) + top = SCREENMAN:GetTopScreen() + end, + UsersUpdateMessageCommand = function(self) + self:queuecommand("Set") + end +} + +local function userLabel(i) + local x = 0 + local y = 0 + if i <= usersRowSize then + x = (usersX) + (i * usersWidth) + y = usersY + usersHeight + elseif i <= usersRowSize * 2 then + x = (usersX) + ((i - usersRowSize) * usersWidth) + y = usersY + elseif i <= usersRowSize * 3 then + x = (usersX) + ((i - usersRowSize * 2) * usersWidth) + usersWidthSmall + y = usersY + usersHeight + elseif i <= usersRowSize * 4 then + x = (usersX) + ((i - usersRowSize * 3) * usersWidth) + usersWidthSmall + y = usersY + elseif i <= usersRowSize * 5 then + x = (usersX) + (usersRowSize * usersWidth) + usersWidthSmall * (i - usersRowSize * 4) + y = usersY + else + x = (usersX) + (usersRowSize * usersWidth) + usersWidthSmall * (i - usersRowSize * 5) + y = usersY + usersHeight + end + local aux = + LoadFont("Common Normal") .. + { + Name = i, + BeginCommand = function(self) + self:xy(x, y):zoom(usersZoom):diffuse(posit):queuecommand("Set") + end, + SetCommand = function(self) + local num = self:GetName() + 0 + lobbos = NSMAN:GetLobbyUserList() + qty = #lobbos + if num <= qty then + local str = "" + str = str .. top:GetUser(num) + self:settext(str) + if top:GetUserState(num) == 2 or top:GetUserState(num) == 1 then + self:diffuse(posit) + elseif top:GetUserState(num) == 4 then + self:diffuse(negat) + else + self:diffuse(enable) + end + else + self:settext("") + end + if qty < 9 then + self:maxwidth(usersWidthZoom) + else + self:maxwidth(usersWidthSmallZoom) + end + end, + PlayerJoinedMessageCommand = function(self) + self:queuecommand("Set") + end, + PlayerUnjoinedMessageCommand = function(self) + self:queuecommand("Set") + end, + UsersUpdateMessageCommand = function(self) + self:queuecommand("Set") + end + } + return aux +end + +for i = 1, 32 do + r[#r + 1] = userLabel(i) +end + +return r diff --git a/src/NetworkSyncManager.cpp b/src/NetworkSyncManager.cpp index 2134cf50a5..93f12d3554 100644 --- a/src/NetworkSyncManager.cpp +++ b/src/NetworkSyncManager.cpp @@ -954,6 +954,7 @@ ETTProtocol::Update(NetworkSyncManager* n, float fDeltaTime) for (auto& user : removedUsers) { NSMAN->lobbyuserlist.emplace_back(user.get()); } + SCREENMAN->SendMessageToTopScreen(SM_UsersUpdate); } break; case ettps_roomlist: { RoomData tmp; @@ -999,7 +1000,7 @@ ETTProtocol::Update(NetworkSyncManager* n, float fDeltaTime) } } } - SCREENMAN->SendMessageToTopScreen(SM_UsersUpdate); + SCREENMAN->SendMessageToTopScreen(SM_UsersUpdate); } break; } } catch (exception e) { @@ -1859,6 +1860,17 @@ LuaFunction(IsSMOnlineLoggedIn, NSMAN->loggedIn) } return 1; } + static int GetLobbyUserList(T* p, lua_State* L) + { + lua_newtable(L); + int i = 1; + for (auto& user : NSMAN->lobbyuserlist) { + lua_pushstring(L, user.c_str()); + lua_rawseti(L, -2, i); + i++; + } + return 1; + } LunaNetworkSyncManager() { ADD_METHOD(GetEvalScores); @@ -1870,6 +1882,7 @@ LuaFunction(IsSMOnlineLoggedIn, NSMAN->loggedIn) ADD_METHOD(Logout); ADD_METHOD(IsETTP); ADD_METHOD(GetCurrentRoomName); + ADD_METHOD(GetLobbyUserList); } }; @@ -1893,21 +1906,10 @@ class LunaChartRequest : public Luna lua_pushnumber(L, p->rate / 1000); return 1; } - static int GetLobbyUserList(T* p, lua_State* L) - { - lua_newtable(L); - int i = 1; - for (auto& user : NSMAN->lobbyuserlist) { - lua_pushstring(L, user.c_str()); - lua_rawseti(L, -2, i); - i++; - } - return 1; - } + LunaChartRequest() { ADD_METHOD(GetChartkey); - ADD_METHOD(GetLobbyUserList); ADD_METHOD(GetUser); ADD_METHOD(GetRate); }