diff --git a/src/util/config/config.cpp b/src/util/config/config.cpp index 6cf08c77..3bb08820 100644 --- a/src/util/config/config.cpp +++ b/src/util/config/config.cpp @@ -193,6 +193,24 @@ namespace dxvk { result = sign * intval; return true; } + + + bool Config::parseOptionValue( + const std::string& value, + Tristate& result) { + if (value == "True") { + result = Tristate::True; + return true; + } else if (value == "False") { + result = Tristate::False; + return true; + } else if (value == "Auto") { + result = Tristate::Auto; + return true; + } else { + return false; + } + } Config Config::getAppConfig(const std::string& appName) { diff --git a/src/util/config/config.h b/src/util/config/config.h index 170983f4..f44c652b 100644 --- a/src/util/config/config.h +++ b/src/util/config/config.h @@ -5,6 +5,18 @@ namespace dxvk { + /** + * \brief Tri-state + * + * Used to conditionally override + * booleans if desired. + */ + enum class Tristate : int32_t { + Auto = -1, + False = 0, + True = 1, + }; + /** * \brief Config option set * @@ -108,7 +120,26 @@ namespace dxvk { static bool parseOptionValue( const std::string& value, int32_t& result); + + static bool parseOptionValue( + const std::string& value, + Tristate& result); }; + + /** + * \brief Applies tristate option + * + * Overrides the given value if \c state is + * \c True or \c False, and leaves it intact + * otherwise. + * \param [out] option The value to override + * \param [in] state Tristate to apply + */ + inline void applyTristate(bool& option, Tristate state) { + option &= state != Tristate::False; + option |= state == Tristate::True; + } + } \ No newline at end of file