Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter preset functionality #1277

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 69 additions & 6 deletions Themes/Rebirth/BGAnimations/playerInfoFrame/searchfilter.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local filterpreset = require('filterpreset')

local ratios = {
Width = 782 / 1920,
Height = 971 / 1080,
Expand Down Expand Up @@ -55,6 +57,9 @@ local translations = {
Results = THEME:GetString("SearchFilter", "Results"),
Reset = THEME:GetString("SearchFilter", "Reset"),
Apply = THEME:GetString("SearchFilter", "Apply"),
SaveToDefaultPreset = THEME:GetString("FilterPreset", "SaveToDefaultPreset"),
ExportPresetToFile = THEME:GetString("FilterPreset", "ExportPresetToFile"),
SaveFilterPresetPrompt = THEME:GetString("FilterPreset", "SaveFilterPresetPrompt"),
}

local visibleframeX = SCREEN_WIDTH - actuals.Width
Expand Down Expand Up @@ -189,13 +194,13 @@ local function upperSection()
local foundtitle = ""
local foundsubtitle = ""
local foundgroup = ""

if artistpos ~= nil or authorpos ~= nil or
titlepos ~= nil or subtitlepos ~= nil or
mapperpos ~= nil or charterpos ~= nil or
stepperpos ~= nil or grouppos ~= nil or
packpos ~= nil then

if artistpos ~= nil then
local strend = input:find("[;]", artistpos+1)
if strend == nil then strend = #input else strend = strend-1 end
Expand Down Expand Up @@ -251,7 +256,7 @@ local function upperSection()
end

-- you know what im just going to update all the other entry fields based on this one

end,
-- "Title Search"
function(input)
Expand Down Expand Up @@ -436,7 +441,7 @@ local function upperSection()
end
if searchentry.Group ~= "" then
finalstr = finalstr .. "group="..searchentry.Group..";"
end
end
end
self:GetChild("RowFrame_1"):GetChild("RowInput"):settext(finalstr)
end
Expand Down Expand Up @@ -1066,7 +1071,7 @@ local function lowerSection()
else
return
end

minrate = clamp(clamp(minrate + increment, 0.7, FILTERMAN:GetMaxFilterRate()), 0.7, 3)
FILTERMAN:SetMinFilterRate(minrate)
self:playcommand("UpdateText")
Expand Down Expand Up @@ -1170,6 +1175,60 @@ local function lowerSection()
end
}

t[#t+1] = filterMiscLine(9) .. {
Name = "SaveLine",
InitCommand = function(self)
self:settext(translations["SaveToDefaultPreset"])
end,
MouseOverCommand = onHover,
MouseOutCommand = onUnHover,
MouseDownCommand = function(self)
filterpreset.save_preset("default", PLAYER_1)
end
}


t[#t+1] = filterMiscLine(10) .. {
Name = "ExportLine",
InitCommand = function(self)
self:settext(translations["ExportPresetToFile"])
end,
MouseOverCommand = onHover,
MouseOutCommand = onUnHover,
MouseDownCommand = function(self)
local redir = SCREENMAN:get_input_redirected(PLAYER_1)
local function off()
if redir then
SCREENMAN:set_input_redirected(PLAYER_1, false)
end
end
local function on()
if redir then
SCREENMAN:set_input_redirected(PLAYER_1, true)
end
end
off()

askForInputStringWithFunction(
translations["SaveFilterPresetPrompt"],
32,
false,
function(answer)
-- success if the answer isnt blank
if answer:gsub("^%s*(.-)%s*$", "%1") ~= "" then
filterpreset.save_preset(answer)
else
on()
end
end,
function() return true, "" end,
function()
on()
end
)
end
}

return t
end

Expand Down Expand Up @@ -1218,4 +1277,8 @@ t[#t+1] = Def.Quad {
t[#t+1] = upperSection()
t[#t+1] = lowerSection()

return t
-- Load default preset if it exists. We should only be setting the values once
-- at startup. Subsequent calls should not occur.
filterpreset.load_preset("default", false, PLAYER_1)

return t
7 changes: 6 additions & 1 deletion Themes/Rebirth/Languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,11 @@ Results=Matches
Reset=Reset
Apply=Apply

[FilterPreset]
ExportPresetToFile=Export
SaveFilterPresetPrompt=Enter filter preset file name:
SaveToDefaultPreset=Save

[Settings]
NothingBound=none
CurrentlyBinding=Currently Binding
Expand Down Expand Up @@ -1021,4 +1026,4 @@ Bm_Double7=14K+2
Maniax_Single=4K
Maniax_Double=8K
Pnm_Five=5K
Pnm_Nine=9K
Pnm_Nine=9K
Loading
Loading