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