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
This commit is contained in:
Nigel Barink 2022-11-05 12:29:50 +01:00
parent b44c88d05c
commit 41d5b87c7b
13 changed files with 143 additions and 8 deletions

6
.gitmodules vendored
View File

@ -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

View File

@ -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")

View File

@ -0,0 +1,35 @@
#include <stdio.h>
#include "EditorConsole.h"
EditorConsole::EditorConsole()
: Items(ImVector<char*>()), 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));
}

View File

@ -0,0 +1,18 @@
#pragma once
#include <imgui.h>
class EditorConsole
{
public:
EditorConsole();
~EditorConsole();
void Draw();
void AddLog(const char* fmt, ...);
private:
ImVector<char*> Items;
bool AutoScroll;
bool ScrollToBottom;
};

21
Editor/src/Project.cpp Normal file
View File

@ -0,0 +1,21 @@
#include "Project.h"
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
#include <yaml-cpp/yaml.h>
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();
}

10
Editor/src/Project.h Normal file
View File

@ -0,0 +1,10 @@
#pragma once
#include <filesystem>
class Project {
public:
Project(const std::string& name): ProjectName(name){}
void CreateProject(std::filesystem::path path );
private:
std::string ProjectName;
};

View File

@ -1,6 +1,7 @@
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <imgui.h>
#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();
}

View File

@ -1,5 +1,5 @@
#include "widgets.h"
//#include "EditorConsole.h"
#include "EditorConsole.h"
#include <iostream>
#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();
}

View File

@ -19,7 +19,8 @@
- Scripting support ( idk what language)
- LUA
- Configuration options
- JSON
- LUA
- others ?!?!?
- YAML

View File

@ -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"

1
libs/nativefiledialog Submodule

@ -0,0 +1 @@
Subproject commit 67345b80ebb429ecc2aeda94c478b3bcc5f7888e

1
libs/yaml-cpp Submodule

@ -0,0 +1 @@
Subproject commit 0579ae3d976091d7d664aa9d2527e0d0cff25763

13
yaml-cpp/premake5.lua Normal file
View File

@ -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"
}