diff options
author | cracyc <cracyc@users.noreply.github.com> | 2018-10-03 15:55:34 -0500 |
---|---|---|
committer | cracyc <cracyc@users.noreply.github.com> | 2018-10-03 15:55:34 -0500 |
commit | 845925fe992f199775302beb4ba8eb5c74acadf7 (patch) | |
tree | 82b78bf535e0efb43339feb847f3bf92a8101190 /plugins | |
parent | cfee54e1f84163f50801c2b04aa0d579b7b6406f (diff) |
plugins/portname: add softlist parent loading and import tag (nw)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/portname/init.lua | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/plugins/portname/init.lua b/plugins/portname/init.lua index e231931a347..3c04d26f72a 100644 --- a/plugins/portname/init.lua +++ b/plugins/portname/init.lua @@ -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() |