mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 10:24:12 +01:00
[util] Add tristate config option type
This commit is contained in:
parent
214891ffc6
commit
524227d21c
@ -195,6 +195,24 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
auto appConfig = g_appDefaults.find(appName);
|
||||
if (appConfig != g_appDefaults.end()) {
|
||||
|
@ -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
|
||||
*
|
||||
@ -109,6 +121,25 @@ namespace dxvk {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user