Ejemplo n.º 1
0
        //-------------------------------------------------
        //  start_luaengine
        //-------------------------------------------------
        public void start_luaengine()
        {
            if (options().plugins())
            {
                //throw new emu_unimplemented();
#if false
                // scan all plugin directories
                path_iterator iter = new path_iterator(options().plugins_path());
                string        pluginpath;
                while (iter.next(out pluginpath))
                {
                    // user may specify environment variables; subsitute them
                    m_osdcore.osd_subst_env(out pluginpath, pluginpath);

                    // and then scan the directory recursively
                    m_plugins.scan_directory(pluginpath, true);
                }

                {
                    // parse the file
                    // attempt to open the output file
                    emu_file file = new emu_file(options().ini_path(), OPEN_FLAG_READ);
                    if (file.open("plugin.ini") == osd_file.error.NONE)
                    {
                        try
                        {
                            m_plugins.parse_ini_file(file.core_file_get());  //(util::core_file&)file
                        }
                        catch (options_exception)
                        {
                            osd_printf_error("**Error loading plugin.ini**\n");
                        }

                        file.close();
                    }
                }

                // process includes
                foreach (string incl in split(options().plugin(), ','))
                {
                    plugin_options::plugin *p = m_plugins->find(incl);
                    if (!p)
                    {
                        fatalerror("Fatal error: Could not load plugin: %s\n", incl);
                    }
                    p.m_start = true;
                }

                // process excludes
                foreach (string excl in split(options().no_plugin(), ','))
                {
                    plugin_options::plugin *p = m_plugins->find(excl);
                    if (!p)
                    {
                        fatalerror("Fatal error: Unknown plugin: %s\n", excl);
                    }
                    p.m_start = false;
                }
#endif
            }

            // we have a special way to open the console plugin
            if (options().console())
            {
                plugin_options.plugin p = m_plugins.find(OPTION_CONSOLE);
                if (p == null)
                {
                    fatalerror("Fatal error: Console plugin not found.\n");
                }

                p.m_start = true;
            }

            m_lua.initialize();

            {
                emu_file            file   = new emu_file(options().plugins_path(), OPEN_FLAG_READ);
                std.error_condition filerr = file.open("boot.lua");
                if (!filerr)
                {
                    string exppath;
                    m_osdcore.osd_subst_env(out exppath, file.fullpath());
                    m_lua.load_script(file.fullpath());
                    file.close();
                }
            }
        }
Ejemplo n.º 2
0
        public void start_luaengine()
        {
            if (options().plugins())
            {
                path_iterator iter = new path_iterator(options().plugins_path());
                string        pluginpath;
                while (iter.next(out pluginpath))
                {
                    m_plugins.parse_json(pluginpath);
                }

                string [] include = options().plugin() == null ? new string[0] : options().plugin().Split(',');  // split(options().plugin(),',');
                string [] exclude = options().no_plugin() == null ? new string[0] : options().no_plugin().Split(',');

                {
                    // parse the file
                    // attempt to open the output file
                    emu_file file = new emu_file(options().ini_path(), OPEN_FLAG_READ);
                    if (file.open("plugin.ini") == osd_file.error.NONE)
                    {
                        try
                        {
                            m_plugins.parse_ini_file(file.core_file_get(), mame_options.OPTION_PRIORITY_MAME_INI, mame_options.OPTION_PRIORITY_MAME_INI < mame_options.OPTION_PRIORITY_DRIVER_INI, false);
                        }
                        catch (options_exception)
                        {
                            osd_printf_error("**Error loading plugin.ini**\n");
                        }

                        file.close();
                    }
                }

                foreach (var curentry in m_plugins.entries())
                {
                    if (curentry.type() != core_options.option_type.HEADER)
                    {
                        if (Array.Exists(include, s => s == curentry.name()))  // std::find(include.begin(), include.end(), curentry.name()) != include.end())
                        {
                            m_plugins.set_value(curentry.name(), "1", emu_options.OPTION_PRIORITY_CMDLINE);
                        }

                        if (Array.Exists(exclude, s => s == curentry.name()))  // std::find(exclude.begin(), exclude.end(), curentry.name()) != exclude.end())
                        {
                            m_plugins.set_value(curentry.name(), "0", emu_options.OPTION_PRIORITY_CMDLINE);
                        }
                    }
                }
            }

            if (options().console())
            {
                m_plugins.set_value("console", "1", emu_options.OPTION_PRIORITY_CMDLINE);
                if (m_plugins.exists(emu_options.OPTION_CONSOLE))
                {
                    m_plugins.set_value(emu_options.OPTION_CONSOLE, "1", emu_options.OPTION_PRIORITY_CMDLINE);
                }
                else
                {
                    fatalerror("Console plugin not found.\n");
                }
            }

            m_lua.initialize();

            {
                emu_file       file   = new emu_file(options().plugins_path(), OPEN_FLAG_READ);
                osd_file.error filerr = file.open("boot.lua");
                if (filerr == osd_file.error.NONE)
                {
                    string exppath;
                    osdcore_global.m_osdcore.osd_subst_env(out exppath, file.fullpath());
                    m_lua.load_script(file.fullpath());
                    file.close();
                }
            }
        }