diff --git a/Themes/Til Death/BGAnimations/ScreenGameplay overlay/PlayerInfo.lua b/Themes/Til Death/BGAnimations/ScreenGameplay overlay/PlayerInfo.lua index b063740618..6141749511 100644 --- a/Themes/Til Death/BGAnimations/ScreenGameplay overlay/PlayerInfo.lua +++ b/Themes/Til Death/BGAnimations/ScreenGameplay overlay/PlayerInfo.lua @@ -22,7 +22,7 @@ local t = Def.ActorFrame{ LoadFont("Common Large") .. { InitCommand=cmd(xy,PlayerFrameX+52,PlayerFrameY+28;halign,0;zoom,0.75;maxwidth,50), BeginCommand=function(self) - local meter = GAMESTATE:GetCurrentSteps(PLAYER_1):GetMSD(getCurRateValue(),0) + local meter = GAMESTATE:GetCurrentSteps(PLAYER_1):GetMSD(getCurRateValue(),1) self:settextf("%05.2f",meter) self:diffuse(ByMSD(meter)) end, diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua index 2015eb8b5f..3957eb8c91 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua @@ -11,6 +11,7 @@ local frameWidth = capWideScale(360,400) local frameHeight = 350 local offsetX = 10 local offsetY = 20 +local activebound = 0 for i=1,#ms.SkillSets do SSQuery[i] = "0" end @@ -39,7 +40,8 @@ local function FilterInput(event) if SSQuery[ActiveSS] == "" or #SSQuery[ActiveSS] > 2 then SSQuery[ActiveSS] = "0" end - whee:SetSkillsetFilter(tonumber(SSQuery[ActiveSS]), ActiveSS) + GAMESTATE:SetSSFilter(tonumber(SSQuery[ActiveSS]), ActiveSS, activebound) + whee:SongSearch("") -- stupid workaround? MESSAGEMAN:Broadcast("UpdateFilter") end end @@ -60,6 +62,7 @@ local f = Def.ActorFrame{ self:visible(true) active = true else + MESSAGEMAN:Broadcast("NumericInputEnded") self:visible(false) self:queuecommand("Off") end @@ -67,6 +70,7 @@ local f = Def.ActorFrame{ TabChangedMessageCommand=cmd(queuecommand,"Set"), MouseRightClickMessageCommand=function(self) ActiveSS = 0 + MESSAGEMAN:Broadcast("NumericInputEnded") MESSAGEMAN:Broadcast("UpdateFilter") SCREENMAN:set_input_redirected(PLAYER_1, false) end, @@ -88,22 +92,48 @@ local f = Def.ActorFrame{ self:settext("Greyed out values are inactive.") end, }, + Def.Quad{ + InitCommand=cmd(xy,frameX+frameWidth/2+90,175;zoomto,40,30;halign,0;diffusealpha,0), + MouseLeftClickMessageCommand=function(self) + if isOver(self) then + GAMESTATE:SetMaxFilterRate(GAMESTATE:GetMaxFilterRate()+0.1) + MESSAGEMAN:Broadcast("MaxFilterRateChanged") + whee:SongSearch("") + end + end, + MouseRightClickMessageCommand=function(self) + if isOver(self) then + GAMESTATE:SetMaxFilterRate(GAMESTATE:GetMaxFilterRate()-0.1) + MESSAGEMAN:Broadcast("MaxFilterRateChanged") + whee:SongSearch("") + end + end, + }, LoadFont("Common Large")..{ InitCommand=cmd(xy,frameX+frameWidth/2,175;zoom,textzoom;halign,0), SetCommand=function(self) - self:settext("Max Rate: 1.5x") + self:settextf("Max Rate:%5.1fx",GAMESTATE:GetMaxFilterRate()) end, + MaxFilterRateChangedMessageCommand=cmd(queuecommand,"Set"), }, LoadFont("Common Large")..{ InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY;zoom,textzoom;halign,0), - SetCommand=function(self) - self:settext("Mode: ".."Inclusive") + SetCommand=function(self) + --local mode = GAMESTATE:GetFilterMode() + if mode then + self:settext("Mode: ".."AND") + else + self:settext("Mode: ".."OR") + end end, }, - LoadFont("Common Large")..{ - InitCommand=cmd(xy,frameX+frameWidth/2,175 + spacingY*2;zoom,textzoom;halign,0), - SetCommand=function(self) - self:settext("Highest SS Only : ".."Off") + Def.Quad{ + InitCommand=cmd(xy,frameX+frameWidth/2+90,175;zoomto,40,30;halign,0;diffusealpha,0), + MouseLeftClickMessageCommand=function(self) + if isOver(self) then + GAMESTATE:ToggleFilterMode() + whee:SongSearch("") + end end, }, } @@ -119,16 +149,17 @@ local function CreateFilterInputBox(i) MouseLeftClickMessageCommand=function(self) if isOver(self) then ActiveSS = i + activebound = 0 MESSAGEMAN:Broadcast("NumericInputActive") self:diffusealpha(0.1) SCREENMAN:set_input_redirected(PLAYER_1, true) end end, SetCommand=function(self) - if ActiveSS ~= i then - self:diffuse(color("#000000")) - else + if ActiveSS == i and activebound == 0 then self:diffuse(color("#666666")) + else + self:diffuse(color("#000000")) end end, UpdateFilterMessageCommand=cmd(queuecommand,"Set"), @@ -137,7 +168,7 @@ local function CreateFilterInputBox(i) LoadFont("Common Large")..{ InitCommand=cmd(addx,150;addy,175 + (i-1)*spacingY;halign,1;maxwidth,40;zoom,textzoom), SetCommand=function(self) - local fval = whee:GetSkillsetFilter(i) + local fval = GAMESTATE:GetSSFilter(i,0) -- lower bounds self:settext(fval) if fval <= 0 and ActiveSS ~= i then self:diffuse(color("#666666")) @@ -152,16 +183,17 @@ local function CreateFilterInputBox(i) MouseLeftClickMessageCommand=function(self) if isOver(self) and false then ActiveSS = i + activebound = 1 MESSAGEMAN:Broadcast("NumericInputActive") self:diffusealpha(0.1) SCREENMAN:set_input_redirected(PLAYER_1, true) end end, SetCommand=function(self) - if ActiveSS ~= i or true then - self:diffuse(color("#000000")) - else + if ActiveSS == i and activebound == 1 then self:diffuse(color("#666666")) + else + self:diffuse(color("#000000")) end end, UpdateFilterMessageCommand=cmd(queuecommand,"Set"), @@ -170,7 +202,7 @@ local function CreateFilterInputBox(i) LoadFont("Common Large")..{ InitCommand=cmd(addx,175;addy,175 + (i-1)*spacingY;halign,1;maxwidth,40;zoom,textzoom), SetCommand=function(self) - local fval = 0 --whee:GetSkillsetFilter(i) + local fval = GAMESTATE:GetSSFilter(i,1) -- upper bounds self:settext(fval) if fval <= 0 then self:diffuse(color("#666666")) diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua index 2b0ded5bef..247ef1738d 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua @@ -91,7 +91,7 @@ function tabs(index) SetCommand=function(self) self:settext(tabNames[index]) if isTabEnabled(index) then - if index == 6 and whee:AnyActiveSkillsetFilter() then + if index == 6 and GAMESTATE:AnyActiveFilter() then self:diffuse(color("#cc2929")) else self:diffuse(getMainColor('positive')) diff --git a/src/GameState.cpp b/src/GameState.cpp index 43536cd5c0..5b0e03bde0 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -178,9 +178,10 @@ GameState::GameState() : // filter stuff - mina - ZERO( SkillsetFilters ); - MaxFilterRate = 1.5; - + ZERO( SSFilterLowerBounds ); + ZERO( SSFilterUpperBounds ); + MaxFilterRate = 1.f; + FilterMode = 0; // Register with Lua. { @@ -207,6 +208,31 @@ GameState::~GameState() SAFE_DELETE( processedTiming ); } +// tmp filter stuff - mina +bool GameState::AnyActiveFilter() { + FOREACH_ENUM(Skillset, ss) { + if (SSFilterLowerBounds[ss] > 0) + return true; + if (SSFilterUpperBounds[ss] > 0) + return true; + } + return false; +} + +void GameState::SetSSFilter(float v, Skillset ss, int bound) { + if (bound == 0) + SSFilterLowerBounds[ss] = v; + else + SSFilterUpperBounds[ss] = v; +} + +float GameState::GetSSFilter(Skillset ss, int bound) { + if (bound == 0) + return SSFilterLowerBounds[ss]; + else + return SSFilterUpperBounds[ss]; +} + PlayerNumber GameState::GetMasterPlayerNumber() const { return this->masterPlayerNumber; @@ -2815,6 +2841,7 @@ class LunaGameState: public Luna DEFINE_METHOD( GetCoinMode, GetCoinMode() ) DEFINE_METHOD( GetPremium, GetPremium() ) DEFINE_METHOD( GetSongOptionsString, m_SongOptions.GetCurrent().GetString() ) + DEFINE_METHOD( AnyActiveFilter, AnyActiveFilter()) static int GetSessionTime(T* p, lua_State *L) { lua_pushnumber(L, p->m_timeGameStarted.GetTimeSinceStart()); return 1; } static int GetSongOptions( T* p, lua_State *L ) { @@ -3242,8 +3269,34 @@ class LunaGameState: public Luna p->m_autogen_fargs[si]= v; COMMON_RETURN_SELF; } + static int SetSSFilter(T* p, lua_State *L) { + p->SetSSFilter(FArg(1), static_cast(IArg(2) - 1), IArg(3)); + return 1; + } + static int GetSSFilter(T* p, lua_State *L) { + float f = p->GetSSFilter(static_cast(IArg(1) - 1), IArg(2)); + lua_pushnumber(L, f); + return 1; + } static int SetMaxFilterRate(T* p, lua_State* L) { - p->MaxFilterRate = FArg(1); + float mfr = FArg(1); + CLAMP(mfr, 0.7f, 2.f); + p->MaxFilterRate = mfr; + return 1; + } + static int GetMaxFilterRate(T* p, lua_State* L) { + lua_pushnumber(L, p->MaxFilterRate); + return 1; + } + static int ToggleFilterMode(T* p, lua_State* L) { + if (p->FilterMode == 1) + p->FilterMode = 0; + else + p->FilterMode = 1; + return 1; + } + static int GetFilterMode(T* p, lua_State* L) { + lua_pushnumber(L, p->FilterMode); return 1; } @@ -3374,7 +3427,13 @@ class LunaGameState: public Luna ADD_METHOD( SetStepsForEditMode ); ADD_METHOD( GetAutoGenFarg ); ADD_METHOD( SetAutoGenFarg ); + ADD_METHOD( SetSSFilter ); + ADD_METHOD( GetSSFilter ); + ADD_METHOD( AnyActiveFilter ); ADD_METHOD( SetMaxFilterRate ); + ADD_METHOD( GetMaxFilterRate ); + ADD_METHOD( ToggleFilterMode ); + ADD_METHOD( GetFilterMode ); } }; diff --git a/src/GameState.h b/src/GameState.h index ae153f973a..97d3523662 100644 --- a/src/GameState.h +++ b/src/GameState.h @@ -243,10 +243,19 @@ class GameState int GetLoadingCourseSongIndex() const; - // mina was here to drop in some temporary(?) filter things that need to persist - mina - float SkillsetFilters[NUM_Skillset]; + // todo: make a filterman or something - mina + float SSFilterLowerBounds[NUM_Skillset]; + float SSFilterUpperBounds[NUM_Skillset]; float MaxFilterRate; - void SetMaxFilterRate(float v) { MaxFilterRate; } + int FilterMode; // 0 = OR 1 = AND + float GetSSFilter(Skillset ss, int bound); + void SetSSFilter(float v, Skillset ss, int bound); + + bool SkillsetFiltersActive = false; + bool AnyActiveFilter(); + + + // State Info used during gameplay diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index fd255a679f..a87b29da68 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -126,9 +126,6 @@ void MusicWheel::Load( const RString &sType ) FOREACH_ENUM( SortOrder, so ) { m_WheelItemDatasStatus[so]=INVALID; } - ZERO( SkillsetFilters ); - FOREACH_ENUM(Skillset, ss) - SkillsetFilters[ss] = GAMESTATE->SkillsetFilters[ss]; } void MusicWheel::BeginScreen() @@ -261,8 +258,6 @@ MusicWheel::~MusicWheel() delete *i; } } - FOREACH_ENUM(Skillset, ss) - GAMESTATE->SkillsetFilters[ss] = SkillsetFilters[ss]; } void MusicWheel::ReloadSongList(bool searching, RString findme) @@ -597,9 +592,10 @@ void MusicWheel::FilterBySkillsets(vector& inv) { for (size_t i = 0; i < inv.size(); i++) { bool addsong = false; FOREACH_ENUM(Skillset, ss) { - if (SkillsetFilters[ss] > 0.f) { + float lb = GAMESTATE->SSFilterLowerBounds[ss]; + if (lb > 0.f) { float val = inv[i]->GetHighestOfSkillsetAllSteps(static_cast(ss), GAMESTATE->MaxFilterRate); - if (val > SkillsetFilters[ss]) + if (val > lb) addsong = addsong || true; } } @@ -609,14 +605,6 @@ void MusicWheel::FilterBySkillsets(vector& inv) { inv.swap(tmp); } -// should make an explicit toggle soon - mina -bool MusicWheel::AnyActiveSkillsetFilter() { - FOREACH_ENUM(Skillset, ss) - if (SkillsetFilters[ss] > 0) - return true; - return false; -} - void MusicWheel::BuildWheelItemDatas( vector &arrayWheelItemDatas, SortOrder so, bool searching, RString findme ) { switch( so ) @@ -670,7 +658,7 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt if (searching) FilterBySearch(arraySongs, findme); - if (AnyActiveSkillsetFilter()) + if (GAMESTATE->AnyActiveFilter()) FilterBySkillsets(arraySongs); bool bUseSections = true; @@ -1793,7 +1781,6 @@ class LunaMusicWheel : public Luna return 1; } DEFINE_METHOD(GetSelectedSection, GetSelectedSection()); - DEFINE_METHOD(AnyActiveSkillsetFilter, AnyActiveSkillsetFilter()); static int IsRouletting(T* p, lua_State *L) { lua_pushboolean(L, p->IsRouletting()); return 1; } static int SelectSong(T* p, lua_State *L) { @@ -1819,16 +1806,6 @@ class LunaMusicWheel : public Luna p->ReloadSongList(true, SArg(1)); return 1; } - static int SetSkillsetFilter(T* p, lua_State *L) { - p->SetSkillsetFilter(FArg(1), static_cast(IArg(2)-1)); - p->ReloadSongList(true, ""); - return 1; - } - static int GetSkillsetFilter(T* p, lua_State *L) { - float f = p->GetSkillsetFilter(static_cast(IArg(1) - 1)); - lua_pushnumber(L, f); - return 1; - } LunaMusicWheel() { @@ -1838,9 +1815,6 @@ class LunaMusicWheel : public Luna ADD_METHOD( SelectSong ); ADD_METHOD( SelectCourse ); ADD_METHOD( SongSearch ); - ADD_METHOD( SetSkillsetFilter ); - ADD_METHOD( GetSkillsetFilter ); - ADD_METHOD( AnyActiveSkillsetFilter ); } }; diff --git a/src/MusicWheel.h b/src/MusicWheel.h index 031366901e..e59d17b990 100644 --- a/src/MusicWheel.h +++ b/src/MusicWheel.h @@ -52,11 +52,6 @@ class MusicWheel : public WheelBase virtual void ReloadSongList(bool searching, RString findme); - // mina was here - mina - void SetSkillsetFilter(float v, Skillset ss) { SkillsetFilters[ss] = v; } - float GetSkillsetFilter(Skillset ss) { return SkillsetFilters[ss]; } - bool SkillsetFiltersActive = false; - bool AnyActiveSkillsetFilter(); // Lua void PushSelf( lua_State *L ); @@ -68,7 +63,6 @@ class MusicWheel : public WheelBase bool SelectModeMenuItem(); void FilterBySearch(vector& inv, RString findme); - float SkillsetFilters[NUM_Skillset]; void FilterBySkillsets(vector& inv); RString lastvalidsearch;