mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Moved environment to a resource and a component
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user