From aac4e79d4b62decf5b53683b100525587b5091c8 Mon Sep 17 00:00:00 2001 From: npwoods Date: Wed, 24 Jul 2019 07:14:56 -0400 Subject: Refactored MAME's plugin system --- plugins/boot.lua | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'plugins/boot.lua') diff --git a/plugins/boot.lua b/plugins/boot.lua index 5ed1ac803ad..98eb14baa86 100644 --- a/plugins/boot.lua +++ b/plugins/boot.lua @@ -26,27 +26,11 @@ local dir = lfs.env_replace(manager:options().entries.pluginspath:value()) package.path = dir .. "/?.lua;" .. dir .. "/?/init.lua" -local json = require('json') -local function readAll(file) - local f = io.open(file, "rb") - local content = f:read("*all") - f:close() - return content -end - -for file in lfs.dir(dir) do - if (file~="." and file~=".." and lfs.attributes(dir .. "/" .. file,"mode")=="directory") then - local filename = dir .. "/" .. file .. "/plugin.json" - local meta = json.parse(readAll(filename)) - if (meta["plugin"]["type"]=="plugin") and (mame_manager:plugins().entries[meta["plugin"]["name"]]~=nil) then - local entry = mame_manager:plugins().entries[meta["plugin"]["name"]] - if (entry:value()==true) then - emu.print_verbose("Starting plugin " .. meta["plugin"]["name"] .. "...") - plugin = require(meta["plugin"]["name"]) - if plugin.set_folder~=nil then plugin.set_folder(dir .. "/" .. file) end - plugin.startplugin(); - end - end +for _,entry in pairs(manager:plugins()) do + if (entry.type == "plugin" and entry.start) then + emu.print_verbose("Starting plugin " .. entry.name .. "...") + plugin = require(entry.name) + if plugin.set_folder~=nil then plugin.set_folder(entry.directory) end + plugin.startplugin(); end end - -- cgit v1.2.3-70-g09d2