Skip to content

Commit

Permalink
properly define interaction between filter input permutations
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jan 14, 2017
1 parent af0ece8 commit b53b286
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,20 @@ local f = Def.ActorFrame{
self:settext("Right click/Start/Back to cancel input.")
end,
},
LoadFont("Common Large")..{
LoadFont("Common Large")..{
InitCommand=cmd(xy,frameX,frameY+40;zoom,0.3;halign,0),
SetCommand=function(self)
self:settext("Greyed out values are inactive.")
end,
},
LoadFont("Common Large")..{
InitCommand=cmd(xy,frameX,frameY+60;zoom,0.3;halign,0),
SetCommand=function(self)
self:settext("Using both bounds creates a range.")
end,
},
Def.Quad{
InitCommand=cmd(xy,frameX+frameWidth/2+90,175;zoomto,40,20;halign,0;diffusealpha,0.5),
InitCommand=cmd(xy,frameX+frameWidth/2+90,175;zoomto,40,20;halign,0;diffusealpha,0),
MouseLeftClickMessageCommand=function(self)
if isOver(self) then
GAMESTATE:SetMaxFilterRate(GAMESTATE:GetMaxFilterRate()+0.1)
Expand Down Expand Up @@ -135,7 +141,7 @@ local f = Def.ActorFrame{
FilterModeChangedMessageCommand=cmd(queuecommand,"Set"),
},
Def.Quad{
InitCommand=cmd(xy,frameX+frameWidth/2+50,175 + spacingY;zoomto,40,20;halign,0;diffusealpha,0.5),
InitCommand=cmd(xy,frameX+frameWidth/2+50,175 + spacingY;zoomto,40,20;halign,0;diffusealpha,0),
MouseLeftClickMessageCommand=function(self)
if isOver(self) then
GAMESTATE:ToggleFilterMode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,23 +452,27 @@ t[#t+1] = LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+120,frameY-60;halign,0;zoom,0.4,maxwidth,125),
BeginCommand=cmd(queuecommand,"Set"),
SetCommand=function(self)
local dwerp = {}
for i=2,#ms.SkillSets do
dwerp[i-1] = string.format("%5.2f", steps:GetMSD(getCurRateValue(), i))..ms.SkillSets[i]
end
table.sort(dwerp)
ss1 = string.sub(dwerp[#dwerp],6)
if tonumber(string.sub(dwerp[#dwerp-1],0,5)) > tonumber(string.sub(dwerp[#dwerp],0,5))*0.9 then
ss2 = string.sub(dwerp[#dwerp-1],6)
else
ss2 = ""
end
if tonumber(string.sub(dwerp[#dwerp-2],0,5)) > tonumber(string.sub(dwerp[#dwerp],0,5))*0.9 then
ss3 = string.sub(dwerp[#dwerp-2],6)
if song then
local dwerp = {}
for i=2,#ms.SkillSets do
dwerp[i-1] = string.format("%5.2f", steps:GetMSD(getCurRateValue(), i))..ms.SkillSets[i]
end
table.sort(dwerp)
ss1 = string.sub(dwerp[#dwerp],6)
if tonumber(string.sub(dwerp[#dwerp-1],0,5)) > tonumber(string.sub(dwerp[#dwerp],0,5))*0.9 then
ss2 = string.sub(dwerp[#dwerp-1],6)
else
ss2 = ""
end
if tonumber(string.sub(dwerp[#dwerp-2],0,5)) > tonumber(string.sub(dwerp[#dwerp],0,5))*0.9 then
ss3 = string.sub(dwerp[#dwerp-2],6)
else
ss3 = ""
end
self:settext(ss1)
else
ss3 = ""
self:settext("")
end
self:settext(ss1)
end,
CurrentRateChangedMessageCommand=cmd(queuecommand,"Set"),
RefreshChartInfoMessageCommand=cmd(queuecommand,"Set"),
Expand All @@ -478,7 +482,11 @@ t[#t+1] = LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+120,frameY-30;halign,0;zoom,0.4,maxwidth,125),
BeginCommand=cmd(queuecommand,"Set"),
SetCommand=function(self)
self:settext(ss2)
if song then
self:settext(ss2)
else
self:settext("")
end
end,
CurrentRateChangedMessageCommand=cmd(queuecommand,"Set"),
RefreshChartInfoMessageCommand=cmd(queuecommand,"Set"),
Expand All @@ -488,7 +496,11 @@ t[#t+1] = LoadFont("Common Large") .. {
InitCommand=cmd(xy,frameX+120,frameY;halign,0;zoom,0.4,maxwidth,125),
BeginCommand=cmd(queuecommand,"Set"),
SetCommand=function(self)
self:settext(ss3)
if song then
self:settext(ss3)
else
self:settext("")
end
end,
CurrentRateChangedMessageCommand=cmd(queuecommand,"Set"),
RefreshChartInfoMessageCommand=cmd(queuecommand,"Set"),
Expand Down
36 changes: 30 additions & 6 deletions src/MusicWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,19 +587,32 @@ void MusicWheel::FilterBySearch(vector<Song*>& inv, RString findme) {
FilterBySearch(inv, lastvalidsearch);
}


// should definitely house these in lower level functions so return can be called the iteration an outcome is determined on instead of clumsily using continue - mina
void MusicWheel::FilterBySkillsets(vector<Song*>& inv) {
vector<Song*> tmp;
if (!GAMESTATE->ExclusiveFilter) {
for (size_t i = 0; i < inv.size(); i++) {
bool addsong = false;
FOREACH_ENUM(Skillset, ss) {
float lb = GAMESTATE->SSFilterLowerBounds[ss];
if (lb > 0.f) {
float ub = GAMESTATE->SSFilterUpperBounds[ss];
if (lb > 0.f || ub > 0.f) { // if either bound is active, continue to evaluation
float val = inv[i]->GetHighestOfSkillsetAllSteps(static_cast<int>(ss), GAMESTATE->MaxFilterRate);
if (val > lb)
addsong = addsong || true;
bool isrange = lb > 0.f && ub > 0.f; // both bounds are active and create an explicit range
if (isrange) {
if (val > lb && val < ub) // if dealing with an explicit range evaluate as such
addsong = addsong || true;
}
else
if (lb > 0.f && val > lb) // must be a nicer way to handle this but im tired
addsong = addsong || true;
if (ub > 0.f && val < ub)
addsong = addsong || true;
}
}

// only add the song if it's cleared the gauntlet
if (addsong)
tmp.emplace_back(inv[i]);
}
Expand All @@ -608,11 +621,22 @@ void MusicWheel::FilterBySkillsets(vector<Song*>& inv) {
for (size_t i = 0; i < inv.size(); i++) {
bool addsong = true;
FOREACH_ENUM(Skillset, ss) {
if (!addsong)
continue;
float lb = GAMESTATE->SSFilterLowerBounds[ss];
if (lb > 0.f) {
float ub = GAMESTATE->SSFilterUpperBounds[ss];
if (lb > 0.f || ub > 0.f) {
float val = inv[i]->GetHighestOfSkillsetAllSteps(static_cast<int>(ss), GAMESTATE->MaxFilterRate);
if (val < lb)
addsong = false;
bool isrange = lb > 0.f && ub > 0.f;
if (isrange) {
if (val < lb || val > ub)
addsong = false;
}
else
if (lb > 0.f && val < lb)
addsong = false;
if (ub > 0.f && val > ub)
addsong = false;
}
}
if (addsong)
Expand Down

0 comments on commit b53b286

Please sign in to comment.