flamendless / Slab

An immediate mode GUI for the Love2D framework.
MIT License
289 stars 25 forks source link

[Mouse] Read mouse arguments out of Args table #94

Closed idbrii closed 3 years ago

idbrii commented 3 years ago

Fix #20. Related to #80.

5fb76d3 changed the order of arguments from #80, so nothing was ever passed as TransformPointToSlab. Instead, pass it inside the args table that probably jives better with how things are done in slab.

The function arg to customize screen to slab coordinates isn't passed from Slab.Initialize -- it only passes the input table.

Usage with push.lua:

function love.load(args)
    local function get_push_mouse(x,y)
        local new_x,new_y = push:toGame(x,y)
        if new_x and new_y then
            return new_x,new_y
        end
        return x,y
    end
    local game_width, game_height, window_width, window_height = 320, 240, 1280, 720
    push:setupScreen(game_width, game_height, window_width, window_height)
    args.TransformPointToSlab = get_push_mouse
    Slab.Initialize(args)
end

function love.draw()
    push:start()
        Slab.Draw()
    push:finish()
end

Slab.Initialize is already ensuring that args is not nil.

flamendless commented 3 years ago

Thanks for this!

idbrii commented 3 years ago

Oh! Are you the new maintainer? Thanks for merging! 👍🏽

flamendless commented 3 years ago

Indeed i am. Thank you for contributing