Skip to content

Commit

Permalink
massive updates to theme profile viewer including functionality to in…
Browse files Browse the repository at this point in the history
…validate scores as the player chooses
  • Loading branch information
MinaciousGrace committed Jan 8, 2017
1 parent c16d57d commit 0a364c1
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 36 deletions.
129 changes: 106 additions & 23 deletions Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/profile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ local frameY = 45
local frameWidth = capWideScale(320,400)
local frameHeight = 350
local fontScale = 0.4
local scorestodisplay = 25
local distY = 15
local offsetX = 10
local offsetY = 20
local rankingSkillset=0
local rankingPage=1
local rankingWidth = 250
local rankingX = capWideScale(75,90)
local rankingY = capWideScale(200,180)
local rankingWidth = frameWidth-50
local rankingX = capWideScale(25,45)
local rankingY = capWideScale(80,60)
local rankingTitleWidth = (rankingWidth/(#ms.SkillSets + 1))

if GAMESTATE:IsPlayerEnabled(PLAYER_1) then
Expand Down Expand Up @@ -61,38 +62,110 @@ local r = Def.ActorFrame{
}

local function rankingLabel(i)
local ths -- the top highscore object - mina
local t = Def.ActorFrame{
InitCommand=cmd(visible, false),
UpdateRankingMessageCommand=function(self)
if rankingSkillset > 0 then
self:visible(true)
else
self:visible(false)
end
end,
LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+rankingX,frameY+rankingY+110-(11-i)*10;halign,0;zoom,0.25;diffuse,getMainColor('positive');maxwidth,160),
SetCommand=function(self)
local a=profile:GetTopSSRValue(i+(10*(rankingPage-1)), rankingSkillset)
if a==0 then
self:settext( ' - ' )
else
self:settextf("%5.2f", a)
if update and rankingSkillset > 0 then
ths = profile:GetTopSSRHighScore(i+(20*(rankingPage-1)), rankingSkillset)
if ths then
local a=profile:GetTopSSRValue(i+(20*(rankingPage-1)), rankingSkillset)
self:settextf("%5.2f", a)
if not ths:GetEtternaValid() then
self:diffuse(byJudgment("TapNoteScore_Miss"))
else
self:diffuse(getMainColor('positive'))
end
else
self:settext( ' - ' )
end
end
end,
UpdateRankingMessageCommand=cmd(queuecommand,"Set"),
},
LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+rankingX+40,frameY+rankingY+110-(11-i)*10;halign,0;zoom,0.25;diffuse,getMainColor('positive');maxwidth,rankingWidth*4-160),
InitCommand=cmd(xy,frameX+rankingX+40,frameY+rankingY+110-(11-i)*10;halign,0;zoom,0.25;diffuse,getMainColor('positive');maxwidth,rankingWidth*2.5-160),
SetCommand=function(self)
local a=profile:GetTopSSRValue(i+(10*(rankingPage-1)), rankingSkillset)
if a==0 then
if ths then
local a=profile:GetTopSSRValue(i+(20*(rankingPage-1)), rankingSkillset)
self:settext(profile:GetTopSSRSongName(i+(20*(rankingPage-1)), rankingSkillset) )
if not ths:GetEtternaValid() then
self:diffuse(byJudgment("TapNoteScore_Miss"))
else
self:diffuse(getMainColor('positive'))
end
else
self:settext( ' ' )
end
end,
UpdateRankingMessageCommand=cmd(queuecommand,"Set"),
},
LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+rankingX+240,frameY+rankingY+110-(11-i)*10;halign,0.5;zoom,0.25;diffuse,getMainColor('positive');maxwidth,rankingWidth*4-160),
SetCommand=function(self)
if ths then
local ratestring = string.format("%.2f", ths:GetMusicRate()):gsub("%.?0+$", "").."x"
self:settext(ratestring)
if not ths:GetEtternaValid() then
self:diffuse(byJudgment("TapNoteScore_Miss"))
else
self:diffuse(getMainColor('positive'))
end
else
self:settext( ' - ' )
end
end,
UpdateRankingMessageCommand=cmd(queuecommand,"Set"),
},
LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+rankingX+290,frameY+rankingY+110-(11-i)*10;halign,0.5;zoom,0.25;diffuse,getMainColor('positive');maxwidth,rankingWidth*4-160),
SetCommand=function(self)
if ths then
self:settextf("%5.2f%%", ths:GetWifeScore()*100)
if not ths:GetEtternaValid() then
self:diffuse(byJudgment("TapNoteScore_Miss"))
else
self:diffuse(getGradeColor(ths:GetWifeGrade()))
end
else
self:settext(profile:GetTopSSRSongName(i+(10*(rankingPage-1)), rankingSkillset) )
self:settext( ' - ' )
end
end,
UpdateRankingMessageCommand=cmd(queuecommand,"Set"),
},
Def.Quad{
InitCommand=cmd(xy,rankingX+rankingWidth/2,frameY+rankingY+105-(11-i)*10;zoomto,rankingWidth,10;halign,0.5;valign,0;diffuse,getMainColor('frames');diffusealpha,0),
MouseLeftClickMessageCommand=function(self)
if ths then
if isOver(self) then
ths:ToggleEtternaValidation()
MESSAGEMAN:Broadcast("UpdateRanking")
if ths:GetEtternaValid() then
ms.ok("Score Revalidated")
else
ms.ok("Score Invalidated")
end
end
end
end
}
}
return t
end

