From 17520b47b14167e01655473636720d35c02275be Mon Sep 17 00:00:00 2001 From: MinaciousGrace Date: Fri, 13 Jan 2017 03:14:52 -0500 Subject: [PATCH] commit wip filters before moving them to a new tab --- .../songsearch.lua | 88 +++++++++++++------ .../ScreenSelectMusic decorations/tabs.lua | 7 +- src/MusicWheel.cpp | 13 ++- src/MusicWheel.h | 1 + 4 files changed, 70 insertions(+), 39 deletions(-) diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua index 2cd7804cc4..54e6cf4b1d 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua @@ -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 @@ -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") @@ -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) @@ -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"), }, @@ -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 diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua index 6da3647e8a..c7fd59df72 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua @@ -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, } diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index e20808a548..993cfe5185 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -604,17 +604,11 @@ void MusicWheel::FilterBySkillsets(vector& 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(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]); } @@ -673,7 +667,8 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt if (searching) { FilterBySearch(arraySongs, findme); - FilterBySkillsets(arraySongs); + if (SkillsetFiltersActive) + FilterBySkillsets(arraySongs); } bool bUseSections = true; @@ -1823,6 +1818,8 @@ class LunaMusicWheel : public Luna } static int SetSkillsetFilter(T* p, lua_State *L) { p->SetSkillsetFilter(FArg(1), static_cast(IArg(2)-1)); + if(FArg(1) > 0) + p->SkillsetFiltersActive = true; p->ReloadSongList(true, ""); return 1; } diff --git a/src/MusicWheel.h b/src/MusicWheel.h index 31f4fc3a60..ae124ff1ae 100644 --- a/src/MusicWheel.h +++ b/src/MusicWheel.h @@ -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 );