Migrate ProjectManager to dependency injection
- Created IProjectManager interface - ProjectManager now implements IProjectManager - Removed ProjectManager::Get() singleton - Added IEditorContext::GetProjectManager() - ProjectPanel now uses m_context->GetProjectManager() instead of singleton - EditorContext owns ProjectManager instance
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "ProjectPanel.h"
|
||||
#include "Managers/ProjectManager.h"
|
||||
#include "Core/IEditorContext.h"
|
||||
#include "Core/IProjectManager.h"
|
||||
#include "Core/AssetItem.h"
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
@@ -13,7 +14,7 @@ ProjectPanel::ProjectPanel() : Panel("Project") {
|
||||
}
|
||||
|
||||
void ProjectPanel::Initialize(const std::string& projectPath) {
|
||||
ProjectManager::Get().Initialize(projectPath);
|
||||
m_context->GetProjectManager().Initialize(projectPath);
|
||||
}
|
||||
|
||||
void ProjectPanel::Render() {
|
||||
@@ -26,7 +27,7 @@ void ProjectPanel::Render() {
|
||||
|
||||
ImGui::Begin(m_name.c_str(), nullptr, ImGuiWindowFlags_None);
|
||||
|
||||
auto& manager = ProjectManager::Get();
|
||||
auto& manager = m_context->GetProjectManager();
|
||||
|
||||
bool canGoBack = manager.CanNavigateBack();
|
||||
ImGui::BeginDisabled(!canGoBack);
|
||||
@@ -160,7 +161,7 @@ void ProjectPanel::Render() {
|
||||
}
|
||||
|
||||
void ProjectPanel::RenderAssetItem(const AssetItemPtr& item, int index) {
|
||||
auto& manager = ProjectManager::Get();
|
||||
auto& manager = m_context->GetProjectManager();
|
||||
bool isSelected = (manager.GetSelectedIndex() == index);
|
||||
|
||||
ImGui::PushID(index);
|
||||
@@ -287,7 +288,7 @@ void ProjectPanel::RenderAssetItem(const AssetItemPtr& item, int index) {
|
||||
}
|
||||
|
||||
void ProjectPanel::CreateNewFolder(const std::string& name) {
|
||||
auto& manager = ProjectManager::Get();
|
||||
auto& manager = m_context->GetProjectManager();
|
||||
manager.CreateFolder(name);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user