Merge branch 'develop' of https://github.com/antopilo/nuake into develop

This commit is contained in:
Antoine Pilote
2024-09-17 12:32:48 -04:00
34 changed files with 550 additions and 137 deletions

View File

@@ -736,6 +736,7 @@ namespace Nuake {
NameComponent& nameComponent = e.GetComponent<NameComponent>();
std::string name = nameComponent.Name;
ParentComponent& parent = e.GetComponent<ParentComponent>();
if (Selection.Type == EditorSelectionType::Entity && Selection.Entity == e)
@@ -767,9 +768,7 @@ namespace Nuake {
}
auto cursorPos = ImGui::GetCursorPos();
ImGui::SetNextItemAllowOverlap();
bool open = ImGui::TreeNodeEx(name.c_str(), base_flags);
if (m_IsRenaming)
@@ -904,6 +903,25 @@ namespace Nuake {
ImGui::TextColored(ImVec4(0.5, 0.5, 0.5, 1.0), GetEntityTypeName(e).c_str());
ImGui::TableNextColumn();
{
bool hasScript = e.HasComponent<NetScriptComponent>();
if (hasScript)
{
std::string scrollIcon = std::string(ICON_FA_SCROLL) + "##" + name;
ImGui::PushStyleColor(ImGuiCol_Button, { 0, 0, 0, 0 });
if (ImGui::Button(scrollIcon.c_str(), { 40, 0 }))
{
auto& scriptComponent = e.GetComponent<NetScriptComponent>();
if (!scriptComponent.ScriptPath.empty() && FileSystem::FileExists(scriptComponent.ScriptPath))
{
OS::OpenIn(FileSystem::RelativeToAbsolute(scriptComponent.ScriptPath));
}
}
ImGui::PopStyleColor();
}
}
ImGui::TableNextColumn();
{
bool& isVisible = e.GetComponent<VisibilityComponent>().Visible;
@@ -2139,10 +2157,11 @@ namespace Nuake {
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { 4, 4 });
if (ImGui::BeginChild("Scene tree", ImGui::GetContentRegionAvail(), false))
{
if (ImGui::BeginTable("entity_table", 3, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingStretchProp))
if (ImGui::BeginTable("entity_table", 4, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingStretchProp))
{
ImGui::TableSetupColumn(" Label", ImGuiTableColumnFlags_IndentEnable | ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_IndentDisable | ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("Script", ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentDisable | ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("Visibility ", ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentDisable | ImGuiTableColumnFlags_WidthFixed);
ImGui::TableHeadersRow();
@@ -2427,6 +2446,11 @@ namespace Nuake {
void EditorInterface::Overlay()
{
if (Engine::GetGameState() == GameState::Playing)
{
return;
}
// FIXME-VIEWPORT: Select a default viewport
const float DISTANCE = 10.0f;
int corner = 0;
@@ -3271,6 +3295,27 @@ namespace Nuake {
}
void EditorInterface::OnDragNDrop(const std::vector<std::string>& paths)
{
if (Engine::GetProject())
{
for (const auto& path : paths)
{
if (!FileSystem::FileExists(path, true))
{
continue;
}
if (!FileSystem::DirectoryExists(FileSystemUI::m_CurrentDirectory->GetFullPath(), true))
{
return;
}
FileSystem::CopyFileAbsolute(path, FileSystemUI::m_CurrentDirectory->GetFullPath());
}
}
}
bool EditorInterface::LoadProject(const std::string& projectPath)
{
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));

View File

@@ -106,5 +106,6 @@ namespace Nuake
public:
void OnWindowFocused();
void OnDragNDrop(const std::vector<std::string>& paths);
};
}

View File

@@ -261,6 +261,8 @@ namespace Nuake
OS::OpenTrenchbroomMap(file->GetAbsolutePath());
break;
case FileType::NetScript:
case FileType::UI:
case FileType::CSS:
OS::OpenIn(file->GetAbsolutePath());
break;
case FileType::Scene:
@@ -383,17 +385,30 @@ namespace Nuake
textureImage = image;
}
}
else if (fileType == FileType::Solution)
{
textureImage = textureMgr->GetTexture("Resources/Images/sln_icon.png");
}
else if (fileType == FileType::Map)
{
textureImage = textureMgr->GetTexture("Resources/Images/trenchbroom_icon.png");
}
ImGui::SetCursorPos(prevCursor);
ImGui::Image(reinterpret_cast<ImTextureID>(textureImage->GetID()), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
ImGui::PopStyleVar();
auto imguiStyle = ImGui::GetStyle();
auto& imguiStyle = ImGui::GetStyle();
ImVec2 startOffset = ImVec2(imguiStyle.CellPadding.x / 2.0f, 0);
ImVec2 offsetEnd = ImVec2(startOffset.x, imguiStyle.CellPadding.y / 2.0f);
ImU32 rectColor = IM_COL32(255, 255, 255, 16);
ImGui::GetWindowDrawList()->AddRectFilled(prevScreenPos + ImVec2(0, 100) - startOffset, prevScreenPos + ImVec2(100, 150) + offsetEnd, rectColor, 1.0f);
ImU32 rectColor2 = UI::PrimaryCol;
Color fileTypeColor = GetColorByFileType(file->GetFileType());
ImGui::GetWindowDrawList()->AddRectFilled(prevScreenPos + ImVec2(0, 100) - startOffset, prevScreenPos + ImVec2(100, 101) + offsetEnd, IM_COL32(fileTypeColor.r * 255.f, fileTypeColor.g * 255.f, fileTypeColor.b * 255.f, fileTypeColor.a * 255.f), 0.0f);
std::string visibleName = file->GetName();
const uint32_t MAX_CHAR_NAME = 32;
if (file->GetName().size() >= MAX_CHAR_NAME)
@@ -670,6 +685,57 @@ namespace Nuake
Scan();
}
Color FileSystemUI::GetColorByFileType(FileType fileType)
{
switch (fileType)
{
case Nuake::FileType::Unknown:
break;
case Nuake::FileType::Image:
break;
case Nuake::FileType::Material:
break;
case Nuake::FileType::Mesh:
break;
case Nuake::FileType::Script:
return { 1.0, 0.0, 0.0, 1.0 };
break;
case Nuake::FileType::NetScript:
return { 1.0, 0.0, 0.0, 1.0 };
break;
case Nuake::FileType::Project:
return Engine::GetProject()->Settings.PrimaryColor;
break;
case Nuake::FileType::Prefab:
break;
case Nuake::FileType::Scene:
return { 0, 1.0f, 1.0, 1.0 };
break;
case Nuake::FileType::Wad:
break;
case Nuake::FileType::Map:
return { 0.0, 1.0, 0.0, 1.0 };
break;
case Nuake::FileType::Assembly:
break;
case Nuake::FileType::Solution:
break;
case Nuake::FileType::Audio:
return { 0.0, 0.0, 1.0, 1.0 };
break;
case Nuake::FileType::UI:
return { 1.0, 1.0, 0.0, 1.0 };
break;
case Nuake::FileType::CSS:
return { 1.0, 0.0, 1.0, 1.0 };
break;
default:
break;
}
return Color(0, 0, 0, 0);
}
void FileSystemUI::Scan()
{
if (!m_CurrentDirectory)
@@ -888,6 +954,11 @@ namespace Nuake
{
for (Ref<Directory>& d : m_CurrentDirectory->Directories)
{
if (d->GetName() == "bin" || d->GetName() == ".vs" || d->GetName() == "obj")
{
continue;
}
if(String::Sanitize(d->Name).find(String::Sanitize(m_SearchKeyword)) != std::string::npos)
{
if (i + 1 % amount != 0)
@@ -907,6 +978,11 @@ namespace Nuake
{
if(m_SearchKeyword.empty() || f->GetName().find(String::Sanitize(m_SearchKeyword)) != std::string::npos)
{
if (f->GetFileType() == FileType::Unknown || f->GetFileType() == FileType::Assembly)
{
continue;
}
if (i + 1 % amount != 0 || i == 1)
{
ImGui::TableNextColumn();
@@ -915,7 +991,7 @@ namespace Nuake
{
ImGui::TableNextRow();
}
DrawFile(f, i);
i++;
}

View File

@@ -33,6 +33,8 @@ namespace Nuake {
void DrawContextMenu();
void RefreshFileBrowser();
Color GetColorByFileType(FileType fileType);
void Scan();
};
}

View File

@@ -240,7 +240,7 @@ std::vector<std::string> MapImporterWindow::ScanUsedWads()
std::string MapImporterWindow::GetTransformedWadPath(const std::string& path)
{
const std::string& baseTextureDir = "/textures/";
const std::string& baseTextureDir = "/Textures/";
using namespace Nuake;
if (m_WadToMaterialMap.find(path) != m_WadToMaterialMap.end())
@@ -285,7 +285,7 @@ std::string MapImporterWindow::GetTransformedWadPath(const std::string& path)
if (entry.is_regular_file() && stem == upperInput)
{
std::filesystem::path relativePath = std::filesystem::relative(entry.path(), FileSystem::Root + "/textures/");
std::filesystem::path relativePath = std::filesystem::relative(entry.path(), FileSystem::Root + "/Textures/");
std::filesystem::path pathWithoutExtension = relativePath;
pathWithoutExtension = pathWithoutExtension.parent_path(); // Remove the file name