Updated Editor architecture
- Everything editor related will be happening in EditorLayer - Added an icon font - Added proper icon - Added project badge in main menu bar - Texture class now keeps track of the texture width and height
This commit is contained in:
parent
c82398205a
commit
550c1b6e5b
BIN
Editor/rsc/Yoggie.png
(Stored with Git LFS)
Normal file
BIN
Editor/rsc/Yoggie.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -38,6 +38,8 @@ public:
|
||||
asset.setFilPath(filepath.string());
|
||||
spdlog::info("Created asset: {0}", asset.GetName());
|
||||
files.push_back(asset);
|
||||
|
||||
assetIcon = YoggieEngine::Texture("rsc/AssetIcon.png");
|
||||
|
||||
}
|
||||
|
||||
@ -45,7 +47,6 @@ public:
|
||||
|
||||
void Draw() override {
|
||||
|
||||
//assetIcon = YoggieEngine::Texture("rsc/AssetIcon.png");
|
||||
ImGui::DragInt("IconSize", &iconSize, 1, 30, 90);
|
||||
ImGui::DragInt("Maximum Columns", &maxColumns, 1, 1, 6);
|
||||
if (ImGui::BeginTable("##resources", 3))
|
||||
@ -81,8 +82,7 @@ public:
|
||||
|
||||
ImGui::PopStyleColor(3);
|
||||
ImGui::EndTable();
|
||||
const GLuint textures[2]{ assetIcon.GetID(), folderIcon.GetID() };
|
||||
glDeleteTextures(2, textures);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,19 +4,19 @@
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <nfd.h>
|
||||
|
||||
#include "AssetManagement/SceneSerializer.h"
|
||||
#include "AssetManagement/AssetRegistry.h"
|
||||
#include "Views/Viewport.h"
|
||||
#include "PropertyPanels/SceneExplorer.h"
|
||||
#include "AssetManagement/AssetFinder.h"
|
||||
#include "MainMenuBar.h"
|
||||
#include "PropertyPanels/Inspector.h"
|
||||
#include "Project/ProjectInfo.h"
|
||||
#include "Runtime/RuntimeControls.h"
|
||||
#include "AssetManagement/uuid.h"
|
||||
#include "Project/Settings.h"
|
||||
#include "Console.h"
|
||||
#include "AssetManagement/AssetLoaders/ModelLoader.h"
|
||||
#include "IconsMaterialDesign.h"
|
||||
#include "Project/Project.h"
|
||||
#include <ImGuizmo.h>
|
||||
|
||||
using namespace YoggieEngine;
|
||||
class EditorLayer : public Layer {
|
||||
@ -24,9 +24,6 @@ class EditorLayer : public Layer {
|
||||
public:
|
||||
EditorLayer():
|
||||
Layer(),
|
||||
rc(),
|
||||
sceneview(scene, Selected),
|
||||
explorer(Selected, scene),
|
||||
inspector (Selected)
|
||||
{
|
||||
}
|
||||
@ -45,10 +42,12 @@ public:
|
||||
auto latern = modelLoader.LoadAsset(std::filesystem::path("build/debug/Models/Latern.gltf"));
|
||||
spdlog::info( "Loaded mesh: {0}" , latern.GetName() );
|
||||
|
||||
//ProjectInfo projectInfo(project);
|
||||
|
||||
//Settings settings = Settings();
|
||||
//Console console = Console();
|
||||
|
||||
Logo = Texture("rsc/Yoggie.png", true);
|
||||
|
||||
|
||||
|
||||
Selected = YoggieEngine::Entity((entt::entity)-1, &scene);
|
||||
@ -57,34 +56,260 @@ public:
|
||||
|
||||
void OnUpdate() override {
|
||||
scene.Update();
|
||||
|
||||
if (sceneview.isFocused) {
|
||||
/*
|
||||
* if (Sceneview.isFocused) {
|
||||
UpdateSceneCamera(sceneview);
|
||||
|
||||
spdlog::info( "Scene view in Focus!\r");
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void OnUI() override {
|
||||
{
|
||||
MainMenuBar menuBar = MainMenuBar();
|
||||
menuBar.ApplicationMenu(project);
|
||||
menuBar.SceneMenu(project, scene);
|
||||
menuBar.SelectMenu();
|
||||
menuBar.WindowMenu();
|
||||
menuBar.DebugMenu();
|
||||
menuBar.Help();
|
||||
|
||||
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();
|
||||
}
|
||||
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
|
||||
|
||||
AssetRegistry::LoadFromSource(
|
||||
path,
|
||||
"build/Debug/Assets"//project.get()->GetProjectDirectory() / "Assets"
|
||||
);
|
||||
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):
|
||||
{
|
||||
YoggieEngine::Mesh* importedMesh = AssetRegistry::LoadFromAssetFile(path);
|
||||
if (importedMesh != nullptr)
|
||||
{
|
||||
auto full_name = std::filesystem::path(path);
|
||||
// auto importedModel = scene.AddEntity(full_name.filename().u8string());
|
||||
// auto& rendererComponent = importedModel.AddComponent<YoggieEngine::Render3DComponent>();
|
||||
// rendererComponent.mesh = *importedMesh;
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case(NFD_CANCEL):
|
||||
spdlog::debug("User cancelled action");
|
||||
break;
|
||||
case(NFD_ERROR):
|
||||
spdlog::warn("Something went wrong!");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
//projectInfo.Update();
|
||||
sceneview.Update();
|
||||
rc.Update();
|
||||
explorer.Update();
|
||||
//settings.Update();
|
||||
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();
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.1f, 0.01f));
|
||||
if (ImGui::Button(ICON_MD_MINIMIZE)) { spdlog::info("Minimize"); }
|
||||
if (ImGui::Button(ICON_MD_MAXIMIZE)) { spdlog::info("Maximize"); }
|
||||
if (ImGui::Button(ICON_MD_CLOSE)) { spdlog::info("Quit"); }
|
||||
*/
|
||||
ImGui::PopStyleColor(1);
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
ImGui::EndMainMenuBar();
|
||||
|
||||
|
||||
ImGui::Begin("RuntimeControls");
|
||||
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();
|
||||
|
||||
|
||||
ImGui::Begin("SceneView");
|
||||
|
||||
//ImGui::Image((ImTextureID)gameScreen.GetID(), gameScreen.getSize());
|
||||
|
||||
ImGuizmo::Enable(true);
|
||||
ImGuizmo::SetOrthographic(false);
|
||||
ImGuizmo::SetDrawlist();
|
||||
|
||||
ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetContentRegionMax().x, ImGui::GetContentRegionMax().y);
|
||||
/*
|
||||
const auto& projection = camera.projection;
|
||||
glm::mat4& view = glm::mat4(1.0f);
|
||||
ImGuizmo::DrawGrid();
|
||||
ImGuizmo::ViewManipulate();
|
||||
|
||||
|
||||
if(selected != nullptr && selected->isValid()){
|
||||
auto& tc = selected->GetComponent<YoggieEngine::TransformComponent>();
|
||||
glm::mat4 transform = tc.GetTransform();
|
||||
|
||||
ImGuizmo::Manipulate();
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
ImGui::End();
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
ImGui::End();
|
||||
|
||||
inspector.Update();
|
||||
|
||||
|
||||
//settings.Update();
|
||||
//console.Update();
|
||||
|
||||
assetsView.Update();
|
||||
@ -101,15 +326,11 @@ public:
|
||||
|
||||
void OnDestroy() override {
|
||||
spdlog::info( " Layer Destroy!" );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
RuntimeControls rc;
|
||||
Viewport sceneview ;
|
||||
SceneExplorer explorer;
|
||||
Inspector inspector;
|
||||
AssetFinder assetsView;
|
||||
|
||||
@ -117,6 +338,9 @@ private:
|
||||
YoggieEngine::Entity Selected;
|
||||
Project project;
|
||||
Scene scene;
|
||||
char* path = nullptr;
|
||||
Texture Logo;
|
||||
|
||||
|
||||
void LoadLastOrEmptyProject() {
|
||||
// Check if there is a last known loaded project and
|
||||
@ -151,7 +375,7 @@ private:
|
||||
}
|
||||
|
||||
|
||||
void UpdateSceneCamera(Viewport& sceneview) {
|
||||
void UpdateSceneCamera() {
|
||||
const float movement_speed = 0.01f;
|
||||
static float lastX = 400, lastY = 300;
|
||||
const float sensitivity = 0.1;
|
||||
@ -204,7 +428,8 @@ private:
|
||||
|
||||
*/
|
||||
|
||||
EditorCamera& cam = sceneview.GetCamera();
|
||||
/*
|
||||
EditorCamera& cam = sceneview.GetCamera();
|
||||
|
||||
|
||||
|
||||
@ -223,6 +448,8 @@ private:
|
||||
|
||||
cam.Update();
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
2244
Editor/src/IconsMaterialDesign.h
Normal file
2244
Editor/src/IconsMaterialDesign.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,194 +0,0 @@
|
||||
#include "MainMenuBar.h"
|
||||
#include <nfd.h>
|
||||
#include "AssetManagement/AssetRegistry.h"
|
||||
|
||||
|
||||
|
||||
MainMenuBar::MainMenuBar()
|
||||
{
|
||||
ImGui::BeginMainMenuBar();
|
||||
}
|
||||
|
||||
void MainMenuBar::ApplicationMenu(Project& project) {
|
||||
|
||||
if (ImGui::BeginMenu("Application")) {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (ImGui::MenuItem("Preferences"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Exit"))
|
||||
{
|
||||
// TODO: Exit application
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void MainMenuBar::SceneMenu(Project& project, YoggieEngine::Scene& scene) {
|
||||
|
||||
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
|
||||
|
||||
AssetRegistry::LoadFromSource(
|
||||
path,
|
||||
"build/Debug/Assets"//project.get()->GetProjectDirectory() / "Assets"
|
||||
);
|
||||
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):
|
||||
{
|
||||
YoggieEngine::Mesh* importedMesh = AssetRegistry::LoadFromAssetFile(path);
|
||||
if (importedMesh != nullptr)
|
||||
{
|
||||
auto full_name = std::filesystem::path(path);
|
||||
auto importedModel = scene.AddEntity(full_name.filename().u8string());
|
||||
auto& rendererComponent = importedModel.AddComponent<YoggieEngine::Render3DComponent>();
|
||||
rendererComponent.mesh = *importedMesh;
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case(NFD_CANCEL):
|
||||
spdlog::debug("User cancelled action");
|
||||
break;
|
||||
case(NFD_ERROR):
|
||||
spdlog::warn("Something went wrong!");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void MainMenuBar::DebugMenu()
|
||||
{
|
||||
if (ImGui::BeginMenu("Debug")) {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void MainMenuBar::SelectMenu() {
|
||||
if (ImGui::BeginMenu("Select")) {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void MainMenuBar::WindowMenu() {
|
||||
if (ImGui::BeginMenu("Window")) {
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void MainMenuBar::Help() {
|
||||
if (ImGui::BeginMenu("Help")) {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
MainMenuBar::~MainMenuBar()
|
||||
{
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
#include <imgui.h>
|
||||
#include "AssetManagement/SceneSerializer.h"
|
||||
#include "../../YoggieEngine/src/Scene/Scene.h"
|
||||
#include "Project/Project.h"
|
||||
|
||||
|
||||
class MainMenuBar {
|
||||
|
||||
public:
|
||||
MainMenuBar();
|
||||
|
||||
void ApplicationMenu(Project& project);
|
||||
|
||||
void SceneMenu(Project& project, YoggieEngine::Scene& scene);
|
||||
|
||||
void DebugMenu();
|
||||
|
||||
void SelectMenu();
|
||||
|
||||
void WindowMenu();
|
||||
|
||||
void Help();
|
||||
|
||||
~MainMenuBar();
|
||||
|
||||
private:
|
||||
char* path = nullptr;
|
||||
|
||||
};
|
@ -1,7 +0,0 @@
|
||||
#include "ProjectInfo.h"
|
||||
|
||||
void ProjectInfo::Draw()
|
||||
{
|
||||
ImGui::Text("Project: %s", project.GetName().c_str());
|
||||
ImGui::Text("Directory: %s", project.GetProjectDirectory().u8string().c_str());
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
#include "../../YoggieEngine/src/YoggieEngine.h"
|
||||
#include "../EditorWindow.h"
|
||||
#include "Project.h"
|
||||
|
||||
class ProjectInfo : public EditorWindow {
|
||||
public:
|
||||
ProjectInfo(Project& project) : EditorWindow("Project Info"), project(project) {}
|
||||
|
||||
void Draw() override;
|
||||
|
||||
private:
|
||||
Project& project;
|
||||
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
#include "SceneExplorer.h"
|
||||
|
||||
void SceneExplorer::Draw()
|
||||
{
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
#include "../../YoggieEngine/src/YoggieEngine.h"
|
||||
#include "../EditorWindow.h"
|
||||
#include "../../src/Scene/Entity.h"
|
||||
|
||||
class SceneExplorer : public EditorWindow {
|
||||
public:
|
||||
SceneExplorer(YoggieEngine::Entity& selected, YoggieEngine::Scene& scene)
|
||||
: EditorWindow("SceneExplorer"), scene(scene), selected(selected)
|
||||
{}
|
||||
|
||||
void Draw() override;
|
||||
|
||||
|
||||
private:
|
||||
YoggieEngine::Entity& selected;
|
||||
YoggieEngine::Scene& scene;
|
||||
|
||||
|
||||
};
|
@ -1,27 +0,0 @@
|
||||
#include "RuntimeControls.h"
|
||||
|
||||
void RuntimeControls::Draw() {
|
||||
ImGui::SameLine((ImGui::GetWindowContentRegionMax().x / 2) - (numButtons * buttonSize.x));
|
||||
for (int i = 0; i < numButtons; i++) {
|
||||
ImVec4 color = button[i].Color;
|
||||
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(button[i].Name, buttonSize)) {
|
||||
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::SameLine();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
#pragma once
|
||||
#include "../../YoggieEngine/src/YoggieEngine.h"
|
||||
#include "../EditorWindow.h"
|
||||
|
||||
#define RuntimeControlWindowFlags (ImGuiWindowFlags_)(ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse)
|
||||
|
||||
struct ButtonInfo {
|
||||
const char* Name;
|
||||
ImVec4 Color;
|
||||
};
|
||||
|
||||
class RuntimeControls : public EditorWindow {
|
||||
public:
|
||||
RuntimeControls() : EditorWindow("RuntimeControls", RuntimeControlWindowFlags) {}
|
||||
|
||||
void Draw() override;
|
||||
|
||||
private:
|
||||
ImVec2 buttonSize = ImVec2{ 90 ,25 };
|
||||
unsigned int numButtons = 2;
|
||||
ButtonInfo button[2] = {
|
||||
{"Play" , ImVec4{ 0.001 * 12 , 0.001 * 201 , 0.001 * 69, 1.0f}},
|
||||
{"Simulate", ImVec4{ 0.001 * 14, 0.001 * 157, 0.001 * 201, 1.0f}}
|
||||
};
|
||||
|
||||
};
|
@ -1,61 +0,0 @@
|
||||
#include "Viewport.h"
|
||||
|
||||
Viewport::Viewport(YoggieEngine::Scene& scene, YoggieEngine::Entity& selected) :
|
||||
EditorWindow("SceneView"),
|
||||
renderer(YoggieEngine::RendererConfig{ 1200, 700, glm::vec3(0), true })
|
||||
{
|
||||
CurrentScene = &scene;
|
||||
this->selected = &selected;
|
||||
}
|
||||
|
||||
void Viewport::Draw() {
|
||||
|
||||
auto group = CurrentScene->getReg().view<YoggieEngine::TransformComponent, YoggieEngine::Render3DComponent>();
|
||||
group.each([&](auto enity, YoggieEngine::TransformComponent& t, YoggieEngine::Render3DComponent& renderComponent) {
|
||||
renderer.Submit(renderComponent, t);
|
||||
});
|
||||
|
||||
isFocused = ImGui::IsWindowFocused();
|
||||
|
||||
renderer.Render(*CurrentScene);
|
||||
|
||||
ImGui::Image(
|
||||
(void*)(intptr_t)renderer.getCurrentFrameBuffer().GetColourAttachment(),
|
||||
ImVec2{ (float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight() }
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
ImGuizmo::Enable(true);
|
||||
ImGuizmo::SetOrthographic(false);
|
||||
ImGuizmo::SetDrawlist();
|
||||
|
||||
float windowWidth = (float)ImGui::GetWindowWidth();
|
||||
float windowHeight = (float)ImGui::GetWindowHeight();
|
||||
ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, windowWidth, windowHeight);
|
||||
|
||||
const auto& ProjMatrix = camera.projection;
|
||||
glm::mat4& cameraView = glm::mat4(1.0f);//glm::inverse(glm::translate(glm::mat4(1.0f) , cam.Position) * glm::toMat4(glm::quat(cam.Rotation)) );
|
||||
|
||||
ImGuizmo::DrawGrid(glm::value_ptr(cameraView), glm::value_ptr(ProjMatrix), glm::value_ptr(cameraDelta), 100.0f);
|
||||
ImGuizmo::ViewManipulate(glm::value_ptr(cameraView), 1, ImGui::GetWindowPos(), {90,90}, 0x22CCCCCC);
|
||||
|
||||
|
||||
if (selected == nullptr)
|
||||
return;
|
||||
|
||||
if (selected->isValid()) {
|
||||
|
||||
auto& tc = selected->GetComponent<YoggieEngine::TransformComponent>();
|
||||
glm::mat4 transform = tc.GetTransform();
|
||||
|
||||
ImGuizmo::Manipulate(
|
||||
glm::value_ptr(cameraView),
|
||||
glm::value_ptr(ProjMatrix),
|
||||
ImGuizmo::TRANSLATE, ImGuizmo::LOCAL,
|
||||
glm::value_ptr(transform), nullptr, nullptr);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
#include "../../YoggieEngine/src/YoggieEngine.h"
|
||||
#include "../EditorWindow.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
#include "../../libs/guizmo/ImGuizmo.h"
|
||||
#include "../EditorCamera.h"
|
||||
|
||||
|
||||
class Viewport : public EditorWindow {
|
||||
public:
|
||||
bool isFocused = false;
|
||||
Viewport(YoggieEngine::Scene& scene, YoggieEngine::Entity& selected);
|
||||
Viewport() = default;
|
||||
void Draw() override;
|
||||
|
||||
EditorCamera& GetCamera(){ return camera; }
|
||||
|
||||
private:
|
||||
YoggieEngine::Renderer renderer;
|
||||
YoggieEngine::Scene* CurrentScene;
|
||||
YoggieEngine::Entity* selected;
|
||||
glm::mat4 cameraDelta = glm::mat4(1.0);
|
||||
EditorCamera camera;
|
||||
|
||||
};
|
@ -4,7 +4,7 @@
|
||||
#include <backends/imgui_impl_opengl3.h>
|
||||
#include <backends/imgui_impl_glfw.h>
|
||||
#include "../../libs/guizmo/ImGuizmo.h"
|
||||
|
||||
#include "../../Editor/src/IconsMaterialDesign.h"
|
||||
|
||||
namespace YoggieEngine {
|
||||
|
||||
@ -23,6 +23,11 @@ namespace YoggieEngine {
|
||||
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable;
|
||||
io.Fonts->AddFontFromFileTTF("build/Debug/Fonts/Roboto-Regular.ttf", 18);
|
||||
ImFontConfig config;
|
||||
config.MergeMode = true;
|
||||
config.GlyphMinAdvanceX = 18.0f;
|
||||
static const ImWchar icon_ranges[] = { ICON_MIN_MD , ICON_MAX_MD, 0 };
|
||||
io.Fonts->AddFontFromFileTTF("build/Debug/Fonts/MaterialIcons-Regular.ttf", 18, &config, icon_ranges);
|
||||
|
||||
ImGui::StyleColorsDark();
|
||||
/*
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace YoggieEngine {
|
||||
Texture::Texture(const std::string texturePath , bool Transparency) {
|
||||
int width, height, channels;
|
||||
int channels;
|
||||
unsigned char* data = stbi_load(texturePath.c_str(), &width, &height, &channels, 0);
|
||||
|
||||
if (data) {
|
||||
|
@ -8,7 +8,11 @@ namespace YoggieEngine {
|
||||
void Bind();
|
||||
void Unbind();
|
||||
const unsigned int GetID() const { return Id; }
|
||||
const ImVec2 getSize() { return {(float)width, (float)height}; }
|
||||
private:
|
||||
unsigned int Id;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user