From 56c151ef2f8c613d3b6f57068143f102bf13bf1d Mon Sep 17 00:00:00 2001 From: MinaciousGrace Date: Sat, 14 Jan 2017 17:03:29 -0500 Subject: [PATCH] initial implementation of filters complete????? --- .../ScreenSelectMusic decorations/filters.lua | 38 ++++++++- src/GameState.cpp | 17 +++- src/MusicWheel.cpp | 78 +++++++++++-------- src/MusicWheelItem.cpp | 2 + src/PlayerState.h | 2 +- src/Song.cpp | 1 + 6 files changed, 101 insertions(+), 37 deletions(-) diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua index c0259002af..4a8caff4a8 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua @@ -104,6 +104,12 @@ local f = Def.ActorFrame{ self:settext("Using both bounds creates a range.") end, }, + LoadFont("Common Large")..{ + InitCommand=cmd(xy,frameX,frameY+80;zoom,0.3;halign,0), + SetCommand=function(self) + self:settext("'Highest Only' applies only to Mode: Or") + end, + }, LoadFont("Common Large")..{ InitCommand=cmd(xy,frameX+frameWidth/2,175;zoom,textzoom;halign,0), SetCommand=function(self) @@ -130,6 +136,30 @@ local f = Def.ActorFrame{ }, LoadFont("Common Large")..{ InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY;zoom,textzoom;halign,0), + SetCommand=function(self) + self:settextf("Min Rate:%5.1fx",GAMESTATE:GetMinFilterRate()) + end, + MaxFilterRateChangedMessageCommand=cmd(queuecommand,"Set"), + }, + Def.Quad{ + InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY;zoomto,130,18;halign,0;diffusealpha,0), + MouseLeftClickMessageCommand=function(self) + if isOver(self) then + GAMESTATE:SetMinFilterRate(GAMESTATE:GetMinFilterRate()+0.1) + MESSAGEMAN:Broadcast("MaxFilterRateChanged") + whee:SongSearch("") + end + end, + MouseRightClickMessageCommand=function(self) + if isOver(self) then + GAMESTATE:SetMinFilterRate(GAMESTATE:GetMinFilterRate()-0.1) + MESSAGEMAN:Broadcast("MaxFilterRateChanged") + whee:SongSearch("") + end + end, + }, + LoadFont("Common Large")..{ + InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY * 2;zoom,textzoom;halign,0), SetCommand=function(self) local mode = GAMESTATE:GetFilterMode() if mode then @@ -141,7 +171,7 @@ local f = Def.ActorFrame{ FilterModeChangedMessageCommand=cmd(queuecommand,"Set"), }, Def.Quad{ - InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY;zoomto,120,18;halign,0;diffusealpha,0), + InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY * 2;zoomto,120,18;halign,0;diffusealpha,0), MouseLeftClickMessageCommand=function(self) if isOver(self) then GAMESTATE:ToggleFilterMode() @@ -151,7 +181,7 @@ local f = Def.ActorFrame{ end, }, LoadFont("Common Large")..{ - InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY * 2;zoom,textzoom;halign,0), + InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY * 3;zoom,textzoom;halign,0), SetCommand=function(self) local yes = GAMESTATE:GetHighestSkillsetsOnly() if yes then @@ -163,7 +193,7 @@ local f = Def.ActorFrame{ FilterModeChangedMessageCommand=cmd(queuecommand,"Set"), }, Def.Quad{ - InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY * 2;zoomto,160,18;halign,0;diffusealpha,0), + InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY * 3;zoomto,160,18;halign,0;diffusealpha,0), MouseLeftClickMessageCommand=function(self) if isOver(self) then GAMESTATE:ToggleHighestSkillsetsOnly() @@ -173,7 +203,7 @@ local f = Def.ActorFrame{ end, }, LoadFont("Common Large")..{ - InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY * 3;zoom,textzoom;halign,0;settext,""), + InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY * 4;zoom,textzoom;halign,0;settext,""), FilterResultsMessageCommand=function(self, msg) self:settext("Matches: "..msg.Matches.."/"..msg.Total) end diff --git a/src/GameState.cpp b/src/GameState.cpp index 662ca6b3fd..42f6c9df9b 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -3278,7 +3278,8 @@ class LunaGameState: public Luna } static int SetMaxFilterRate(T* p, lua_State* L) { float mfr = FArg(1); - CLAMP(mfr, 0.7f, 2.f); + auto loot = p->m_pPlayerState[0]; + CLAMP(mfr, loot->wtFFF, 2.f); p->MaxFilterRate = mfr; return 1; } @@ -3286,6 +3287,18 @@ class LunaGameState: public Luna lua_pushnumber(L, p->MaxFilterRate); return 1; } + static int SetMinFilterRate(T* p, lua_State* L) { + float mfr = FArg(1); + CLAMP(mfr, 0.7f, p->MaxFilterRate); + auto loot = p->m_pPlayerState[0]; + loot->wtFFF = mfr; + return 1; + } + static int GetMinFilterRate(T* p, lua_State* L) { + auto loot = p->m_pPlayerState[0]; + lua_pushnumber(L, loot->wtFFF); + return 1; + } static int ToggleFilterMode(T* p, lua_State* L) { p->ExclusiveFilter = !p->ExclusiveFilter; return 1; @@ -3437,6 +3450,8 @@ class LunaGameState: public Luna ADD_METHOD( AnyActiveFilter ); ADD_METHOD( SetMaxFilterRate ); ADD_METHOD( GetMaxFilterRate ); + ADD_METHOD( SetMinFilterRate ); + ADD_METHOD( GetMinFilterRate ); ADD_METHOD( ToggleFilterMode ); ADD_METHOD( GetFilterMode ); ADD_METHOD( ToggleHighestSkillsetsOnly ); diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index 35f0153553..730deb2491 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -598,23 +598,28 @@ void MusicWheel::FilterBySkillsets(vector& inv) { float lb = GAMESTATE->SSFilterLowerBounds[ss]; float ub = GAMESTATE->SSFilterUpperBounds[ss]; if (lb > 0.f || ub > 0.f) { // if either bound is active, continue to evaluation - if (GAMESTATE->HighestSkillsetsOnly) - if (!inv[i]->IsSkillsetHighestOfAnySteps(ss, GAMESTATE->MaxFilterRate)) - continue; - - float val = inv[i]->GetHighestOfSkillsetAllSteps(static_cast(ss), GAMESTATE->MaxFilterRate); - - 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; - } + float currate = GAMESTATE->MaxFilterRate + 0.1f; + float minrate = GAMESTATE->m_pPlayerState[0]->wtFFF; + do { + currate = currate - 0.1f; + if (GAMESTATE->HighestSkillsetsOnly) + if (!inv[i]->IsSkillsetHighestOfAnySteps(ss, currate)) + continue; + + float val = inv[i]->GetHighestOfSkillsetAllSteps(static_cast(ss), currate); + + 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; + } + } while (currate > minrate); } } @@ -627,25 +632,36 @@ void MusicWheel::FilterBySkillsets(vector& inv) { for (size_t i = 0; i < inv.size(); i++) { bool addsong = true; FOREACH_ENUM(Skillset, ss) { - if (!addsong) - continue; + bool pineapple = true; float lb = GAMESTATE->SSFilterLowerBounds[ss]; float ub = GAMESTATE->SSFilterUpperBounds[ss]; if (lb > 0.f || ub > 0.f) { - float val = inv[i]->GetHighestOfSkillsetAllSteps(static_cast(ss), GAMESTATE->MaxFilterRate); - 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; - } + bool localaddsong; + float currate = GAMESTATE->MaxFilterRate + 0.1f; + float minrate = GAMESTATE->m_pPlayerState[0]->wtFFF; + bool toiletpaper = false; + do { + localaddsong = true; + currate = currate - 0.1f; + float val = inv[i]->GetHighestOfSkillsetAllSteps(static_cast(ss), currate); + bool isrange = lb > 0.f && ub > 0.f; + if (isrange) { + if (val < lb || val > ub) + localaddsong = false; + } + else { + if (lb > 0.f && val < lb) + localaddsong = false; + if (ub > 0.f && val > ub) + localaddsong = false; + } + toiletpaper = localaddsong || toiletpaper; + } while (currate > minrate); + pineapple = pineapple && toiletpaper; } + addsong = addsong && pineapple; } + if (addsong) tmp.emplace_back(inv[i]); } diff --git a/src/MusicWheelItem.cpp b/src/MusicWheelItem.cpp index dcb8977ec5..6981f28038 100644 --- a/src/MusicWheelItem.cpp +++ b/src/MusicWheelItem.cpp @@ -19,6 +19,8 @@ #include "ScreenSelectMusic.h" #include "ScreenManager.h" +static Preference uanastypadplayerdog("ShowGradesForAnyDifficulty", true); + static const char *MusicWheelItemTypeNames[] = { "Song", "SectionExpanded", diff --git a/src/PlayerState.h b/src/PlayerState.h index 2f5953280d..5b82078695 100644 --- a/src/PlayerState.h +++ b/src/PlayerState.h @@ -136,7 +136,7 @@ class PlayerState int m_NumCols; void SetNumCols(int ncol) { m_NumCols = ncol; }; int GetNumCols() { return m_NumCols; }; - + float wtFFF = 1.f; // lol dont ask - mina // Lua diff --git a/src/Song.cpp b/src/Song.cpp index 0ff3423199..e61fa8967c 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -1733,6 +1733,7 @@ float Song::GetPreviewStartSeconds() const } float Song::GetHighestOfSkillsetAllSteps(int x, float rate) { + CLAMP(rate, 0.7f, 2.f); float o = 0.f; vector vsteps = GetAllSteps(); FOREACH(Steps*, vsteps, steps)