mirror of
https://github.com/holub/mame
synced 2025-04-20 15:32:45 +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
|
||||
local filename = "plugins/" .. file .. "/plugin.json"
|
||||
local meta = json.parse(readAll(filename))
|
||||
if (meta["plugin"]["type"]=="plugin") and (meta["plugin"]["start"]=="true") then
|
||||
server = require(meta["plugin"]["name"])
|
||||
if server.set_folder~=nil then server.set_folder("plugins/" .. file) end
|
||||
server.startplugin();
|
||||
if (meta["plugin"]["type"]=="plugin") and (manager:plugins().entries[meta["plugin"]["name"]]~=nil) then
|
||||
local entry = manager:plugins().entries[meta["plugin"]["name"]]
|
||||
if (entry:value()==true) then
|
||||
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
|
||||
|
@ -1630,6 +1630,21 @@ void cli_frontend::execute_commands(const char *exename)
|
||||
|
||||
// generate the updated INI
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1436,6 +1436,7 @@ void lua_engine::initialize()
|
||||
.beginClass <machine_manager> ("manager")
|
||||
.addFunction ("machine", &machine_manager::machine)
|
||||
.addFunction ("options", &machine_manager::options)
|
||||
.addFunction ("plugins", &machine_manager::plugins)
|
||||
.endClass ()
|
||||
.beginClass <lua_machine> ("lua_machine")
|
||||
.addCFunction ("popmessage", &lua_machine::l_popmessage)
|
||||
@ -1564,6 +1565,8 @@ void lua_engine::initialize()
|
||||
.endClass()
|
||||
.deriveClass <ui_options, core_options> ("ui_options")
|
||||
.endClass()
|
||||
.deriveClass <plugin_options, core_options> ("plugin_options")
|
||||
.endClass()
|
||||
.beginClass <parameters_manager> ("parameters")
|
||||
.addFunction ("add", ¶meters_manager::add)
|
||||
.addFunction ("lookup", ¶meters_manager::lookup)
|
||||
|
@ -156,14 +156,28 @@ void machine_manager::update_machine()
|
||||
|
||||
void machine_manager::start_luaengine()
|
||||
{
|
||||
m_lua->initialize();
|
||||
path_iterator iter(options().plugins_path());
|
||||
std::string pluginpath;
|
||||
while (iter.next(pluginpath))
|
||||
{
|
||||
path_iterator iter(options().plugins_path());
|
||||
std::string pluginpath;
|
||||
while (iter.next(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)
|
||||
{
|
||||
m_plugins->parse_json(pluginpath);
|
||||
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);
|
||||
osd_file::error filerr = file.open("boot.lua");
|
||||
if (filerr == osd_file::error::NONE)
|
||||
|
Loading…
Reference in New Issue
Block a user