mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-19 07:21:40 +00:00
Qt/CheatSearchWidget: Add a checkbox to force parsing a value as hexadecimal.
This commit is contained in:
parent
b3e17d2772
commit
6e814cbb8f
4 changed files with 49 additions and 15 deletions
|
@ -340,22 +340,31 @@ void Cheats::CheatSearchSession<T>::SetFilterType(FilterType filter_type)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
static std::optional<T> ParseValue(const std::string& str)
|
||||
static std::optional<T> ParseValue(const std::string& str, bool force_parse_as_hex)
|
||||
{
|
||||
if (str.empty())
|
||||
return std::nullopt;
|
||||
|
||||
T tmp;
|
||||
if (TryParse(str, &tmp))
|
||||
return tmp;
|
||||
if constexpr (std::is_integral_v<T>)
|
||||
{
|
||||
if (TryParse(str, &tmp, force_parse_as_hex ? 16 : 0))
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TryParse(str, &tmp))
|
||||
return tmp;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Cheats::CheatSearchSession<T>::SetValueFromString(const std::string& value_as_string)
|
||||
bool Cheats::CheatSearchSession<T>::SetValueFromString(const std::string& value_as_string,
|
||||
bool force_parse_as_hex)
|
||||
{
|
||||
m_value = ParseValue<T>(value_as_string);
|
||||
m_value = ParseValue<T>(value_as_string, force_parse_as_hex);
|
||||
return m_value.has_value();
|
||||
}
|
||||
|
||||
|
@ -498,6 +507,18 @@ bool Cheats::CheatSearchSession<T>::GetAligned()
|
|||
return m_aligned;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Cheats::CheatSearchSession<T>::IsIntegerType() const
|
||||
{
|
||||
return std::is_integral_v<T>;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Cheats::CheatSearchSession<T>::IsFloatingType() const
|
||||
{
|
||||
return std::is_floating_point_v<T>;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
size_t Cheats::CheatSearchSession<T>::GetResultCount() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue