From 509283f48ae7644b0e5f8bee110b5ddbe48927f5 Mon Sep 17 00:00:00 2001 From: Yimura Date: Sat, 26 Dec 2020 19:59:40 +0100 Subject: [PATCH] feat(GUI): Added user sidebar --- BigBaseV2/src/gui.cpp | 3 ++ BigBaseV2/src/gui.hpp | 1 + BigBaseV2/src/gui/user_sidebar.cpp | 74 ++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 BigBaseV2/src/gui/user_sidebar.cpp diff --git a/BigBaseV2/src/gui.cpp b/BigBaseV2/src/gui.cpp index 4e721b04..4812ea4b 100644 --- a/BigBaseV2/src/gui.cpp +++ b/BigBaseV2/src/gui.cpp @@ -104,6 +104,9 @@ namespace big // gui/main_window.cpp render_main_window(); + + // gui/user_sidebar.cpp + render_user_sidebar(); } EXCEPT_CLAUSE } diff --git a/BigBaseV2/src/gui.hpp b/BigBaseV2/src/gui.hpp index a6447d80..4ab4b8c0 100644 --- a/BigBaseV2/src/gui.hpp +++ b/BigBaseV2/src/gui.hpp @@ -15,6 +15,7 @@ namespace big void render_top_bar(); void render_main_window(); + void render_user_sidebar(); public: bool m_opened{}; }; diff --git a/BigBaseV2/src/gui/user_sidebar.cpp b/BigBaseV2/src/gui/user_sidebar.cpp new file mode 100644 index 00000000..98cd5212 --- /dev/null +++ b/BigBaseV2/src/gui/user_sidebar.cpp @@ -0,0 +1,74 @@ +#include "imgui.h" +#include "gui.hpp" +#include "features.hpp" + +namespace big +{ + void gui::render_user_sidebar() + { + ImGui::SetNextWindowSize({ 350.f, (float)y }, ImGuiCond_Always); + ImGui::SetNextWindowPos({ x - 350.f, 0.f }, ImGuiCond_Always); + if (ImGui::Begin("###player_menu", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNav)) + { + auto vecButtonWidth = ImVec2(ImGui::GetWindowSize().x, 0.0f); + + ImGui::TextColored({ 255,255,255,255 }, "YOU:"); + + if (ImGui::Button(g_players[g_playerId].name, vecButtonWidth)) + { + g_selectedPlayer = g_playerId; + } + + ImGui::Separator(); + + if (ImGui::TreeNode("Friends")) + { + bool friendInLobby = false; + + for (int i = 0; i < 32; i++) + { + player player = g_players[i]; + + if (player.is_friend && player.is_online) + { + friendInLobby = true; + + if (ImGui::Button(player.name, vecButtonWidth)) + { + g_selectedPlayer = i; + } + } + } + + if (!friendInLobby) + { + ImGui::TextColored({ 180,180,180,255 }, " No friends in current lobby."); + } + + ImGui::TreePop(); + ImGui::Separator(); + } + + if (ImGui::TreeNode("Players")) + { + for (int i = 0; i < 32; i++) + { + player player = g_players[i]; + + if (!player.is_friend && player.is_online && i != g_playerId) + { + if (ImGui::Button(player.name, vecButtonWidth)) + { + g_selectedPlayer = i; + } + } + } + + ImGui::TreePop(); + } + + ImGui::End(); + } + + } +} \ No newline at end of file