Skip to content

Commit

Permalink
initial implementation of filters complete?????
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jan 14, 2017
1 parent 43f9411 commit 56c151e
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand Down
17 changes: 16 additions & 1 deletion src/GameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3278,14 +3278,27 @@ class LunaGameState: public Luna<GameState>
}
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;
}
static int GetMaxFilterRate(T* p, lua_State* L) {
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;
Expand Down Expand Up @@ -3437,6 +3450,8 @@ class LunaGameState: public Luna<GameState>
ADD_METHOD( AnyActiveFilter );
ADD_METHOD( SetMaxFilterRate );
ADD_METHOD( GetMaxFilterRate );
ADD_METHOD( SetMinFilterRate );
ADD_METHOD( GetMinFilterRate );
ADD_METHOD( ToggleFilterMode );
ADD_METHOD( GetFilterMode );
ADD_METHOD( ToggleHighestSkillsetsOnly );
Expand Down
78 changes: 47 additions & 31 deletions src/MusicWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,23 +598,28 @@ void MusicWheel::FilterBySkillsets(vector<Song*>& 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<int>(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<int>(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);
}
}

Expand All @@ -627,25 +632,36 @@ 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;
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<int>(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<int>(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]);
}
Expand Down
2 changes: 2 additions & 0 deletions src/MusicWheelItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "ScreenSelectMusic.h"
#include "ScreenManager.h"

static Preference<bool> uanastypadplayerdog("ShowGradesForAnyDifficulty", true);

static const char *MusicWheelItemTypeNames[] = {
"Song",
"SectionExpanded",
Expand Down
2 changes: 1 addition & 1 deletion src/PlayerState.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Steps*> vsteps = GetAllSteps();
FOREACH(Steps*, vsteps, steps)
Expand Down

0 comments on commit 56c151e

Please sign in to comment.