summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar cracyc <cracyc@users.noreply.github.com>2018-01-21 18:32:15 -0600
committerGravatarGravatar cracyc <cracyc@users.noreply.github.com>2018-01-21 18:32:15 -0600
commit59544382d3d13e6b34657fb3886d1db57463ea03 (patch) (github)
tree2b0362a140e6c97878bf3bce1be3edc70222c6bb
parenta477180ebe082c055e72a6f7d93ff41c6680223f (diff)
downloadmame-59544382d3d13e6b34657fb3886d1db57463ea03.tar.bz2
mame-59544382d3d13e6b34657fb3886d1db57463ea03.zip
plugins/portname: sort the list and print the port names and masks (nw)
-rw-r--r--plugins/portname/init.lua20
1 files changed, 15 insertions, 5 deletions
diff --git a/plugins/portname/init.lua b/plugins/portname/init.lua
index 112c10aef47..0d1edeb288d 100644
--- a/plugins/portname/init.lua
+++ b/plugins/portname/init.lua
@@ -96,11 +96,15 @@ function portname.startplugin()
for fname, field in pairs(port.fields) do
local dname = field.default_name
if not fields[dname] then
- fields[dname] = ""
+ fields[dname] = {}
+ fields[dname].name = ""
end
if fname ~= dname then
- fields[dname] = fname
+ fields[dname].name = fname
end
+ fields[dname].port = pname
+ fields[dname].mask = field.mask
+ fields[dname].default = dname
end
end
local function check_path(path)
@@ -133,10 +137,16 @@ function portname.startplugin()
file:close()
return false
end
+ local sfields = {}
+ for def, field in pairs(fields) do
+ sfields[#sfields + 1] = field
+ end
+ table.sort(sfields, function(a, b) if(a.port == b.port) then return a.mask < b.mask end return a.port < b.port end)
file = io.open(ctrlrpath .. "/portname/" .. filename, "w")
- for def, custom in pairs(fields) do
- def = def:gsub("[\\\"]", function (s) return "\\" .. s end)
- custom = custom:gsub("[\\\"]", function (s) return "\\" .. s end)
+ for n, field in ipairs(sfields) do
+ def = field.default:gsub("[\\\"]", function (s) return "\\" .. s end)
+ custom = field.name:gsub("[\\\"]", function (s) return "\\" .. s end)
+ file:write(string.format("# port %s mask %08x\n", field.port, field.mask))
file:write("msgid \"" .. def .."\"\nmsgstr \"" .. custom .. "\"\n\n")
end
file:close()