LkEngine 0.1.2
 
Loading...
Searching...
No Matches
Project.h
1/******************************************************************
2 * LProject
3 *
4 *******************************************************************/
5#pragma once
6
8#include "LkEngine/Core/LObject/ObjectPtr.h"
9
10#include "LkEngine/Asset/EditorAssetManager.h"
11#include "LkEngine/Asset/RuntimeAssetManager.h"
12
13#include "LkEngine/Scene/Scene.h"
14#include "LkEngine/Serialization/FileStream.h"
15
16namespace LkEngine {
17
19 {
20 std::string Name{};
21
22 std::string AssetDirectory = "Assets";
23 std::string AssetRegistryPath{};
24 std::string MeshDirectory{};
25
26 std::string StartScene{};
27
28 bool bAutoSave = true;
29 std::chrono::seconds AutoSaveInterval = 150s;
30
31 /* Not serialized. */
32 std::string ProjectFileName{};
33 std::string ProjectDirectory{};
34 };
35
36 enum class EProjectLoadAction : uint8_t
37 {
38 Unload,
39 Load
40 };
41
42 class LProject : public LObject
43 {
44 public:
45 LK_DECLARE_MULTICAST_DELEGATE(FOnProjectChanged, const TObjectPtr<LProject>&);
46 public:
47 LProject();
48 ~LProject() = default;
49
50 void Load(const std::string& ProjectPath);
51
53 FORCEINLINE static TObjectPtr<LProject> Current() { return ActiveProject; }
54
55 static std::filesystem::path GetAssetDirectory();
56 static std::filesystem::path GetAssetRegistryPath();
57 static std::filesystem::path GetMeshDirectory();
58
59 bool Save();
60
61 FProjectConfiguration& GetConfiguration() { return Configuration; }
62 const FProjectConfiguration& GetConfiguration() const { return Configuration; }
63
64 FORCEINLINE static TObjectPtr<IAssetManager> GetAssetManager()
65 {
66 LK_CORE_VERIFY(AssetManager);
67 return AssetManager;
68 }
69
70 FORCEINLINE static TObjectPtr<LEditorAssetManager> GetEditorAssetManager()
71 {
72 LK_CORE_VERIFY(AssetManager);
73 return AssetManager.As<LEditorAssetManager>();
74 }
75
76 FORCEINLINE static TObjectPtr<LRuntimeAssetManager> GetRuntimeAssetManager()
77 {
78 LK_CORE_VERIFY(AssetManager);
79 return AssetManager.As<LRuntimeAssetManager>();
80 }
81
82 static const std::string& GetProjectName()
83 {
84 LK_CORE_VERIFY(ActiveProject, "No active project");
85 return ActiveProject->GetConfiguration().Name;
86 }
87
88 static std::filesystem::path GetProjectDirectory()
89 {
90 LK_CORE_VERIFY(ActiveProject, "No active project");
91 return ActiveProject->GetConfiguration().ProjectDirectory;
92 }
93
94 static void SetActive(TObjectPtr<LProject> Project);
95
96 static bool IsActiveProject(const TObjectPtr<LProject>& Project)
97 {
98 return (ActiveProject == Project);
99 }
100
101 void SetName(const std::string& InName) { Configuration.Name = InName; }
102 const std::string& GetName() const { return Configuration.Name; }
103
104 public:
105 inline static constexpr const char* FILE_EXTENSION = "lkproject";
106 static FOnProjectChanged OnProjectChanged;
107 private:
108 FProjectConfiguration Configuration{};
109
110 inline static TObjectPtr<LProject> ActiveProject{};
111 inline static TObjectPtr<IAssetManager> AssetManager{};
112
113 friend class LEditorLayer;
114
115 LCLASS(LProject)
116 };
117
118}
LObject implementation.
Definition Object.h:46
Definition Project.h:43
static FORCEINLINE TObjectPtr< LProject > Current()
Definition Project.h:53
Definition ObjectPtr.h:102
#define LCLASS(Class)
Definition CoreMacros.h:226
Definition Asset.h:11
Definition Project.h:19