2023-05-08 20:07:29 +00:00
|
|
|
#pragma once
|
|
|
|
#include <iostream>
|
|
|
|
#include <mini/ini.h>
|
2023-05-11 18:27:07 +00:00
|
|
|
#include <nfd.h>
|
2023-06-05 15:47:40 +00:00
|
|
|
#include <ImGuizmo.h>
|
2023-05-11 18:27:07 +00:00
|
|
|
|
2023-06-05 15:47:40 +00:00
|
|
|
#include "Inspector.h"
|
2023-05-08 20:07:29 +00:00
|
|
|
#include "Console.h"
|
2023-05-11 18:27:07 +00:00
|
|
|
#include "IconsMaterialDesign.h"
|
2023-06-05 15:47:40 +00:00
|
|
|
#include "Project.h"
|
2023-05-12 20:38:10 +00:00
|
|
|
#include "EditorCamera.h"
|
2023-05-08 20:07:29 +00:00
|
|
|
using namespace YoggieEngine;
|
2023-05-16 18:18:26 +00:00
|
|
|
|
2023-05-16 19:59:10 +00:00
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
class EditorLayer : public Layer {
|
|
|
|
|
2023-05-16 19:59:10 +00:00
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
public:
|
2023-05-17 17:41:48 +00:00
|
|
|
EditorLayer() :
|
2023-05-08 20:07:29 +00:00
|
|
|
Layer(),
|
2023-05-12 20:38:10 +00:00
|
|
|
inspector(Selected),
|
|
|
|
scene(),
|
|
|
|
renderer()
|
2023-05-08 20:07:29 +00:00
|
|
|
{
|
2023-05-12 20:38:10 +00:00
|
|
|
|
2023-06-05 15:47:40 +00:00
|
|
|
Logo.Load("rsc/Yoggie.png");
|
2023-05-12 20:38:10 +00:00
|
|
|
spdlog::info("{0}", project.GetProjectDirectory().string());
|
2023-06-05 15:47:40 +00:00
|
|
|
Selected = YoggieEngine::Entity((entt::entity)-1, &scene);
|
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OnStartup() override {
|
|
|
|
std::string path = (std::filesystem::current_path()).string();
|
|
|
|
project.setProjectDirectory(path);
|
|
|
|
LoadLastOrEmptyProject();
|
|
|
|
//Console console = Console();
|
2023-05-11 18:27:07 +00:00
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
}
|
2023-05-16 18:18:26 +00:00
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
void OnUpdate() override {
|
|
|
|
scene.Update();
|
2023-05-12 20:38:10 +00:00
|
|
|
renderer.Render(scene, *camera);
|
2023-05-08 20:07:29 +00:00
|
|
|
}
|
|
|
|
|
2023-05-16 19:59:10 +00:00
|
|
|
|
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
void OnUI() override {
|
2023-05-11 18:27:07 +00:00
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { ImGui::GetWindowWidth(), 7 });
|
|
|
|
ImGui::BeginMainMenuBar();
|
|
|
|
int scaleFactor = 30;
|
|
|
|
ImGui::Image((ImTextureID)Logo.GetID(), { Logo.getSize().x / scaleFactor , Logo.getSize().y / scaleFactor });
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
if (ImGui::BeginMenu("App")) {
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Load Project"))
|
|
|
|
{
|
|
|
|
nfdresult_t result = NFD_OpenDialog({ "yproj" }, NULL, &path);
|
|
|
|
switch (result) {
|
|
|
|
case(NFD_OKAY):
|
|
|
|
//Project::LoadProject(path, project);
|
|
|
|
//AssetRegistry::setAssetPath(project.GetProjectDirectory());
|
|
|
|
//AssetRegistry::BuildAssetView();
|
|
|
|
break;
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
spdlog::error("NFD_Error: {0}", NFD_GetError());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Save project as...")) {
|
|
|
|
nfdresult_t result = NFD_SaveDialog({ "yproj" }, NULL, &path);
|
|
|
|
switch (result) {
|
|
|
|
case(NFD_OKAY):
|
|
|
|
spdlog::info("Save as: {0}", path);
|
|
|
|
//Project::SaveProject(path, project);
|
|
|
|
break;
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
spdlog::error("NFD_Error: {0}", NFD_GetError());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndMenu();
|
2023-05-08 20:07:29 +00:00
|
|
|
}
|
2023-05-11 18:27:07 +00:00
|
|
|
if (ImGui::BeginMenu("Scene")) {
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Save scene"))
|
|
|
|
{
|
|
|
|
nfdresult_t result = NFD_SaveDialog({ "yscene" }, NULL, &path);
|
|
|
|
switch (result) {
|
|
|
|
case(NFD_OKAY):
|
|
|
|
//SaveScene(path, scene);
|
|
|
|
|
|
|
|
//project.AddScene(scene);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Load scene"))
|
|
|
|
{
|
|
|
|
auto result = NFD_OpenDialog({ "yscene" }, NULL, &path);
|
|
|
|
switch (result) {
|
|
|
|
case (NFD_OKAY):
|
|
|
|
//LoadScene(path, scene);
|
|
|
|
break;
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Add Entity"))
|
|
|
|
{
|
|
|
|
//scene.AddEntity("New Entity");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Import Model"))
|
|
|
|
{
|
|
|
|
auto result = NFD_OpenDialog("obj,fbx,gltf", NULL, &path);
|
|
|
|
switch (result) {
|
|
|
|
case(NFD_OKAY):
|
|
|
|
// Import Model
|
2023-05-16 18:18:26 +00:00
|
|
|
/*
|
2023-05-11 18:27:07 +00:00
|
|
|
AssetRegistry::LoadFromSource(
|
|
|
|
path,
|
|
|
|
"build/Debug/Assets"//project.get()->GetProjectDirectory() / "Assets"
|
|
|
|
);
|
2023-05-16 18:18:26 +00:00
|
|
|
*/
|
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
break;
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Import MeshAsset (temp)"))
|
|
|
|
{
|
|
|
|
auto result = NFD_OpenDialog("mesh", NULL, &path);
|
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
case(NFD_OKAY):
|
|
|
|
{
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
spdlog::debug("User cancelled action");
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
spdlog::warn("Something went wrong!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::SameLine(ImGui::GetWindowWidth() / 4 * 3);
|
|
|
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.3f, 0.3f, 0.3f, 1.0f));
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
|
|
|
ImGui::Button(ICON_MD_ROCKET_LAUNCH "Project");
|
|
|
|
|
|
|
|
ImGui::SameLine(ImGui::GetWindowWidth() - 120);
|
|
|
|
|
|
|
|
ImGui::PopStyleColor(1);
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
ImGui::EndMainMenuBar();
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::Begin("RuntimeControls");
|
2023-05-13 16:10:24 +00:00
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::Text(ICON_MD_TRANSFORM);
|
|
|
|
|
|
|
|
auto spacing = 10;
|
|
|
|
float buttonWidth = 75.0f;
|
|
|
|
float buttonHeight = 30;
|
|
|
|
float ColorIntensity = 0.5f;
|
|
|
|
float ColorIntensityHovered = 0.75;
|
|
|
|
float ColorIntensityActive = 0.85;
|
|
|
|
float yPadding = 6.f;
|
|
|
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2{0, yPadding });
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.0f,ColorIntensity ,0.0f ,1.0f });
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.0f,ColorIntensityHovered ,0.0f ,1.0f });
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.0f,ColorIntensityActive ,0.0f ,1.0f });
|
|
|
|
ImGui::SameLine(0, spacing);
|
|
|
|
if (ImGui::Button("Translate", { buttonWidth,buttonHeight }))
|
|
|
|
activeOperation = ImGuizmo::OPERATION::TRANSLATE;
|
|
|
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2{ 0, yPadding });
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ ColorIntensity, 0.0f ,0.0f ,1.0f });
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ ColorIntensityHovered, 0.0f ,0.0f ,1.0f });
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ ColorIntensityActive, 0.0f ,0.0f ,1.0f });
|
|
|
|
ImGui::SameLine(0, spacing);
|
|
|
|
if (ImGui::Button("Rotate", { buttonWidth,buttonHeight }))
|
|
|
|
activeOperation = ImGuizmo::OPERATION::ROTATE;
|
|
|
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2{ 0, yPadding });
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.0f, 0.0f ,ColorIntensity ,1.0f });
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.0f, 0.0f ,ColorIntensityHovered ,1.0f });
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.0f, 0.0f ,ColorIntensityActive ,1.0f });
|
|
|
|
ImGui::SameLine(0, spacing);
|
|
|
|
if (ImGui::Button("Scale", { buttonWidth,buttonHeight }))
|
|
|
|
activeOperation = ImGuizmo::OPERATION::SCALE;
|
|
|
|
|
|
|
|
ImGui::PopStyleColor(9);
|
|
|
|
ImGui::PopStyleVar(3);
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
ImGui::SameLine((ImGui::GetWindowContentRegionMax().x / 2) - (90));
|
|
|
|
auto color = ImVec4{ 0.001 * 12 , 0.001 * 201 , 0.001 * 69, 1.0f };
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, color);
|
|
|
|
const float strengthIncrease = 1.5f;
|
|
|
|
ImGui::PushStyleColor(
|
|
|
|
ImGuiCol_ButtonHovered,
|
|
|
|
ImVec4{
|
|
|
|
color.x * strengthIncrease,
|
|
|
|
color.y * strengthIncrease,
|
|
|
|
color.z * strengthIncrease,
|
|
|
|
color.w
|
|
|
|
}
|
|
|
|
);
|
|
|
|
if (ImGui::Button(ICON_MD_PLAY_ARROW, { 90,25 })) {
|
|
|
|
// Play game
|
|
|
|
}
|
|
|
|
ImGui::PopStyleColor(2);
|
|
|
|
ImGui::SameLine();
|
|
|
|
color = ImVec4{ 0.001 * 14, 0.001 * 157, 0.001 * 201, 1.0f };
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, color);
|
|
|
|
|
|
|
|
ImGui::PushStyleColor(
|
|
|
|
ImGuiCol_ButtonHovered,
|
|
|
|
ImVec4{
|
|
|
|
color.x * strengthIncrease,
|
|
|
|
color.y * strengthIncrease,
|
|
|
|
color.z * strengthIncrease,
|
|
|
|
color.w
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ImGui::Button(ICON_MD_ELECTRIC_BOLT, { 90,25 })) {
|
|
|
|
// Simulate physics
|
|
|
|
}
|
|
|
|
ImGui::PopStyleColor(2);
|
|
|
|
ImGui::End();
|
|
|
|
|
|
|
|
|
2023-05-12 20:38:10 +00:00
|
|
|
unsigned int viewportWindowFlags = ImGuiWindowFlags_NoTitleBar
|
|
|
|
| ImGuiWindowFlags_NoDecoration
|
|
|
|
| ImGuiWindowFlags_NoScrollbar
|
|
|
|
| ImGuiWindowFlags_NoMove
|
|
|
|
| ImGuiWindowFlags_NoCollapse;
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 0,0 });
|
|
|
|
ImGui::Begin("SceneView",nullptr,viewportWindowFlags);
|
2023-05-16 18:18:26 +00:00
|
|
|
// spdlog::info("{0}x{1}", ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
2023-05-16 19:59:10 +00:00
|
|
|
SceneisFocused = ImGui::IsWindowFocused() || ImGui::IsWindowHovered();
|
2023-05-12 20:38:10 +00:00
|
|
|
ImGui::Image((ImTextureID)(intptr_t)renderer.getCurrentFrameBuffer().GetColourAttachment(),
|
2023-06-05 15:47:40 +00:00
|
|
|
ImVec2{(float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight()});
|
2023-05-11 18:27:07 +00:00
|
|
|
|
2023-05-13 16:10:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
//ImGuizmo::ViewManipulate(glm::value_ptr(cameraView), 1, ImGui::GetWindowPos(), { 90,90 }, 0x22CCCCCCC);
|
2023-05-11 18:27:07 +00:00
|
|
|
|
|
|
|
|
2023-05-13 16:10:24 +00:00
|
|
|
if(Selected.isValid()){
|
|
|
|
|
|
|
|
|
|
|
|
ImGuizmo::SetOrthographic(false);
|
|
|
|
ImGuizmo::SetDrawlist();
|
|
|
|
|
|
|
|
ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
2023-05-11 18:27:07 +00:00
|
|
|
|
2023-05-16 18:18:26 +00:00
|
|
|
const auto& ProjMatrix = camera->getProjection(ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
|
|
|
const glm::mat4& viewMatrix = glm::inverse(camera->getTransform());
|
2023-05-13 16:10:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
auto& tc = Selected.GetComponent<YoggieEngine::TransformComponent>();
|
2023-05-13 19:32:55 +00:00
|
|
|
auto transform = tc.GetTransform();
|
2023-05-16 18:18:26 +00:00
|
|
|
ImGuizmo::Manipulate(
|
|
|
|
glm::value_ptr(viewMatrix),
|
|
|
|
glm::value_ptr(ProjMatrix),
|
|
|
|
activeOperation, ImGuizmo::LOCAL, glm::value_ptr(transform));
|
|
|
|
if (ImGuizmo::IsUsing())
|
|
|
|
{
|
2023-05-13 16:10:24 +00:00
|
|
|
tc.Decompose(transform);
|
2023-05-11 18:27:07 +00:00
|
|
|
|
2023-05-16 18:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::End();
|
2023-05-12 20:38:10 +00:00
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
ImGui::Begin("EditorCamera");
|
|
|
|
|
2023-05-16 18:18:26 +00:00
|
|
|
ImGui::SliderFloat3("position", glm::value_ptr(camera->Position), -50, 50);
|
2023-05-12 20:38:10 +00:00
|
|
|
ImGui::End();
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
|
|
|
|
ImGui::Begin(ICON_MD_MENU "SceneExplorer",nullptr);
|
|
|
|
scene.getReg().each([&](entt::entity enttNumber) {
|
|
|
|
YoggieEngine::Entity entity = YoggieEngine::Entity(enttNumber, &scene);
|
|
|
|
auto id = entity.GetComponent<YoggieEngine::IdentifierComponent>();
|
|
|
|
if (ImGui::Selectable(id.name.c_str(), entity == Selected)) {
|
|
|
|
Selected = YoggieEngine::Entity(enttNumber, &scene);
|
2023-05-12 20:38:10 +00:00
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
}
|
|
|
|
});
|
2023-05-12 20:38:10 +00:00
|
|
|
|
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
ImGui::End();
|
2023-05-08 20:07:29 +00:00
|
|
|
|
2023-06-05 15:47:40 +00:00
|
|
|
/*
|
|
|
|
{
|
|
|
|
ImGui::Begin("Asset", nullptr);
|
|
|
|
|
|
|
|
const char* hidden_extensions[]{
|
|
|
|
".exe",
|
|
|
|
".pdb",
|
|
|
|
".idb",
|
|
|
|
".dll",
|
|
|
|
".ini"
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
std::vector <Asset> files = std::vector<Asset>();
|
2023-05-11 18:27:07 +00:00
|
|
|
|
2023-06-05 15:47:40 +00:00
|
|
|
int iconSize = 60;
|
|
|
|
int maxColumns = 3;
|
2023-05-11 18:27:07 +00:00
|
|
|
|
2023-06-05 15:47:40 +00:00
|
|
|
YoggieEngine::Texture folderIcon;
|
|
|
|
YoggieEngine::Texture assetIcon;
|
2023-05-08 20:07:29 +00:00
|
|
|
|
2023-06-05 15:47:40 +00:00
|
|
|
assetIcon = YoggieEngine::Texture("rsc/AssetIcon.png");
|
2023-05-08 20:07:29 +00:00
|
|
|
|
2023-06-05 15:47:40 +00:00
|
|
|
|
|
|
|
ImGui::DragInt("IconSize", &iconSize, 1, 30, 90);
|
|
|
|
ImGui::DragInt("Max. Columns", &maxColumns, 1, 1, 6);
|
|
|
|
|
|
|
|
if (ImGui::BeginTable("##Resources", 3)) {
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.f, 0.f, 0.f));
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.f, 0.f, 0.f));
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.f, 1.f, 1.f, 0.2f));
|
|
|
|
|
|
|
|
int row = 0;
|
|
|
|
int column = 0;
|
|
|
|
for (auto& asset : files) {
|
|
|
|
if (column % 3 == 0) {
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
column = 0;
|
|
|
|
row++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::TableSetColumnIndex(column);
|
|
|
|
|
|
|
|
ImGui::ImageButton(
|
|
|
|
(ImTextureID)assetIcon.GetID(),
|
|
|
|
ImVec2{ (float)iconSize, (float)iconSize });
|
|
|
|
ImGui::Text(asset.GetName(), row);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
column++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::PopStyleColor(3);
|
|
|
|
ImGui::EndTable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::End();
|
|
|
|
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
ImGui::ShowDemoWindow();
|
|
|
|
//ImGui::ShowMetricsWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnCreate() override {
|
2023-05-09 17:36:34 +00:00
|
|
|
spdlog::info(" Layer Create!" );
|
2023-05-08 20:07:29 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnDestroy() override {
|
2023-05-09 17:36:34 +00:00
|
|
|
spdlog::info( " Layer Destroy!" );
|
2023-05-11 18:27:07 +00:00
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-05 15:47:40 +00:00
|
|
|
|
|
|
|
bool OnKey(int key, int mode) override {
|
|
|
|
float movement_speed = 0.10f;
|
|
|
|
|
|
|
|
if (SceneisFocused) {
|
|
|
|
if (key == YOGGIE_KEY_UP)
|
|
|
|
camera->Rotation.x += movement_speed;
|
|
|
|
|
|
|
|
if (key == YOGGIE_KEY_DOWN)
|
|
|
|
camera->Rotation.x -= movement_speed;
|
|
|
|
|
|
|
|
if (key == YOGGIE_KEY_LEFT)
|
|
|
|
camera->Rotation.y += movement_speed;
|
|
|
|
|
|
|
|
if (key == YOGGIE_KEY_RIGHT)
|
|
|
|
camera->Rotation.y -= movement_speed;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (key == YOGGIE_KEY_A)
|
|
|
|
camera->Position += glm::vec3(1.0f, 0.0f, 0.0f) * movement_speed;
|
|
|
|
|
|
|
|
if (key == YOGGIE_KEY_S)
|
|
|
|
camera->Position += glm::vec3(0.0f, 0.0f, -1.0f) * movement_speed;
|
|
|
|
|
|
|
|
if (key == YOGGIE_KEY_D)
|
|
|
|
camera->Position -= glm::vec3(1.0f, 0.0f, 0.0f) * movement_speed;
|
|
|
|
|
|
|
|
if (key == GLFW_KEY_W)
|
|
|
|
camera->Position -= glm::vec3(0.0f, 0.0f, -1.0f) * movement_speed;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
private:
|
|
|
|
Inspector inspector;
|
2023-06-05 15:47:40 +00:00
|
|
|
Renderer renderer;
|
|
|
|
|
|
|
|
EditorCamera* camera = new EditorCamera();
|
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
|
|
|
|
Project project;
|
|
|
|
Scene scene;
|
2023-05-16 19:59:10 +00:00
|
|
|
|
2023-06-05 15:47:40 +00:00
|
|
|
bool SimulatePhysics = true;
|
|
|
|
bool SceneisFocused = false;
|
2023-05-16 19:59:10 +00:00
|
|
|
|
2023-06-05 15:47:40 +00:00
|
|
|
YoggieEngine::Entity Selected;
|
|
|
|
ImGuizmo::OPERATION activeOperation = ImGuizmo::OPERATION::TRANSLATE;
|
2023-05-08 20:07:29 +00:00
|
|
|
|
2023-06-05 15:47:40 +00:00
|
|
|
char* path = nullptr;
|
|
|
|
Texture Logo;
|
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
void LoadLastOrEmptyProject() {
|
|
|
|
// Check if there is a last known loaded project and
|
|
|
|
// load that one .
|
|
|
|
|
|
|
|
// Otherwise load no project..
|
|
|
|
// OR
|
|
|
|
// Load an empty project.
|
|
|
|
mINI::INIStructure ini;
|
|
|
|
|
|
|
|
if (std::filesystem::exists("build\\Debug\\Editor.ini"))
|
|
|
|
{
|
|
|
|
mINI::INIFile file("build\\Debug\\Editor.ini");
|
|
|
|
file.read(ini);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spdlog::debug("Could not find an `Editor.ini` file.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ini["editor"]["openlastproject"] == "TRUE")
|
|
|
|
{
|
|
|
|
|
|
|
|
Project::LoadProject(ini["cache"]["project"], project);
|
2023-06-05 15:47:40 +00:00
|
|
|
///LoadScene(ini["cache"]["scene"], scene);
|
2023-05-08 20:07:29 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spdlog::debug("Starting without a project. Please create one.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|