diff options
author | Vas Crabb <vas@vastheman.com> | 2020-12-16 02:18:52 +1100 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2020-12-16 02:18:52 +1100 |
commit | 503332a9867f9aa27fc77cd9e762626d22d213ef (patch) | |
tree | e60fba6664a3d980d5f62846982bde381a25c3f7 /plugins | |
parent | b5f78fe38358b68fc54416328f764cf4e2bf3333 (diff) |
-Lua cleanup and documentation migration checkpoint.
* Cleaned up some more of the Lua inteface. Mostly replacing methods
with properties, some consistency fixes, a few renames, some more
exposed functionality, and a couple of properties that have no
business being set from scripts made read-only.
* Moved a lot more Lua documentation out of source comments into the
documentation, and expanded on it in the process.
* Got more UI code out of the input manager.
* Changed input sequence poller to a polymorphic class where you
specify your intention upfront.
* Changed the cheat plugin to use UI Clear to clear hotkey assignments
and leave them unchanged if the user starts assignment but doesn't
press any switches.
* Ported AJR's fix for over-eager double-click recognition from SDL to
Windows OSD.
-goldnpkr.cpp: Cleaned up inputs, using standard keyout and payout types
and key assignments.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/autofire/autofire_menu.lua | 13 | ||||
-rw-r--r-- | plugins/cheat/init.lua | 30 | ||||
-rw-r--r-- | plugins/cheatfind/init.lua | 8 | ||||
-rw-r--r-- | plugins/gdbstub/init.lua | 4 |
4 files changed, 31 insertions, 24 deletions
diff --git a/plugins/autofire/autofire_menu.lua b/plugins/autofire/autofire_menu.lua index 4744de1b2ac..b9fb89d5042 100644 --- a/plugins/autofire/autofire_menu.lua +++ b/plugins/autofire/autofire_menu.lua @@ -76,6 +76,7 @@ end local function handle_main_menu(index, event, buttons) local section, adjusted_index = menu_section(index) if section == MENU_SECTIONS.CONTENT then + manager:machine():popmessage(_('Press UI Clear to delete')) if event == 'select' then current_button = buttons[adjusted_index] table.insert(menu_stack, MENU_TYPES.EDIT) @@ -108,10 +109,10 @@ end -- Borrowed from the cheat plugin local function poll_for_hotkey() local input = manager:machine():input() - local poller = input:sequence_poller() + local poller = input:switch_sequence_poller() manager:machine():popmessage(_('Press button for hotkey or wait to leave unchanged')) manager:machine():video():frame_update(true) - poller:start('switch') + poller:start() local time = os.clock() local clearmsg = true while (not poller:poll()) and (poller.modified or (os.clock() < time + 1)) do @@ -132,16 +133,16 @@ local function poll_for_hotkey() end local function handle_configure_menu(index, event) - -- Input if index == 1 then + -- Input if event == 'select' then table.insert(menu_stack, MENU_TYPES.BUTTON) return true else return false end - -- Hotkey elseif index == 2 then + -- Hotkey if event == 'select' then local keycode = poll_for_hotkey() if keycode then @@ -153,16 +154,16 @@ local function handle_configure_menu(index, event) else return false end - -- On frames elseif index == 3 then + -- On frames manager:machine():popmessage(_('Number of frames button will be pressed')) if event == 'left' then current_button.on_frames = current_button.on_frames - 1 elseif event == 'right' then current_button.on_frames = current_button.on_frames + 1 end - -- Off frames elseif index == 4 then + -- Off frames manager:machine():popmessage(_('Number of frames button will be released')) if event == 'left' then current_button.off_frames = current_button.off_frames - 1 diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua index 082864bb2fb..2acb377192f 100644 --- a/plugins/cheat/init.lua +++ b/plugins/cheat/init.lua @@ -605,15 +605,21 @@ function cheat.startplugin() local menu = {} if hotkeymenu then menu[1] = {_("Select cheat to set hotkey"), "", "off"} - menu[2] = {"---", "", "off"} + menu[2] = {_("Press UI Clear to clear hotkey"), "", "off"} + menu[3] = {"---", "", "off"} hotkeylist = {} - local function hkcbfunc(cheat) + local function hkcbfunc(cheat, event) + if event == "clear" then + cheat.hotkeys = nil + return + end + local input = manager:machine():input() - local poller = input:sequence_poller() - manager:machine():popmessage(_("Press button for hotkey or wait to clear")) + local poller = input:switch_sequence_poller() + manager:machine():popmessage(_("Press button for hotkey or wait to leave unchanged")) manager:machine():video():frame_update(true) - poller:start("switch") + poller:start() local time = os.clock() local clearmsg = true while (not poller:poll()) and (poller.modified or (os.clock() < time + 1)) do @@ -627,10 +633,8 @@ function cheat.startplugin() manager:machine():video():frame_update(true) end end - if poller.valid then + if poller.modified and poller.valid then cheat.hotkeys = { pressed = false, keys = poller.sequence } - else - cheat.hotkeys = nil end if clearmsg then manager:machine():popmessage() @@ -641,7 +645,7 @@ function cheat.startplugin() for num, cheat in ipairs(cheats) do if cheat.script then menu[#menu + 1] = {cheat.desc, cheat.hotkeys and manager:machine():input():seq_name(cheat.hotkeys.keys) or _("None"), ""} - hotkeylist[#hotkeylist + 1] = function() return hkcbfunc(cheat) end + hotkeylist[#hotkeylist + 1] = function(event) return hkcbfunc(cheat, event) end end end menu[#menu + 1] = {"---", "", ""} @@ -701,12 +705,12 @@ function cheat.startplugin() local function menu_callback(index, event) manager:machine():popmessage() if hotkeymenu then - if event == "select" then - index = index - 2 + if event == "select" or event == "clear" then + index = index - 3 if index >= 1 and index <= #hotkeylist then - hotkeylist[index]() + hotkeylist[index](event) return true - elseif index == #hotkeylist + 2 then + elseif index == #hotkeylist + 2 and event == "select" then hotkeymenu = false return true end diff --git a/plugins/cheatfind/init.lua b/plugins/cheatfind/init.lua index e540fe59fe6..1a3be72d9bc 100644 --- a/plugins/cheatfind/init.lua +++ b/plugins/cheatfind/init.lua @@ -302,9 +302,11 @@ function cheatfind.startplugin() for tag, list in pairs(space_table) do for name, space in pairs(list) do local ram = {} - for num, entry in pairs(space.map) do - if entry.writetype == "ram" then - ram[#ram + 1] = { offset = entry.offset, size = entry.endoff - entry.offset } + for num, entry in pairs(space.map.entries) do + if entry.write.handlertype == "ram" then + ram[#ram + 1] = { + offset = entry.address_start & space.address_mask, + size = (entry.address_end & space.address_mask) - (entry.address_start & space.address_mask) } if space.shift > 0 then ram[#ram].size = ram[#ram].size >> space.shift elseif space.shift < 0 then diff --git a/plugins/gdbstub/init.lua b/plugins/gdbstub/init.lua index f2292bc0027..e850e62ae5b 100644 --- a/plugins/gdbstub/init.lua +++ b/plugins/gdbstub/init.lua @@ -175,7 +175,7 @@ function gdbstub.startplugin() local data = "" local space = cpu.spaces["program"] for count = 1, len do - data = data .. string.format("%.2x", space:read_log_u8(addr)) + data = data .. string.format("%.2x", space:readv_u8(addr)) addr = addr + 1 end socket:write("+$" .. data .. "#" .. chksum(data)) @@ -188,7 +188,7 @@ function gdbstub.startplugin() if addr and len and data then addr = tonumber(addr, 16) local space = cpu.spaces["program"] - data:gsub("%x%x", function(s) space:write_log_u8(addr + count, tonumber(s, 16)) count = count + 1 end) + data:gsub("%x%x", function(s) space:writev_u8(addr + count, tonumber(s, 16)) count = count + 1 end) socket:write("+$OK#9a") else socket:write("+$E00#a5") |