mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Merge branch 'develop' of https://github.com/antopilo/Nuake into develop
# Conflicts: # Nuake/src/Resource/StaticResources.cpp
This commit is contained in:
@@ -119,11 +119,12 @@ Nuake::Application* Nuake::CreateApplication(int argc, char** argv)
|
||||
ApplicationSpecification specification
|
||||
{
|
||||
.Name = "Editor",
|
||||
.WindowWidth = 1100,
|
||||
.WindowHeight = 630,
|
||||
.WindowWidth = static_cast<uint32_t>(launchSettings.resolution.x),
|
||||
.WindowHeight = static_cast<uint32_t>(launchSettings.resolution.y),
|
||||
.VSync = true
|
||||
};
|
||||
|
||||
|
||||
#ifdef NK_DEBUG
|
||||
specification.Name += "(DEBUG BUILD)";
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
struct LaunchSettings
|
||||
{
|
||||
int32_t monitor = 1;
|
||||
Nuake::Vector2 resolution = { 1920, 1080 };
|
||||
Nuake::Vector2 resolution = { 1100, 630 };
|
||||
std::string windowTitle = "Nuake Editor ";
|
||||
std::string projectPath;
|
||||
};
|
||||
|
||||
@@ -3094,12 +3094,12 @@ namespace Nuake {
|
||||
|
||||
std::string selectedProject = FileDialog::SaveFile("Project file\0*.project");
|
||||
|
||||
if(!String::EndsWith(selectedProject, ".project"))
|
||||
selectedProject += ".project";
|
||||
|
||||
if (selectedProject.empty()) // Hit cancel
|
||||
return;
|
||||
|
||||
if(!String::EndsWith(selectedProject, ".project"))
|
||||
selectedProject += ".project";
|
||||
|
||||
auto backslashSplits = String::Split(selectedProject, '\\');
|
||||
auto fileName = backslashSplits[backslashSplits.size() - 1];
|
||||
|
||||
|
||||
@@ -14,8 +14,11 @@
|
||||
#include <src/FileSystem/FileDialog.h>
|
||||
|
||||
#include <Engine.h>
|
||||
#include <src/Resource/SkyResource.h>
|
||||
#include <src/Resource/Prefab.h>
|
||||
|
||||
#include "src/Rendering/Textures/TextureManager.h"
|
||||
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
#include "Tracy.hpp"
|
||||
@@ -64,6 +67,12 @@ void EditorSelectionPanel::ResolveFile(Ref<Nuake::File> file)
|
||||
Ref<Material> material = ResourceLoader::LoadMaterial(currentFile->GetRelativePath());
|
||||
selectedResource = material;
|
||||
}
|
||||
|
||||
if (currentFile->GetFileType() == FileType::Sky)
|
||||
{
|
||||
Ref<SkyResource> sky = ResourceLoader::LoadSky(currentFile->GetRelativePath());
|
||||
selectedResource = sky;
|
||||
}
|
||||
}
|
||||
|
||||
void EditorSelectionPanel::Draw(EditorSelection selection, const std::string& id)
|
||||
@@ -236,6 +245,199 @@ void EditorSelectionPanel::DrawFile(Ref<Nuake::File> file)
|
||||
{
|
||||
//Ref<Prefab> prefab = CreateRef<Prefab>(file->GetRelativePath());
|
||||
//DrawPrefabPanel(prefab);
|
||||
break;
|
||||
}
|
||||
case FileType::Sky:
|
||||
{
|
||||
auto sky = std::static_pointer_cast<SkyResource>(selectedResource);
|
||||
std::string skyName = sky->Path;
|
||||
{
|
||||
UIFont boldfont = UIFont(Fonts::SubTitle);
|
||||
ImGui::Text(sky->Path.c_str());
|
||||
|
||||
}
|
||||
ImGui::SameLine();
|
||||
{
|
||||
UIFont boldfont = UIFont(Fonts::Icons);
|
||||
if (ImGui::Button(ICON_FA_SAVE))
|
||||
{
|
||||
if (ResourceManager::IsResourceLoaded(sky->ID))
|
||||
{
|
||||
ResourceManager::RegisterResource(sky);
|
||||
}
|
||||
|
||||
std::string fileData = sky->Serialize().dump(4);
|
||||
|
||||
FileSystem::BeginWriteFile(sky->Path);
|
||||
FileSystem::WriteLine(fileData);
|
||||
FileSystem::EndWriteFile();
|
||||
}
|
||||
}
|
||||
|
||||
int textureId = 0;
|
||||
|
||||
// Top
|
||||
ImGui::Text("Top");
|
||||
if (auto topTexture = sky->GetFaceTexture(SkyFaces::Top);
|
||||
!topTexture.empty())
|
||||
{
|
||||
textureId = TextureManager::Get()->GetTexture(FileSystem::RelativeToAbsolute(topTexture))->GetID();
|
||||
}
|
||||
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture1"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
std::string texture = FileDialog::OpenFile("*.png | *.jpg");
|
||||
if (!texture.empty())
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Top, FileSystem::AbsoluteToRelative(texture));
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (ImGui::MenuItem("Clear Texture"))
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Top, "");
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
textureId = 0;
|
||||
|
||||
ImGui::Text("Bottom");
|
||||
if (auto bottomTexture = sky->GetFaceTexture(SkyFaces::Bottom);
|
||||
!bottomTexture.empty())
|
||||
{
|
||||
textureId = TextureManager::Get()->GetTexture(FileSystem::RelativeToAbsolute(bottomTexture))->GetID();
|
||||
}
|
||||
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture2"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
std::string texture = FileDialog::OpenFile("*.png | *.jpg");
|
||||
if (!texture.empty())
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Bottom, FileSystem::AbsoluteToRelative(texture));
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (ImGui::MenuItem("Clear Texture"))
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Bottom, "");
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
textureId = 0;
|
||||
|
||||
ImGui::Text("Left");
|
||||
if (auto bottomTexture = sky->GetFaceTexture(SkyFaces::Left);
|
||||
!bottomTexture.empty())
|
||||
{
|
||||
textureId = TextureManager::Get()->GetTexture(FileSystem::RelativeToAbsolute(bottomTexture))->GetID();
|
||||
}
|
||||
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture3"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
std::string texture = FileDialog::OpenFile("*.png | *.jpg");
|
||||
if (!texture.empty())
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Left, FileSystem::AbsoluteToRelative(texture));
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (ImGui::MenuItem("Clear Texture"))
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Left, "");
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
textureId = 0;
|
||||
|
||||
ImGui::Text("Right");
|
||||
if (auto bottomTexture = sky->GetFaceTexture(SkyFaces::Right);
|
||||
!bottomTexture.empty())
|
||||
{
|
||||
textureId = TextureManager::Get()->GetTexture(FileSystem::RelativeToAbsolute(bottomTexture))->GetID();
|
||||
}
|
||||
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture4"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
std::string texture = FileDialog::OpenFile("*.png | *.jpg");
|
||||
if (!texture.empty())
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Right, FileSystem::AbsoluteToRelative(texture));
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (ImGui::MenuItem("Clear Texture"))
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Right, "");
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
textureId = 0;
|
||||
|
||||
ImGui::Text("Front");
|
||||
if (auto bottomTexture = sky->GetFaceTexture(SkyFaces::Front);
|
||||
!bottomTexture.empty())
|
||||
{
|
||||
textureId = TextureManager::Get()->GetTexture(FileSystem::RelativeToAbsolute(bottomTexture))->GetID();
|
||||
}
|
||||
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture5"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
std::string texture = FileDialog::OpenFile("*.png | *.jpg");
|
||||
if (!texture.empty())
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Front, FileSystem::AbsoluteToRelative(texture));
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (ImGui::MenuItem("Clear Texture"))
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Front, "");
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
textureId = 0;
|
||||
|
||||
ImGui::Text("Back");
|
||||
if (auto bottomTexture = sky->GetFaceTexture(SkyFaces::Back);
|
||||
!bottomTexture.empty())
|
||||
{
|
||||
textureId = TextureManager::Get()->GetTexture(FileSystem::RelativeToAbsolute(bottomTexture))->GetID();
|
||||
}
|
||||
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#skytexture6"), (void*)textureId, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
std::string texture = FileDialog::OpenFile("*.png | *.jpg");
|
||||
if (!texture.empty())
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Back, FileSystem::AbsoluteToRelative(texture));
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (ImGui::MenuItem("Clear Texture"))
|
||||
{
|
||||
sky->SetTextureFace(SkyFaces::Back, "");
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "../Misc/ThumbnailManager.h"
|
||||
|
||||
#include <Tracy.hpp>
|
||||
#include <src/Resource/SkyResource.h>
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
@@ -328,6 +329,10 @@ namespace Nuake
|
||||
{
|
||||
dragType = "_UIFile";
|
||||
}
|
||||
else if (fileExtension == ".sky")
|
||||
{
|
||||
dragType = "_SkyFile";
|
||||
}
|
||||
|
||||
ImGui::SetDragDropPayload(dragType.c_str(), (void*)(pathBuffer), sizeof(pathBuffer));
|
||||
ImGui::Text(file->GetName().c_str());
|
||||
@@ -674,6 +679,28 @@ namespace Nuake
|
||||
RefreshFileBrowser();
|
||||
}
|
||||
}
|
||||
if (ImGui::MenuItem("Sky"))
|
||||
{
|
||||
const std::string path = FileDialog::SaveFile("*.sky");
|
||||
if (!path.empty())
|
||||
{
|
||||
std::string finalPath = path;
|
||||
if (!String::EndsWith(path, ".sky"))
|
||||
{
|
||||
finalPath = path + ".sky";
|
||||
}
|
||||
|
||||
Ref<SkyResource> sky = CreateRef<SkyResource>(FileSystem::AbsoluteToRelative(finalPath));
|
||||
sky->IsEmbedded = false;
|
||||
auto jsonData = sky->Serialize();
|
||||
|
||||
FileSystem::BeginWriteFile(finalPath, true);
|
||||
FileSystem::WriteLine(jsonData.dump(4));
|
||||
FileSystem::EndWriteFile();
|
||||
|
||||
RefreshFileBrowser();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user