GUI: randomize in macros under the right click

This commit is contained in:
tildearrow 2022-09-16 00:18:14 -05:00
parent aa38292ca4
commit 587e066d43
3 changed files with 25 additions and 0 deletions

View file

@ -5216,6 +5216,8 @@ FurnaceGUI::FurnaceGUI():
macroOffY(0),
macroScaleX(100.0f),
macroScaleY(100.0f),
macroRandMin(0),
macroRandMax(0),
macroLoopDragStart(0,0),
macroLoopDragAreaSize(0,0),
macroLoopDragTarget(NULL),

View file

@ -1446,6 +1446,7 @@ class FurnaceGUI {
FurnaceGUIMacroDesc lastMacroDesc;
int macroOffX, macroOffY;
float macroScaleX, macroScaleY;
int macroRandMin, macroRandMax;
ImVec2 macroLoopDragStart;
ImVec2 macroLoopDragAreaSize;

View file

@ -4556,6 +4556,28 @@ void FurnaceGUI::drawInsEdit() {
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("randomize...")) {
if (macroRandMin<lastMacroDesc.min) macroRandMin=lastMacroDesc.min;
if (macroRandMin>lastMacroDesc.max) macroRandMin=lastMacroDesc.max;
if (macroRandMax<lastMacroDesc.min) macroRandMax=lastMacroDesc.min;
if (macroRandMax>lastMacroDesc.max) macroRandMax=lastMacroDesc.max;
ImGui::InputInt("Min",&macroRandMin,1,10);
ImGui::InputInt("Max",&macroRandMax,1,10);
if (ImGui::Button("randomize")) {
for (int i=0; i<lastMacroDesc.macro->len; i++) {
int val=0;
if (macroRandMax<=macroRandMin) {
val=macroRandMin;
} else {
val=macroRandMin+(rand()%(macroRandMax-macroRandMin+1));
}
lastMacroDesc.macro->val[i]=val;
}
ImGui::CloseCurrentPopup();
}
ImGui::EndMenu();
}
ImGui::EndPopup();
}