2017-02-26 20:00:24 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
|
|
|
|
2020-01-18 17:19:32 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
2017-02-26 20:00:24 +00:00
|
|
|
namespace ControllerEmu
|
|
|
|
{
|
2019-03-27 00:31:03 +00:00
|
|
|
NumericSettingBase::NumericSettingBase(const NumericSettingDetails& details) : m_details(details)
|
2017-02-26 20:00:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-03-27 00:31:03 +00:00
|
|
|
const char* NumericSettingBase::GetUIName() const
|
2017-02-26 20:00:24 +00:00
|
|
|
{
|
2019-03-27 00:31:03 +00:00
|
|
|
return m_details.ui_name;
|
2017-02-26 20:00:24 +00:00
|
|
|
}
|
2019-03-27 00:31:03 +00:00
|
|
|
|
|
|
|
const char* NumericSettingBase::GetUISuffix() const
|
|
|
|
{
|
|
|
|
return m_details.ui_suffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* NumericSettingBase::GetUIDescription() const
|
|
|
|
{
|
|
|
|
return m_details.ui_description;
|
|
|
|
}
|
|
|
|
|
2020-01-18 17:19:32 +00:00
|
|
|
template <>
|
|
|
|
void NumericSetting<int>::SetExpressionFromValue()
|
|
|
|
{
|
|
|
|
m_value.m_input.SetExpression(ValueToString(GetValue()));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void NumericSetting<double>::SetExpressionFromValue()
|
|
|
|
{
|
|
|
|
// We must use a dot decimal separator for expression parser.
|
|
|
|
std::ostringstream ss;
|
|
|
|
ss.imbue(std::locale::classic());
|
|
|
|
ss << GetValue();
|
|
|
|
|
|
|
|
m_value.m_input.SetExpression(ss.str());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void NumericSetting<bool>::SetExpressionFromValue()
|
|
|
|
{
|
|
|
|
// Cast bool to prevent "true"/"false" strings.
|
|
|
|
m_value.m_input.SetExpression(ValueToString(int(GetValue())));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
SettingType NumericSetting<int>::GetType() const
|
|
|
|
{
|
|
|
|
return SettingType::Int;
|
|
|
|
}
|
|
|
|
|
2019-03-27 00:31:03 +00:00
|
|
|
template <>
|
|
|
|
SettingType NumericSetting<double>::GetType() const
|
|
|
|
{
|
|
|
|
return SettingType::Double;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
SettingType NumericSetting<bool>::GetType() const
|
2017-02-26 20:00:24 +00:00
|
|
|
{
|
2019-03-27 00:31:03 +00:00
|
|
|
return SettingType::Bool;
|
2017-02-26 20:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ControllerEmu
|