Merge pull request #591 from harlanx/clamp_input_values

Clamp input values
This commit is contained in:
Taiga 2022-08-30 12:20:44 -06:00 committed by GitHub
commit 44bdbe0a14
2 changed files with 7 additions and 4 deletions

View File

@ -78,7 +78,7 @@ bool TypeWidget(const char* label, int& value, int step, int start, int end, con
if (start == end)
result = ImGui::InputInt(label, &value, step);
else
result = ImGui::DragInt(label, &value, (float)step, start, end);
result = ImGui::DragInt(label, &value, (float)step, start, end, nullptr, ImGuiSliderFlags_AlwaysClamp);
END_TYPE_WIDGET();
}
@ -90,7 +90,7 @@ bool TypeWidget(const char* label, float& value, float step, float start, float
if (start == end)
result = ImGui::InputFloat(label, &value, step);
else
result = ImGui::DragFloat(label, &value, step, start, end);
result = ImGui::DragFloat(label, &value, step, start, end, nullptr, ImGuiSliderFlags_AlwaysClamp);
END_TYPE_WIDGET();
}

View File

@ -65,7 +65,7 @@ namespace cheat::feature
}
else
{
ConfigWidget("Min Multiplier", f_minMultiplier, 1, 2, 1000, "Attack count minimum multiplier.");
ConfigWidget("Min Multiplier", f_minMultiplier, 1, 1, 1000, "Attack count minimum multiplier.");
ConfigWidget("Max Multiplier", f_maxMultiplier, 1, 2, 1000, "Attack count maximum multiplier.");
}
}
@ -158,6 +158,9 @@ namespace cheat::feature
}
if (f_Randomize)
{
if (f_minMultiplier.value() >= f_maxMultiplier.value())
countOfAttacks = f_minMultiplier.value();
else
countOfAttacks = rand() % (f_maxMultiplier.value() - f_minMultiplier.value()) + f_minMultiplier.value();
return countOfAttacks;
}