Commit Graph

38 Commits

Author SHA1 Message Date
Vas Crabb
b67b969bf0 -Improved some Lua APIs:
* Moved several machine lifecycle callbacks to the notifier/subscriber
  model.  The old callback registration model is still available for
  them for now, but prints a deprecation warning.
* Added pre-save/post-load notifications.
* Use a single allocated timer rather than one anonymous timer per
  waiter.  Waiters no longer prevent saved states from being loaded.
* Clean up outstanding waiters on stop or state load rather than just
  leaking them.
* Started documenting parts of the emulator interface object that should
  be relatively stable.

-imagedev/avivideo.cpp: Fixed an object leak on unload.  Also changed
 some other media image devices to use smart pointers.
2023-04-07 06:20:40 +10:00
Vas Crabb
00f317b3d3 -ui/menu.cpp: Don't pass IPT_UI_BACK event to the implementation when dismissing the menu.
-plugins/autofire, plugins/inputmacro: Don't be so eager to create empty settings folders.
2023-03-23 03:39:54 +11:00
Vas Crabb
d4589e0b29 Input refactoring:
osd/modules/input, emu/inpttype.cpp: Made most default joystick
assignments supplied by input modules.  Input modules take available
controls into consideration when generating default assignments.

emu/inpttype.ipp: Added a separate "Back" UI input separate from Cancel.
You may want an easier to hit combination for moving to the previous
menu than for exiting or cancelling input.  They both default to Escape.

emu/inpttype.ipp: Added a UI Help control.  Currently only used by
analog inputs menu

emu/inpttype.h: Moved I/O port field type enum to its own header and
sorted UI controls so they appear in a more logical order.

ui: Don't use UI Select to restore defaults - people should be getting
used to the UI Clear input by now.  UI Select cycles multi-value items
instead.

ui/inputmap.cpp: Don't use immediate cancel to cycle between clearing
and restoring default assignment (use UI Clear instead).

