made script to copy imgui files to src
This commit is contained in:
78
src/main.cpp
78
src/main.cpp
@@ -15,6 +15,7 @@
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_glfw.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include "imgui_internal.h"
|
||||
#include "InputManager.h"
|
||||
#include "stb_image.h"
|
||||
|
||||
@@ -43,6 +44,8 @@ FreeCamera gCamera {};
|
||||
|
||||
Scene gScene{};
|
||||
|
||||
bool gUiFirstRender = true;
|
||||
|
||||
void glfw_error_callback(int error, const char* description);
|
||||
void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||
void glfw_framebuffer_size_callback(GLFWwindow* window, int width, int height);
|
||||
@@ -175,6 +178,9 @@ void load_imgui() {
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||
|
||||
ImGui::StyleColorsDark();
|
||||
ImGui_ImplGlfw_InitForOpenGL(gWindow, true);
|
||||
ImGui_ImplOpenGL3_Init("#version 330");
|
||||
@@ -233,10 +239,10 @@ void loop() {
|
||||
glfwPollEvents();
|
||||
|
||||
// check inputs
|
||||
if (InputManager::check_action_performed("exit_application")) {
|
||||
/*if (InputManager::check_action_performed("exit_application")) {
|
||||
glfwSetWindowShouldClose(gWindow, true);
|
||||
continue;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (InputManager::check_action_performed("move_forward")) {
|
||||
gCamera.move(FORWARD, .05);
|
||||
@@ -291,25 +297,63 @@ void draw_ui() {
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
{
|
||||
if (ImGui::Begin("Scene")) {
|
||||
ImGui::Text("Scene");
|
||||
const auto root = gScene.get_root();
|
||||
auto entity = gScene.fetch_component<Components::Relationship>(root).first_child;
|
||||
while (entity != entt::null) {
|
||||
const auto&[name] = gScene.fetch_component<Components::Tag>(entity);
|
||||
std::string text = fmt::format(" {0}", name);
|
||||
ImGui::Text((char*)text.data());
|
||||
entity = gScene.fetch_component<Components::Relationship>(entity).next_sibling;
|
||||
}
|
||||
ImGui::End();
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(viewport->Pos);
|
||||
ImGui::SetNextWindowSize(viewport->Size);
|
||||
ImGui::SetNextWindowViewport(viewport->ID);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
|
||||
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
|
||||
|
||||
ImGui::Begin("b_engine dockspace", nullptr, window_flags);
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
ImGuiID dockspace_id = ImGui::GetID("bengine_dockspace");
|
||||
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_None);
|
||||
|
||||
if (gUiFirstRender) {
|
||||
gUiFirstRender = false;
|
||||
|
||||
ImGui::DockBuilderRemoveNode(dockspace_id); // Clear any previous layout
|
||||
ImGui::DockBuilderAddNode(dockspace_id, ImGuiDockNodeFlags_DockSpace);
|
||||
ImGui::DockBuilderSetNodeSize(dockspace_id, viewport->Size);
|
||||
|
||||
ImGuiID dock_main_id = dockspace_id; // The center remains for the game view
|
||||
|
||||
const ImGuiID dock_id_left =
|
||||
ImGui::DockBuilderSplitNode(dock_main_id, ImGuiDir_Left, 0.2f, nullptr, &dock_main_id);
|
||||
const ImGuiID dock_id_right =
|
||||
ImGui::DockBuilderSplitNode(dock_main_id, ImGuiDir_Right, 0.25f, nullptr, &dock_main_id);
|
||||
|
||||
// Assign your windows to these specific dock IDs
|
||||
ImGui::DockBuilderDockWindow("Hierarchy", dock_id_left);
|
||||
ImGui::DockBuilderDockWindow("Inspector", dock_id_right);
|
||||
ImGui::DockBuilderDockWindow("Scene", dock_main_id);
|
||||
|
||||
ImGui::DockBuilderFinish(dockspace_id);
|
||||
}
|
||||
|
||||
ImGui::Begin("Hierarchy");
|
||||
ImGui::Text("List of GameObjects...");
|
||||
ImGui::End();
|
||||
|
||||
ImGui::Begin("Inspector");
|
||||
ImGui::Text("Component Properties...");
|
||||
ImGui::End();
|
||||
|
||||
ImGui::Begin("Scene");
|
||||
ImGui::Text("This is where your 3D view goes!");
|
||||
ImGui::End();
|
||||
|
||||
if (ImGui::BeginMainMenuBar()) {
|
||||
if (ImGui::BeginMenu("File")) {
|
||||
if (ImGui::MenuItem("New Scene", "Ctrl+N")) {
|
||||
if (ImGui::MenuItem("New Scene")) {
|
||||
/* Handle New File logic */
|
||||
}
|
||||
if (ImGui::MenuItem("Open Scene", "Ctrl+O")) {
|
||||
if (ImGui::MenuItem("Open Scene")) {
|
||||
/* Handle Open logic */
|
||||
}
|
||||
ImGui::Separator(); // Adds a visual line between sections
|
||||
@@ -317,7 +361,7 @@ void draw_ui() {
|
||||
/* Handle Save logic */
|
||||
}
|
||||
if (ImGui::MenuItem("Exit", "Alt+F4")) {
|
||||
/* Handle Exit logic */
|
||||
glfwSetWindowShouldClose(gWindow, true);
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
@@ -331,6 +375,8 @@ void draw_ui() {
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
ImGui::Render();
|
||||
}
|
||||
Reference in New Issue
Block a user