diff --git a/Themes/Til Death/BGAnimations/ScreenNetRoom overlay/default.lua b/Themes/Til Death/BGAnimations/ScreenNetRoom overlay/default.lua index c7410278e1..e3eea5c2fd 100644 --- a/Themes/Til Death/BGAnimations/ScreenNetRoom overlay/default.lua +++ b/Themes/Til Death/BGAnimations/ScreenNetRoom overlay/default.lua @@ -38,46 +38,6 @@ t[#t+1] = LoadFont("Common Large")..{ t[#t+1] = LoadActor("../_cursor"); t[#t+1] = LoadActor("currenttime"); t[#t+1] = LoadActor("../_halppls"); - - -t[#t+1] = LoadFont("Common Normal") .. { - InitCommand=cmd(xy,SCREEN_WIDTH/3,SCREEN_TOP+15;zoom,0.35;diffuse,getMainColor('positive');maxwidth,SCREEN_WIDTH), - BeginCommand=cmd(queuecommand,"Set"), - SetCommand=function(self) - local str = "" - local top = SCREENMAN:GetTopScreen() - if top:GetUserQty() > 5 then - for i=1,5 do - str = str .. " " .. (top:GetUser(i)) - end - - else - for i=1,top:GetUserQty() do - str = str .. " " .. (top:GetUser(i)) - end - end - self:settext(str) - end, - PlayerJoinedMessageCommand=cmd(queuecommand,"Set"), - PlayerUnjoinedMessageCommand=cmd(queuecommand,"Set"), - UsersUpdateMessageCommand=cmd(queuecommand,"Set"), -} -t[#t+1] = LoadFont("Common Normal") .. { - InitCommand=cmd(xy,SCREEN_WIDTH/3,SCREEN_TOP+25;zoom,0.35;diffuse,getMainColor('positive');maxwidth,SCREEN_WIDTH), - BeginCommand=cmd(queuecommand,"Set"), - SetCommand=function(self) - local str = "" - local top = SCREENMAN:GetTopScreen() - if top:GetUserQty() > 5 then - for i=6,top:GetUserQty() do - str = str .. " " .. (top:GetUser(i)) - end - end - self:settext(str) - end, - PlayerJoinedMessageCommand=cmd(queuecommand,"Set"), - PlayerUnjoinedMessageCommand=cmd(queuecommand,"Set"), - UsersUpdateMessageCommand=cmd(queuecommand,"Set"), -} +t[#t+1] = LoadActor("../_userlist"); return t diff --git a/Themes/Til Death/BGAnimations/ScreenNetSelectBase overlay/default.lua b/Themes/Til Death/BGAnimations/ScreenNetSelectBase overlay/default.lua index 4eb3f4b00d..54971ca04d 100644 --- a/Themes/Til Death/BGAnimations/ScreenNetSelectBase overlay/default.lua +++ b/Themes/Til Death/BGAnimations/ScreenNetSelectBase overlay/default.lua @@ -41,45 +41,6 @@ t[#t+1] = LoadFont("Common Large")..{InitCommand=cmd(xy,5,32;halign,0;valign,1;z t[#t+1] = LoadActor("../_cursor") t[#t+1] = LoadActor("../_halppls") --t[#t+1] = LoadActor("wifesearchbar") - -t[#t+1] = LoadFont("Common Normal") .. { - InitCommand=cmd(xy,SCREEN_WIDTH/3,SCREEN_TOP+15;zoom,0.35;diffuse,getMainColor('positive');maxwidth,SCREEN_WIDTH), - BeginCommand=cmd(queuecommand,"Set"), - SetCommand=function(self) - local str = "" - local top = SCREENMAN:GetTopScreen() - if top:GetUserQty() > 5 then - for i=1,5 do - str = str .. " " .. (top:GetUser(i)) - end - - else - for i=1,top:GetUserQty() do - str = str .. " " .. (top:GetUser(i)) - end - end - self:settext(str) - end, - PlayerJoinedMessageCommand=cmd(queuecommand,"Set"), - PlayerUnjoinedMessageCommand=cmd(queuecommand,"Set"), - UsersUpdateMessageCommand=cmd(queuecommand,"Set"), -} -t[#t+1] = LoadFont("Common Normal") .. { - InitCommand=cmd(xy,SCREEN_WIDTH/3,SCREEN_TOP+25;zoom,0.35;diffuse,getMainColor('positive');maxwidth,SCREEN_WIDTH), - BeginCommand=cmd(queuecommand,"Set"), - SetCommand=function(self) - local str = "" - local top = SCREENMAN:GetTopScreen() - if top:GetUserQty() > 5 then - for i=6,top:GetUserQty() do - str = str .. " " .. (top:GetUser(i)) - end - end - self:settext(str) - end, - PlayerJoinedMessageCommand=cmd(queuecommand,"Set"), - PlayerUnjoinedMessageCommand=cmd(queuecommand,"Set"), - UsersUpdateMessageCommand=cmd(queuecommand,"Set"), -} +t[#t+1] = LoadActor("../_userlist") return t diff --git a/Themes/Til Death/BGAnimations/ScreenNetSelectMusic decorations/profile.lua b/Themes/Til Death/BGAnimations/ScreenNetSelectMusic decorations/profile.lua index 69030b792b..9692c63095 100644 --- a/Themes/Til Death/BGAnimations/ScreenNetSelectMusic decorations/profile.lua +++ b/Themes/Til Death/BGAnimations/ScreenNetSelectMusic decorations/profile.lua @@ -47,7 +47,12 @@ t[#t+1] = Def.Quad{InitCommand=cmd(xy,frameX,frameY;zoomto,frameWidth,offsetY;ha t[#t+1] = LoadFont("Common Normal")..{InitCommand=cmd(xy,frameX+5,frameY+offsetY-9;zoom,0.6;halign,0;diffuse,getMainColor('positive');settext,"Profile Info (WIP)")} -- The input callback for mouse clicks already exists within the tabmanager and redefining it within the local scope does nothing but create confusion - mina -local r = Def.ActorFrame{} +local r = Def.ActorFrame{ + -- Cache the ranking + BeginCommand=function(self) + profile:GetTopSSRValue(250, rankingSkillset) + end, +} local function rankingLabel(i) local ths -- the top highscore object - mina diff --git a/Themes/Til Death/BGAnimations/_userlist.lua b/Themes/Til Death/BGAnimations/_userlist.lua new file mode 100644 index 0000000000..8b5eb841b5 --- /dev/null +++ b/Themes/Til Death/BGAnimations/_userlist.lua @@ -0,0 +1,85 @@ +local usersZoom = 0.35 +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=cmd(queuecommand,"Set"), + InitCommand=cmd(queuecommand,"Set"), + SetCommand=function(self) + top = SCREENMAN:GetTopScreen() + end, + UsersUpdateMessageCommand=cmd(queuecommand,"Set"), +} + + +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=cmd(xy,x,y;zoom,usersZoom;diffuse,posit;queuecommand,"Set"), + SetCommand=function(self) + local num = self:GetName()+0 + qty = top:GetUserQty() + 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=cmd(queuecommand,"Set"), + PlayerUnjoinedMessageCommand=cmd(queuecommand,"Set"), + UsersUpdateMessageCommand=cmd(queuecommand,"Set"), + } + return aux +end + +for i=1,32 do + r[#r+1] = userLabel(i) +end + +return r \ No newline at end of file diff --git a/src/Profile.cpp b/src/Profile.cpp index a2fba678ed..650608639b 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -2256,7 +2256,7 @@ bool Profile::CalcTopSSRs(unsigned int qty, int skillset) { vector topSSRs; //Auxiliary vector to sort faster - //Pointers to the skillset's vectors + //Pointers to the skillset's vectors vector *topSSRHighScoresPtr = &topSSRHighScores[skillset]; vector *topSSRStepIdsPtr = &topSSRStepIds[skillset]; vector *topSSRSongIdsPtr = &topSSRSongIds[skillset]; @@ -2285,10 +2285,17 @@ bool Profile::CalcTopSSRs(unsigned int qty, int skillset) { (*topSSRHighScoresPtr).emplace_back(emptyHighScorePtr); } + struct info { + float ssr; + unsigned int pos; + }; + info temp[40]; + bool replaced = false; + //Build the top FOREACHM(SongID, HighScoresForASong, m_SongHighScores, i) { const SongID& id = i->first; - + if (!id.IsValid()) continue; @@ -2302,16 +2309,39 @@ bool Profile::CalcTopSSRs(unsigned int qty, int skillset) { Steps* psteps = stepsid.ToSteps(id.ToSong(), true); if (!psteps) continue; + for (int i = 0;i < 40;i++) { + temp[i].ssr = 0; + temp[i].pos = 0; + } + for (size_t i = 0; i < hsv.size(); i++) { float ssr = hsv[i].GetSkillsetSSR(static_cast(skillset)); + int rate = static_cast(hsv[i].GetMusicRate() * 20); + + if ((temp[rate - 1]).ssr >= ssr) + continue; //Compare with the smallest value(last one) to see if we need to change the values if (topSSRs[qty - 1] < ssr) { + if ((temp[rate - 1]).ssr != 0) + replaced = true; + + if (replaced) { + (*topSSRStepIdsPtr).erase((*topSSRStepIdsPtr).begin() + temp[rate - 1].pos); + topSSRs.erase(topSSRs.begin() + temp[rate - 1].pos); + (*topSSRSongIdsPtr).erase((*topSSRSongIdsPtr).begin() + temp[rate - 1].pos); + (*topSSRHighScoresPtr).erase((*topSSRHighScoresPtr).begin() + temp[rate - 1].pos); + qty--; + } + + //Find the position of the inmediate smaller value for (poscounter = qty - 1; topSSRs[poscounter - 1] < ssr && poscounter != 0;) { poscounter--; } - counter++; + + temp[rate - 1].pos = poscounter; + temp[rate - 1].ssr = ssr; //insert in the proper place (*topSSRStepIdsPtr).insert((*topSSRStepIdsPtr).begin() + poscounter, stepsid); @@ -2319,11 +2349,17 @@ bool Profile::CalcTopSSRs(unsigned int qty, int skillset) { (*topSSRSongIdsPtr).insert((*topSSRSongIdsPtr).begin() + poscounter, id); (*topSSRHighScoresPtr).insert((*topSSRHighScoresPtr).begin() + poscounter, &(hsv[i])); + //erase last element to keep the same amount of elements(qty) - topSSRs.pop_back(); - (*topSSRStepIdsPtr).pop_back(); - (*topSSRSongIdsPtr).pop_back(); - (*topSSRHighScoresPtr).pop_back(); + if (!replaced) { + counter++; + topSSRs.pop_back(); + (*topSSRStepIdsPtr).pop_back(); + (*topSSRSongIdsPtr).pop_back(); + (*topSSRHighScoresPtr).pop_back(); + } + else + qty++; } } } @@ -2335,6 +2371,112 @@ bool Profile::CalcTopSSRs(unsigned int qty, int skillset) { return false; } +//Todo: Make this not recalc everything -Nick12 +//What's below the return currently crashes +void Profile::TopSSRsAddNewScore(HighScore *hs, StepsID stepsid, SongID songid) { + for (int skillset = 0; skillset < NUM_Skillset; skillset++) {//undefined skillset + if (skillset < 0 || skillset >= NUM_Skillset) + continue; + + if (!songid.IsValid()) + continue; + + if (!stepsid.IsValid() || stepsid.GetStepsType() != StepsType_dance_single) + continue; + + Steps* psteps = stepsid.ToSteps(songid.ToSong(), true); + if (!psteps) + continue; + + + vector topSSRs; //Auxiliary vector to sort faster + + //Pointers to the skillset's vectors + vector *topSSRHighScoresPtr = &topSSRHighScores[skillset]; + vector *topSSRStepIdsPtr = &topSSRStepIds[skillset]; + vector *topSSRSongIdsPtr = &topSSRSongIds[skillset]; + + unsigned int poscounter; + + int qty = (*topSSRHighScoresPtr).size(); + if (qty == 0) + continue; + + for (unsigned int i = 0; i < qty; i++) { + if ((*topSSRHighScoresPtr)[i] != NULL) + topSSRs.push_back((*topSSRHighScoresPtr)[i]->GetSkillsetSSR(static_cast(skillset))); + else + topSSRs.push_back(0); + } + + float ssr = hs->GetSkillsetSSR(static_cast(skillset)); + + //Compare with the smallest value(last one) to see if we need to change the values + if (topSSRs[qty - 1] < ssr) { + + //This isnt finished so we just recalc it all for the moment when we find it needs to + // + for (unsigned int i = 0; i < qty; i++) { + if ((*topSSRSongIdsPtr)[i] == songid && (*topSSRStepIdsPtr)[i] == stepsid && + (*topSSRHighScoresPtr)[i]->GetMusicRate() == hs->GetMusicRate() && + (*topSSRHighScoresPtr)[i] != NULL) { + if (topSSRs[i] >= ssr) + return; + } + } + CalcAllTopSSRs(qty); + return; + // + + //Check for duplicates + bool replace = false; + bool matches = false; + for (unsigned int i = 0; i < qty; i++) { + if ((*topSSRSongIdsPtr)[i] == songid && (*topSSRStepIdsPtr)[i] == stepsid && + (*topSSRHighScoresPtr)[i]->GetMusicRate() == hs->GetMusicRate() && + (*topSSRHighScoresPtr)[i] != NULL) { + matches = true; + if (topSSRs[i] < ssr) { + (*topSSRStepIdsPtr).erase((*topSSRStepIdsPtr).begin() + i); + topSSRs.erase(topSSRs.begin() + i); + (*topSSRSongIdsPtr).erase((*topSSRSongIdsPtr).begin() + i); + (*topSSRHighScoresPtr).erase((*topSSRHighScoresPtr).begin() + i); + qty--; + replace = true; + } + else + break; + } + } + + //If there is a match but we dont replace just skip the whole thing + if (matches && !replace) + continue; + + //Find the position of the inmediate smaller value + for (poscounter = qty - 1; topSSRs[poscounter - 1] < ssr && poscounter != 0;) { + poscounter--; + } + + //insert in the proper place + (*topSSRStepIdsPtr).insert((*topSSRStepIdsPtr).begin() + poscounter, stepsid); + topSSRs.insert(topSSRs.begin() + poscounter, ssr); + (*topSSRSongIdsPtr).insert((*topSSRSongIdsPtr).begin() + poscounter, songid); + (*topSSRHighScoresPtr).insert((*topSSRHighScoresPtr).begin() + poscounter, hs); + + //erase last element to keep the same amount of elements(qty) + if (!replace) { + topSSRs.pop_back(); + (*topSSRStepIdsPtr).pop_back(); + (*topSSRSongIdsPtr).pop_back(); + (*topSSRHighScoresPtr).pop_back(); + } + } + + } + return; +} + float Profile::AggregateScores(vector& invector, float rating, float res, int iter) const { if (invector.size() == 0) diff --git a/src/Profile.h b/src/Profile.h index 1b1accf64b..01fddc8b6a 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -449,6 +449,7 @@ class Profile //TopSSRs bool CalcTopSSRs(unsigned int qty, int skillset); bool CalcAllTopSSRs(unsigned int qty); + void TopSSRsAddNewScore(HighScore *hs, StepsID stepsid, SongID songid); float GetTopSSRMSD(unsigned int rank, int skillset); HighScore* GetTopSSRHighScore(unsigned int rank, int skillset); SongID GetTopSSRSongID(unsigned int rank, int skillset); diff --git a/src/ScreenEvaluation.cpp b/src/ScreenEvaluation.cpp index b82e12c804..bc5ae9aec2 100644 --- a/src/ScreenEvaluation.cpp +++ b/src/ScreenEvaluation.cpp @@ -793,6 +793,13 @@ bool ScreenEvaluation::MenuStart( const InputEventPlus &input ) void ScreenEvaluation::HandleMenuStart() { + Profile *prof = PROFILEMAN->GetProfile( static_cast(0) ); + HighScore * hs = &(m_pStageStats->m_player[0].m_HighScore); + StepsID stepsid; + stepsid.FromSteps(GAMESTATE->m_pCurSteps[PLAYER_1]); + SongID songid; + songid.FromSong(GAMESTATE->m_pCurSong); + prof->TopSSRsAddNewScore(hs, stepsid, songid); StartTransitioningScreen( SM_GoToNextScreen ); } diff --git a/src/ScreenNetSelectBase.cpp b/src/ScreenNetSelectBase.cpp index b9733203cb..ea851ef181 100644 --- a/src/ScreenNetSelectBase.cpp +++ b/src/ScreenNetSelectBase.cpp @@ -494,6 +494,14 @@ class LunaScreenNetSelectBase : public Luna lua_pushstring(L, ""); return 1; } + static int GetUserState(T* p, lua_State *L) + { + if (IArg(1) <= p->ToUsers()->size() && IArg(1) >= 1) + lua_pushnumber(L, NSMAN->m_PlayerStatus[NSMAN->m_ActivePlayer[IArg(1) - 1]] ); + else + lua_pushnumber(L, 0); + return 1; + } public: LunaScreenNetSelectBase() { @@ -502,6 +510,7 @@ class LunaScreenNetSelectBase : public Luna ADD_METHOD(ChatboxInput); ADD_METHOD(ChatboxVisible); ADD_METHOD(GetUserQty); + ADD_METHOD(GetUserState); } }; diff --git a/src/ScreenNetSelectMusic.cpp b/src/ScreenNetSelectMusic.cpp index 87a3e7722a..09ca839989 100644 --- a/src/ScreenNetSelectMusic.cpp +++ b/src/ScreenNetSelectMusic.cpp @@ -211,23 +211,36 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM ) Song* CurSong = m_MusicWheel.GetSelectedSong(); if(CurSong != NULL ) - if( ( !CurSong->GetTranslitArtist().CompareNoCase( NSMAN->m_sArtist ) ) && - ( !CurSong->GetTranslitMainTitle().CompareNoCase( NSMAN->m_sMainTitle ) ) && - ( !CurSong->GetTranslitSubTitle().CompareNoCase( NSMAN->m_sSubTitle ) ) ) - { - switch ( NSMAN->m_iSelectMode ) + ( !CurSong->GetTranslitMainTitle().CompareNoCase( NSMAN->m_sMainTitle ) ) && + ( !CurSong->GetTranslitSubTitle().CompareNoCase( NSMAN->m_sSubTitle ) ) ) { - case 0: - case 1: - NSMAN->m_iSelectMode = 0; - NSMAN->SelectUserSong(); - break; - case 2: // Proper starting of song - case 3: // Blind starting of song - StartSelectedSong(); - goto done; + switch ( NSMAN->m_iSelectMode ) + { + case 0: + case 1: + NSMAN->m_iSelectMode = 0; + NSMAN->SelectUserSong(); + break; + case 2: // Proper starting of song + case 3: // Blind starting of song + StartSelectedSong(); + goto done; + } + } + else { + FOREACH_ENUM(Skillset, i) { + GAMESTATE->SSFilterLowerBounds[i] = 0; + GAMESTATE->SSFilterUpperBounds[i] = 0; + } + m_MusicWheel.ReloadSongList(false, ""); + } + else { + FOREACH_ENUM(Skillset, i) { + GAMESTATE->SSFilterLowerBounds[i] = 0; + GAMESTATE->SSFilterUpperBounds[i] = 0; } + m_MusicWheel.ReloadSongList(false, ""); } m_MusicWheel.ReloadSongList(false, "");