Skip to content

Commit

Permalink
Merge pull request #23 from Nickito12/master
Browse files Browse the repository at this point in the history
Bunch of stuff
  • Loading branch information
MinaciousGrace authored Jan 17, 2017
2 parents 9bf7ee8 + 43fddfb commit abff056
Show file tree
Hide file tree
Showing 9 changed files with 286 additions and 103 deletions.
42 changes: 1 addition & 41 deletions Themes/Til Death/BGAnimations/ScreenNetRoom overlay/default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
85 changes: 85 additions & 0 deletions Themes/Til Death/BGAnimations/_userlist.lua
Original file line number Diff line number Diff line change
@@ -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
156 changes: 149 additions & 7 deletions src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2256,7 +2256,7 @@ bool Profile::CalcTopSSRs(unsigned int qty, int skillset) {

vector<float> topSSRs; //Auxiliary vector to sort faster

//Pointers to the skillset's vectors
//Pointers to the skillset's vectors
vector<HighScore*> *topSSRHighScoresPtr = &topSSRHighScores[skillset];
vector<StepsID> *topSSRStepIdsPtr = &topSSRStepIds[skillset];
vector<SongID> *topSSRSongIdsPtr = &topSSRSongIds[skillset];
Expand Down Expand Up @@ -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;

Expand All @@ -2302,28 +2309,57 @@ 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>(skillset));
int rate = static_cast<int>(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);
topSSRs.insert(topSSRs.begin() + poscounter, ssr);
(*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++;
}
}
}
Expand All @@ -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<float> topSSRs; //Auxiliary vector to sort faster

//Pointers to the skillset's vectors
vector<HighScore*> *topSSRHighScoresPtr = &topSSRHighScores[skillset];
vector<StepsID> *topSSRStepIdsPtr = &topSSRStepIds[skillset];
vector<SongID> *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>(skillset)));
else
topSSRs.push_back(0);
}

float ssr = hs->GetSkillsetSSR(static_cast<Skillset>(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<float>& invector, float rating, float res, int iter) const {
if (invector.size() == 0)
Expand Down
Loading

0 comments on commit abff056

Please sign in to comment.