Skip to content

Commit eae3632

Browse files
kill obsolete profile tab code and do some further polish
1 parent aa5a8cb commit eae3632

File tree

3 files changed

+19
-249
lines changed

3 files changed

+19
-249
lines changed

Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/profile.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ local rankingTitleWidth = (rankingWidth/(#ms.SkillSets + 1))
4040

4141
if GAMESTATE:IsPlayerEnabled(PLAYER_1) then
4242
profile = GetPlayerOrMachineProfile(PLAYER_1)
43+
profile:SortAllSSRs() -- should be fine this way now - mina
4344
end
4445

4546

@@ -72,7 +73,6 @@ local function rankingLabel(i)
7273
if update then
7374
self:diffuse(getMainColor("positive"))
7475
self:settext(((rankingPage-1)*25)+i..".")
75-
profile:SortAllSSRs()
7676
ths = profile:GetTopSSRHighScore(i+(scorestodisplay*(rankingPage-1)), rankingSkillset)
7777
ck = ths:GetChartKey()
7878
thssong = SONGMAN:GetSongByChartKey(ck)
@@ -159,8 +159,8 @@ local function rankingLabel(i)
159159
InitCommand=cmd(xy,frameX+rankingX+310,frameY+rankingY+110-(11-i)*10;halign,0.5;zoom,0.25;diffuse,getMainColor('positive');maxwidth,rankingWidth*4-160),
160160
SetCommand=function(self)
161161
if update and ths then
162-
if (thsteps ~= nil) then
163-
local diff = thsteps:GetDifficulty()
162+
if (thssteps ~= nil) then
163+
local diff = thssteps:GetDifficulty()
164164
self:diffuse(byDifficulty(diff))
165165
self:settext(getShortDifficulty(diff))
166166
end
@@ -190,8 +190,7 @@ local function rankingLabel(i)
190190
if update and ths then
191191
if isOver(self) then
192192
local whee = SCREENMAN:GetTopScreen():GetMusicWheel()
193-
local ssrsong = profile:GetSongFromSSR(i+(scorestodisplay*(rankingPage-1)), rankingSkillset)
194-
whee:SelectSong(ssrsong)
193+
whee:SelectSong(thssong)
195194
end
196195
end
197196
end
@@ -209,14 +208,14 @@ local function rankingButton(i)
209208
self:diffusealpha(1)
210209
else
211210
self:diffusealpha(0.35)
212-
end;
211+
end
213212
end,
214213
MouseLeftClickMessageCommand=function(self)
215214
if isOver(self) then
216215
rankingSkillset = i-1
217216
rankingPage = 1
218217
MESSAGEMAN:Broadcast("UpdateRanking")
219-
end;
218+
end
220219
end,
221220
UpdateRankingMessageCommand=cmd(queuecommand,"Set"),
222221
},

src/Profile.cpp

Lines changed: 13 additions & 241 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,238 +2594,31 @@ void Profile::RecalculateSSRs(bool OnlyOld) {
25942594
}
25952595

25962596

2597-
RString Profile::GetTopSSRSongName(unsigned int rank, int skillset) {
2598-
RString ck = GetTopSSRChartkey(rank, skillset);
2599-
Song* pSong = SONGMAN->GetSongByChartkey(ck);
2600-
if (!pSong)
2601-
return "";
2602-
2603-
return pSong->GetMainTitle();
2604-
}
2605-
float Profile::GetTopSSRValue(unsigned int rank, int skillset) {
2606-
if (rank <= 0)
2607-
rank = 1;
2608-
HighScore *highScorePtr = GetTopSSRHighScore(rank, skillset);
2597+
float Profile::GetTopSSRValue(unsigned int rank, int ss) {
2598+
if (rank < 0)
2599+
rank = 0;
2600+
HighScore *highScorePtr = GetTopSSRHighScore(rank, ss);
26092601
//Empty HighScore Pointer = NULL then return 0
26102602
if(highScorePtr == NULL)
26112603
return 0.f;
26122604

2613-
if (skillset >= 0 && skillset < NUM_Skillset)
2614-
return highScorePtr->GetSkillsetSSR(static_cast<Skillset>(skillset));
2605+
if (ss >= 0 && ss < NUM_Skillset && rank < pscores.TopSSRs[ss].size())
2606+
return highScorePtr->GetSkillsetSSR(static_cast<Skillset>(ss));
26152607

26162608
//Undefined skillset
26172609
return 0.f;
26182610
}
2619-
Song* Profile::GetTopSSRSong(unsigned int rank, int skillset) {
2620-
RString ck = GetTopSSRChartkey(rank, skillset);
2621-
return SONGMAN->GetSongByChartkey(ck);
2622-
}
2623-
Steps* Profile::GetTopSSRSteps(unsigned int rank, int skillset) {
2624-
RString ck = GetTopSSRChartkey(rank, skillset);
2625-
return SONGMAN->GetStepsByChartkey(ck);
2626-
}
2627-
RString Profile::GetTopSSRChartkey(unsigned int rank, int skillset) {
2628-
if (rank <= 0)
2629-
rank = 1;
2630-
if (rank > static_cast<unsigned int>(topSSRChartkeys[skillset].size()))
2631-
if (CalcTopSSRs(rank, skillset) == false) {
2632-
return "";
2633-
}
26342611

2635-
LOG->Warn(pscores.TopSSRs[skillset][rank - 1]->GetHistoricChartKey());
2636-
2637-
if (skillset >= 0 && skillset < NUM_Skillset)
2638-
return pscores.TopSSRs[skillset][rank - 1]->GetHistoricChartKey();
2639-
2640-
//Undefined skillset
2641-
return "";
2642-
}
26432612
HighScore* Profile::GetTopSSRHighScore(unsigned int rank, int ss) {
2644-
if (rank <= 0)
2645-
rank = 1;
2613+
if (rank < 0)
2614+
rank = 0;
26462615

2647-
pscores.SortTopSSRPtrs(static_cast<Skillset>(ss));
2648-
if (ss >= 0 && ss < NUM_Skillset && rank < pscores.TopSSRs[ss].size()) {
2649-
auto aa = &(*pscores.TopSSRs[ss][rank - 1]);
2650-
return aa;
2651-
}
2616+
if (ss >= 0 && ss < NUM_Skillset && rank < pscores.TopSSRs[ss].size())
2617+
return &(*pscores.TopSSRs[ss][rank]);
26522618

26532619
return NULL;
26542620
}
26552621

2656-
// Todo: Make it only iterate once - Nick12
2657-
bool Profile::CalcAllTopSSRs(unsigned int qty) {
2658-
bool ret = true;
2659-
for(int i = 0; i < NUM_Skillset; i++)
2660-
ret = CalcTopSSRs(qty, i) && ret;
2661-
return ret;
2662-
}
2663-
bool Profile::CalcTopSSRs(unsigned int qty, int skillset) {
2664-
//undefined skillset
2665-
if (skillset < 0 || skillset >= NUM_Skillset)
2666-
return false;
2667-
2668-
vector<float> topSSRs; //Auxiliary vector to sort faster
2669-
2670-
//Pointers to the skillset's vectors
2671-
vector<vector<HighScore>*> *topSSRHighScoreListsPtr = &topSSRHighScoreLists[skillset];
2672-
vector<unsigned int> *topSSRHighScoreIndexsPtr = &topSSRHighScoreIndexs[skillset];
2673-
vector<RString> *topSSRChartkeysPtr = &topSSRChartkeys[skillset];
2674-
2675-
//Counter to see if we meet the required ranking size
2676-
unsigned int counter = 0;
2677-
//Axi
2678-
unsigned int poscounter;
2679-
2680-
//Initialize vectors
2681-
HighScore* emptyHighScorePtr = NULL;
2682-
vector<HighScore>* emptyHighScoreListsPtr = NULL;
2683-
(*topSSRChartkeysPtr).clear();
2684-
(*topSSRHighScoreListsPtr).clear();
2685-
(*topSSRHighScoreIndexsPtr).clear();
2686-
2687-
//Empty the vectors if qty=0
2688-
if (qty == 0)
2689-
return true;
2690-
2691-
for (unsigned int i = 0; i < qty; i++) {
2692-
topSSRs.emplace_back(0);
2693-
(*topSSRChartkeysPtr).emplace_back("");
2694-
(*topSSRHighScoreListsPtr).emplace_back(emptyHighScoreListsPtr);
2695-
(*topSSRHighScoreIndexsPtr).emplace_back(0);
2696-
}
2697-
2698-
struct info {
2699-
float ssr;
2700-
unsigned int pos;
2701-
};
2702-
info temp[60];
2703-
for (int i = 0;i < 60;i++) {
2704-
temp[i].ssr = 0;
2705-
temp[i].pos = 0;
2706-
}
2707-
2708-
bool replaced = false;
2709-
2710-
//Build the top
2711-
FOREACHM(SongID, HighScoresForASong, m_SongHighScores, i) {
2712-
const SongID& id = i->first;
2713-
2714-
HighScoresForASong& hsfas = i->second;
2715-
FOREACHM(StepsID, HighScoresForASteps, hsfas.m_StepsHighScores, j) {
2716-
HighScoresForASteps& zz = j->second;
2717-
const StepsID& stepsid = j->first;
2718-
vector<HighScore>& hsv = zz.hsl.vHighScores;
2719-
2720-
Steps* psteps = SONGMAN->GetStepsByChartkey(stepsid);
2721-
if (!psteps)
2722-
continue;
2723-
2724-
if (!psteps->IsRecalcValid())
2725-
continue;
2726-
2727-
for (int i = 0;i < 60;i++) {
2728-
temp[i].ssr = 0;
2729-
temp[i].pos = 0;
2730-
}
2731-
2732-
for (size_t i = 0; i < hsv.size(); i++) {
2733-
float ssr = hsv[i].GetSkillsetSSR(static_cast<Skillset>(skillset));
2734-
int rate = static_cast<int>(hsv[i].GetMusicRate() * 20);
2735-
2736-
if ((temp[rate - 1]).ssr >= ssr)
2737-
continue;
2738-
//Compare with the smallest value(last one) to see if we need to change the values
2739-
if (topSSRs[qty - 1] < ssr) {
2740-
2741-
if ((temp[rate - 1]).ssr != 0)
2742-
replaced = true;
2743-
else
2744-
replaced = false;
2745-
2746-
2747-
if (replaced) {
2748-
topSSRs.erase(topSSRs.begin() + temp[rate - 1].pos);
2749-
(*topSSRChartkeysPtr).erase((*topSSRChartkeysPtr).begin() + temp[rate - 1].pos);
2750-
(*topSSRHighScoreListsPtr).erase((*topSSRHighScoreListsPtr).begin() + temp[rate - 1].pos);
2751-
(*topSSRHighScoreIndexsPtr).erase((*topSSRHighScoreIndexsPtr).begin() + temp[rate - 1].pos);
2752-
//qty--;
2753-
}
2754-
2755-
2756-
//Find the position of the inmediate smaller value
2757-
for (poscounter = qty - 1; topSSRs[poscounter - 1] < ssr && poscounter != 0;) {
2758-
poscounter--;
2759-
}
2760-
2761-
temp[rate - 1].pos = poscounter;
2762-
temp[rate - 1].ssr = ssr;
2763-
2764-
//insert in the proper place
2765-
topSSRs.emplace(topSSRs.begin() + poscounter, ssr);
2766-
(*topSSRChartkeysPtr).emplace((*topSSRChartkeysPtr).begin() + poscounter, stepsid.GetKey());
2767-
(*topSSRHighScoreListsPtr).emplace((*topSSRHighScoreListsPtr).begin() + poscounter, &hsv);
2768-
(*topSSRHighScoreIndexsPtr).emplace((*topSSRHighScoreIndexsPtr).begin() + poscounter, i+1);
2769-
2770-
2771-
//erase last element to keep the same amount of elements(qty)
2772-
if (!replaced) {
2773-
counter++;
2774-
topSSRs.pop_back();
2775-
(*topSSRChartkeysPtr).pop_back();
2776-
(*topSSRHighScoreListsPtr).pop_back();
2777-
(*topSSRHighScoreIndexsPtr).pop_back();
2778-
}
2779-
}
2780-
}
2781-
}
2782-
}
2783-
2784-
//If we didnt find enough ssr's to fill qty elements return false
2785-
if (counter >= qty)
2786-
return true;
2787-
return false;
2788-
}
2789-
2790-
2791-
void Profile::TopSSRsAddNewScore(HighScore *hs, StepsID stepsid, SongID songid) {
2792-
Steps* psteps = SONGMAN->GetStepsByChartkey(stepsid);
2793-
if (!psteps)
2794-
return;
2795-
2796-
if (!psteps->IsRecalcValid())
2797-
return;
2798-
2799-
for (int skillset = 0; skillset < NUM_Skillset; skillset++) {
2800-
//Pointers to the skillset's vectors
2801-
vector<unsigned int> *topSSRHighScoreIndexsPtr = &topSSRHighScoreIndexs[skillset];
2802-
vector<vector<HighScore>*> *topSSRHighScoreListsPtr = &topSSRHighScoreLists[skillset];
2803-
vector<RString> *topSSRChartkeyPtr = &topSSRChartkeys[skillset];
2804-
2805-
unsigned int qty = (*topSSRChartkeyPtr).size();
2806-
if (qty == 0)
2807-
continue;
2808-
2809-
float ssr = hs->GetSkillsetSSR(static_cast<Skillset>(skillset));
2810-
if (ssr == 0)
2811-
return;
2812-
2813-
2814-
//Compare with the smallest value(last one) to see if we need to change the values
2815-
if ( ((*topSSRHighScoreIndexsPtr)[qty - 1] != 0 ? (*topSSRHighScoreLists[skillset][qty - 1])[topSSRHighScoreIndexs[skillset][qty-1] - 1].GetSkillsetSSR(static_cast<Skillset>(skillset)) : 0) < ssr) {
2816-
2817-
2818-
//Screw it lets just try always recalculating to see if this works at the very least
2819-
//Todo:Make this not recalc all the time -Nick12
2820-
CalcAllTopSSRs(qty);
2821-
return;
2822-
}
2823-
2824-
}
2825-
return;
2826-
}
2827-
2828-
28292622
float Profile::AggregateScores(vector<float>& invector, float rating, float res, int iter) const {
28302623
if (invector.size() == 0)
28312624
return 0.f;
@@ -3508,25 +3301,12 @@ class LunaProfile : public Luna<Profile>
35083301
lua_pushnil(L);
35093302
return 1;
35103303
}
3511-
static int GetLastPlayedCourse(T* p, lua_State *L)
3512-
{
3513-
Course *pC = p->m_lastCourse.ToCourse();
3514-
if (pC)
3515-
pC->PushSelf(L);
3516-
else
3517-
lua_pushnil(L);
3518-
return 1;
3519-
}
3520-
static int GetTopSSRSongName(T* p, lua_State *L) {
3521-
lua_pushstring(L, p->GetTopSSRSongName(IArg(1), IArg(2)));
3522-
return 1;
3523-
}
35243304
static int GetTopSSRValue(T* p, lua_State *L) {
3525-
lua_pushnumber(L, p->GetTopSSRValue(IArg(1), IArg(2)));
3305+
lua_pushnumber(L, p->GetTopSSRValue(IArg(1) - 1, IArg(2)));
35263306
return 1;
35273307
}
35283308
static int GetTopSSRHighScore(T* p, lua_State *L) {
3529-
HighScore* ths = p->GetTopSSRHighScore(IArg(1), IArg(2));
3309+
HighScore* ths = p->GetTopSSRHighScore(IArg(1) - 1, IArg(2));
35303310
if (ths)
35313311
ths->PushSelf(L);
35323312
else
@@ -3538,14 +3318,7 @@ class LunaProfile : public Luna<Profile>
35383318
lua_pushnumber(L, p->m_fPlayerSkillsets[lel]);
35393319
return 1;
35403320
}
3541-
static int GetSongFromSSR(T* p, lua_State *L) {
3542-
p->GetTopSSRSong(IArg(1), IArg(2))->PushSelf(L);
3543-
return 1;
3544-
}
3545-
static int GetStepsFromSSR(T* p, lua_State *L) {
3546-
p->GetTopSSRSteps(IArg(1), IArg(2))->PushSelf(L);
3547-
return 1;
3548-
}
3321+
35493322
static int SortAllSSRs(T* p, lua_State *L) {
35503323
for(size_t i = 0; i < NUM_Skillset; ++i)
35513324
p->pscores.SortTopSSRPtrs(static_cast<Skillset>(i));
@@ -3643,7 +3416,6 @@ class LunaProfile : public Luna<Profile>
36433416
ADD_METHOD( GetTotalDancePoints );
36443417
ADD_METHOD( GetUserTable );
36453418
ADD_METHOD( GetLastPlayedSong );
3646-
ADD_METHOD( GetLastPlayedCourse );
36473419
ADD_METHOD( GetGUID );
36483420
ADD_METHOD( GetPlayerRating );
36493421
ADD_METHOD( GetPlayerSkillsetRating );

src/ScreenEvaluation.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,6 @@ void ScreenEvaluation::HandleMenuStart()
799799
stepsid.FromSteps(GAMESTATE->m_pCurSteps[PLAYER_1]);
800800
SongID songid;
801801
songid.FromSong(GAMESTATE->m_pCurSong);
802-
prof->TopSSRsAddNewScore(hs, stepsid, songid);
803802
StartTransitioningScreen( SM_GoToNextScreen );
804803
}
805804

0 commit comments

Comments
 (0)