-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProjectSettingUI.cpp
More file actions
60 lines (55 loc) · 1.79 KB
/
Copy pathProjectSettingUI.cpp
File metadata and controls
60 lines (55 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "UI/ProjectSettingUI.h"
#include "ProjectSetting.h"
#include "AssetDatabase.h"
#include "DragDropHelper.hpp"
namespace sh::editor
{
SH_EDITOR_API void ProjectSettingUI::RenderUI(ProjectSetting& setting, const std::filesystem::path& rootPath, bool& bOpen)
{
static auto& assetDatabase = *AssetDatabase::GetInstance();
ImGui::SetNextWindowSize(ImVec2{ 512, 512 }, ImGuiCond_::ImGuiCond_Appearing);
ImGui::Begin("Project Setting", &bOpen);
ImGui::Text("Starting world");
std::string startingWorldName;
if (setting.startingWorldUUID.IsEmpty())
startingWorldName = "Empty";
else
{
auto objPtr = core::SObjectManager::GetInstance()->GetSObject(setting.startingWorldUUID);
startingWorldName = objPtr->GetName().ToString();
}
ImGui::Button(startingWorldName.c_str(), ImVec2{ -1, 20 });
if (ImGui::BeginDragDropTarget())
{
const std::string worldType{ core::reflection::TypeTraits::GetTypeName<game::World>() };
const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(worldType.c_str());
if (payload != nullptr)
{
const core::SObject* const sobjPtr = *reinterpret_cast<core::SObject**>(payload->Data);
auto assetInfoPtr = assetDatabase.GetAssetPath(sobjPtr->GetUUID());
if (assetInfoPtr != nullptr)
{
setting.startingWorldUUID = sobjPtr->GetUUID();
setting.Save(rootPath / "ProjectSetting.json");
}
}
else
{
if (game::World* worldPtr = dragdrop::AcceptAsset<game::World>())
{
if (core::IsValid(worldPtr))
{
auto assetInfoPtr = assetDatabase.GetAssetPath(worldPtr->GetUUID());
if (assetInfoPtr != nullptr)
{
setting.startingWorldUUID = worldPtr->GetUUID();
setting.Save(rootPath / "ProjectSetting.json");
}
}
}
}
}
ImGui::Separator();
ImGui::End();
}
}//namespace