mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-12 20:28:11 -05:00
Add option to round variable to nearest integer
This commit is contained in:
@@ -25,6 +25,8 @@ static std::map<MacroActionVariable::Type, std::string> actionTypes = {
|
||||
"AdvSceneSwitcher.action.variable.type.setConditionValue"},
|
||||
{MacroActionVariable::Type::SET_ACTION_VALUE,
|
||||
"AdvSceneSwitcher.action.variable.type.setActionValue"},
|
||||
{MacroActionVariable::Type::ROUND_TO_INT,
|
||||
"AdvSceneSwitcher.action.variable.type.roundToInt"},
|
||||
};
|
||||
|
||||
static void apppend(Variable &var, const std::string &value)
|
||||
@@ -95,6 +97,13 @@ bool MacroActionVariable::PerformAction()
|
||||
var->SetValue(segment->GetVariableValue());
|
||||
break;
|
||||
}
|
||||
case Type::ROUND_TO_INT: {
|
||||
double curValue;
|
||||
if (!var->DoubleValue(curValue)) {
|
||||
return true;
|
||||
}
|
||||
var->SetValue(std::to_string(int(std::round(curValue))));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
DECREMENT,
|
||||
SET_CONDITION_VALUE,
|
||||
SET_ACTION_VALUE,
|
||||
ROUND_TO_INT,
|
||||
};
|
||||
|
||||
Type _type = Type::SET_FIXED_VALUE;
|
||||
|
||||
Reference in New Issue
Block a user