diff options
| author | 2023-04-07 06:20:40 +1000 | |
|---|---|---|
| committer | 2023-04-07 06:20:40 +1000 | |
| commit | b67b969bf0911d71396c77e42d85ddfe80de6f20 (patch) | |
| tree | 8d964eac6e0c4c849dc2b9b0b3742154c6c943d4 /plugins/layout | |
| parent | c4282fecede9032be78028e8fde737d44bf2b7c6 (diff) | |
-Improved some Lua APIs:
* Moved several machine lifecycle callbacks to the notifier/subscriber
model. The old callback registration model is still available for
them for now, but prints a deprecation warning.
* Added pre-save/post-load notifications.
* Use a single allocated timer rather than one anonymous timer per
waiter. Waiters no longer prevent saved states from being loaded.
* Clean up outstanding waiters on stop or state load rather than just
leaking them.
* Started documenting parts of the emulator interface object that should
be relatively stable.
-imagedev/avivideo.cpp: Fixed an object leak on unload. Also changed
some other media image devices to use smart pointers.
Diffstat (limited to 'plugins/layout')
| -rw-r--r-- | plugins/layout/init.lua | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/plugins/layout/init.lua b/plugins/layout/init.lua index 861e0a697b3..a7d3f7fb199 100644 --- a/plugins/layout/init.lua +++ b/plugins/layout/init.lua @@ -2,15 +2,17 @@ -- copyright-holders:Carl -- Layout scripts should return a table and a string. The table can have two optional keys reset and frame -- which have functions for values called on reset and frame draw respectively and the string is a unique name. -local exports = {} -exports.name = "layout" -exports.version = "0.0.1" -exports.description = "Layout helper plugin" -exports.license = "BSD-3-Clause" -exports.author = { name = "Carl" } +local exports = { + name = "layout", + version = "0.0.1", + description = "Layout helper plugin", + license = "BSD-3-Clause", + author = { name = "Carl" } } local layout = exports +local frame_subscription, stop_subscription + function layout.startplugin() local scripts = {} local function prepare_layout(file, script) @@ -45,7 +47,7 @@ function layout.startplugin() end emu.register_callback(prepare_layout, "layout") - emu.register_frame(function() + frame_subscription = emu.add_machine_frame_notifier(function () if manager.machine.paused then return end @@ -55,14 +57,16 @@ function layout.startplugin() end end end) - emu.register_start(function() + emu.register_prestart(function () for num, scr in pairs(scripts) do if scr.reset then scr.reset() end end end) - emu.register_stop(function() scripts = {} end) + stop_subscription = emu.add_machine_stop_notifier(function () + scripts = {} + end) end return exports |
