Skip to content

Commit

Permalink
add IgnoreTabInput theme pref
Browse files Browse the repository at this point in the history
off: default behavior (dont ignore number tab inputs)
only in search: ignore number tab inputs when in search tab
always: always ignore number tab inputs
  • Loading branch information
Ulti-FD committed Jul 5, 2021
1 parent d234ee0 commit 2828be1
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
local searchstring = ""
local frameX = 10
local frameY = 180 + capWideScale(get43size(120), 120)
local frameY = 300
local active = false
local whee
local lastsearchstring = ""
local instantSearch = themeConfig:get_data().global.InstantSearch
local IgnoreTabInput = themeConfig:get_data().global.IgnoreTabInput

local function searchInput(event)
if event.type ~= "InputEventType_Release" and active == true then
Expand Down Expand Up @@ -36,7 +37,7 @@ local function searchInput(event)
elseif
--if not nil and (not a number or (ctrl pressed and not online))
event.char and event.char:match('[%%%+%-%!%@%#%$%^%&%*%(%)%=%_%.%,%:%;%\'%"%>%<%?%/%~%|%w%[%]%{%}%`%\\]') and
(not tonumber(event.char) or CtrlPressed)
(not tonumber(event.char) or CtrlPressed or IgnoreTabInput > 1)
then
searchstring = searchstring .. event.char
end
Expand All @@ -58,6 +59,7 @@ local translated_info = {
ExplainBack = THEME:GetString("TabSearch", "ExplainBack"),
ExplainDel = THEME:GetString("TabSearch", "ExplainDelete"),
ExplainLimit = THEME:GetString("TabSearch", "ExplainLimitation"),
ExplainNumInput = THEME:GetString("TabSearch", "ExplainNumInput")
}

local t =
Expand Down Expand Up @@ -141,10 +143,17 @@ local t =
LoadFont("Common Normal") ..
{
InitCommand = function(self)
self:xy(frameX + 20, frameY + 40):zoom(0.5):halign(0)
self:xy(frameX + 20, frameY + 50):zoom(0.5):halign(0)
self:settext(translated_info["ExplainLimit"])
end
},
LoadFont("Common Normal") ..
{
InitCommand = function(self)
self:xy(frameX + 20, frameY + 70):zoom(0.5):align(0,0)
self:settext(translated_info["ExplainNumInput"])
end
}
}

return t
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ local active = true
local numericinputactive = false
local whee

local function IgnoreTabInputs()
local IgnoreTabInput = themeConfig:get_data().global.IgnoreTabInput
if IgnoreTabInput == 3 then
return true
elseif IgnoreTabInput == 2 and getTabIndex() == 3 then
return true
else
return false
end
end

local tabNames = {"General", "MSD", "Scores", "Search", "Profile", "Filters", "Goals", "Playlists", "Packs", "Tags"} -- this probably should be in tabmanager.

local function input(event)
Expand All @@ -21,12 +32,14 @@ local function input(event)
return false
end

