From 84951fd610bf1d71a86b019dce7099eb2f86ebb0 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 16 Jul 2018 10:11:50 -0400 Subject: [PATCH] obscene ui-candy and wishlist buttons on online leaderboards for: - going to a player's profile - going to the score profile for a listed score - going to the song leaderboard - avatar junk that's in a button for no reason --- .../ScreenSelectMusic decorations/score.lua | 55 ++++++++++++++++++- src/DownloadManager.cpp | 10 +++- src/DownloadManager.h | 2 + 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/score.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/score.lua index 1357dfddfc..93022cf604 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/score.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/score.lua @@ -519,8 +519,10 @@ function updateNetScores(self) end MESSAGEMAN:Broadcast("NetScoreUpdate") end +local eosongid local netTab = Def.ActorFrame { - ChartLeaderboardUpdateMessageCommand = function(self) + ChartLeaderboardUpdateMessageCommand = function(self,params) + eosongid = params.songid updateNetScores(self) end, UpdateChartMessageCommand=function(self) @@ -813,7 +815,58 @@ local function netscoreitem(drawindex) self:queuecommand("Set") end, }, + + -- completely gratuitous eo player profile link button (this is the only one that works atm) + Def.Quad{ + InitCommand=function(self) + self:xy(netscoreframex+28,netscoreframey+18+(drawindex*netscorespacing)):zoomto((netscoreframeWidth-15)/1.75,20):halign(0):diffuse(getMainColor('positive')):valign(1):diffusealpha(0) + end, + MouseLeftClickMessageCommand=function(self) + if isOver(self) and nestedTab == 2 then + local urlstringyo = "https://etternaonline.com/user/"..tmpScore.username + GAMESTATE:ApplyGameCommand("urlnoexit,"..urlstringyo) + end + end + }, + + -- completely gratuitous eo song id link button + Def.Quad{ + InitCommand=function(self) + self:xy(netscoreframex-25,netscoreframey+netscorespacing/2+(drawindex*netscorespacing)-2):zoomto(20,20):valign(0.5):diffuse(getMainColor('positive')):diffusealpha(0) + end, + MouseLeftClickMessageCommand=function(self) + if isOver(self) and nestedTab == 2 then + local urlstringyo = "https://etternaonline.com/song/view/"..eosongid + GAMESTATE:ApplyGameCommand("urlnoexit,"..urlstringyo) + end + end + }, + -- completely gratuitous eo player score link button + Def.Quad{ + InitCommand=function(self) + self:xy(netscoreframex+28,netscoreframey+23+(drawindex*netscorespacing)):zoomto((netscoreframeWidth-15)/1.75,14):halign(0):diffusealpha(0) + end, + MouseLeftClickMessageCommand=function(self) + if isOver(self) and nestedTab == 2 then + local urlstringyo = "https://etternaonline.com/score/view/"..tmpScore.scoreid + GAMESTATE:ApplyGameCommand("urlnoexit,"..urlstringyo) + end + end + }, + + -- gratuity g-another + Def.Quad{ + InitCommand=function(self) + self:xy(netscoreframex+28,netscoreframey+23+(drawindex*netscorespacing)):zoomto(0,0):halign(0):diffusealpha(0) + end, + MouseLeftClickMessageCommand=function(self) + if isOver(self) and nestedTab == 2 then + local urlstringyo = "https://etternaonline.com/avatars/"..tmpScore.avatar + GAMESTATE:ApplyGameCommand("urlnoexit,"..urlstringyo) + end + end + }, --mods (maybe make this be a mouseover later) -mina -- LoadFont("Common normal")..{ -- InitCommand=function(self) diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp index ccbb39831e..50568afc73 100644 --- a/src/DownloadManager.cpp +++ b/src/DownloadManager.cpp @@ -807,10 +807,12 @@ void DownloadManager::RequestChartLeaderBoard(string chartkey) vec.clear(); unordered_set userswithscores; float currentrate = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate; + Message msg("ChartLeaderboardUpdate"); try { auto j = json::parse(req.result); if (j.find("errors") != j.end()) throw exception(); + //msg.SetParam("songid", RString(j.value("songid", "").c_str())); // want songid here or something -mina auto scores = j.find("data"); for (auto scoreJ : (*scores)) { auto score = *(scoreJ.find("attributes")); @@ -841,6 +843,8 @@ void DownloadManager::RequestChartLeaderBoard(string chartkey) tmp.letgo = judgements.value("letGoHold", 0); } tmp.datetime.FromString(score.value("datetime", "0")); + tmp.scoreid = score.value("id", "").c_str(); // i assume this is supposed to be the score id... doesn't work? -mina + tmp.avatar = score.value("avatar", "").c_str(); // also busted or i'm really bad one of the two // filter scores not on the current rate out if enabled... dunno if we need this precision -mina tmp.rate = score.value("rate", 0.0); @@ -875,7 +879,7 @@ void DownloadManager::RequestChartLeaderBoard(string chartkey) //json failed } userswithscores.clear(); // should be ok to free the mem in this way? -mina - MESSAGEMAN->Broadcast("ChartLeaderboardUpdate"); + MESSAGEMAN->Broadcast(msg); // see start of function }; SendRequest("/charts/"+chartkey+"/leaderboards", vector>(), done, true); } @@ -1387,6 +1391,10 @@ class LunaDownloadManager : public Luna lua_setfield(L, -2, "playerRating"); lua_pushstring(L, score.datetime.GetString().c_str()); lua_setfield(L, -2, "datetime"); + lua_pushstring(L, score.scoreid.c_str()); + lua_setfield(L, -2, "scoreid"); + lua_pushstring(L, score.avatar.c_str()); + lua_setfield(L, -2, "avatar"); if (!score.replayData.empty()) { lua_createtable(L, 0, score.replayData.size()); int i = 1; diff --git a/src/DownloadManager.h b/src/DownloadManager.h index ae16f181ed..a720945c5d 100644 --- a/src/DownloadManager.h +++ b/src/DownloadManager.h @@ -121,6 +121,8 @@ class OnlineScore { string username; float playerRating{ 0.0f }; string modifiers; + string scoreid; + string avatar; DateTime datetime; vector> replayData; };