Added saving and loading
This commit is contained in:
@@ -2,14 +2,18 @@
|
||||
#define OPEN_ENGINE_HPP
|
||||
|
||||
#include "open_engine/orthographic_camera_controller.hpp"
|
||||
#include "open_engine/scene/native_scriptable_entity.hpp"
|
||||
#include "open_engine/imgui/imgui_layer.hpp"
|
||||
#include "open_engine/events/key_event.hpp"
|
||||
#include "open_engine/scene/components.hpp"
|
||||
#include "open_engine/application.hpp"
|
||||
#include "open_engine/ref_scope.hpp"
|
||||
#include "open_engine/logging.hpp"
|
||||
|
||||
#include "open_engine/scene/native_scriptable_entity.hpp"
|
||||
#include "open_engine/scene/scene_serializer.hpp"
|
||||
#include "open_engine/scene/components.hpp"
|
||||
#include "open_engine/scene/components.hpp"
|
||||
|
||||
#include "open_engine/core/file_dialogs.hpp"
|
||||
#include "open_engine/core/time.hpp"
|
||||
#include "open_engine/core.hpp"
|
||||
|
||||
@@ -23,7 +27,6 @@
|
||||
#include "open_engine/renderer/renderer2d.hpp"
|
||||
#include "open_engine/renderer/renderer.hpp"
|
||||
#include "open_engine/renderer/texture.hpp"
|
||||
#include "open_engine/scene/components.hpp"
|
||||
#include "open_engine/renderer/buffer.hpp"
|
||||
#include "open_engine/renderer/shader.hpp"
|
||||
#include "open_engine/scene/entity.hpp"
|
||||
|
||||
16
open_engine/include/open_engine/core/file_dialogs.hpp
Normal file
16
open_engine/include/open_engine/core/file_dialogs.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef FILE_DIALOGS_HPP
|
||||
#define FILE_DIALOGS_HPP
|
||||
|
||||
// TODO: Un-Class this?
|
||||
namespace OpenEngine {
|
||||
|
||||
class FileDialogs
|
||||
{
|
||||
public:
|
||||
static std::string OpenFile(const char* filters);
|
||||
static std::string SaveFile(const char* filters);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FILE_DIALOGS_HPP
|
||||
@@ -34,7 +34,6 @@ namespace OpenEngine {
|
||||
std::memset(buffer, 0, sizeof(buffer));
|
||||
std::strncpy(buffer, tag.c_str(), sizeof(buffer));
|
||||
|
||||
ImGui::Text("Name");
|
||||
if (ImGui::InputText("##tagEditor", buffer, sizeof(buffer), ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll)
|
||||
|| (!ImGui::IsItemActive() && ImGui::IsMouseClicked(0)))
|
||||
tag = buffer;
|
||||
@@ -68,7 +67,9 @@ namespace OpenEngine {
|
||||
void OnImGuiRender(Entity& entity)
|
||||
{
|
||||
DrawVec3Control("Position", translation);
|
||||
DrawVec3Control("Rotation", rotation);
|
||||
glm::vec3 rotation_comp = glm::degrees(rotation);
|
||||
DrawVec3Control("Rotation", rotation_comp);
|
||||
rotation = glm::radians(rotation_comp);
|
||||
DrawVec3Control("Scale", scale);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "open_engine/scene/scene.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <entt/entity/fwd.hpp>
|
||||
#include <entt/entt.hpp>
|
||||
#include <utility>
|
||||
|
||||
@@ -44,6 +46,7 @@ namespace OpenEngine {
|
||||
};
|
||||
|
||||
operator bool() const { return handle != entt::null; };
|
||||
operator entt::entity() const { return handle; };
|
||||
operator uint32_t() const { return (uint32_t)handle; };
|
||||
|
||||
bool operator ==(const Entity& other) const {
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace OpenEngine {
|
||||
virtual ~NativeScriptableEntity() = default;
|
||||
template <typename T>
|
||||
T& GetComponent() { return entity.GetComponents<T>(); };
|
||||
template <typename T>
|
||||
bool HasComponent() { return entity.HasComponent<T>(); };
|
||||
|
||||
protected:
|
||||
virtual void OnCreate() {};
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace OpenEngine {
|
||||
~Scene() = default;
|
||||
|
||||
Entity CreateEntity(const std::string& name = std::string());
|
||||
void DeleteEntity(Entity entity);
|
||||
|
||||
void OnUpdate();
|
||||
void OnViewportResize(uint32_t width, uint32_t height);
|
||||
@@ -26,6 +27,7 @@ namespace OpenEngine {
|
||||
|
||||
uint32_t viewport_width = 0, viewport_height = 0;
|
||||
|
||||
friend class SceneSerializer;
|
||||
friend class Entity;
|
||||
};
|
||||
}
|
||||
|
||||
25
open_engine/include/open_engine/scene/scene_serializer.hpp
Normal file
25
open_engine/include/open_engine/scene/scene_serializer.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef SCENE_SERIALIZER_HPP
|
||||
#define SCENE_SERIALIZER_HPP
|
||||
|
||||
#include "open_engine/ref_scope.hpp"
|
||||
#include "open_engine/scene/scene.hpp"
|
||||
|
||||
namespace OpenEngine {
|
||||
|
||||
class SceneSerializer
|
||||
{
|
||||
public:
|
||||
SceneSerializer(const Ref<Scene>& scene);
|
||||
|
||||
void Serialize(const std::string& file_path);
|
||||
void SerializeRuntime(const std::string& file_path);
|
||||
|
||||
bool Deserialize(const std::string& file_path);
|
||||
bool DeserializeRuntime(const std::string& file_path);
|
||||
|
||||
private:
|
||||
Ref<Scene> context;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SCENE_SERIALIZER_HPP
|
||||
Reference in New Issue
Block a user