Moved environment to a resource and a component

This commit is contained in:
antopilo
2024-11-21 21:06:14 -05:00
parent 9937d35579
commit 4ab59bf7e8
21 changed files with 1343 additions and 1051 deletions

View File

@@ -333,6 +333,10 @@ namespace Nuake
{
dragType = "_SkyFile";
}
else if (fileExtension == ".env")
{
dragType = "_EnvFile";
}
ImGui::SetDragDropPayload(dragType.c_str(), (void*)(pathBuffer), sizeof(pathBuffer));
ImGui::Text(file->GetName().c_str());
@@ -401,6 +405,10 @@ namespace Nuake
{
textureImage = textureMgr->GetTexture("Resources/Images/trenchbroom_icon.png");
}
else if (fileType == FileType::Env)
{
textureImage = textureMgr->GetTexture("Resources/Images/env_file_icon.png");
}
ImGui::SetCursorPos(prevCursor);
ImGui::Image(reinterpret_cast<ImTextureID>(textureImage->GetID()), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
@@ -698,6 +706,28 @@ namespace Nuake
FileSystem::WriteLine(jsonData.dump(4));
FileSystem::EndWriteFile();
RefreshFileBrowser();
}
}
if (ImGui::MenuItem("Environment"))
{
const std::string path = FileDialog::SaveFile("*.env");
if (!path.empty())
{
std::string finalPath = path;
if (!String::EndsWith(path, ".env"))
{
finalPath = path + ".env";
}
Ref<Environment> env = CreateRef<Environment>(FileSystem::AbsoluteToRelative(finalPath));
env->IsEmbedded = false;
auto jsonData = env->Serialize();
FileSystem::BeginWriteFile(finalPath, true);
FileSystem::WriteLine(jsonData.dump(4));
FileSystem::EndWriteFile();
RefreshFileBrowser();
}
}