[manifest]
version = "1.0.0"
dump_lua = true
priority = 69

# Replace joker sorting. Needs better mod compat
[[patches]] 
[patches.pattern]
target = "cardarea.lua"
pattern = "if self.config.type == 'joker' or self.config.type == 'title_2' then"
position = "at"
payload = '''
if self == G.jokers and G.jokers.cart_jokers_expanded then
    local align_cards = Cartomancer.expand_G_jokers()

    -- This should work fine without cryptid. But because cryptid's patch is priority=0, it has to be this way
    if not G.GAME.modifiers.cry_conveyor then 
        table.sort(self.cards, function (a, b) return a.T.x + a.T.w/2 - 100*(a.pinned and a.sort_id or 0) < b.T.x + b.T.w/2 - 100*(b.pinned and b.sort_id or 0) end)
    end
    
    if align_cards then
        G.jokers:hard_set_cards()
    end
elseif self.config.type == 'joker' or self.config.type == 'title_2' then'''
match_indent = true

# Hide all cards that are off-screen
[[patches]] 
[patches.pattern]
target = "card.lua"
pattern = "if not self.states.visible then return end"
position = "after"
payload = '''
if self.VT.x < -3 or self.VT.x > G.TILE_W + 2.5 then return end'''
match_indent = true

# Add slider ID
[[patches]]
[patches.pattern]
target = "functions/UI_definitions.lua"
pattern = '''{n=G.UIT.B, config={w=startval,h=args.h, r = 0.1, colour = args.colour, ref_table = args, refresh_movement = true}},'''
position = "at"
payload = '''
{n=G.UIT.B, config={id = args.id, w=startval,h=args.h, r = 0.1, colour = args.colour, ref_table = args, refresh_movement = true}},
'''
match_indent = true

# Hide slider value
[[patches]] 
[patches.regex]
target = "functions/UI_definitions.lua"
pattern = '''
(?<content>\{n=G\.UIT\.C\, config=\{align = "cm"\, minh = args\.h\,r = 0\.1\, minw = 0\.8\, colour = args\.colour\,shadow = true\}\, nodes=\{
[\t ]*\{n=G\.UIT\.T\, config=\{ref_table = args\, ref_value = 'text'\, scale = args\.text_scale\, colour = G\.C\.UI\.TEXT_LIGHT\, decimal_places = args\.decimal_places\}\}
[\t ]*\}\})\,'''
position = "at"
payload = '''
not args.hide_val and $content or nil'''
