Skip to content

Commit

Permalink
move filters to a separate tab
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jan 13, 2017
1 parent 17520b4 commit 2ae00cf
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.." "
Expand All @@ -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

Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/Scripts/TabManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 0 additions & 11 deletions Themes/Til Death/Scripts/WifeSundries.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/MusicWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,10 @@ class LunaMusicWheel : public Luna<MusicWheel>
p->ReloadSongList(true, "");
return 1;
}
static int GetSkillsetFilter(T* p, lua_State *L) {
p->GetSkillsetFilter(static_cast<Skillset>(IArg(2) - 1));
return 1;
}

LunaMusicWheel()
{
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; }
float GetSkillsetFilter(Skillset ss) { return SkillsetFilters[ss]; }
bool SkillsetFiltersActive = false;
// Lua
void PushSelf( lua_State *L );
Expand Down

0 comments on commit 2ae00cf

Please sign in to comment.