Skip to content

Commit e10bf0f

Browse files
authored
Cleaned up project hub and asset browser (#547)
* Cleaned up project hub * Added ProjectManagement utils and cleaned up code * Updated asset browser
1 parent dbaa6cb commit e10bf0f

25 files changed

Lines changed: 1030 additions & 711 deletions

File tree

Sources/Overload/OvCore/include/OvCore/ResourceManagement/AResourceManager.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66

77
#pragma once
88

9-
#include <unordered_map>
109
#include <any>
11-
12-
10+
#include <filesystem>
11+
#include <unordered_map>
1312

1413
namespace OvCore::ResourceManagement
1514
{
@@ -93,7 +92,10 @@ namespace OvCore::ResourceManagement
9392
* @param p_projectAssetsPath
9493
* @param p_engineAssetsPath
9594
*/
96-
static void ProvideAssetPaths(const std::string& p_projectAssetsPath, const std::string& p_engineAssetsPath);
95+
static void ProvideAssetPaths(
96+
const std::filesystem::path& p_projectAssetsPath,
97+
const std::filesystem::path& p_engineAssetsPath
98+
);
9799

98100
/**
99101
* Returns the resource map
@@ -107,8 +109,8 @@ namespace OvCore::ResourceManagement
107109
std::string GetRealPath(const std::string& p_path) const;
108110

109111
private:
110-
inline static std::string __PROJECT_ASSETS_PATH = "";
111-
inline static std::string __ENGINE_ASSETS_PATH = "";
112+
inline static std::filesystem::path __PROJECT_ASSETS_PATH;
113+
inline static std::filesystem::path __ENGINE_ASSETS_PATH;
112114

113115
std::unordered_map<std::string, T*> m_resources;
114116
};

Sources/Overload/OvCore/include/OvCore/ResourceManagement/AResourceManager.inl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,13 @@ namespace OvCore::ResourceManagement
114114
}
115115

116116
template<typename T>
117-
inline void AResourceManager<T>::ProvideAssetPaths(const std::string & p_projectAssetsPath, const std::string & p_engineAssetsPath)
117+
inline void AResourceManager<T>::ProvideAssetPaths(
118+
const std::filesystem::path& p_projectAssetsPath,
119+
const std::filesystem::path& p_engineAssetsPath
120+
)
118121
{
119-
__PROJECT_ASSETS_PATH = p_projectAssetsPath;
120-
__ENGINE_ASSETS_PATH = p_engineAssetsPath;
122+
__PROJECT_ASSETS_PATH = p_projectAssetsPath;
123+
__ENGINE_ASSETS_PATH = p_engineAssetsPath;
121124
}
122125

123126
template<typename T>
@@ -129,17 +132,17 @@ namespace OvCore::ResourceManagement
129132
template<typename T>
130133
inline std::string AResourceManager<T>::GetRealPath(const std::string& p_path) const
131134
{
132-
std::string result;
135+
std::filesystem::path path;
133136

134-
if (p_path[0] == ':') // The path is an engine path
137+
if (p_path.starts_with(':')) // The path is an engine path
135138
{
136-
result = __ENGINE_ASSETS_PATH + std::string(p_path.data() + 1, p_path.data() + p_path.size());
139+
path = __ENGINE_ASSETS_PATH / p_path.substr(1);
137140
}
138141
else // The path is a project path
139142
{
140-
result = __PROJECT_ASSETS_PATH + p_path;
143+
path = __PROJECT_ASSETS_PATH / p_path;
141144
}
142145

143-
return result;
146+
return path.string();
144147
}
145148
}

Sources/Overload/OvCore/include/OvCore/Scripting/Common/TScriptEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace OvCore::Scripting
4242
* Defines the root location of the script folder
4343
* @param p_rootFolder
4444
*/
45-
void SetScriptRootFolder(const std::string& p_rootFolder);
45+
void SetScriptRootFolder(const std::filesystem::path& p_rootFolder);
4646

4747
/**
4848
* Returns a list of valid extensions for scripts.

Sources/Overload/OvCore/include/OvCore/Scripting/Lua/LuaScriptEngine.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
#pragma once
88

9-
#include <vector>
9+
#include <filesystem>
1010
#include <memory>
11+
#include <vector>
1112

1213
#include <OvCore/Scripting/Common/TScriptEngine.h>
1314

@@ -29,7 +30,7 @@ namespace OvCore::Scripting
2930
struct LuaScriptEngineContext
3031
{
3132
std::unique_ptr<sol::state> luaState;
32-
std::string scriptRootFolder;
33+
std::filesystem::path scriptRootFolder;
3334
std::vector<std::reference_wrapper<OvCore::ECS::Components::Behaviour>> behaviours;
3435
uint32_t errorCount;
3536
};

Sources/Overload/OvCore/src/OvCore/SceneSystem/SceneManager.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,19 @@ void OvCore::SceneSystem::SceneManager::LoadDefaultScene()
6262

6363
bool OvCore::SceneSystem::SceneManager::LoadScene(const std::string& p_path, bool p_absolute)
6464
{
65-
std::string completePath = (p_absolute ? "" : m_sceneRootFolder) + p_path;
65+
std::filesystem::path path =
66+
p_absolute ?
67+
std::filesystem::current_path() :
68+
std::filesystem::path{ m_sceneRootFolder };
69+
70+
path /= p_path;
6671

6772
tinyxml2::XMLDocument doc;
68-
doc.LoadFile(completePath.c_str());
73+
doc.LoadFile(path.string().c_str());
6974

7075
if (LoadSceneFromMemory(doc))
7176
{
72-
StoreCurrentSceneSourcePath(completePath);
77+
StoreCurrentSceneSourcePath(path.string());
7378
return true;
7479
}
7580

Sources/Overload/OvCore/src/OvCore/Scripting/Lua/LuaScriptEngine.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ void OvCore::Scripting::LuaScriptEngine::CreateContext()
118118
m_context.errorCount = 0;
119119

120120
std::for_each(m_context.behaviours.begin(), m_context.behaviours.end(),
121-
[this](std::reference_wrapper<OvCore::ECS::Components::Behaviour> behaviour)
122-
{
123-
if (!RegisterBehaviour(*m_context.luaState, behaviour.get(), m_context.scriptRootFolder + behaviour.get().name + GetDefaultExtension()))
121+
[this](std::reference_wrapper<OvCore::ECS::Components::Behaviour> behaviour) {
122+
const auto scriptFileName = behaviour.get().name + GetDefaultExtension();
123+
const auto scriptPath = m_context.scriptRootFolder / scriptFileName;
124+
if (!RegisterBehaviour(*m_context.luaState, behaviour.get(), scriptPath.string()))
124125
{
125126
++m_context.errorCount;
126127
}
@@ -155,7 +156,7 @@ template<>
155156
OvCore::Scripting::LuaScriptEngineBase::~TScriptEngine() {}
156157

157158
template<>
158-
void OvCore::Scripting::LuaScriptEngineBase::SetScriptRootFolder(const std::string& p_scriptRootFolder)
159+
void OvCore::Scripting::LuaScriptEngineBase::SetScriptRootFolder(const std::filesystem::path& p_scriptRootFolder)
159160
{
160161
m_context.scriptRootFolder = p_scriptRootFolder;
161162
}
@@ -185,7 +186,10 @@ void OvCore::Scripting::LuaScriptEngineBase::AddBehaviour(OvCore::ECS::Component
185186

186187
m_context.behaviours.push_back(std::ref(p_toAdd));
187188

188-
if (!RegisterBehaviour(*m_context.luaState, p_toAdd, m_context.scriptRootFolder + p_toAdd.name + GetDefaultExtension()))
189+
const auto scriptFileName = p_toAdd.name + GetDefaultExtension();
190+
const auto scriptPath = m_context.scriptRootFolder / scriptFileName;
191+
192+
if (!RegisterBehaviour(*m_context.luaState, p_toAdd, scriptPath.string()))
189193
{
190194
++m_context.errorCount;
191195
}

Sources/Overload/OvCore/src/OvCore/Scripting/Null/NullScriptEngine.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @licence: MIT
55
*/
66

7+
#include <filesystem>
8+
79
#include <OvCore/Scripting/Null/NullScriptEngine.h>
810

911
template<>
@@ -13,7 +15,7 @@ template<>
1315
OvCore::Scripting::NullScriptEngineBase::~TScriptEngine() {}
1416

1517
template<>
16-
void OvCore::Scripting::NullScriptEngineBase::SetScriptRootFolder(const std::string& p_scriptRootFolder) {}
18+
void OvCore::Scripting::NullScriptEngineBase::SetScriptRootFolder(const std::filesystem::path& p_scriptRootFolder) {}
1719

1820
template<>
1921
std::vector<std::string> OvCore::Scripting::NullScriptEngineBase::GetValidExtensions()

Sources/Overload/OvEditor/include/OvEditor/Core/Application.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
#pragma once
88

9-
#include "OvEditor/Core/Context.h"
10-
#include "OvEditor/Core/Editor.h"
9+
#include <OvEditor/Core/Context.h>
10+
#include <OvEditor/Core/Editor.h>
1111

1212
namespace OvEditor::Core
1313
{
@@ -19,15 +19,14 @@ namespace OvEditor::Core
1919
public:
2020
/**
2121
* Constructor
22-
* @param p_projectPath
23-
* @param p_projectName
22+
* @param p_projectFolder (The folder containing the .ovproject file)
2423
*/
25-
Application(const std::string& p_projectPath, const std::string& p_projectName);
24+
Application(const std::filesystem::path& p_projectFolder);
2625

2726
/**
2827
* Destructor
2928
*/
30-
~Application();
29+
virtual ~Application();
3130

3231
/**
3332
* Run the app

Sources/Overload/OvEditor/include/OvEditor/Core/Context.h

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,26 @@
66

77
#pragma once
88

9-
#include <OvTools/Filesystem/IniFile.h>
10-
11-
#include <OvRendering/HAL/UniformBuffer.h>
12-
#include <OvRendering/HAL/ShaderStorageBuffer.h>
13-
14-
#include <OvPhysics/Core/PhysicsEngine.h>
9+
#include <filesystem>
1510

1611
#include <OvAudio/Core/AudioEngine.h>
17-
18-
#include <OvWindowing/Context/Device.h>
19-
#include <OvWindowing/Inputs/InputManager.h>
20-
#include <OvWindowing/Window.h>
21-
12+
#include <OvCore/ResourceManagement/MaterialManager.h>
2213
#include <OvCore/ResourceManagement/ModelManager.h>
23-
#include <OvCore/ResourceManagement/TextureManager.h>
2414
#include <OvCore/ResourceManagement/ShaderManager.h>
25-
#include <OvCore/ResourceManagement/MaterialManager.h>
2615
#include <OvCore/ResourceManagement/SoundManager.h>
16+
#include <OvCore/ResourceManagement/TextureManager.h>
2717
#include <OvCore/SceneSystem/SceneManager.h>
2818
#include <OvCore/Scripting/ScriptEngine.h>
29-
30-
#include <OvUI/Core/UIManager.h>
31-
#include <OvAudio/Core/AudioEngine.h>
32-
33-
#include "OvEditor/Core/EditorResources.h"
19+
#include <OvEditor/Core/EditorResources.h>
3420
#include <OvEditor/Utils/TextureRegistry.h>
21+
#include <OvPhysics/Core/PhysicsEngine.h>
22+
#include <OvRendering/HAL/UniformBuffer.h>
23+
#include <OvRendering/HAL/ShaderStorageBuffer.h>
24+
#include <OvTools/Filesystem/IniFile.h>
25+
#include <OvWindowing/Window.h>
26+
#include <OvUI/Core/UIManager.h>
27+
#include <OvWindowing/Context/Device.h>
28+
#include <OvWindowing/Inputs/InputManager.h>
3529

3630
namespace OvEditor::Core
3731
{
@@ -43,15 +37,14 @@ namespace OvEditor::Core
4337
public:
4438
/**
4539
* Constructor
46-
* @param p_projectPath
47-
* @param p_projectName
40+
* @param p_projectFolder (including the .ovproject file)
4841
*/
49-
Context(const std::string& p_projectPath, const std::string& p_projectName);
42+
Context(const std::filesystem::path& p_projectFolder);
5043

5144
/**
5245
* Destructor
5346
*/
54-
~Context();
47+
virtual ~Context();
5548

5649
/**
5750
* Reset project settings ini file
@@ -70,13 +63,12 @@ namespace OvEditor::Core
7063
void ApplyProjectSettings();
7164

7265
public:
73-
const std::string projectPath;
74-
const std::string projectName;
75-
const std::string projectFilePath;
76-
const std::string engineAssetsPath;
77-
const std::string projectAssetsPath;
78-
const std::string projectScriptsPath;
79-
const std::string editorAssetsPath;
66+
const std::filesystem::path projectFolder;
67+
const std::filesystem::path projectFile;
68+
const std::filesystem::path engineAssetsPath;
69+
const std::filesystem::path projectAssetsPath;
70+
const std::filesystem::path projectScriptsPath;
71+
const std::filesystem::path editorAssetsPath;
8072

8173
std::unique_ptr<OvWindowing::Context::Device> device;
8274
std::unique_ptr<OvWindowing::Window> window;

Sources/Overload/OvEditor/include/OvEditor/Core/EditorActions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ namespace OvEditor::Core
381381
* @param p_buildPath
382382
* @param p_autoRun
383383
*/
384-
void BuildAtLocation(const std::string& p_configuration, const std::string p_buildPath, bool p_autoRun = false);
384+
void BuildAtLocation(const std::string& p_configuration, const std::filesystem::path&, bool p_autoRun = false);
385385
#pragma endregion
386386

387387
#pragma region PROFILNIG

0 commit comments

Comments
 (0)