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:
@ -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")
|
||||
|
35
Editor/src/EditorConsole.cpp
Normal file
35
Editor/src/EditorConsole.cpp
Normal 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));
|
||||
}
|
18
Editor/src/EditorConsole.h
Normal file
18
Editor/src/EditorConsole.h
Normal 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
21
Editor/src/Project.cpp
Normal 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
10
Editor/src/Project.h
Normal 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;
|
||||
|
||||
};
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user