feat: add summon menu
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
#include "render/Renderer.h"
|
||||
#include "network/Network.h"
|
||||
|
||||
#include "render/gui/GuiManager.h"
|
||||
#include "render/gui/SummonMenu.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
@@ -28,9 +31,14 @@ static SDL_GLContext gl_context;
|
||||
static std::unique_ptr<td::client::Client> client;
|
||||
static std::thread* serverThread;
|
||||
static td::render::Renderer* renderer;
|
||||
static td::gui::GuiManager guiManager;
|
||||
|
||||
bool serverShouldStop = false;
|
||||
|
||||
void initWidgets(){
|
||||
guiManager.addWidgets(std::make_shared<td::gui::SummonMenu>(client.get()));
|
||||
}
|
||||
|
||||
void init(SDL_Window* sdl_window, SDL_GLContext sdlContext, td::render::Renderer* render) {
|
||||
window = sdl_window;
|
||||
gl_context = sdlContext;
|
||||
@@ -44,6 +52,7 @@ void init(SDL_Window* sdl_window, SDL_GLContext sdlContext, td::render::Renderer
|
||||
ImGui::GetIO().Fonts->AddFontDefault(&c);
|
||||
renderer = render;
|
||||
client = std::make_unique<td::client::Client>(render);
|
||||
initWidgets();
|
||||
}
|
||||
|
||||
void beginFrame() {
|
||||
@@ -237,53 +246,7 @@ void capValues(int* values, int& value) {
|
||||
}
|
||||
|
||||
void renderSummonMenu() {
|
||||
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();
|
||||
ImGui::PushID(i);
|
||||
ImGui::Image(my_tex_id, ImVec2(100, 100));
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::Separator();
|
||||
ImGui::PushItemWidth(width);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ImGui::SameLine();
|
||||
ImGui::PushID(i);
|
||||
if (ImGui::InputInt("", values + i, 1, 10)) {
|
||||
capValues(values, values[i]);
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::Separator();
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ImGui::SameLine();
|
||||
ImGui::PushID(i);
|
||||
ImGui::Image(my_tex_id, ImVec2(100, 100));
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::Separator();
|
||||
ImGui::PushItemWidth(width);
|
||||
for (int i = 8; i < 16; i++) {
|
||||
ImGui::SameLine();
|
||||
ImGui::PushID(i);
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void renderGame() {
|
||||
@@ -303,7 +266,7 @@ void renderGame() {
|
||||
showTPS();
|
||||
showStats();
|
||||
showPlayers();
|
||||
renderSummonMenu();
|
||||
guiManager.renderWidgets();
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user