diff options
| author | 2020-12-27 01:32:37 +1100 | |
|---|---|---|
| committer | 2020-12-27 01:32:37 +1100 | |
| commit | 9e36b6a6d951ea6f2d72cab874c3c8e72d001001 (patch) | |
| tree | c41bfd0c1b499d790c4091eb266caf6955219fc1 /plugins/cheatfind | |
| parent | 509c946736b5f02cac84d19f2cde4e966d637a2c (diff) | |
More Lua interface cleanup - it's simpler with cleaner underlyng APIs.
Made the sound manager mute controls readable, and got rid of system
enable since it just controls system mute anyway. This was causing
confusion: phantom2 was trying to use both independentlyt casuing the
mute bit to be ignored.
THe Lua interface changes are mostly changing methods to properties,
some renames to make things clearer, and some additional properties for
better control over snapshots.
Diffstat (limited to 'plugins/cheatfind')
| -rw-r--r-- | plugins/cheatfind/init.lua | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/plugins/cheatfind/init.lua b/plugins/cheatfind/init.lua index 1a3be72d9bc..9ac4db42e21 100644 --- a/plugins/cheatfind/init.lua +++ b/plugins/cheatfind/init.lua @@ -16,7 +16,7 @@ function cheatfind.startplugin() -- return table of devices and spaces function cheat.getspaces() local spaces = {} - for tag, device in pairs(manager:machine().devices) do + for tag, device in pairs(manager.machine.devices) do if device.spaces then spaces[tag] = {} for name, space in pairs(device.spaces) do @@ -30,7 +30,7 @@ function cheatfind.startplugin() -- return table of ram devices function cheat.getram() local ram = {} - for tag, device in pairs(manager:machine().devices) do + for tag, device in pairs(manager.machine.devices) do if device.shortname == "ram" then ram[tag] = {} ram[tag].dev = device @@ -43,7 +43,7 @@ function cheatfind.startplugin() -- return table of share regions function cheat.getshares() local shares = {} - for tag, share in pairs(manager:machine():memory().shares) do + for tag, share in pairs(manager.machine.memory.shares) do shares[tag] = share end return shares @@ -395,7 +395,7 @@ function cheatfind.startplugin() local r name, r = incdec(event, name, 1, #c) if (event == "select" or event == "comment") and name == 1 then - manager:machine():popmessage(string.format(_("Default name is %s"), cheat_save.name)) + manager.machine:popmessage(string.format(_("Default name is %s"), cheat_save.name)) end return r end @@ -424,7 +424,7 @@ function cheatfind.startplugin() r = true end elseif event == "select" or event == "comment" or event == "right" then - manager:machine():popmessage(_("You can enter any type name")) + manager.machine:popmessage(_("You can enter any type name")) end end return r @@ -441,7 +441,7 @@ function cheatfind.startplugin() if name == 2 then desc = name_type ~= #ctype and ctype[name_type] or name_other if #desc == 0 then - manager:machine():popmessage(_("Type name is empty")) + manager.machine:popmessage(_("Type name is empty")) return end if cplayer[name_player] ~= "All" then @@ -465,7 +465,7 @@ function cheatfind.startplugin() -- old cheat .dat format, write support only (for cheat forum posting of new cheats if posted in simple format) file:write(string.format(cheat_save.dat, desc)) file:close() - manager:machine():popmessage(string.format(_("Cheat written to %s and added to cheat.simple"), filename)) + manager.machine:popmessage(string.format(_("Cheat written to %s and added to cheat.simple"), filename)) end written = true elseif not getmetatable(devtable[devcur].space).__name:match("device_t") and devtable[devcur].sname == "program" then @@ -475,12 +475,12 @@ function cheatfind.startplugin() -- old cheat .dat format, write support only (for cheat forum posting of new cheats if posted in simple format) file:write(string.format(cheat_save.dat, desc)) file:close() - manager:machine():popmessage(_("Cheat added to cheat.simple")) + manager.machine:popmessage(_("Cheat added to cheat.simple")) written = true end end if not written then - manager:machine():popmessage(_("Unable to write file\nEnsure that cheatpath folder exists")) + manager.machine:popmessage(_("Unable to write file\nEnsure that cheatpath folder exists")) end cheat_save = nil return true @@ -498,7 +498,7 @@ function cheatfind.startplugin() menu_lim(devsel, 1, #devtable, m) local function f(event) if (event == "left" or event == "right") and #menu_blocks ~= 0 then - manager:machine():popmessage(_("Changes to this only take effect when \"Start new search\" is selected")) + manager.machine:popmessage(_("Changes to this only take effect when \"Start new search\" is selected")) end devsel = incdec(event, devsel, 1, #devtable) return true @@ -515,10 +515,10 @@ function cheatfind.startplugin() if pausesel == 1 then pausesel = 2 menu_is_showing = false - manager:machine():popmessage(_("Manually toggle pause when needed")) + manager.machine:popmessage(_("Manually toggle pause when needed")) else pausesel = 1 - manager:machine():popmessage(_("Automatically toggle pause with on-screen menus")) + manager.machine:popmessage(_("Automatically toggle pause with on-screen menus")) emu.pause() end end @@ -539,7 +539,7 @@ function cheatfind.startplugin() menu_blocks[num] = {} menu_blocks[num][1] = cheat.save(devtable[devcur].space, region.offset, region.size) end - manager:machine():popmessage(_("All slots cleared and current state saved to Slot 1")) + manager.machine:popmessage(_("All slots cleared and current state saved to Slot 1")) watches = {} opsel = 1 value = 0 @@ -562,7 +562,7 @@ function cheatfind.startplugin() for num, region in ipairs(devtable[devcur].ram) do menu_blocks[num][#menu_blocks[num] + 1] = cheat.save(devtable[devcur].space, region.offset, region.size) end - manager:machine():popmessage(string.format(_("Memory state saved to Slot %d"), #menu_blocks[1])) + manager.machine:popmessage(string.format(_("Memory state saved to Slot %d"), #menu_blocks[1])) if (leftop == #menu_blocks[1] - 1 and rightop == #menu_blocks[1] - 2 ) then leftop = #menu_blocks[1] rightop = #menu_blocks[1]-1 @@ -609,7 +609,7 @@ function cheatfind.startplugin() count = count + #matches[#matches][num] end end - manager:machine():popmessage(string.format(_("%d total matches found"), count)) + manager.machine:popmessage(string.format(_("%d total matches found"), count)) matches[#matches].count = count matchpg = 0 devsel = devcur @@ -672,25 +672,25 @@ function cheatfind.startplugin() opsel, r = incdec(event, opsel, 1, #optable) if event == "left" or event == "right" or event == "comment" then if optable[opsel] == "lt" then - manager:machine():popmessage(_("Left less than right")) + manager.machine:popmessage(_("Left less than right")) elseif optable[opsel] == "gt" then - manager:machine():popmessage(_("Left greater than right")) + manager.machine:popmessage(_("Left greater than right")) elseif optable[opsel] == "eq" then - manager:machine():popmessage(_("Left equal to right")) + manager.machine:popmessage(_("Left equal to right")) elseif optable[opsel] == "ne" then - manager:machine():popmessage(_("Left not equal to right")) + manager.machine:popmessage(_("Left not equal to right")) elseif optable[opsel] == "beq" then - manager:machine():popmessage(_("Left equal to right with bitmask")) + manager.machine:popmessage(_("Left equal to right with bitmask")) elseif optable[opsel] == "bne" then - manager:machine():popmessage(_("Left not equal to right with bitmask")) + manager.machine:popmessage(_("Left not equal to right with bitmask")) elseif optable[opsel] == "ltv" then - manager:machine():popmessage(_("Left less than value")) + manager.machine:popmessage(_("Left less than value")) elseif optable[opsel] == "gtv" then - manager:machine():popmessage(_("Left greater than value")) + manager.machine:popmessage(_("Left greater than value")) elseif optable[opsel] == "eqv" then - manager:machine():popmessage(_("Left equal to value")) + manager.machine:popmessage(_("Left equal to value")) elseif optable[opsel] == "nev" then - manager:machine():popmessage(_("Left not equal to value")) + manager.machine:popmessage(_("Left not equal to value")) end end return r @@ -741,11 +741,11 @@ function cheatfind.startplugin() pokevalsel, r = incdec(event, pokevalsel, 1, #pokevaltable) if event == "left" or event == "right" or event == "comment" then if pokevalsel == 1 then - manager:machine():popmessage(_("Use this if you want to poke the Slot 1 value (eg. You started with something but lost it)")) + manager.machine:popmessage(_("Use this if you want to poke the Slot 1 value (eg. You started with something but lost it)")) elseif pokevalsel == 2 then - manager:machine():popmessage(_("Use this if you want to poke the Last Slot value (eg. You started without an item but finally got it)")) + manager.machine:popmessage(_("Use this if you want to poke the Last Slot value (eg. You started without an item but finally got it)")) else - manager:machine():popmessage(string.format(_("Use this if you want to poke %s"), pokevaltable[pokevalsel])) + manager.machine:popmessage(string.format(_("Use this if you want to poke %s"), pokevaltable[pokevalsel])) end end return r @@ -940,7 +940,7 @@ function cheatfind.startplugin() end if match.mode == 1 then if not emu.plugin.cheat then - manager:machine():popmessage(_("Cheat engine not available")) + manager.machine:popmessage(_("Cheat engine not available")) else emu.plugin.cheat.inject(cheat) end @@ -954,14 +954,14 @@ function cheatfind.startplugin() if emu.softname():find(":") then setname = emu.softname():gsub(":", "/") else - for name, image in pairs(manager:machine().images) do + for name, image in pairs(manager.machine.images) do if image:exists() and image:software_list_name() ~= "" then setname = image:software_list_name() .. "/" .. emu.softname() end end end end - cheat_save.path = emu.subst_env(manager:machine():options().entries.cheatpath:value()):match("([^;]+)") + cheat_save.path = emu.subst_env(manager.machine.options.entries.cheatpath:value()):match("([^;]+)") cheat_save.filename = string.format("%s/%s", cheat_save.path, setname) cheat_save.name = cheat.desc local json = require("json") @@ -970,7 +970,7 @@ function cheatfind.startplugin() cheat_save.xml = string.format("<mamecheat version=\"1\">\n <cheat desc=\"%%s\">\n <script state=\"run\">\n <action>%s.pp%s@%X=%X</action>\n </script>\n </cheat>\n</mamecheat>", dev.tag:sub(2), widchar, match.addr, match.newval) cheat_save.simple = string.format("%s,%s,%X,%s,%X,%%s\n", setname, dev.tag, match.addr, widchar, pokevalue) cheat_save.dat = string.format(":%s:40000000:%X:%08X:FFFFFFFF:%%s\n", setname, match.addr, pokevalue) - manager:machine():popmessage(string.format(_("Default name is %s"), cheat_save.name)) + manager.machine:popmessage(string.format(_("Default name is %s"), cheat_save.name)) return true else local func = "return space:read" @@ -1045,19 +1045,19 @@ function cheatfind.startplugin() end emu.register_menu(menu_callback, menu_populate, _("Cheat Finder")) emu.register_frame_done(function () - local screen = manager:machine().screens:at(1) - local height = mame_manager:ui():get_line_height() + local screen = manager.machine.screens:at(1) + local height = mame_manager.ui.line_height for num, watch in ipairs(watches) do screen:draw_text("left", num * height, string.format(watch.format, watch.addr, watch.func())) end - if tabbed_out and manager:ui():is_menu_active() then + if tabbed_out and manager.ui.menu_active then emu.pause() menu_is_showing = true tabbed_out = false end end) emu.register_periodic(function () - if menu_is_showing and not manager:ui():is_menu_active() then + if menu_is_showing and not manager.ui.menu_active then emu.unpause() menu_is_showing = false tabbed_out = true |
