Lots of interconnected changes in this commit:
- Removed unnecessary name/author/filename members all over the place.
- Started using exceptions to deliver preset loading and rendering errors to the topmost ProjectM class.
- Added stream loading methods to factories and the base Preset class.
- Added new events for requesting preset switch and telling the user about loading errors.
- Consolidated preset switching logic in ProjectM class a bit.
Path scanning is using C++17's std::filesystem if available, but uses boost::filesystem as fallback. Using boost can be forced using the ENABLE_BOOST_FILESYSTEM CMake option.
Also make sure to propagate the changed value to the preset code via the PipelineContext class. Keeping it in the settings struct for now. Storing a dynamic value in settings makes no sense, so it will be removed later.
This removes:
- "Toast" messages
- The help text
- Statistics
- Preset name and (unimplemented) song title display
- Preset selection list and search menu
Some of the above functionality might later be added as an optional library, in a separate repository and with proper UTF-8 support.
The native presets did not build anymore due to refactorings, cause other build issues on Windows (e.g. require linking to psapi.lib) and would need a complete makeover anyway.
In this case, the weighted random chooser would divide by zero, which will cause a crash. In the case this happens, we'll simply use a uniform random distribution as all ratings are equally zero.
The external gltext.h is C, thus forward declare GLTtext as a struct
instead of a class.
In file included from /projectm/src/libprojectM/Renderer/MenuText.cpp:7:
/projectm/src/libprojectM/Renderer/../gltext.h:108:9: warning: struct 'GLTtext' was previously declared as a class; this is valid, but may result in linker errors under the Microsoft C++ ABI [-Wmismatched-tags]
typedef struct GLTtext GLTtext;
^
/projectm/src/libprojectM/Renderer/MenuText.h:9:7: note: previous use is here
class GLTtext;
^
In file included from /projectm/src/libprojectM/Renderer/MenuText.cpp:7:
/projectm/src/libprojectM/Renderer/../gltext.h:211:1: warning: 'GLTtext' defined as a struct here but previously declared as a class; this is valid, but may result in linker errors under the Microsoft C++ ABI [-Wmismatched-tags]
struct GLTtext {
^
/projectm/src/libprojectM/Renderer/MenuText.h:9:1: note: did you mean struct here?
class GLTtext;
^~~~~
struct
CMake defines WIN32 by default on Windows, but we shouldn't rely on it.
_WIN32 is defined by all compilers targeting Windows.
Also cleaned up some header includes.
CMake defines WIN32 by default on Windows, but we shouldn't rely on it,
as it is also defined when using MinGW. Since the comments suggest MSVC-
specific code, scope to MSVC only.
Unfortunately, windows.h breaks the standard library because it
defines max() as a macro by default.
To fix this, add NOMINMAX (and WIN32_LEAN_AND_MEAN for good measure) to
the compile options. Ideally, this would be set on a per-target basis,
but with so many OBJECT targets, that is really tedious. Luckily,
add_compile_definitions() is scoped to the current directory and sub-
directories only.
On MSVC, this warning is emitted when including <vector>, among others:
warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
clang-cl won't even build without /EHsc and fails on the first try-statement.
Since projectM uses the C++ standard library and because it uses exceptions
itself, enable the flag.
Also, since projectM uses dynamic_cast, enable RTTI.
While both /EHsc and /GR are added by CMake by default, user-provided
CMAKE_CXX_FLAGS will override the CMake default. So instead of relying on
the CMake default, enable them explicitly.
In file included from /projectm/src/libprojectM/Renderer/Renderer.cpp:1:
/projectm/src/libprojectM/Renderer/Renderer.hpp:191:10: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
191 | std::unique_ptr<TextureManager> m_textureManager;
| ^~~~~~~~~~
This fixes the following CMake error when configuring with just
-DENABLE_STATIC_LIB=OFF:
CMake Error at src/libprojectM/CMakeLists.txt:130 (add_library):
add_library cannot create ALIAS target "projectM::libprojectM" because
target "projectM_static" does not already exist.
In this case, static linking is disabled, thus the "projectM_static"
CMake target doesn't exist. Previously, ENABLE_SHARED_LINKING was always
false, and because of that, "projectM::libprojectM" was added as as an
alias to "projectM_static", which didn't exist.
Now, ENABLE_SHARED_LINKING is set to true only when ENABLE_SHARED_LIB is
enabled, otherwise it will be false.
Amends the previous commit.
In order to avoid unused parameter warnings when building the library
itself, also unname these parameters here.
The names of these parameters are still named in ProjectM.hpp, so they
serve as documentation. In ProjectM.cpp, they are mere stubs.
As a drive-by, removed some unneeded newlines.
Fixes multiple "warning: unknown pragma ignored [-Wunknown-pragmas]"
diagnostics on GCC/Clang when used with MinGW, both when building the
library aswell as in client applications.