2022-01-11 22:33:29 +01:00
|
|
|
#include "gui/gui.hpp"
|
2022-01-09 00:43:33 +01:00
|
|
|
#include "imgui.h"
|
2022-01-17 19:57:00 +01:00
|
|
|
#include "imgui_stdlib.h"
|
2022-01-09 00:43:33 +01:00
|
|
|
#include "imgui_impl_glfw.h"
|
|
|
|
#include "imgui_impl_opengl3.h"
|
2022-01-11 22:33:29 +01:00
|
|
|
#include "gui/window.hpp"
|
2022-01-17 22:00:26 +01:00
|
|
|
#include "gui/gui_data.hpp"
|
|
|
|
#include "character_sheet.hpp"
|
2022-01-20 22:30:14 +01:00
|
|
|
#include "controller.hpp"
|
2022-01-09 00:43:33 +01:00
|
|
|
|
2022-01-14 22:06:07 +01:00
|
|
|
gui::Gui::Gui(GuiData &data, menu::MenuData &menuData) : data(data), menu(menuData), font("font/DejaVuSans.ttf") {
|
2022-01-10 21:16:05 +01:00
|
|
|
SPDLOG_DEBUG("Creating GUI");
|
2022-01-11 22:06:21 +01:00
|
|
|
(void) ImGui::CreateContext();
|
2022-01-09 00:43:33 +01:00
|
|
|
ImGui::StyleColorsDark();
|
2022-01-11 22:06:21 +01:00
|
|
|
(void) ImGui::GetIO().Fonts->AddFontFromFileTTF(font.c_str(), 18.0f);
|
|
|
|
(void) ImGui_ImplGlfw_InitForOpenGL(data.get_window().get_window().get(), true);
|
2022-01-17 22:00:26 +01:00
|
|
|
initialized = ImGui_ImplOpenGL3_Init("#version 130");
|
2022-01-10 21:16:05 +01:00
|
|
|
SPDLOG_DEBUG("Initialized: {}", initialized);
|
2022-01-09 00:43:33 +01:00
|
|
|
}
|
2022-01-08 21:57:17 +01:00
|
|
|
|
|
|
|
gui::Gui::~Gui() noexcept {
|
2022-01-09 00:43:33 +01:00
|
|
|
ImGui_ImplOpenGL3_Shutdown();
|
|
|
|
ImGui_ImplGlfw_Shutdown();
|
|
|
|
ImGui::DestroyContext();
|
|
|
|
}
|
|
|
|
|
2022-01-20 22:30:14 +01:00
|
|
|
void gui::Gui::render_gui(const Controller &controller) {
|
2022-01-09 00:43:33 +01:00
|
|
|
if (initialized) {
|
2022-01-14 19:21:42 +01:00
|
|
|
constexpr ImGuiWindowFlags flags = ImGuiWindowFlags_MenuBar |
|
|
|
|
ImGuiWindowFlags_NoMove |
|
2022-01-11 22:01:57 +01:00
|
|
|
ImGuiWindowFlags_NoResize |
|
|
|
|
ImGuiWindowFlags_NoCollapse |
|
|
|
|
ImGuiWindowFlags_NoTitleBar;
|
|
|
|
|
2022-01-09 00:43:33 +01:00
|
|
|
ImGui_ImplOpenGL3_NewFrame();
|
|
|
|
ImGui_ImplGlfw_NewFrame();
|
|
|
|
ImGui::NewFrame();
|
|
|
|
|
|
|
|
//TODO GUI
|
2022-01-11 22:01:57 +01:00
|
|
|
{
|
|
|
|
const ImGuiViewport &viewport = *ImGui::GetMainViewport();
|
|
|
|
ImGui::SetNextWindowPos(viewport.Pos);
|
|
|
|
ImGui::SetNextWindowSize(viewport.Size);
|
2022-01-09 00:43:33 +01:00
|
|
|
}
|
2022-01-11 22:01:57 +01:00
|
|
|
|
|
|
|
// Never collapsed.
|
2022-01-11 22:06:21 +01:00
|
|
|
(void) ImGui::Begin("Billy", nullptr, flags);
|
2022-01-14 19:21:42 +01:00
|
|
|
menu.gui();
|
2022-01-11 22:01:57 +01:00
|
|
|
|
2022-01-17 19:57:00 +01:00
|
|
|
{
|
2022-01-24 20:51:25 +01:00
|
|
|
ImGui::BeginChild("carac", ImVec2(0, ImGui::GetWindowHeight() * 0.2f), true);
|
2022-01-17 19:57:00 +01:00
|
|
|
ImGui::Text("Caractère");
|
|
|
|
// Remove label
|
|
|
|
ImGui::PushItemWidth(-1);
|
|
|
|
ImGui::InputTextMultiline("Caractère", &data.billy.caractere);
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
2022-01-24 20:51:25 +01:00
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
{
|
|
|
|
ImGui::BeginChild("habilete", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true);
|
|
|
|
ImGui::Text("Habileté");
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
2022-01-17 19:57:00 +01:00
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
{
|
2022-01-24 20:51:25 +01:00
|
|
|
ImGui::BeginChild("adresse", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true);
|
|
|
|
ImGui::Text("Adresse");
|
|
|
|
ImGui::Text("Bottom pane1");
|
|
|
|
ImGui::Text("Bottom pane2");
|
|
|
|
ImGui::Text("Bottom pane3");
|
|
|
|
ImGui::Text("Bottom pane4");
|
2022-01-17 19:57:00 +01:00
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-01-24 20:51:25 +01:00
|
|
|
ImGui::BeginChild("endurance", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true);
|
|
|
|
ImGui::Text("Endurance");
|
2022-01-17 19:57:00 +01:00
|
|
|
ImGui::Text("Bottom pane1");
|
|
|
|
ImGui::Text("Bottom pane2");
|
|
|
|
ImGui::Text("Bottom pane3");
|
|
|
|
ImGui::Text("Bottom pane4");
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
2022-01-24 20:51:25 +01:00
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
{
|
|
|
|
ImGui::BeginChild("chance", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true);
|
|
|
|
ImGui::Text("Chance");
|
|
|
|
ImGui::Text("Bottom pane1");
|
|
|
|
ImGui::Text("Bottom pane2");
|
|
|
|
ImGui::Text("Bottom pane3");
|
|
|
|
ImGui::Text("Bottom pane4");
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
|
|
|
ImGui::EndGroup();
|
|
|
|
ImGui::SameLine();
|
|
|
|
{
|
|
|
|
ImGui::BeginChild("stats secondaire", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.4f), true);
|
|
|
|
ImGui::Text("STAT. SECONDAIRES");
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
2022-01-09 00:43:33 +01:00
|
|
|
|
|
|
|
ImGui::End();
|
|
|
|
|
2022-01-20 22:30:14 +01:00
|
|
|
controller.control_menu();
|
|
|
|
|
2022-01-09 00:43:33 +01:00
|
|
|
ImGui::Render();
|
|
|
|
}
|
|
|
|
}
|
2022-01-08 21:57:17 +01:00
|
|
|
|
2022-01-09 00:43:33 +01:00
|
|
|
void gui::Gui::render_gpu() const {
|
|
|
|
if (initialized) {
|
2022-01-17 23:36:12 +01:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
2022-01-09 00:43:33 +01:00
|
|
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
|
|
}
|
2022-01-08 21:57:17 +01:00
|
|
|
}
|