refactor: create gui widget classes
This commit is contained in:
@@ -1,24 +1,14 @@
|
||||
#include "render/gui/GameMenu.h"
|
||||
#include "render/gui/imgui/imgui.h"
|
||||
|
||||
#include "render/WorldRenderer.h"
|
||||
|
||||
#include "game/client/Client.h"
|
||||
#include "game/server/Lobby.h"
|
||||
|
||||
namespace td {
|
||||
namespace gui {
|
||||
|
||||
ImVec4 getImGuiTeamColor(td::game::TeamColor color) {
|
||||
switch (color) {
|
||||
case td::game::TeamColor::None:
|
||||
break;
|
||||
case td::game::TeamColor::Red:
|
||||
return ImVec4(1, 0, 0, 1);
|
||||
case td::game::TeamColor::Blue:
|
||||
return ImVec4(0, 0, 1, 1);
|
||||
}
|
||||
return ImVec4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
GameMenu::GameMenu(client::Client* client) : GuiWidget(client), m_SummonMenu(std::make_unique<SummonMenu>(client)) {
|
||||
|
||||
}
|
||||
@@ -51,7 +41,7 @@ void GameMenu::showPlayers() {
|
||||
if (ImGui::TreeNode(std::string("Players (" + std::to_string(getClient()->getGame().getPlayers().size()) + ")##player_list").c_str())) {
|
||||
for (auto pair : getClient()->getGame().getPlayers()) {
|
||||
const td::game::Player& player = pair.second;
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, getImGuiTeamColor(player.getTeamColor()));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, render::WorldRenderer::getImGuiTeamColor(player.getTeamColor()));
|
||||
ImGui::Text("%s", player.getName().c_str());
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user