osd: Reduced the number of files needing to include the dreaded emu.h.
Got some implementation out of headers.
2023-02-18 06:18:45 +11:00
npwoods
13910382a5
osd/modules/file: Don't magically substitute environment variables when opening files. (#9859)
* util/options.cpp: Added option types for single and multiple paths.
* util/options.cpp: Substitute environment variables in values from defaults and INI files.
* ui/dirmenu.cpp: Removed hard-coded list of multi-path options.
* plugins: Don't substitute environment variables in path options.
2022-12-17 06:03:59 +11:00
Vas Crabb
16e709ad82 plugins/autofire, plugins/inputmacro: Use clear_value to release I/O port fields. 2022-11-06 02:46:39 +11:00
Vas Crabb
e6588480c4
Lua engine improvements (#9453)
Made auto-boot script errors and plugin bootstrap errors fatal.

Run auto-boot scripts in a sandbox.  Globals can be accessed, but not
set.  The sandbox is cleared on hard reset, but not on soft reset.

Added (hopefully) useful to string metafunctions to device_t and
address space that show short names and tags.

Fixed issues in plugins that surface when strict type checking is
enabled, as this means numbers and nil are not automatically converted
to strings.  Plugins should be tested with debug builds to check for
this.

Made save item read_block raise an error on invalid arguments rather
than returning an empty string, and made it use luaL_buffer directly
rather than using the helper wrapper.

Changed some more function bindings to use set_function to avoid issues
related to ThePhD/sol2#608, and got rid of some unnecessary lambda
captures.
2022-03-23 20:27:30 +11:00
Vas Crabb
7d8c657fad Moved localised I/O port name lookup into I/O port manager.
Added pseudo format specifiers to controller port names: %p for player
and %% for literal percent symbol.  This lets you get the localised
player identifier in overridden input names (see NES and Neo-Geo for
examples), and reduces the number of messages to translate.

For translators, the new messages are mostly previously existing
messages with wording adjusted for clarity (e.g. referring to "media"
rather than "ROMs" in several places, as things like disk and tape
images are included).  It's also possible to localise the "???"
dipslayed for an input without a valid name, but that should never
actually appear in practice.
2021-12-09 07:42:12 +11:00
Vas Crabb
07e55935cf plugins: Rewrote timer plugin fixing multiple issues.
Added emulated time recording as well as wall clock time.

Fixed recording time for multiple software items per system.  An
incorrect constraint on the database table meant that time was only
being recorded for a single software item per system.

Detect the "empty" driver so the time spent at the selection menu isn't
recorded (you'd get multiple entries for this due to the way options
leak when returning to the system selection menu).

Included schema migration code to update existing timer plugin
databases.  Also replaced some unnecessary floating point code with
integer maths, added log messages, and made the plugin unload unload its
database access code during emulation.

Changed other plugins' use of paths with trailing slashes as this causes
stat to fail on Windows.
2021-11-06 05:20:59 +11:00
Vas Crabb
de9ed12186 plugins: Reduced amnesia for autofire and inputmacro plugins.
Made autofire and inputmacro plugins capable of remembering settings if
the host input device for the binding is missing or if an input for a
slot device that isn't present is referenced.
2021-11-05 02:46:04 +11:00
Vas Crabb
6e355f86c8 frontend: Don't let the non-menus get as far as trying to draw. 2021-11-04 10:32:24 +11:00
Vas Crabb
8c6cb643e3 plugins: Simplify logic in autofire and inputmacro plugins to try and avoid leaking state across sessions. 2021-11-04 09:55:26 +11:00
Vas Crabb
d775a2731d plugins: Moved the timecode recording functionality to a plugin. 2021-11-02 15:31:03 +11:00
Vas Crabb
d64ea5331b
-frontend: Refactored menu event handling and fixed a number of issues. (#8777)
* Moved common code for drawing about box, info viewer, and other text box menus to a base class; removed the last of the info viewer logic and the multi-line item hack from the base menu class.
* Added previous/next group navigation for general inputs and plugin input selection menus.
* Moved message catalog logic to lib/util, allowing osd and emu to use localised messages.
* Made the base menu class use the UI manager’s feature for holding session state rather than a static map and mutex.
* Improved menu event handling model, and fixed many issues, particularly with menus behaving badly when hidden/shown.
* Added better support for menus that don’t participate in the usual menu stack, like the menuless sliders and the save/load state menus.
* Made a number of menus refresh state when being shown after being hidden (fixes MT08121 among other issues).
* Fixed indication of mounted slot option in the slot option details menu.
* Improved appearance of background menus when emulation isn't running - draw all menus in the stack, and darken the background menus to make the edges of the active menu clearer.
* Fixed locale issues in -listxml.

-debugger: Made GUI debuggers more uniform.
* Added new memory view features to Win32 debugger.
* Fixed spelling of hexadecimal in Cocoa debugger and added decimal address option.
* Fixed duplicate keyboard shortcut in Cocoa debugger (Shift-Cmd-D was both new device window and 64-bit float format).
* Made keyboard shortcuts slightly more consistent across debuggers.

-plugins: Moved input selection menu and sequence polling code to a common library.  Fixed the issue that prevented keyboard inputs being mapped with -steadykey on.

-docs: Started adding some documentation for MAME's internal UI, and updated the list of example front-ends.

-Regenerated message catalog sources.  For translators, the new strings are mostly:
* The names of the inputs provided by the OS-dependent layer for things like fullscreen and video features. These show up in the user interface inputs menu.
* The names for automatically generated views. These show up in the video options menu - test with a system with a lot of screens to see more variants.
* The input macro plugin UI.
* A few format strings for analog input assignments.
* A few strings for the about box header.
2021-10-31 12:31:16 +11:00
Vas Crabb
4601e60391 plugins: Use SPDX short identifiers for licenses in exports (more precise and easier to localise), use CC0 for hiscore plugin rather than CC0. 2021-10-25 01:57:07 +11:00
Vas Crabb
5ab93130eb Plugin updates:
Changed the hiscore plugin to save inside the "hiscore" folder in the
plugin data directory.  The old hiscore path setting has already been
removed from MAME for some time.  This means the plugin was always
saving in the "hi" folder in the working directory with no way to change
it, which is problematic on Linux and macOS, particularly for distro
packagers.  There are lots of plugin and UI changes in this release, so
we may as well get this out of the way now.  Also made it possible to
change the "timed save" option from the Plugin Options menu, and save
that in the data folder, too.

Documented the input macro plugin.  The only undocumented plugins now
are the cheat plugin, the cheat finder plugin, and the port name plugin.
2021-10-24 09:38:03 +11:00
Vas Crabb
33f5ab983d -Cleaned up CI targets:
* Restricted Linux CI build to only run on changes to code,
  translations, software lists, and build scripts.
* Restricted Windows/macOS CO to only run on changes to code and build
  scripts.  They provide nothing over Linux for the other stuff.
* Added plugin properties and controller file validation to the "hash"
  workflow.
* Added a workflow for building documentation, so pull requests that
  affect documentation will at least get a basic check in advance.

-plugins/autofire: Bumped version as configuration format has changed.
2021-10-22 02:46:52 +11:00
Vas Crabb
f459eb6e13 Plugin usability improvements:
* autofire, inputmacro: Made left/right repeat when held (makes setting
  long delays/durations easier).
* autofire, inputmacro: Added headings for devices in input selection
  menus (helps when controller buttons have identical names, e.g. AES)
* autofire: Made intial selection when moving between menus intuitive,
  log some errors on saving/loading configuration.
* autofire: Fixed two errors in Chinese localisations.
2021-10-22 01:14:05 +11:00
Vas Crabb
b1c7644159 -plugins: Added an input macro plugin.
-plugins: Sort input selection menus for autofire plugin.

-frontend: Fixed another case where the menus may not automatically
scroll the first item into view.
2021-10-21 04:11:43 +11:00
Vas Crabb
4e74debb69 frontend: Don't show plugin options menu in main menu before start - it doesn't work anyway. 2021-10-20 05:27:31 +11:00
Vas Crabb
0a9ea09a9a Tie up a few loose ends:
debugger: Octal cheats for octal address spaces.

frontend: Pass events for automatically generated menu items to the
plugin - they will have index zero.

frontend: Don't try calling the data plugin from the main menu if the
system isn't starting yet - doing so will prevent the data plugin from
loading at all.
2021-10-20 02:03:43 +11:00
Vas Crabb
22bc3486c3 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.
2021-10-15 10:12:56 +11:00
Vas Crabb
751c2806bf Re-generated translations for I/O port names.
Trying to collect messages from everything at once hits some limit in
xgettext and causes messages to be lost no, so I've split it up by the
second-level source directories.

For some reason xgettext thinks overloaded Lua functions are blasphemy,
so that has to be worked around, too.
2021-10-11 15:02:55 +11:00
Vas Crabb
fd6309ee91 frontend: Keep cleaning up.
Got rid of one of the UI audit inputs.  There only needs to be one, and
the options can be presented in the confirmation menu.  Two secret
keystrokes is too confusing.  Also got rid of the long-obsolete UI
Toggle Debugger input.

Added audit media button to the toolbar so it's a bit less opaque, and
it can be accessed with a mouse/trackball (not just by knowing the key
mapping).

Made default I/O port names localisable.

Made autofire plugin save port fields using the { port, mask, type }
tuple, the same way MAME does.  Unfortunately this will break existing
autofire configuration, but it should be more stable going forward.

Added some more UI keys to the default key mappings documentation.
2021-10-11 13:14:31 +11:00
Vas Crabb
fab84e8d2b Mostly revert "Create console history file in homepath (#8026)"
The change to make the console plugin work is preserved.

This reverts commit 25137717c9.
2021-05-07 02:14:05 +10:00
Szunti
25137717c9
Create console history file in homepath (#8026)
* Fix console history path, homepath is a core option

* Create missing directories recursively in lua plugins.

* Add lfs to global environment in a less magical way.

require normally doesn't bind the name globally just returns the
module, mame sets a preloader that does bind lfs globally, but
maybe it's less surprising to do it explicitly
2021-05-03 20:40:10 -04:00
Vas Crabb
a5e6f4ea8d Expose a couple more things to Lua so the plugins can show the actual key mapped to UI clear. 2020-12-27 04:27:42 +11:00
Vas Crabb
9e36b6a6d9 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.
2020-12-27 01:32:37 +11:00
Vas Crabb
503332a986 -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.
2020-12-16 02:18:52 +11:00
AJR
e70d4ebb34 plugins: Replace environment variable substitution function with core version 2020-12-08 09:44:32 -05:00
Vas Crabb
e008c7b1b1 -Lua engine cleanup, input edition:
* Modernised and cleaned up Lua bindings for input classes.
* Exposed the input_sequence_poller class to Lua and updated the
  autofire and cheat plugins to use it, rather than continuing to
  pretend it's part of the input manager.
* Exposed more of the natural keyboard manager, including the ability
  to enable/disable individual keyboard and keypad devices like you
  can from the keyboard mode menu.
* Exposed a few more things on ioport_port and input_device.

-plugins/cheat: Fixed menu item not updating visually when disabling a
 cheat with UI Left.

-plugins/cheatfind: Fixed not finding the first screen after screen
 enumerator was exposed as an object rather than using a table.

-bwidow.cpp, pacman.cpp: Minor cleanup to recent changes.
2020-12-09 01:10:26 +11:00
Vas Crabb
718da3388c
plugins/autofire: remove leftover code from first attempt at removing empty configuration files 2020-07-19 23:07:39 +10:00
kunikuni
070eeeec3a
plugins/autofire: don't save 2bytes cfg file (nw) (#6969)
* plugins/autofire: don't save 2bytes cfg file (nw)

* Update autofire_save.lua
2020-07-19 23:05:00 +10:00
kunikuni
33fbb85d59
plugins/autofire: don't save 2bytes cfg file (#6960) 2020-07-17 15:05:23 -04:00
Vas Crabb
c38f63c10a plugins/cheat, plugins/autofire: only time out input sequence entry if nothing is entered (nw) 2019-11-22 02:32:29 +11:00
cracyc
0ec88f2ff7 plugins/autofire: permit input sequences (nw) 2019-11-20 22:35:13 -06:00
Jack Li
2da86cda04 Change autofire config directory to homepath (#5129)
* Revert "Used set_folder to avoid hardcoding plugin name in settings path"

This reverts commit 76884986fd8630f81cfc838aa42f264fdcec2ea9.

* Changed autofire config directory to homepath

* Bumped autofire plugin version
2019-05-30 14:31:57 -04:00
Jack Li
27f66693c5 Autofire plugin: Save/load fixes (#5093)
* Fixed bugs related to reloading roms

Soft resets would reload autofire settings without saving them first, causing the settings to be lost. This commit adds a check to only reload from the settings file if loading a different rom than before.

Hard resets would leave bad references lying around, causing MAME to crash under certain circumstances (i.e. resetting while in the edit menu and entering the menu again). This commit makes sure to properly clean up and reinitialize menu and button states when resetting.

* Used set_folder to avoid hardcoding plugin name in settings path

* Bumped autofire plugin version
2019-05-21 18:44:44 -04:00
Jack Li
0040650300 Add plugin for autofire (#5050)
* Hardcoded autofire plugin

* Changed register_frame to register_frame_done, removed pause check

* Added support for multiple buttons loaded from a file

* Implemented saving settings on quit

* Fixed multiple keybindings for same button from overwriting each other

* Replaced double-quotes with single-quotes

* Refactored saving/loading into a separate module

* Changed button format to use input_code rather than string token

Settings format is unchanged (still saved as string token).

* Rewrote table initialization in save/load

* Implemented menus

* Added helper messages for "on frames"/"off frames"
2019-05-14 10:26:27 -04:00