diff options
author | 2021-10-15 09:42:35 +1100 | |
---|---|---|
committer | 2021-10-15 10:12:56 +1100 | |
commit | 22bc3486c3ef8f2230e99daf49785a89ac8a1182 (patch) | |
tree | 4f10f7386b7b0a32c9d560395399e8b7632df34c /plugins/autofire/autofire_menu.lua | |
parent | 3e8763bea5a93f3139204fcb8a0c74c2ac364af5 (diff) |
More user experience improvements:
frontend: Made it possible to cancel a media audit while it's in
progress. Also made the media audit multi-threaded so it's faster.
frontend: Made the DIP switches in the DIP switch preview clickable.
frontend: Made the system and software selection menus leave focus on
the same system when clearing the search rather than jumping to the
first item. Also fixed a couple of bugs in the logic for keeping the
selected item visible.
frontend: Fixed a few places that weren't showing localised system
names.
frontend: Made UI Cancel clear a search in the file manager the same way
it does on the system and sofware selection menus.
frontend: Made it possible for plugin menus to handle UI Cancel more
naturally, backing up to the previous plugin menu rather than dropping
straight back to the list of plugins. Updated the autofire, cheat and
cheatfind plugins, and fixed a few other issues in the cheatfind plugin.
debugger: Made the mount and unmount commands accept instance names as
well as brief instance names. Also updated another page of debugger
documentation.
Diffstat (limited to 'plugins/autofire/autofire_menu.lua')
-rw-r--r-- | plugins/autofire/autofire_menu.lua | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/plugins/autofire/autofire_menu.lua b/plugins/autofire/autofire_menu.lua index c4a76e39f64..3536800767f 100644 --- a/plugins/autofire/autofire_menu.lua +++ b/plugins/autofire/autofire_menu.lua @@ -140,8 +140,6 @@ local function handle_configure_menu(index, event) if event == 'select' then table.insert(menu_stack, MENU_TYPES.BUTTON) return true - else - return false end elseif index == 2 then -- Hotkey @@ -150,30 +148,30 @@ local function handle_configure_menu(index, event) if keycode then current_button.key = keycode return true - else - return false end - else - return false end 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 + return true elseif event == 'right' then current_button.on_frames = current_button.on_frames + 1 + return true end 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 + return true elseif event == 'right' then current_button.off_frames = current_button.off_frames + 1 + return true end end - return true + return false end local function populate_edit_menu() @@ -192,13 +190,11 @@ end local function handle_edit_menu(index, event, buttons) local section, adjusted_index = menu_section(index) - if section == MENU_SECTIONS.CONTENT then + if ((section == MENU_SECTIONS.FOOTER) and (event == 'select')) or (event == 'cancel') then + table.remove(menu_stack) + return true + elseif section == MENU_SECTIONS.CONTENT then return handle_configure_menu(adjusted_index, event) - elseif section == MENU_SECTIONS.FOOTER then - if event == 'select' then - table.remove(menu_stack) - return true - end end return false end @@ -223,16 +219,14 @@ end local function handle_add_menu(index, event, buttons) local section, adjusted_index = menu_section(index) - if section == MENU_SECTIONS.CONTENT then - return handle_configure_menu(adjusted_index, event) - elseif section == MENU_SECTIONS.FOOTER then - if event == 'select' then - table.remove(menu_stack) - if is_button_complete(current_button) then - buttons[#buttons + 1] = current_button - end - return true + if ((section == MENU_SECTIONS.FOOTER) and (event == 'select')) or (event == 'cancel') then + table.remove(menu_stack) + if is_button_complete(current_button) and (event == 'select') then + buttons[#buttons + 1] = current_button end + return true + elseif section == MENU_SECTIONS.CONTENT then + return handle_configure_menu(adjusted_index, event) end return false end @@ -249,7 +243,6 @@ local function populate_button_menu() for port_key, port in pairs(manager.machine.ioport.ports) do for field_key, field in pairs(port.fields) do if is_supported_input(field) then - menu[#menu + 1] = { _p("input-name", field.name), '', '' } inputs[#inputs + 1] = { port_name = port_key, field_name = field_key, @@ -258,13 +251,24 @@ local function populate_button_menu() end end end + -- TODO: group by device so we can sort table.sort(inputs, function(x, y) return x.ioport_field.name < y.ioport_field.name end) + for i, input in pairs(inputs) do + menu[header_height + i] = { _p("input-name", input.ioport_field.name), '', '' } + end content_height = #menu + + menu[#menu + 1] = {'---', '', ''} + menu[#menu + 1] = {_('Cancel'), '', ''} + return menu end local function handle_button_menu(index, event) local section, adjusted_index = menu_section(index) - if section == MENU_SECTIONS.CONTENT and event == 'select' then + if ((section == MENU_SECTIONS.FOOTER) and (event == 'select')) or (event == 'cancel') then + table.remove(menu_stack) + return true + elseif (section == MENU_SECTIONS.CONTENT) and (event == 'select') then local selected_input = inputs[adjusted_index] current_button.port = selected_input.port_name current_button.field = selected_input.field_name |