mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
Input: Add "abs" input expression function.
This commit is contained in:
parent
a056a1366f
commit
f5b9049421
@ -303,6 +303,7 @@ void IOWindow::CreateMainLayout()
|
|||||||
m_functions_combo->addItem(QStringLiteral("min"));
|
m_functions_combo->addItem(QStringLiteral("min"));
|
||||||
m_functions_combo->addItem(QStringLiteral("max"));
|
m_functions_combo->addItem(QStringLiteral("max"));
|
||||||
m_functions_combo->addItem(QStringLiteral("clamp"));
|
m_functions_combo->addItem(QStringLiteral("clamp"));
|
||||||
|
m_functions_combo->addItem(QStringLiteral("abs"));
|
||||||
|
|
||||||
m_variables_combo = new QComboBoxWithMouseWheelDisabled(this);
|
m_variables_combo = new QComboBoxWithMouseWheelDisabled(this);
|
||||||
m_variables_combo->addItem(tr("User Variables"));
|
m_variables_combo->addItem(tr("User Variables"));
|
||||||
|
@ -69,6 +69,22 @@ private:
|
|||||||
void SetValue(ControlState value) override { GetArg(0).SetValue(1.0 - value); }
|
void SetValue(ControlState value) override { GetArg(0).SetValue(1.0 - value); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// usage: abs(expression)
|
||||||
|
class AbsExpression final : public FunctionExpression
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
ArgumentValidation
|
||||||
|
ValidateArguments(const std::vector<std::unique_ptr<Expression>>& args) override
|
||||||
|
{
|
||||||
|
if (args.size() == 1)
|
||||||
|
return ArgumentsAreValid{};
|
||||||
|
else
|
||||||
|
return ExpectedArguments{"expression"};
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlState GetValue() const override { return std::abs(GetArg(0).GetValue()); }
|
||||||
|
};
|
||||||
|
|
||||||
// usage: sin(expression)
|
// usage: sin(expression)
|
||||||
class SinExpression : public FunctionExpression
|
class SinExpression : public FunctionExpression
|
||||||
{
|
{
|
||||||
@ -641,6 +657,8 @@ std::unique_ptr<FunctionExpression> MakeFunctionExpression(std::string_view name
|
|||||||
return std::make_unique<NotExpression>();
|
return std::make_unique<NotExpression>();
|
||||||
if (name == "if")
|
if (name == "if")
|
||||||
return std::make_unique<IfExpression>();
|
return std::make_unique<IfExpression>();
|
||||||
|
if (name == "abs")
|
||||||
|
return std::make_unique<AbsExpression>();
|
||||||
if (name == "sin")
|
if (name == "sin")
|
||||||
return std::make_unique<SinExpression>();
|
return std::make_unique<SinExpression>();
|
||||||
if (name == "cos")
|
if (name == "cos")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user