Skip to content

Commit

Permalink
display goal % in wifetwirl for the current chart/rate if applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jun 7, 2017
1 parent ad4a720 commit 05738db
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,6 @@ t[#t+1] = Def.ActorFrame{
CurrentRateChangedMessageCommand=cmd(queuecommand,"Set"),
},

-- Primary ScoreType
LoadFont("Common Large")..{
InitCommand=cmd(xy,frameX+125,frameY+40;zoom,0.3;halign,1;valign,1),
BeginCommand=cmd(queuecommand,"Set"),
SetCommand=function(self)
if song and score then
self:settext(scoringToText(scoreType))
else
self:settext("")
end
end,
CurrentRateChangedMessageCommand=cmd(queuecommand,"Set"),
RefreshChartInfoMessageCommand=cmd(queuecommand,"Set"),
},

-- Rate for the displayed score
LoadFont("Common Normal")..{
InitCommand=cmd(xy,frameX+55,frameY+58;zoom,0.5;halign,0.5),
Expand Down Expand Up @@ -380,6 +365,68 @@ t[#t+1] = LoadFont("Common Large") .. {
RefreshChartInfoMessageCommand=cmd(queuecommand,"Set"),
}

t[#t+1] = LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+135,frameY+45;zoom,0.3;halign,0.5;valign,1),
BeginCommand=cmd(queuecommand,"Set"),
SetCommand=function(self)
if song and steps then
local goal = profile:GetEasiestGoalForChartAndRate(steps:GetChartKey(), getCurRateValue())
if goal then
self:settext("Target:")
else
self:settext("")
end
else
self:settext("")
end
end,
CurrentRateChangedMessageCommand=cmd(queuecommand,"Set"),
CurrentStepsP1ChangedMessageCommand=cmd(queuecommand,"Set"),
RefreshChartInfoMessageCommand=cmd(queuecommand,"Set"),
}

t[#t+1] = LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+135,frameY+60;zoom,0.3;halign,0.5;valign,1),
BeginCommand=cmd(queuecommand,"Set"),
SetCommand=function(self)
if song and steps then
local goal = profile:GetEasiestGoalForChartAndRate(steps:GetChartKey(), getCurRateValue())
if goal then
self:settextf("%.2f%%", goal:GetPercent() * 100)
else
self:settext("")
end
else
self:settext("")
end
end,
CurrentRateChangedMessageCommand=cmd(queuecommand,"Set"),
CurrentStepsP1ChangedMessageCommand=cmd(queuecommand,"Set"),
RefreshChartInfoMessageCommand=cmd(queuecommand,"Set"),
}

-- perhaps need this perhaps not
-- t[#t+1] = LoadFont("Common Large") .. {
-- InitCommand=cmd(xy,frameX+135,frameY+65;zoom,0.3;halign,0.5;valign,1),
-- BeginCommand=cmd(queuecommand,"Set"),
-- SetCommand=function(self)
-- if steps then
-- local goal = profile:GetEasiestGoalForChartAndRate(steps:GetChartKey(), getCurRateValue())
-- if goal then
-- self:settextf("%.2f", goal:GetRate())
-- else
-- self:settext("")
-- end
-- else
-- self:settext("")
-- end
-- end,
-- CurrentStepsP1ChangedMessageCommand=cmd(queuecommand,"Set"),
-- RefreshChartInfoMessageCommand=cmd(queuecommand,"Set"),
-- }



-- t[#t+1] = LoadFont("Common Large") .. {
-- InitCommand=cmd(xy,(capWideScale(get43size(384),384))+68,SCREEN_BOTTOM-135;halign,1;zoom,0.4,maxwidth,125),
-- BeginCommand=cmd(queuecommand,"Set"),
Expand Down
25 changes: 25 additions & 0 deletions src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2631,6 +2631,30 @@ class LunaProfile : public Luna<Profile>
lua_pushboolean(L, o);
return 1;
}

// ok i should probably handle this better -mina
static int GetEasiestGoalForChartAndRate(T* p, lua_State *L) {
string ck = SArg(1);
if (!p->goalmap.count(ck)) {
lua_pushnil(L);
return 1;
}

auto& sgv = p->goalmap[ck].goals;
bool herp = false;
ScoreGoal& ez = sgv[0];
for (auto& n : sgv)
if (lround(n.rate * 10000.f) == lround(FArg(2) * 10000.f) && !n.achieved && n.percent <= ez.percent) {
ez = n;
herp = true;
}
if (herp)
ez.PushSelf(L);
else
lua_pushnil(L);
return 1;
}

LunaProfile()
{
ADD_METHOD( AddScreenshot );
Expand Down Expand Up @@ -2677,6 +2701,7 @@ class LunaProfile : public Luna<Profile>
ADD_METHOD(GetIgnoreStepCountCalories);
ADD_METHOD(CalculateCaloriesFromHeartRate);
ADD_METHOD(IsCurrentChartPermamirror);
ADD_METHOD(GetEasiestGoalForChartAndRate);
}
};

Expand Down

0 comments on commit 05738db

Please sign in to comment.