local function rankingButton(i)
local t = Def.ActorFrame{
Def.Quad{
InitCommand=cmd(xy,frameX+rankingX+(i-1+i*(1/(1+#ms.SkillSets)))*rankingTitleWidth,frameY+rankingY-30;zoomto,rankingTitleWidth,30;halign,0;valign,0;diffuse,getMainColor('frames');diffusealpha,0.35),
InitCommand=cmd(xy,frameX+rankingX+(i-1+i*(1/(1+#ms.SkillSets)))*rankingTitleWidth,frameY+rankingY-30;zoomto,rankingTitleWidth,30;halign,0.5;valign,0;diffuse,getMainColor('frames');diffusealpha,0.35),
SetCommand=function(self)
if i-1 == rankingSkillset then
self:diffusealpha(0.7)
Expand All @@ -109,7 +182,7 @@ local function rankingButton(i)
UpdateRankingMessageCommand=cmd(queuecommand,"Set"),
},
LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+rankingX+(i-1+i*(1/(1+#ms.SkillSets)))*rankingTitleWidth,frameY+rankingY-15;halign,0;diffuse,getMainColor('positive');maxwidth,rankingTitleWidth;maxheight,25),
InitCommand=cmd(xy,frameX+rankingX+(i-1+i*(1/(1+#ms.SkillSets)))*rankingTitleWidth,frameY+rankingY-15;halign,0.5;diffuse,getMainColor('positive');maxwidth,rankingTitleWidth;maxheight,25),
BeginCommand=function(self)
self:settext(ms.SkillSets[i])
end,
Expand All @@ -120,7 +193,7 @@ end


r[#r+1] = Def.Quad{
InitCommand=cmd(xy,frameX+rankingX+rankingWidth,frameY+rankingY+40;zoomto,40,20;halign,0;valign,0;diffuse,getMainColor('frames');diffusealpha,0.35),
InitCommand=cmd(xy,frameX+frameWidth-30,frameY+rankingY+265;zoomto,40,20;halign,0.5;valign,0;diffuse,getMainColor('frames');diffusealpha,0.35),
MouseLeftClickMessageCommand=function(self)
if isOver(self) then
--Move right
Expand All @@ -134,14 +207,14 @@ r[#r+1] = Def.Quad{
end;
}
r[#r+1] = LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+rankingX+rankingWidth,frameY+rankingY+50;halign,0;zoom,0.3;diffuse,getMainColor('positive')),
InitCommand=cmd(xy,frameX+frameWidth-30,frameY+rankingY+275;halign,0.5;zoom,0.3;diffuse,getMainColor('positive')),
BeginCommand=function(self)
self:settext( 'Next' )
end,
}

r[#r+1] = Def.Quad{
InitCommand=cmd(xy,frameX+rankingX-75,frameY+rankingY+40;zoomto,65,20;halign,0;valign,0;diffuse,getMainColor('frames');diffusealpha,0.35),
InitCommand=cmd(xy,frameX+40,frameY+rankingY+265;zoomto,65,20;halign,0.5;valign,0;diffuse,getMainColor('frames');diffusealpha,0.35),
MouseLeftClickMessageCommand=function(self)
if isOver(self) then
--Move left
Expand All @@ -155,15 +228,18 @@ r[#r+1] = Def.Quad{
end;
}
r[#r+1] = LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+rankingX-75,frameY+rankingY+50;halign,0;zoom,0.3;diffuse,getMainColor('positive')),
InitCommand=cmd(xy,frameX+40,frameY+rankingY+275;halign,0.5;zoom,0.3;diffuse,getMainColor('positive')),
BeginCommand=function(self)
self:settext( 'Previous' )
end,
}
for i=1,10 do
for i=1,scorestodisplay do
r[#r+1] = rankingLabel(i)
end
for i=1,#ms.SkillSets do

-- Technically the "overall" skillset is used for single value display during music select/eval and isn't factored in to the profile rating
-- Only the specific skillsets are, and so overall should be used to display the specific skillset breakdowns separately - mina
for i=1,#ms.SkillSets do
r[#r+1] = rankingButton(i)
end

Expand All @@ -172,8 +248,15 @@ t[#t+1] = r
-- should make a highlight or something to indicate the greatest value at a quick glance
local function littlebits(i)
local t = Def.ActorFrame{
UpdateRankingMessageCommand=function(self)
if rankingSkillset == 0 then
self:visible(true)
else
self:visible(false)
end
end,
LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+(frameWidth/2)-100,frameY+20 + 22*i;halign,0;zoom,0.5;diffuse,getMainColor('positive')),
InitCommand=cmd(xy,frameX+30,frameY+120 + 22*i;halign,0;zoom,0.5;diffuse,getMainColor('positive')),
BeginCommand=cmd(queuecommand,"Set"),
SetCommand=function(self)
self:settext(ms.SkillSets[i]..":")
Expand All @@ -182,7 +265,7 @@ local function littlebits(i)
PlayerUnjoinedMessageCommand=cmd(queuecommand,"Set"),
},
LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+(frameWidth/2)+90,frameY+20 + 22*i;halign,1;zoom,0.5),
InitCommand=cmd(xy,frameX+270,frameY+120 + 22*i;halign,1;zoom,0.5),
BeginCommand=cmd(queuecommand,"Set"),
SetCommand=function(self)
local rating = profile:GetPlayerSkillsetRating(i)
Expand All @@ -196,7 +279,7 @@ local function littlebits(i)
return t
end

for i=1,#ms.SkillSets do
for i=2,#ms.SkillSets do
t[#t+1] = littlebits(i)
end

Expand Down
11 changes: 11 additions & 0 deletions Themes/Til Death/Scripts/WifeSundries.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ ms.SkillSets = {
"Technical"
}

ms.SkillSetsShort = {
"Overall",
"Stream",
"JS",
"HS",
"Stam",
"Jack Speed",
"Jack Stam",
"Tech"
}

local PersistentSearch

function GetPersistentSearch()
Expand Down
13 changes: 13 additions & 0 deletions src/HighScore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct HighScoreImpl
float fSurviveSeconds;
float fMusicRate;
float fJudgeScale;
bool bEtternaValid;
vector<float> vOffsetVector;
vector<int> vNoteRowVector;
unsigned int iMaxCombo; // maximum combo obtained [SM5 alpha 1a+]
Expand Down Expand Up @@ -171,6 +172,7 @@ HighScoreImpl::HighScoreImpl()
fWifeScore = 0.f;
fMusicRate = 0.f;
fJudgeScale = 0.f;
bEtternaValid = true;
vOffsetVector.clear();
vNoteRowVector.clear();
fSurviveSeconds = 0.f;
Expand Down Expand Up @@ -205,6 +207,7 @@ XNode *HighScoreImpl::CreateNode() const
pNode->AppendChild( "WifeScore", fWifeScore);
pNode->AppendChild( "Rate", fMusicRate);
pNode->AppendChild( "JudgeScale", fJudgeScale);
pNode->AppendChild( "EtternaValid", bEtternaValid);
pNode->AppendChild( "Offsets", OffsetsToString(vOffsetVector));
pNode->AppendChild( "NoteRows", NoteRowsToString(vNoteRowVector));
pNode->AppendChild( "SurviveSeconds", fSurviveSeconds );
Expand Down Expand Up @@ -254,6 +257,7 @@ void HighScoreImpl::LoadFromNode(const XNode *pNode)
pNode->GetChildValue("WifeScore", fWifeScore);
pNode->GetChildValue("Rate", fMusicRate);
pNode->GetChildValue("JudgeScale", fJudgeScale);
pNode->GetChildValue("EtternaValid", bEtternaValid);
pNode->GetChildValue("Offsets", s); vOffsetVector = OffsetsToVector(s);
pNode->GetChildValue("NoteRows", s); vNoteRowVector = NoteRowsToVector(s);
pNode->GetChildValue("SurviveSeconds", fSurviveSeconds);
Expand Down Expand Up @@ -343,6 +347,7 @@ float HighScore::GetPercentDP() const { return m_Impl->fPercentDP; }
float HighScore::GetWifeScore() const { return m_Impl->fWifeScore; }
float HighScore::GetMusicRate() const { return m_Impl->fMusicRate; }
float HighScore::GetJudgeScale() const { return m_Impl->fJudgeScale; }
bool HighScore::GetEtternaValid() const { return m_Impl->bEtternaValid; }
float HighScore::GetSurviveSeconds() const { return m_Impl->fSurviveSeconds; }
float HighScore::GetSurvivalSeconds() const { return GetSurviveSeconds() + GetLifeRemainingSeconds(); }
RString HighScore::GetModifiers() const { return m_Impl->sModifiers; }
Expand All @@ -369,6 +374,7 @@ void HighScore::SetPercentDP( float f ) { m_Impl->fPercentDP = f; }
void HighScore::SetWifeScore(float f) {m_Impl->fWifeScore = f;}
void HighScore::SetMusicRate(float f) { m_Impl->fMusicRate = f; }
void HighScore::SetJudgeScale(float f) { m_Impl->fJudgeScale = f; }
void HighScore::SetEtternaValid(bool b) { m_Impl->bEtternaValid = b; }
void HighScore::SetOffsetVector(vector<float> v) { m_Impl->vOffsetVector = v; }
void HighScore::SetNoteRowVector(vector<int> v) { m_Impl->vNoteRowVector = v; }
void HighScore::SetAliveSeconds( float f ) { m_Impl->fSurviveSeconds = f; }
Expand Down Expand Up @@ -766,12 +772,17 @@ class LunaHighScore: public Luna<HighScore>
lua_pushnumber(L, p->GetSkillsetSSR(lel));
return 1;
}
static int ToggleEtternaValidation(T* p, lua_State *L) {
p->SetEtternaValid(!p->GetEtternaValid());
return 1;
}

DEFINE_METHOD( GetGrade, GetGrade() )
DEFINE_METHOD( GetWifeGrade, GetWifeGrade())
DEFINE_METHOD( ConvertDpToWife, ConvertDpToWife())
DEFINE_METHOD( GetStageAward, GetStageAward() )
DEFINE_METHOD( GetPeakComboAward, GetPeakComboAward() )
DEFINE_METHOD( GetEtternaValid , GetEtternaValid())
LunaHighScore()
{
ADD_METHOD( GetName );
Expand All @@ -796,6 +807,8 @@ class LunaHighScore: public Luna<HighScore>
ADD_METHOD( GetMaxCombo );
ADD_METHOD( GetStageAward );
ADD_METHOD( GetPeakComboAward );
ADD_METHOD( ToggleEtternaValidation );
ADD_METHOD( GetEtternaValid );
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/HighScore.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct HighScore
float GetWifeScore() const;
float GetMusicRate() const;
float GetJudgeScale() const;
bool GetEtternaValid() const;
/**
* @brief Determine how many seconds the player had left in Survival mode.
* @return the number of seconds left. */
Expand Down Expand Up @@ -80,6 +81,7 @@ struct HighScore
void SetWifeScore(float f);
void SetMusicRate(float f);
void SetJudgeScale(float f);
void SetEtternaValid(bool b);
void SetOffsetVector(vector<float> v);
void SetNoteRowVector(vector<int> v);
void SetAliveSeconds( float f );
Expand Down
8 changes: 0 additions & 8 deletions src/PlayerStageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,6 @@ float PlayerStageStats::GetWifeScore() const {
return m_fWifeScore;
}
vector<float> PlayerStageStats::CalcSSR() const {
vector<float> o = { 0.f, 0.f, 0.f,0.f,0.f };
if (GetGrade() == Grade_Failed || m_fWifeScore < 0.1f || GAMESTATE->m_pCurSteps[m_player_number]->m_StepsType != StepsType_dance_single)
return o ;

FOREACHM_CONST(float, float, m_fLifeRecord, fail)
if (fail->second == 0.f)
return o;

auto nd = GAMESTATE->m_pCurSteps[m_player_number]->GetNoteData();
TimingData* td = GAMESTATE->m_pCurSteps[m_player_number]->GetTimingData();
float musicrate = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
Expand Down
14 changes: 12 additions & 2 deletions src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2094,8 +2094,9 @@ void Profile::CalcPlayerRating(float& prating, float* pskillsets) const {
const HighScoresForASteps& zz = j->second;
const vector<HighScore>& hsv = zz.hsl.vHighScores;
for (size_t i = 0; i < hsv.size(); i++) {
FOREACH_ENUM(Skillset, ss)
demskillas[ss].emplace_back(hsv[i].GetSkillsetSSR(ss));
if(hsv[i].GetEtternaValid())
FOREACH_ENUM(Skillset, ss)
demskillas[ss].emplace_back(hsv[i].GetSkillsetSSR(ss));
}
}
}
Expand Down Expand Up @@ -3092,6 +3093,14 @@ class LunaProfile : public Luna<Profile>
lua_pushnumber(L, p->GetTopSSRValue(IArg(1), IArg(2)) );
return 1;
}
static int GetTopSSRHighScore(T* p, lua_State *L) {
HighScore* ths = p->GetTopSSRHighScore(IArg(1), IArg(2));
if (ths)
ths->PushSelf(L);
else
lua_pushnil(L);
return 1;
}
static int GetPlayerSkillsetRating(T* p, lua_State *L) {
Skillset lel = static_cast<Skillset>(IArg(1) - 1);
lua_pushnumber(L, p->m_fPlayerSkillsets[lel]);
Expand Down Expand Up @@ -3174,6 +3183,7 @@ class LunaProfile : public Luna<Profile>
ADD_METHOD( GetNumFaves );
ADD_METHOD( GetTopSSRValue );
ADD_METHOD( GetTopSSRSongName );
ADD_METHOD( GetTopSSRHighScore );
}
};

Expand Down
Loading

0 comments on commit 0a364c1

Please sign in to comment.