Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hamod Extra Buttons

This mod allows you to add custom buttons to Jokers, Consumables, or any other card.

Examples

HAMOD_BUTTONS.register_group({
    key = 'group1',
    get_config = function(card)
        return {
            offset = {x = 0.35, y = 0},
            align = 'cl'
        }
    end
})

HAMOD_BUTTONS.register_button({
    group = 'group1',
    can_use = function(card)
        return true
    end,
    use = function(card)
        print("Button pressed")
    end,
    get_styling = function(card)
        return {
            text_color = G.C.GOLD,
            height = 0,
            button_color = G.C.CHIPS
        }
    end
})

HAMOD_BUTTONS.register_button({
    group = 'group1',
    can_use = function(card)
        return true
    end,
    use = function(card)
        print("Button pressed")
    end,
    is_visible = function(card)
        return card.area == G.jokers
    end
})

API Documentation

Group parameters
Required
key Identifier of the group\

Optional
get_config = function(card) Function to return the alignment and offset of the group

overwrites = '' Button group which should be overwritten. Useful to replace/extend vanilla behavior ('use_button' for the use and sell buttons on cards)

standalone = false Set this to true, if the button group defines it's own UIBox via generate_UIBox. This makes it impossible to add any buttons to the group

is_visible = function(card) Use this to control if the button group as a whole should be visible. Must be set if standalone == true, otherwise the group is always visible

generate_UIBox = function(card) Use this to define a fully custom UIBox. Must be set if standalone == true, otherwise the group won't show

generate_UIBox = function(card)
        local x_off = (card.ability.consumeable and -0.1 or 0)
        return UIBox{
            definition = custom_ui(),
            config = {
                align = "bmi",
                offset = {x=0,y=0.35},
                parent = card
            }
        }
    end

get_config = function(card) Use this to define custom styling information which is then applied to a UIBox template. Gets ignored when generate_UIBox is defined

return {
    align = 'cl',
    offset = card.ability.consumeable and {x = 0.5, y = 0} or {x = 0.35, y = 0}
    parent = card,
    bond = nil,
    major = nil,
    styling = {
       orientation = 'column'
    }
}

Button parameters
Required
can_use = function(card) Function to determine if the button should currently be enabled or disabled (greyed out). The game calls this every frame the button is visible

use = function(card) Function to execute when the button is pressed

Optional
group Key of a registered group. Buttons in a group are positioned relative to each other. Defaults to 'default'

is_visible = function(card) By default, every card will show this button in every context. Use this function, to limit this to certain types (Jokers, Consumables) or only in certain areas (G.jokers, G.shop_jokers)

get_styling = function(card) Function to return styling information for the button

return {
    text = 'Use', -- Text that is displayed on the button
    font_color = G.C.WHITE, -- Color of the font
    text_align = 'cl', -- Alignment of the text within the button
    text_scale = 0.55, -- Size of the text
    button_color = G.C.GREEN, -- Color of the button
    height = 1, -- Height of the button. Min height is dependent on the padding
    width = 1.25, -- Width of the button. Min width is dependent on the padding
    padding = 0.1 -- Padding inside of the button
    rounding = 0.08, -- Rounding on the buttons corners
}

generate_ui = function(card) Function to return a custom button ui, instead of using a template enriched with get_styling

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages