mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 17:50:04 +00:00
Add alert palette reset buttons
This commit is contained in:
parent
2d8c3c8175
commit
a1d9b25f0b
6 changed files with 177 additions and 0 deletions
|
|
@ -48,6 +48,62 @@ SettingsCategory::SettingsCategory(SettingsCategory&&) noexcept = default;
|
|||
SettingsCategory&
|
||||
SettingsCategory::operator=(SettingsCategory&&) noexcept = default;
|
||||
|
||||
bool SettingsCategory::IsDefault() const
|
||||
{
|
||||
bool isDefault = true;
|
||||
|
||||
// Get subcategory array defaults
|
||||
for (auto& subcategoryArray : p->subcategoryArrays_)
|
||||
{
|
||||
for (auto& subcategory : subcategoryArray.second)
|
||||
{
|
||||
isDefault = isDefault && subcategory->IsDefault();
|
||||
}
|
||||
}
|
||||
|
||||
// Get subcategory defaults
|
||||
for (auto& subcategory : p->subcategories_)
|
||||
{
|
||||
isDefault = isDefault && subcategory->IsDefault();
|
||||
}
|
||||
|
||||
// Get variable defaults
|
||||
for (auto& variable : p->variables_)
|
||||
{
|
||||
isDefault = isDefault && variable->IsDefault();
|
||||
}
|
||||
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
bool SettingsCategory::IsDefaultStaged() const
|
||||
{
|
||||
bool isDefaultStaged = true;
|
||||
|
||||
// Get subcategory array defaults
|
||||
for (auto& subcategoryArray : p->subcategoryArrays_)
|
||||
{
|
||||
for (auto& subcategory : subcategoryArray.second)
|
||||
{
|
||||
isDefaultStaged = isDefaultStaged && subcategory->IsDefaultStaged();
|
||||
}
|
||||
}
|
||||
|
||||
// Get subcategory defaults
|
||||
for (auto& subcategory : p->subcategories_)
|
||||
{
|
||||
isDefaultStaged = isDefaultStaged && subcategory->IsDefaultStaged();
|
||||
}
|
||||
|
||||
// Get variable defaults
|
||||
for (auto& variable : p->variables_)
|
||||
{
|
||||
isDefaultStaged = isDefaultStaged && variable->IsDefaultStaged();
|
||||
}
|
||||
|
||||
return isDefaultStaged;
|
||||
}
|
||||
|
||||
std::string SettingsCategory::name() const
|
||||
{
|
||||
return p->name_;
|
||||
|
|
@ -102,6 +158,39 @@ void SettingsCategory::SetDefaults()
|
|||
p->stagedSignal_();
|
||||
}
|
||||
|
||||
void SettingsCategory::StageDefaults()
|
||||
{
|
||||
// Don't allow individual variables to invoke the signal when operating over
|
||||
// the entire category
|
||||
p->blockSignals_ = true;
|
||||
|
||||
// Stage subcategory array defaults
|
||||
for (auto& subcategoryArray : p->subcategoryArrays_)
|
||||
{
|
||||
for (auto& subcategory : subcategoryArray.second)
|
||||
{
|
||||
subcategory->StageDefaults();
|
||||
}
|
||||
}
|
||||
|
||||
// Stage subcategory defaults
|
||||
for (auto& subcategory : p->subcategories_)
|
||||
{
|
||||
subcategory->StageDefaults();
|
||||
}
|
||||
|
||||
// Stage variable defaults
|
||||
for (auto& variable : p->variables_)
|
||||
{
|
||||
variable->StageDefault();
|
||||
}
|
||||
|
||||
// Unblock signals
|
||||
p->blockSignals_ = false;
|
||||
|
||||
p->stagedSignal_();
|
||||
}
|
||||
|
||||
bool SettingsCategory::Commit()
|
||||
{
|
||||
bool committed = false;
|
||||
|
|
|
|||
|
|
@ -43,11 +43,34 @@ public:
|
|||
*/
|
||||
boost::signals2::signal<void()>& staged_signal();
|
||||
|
||||
/**
|
||||
* Gets whether or not all settings variables are currently set to default
|
||||
* values.
|
||||
*
|
||||
* @return true if all settings variables are currently set to default
|
||||
* values, otherwise false.
|
||||
*/
|
||||
bool IsDefault() const;
|
||||
|
||||
/**
|
||||
* Gets whether or not all settings variables currently have staged values
|
||||
* set to default.
|
||||
*
|
||||
* @return true if all settings variables currently have staged values set
|
||||
* to default, otherwise false.
|
||||
*/
|
||||
bool IsDefaultStaged() const;
|
||||
|
||||
/**
|
||||
* Set all variables to their defaults.
|
||||
*/
|
||||
void SetDefaults();
|
||||
|
||||
/**
|
||||
* Stage all variables to their defaults.
|
||||
*/
|
||||
void StageDefaults();
|
||||
|
||||
/**
|
||||
* Sets the current value of all variables to the staged value.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -65,6 +65,18 @@ inline auto FormatParameter(const T& value)
|
|||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool SettingsVariable<T>::IsDefault() const
|
||||
{
|
||||
return p->value_ == p->default_;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool SettingsVariable<T>::IsDefaultStaged() const
|
||||
{
|
||||
return p->staged_.value_or(p->value_) == p->default_;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T SettingsVariable<T>::GetValue() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,6 +37,24 @@ public:
|
|||
SettingsVariable(SettingsVariable&&) noexcept;
|
||||
SettingsVariable& operator=(SettingsVariable&&) noexcept;
|
||||
|
||||
/**
|
||||
* Gets whether or not the settings variable is currently set to its default
|
||||
* value.
|
||||
*
|
||||
* @return true if the settings variable is currently set to its default
|
||||
* value, otherwise false.
|
||||
*/
|
||||
bool IsDefault() const;
|
||||
|
||||
/**
|
||||
* Gets whether or not the settings variable currently has its staged value
|
||||
* set to default.
|
||||
*
|
||||
* @return true if the settings variable currently has its staged value set
|
||||
* to default, otherwise false.
|
||||
*/
|
||||
bool IsDefaultStaged() const;
|
||||
|
||||
/**
|
||||
* Gets the current value of the settings variable.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -45,6 +45,24 @@ public:
|
|||
*/
|
||||
boost::signals2::signal<void()>& staged_signal();
|
||||
|
||||
/**
|
||||
* Gets whether or not the settings variable is currently set to its default
|
||||
* value.
|
||||
*
|
||||
* @return true if the settings variable is currently set to its default
|
||||
* value, otherwise false.
|
||||
*/
|
||||
virtual bool IsDefault() const = 0;
|
||||
|
||||
/**
|
||||
* Gets whether or not the settings variable currently has its staged value
|
||||
* set to default.
|
||||
*
|
||||
* @return true if the settings variable currently has its staged value set
|
||||
* to default, otherwise false.
|
||||
*/
|
||||
virtual bool IsDefaultStaged() const = 0;
|
||||
|
||||
/**
|
||||
* Sets the current value of the settings variable to default.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue