mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-01 16:57:50 +00:00
Properly save & restore empty values as well
This commit is contained in:
parent
94e6847dc4
commit
4734d8de1e
@ -396,10 +396,9 @@ void manager::add_checkbox(const config& data, config& column) const
|
||||
config& manager::get_value_cfg(const std::string& id)
|
||||
{
|
||||
{
|
||||
const manager* m = this;
|
||||
config& value_cfg = const_cast<config&>(m->get_value_cfg(id));
|
||||
const config& value_cfg = get_value_cfg_or_empty(id);
|
||||
if (!value_cfg.empty()) {
|
||||
return value_cfg;
|
||||
return const_cast<config&>(value_cfg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,7 +417,7 @@ config& manager::get_value_cfg(const std::string& id)
|
||||
return value_cfg;
|
||||
}
|
||||
|
||||
const config& manager::get_value_cfg(const std::string& id) const
|
||||
const config& manager::get_value_cfg_or_empty(const std::string& id) const
|
||||
{
|
||||
static const config empty;
|
||||
|
||||
@ -470,9 +469,9 @@ const config& manager::get_option_info_cfg(const std::string& id) const
|
||||
|
||||
config::attribute_value manager::get_stored_value(const std::string& id) const
|
||||
{
|
||||
const config& valcfg = get_value_cfg(id);
|
||||
const config& valcfg = get_value_cfg_or_empty(id);
|
||||
|
||||
if (!valcfg["value"].empty()) {
|
||||
if (!valcfg.empty()) {
|
||||
// There's a saved value for this option
|
||||
return valcfg["value"];
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ private:
|
||||
* for this option should be written into or
|
||||
* an empty config if that doesn't exist.
|
||||
*/
|
||||
const config& get_value_cfg(const std::string& id) const;
|
||||
const config& get_value_cfg_or_empty(const std::string& id) const;
|
||||
|
||||
/**
|
||||
* Returns the information about an option.
|
||||
|
Loading…
x
Reference in New Issue
Block a user