From 5e5b35fdb8802e512229a9d54a58ca2aa1e04234 Mon Sep 17 00:00:00 2001 From: Kai Blaschke Date: Tue, 5 Apr 2022 13:20:47 +0200 Subject: [PATCH] Replaced behaviour FLAG_* constants with an enum. --- src/libprojectM/ProjectM.cpp | 10 +++++++--- src/libprojectM/ProjectM.hpp | 17 ++++++++++++----- src/libprojectM/ProjectMCWrapper.cpp | 4 ++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/libprojectM/ProjectM.cpp b/src/libprojectM/ProjectM.cpp index d934e7355..813dda081 100644 --- a/src/libprojectM/ProjectM.cpp +++ b/src/libprojectM/ProjectM.cpp @@ -69,7 +69,7 @@ void ProjectM::projectM_resetTextures() } -ProjectM::ProjectM(std::string config_file, int flags) +ProjectM::ProjectM(std::string config_file, Flags flags) : m_flags(flags) , m_pipelineContext(new PipelineContext()) , m_pipelineContext2(new PipelineContext()) @@ -80,7 +80,7 @@ ProjectM::ProjectM(std::string config_file, int flags) } -ProjectM::ProjectM(Settings settings, int flags) +ProjectM::ProjectM(Settings settings, Flags flags) : m_flags(flags) , m_pipelineContext(new PipelineContext()) , m_pipelineContext2(new PipelineContext()) @@ -540,7 +540,11 @@ int ProjectM::initPresetTools(int gx, int gy) /* Set the seed to the current time in seconds */ srand(time(NULL)); - std::string url = (m_flags & FLAG_DISABLE_PLAYLIST_LOAD) ? std::string() : settings().presetURL; + std::string url; + if ((m_flags & Flags::DisablePlaylistLoad) == Flags::DisablePlaylistLoad) + { + url = settings().presetURL; + } if ((m_presetLoader = std::make_unique(gx, gy, url)) == 0) { diff --git a/src/libprojectM/ProjectM.hpp b/src/libprojectM/ProjectM.hpp index f7ee1c3e9..00e61444b 100644 --- a/src/libprojectM/ProjectM.hpp +++ b/src/libprojectM/ProjectM.hpp @@ -91,8 +91,15 @@ typedef enum class ProjectM { public: - static const int FLAG_NONE = 0; - static const int FLAG_DISABLE_PLAYLIST_LOAD = 1 << 0; + /* + * Behaviour flags for the projectM instance. Currently, it's only used to prevent automatically filling + * the preset playlist by traversing the preset path for files. + */ + enum Flags + { + None = 0, //!< No special flags. + DisablePlaylistLoad = 1 << 0 //!< Prevent automatic playlist loading on startup. + }; class Settings { @@ -119,9 +126,9 @@ public: bool softCutRatingsEnabled{ false }; }; - ProjectM(std::string config_file, int flags = FLAG_NONE); + ProjectM(std::string config_file, Flags flags = Flags::None); - ProjectM(Settings settings, int flags = FLAG_NONE); + ProjectM(Settings settings, Flags flags = Flags::None); virtual ~ProjectM(); @@ -388,7 +395,7 @@ private: Settings m_settings; //!< The projectM settings. - int m_flags{ 0 }; //!< Behaviour flags. + Flags m_flags{ Flags::None }; //!< Behaviour flags. std::vector m_presetHistory; //!< List of previously played preset indices. std::vector m_presetFuture; //!< List of preset indices queued for playing. diff --git a/src/libprojectM/ProjectMCWrapper.cpp b/src/libprojectM/ProjectMCWrapper.cpp index cae88252f..42dcbac2f 100644 --- a/src/libprojectM/ProjectMCWrapper.cpp +++ b/src/libprojectM/ProjectMCWrapper.cpp @@ -6,12 +6,12 @@ #include projectMWrapper::projectMWrapper(std::string configFile, int flags) - : ProjectM(std::move(configFile), flags) + : ProjectM(std::move(configFile), static_cast(flags)) { } projectMWrapper::projectMWrapper(ProjectM::Settings settings, int flags) - : ProjectM(std::move(settings), flags) + : ProjectM(std::move(settings), static_cast(flags)) { }