feat: add summon max value

This commit is contained in:
2021-10-08 18:28:21 +02:00
parent ef76437670
commit 48b5372533

View File

@@ -224,12 +224,24 @@ void showStats() {
ImGui::Text("Gold : %i", client->getGame().getPlayer()->getGold());
}
void capValues(int* values, int& value) {
value = std::max(0, value);
value = std::min(12, value);
int total = 0;
for (int j = 0; j < 16; j++) {
total += values[j];
}
if(total == 13)
value--;
}
void renderSummonMenu() {
static bool menu_open = false;
static bool menu_open = true;
if (menu_open) {
ImGui::Begin("Summon", &menu_open);
static int width = 100;
static int values[16]{ 0 };
ImTextureID my_tex_id = ImGui::GetIO().Fonts->TexID;
for (int i = 0; i < 8; i++) {
ImGui::SameLine();
@@ -238,12 +250,13 @@ void renderSummonMenu() {
ImGui::PopID();
}
ImGui::Separator();
static int values[16];
ImGui::PushItemWidth(width);
for (int i = 0; i < 8; i++) {
ImGui::SameLine();
ImGui::PushID(i);
ImGui::InputInt("", values + i, 1, 10);
if (ImGui::InputInt("", values + i, 1, 10)) {
capValues(values, values[i]);
}
ImGui::PopID();
}
ImGui::PopItemWidth();
@@ -259,10 +272,15 @@ void renderSummonMenu() {
for (int i = 8; i < 16; i++) {
ImGui::SameLine();
ImGui::PushID(i);
ImGui::InputInt("", values + i, 1, 10);
if (ImGui::InputInt("", values + i, 1, 10)) {
capValues(values, values[i]);
}
ImGui::PopID();
}
ImGui::PopItemWidth();
if(ImGui::Button("Send")){
std::cout << "Sending Troops ...\n";
}
ImGui::End();
}
}
@@ -284,6 +302,7 @@ void renderGame() {
showTPS();
showStats();
showPlayers();
renderSummonMenu();
ImGui::End();
}
@@ -311,7 +330,6 @@ void render() {
static bool demo_open = false;
if (demo_open)
ImGui::ShowDemoWindow(&demo_open);
renderSummonMenu();
renderFPSCounter();
endFrame();
}