|
|
|
|
/******************************************************************************
|
|
|
|
|
* File - component_guis.cpp
|
|
|
|
|
* Author - Joey Pollack
|
|
|
|
|
* Date - 2022/06/01 (y/m/d)
|
|
|
|
|
* Mod Date - 2022/06/01 (y/m/d)
|
|
|
|
|
* Description - Functions to render component editing GUIs
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "component_guis.h"
|
|
|
|
|
#include <editor/editor.h>
|
|
|
|
|
#include <utils/logger.h>
|
|
|
|
|
#include <gui/imgui_ext.h>
|
|
|
|
|
#include <dearimgui/imgui.h>
|
|
|
|
|
#include <dearimgui/imgui_internal.h>
|
|
|
|
|
|
|
|
|
|
namespace lunarium { namespace editor
|
|
|
|
|
{
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
// COMMON SECTIONS
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
static void DrawTitle(std::string title)
|
|
|
|
|
{
|
|
|
|
|
ImVec2 top_left(ImGui::GetWindowPos().x, ImGui::GetCursorScreenPos().y - ImGui::GetStyle().FramePadding.y);
|
|
|
|
|
ImVec2 bot_right(top_left.x + ImGui::GetWindowSize().x, ImGui::GetCursorScreenPos().y + ImGui::GetFrameHeight());
|
|
|
|
|
//ImU32 color = ImGui::ColorConvertFloat4ToU32(ImVec4(0.1f, 0.3f, 0.8f, 1.0f));
|
|
|
|
|
ImU32 color = ImGui::ColorConvertFloat4ToU32(ImVec4(0.3f, 0.3f, 0.3f, 1.0f));
|
|
|
|
|
ImGui::GetWindowDrawList()->AddRectFilled(top_left, bot_right, color);
|
|
|
|
|
ImGuiExt::TextCentered(title.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompGui::RenderTagComp(TagComponent& comp)
|
|
|
|
|
{
|
|
|
|
|
DrawTitle("Tag Component");
|
|
|
|
|
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(3.0f, ImGui::GetStyle().ItemSpacing.y));
|
|
|
|
|
const int BUFFER_SIZE = 256;
|
|
|
|
|
static char buffer[BUFFER_SIZE] = "";
|
|
|
|
|
ImGui::Text("Tag Info");
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
strcpy(buffer, comp.Info.c_str());
|
|
|
|
|
ImGui::InputText("##Tag", buffer, BUFFER_SIZE);
|
|
|
|
|
comp.Info = buffer;
|
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// This code taken from the Hazel engine
|
|
|
|
|
/// https://github.com/TheCherno/Hazel/blob/master/Hazelnut/src/Panels/SceneHierarchyPanel.cpp
|
|
|
|
|
void CompGui::RenderTransformComp(TransformComponent& comp)
|
|
|
|
|
{
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(ImGui::GetStyle().ItemSpacing.x, ImGui::GetStyle().ItemSpacing.y + 10.0f));
|
|
|
|
|
DrawTitle("Transform Component");
|
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
|
|
ImGuiExt::Vec2Control("Translation", comp.Position, 0.0f, 85.0f);
|
|
|
|
|
glm::vec3 rotation = glm::degrees(comp.Rotation);
|
|
|
|
|
//ImGuiExt::Vec3Control("Rotation", rotation, 0.0f, 85.0f);
|
|
|
|
|
ImGuiExt::FloatControl("Rotation", rotation.z, 0.0f, 85.0f);
|
|
|
|
|
comp.Rotation = glm::radians(rotation);
|
|
|
|
|
ImGuiExt::Vec2Control("Scale", comp.Scale, 1.0f, 85.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CompGui::RenderVelocityComp(VelocityComponent& comp)
|
|
|
|
|
{
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(ImGui::GetStyle().ItemSpacing.x, ImGui::GetStyle().ItemSpacing.y + 10.0f));
|
|
|
|
|
DrawTitle("Velocity Component");
|
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
|
|
ImGuiExt::Vec2Control("Velocity", comp.Velocity, 0.0f, 85.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CompGui::RenderCameraComp(CameraComponent& comp)
|
|
|
|
|
{
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(ImGui::GetStyle().ItemSpacing.x, ImGui::GetStyle().ItemSpacing.y + 10.0f));
|
|
|
|
|
DrawTitle("Camera Component");
|
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
|
|
glm::vec3 pos = comp.Camera.GetPosition();
|
|
|
|
|
if (ImGuiExt::Vec2Control("Position", pos))
|
|
|
|
|
{
|
|
|
|
|
comp.Camera.SetPosition(pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float rot = comp.Camera.GetRotation();
|
|
|
|
|
if (ImGuiExt::FloatControl("Rotation", rot, 0.0f, 85.0f))
|
|
|
|
|
{
|
|
|
|
|
comp.Camera.SetRotation(rot);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CompGui::RenderBlockOutComp(BlockOutComponent& comp)
|
|
|
|
|
{
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(ImGui::GetStyle().ItemSpacing.x, ImGui::GetStyle().ItemSpacing.y + 10.0f));
|
|
|
|
|
DrawTitle("Block Out Component");
|
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
|
|
ImGui::Text("Block Color: ");
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::ColorEdit4("##BlockOut Color", &comp.Color.x, ImGuiColorEditFlags_DisplayRGB);
|
|
|
|
|
|
|
|
|
|
glm::vec3 _size = {comp.Size.x, comp.Size.y, 0.0f };
|
|
|
|
|
if (ImGuiExt::Vec2Control("Size", _size, 1.0f, 85.0f))
|
|
|
|
|
{
|
|
|
|
|
comp.Size.x = _size.x;
|
|
|
|
|
comp.Size.y = _size.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::Text("Render Layer: ");
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::InputInt("##Render Layer", &comp.RenderLayer, 1, 10);
|
|
|
|
|
}
|
|
|
|
|
}}
|