Skip to content

Commit

Permalink
commit wip filters before moving them to a new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jan 13, 2017
1 parent d614537 commit 17520b4
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ local frameY = 180+capWideScale(get43size(120),120)
local textsearchactive = false
local whee
local lastsearchstring = ""

-- filter stuff should probably be separated from this eventually? - mina
local activeskillsetfilter = 0
local skillsetfilterqueries = {}

for i=1,#ms.SkillSets do
skillsetfilterqueries[i] = ""
skillsetfilterqueries[i] = "0"
end


Expand Down Expand Up @@ -48,7 +50,7 @@ local function searchInput(event)
lastsearchstring = searchstring
end
elseif event.type ~= "InputEventType_Release" and activeskillsetfilter > 0 then
if event.button == "Start" then
if event.button == "Start" or event.button == "Back" then
textsearchactive = true
activeskillsetfilter = 0
MESSAGEMAN:Broadcast("NumericInputEnded")
Expand All @@ -60,10 +62,16 @@ local function searchInput(event)
else
for i=1,#numbershers do -- add standard characters to string
if event.DeviceInput.button == "DeviceButton_"..numbershers[i] then
if skillsetfilterqueries[activeskillsetfilter] == "0" then
skillsetfilterqueries[activeskillsetfilter] = ""
end
skillsetfilterqueries[activeskillsetfilter] = skillsetfilterqueries[activeskillsetfilter]..numbershers[i]
end
end
end
if skillsetfilterqueries[activeskillsetfilter] == "" then
skillsetfilterqueries[activeskillsetfilter] = "0"
end
MESSAGEMAN:Broadcast("UpdateFilter")
if skillsetfilterqueries[activeskillsetfilter] ~= "" then
whee:SetSkillsetFilter(tonumber(skillsetfilterqueries[activeskillsetfilter]), activeskillsetfilter)
Expand Down Expand Up @@ -139,7 +147,7 @@ local t = Def.ActorFrame{
LoadFont("Common Normal")..{
InitCommand=cmd(xy,frameX+20,frameY+70;zoom,0.5;halign,0),
SetCommand=function(self)
self:settext("Currently supports standard english alphabet only.")
--self:settext("Currently supports standard english alphabet only.")
end,
UpdateStringMessageCommand=cmd(queuecommand,"Set"),
},
Expand All @@ -148,31 +156,59 @@ local t = Def.ActorFrame{




local i = 1

local f = Def.ActorFrame{
InitCommand=cmd(xy,frameX+20,frameY-75;zoom,0.4;halign,0),
LoadFont("Common Large")..{
InitCommand=cmd(xy,frameX+20,frameY-70;zoom,0.5;halign,0),
SetCommand=cmd(settext, "Overall")
},
Def.Quad{
InitCommand=cmd(zoomto,100,100),
MouseLeftClickMessageCommand=function(self)
if isOver(self) then
textsearchactive = false
activeskillsetfilter = i
MESSAGEMAN:Broadcast("NumericInputActive")
end
end,
},
LoadFont("Common Large")..{
InitCommand=cmd(xy,frameX+170,frameY-70;zoom,0.5;halign,0),
SetCommand=cmd(settext, skillsetfilterqueries[i]),
UpdateFilterMessageCommand=cmd(queuecommand,"Set"),
},
InitCommand=cmd(xy,frameX+30,frameY-50;halign,0),
}
local filterspacing = 20
local filtertextzoom = 0.35
local function CreateFilterInputBox(i)
local t = Def.ActorFrame{
LoadFont("Common Large")..{
InitCommand=cmd(addy,(i-1)*filterspacing;halign,0;zoom,filtertextzoom),
SetCommand=cmd(settext, ms.SkillSets[i])
},
Def.Quad{
InitCommand=cmd(addx,135;addy,(i-1)*filterspacing;zoomto,18,18;halign,1),
MouseLeftClickMessageCommand=function(self)
if isOver(self) then
textsearchactive = false
activeskillsetfilter = i
ms.ok("Skillset "..i.." Activated")
MESSAGEMAN:Broadcast("NumericInputActive")
self:diffusealpha(0.1)
end
end,
SetCommand=function(self)
if activeskillsetfilter ~= i then
self:diffuse(color("#000000"))
else
self:diffuse(color("#666666"))
end
end,
UpdateFilterMessageCommand=cmd(queuecommand,"Set"),
NumericInputEndedMessageCommand=cmd(queuecommand,"Set"),
},
LoadFont("Common Large")..{
InitCommand=cmd(addx,135;addy,(i-1)*filterspacing;halign,1;maxwidth,40;zoom,filtertextzoom),
SetCommand=function(self)
self:settext(skillsetfilterqueries[i])
if tonumber(skillsetfilterqueries[i]) <= 0 then
self:diffuse(color("#666666"))
else
self:diffuse(color("#FFFFFF"))
end
end,
UpdateFilterMessageCommand=cmd(queuecommand,"Set"),
},
}
return t
end

for i=1,#ms.SkillSets do
f[#f+1] = CreateFilterInputBox(i)
end



t[#t+1] = f

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ local t = Def.ActorFrame{
OnCommand=function(self) SCREENMAN:GetTopScreen():AddInputCallback(input) end,
BeginCommand=function(self) resetTabIndex() end,
PlayerJoinedMessageCommand=function(self) resetTabIndex() end,
BeginningSearchMessageCommand=function(self) active = true end,
BeginningSearchMessageCommand=function(self) active = true end, -- this is for disabling numeric input in the text search and is unused atm
EndingSearchMessageCommand=function(self) active = true end,
NumericInputActiveMessageCommand=function(self)
ms.ok("woot")
numericinputactive = true
end,
NumericInputActiveMessageCommand=function(self) numericinputactive = true end,
NumericInputEndedMessageCommand=function(self) numericinputactive = false end,
}

Expand Down
13 changes: 5 additions & 8 deletions src/MusicWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,17 +604,11 @@ void MusicWheel::FilterBySkillsets(vector<Song*>& inv) {
bool addsong = false;
FOREACH_ENUM(Skillset, ss) {
if (SkillsetFilters[ss] > 0.f) {
LOG->Trace("%i", (int)ss);
float val = inv[i]->GetHighestSkillsetAllSteps(static_cast<int>(ss));
LOG->Trace("val %f", val);
LOG->Trace("comp %f", SkillsetFilters[ss]);
if (val > SkillsetFilters[ss]) {
LOG->Trace("hi");
if (val > SkillsetFilters[ss])
addsong = addsong || true;
}
}
}
LOG->Trace("addsong %i", addsong);
if (addsong == true)
tmp.emplace_back(inv[i]);
}
Expand Down Expand Up @@ -673,7 +667,8 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt

if (searching) {
FilterBySearch(arraySongs, findme);
FilterBySkillsets(arraySongs);
if (SkillsetFiltersActive)
FilterBySkillsets(arraySongs);
}

bool bUseSections = true;
Expand Down Expand Up @@ -1823,6 +1818,8 @@ class LunaMusicWheel : public Luna<MusicWheel>
}
static int SetSkillsetFilter(T* p, lua_State *L) {
p->SetSkillsetFilter(FArg(1), static_cast<Skillset>(IArg(2)-1));
if(FArg(1) > 0)
p->SkillsetFiltersActive = true;
p->ReloadSongList(true, "");
return 1;
}
Expand Down
1 change: 1 addition & 0 deletions src/MusicWheel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class MusicWheel : public WheelBase

// mina was here - mina
void SetSkillsetFilter(float v, Skillset ss) { SkillsetFilters[ss] = v; }
bool SkillsetFiltersActive = false;
// Lua
void PushSelf( lua_State *L );

Expand Down

0 comments on commit 17520b4

Please sign in to comment.