diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/default.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/default.lua index c2d33cc04c..bba0ad4dc7 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/default.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/default.lua @@ -7,6 +7,7 @@ t[#t+1] = LoadActor("tabs") t[#t+1] = LoadActor("songinfo") t[#t+1] = LoadActor("score") t[#t+1] = LoadActor("profile") +t[#t+1] = LoadActor("filter") --t[#t+1] = LoadActor("../ExportSelection") -- will rewrite this myself later t[#t+1] = Def.ActorFrame { diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua new file mode 100644 index 0000000000..42ee5a2fbf --- /dev/null +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/filters.lua @@ -0,0 +1,116 @@ +local numbershers = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"} +local frameX = 10 +local frameY = 180+capWideScale(get43size(120),120) +local active = false +local whee +local filterspacing = 20 +local filtertextzoom = 0.35 +local ActiveSS = 0 +local SSQuery = {} +for i=1,#ms.SkillSets do + SSQuery[i] = "0" +end + + +local function FilterInput(event) + if event.type ~= "InputEventType_Release" and ActiveSS > 0 and active then + if event.button == "Start" or event.button == "Back" then + ActiveSS = 0 + MESSAGEMAN:Broadcast("NumericInputEnded") + SCREENMAN:set_input_redirected(PLAYER_1, false) + return true + elseif event.DeviceInput.button == "DeviceButton_backspace" then + SSQuery[ActiveSS] = SSQuery[ActiveSS]:sub(1, -2) -- remove the last element of the string + elseif event.DeviceInput.button == "DeviceButton_delete" then + SSQuery[ActiveSS] = "" + else + for i=1,#numbershers do -- add standard characters to string + if event.DeviceInput.button == "DeviceButton_"..numbershers[i] then + if SSQuery[ActiveSS] == "0" then + SSQuery[ActiveSS] = "" + end + SSQuery[ActiveSS] = SSQuery[ActiveSS]..numbershers[i] + end + end + end + if SSQuery[ActiveSS] == "" then + SSQuery[ActiveSS] = "0" + end + MESSAGEMAN:Broadcast("UpdateFilter") + if SSQuery[ActiveSS] ~= "" then + whee:SetSkillsetFilter(tonumber(SSQuery[ActiveSS]), ActiveSS) + end + end +end + +local f = Def.ActorFrame{ + InitCommand=cmd(xy,frameX+30,frameY-50;halign,0), + OnCommand=function(self) + whee = SCREENMAN:GetTopScreen():GetMusicWheel() + SCREENMAN:GetTopScreen():AddInputCallback(FilterInput) + self:visible(false) + end, + SetCommand=function(self) + self:finishtweening() + if getTabIndex() == 5 then + self:visible(true) + active = true + else + self:visible(false) + self:queuecommand("Off") + end + end, + TabChangedMessageCommand=cmd(queuecommand,"Set"), + MouseRightClickMessageCommand=function(self) + ActiveSS = 0 + MESSAGEMAN:Broadcast("UpdateFilter") + end, +} + +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 + ActiveSS = i + 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 + 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(SSQuery[i]) + if tonumber(SSQuery[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 + +return f \ No newline at end of file diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua index 54e6cf4b1d..32b7ef7575 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua @@ -1,33 +1,22 @@ local searchstring = "" local englishes = {"a", "b", "c", "d", "e","f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",";"} -local numbershers = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"} local frameX = 10 local frameY = 180+capWideScale(get43size(120),120) -local textsearchactive = false +local active = 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] = "0" -end - - local function searchInput(event) - if event.type ~= "InputEventType_Release" and textsearchactive == true then + if event.type ~= "InputEventType_Release" and active == true then if event.button == "Back" then searchstring = "" whee:SongSearch(searchstring) resetTabIndex(0) MESSAGEMAN:Broadcast("TabChanged") - MESSAGEMAN:Broadcast("EndingSearch", {ActiveFilter = ""}) + MESSAGEMAN:Broadcast("EndingSearch") elseif event.button == "Start" then resetTabIndex(0) - --SetPersistentSearch(searchstring) - MESSAGEMAN:Broadcast("EndingSearch", {ActiveFilter = searchstring}) + MESSAGEMAN:Broadcast("EndingSearch") MESSAGEMAN:Broadcast("TabChanged") elseif event.DeviceInput.button == "DeviceButton_space" then -- add space to the string searchstring = searchstring.." " @@ -49,33 +38,6 @@ local function searchInput(event) whee:SongSearch(searchstring) lastsearchstring = searchstring end - elseif event.type ~= "InputEventType_Release" and activeskillsetfilter > 0 then - if event.button == "Start" or event.button == "Back" then - textsearchactive = true - activeskillsetfilter = 0 - MESSAGEMAN:Broadcast("NumericInputEnded") - return true - elseif event.DeviceInput.button == "DeviceButton_backspace" then - skillsetfilterqueries[activeskillsetfilter] = skillsetfilterqueries[activeskillsetfilter]:sub(1, -2) -- remove the last element of the string - elseif event.DeviceInput.button == "DeviceButton_delete" then - skillsetfilterqueries[activeskillsetfilter] = "" - 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) - end end end @@ -91,13 +53,13 @@ local t = Def.ActorFrame{ ms.ok("Song search activated") MESSAGEMAN:Broadcast("BeginningSearch") self:visible(true) - textsearchactive = true + active = true SCREENMAN:set_input_redirected(PLAYER_1, true) MESSAGEMAN:Broadcast("RefreshSearchResults") else self:visible(false) self:queuecommand("Off") - textsearchactive = false + active = false SCREENMAN:set_input_redirected(PLAYER_1, false) end end, @@ -106,7 +68,7 @@ local t = Def.ActorFrame{ LoadFont("Common Large")..{ InitCommand=cmd(xy,frameX+250-capWideScale(get43size(120),30),frameY-90;zoom,0.7;halign,0.5;maxwidth,470), SetCommand=function(self) - if textsearchactive then + if active then self:settext("Search Active:") self:diffuse(getGradeColor("Grade_Tier03")) else @@ -147,71 +109,10 @@ 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"), }, } - - - -local f = Def.ActorFrame{ - 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 - - - return t \ No newline at end of file diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua index c7fd59df72..dc47eff477 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/tabs.lua @@ -43,7 +43,7 @@ t[#t+1] = LoadFont("Common Normal") .. { --]] --====================================================================================== -local tabNames = {"General","MSD","Score","Search","Profile","Other"} -- this probably should be in tabmanager. +local tabNames = {"General","MSD","Score","Search","Profile","Filters"} -- this probably should be in tabmanager. local frameWidth = (SCREEN_WIDTH*(403/854))/(#tabNames-1) local frameX = frameWidth/2 diff --git a/Themes/Til Death/Scripts/TabManager.lua b/Themes/Til Death/Scripts/TabManager.lua index a4868be1fc..41d18de67b 100644 --- a/Themes/Til Death/Scripts/TabManager.lua +++ b/Themes/Til Death/Scripts/TabManager.lua @@ -5,7 +5,7 @@ local tabIndex = 0 local tabSize = 5 local availTabSize = 2 -local availableTabs1P = {true,true,true,true,true,false} +local availableTabs1P = {true,true,true,true,true,true} local availableTabs2P = {true,false,false,false,true} --0 indexed tabs... yet 1 indexed lua tables mfw. Will probably go into infinite loop if everything is false. diff --git a/Themes/Til Death/Scripts/WifeSundries.lua b/Themes/Til Death/Scripts/WifeSundries.lua index 602dcc95d6..baa1eb47cd 100644 --- a/Themes/Til Death/Scripts/WifeSundries.lua +++ b/Themes/Til Death/Scripts/WifeSundries.lua @@ -76,17 +76,6 @@ ms.SkillSetsShort = { "Tech" } -local PersistentSearch - -function GetPersistentSearch() - if not PersistentSearch then return "" end - return PersistentSearch -end - -function SetPersistentSearch(s) - PersistentSearch = s -end - -- **Functions** function ms.ok(m) if not m then diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index 993cfe5185..e2bb53611c 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -1823,6 +1823,10 @@ class LunaMusicWheel : public Luna p->ReloadSongList(true, ""); return 1; } + static int GetSkillsetFilter(T* p, lua_State *L) { + p->GetSkillsetFilter(static_cast(IArg(2) - 1)); + return 1; + } LunaMusicWheel() { diff --git a/src/MusicWheel.h b/src/MusicWheel.h index ae124ff1ae..25ecdc2d05 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; } + float GetSkillsetFilter(Skillset ss) { return SkillsetFilters[ss]; } bool SkillsetFiltersActive = false; // Lua void PushSelf( lua_State *L );