* Add convenience direct accessors to individual Options.
* Move BasicOptionObserver to a separate header and allow it to
observer multiple options. This also removes the include for
"config/option.h" for using this observer, reducing build time.
* Never skip the "Plugin" option when changing filters. This is
already handled properly in the GameArea class. If the plugin is
unusable, GameArea resets the filter to the default value.
* Make the OptionID names slightly less long and fix the inconsistent
naming in the enum.
Fix regression in ea2a929f, which broke x11 support by not checking for
Wayland when making the Wayland EGL subsurface move call.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Backport 800d6ed69b from wxWidgets git to fix resizing the
`GLDrawingPanel` in Wayland using the EGL `wxGLCanvas`.
Also rename `IsItWayland()` to `IsWayland()`.
Fix#1028
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
When processing the `OnSize` event in the `GameArea` and calling the
embedded `DrawingPanel` `OnSize` event, call `Layout()` afterwards.
This seems to improve the resizing behavior of the EGL `wxGLCanvas`
`DrawingPanel` on Wayland.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This adds a generic Observer interface to config::Option. To
demonstrate its intended usage, the Display Configuration dialog and
the options it controls have been updated to be entirely handled via
the config::Option class.
Implementations for wxValidator are used to validate the flow between
the UI and the underlying Option. In turn, modifying the Option value
triggers all of its observers that should then do what they need to
do.
Rather than explicitly calling all of the needed methods after
modifying a global option value, the UI elements that need to be
notified when an Option value is modified will be notified via their
observers. Runtime assert checks are put in place to prevent infinite
recursion if an observer attempts to modify an Option while handling
the observer callback.
Once all uses of Options have been updated, we should get into a state
where the following will be true:
* cmdevents.cpp will no longer rely on the application state.
* All dialogs will have been moved to specific implementations,
reducing the size of guiinit.cpp
* update_opts() will no longer need to be called and will be removed.
This will then make it easier to update accelerator handling to be
done with config::UserInput.
Bug: #745
Destroy the DrawingPanel on vsync checkbox toggle so that it is
re-created with the vsync option in effect.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Add support for `eglSwapInterval()` to enable or disable VSync on
Wayland.
Also add status messages for enabling or disabling VSync, for both EGL
and GLX.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
wxWidgets 3.2+ has experimental `wxGLCanvas` support for Wayland EGL,
enable it for those versions.
The `glXQueryExtensionsString()` method for enabling or disabling vsync
does not work on Wayland currently, so it's disabled.
TODO: Enable/disable vsync on Wayland EGL.
Fix#1028.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
* Remove the custom handling for pre-3.1.4 builds on Windows since
both the mingw and msvc builds now use 3.2.
* Remove wxDPIChangedEvent handling, since this triggers a resize,
which has the same effect.
* Implement main/WinMain ourselves, rather than relying on wxWidgets
macros. This allows us to initialize the console earlier in the
process.
* Add an explicit dependency on the manifest file to trigger a link
when it is modified.
This converts the HiDPIAware into a series of helper functions, using
wxWidgets native support starting with wxWidgets 3.1.4. Custom
implementations are provided for Mac and Windows.
In addition, this fixes a few issues with the Windows build:
* Use the same defines variables in the MSVC and MinGW builds, with
g++ and Clang.
* Add a custom manifest for the application, indicating full DPI
support and support for recent Windows versions so the application
will no longer run in compatibility mode by default.
* Manually spawn a console in debug builds if none is attached and
always use the parent console if it is available otherwise, even in
release builds. This also removes the /subsystem:console linker
argument.
The static lib is now called `SDL2-static.lib` and the debug version is
called `SDL2-staticd.lib`.
Adjust our `cmake/FindSDL2.cmake` for the new vcpkg naming convention.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Remove constexpr in user-input.h as LLVM 13 complains that it is
illegal.
Use variant-lite as nonstd::variant and related types as some variant
functions are macOS 10.14 Mojave only.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
* Remove the wx prefix and make UserInput a class in the config
namespace.
* Make UserInput constexpr-constructible. This should reduce program
startup time by having the compiler pre-allocate UserInput objects.
* Change initialization of UserInput objects to be made via
constructor. A previous approach would have limited creation of
UserInput objects to a few places but that proved unworkable in the
long run.
* Changed the string to enum conversions to be built at runtime from
the existing constant array rather than redefining the strings.
* Fixed an issue in the initialization of the `checkable_mi` array.
A test had been mistakenly removed during the refactor.
* Fixed an issue where changing a bool or int option would cause an
assertion error at runtime. Changed helper methods definitions to
use a pointer to a variable rather than take a parameter by
reference, clarifying the intent from the caller perspective.
* Fixed the `renderer` enum definition to properly exclude Direct3D or
Quartz2D depending on the platform.
* Various comment fixes.
This change introduces a new class to handle all of the INI options
data, VbamOption. A VbamOption represents a single option in the INI
file. It is not constructible outside of its implementation, which
prevents the initialization of incorrectly formatted options.
Internally, a VbamOption points to a global variable in memory, which
holds the value used at runtime. This is because various parts of the
codebase edit the global variable rather than going through a central
registry. This also means we need to separately update the INI values.
In the future, we may be able to convert all existing reads and writes
to the global variable to go through VbamOption. Individual UX elements
could link directly to getters/setters for a specific VbamOption rather
than have duplicate data.
VbamOption replaces the opt_desc struct and the global opts array. All
users of opt_desc and the global opts array have been updated.
This is a necessary preliminary change to better support a refactor of
accelerators, through wxUserInput.
Issue: #745, #158
Add default menu accelerator `CTRL+I` to `ChangeIFB` which is the menu
item to change the interframe blending algorithm.
CMD+I on macOS.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>