mirror of
https://github.com/holub/mame
synced 2025-04-18 22:49:58 +03:00
plugins/portname: add softlist parent loading and import tag (nw)
This commit is contained in:
parent
cfee54e1f8
commit
845925fe99
@ -2,6 +2,7 @@
|
||||
-- copyright-holders:Carl
|
||||
-- data files are json files named <romname>.json
|
||||
-- {
|
||||
-- "import":"<import filename>"
|
||||
-- "ports":{
|
||||
-- "<ioport name>":{
|
||||
-- "labels":{
|
||||
@ -39,19 +40,21 @@ function portname.startplugin()
|
||||
return filename
|
||||
end
|
||||
|
||||
emu.register_start(function()
|
||||
local file = emu.file(ctrlrpath .. "/portname", "r")
|
||||
local ret = file:open(get_filename())
|
||||
if ret then
|
||||
ret = file:open(get_filename(true))
|
||||
if ret then
|
||||
ret = file:open(manager:machine():system().parent .. ".json")
|
||||
if ret then
|
||||
return
|
||||
end
|
||||
local function parse_names(ctable, depth)
|
||||
if depth >= 5 then
|
||||
emu.print_error("portname: max import depth exceeded\n")
|
||||
return
|
||||
end
|
||||
if ctable.import then
|
||||
local file = emu.file(ctrlrpath .. "/portname", "r")
|
||||
local ret = file:open(ctable.import)
|
||||
if not ret then
|
||||
parse_names(json.parse(file:read(file:size())), depth + 1)
|
||||
end
|
||||
end
|
||||
local ctable = json.parse(file:read(file:size()))
|
||||
if not ctable.ports then
|
||||
return
|
||||
end
|
||||
for pname, port in pairs(ctable.ports) do
|
||||
local ioport = manager:machine():ioport().ports[pname]
|
||||
if ioport then
|
||||
@ -65,6 +68,35 @@ function portname.startplugin()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
emu.register_start(function()
|
||||
local file = emu.file(ctrlrpath .. "/portname", "r")
|
||||
local ret = file:open(get_filename())
|
||||
if ret then
|
||||
if emu.softname() ~= "" then
|
||||
local parent
|
||||
for tag, image in pairs(manager:machine().images) do
|
||||
parent = image.software_parent
|
||||
if parent ~= "" then
|
||||
break
|
||||
end
|
||||
end
|
||||
if parent ~= "" then
|
||||
ret = file:open(emu.romname() .. "_" .. parent:match("([^:]*)$") .. ".json")
|
||||
end
|
||||
end
|
||||
if ret then
|
||||
ret = file:open(get_filename(true))
|
||||
if ret then
|
||||
ret = file:open(manager:machine():system().parent .. ".json")
|
||||
if ret then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
parse_names(json.parse(file:read(file:size())), 0)
|
||||
end)
|
||||
|
||||
local function menu_populate()
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "natkeyboard.h"
|
||||
#include "uiinput.h"
|
||||
#include "pluginopts.h"
|
||||
#include "softlist.h"
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wshift-count-overflow"
|
||||
@ -1986,6 +1987,7 @@ void lua_engine::initialize()
|
||||
"manufacturer", &device_image_interface::manufacturer,
|
||||
"year", &device_image_interface::year,
|
||||
"software_list_name", &device_image_interface::software_list_name,
|
||||
"software_parent", sol::property([](device_image_interface &di) { const software_info *si = di.software_entry(); return si ? si->parentname() : ""; }),
|
||||
"image_type_name", &device_image_interface::image_type_name,
|
||||
"load", &device_image_interface::load,
|
||||
"unload", &device_image_interface::unload,
|
||||
|
Loading…
Reference in New Issue
Block a user