mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Automatically refresh filebrowser on window focus, and preserve path after scanning
This commit is contained in:
@@ -45,6 +45,32 @@ void EditorApplication::OnInit()
|
||||
}
|
||||
}
|
||||
|
||||
m_Window->SetOnWindowFocusedCallback([&](Window& window, bool focused)
|
||||
{
|
||||
if (!focused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& layer : m_LayerStack)
|
||||
{
|
||||
layer->OnWindowFocused();
|
||||
}
|
||||
});
|
||||
|
||||
m_Window->SetOnWindowClosedCallback([](Window& window)
|
||||
{
|
||||
if (Engine::GetProject())
|
||||
{
|
||||
Engine::GetProject()->Save();
|
||||
}
|
||||
|
||||
if (Engine::GetCurrentScene())
|
||||
{
|
||||
Engine::GetCurrentScene()->Save();
|
||||
}
|
||||
});
|
||||
|
||||
PushLayer(CreateScope<EditorLayer>());
|
||||
}
|
||||
|
||||
|
||||
@@ -75,4 +75,9 @@ void EditorLayer::OnUpdate()
|
||||
void EditorLayer::OnDetach()
|
||||
{
|
||||
delete m_EditorInterface;
|
||||
}
|
||||
|
||||
void EditorLayer::OnWindowFocused()
|
||||
{
|
||||
m_EditorInterface->OnWindowFocused();
|
||||
}
|
||||
@@ -22,6 +22,8 @@ public:
|
||||
virtual void OnUpdate() override;
|
||||
virtual void OnDetach() override;
|
||||
|
||||
virtual void OnWindowFocused() override;
|
||||
|
||||
private:
|
||||
CommandBuffer mCommandBuffer;
|
||||
Nuake::EditorInterface* m_EditorInterface;
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "../Actions/EditorSelection.h"
|
||||
#include "FileSystemUI.h"
|
||||
|
||||
#include <src/FileSystem/Directory.h>
|
||||
|
||||
#include "../Misc/InterfaceFonts.h"
|
||||
|
||||
#include "WelcomeWindow.h"
|
||||
@@ -3177,6 +3179,12 @@ namespace Nuake {
|
||||
mCommandBuffer->PushCommand(command);
|
||||
}
|
||||
|
||||
void EditorInterface::OnWindowFocused()
|
||||
{
|
||||
filesystem->Scan();
|
||||
|
||||
}
|
||||
|
||||
bool EditorInterface::LoadProject(const std::string& projectPath)
|
||||
{
|
||||
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));
|
||||
|
||||
@@ -102,5 +102,8 @@ namespace Nuake
|
||||
public:
|
||||
std::string GetEntityTypeName(const Entity& entity) const;
|
||||
static void PushCommand(ICommand&& command);
|
||||
|
||||
public:
|
||||
void OnWindowFocused();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -694,8 +694,28 @@ namespace Nuake
|
||||
|
||||
void FileSystemUI::RefreshFileBrowser()
|
||||
{
|
||||
Scan();
|
||||
}
|
||||
|
||||
void FileSystemUI::Scan()
|
||||
{
|
||||
if (!m_CurrentDirectory)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::string previousPath = m_CurrentDirectory->FullPath;
|
||||
|
||||
FileSystem::Scan();
|
||||
m_CurrentDirectory = FileSystem::RootDirectory;
|
||||
|
||||
if (FileSystem::DirectoryExists(previousPath, true))
|
||||
{
|
||||
m_CurrentDirectory = FileSystem::GetDirectory(FileSystem::AbsoluteToRelative(previousPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CurrentDirectory = FileSystem::RootDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
float h = 200;
|
||||
|
||||
@@ -32,5 +32,7 @@ namespace Nuake {
|
||||
bool DeletePopup();
|
||||
void DrawContextMenu();
|
||||
void RefreshFileBrowser();
|
||||
|
||||
void Scan();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user