Skip to content
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
12 changes: 12 additions & 0 deletions lovely/ui.toml
Original file line number Diff line number Diff line change
Expand Up @@ -552,3 +552,15 @@ pattern = '''
G.HUD_blind.alignment.offset.y = -10'''
payload = '''
ease_value(G.HUD.alignment.offset, 'y', 0 - G.HUD.alignment.offset.y)'''

# Tabbers becoming a cycle option instead of rolling offscreen
[[patches]]
[patches.regex]
target = 'functions/UI_definitions.lua'
position = 'at'
pattern = '''(?:( +local tab_buttons = \{\}\n)((?:[\s]|.)+?\)\n end))'''
payload = '''$1 if #args.tabs <= 8 then $2
else
local cycle_conf = SMODS.GUI.cycle_tabber_handle(tab_buttons, args)
args.current = {k = cycle_conf.current_option, v = args.tabs[cycle_conf.current_option]}
end'''
41 changes: 40 additions & 1 deletion src/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3402,6 +3402,45 @@ end

-- #endregion

SMODS.GUI.cycle_tabber_handle = function(tab_buttons, args)
local options = {}
local c_option = 0
for k,v in pairs(args.tabs) do
if v.chosen then c_option = k end
options[k] = v.label
end
local conf = {
options = options,
w = 7,
cycle_shoulders = true,
opt_callback = 'SMODS_cycle_tabber_move',
current_option = c_option,
colour = G.C.RED,
focus_args = {snap_to = true, nav = 'wide'},
tabs = args.tabs
}
tab_buttons[1] = create_option_cycle(conf)
return conf
end

G.FUNCS.SMODS_cycle_tabber_move = function(arg)
if not arg then return end
local _infotip_object = G.OVERLAY_MENU:get_UIE_by_ID('overlay_menu_infotip')
if _infotip_object and _infotip_object.config.object then
_infotip_object.config.object:remove()
_infotip_object.config.object = Moveable()
end

local tab_contents = G.OVERLAY_MENU:get_UIE_by_ID('tab_contents') --this should be e.UIBox but that's not accessible here
local tab_option = arg.cycle_config.tabs[arg.cycle_config.current_option]
tab_contents.config.object:remove()
tab_contents.config.object = UIBox{
definition = tab_option.tab_definition_function(tab_option.tab_definition_function_args),
config = {offset = {x=0,y=0}, parent = tab_contents, type = 'cm'}
}
tab_contents.UIBox:recalculate()
end

--#region run stake display changes


Expand Down Expand Up @@ -3487,4 +3526,4 @@ function G.UIDEF.SMODS_current_stake()
}}
end

-- #endregion
-- #endregion