From b53b286f5ed522a07e30ec467645d79df198472c Mon Sep 17 00:00:00 2001 From: MinaciousGrace Date: Sat, 14 Jan 2017 10:56:04 -0500 Subject: [PATCH] properly define interaction between filter input permutations --- .../ScreenSelectMusic decorations/filters.lua | 12 +++-- .../wifeTwirl.lua | 46 ++++++++++++------- src/MusicWheel.cpp | 36 ++++++++++++--- 3 files changed, 68 insertions(+), 26 deletions(-) diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua index df4b887d09..b3b289c888 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua @@ -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) @@ -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() diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/wifeTwirl.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/wifeTwirl.lua index 85abec39e0..33313fb5f9 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/wifeTwirl.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/wifeTwirl.lua @@ -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"), @@ -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"), @@ -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"), diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index 2f531d9cb8..70daf76e3d 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -587,6 +587,8 @@ void MusicWheel::FilterBySearch(vector& 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& inv) { vector tmp; if (!GAMESTATE->ExclusiveFilter) { @@ -594,12 +596,23 @@ void MusicWheel::FilterBySkillsets(vector& inv) { 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(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]); } @@ -608,11 +621,22 @@ void MusicWheel::FilterBySkillsets(vector& 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(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)