Skip to content

luaengine: add HUD-like capabilities#90

Merged
galibert merged 2 commits intomamedev:masterfrom
lucab:lucab/mame-lua/gui-v2
Jan 5, 2015
Merged

luaengine: add HUD-like capabilities#90
galibert merged 2 commits intomamedev:masterfrom
lucab:lucab/mame-lua/gui-v2

Conversation

@lucab
Copy link
Copy Markdown
Contributor

@lucab lucab commented Dec 25, 2014

These commits add a way to let LUA scripts register a callback
to be invoked before rendering each frame.
This callback typically makes use of other provided methods to draw
custom graphics on top of each frame.

The idea is to let LUA script provide HUD-like features, mostly used for
trainings and TAS runs development.

Signed-off-by: Luca Bruno lucab@debian.org

This commit allows LUA scripts to implement HUD capabilities,
by overlaying elements (lines, boxes, text) to screen.
Mostly used to draw custom graphic helpers for trainings and
TAS runs development.

Signed-off-by: Luca Bruno <lucab@debian.org>
This commit adds a method to let LUA scripts register a callback
to be invoked before rendering each frame.
This callback typically makes use of screen drawing methods to
draw a custom HUD on top of each frame.

Signed-off-by: Luca Bruno <lucab@debian.org>
@lucab
Copy link
Copy Markdown
Contributor Author

lucab commented Dec 25, 2014

This is v2 of #71, OO-ified after some suggestions from @galibert.

Major changes:

  • now using luabridge, more C++ friendly
  • available screens now enumerable via manager():machine().screens
  • instance methods to draw boxes/lines/text on a single screen separately

@lucab
Copy link
Copy Markdown
Contributor Author

lucab commented Dec 25, 2014

Just as a note, this is a very dumb LUA autoboot_script I'm using to test all of lua_engine current capabilities:

local g = {
        x = 0,
        y = 0
}

local mem=manager:machine().devices[":maincpu"].spaces["program"]
local gui=manager:machine().screens[":screen"]

emu.sethook(function()
        gui:draw_text(g.x, g.y, mem:read_i16(0x0000C000))
        gui:draw_box(20,20, g.x, g.y, 0, 0xffff0000)
        gui:draw_line(20,20, g.x, g.y, 0xff0000ff)
        g.x = g.x + 1;
        g.y = g.y + 1;
        if (g.x+5) >= gui:width() then
            g.x = 0
        end
        if g.y >= gui:height() then
            g.y = 0
        end
end, "frame")

@lucab
Copy link
Copy Markdown
Contributor Author

lucab commented Jan 5, 2015

@galibert @mmicko can I get a review on this?

@galibert
Copy link
Copy Markdown
Member

galibert commented Jan 5, 2015

Eventually the hook should be per-screen, because different screens can
theorically gave different frame rates. But the core is currently fucked
in that area, so you can't do it.

OG.

On Mon, Jan 5, 2015 at 5:54 PM, Luca Bruno notifications@github.com wrote:

@galibert https://github.com/galibert @mmicko
https://github.com/mmicko can I get a review on this?


Reply to this email directly or view it on GitHub
#90 (comment).

galibert added a commit that referenced this pull request Jan 5, 2015
luaengine: add HUD-like capabilities
@galibert galibert merged commit f67e16a into mamedev:master Jan 5, 2015
@lucab lucab deleted the lucab/mame-lua/gui-v2 branch January 6, 2015 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants