mirror of
https://github.com/holub/mame
synced 2025-06-09 14:22:41 +03:00
Populate plugins structures and start marked plugins (nw)
This commit is contained in:
parent
db10880ee0
commit
f329db261f
@ -16,10 +16,14 @@ for file in lfs.dir("plugins") do
|
|||||||
if (file~="." and file~=".." and lfs.attributes("plugins/" .. file,"mode")=="directory") then
|
if (file~="." and file~=".." and lfs.attributes("plugins/" .. file,"mode")=="directory") then
|
||||||
local filename = "plugins/" .. file .. "/plugin.json"
|
local filename = "plugins/" .. file .. "/plugin.json"
|
||||||
local meta = json.parse(readAll(filename))
|
local meta = json.parse(readAll(filename))
|
||||||
if (meta["plugin"]["type"]=="plugin") and (meta["plugin"]["start"]=="true") then
|
if (meta["plugin"]["type"]=="plugin") and (manager:plugins().entries[meta["plugin"]["name"]]~=nil) then
|
||||||
server = require(meta["plugin"]["name"])
|
local entry = manager:plugins().entries[meta["plugin"]["name"]]
|
||||||
if server.set_folder~=nil then server.set_folder("plugins/" .. file) end
|
if (entry:value()==true) then
|
||||||
server.startplugin();
|
print("Starting plugin " .. meta["plugin"]["name"] .. "...")
|
||||||
|
plugin = require(meta["plugin"]["name"])
|
||||||
|
if plugin.set_folder~=nil then plugin.set_folder("plugins/" .. file) end
|
||||||
|
plugin.startplugin();
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1630,6 +1630,21 @@ void cli_frontend::execute_commands(const char *exename)
|
|||||||
|
|
||||||
// generate the updated INI
|
// generate the updated INI
|
||||||
file_ui.puts(ui_opts.output_ini().c_str());
|
file_ui.puts(ui_opts.output_ini().c_str());
|
||||||
|
|
||||||
|
plugin_options plugin_opts;
|
||||||
|
path_iterator iter(m_options.plugins_path());
|
||||||
|
std::string pluginpath;
|
||||||
|
while (iter.next(pluginpath))
|
||||||
|
{
|
||||||
|
plugin_opts.parse_json(pluginpath);
|
||||||
|
}
|
||||||
|
emu_file file_plugin(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||||
|
if (file_plugin.open("plugin.ini") != osd_file::error::NONE)
|
||||||
|
throw emu_fatalerror("Unable to create file plugin.ini\n");
|
||||||
|
|
||||||
|
// generate the updated INI
|
||||||
|
file_plugin.puts(plugin_opts.output_ini().c_str());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1436,6 +1436,7 @@ void lua_engine::initialize()
|
|||||||
.beginClass <machine_manager> ("manager")
|
.beginClass <machine_manager> ("manager")
|
||||||
.addFunction ("machine", &machine_manager::machine)
|
.addFunction ("machine", &machine_manager::machine)
|
||||||
.addFunction ("options", &machine_manager::options)
|
.addFunction ("options", &machine_manager::options)
|
||||||
|
.addFunction ("plugins", &machine_manager::plugins)
|
||||||
.endClass ()
|
.endClass ()
|
||||||
.beginClass <lua_machine> ("lua_machine")
|
.beginClass <lua_machine> ("lua_machine")
|
||||||
.addCFunction ("popmessage", &lua_machine::l_popmessage)
|
.addCFunction ("popmessage", &lua_machine::l_popmessage)
|
||||||
@ -1564,6 +1565,8 @@ void lua_engine::initialize()
|
|||||||
.endClass()
|
.endClass()
|
||||||
.deriveClass <ui_options, core_options> ("ui_options")
|
.deriveClass <ui_options, core_options> ("ui_options")
|
||||||
.endClass()
|
.endClass()
|
||||||
|
.deriveClass <plugin_options, core_options> ("plugin_options")
|
||||||
|
.endClass()
|
||||||
.beginClass <parameters_manager> ("parameters")
|
.beginClass <parameters_manager> ("parameters")
|
||||||
.addFunction ("add", ¶meters_manager::add)
|
.addFunction ("add", ¶meters_manager::add)
|
||||||
.addFunction ("lookup", ¶meters_manager::lookup)
|
.addFunction ("lookup", ¶meters_manager::lookup)
|
||||||
|
@ -155,15 +155,29 @@ void machine_manager::update_machine()
|
|||||||
|
|
||||||
|
|
||||||
void machine_manager::start_luaengine()
|
void machine_manager::start_luaengine()
|
||||||
{
|
|
||||||
m_lua->initialize();
|
|
||||||
{
|
{
|
||||||
path_iterator iter(options().plugins_path());
|
path_iterator iter(options().plugins_path());
|
||||||
std::string pluginpath;
|
std::string pluginpath;
|
||||||
while (iter.next(pluginpath, ""))
|
while (iter.next(pluginpath))
|
||||||
{
|
{
|
||||||
m_plugins->parse_json(pluginpath);
|
m_plugins->parse_json(pluginpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// parse the file
|
||||||
|
std::string error;
|
||||||
|
// attempt to open the output file
|
||||||
|
emu_file file(options().ini_path(), OPEN_FLAG_READ);
|
||||||
|
if (file.open("plugin.ini") == osd_file::error::NONE)
|
||||||
|
{
|
||||||
|
bool result = m_plugins->parse_ini_file((util::core_file&)file, OPTION_PRIORITY_MAME_INI, OPTION_PRIORITY_DRIVER_INI, error);
|
||||||
|
if (!result)
|
||||||
|
osd_printf_error("**Error loading plugin.ini**");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_lua->initialize();
|
||||||
|
|
||||||
|
{
|
||||||
emu_file file(options().plugins_path(), OPEN_FLAG_READ);
|
emu_file file(options().plugins_path(), OPEN_FLAG_READ);
|
||||||
osd_file::error filerr = file.open("boot.lua");
|
osd_file::error filerr = file.open("boot.lua");
|
||||||
if (filerr == osd_file::error::NONE)
|
if (filerr == osd_file::error::NONE)
|
||||||
|
Loading…
Reference in New Issue
Block a user