From 41d5b87c7b36288db9c3dbb71d3b9d6072657eec Mon Sep 17 00:00:00 2001 From: Nigel Barink Date: Sat, 5 Nov 2022 12:29:50 +0100 Subject: [PATCH] Editor console basics and more dependencies Added basics of an editor console, Added YAML-CPP as a dependency of the editor , Added NativeFileDialog as a dependency --- .gitmodules | 6 ++++++ Editor/premake5.lua | 5 ++++- Editor/src/EditorConsole.cpp | 35 +++++++++++++++++++++++++++++++++++ Editor/src/EditorConsole.h | 18 ++++++++++++++++++ Editor/src/Project.cpp | 21 +++++++++++++++++++++ Editor/src/Project.h | 10 ++++++++++ Editor/src/main.cpp | 31 ++++++++++++++++++++++++++++--- Editor/src/widgets.cpp | 6 +++--- Features.md | 3 ++- libraries.lua | 1 + libs/nativefiledialog | 1 + libs/yaml-cpp | 1 + yaml-cpp/premake5.lua | 13 +++++++++++++ 13 files changed, 143 insertions(+), 8 deletions(-) create mode 100644 Editor/src/EditorConsole.cpp create mode 100644 Editor/src/EditorConsole.h create mode 100644 Editor/src/Project.cpp create mode 100644 Editor/src/Project.h create mode 160000 libs/nativefiledialog create mode 160000 libs/yaml-cpp create mode 100644 yaml-cpp/premake5.lua diff --git a/.gitmodules b/.gitmodules index f8db3ba..5f05e41 100644 --- a/.gitmodules +++ b/.gitmodules @@ -30,3 +30,9 @@ [submodule "libs/guizmo"] path = libs/guizmo url = https://github.com/CedricGuillemet/ImGuizmo.git +[submodule "libs/yaml-cpp"] + path = libs/yaml-cpp + url = https://git.barink.dev/Nigel/yaml-cpp.git +[submodule "libs/nativefiledialog"] + path = libs/nativefiledialog + url = https://git.barink.dev/Nigel/nativefiledialog.git diff --git a/Editor/premake5.lua b/Editor/premake5.lua index a04e53c..c56d5be 100644 --- a/Editor/premake5.lua +++ b/Editor/premake5.lua @@ -5,7 +5,8 @@ buildmessage "Building editor ..." links{ "YoggieEngine", - "ImGuizmo" + "ImGuizmo", + "yaml-cpp" } includedirs{ @@ -23,6 +24,7 @@ includedirs{ incfolder["imgui"], incfolder["imguizmo"], incfolder["entt"], + incfolder["yamlcpp"], "./include" @@ -37,3 +39,4 @@ files { "./src/*.cpp" } +include("../yaml-cpp") diff --git a/Editor/src/EditorConsole.cpp b/Editor/src/EditorConsole.cpp new file mode 100644 index 0000000..b69a3cc --- /dev/null +++ b/Editor/src/EditorConsole.cpp @@ -0,0 +1,35 @@ +#include +#include "EditorConsole.h" + + +EditorConsole::EditorConsole() + : Items(ImVector()), AutoScroll(false), ScrollToBottom(false) +{ + AddLog("Hello Editor console!"); +} + +EditorConsole::~EditorConsole() { + +} + +void EditorConsole::Draw() { + ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); + + + for (int i = 0; i < Items.Size; i++) + { + const char* item = Items[i]; + ImGui::TextUnformatted(item); + } +} + + +void EditorConsole::AddLog(const char* fmt, ...) { + char buf[1024]; + va_list args; + va_start(args, fmt); + vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); + buf[IM_ARRAYSIZE(buf) - 1] = 0; + va_end(args); + Items.push_back(strdup(buf)); +} diff --git a/Editor/src/EditorConsole.h b/Editor/src/EditorConsole.h new file mode 100644 index 0000000..51194ec --- /dev/null +++ b/Editor/src/EditorConsole.h @@ -0,0 +1,18 @@ +#pragma once +#include + +class EditorConsole +{ +public: + EditorConsole(); + ~EditorConsole(); + + void Draw(); + void AddLog(const char* fmt, ...); + +private: + ImVector Items; + bool AutoScroll; + bool ScrollToBottom; + +}; \ No newline at end of file diff --git a/Editor/src/Project.cpp b/Editor/src/Project.cpp new file mode 100644 index 0000000..ab1cf60 --- /dev/null +++ b/Editor/src/Project.cpp @@ -0,0 +1,21 @@ +#include "Project.h" +#include +#include +#include +#include +#include + + +void Project::CreateProject(std::filesystem::path path) { + YAML::Emitter projectYAML; + projectYAML << YAML::Key << "Project" << YAML::Value << "new"; + std::ofstream projectFile; + + path.append(ProjectName.append(".yproj")); + + std::cout << path.u8string() << std::endl; + + projectFile.open(path.u8string()); + projectFile << projectYAML.c_str(); + projectFile.close(); +} \ No newline at end of file diff --git a/Editor/src/Project.h b/Editor/src/Project.h new file mode 100644 index 0000000..0a22e22 --- /dev/null +++ b/Editor/src/Project.h @@ -0,0 +1,10 @@ +#pragma once +#include +class Project { +public: + Project(const std::string& name): ProjectName(name){} + void CreateProject(std::filesystem::path path ); +private: + std::string ProjectName; + +}; \ No newline at end of file diff --git a/Editor/src/main.cpp b/Editor/src/main.cpp index e3f2c6d..05cb4c0 100644 --- a/Editor/src/main.cpp +++ b/Editor/src/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include "Project.h" #include "../../libs/guizmo/ImGuizmo.h" @@ -72,11 +73,29 @@ void ImmediateGraphicsDraw() if (ImGui::BeginMenu("Application")) { - if (ImGui::MenuItem("Preferences")) { + if (ImGui::BeginMenu("Project")) { + if (ImGui::MenuItem("New project")) + { + Project p("New-Project"); + p.CreateProject("I:/Dev/MyGameEngine"); + } + + if (ImGui::MenuItem("Load Project")) + { + + } + + ImGui::EndMenu(); + } + + + if (ImGui::MenuItem("Preferences")) + { } - if (ImGui::MenuItem("Exit")) { + if (ImGui::MenuItem("Exit")) + { // TODO: Exit application } @@ -85,12 +104,18 @@ void ImmediateGraphicsDraw() if (ImGui::BeginMenu("Scene")) { + if (ImGui::MenuItem("Save scene")) { + + } + + if (ImGui::MenuItem("Load scene")) { + + } if (ImGui::MenuItem("Add Entity")) { Level1.AddEntity("New entity"); } - ImGui::EndMenu(); } diff --git a/Editor/src/widgets.cpp b/Editor/src/widgets.cpp index 68df376..140c31e 100644 --- a/Editor/src/widgets.cpp +++ b/Editor/src/widgets.cpp @@ -1,5 +1,5 @@ #include "widgets.h" -//#include "EditorConsole.h" +#include "EditorConsole.h" #include #include "../../YoggieEngine/src/Scene/Components.h" #include "../../YoggieEngine/src/Scene/Entity.h" @@ -151,11 +151,11 @@ void Settings() { ImGui::End(); } -//auto console = EditorConsole(); +auto console = EditorConsole(); void Console() { ImGui::Begin("Console", false); - // console.Draw(); + console.Draw(); ImGui::End(); } diff --git a/Features.md b/Features.md index 875d295..3cb58ca 100644 --- a/Features.md +++ b/Features.md @@ -19,7 +19,8 @@ - Scripting support ( idk what language) - LUA + - Configuration options - JSON - LUA - - others ?!?!? + - YAML diff --git a/libraries.lua b/libraries.lua index aa86f74..90777ef 100644 --- a/libraries.lua +++ b/libraries.lua @@ -5,6 +5,7 @@ incfolder["spdlog"] = "%{wks.location}/libs/spdlog/include" incfolder["assimp"] = "%{wks.location}/libs/assimp/include" incfolder["glm"] = "%{wks.location}/libs/glm" incfolder["entt"] = "%{wks.location}/libs/entt/src" +incfolder["yamlcpp"] = "%{wks.location}/libs/yaml-cpp/include" -- Graphics incfolder["glad"] = "%{wks.location}/libs/glad/include" diff --git a/libs/nativefiledialog b/libs/nativefiledialog new file mode 160000 index 0000000..67345b8 --- /dev/null +++ b/libs/nativefiledialog @@ -0,0 +1 @@ +Subproject commit 67345b80ebb429ecc2aeda94c478b3bcc5f7888e diff --git a/libs/yaml-cpp b/libs/yaml-cpp new file mode 160000 index 0000000..0579ae3 --- /dev/null +++ b/libs/yaml-cpp @@ -0,0 +1 @@ +Subproject commit 0579ae3d976091d7d664aa9d2527e0d0cff25763 diff --git a/yaml-cpp/premake5.lua b/yaml-cpp/premake5.lua new file mode 100644 index 0000000..2ebccbd --- /dev/null +++ b/yaml-cpp/premake5.lua @@ -0,0 +1,13 @@ +project "yaml-cpp" +kind "StaticLib" + +buildmessage "Building YAML parser ..." + +includedirs{ + "../libs/yaml-cpp/include" +} + +files{ + "../libs/yaml-cpp/src/*.h", + "../libs/yaml-cpp/src/*.cpp" +} \ No newline at end of file