setTabIndex(9)
MESSAGEMAN:Broadcast("TabChanged", {from = tind, to = 9})
if not IgnoreTabInputs() then
setTabIndex(9)
MESSAGEMAN:Broadcast("TabChanged", {from = tind, to = 9})
end
else
for i = 1, #tabNames do
local numpad = event.DeviceInput.button == "DeviceButton_KP "..event.char -- explicitly ignore numpad inputs for tab swapping (doesn't care about numlock) -mina
if not numpad and event.char and tonumber(event.char) and tonumber(event.char) == i then
if not numpad and event.char and tonumber(event.char) and tonumber(event.char) == i and not IgnoreTabInputs() then
local tind = getTabIndex()
setTabIndex(i - 1)
MESSAGEMAN:Broadcast("TabChanged", {from = tind, to = i-1})
Expand Down
5 changes: 5 additions & 0 deletions Themes/Til Death/Languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ EWMA=EWMA
GradeBackground=Grade Background only
NPSDisplay=NPS Display
NPSGraph=NPS Graph
OnlyInSearch=Only In Search
Always=Always
PersonalBest=Personal Best
RandomPhrases=Random Phrases
SetPercent=Set Percent
Expand Down Expand Up @@ -179,6 +181,7 @@ ProgressBar = Progress Bar Location
ReceptorSize=Receptor Size
ShowVisualizer=Music Visualizer
InstantSearch=Instant Search
IgnoreTabInput=Ignore Tabs Input
[OptionExplanations]
ReceptorSize = Scale the size of the receptors and notes. This will also indirectly scale your scrolling speed.
Expand Down Expand Up @@ -226,6 +229,7 @@ MeasureLines=Toggle whether to display measure lines on the notefield. Please re
ProgressBar = Determines the location of the full progress bar during gameplay.
ShowVisualizer=Toggle whether to display the audio visualizer while on the Song Wheel
InstantSearch=Turn this on to have the Song Wheel update for every letter you put into the song search. If you lag when searching, turn this off.
IgnoreTabInput=While on the song wheel, number inputs do not change tabs.

[OffsetPlot]
ExplainLeft=Highlighting left hand taps
Expand Down Expand Up @@ -530,6 +534,7 @@ ExplainStart=Start to lock search results.
ExplainBack=Escape to cancel search.
ExplainDelete=Delete resets search query.
ExplainLimitation=Currently supports standard English alphabet only.
ExplainNumInput=Hold Ctrl to input numbers (this behavior can be \nchanged via a Theme Option)
RoomTitle=Title
RoomSubtitle=Desc
RoomOpened=Open
Expand Down
1 change: 1 addition & 0 deletions Themes/Til Death/Scripts/01 theme_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local defaultConfig = {
ProgressBar = 1, -- 0 = bottom, 1 = top
ShowVisualizer = true,
InstantSearch = true, -- true = search per press, false = search on enter button
IgnoreTabInput = 1, -- 1 = dont ignore, 2 = ignore only in search, 3 = always
},
NPSDisplay = {
DynamicWindow = false,
Expand Down
44 changes: 42 additions & 2 deletions Themes/Til Death/Scripts/02 ThemePrefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ function LaneCover()
ExportOnChange = true,
Choices = {
THEME:GetString("OptionNames", "Off"),
THEME:GetString("OptionNames", "Sudden"),
THEME:GetString("OptionNames", "Sudden"),
THEME:GetString("OptionNames", "Hidden")
},
LoadSelections = function(self, list, pn)
Expand Down Expand Up @@ -635,7 +635,7 @@ function BackgroundType()
ExportOnChange = true,
Choices = {
THEME:GetString("OptionNames", "Default"),
THEME:GetString("OptionNames", "StaticBG"),
THEME:GetString("OptionNames", "StaticBG"),
THEME:GetString("OptionNames", "RandomBG")
},
LoadSelections = function(self, list, pn)
Expand Down Expand Up @@ -1041,6 +1041,46 @@ function InstantSearch()
return t
end

function IgnoreTabInput()
local t = {
Name = "IgnoreTabInput",
LayoutType = "ShowAllInRow",
SelectType = "SelectOne",
OneChoiceForAllPlayers = true,
ExportOnChange = true,
Choices = {
THEME:GetString("OptionNames", "Off"),
THEME:GetString("OptionNames", "OnlyInSearch"),
THEME:GetString("OptionNames", "Always")
},
LoadSelections = function(self, list, pn)
local pref = themeConfig:get_data().global.IgnoreTabInput
if pref == 1 then
list[1] = true
elseif pref == 2 then
list[2] = true
else
list[3] = true
end
end,
SaveSelections = function(self, list, pn)
local value
if list[1] == true then
value = 1
elseif list[2] == true then
value = 2
else
value = 3
end
themeConfig:get_data().global.IgnoreTabInput = value
themeConfig:set_dirty()
themeConfig:save()
end
}
setmetatable(t, t)
return t
end

function ProgressBar()
local keymode = getCurrentKeyMode()
local t = {
Expand Down
3 changes: 2 additions & 1 deletion Themes/Til Death/metrics.ini
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ LineInputOptions="gamecommand;screen,ScreenOptionsInputSub;name,InputOptions"
Fallback="ScreenOptionsServiceChild"
NextScreen="ScreenOptionsService"
PrevScreen="ScreenOptionsService"
LineNames="SongBGEnabled,RateSort,HelpMenu,NPSWindow,MeasureLines,Visualizer,InstantSearch"
LineNames="SongBGEnabled,RateSort,HelpMenu,NPSWindow,MeasureLines,Visualizer,InstantSearch,IgnoreTabInput"
#LineDefaultScore="lua,DefaultScoreType()"
LineTipType="lua,TipType()"
LineSongBGEnabled="lua,SongBGEnabled()"
Expand All @@ -573,6 +573,7 @@ LineNPSWindow="lua,NPSWindow()"
LineMeasureLines="lua,MeasureLines()"
LineVisualizer="lua,ShowVisualizer()"
LineInstantSearch="lua,InstantSearch()"
LineIgnoreTabInput="lua,IgnoreTabInput()"

[ScreenTextEntry]
QuestionX=SCREEN_CENTER_X
Expand Down

0 comments on commit 2828be1

Please sign in to comment.