feat: add editor project switching workflow
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "Application.h"
|
||||
#include "Core/EditorLoggingSetup.h"
|
||||
#include "Core/ProjectRootResolver.h"
|
||||
#include "Core/EditorWindowTitle.h"
|
||||
#include "Layers/EditorLayer.h"
|
||||
#include "Core/EditorContext.h"
|
||||
@@ -8,6 +9,7 @@
|
||||
#include "UI/BuiltInIcons.h"
|
||||
#include "Platform/Win32Utf8.h"
|
||||
#include "Platform/WindowsProcessDiagnostics.h"
|
||||
#include <XCEngine/Debug/Logger.h>
|
||||
#include <windows.h>
|
||||
|
||||
namespace XCEngine {
|
||||
@@ -105,13 +107,25 @@ bool Application::Initialize(HWND hwnd) {
|
||||
const std::string exeDir = Platform::GetExecutableDirectoryUtf8();
|
||||
ConfigureEditorLogging(exeDir);
|
||||
|
||||
const std::string projectRoot = ResolveEditorProjectRootUtf8();
|
||||
const bool workingDirectoryChanged = SetEditorWorkingDirectory(projectRoot);
|
||||
|
||||
auto& logger = Debug::Logger::Get();
|
||||
const std::string projectRootMessage = "Editor project root: " + projectRoot;
|
||||
logger.Info(Debug::LogCategory::General, projectRootMessage.c_str());
|
||||
|
||||
if (!workingDirectoryChanged) {
|
||||
const std::string warningMessage = "Failed to switch editor working directory to project root: " + projectRoot;
|
||||
logger.Warning(Debug::LogCategory::General, warningMessage.c_str());
|
||||
}
|
||||
|
||||
m_hwnd = hwnd;
|
||||
|
||||
if (!InitializeWindowRenderer(hwnd)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
InitializeEditorContext(exeDir);
|
||||
InitializeEditorContext(projectRoot);
|
||||
InitializeImGui(hwnd);
|
||||
AttachEditorLayer();
|
||||
m_renderReady = true;
|
||||
@@ -151,5 +165,31 @@ void Application::OnResize(int width, int height) {
|
||||
m_windowRenderer.Resize(width, height);
|
||||
}
|
||||
|
||||
bool Application::SwitchProject(const std::string& projectPath) {
|
||||
if (!m_editorContext || projectPath.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_imguiSession.SetProjectPath(projectPath);
|
||||
m_editorContext->SetProjectPath(projectPath);
|
||||
|
||||
auto& logger = Debug::Logger::Get();
|
||||
if (!SetEditorWorkingDirectory(projectPath)) {
|
||||
const std::string warningMessage = "Failed to switch editor working directory to project root: " + projectPath;
|
||||
logger.Warning(Debug::LogCategory::General, warningMessage.c_str());
|
||||
}
|
||||
|
||||
const std::string infoMessage = "Switched editor project root: " + projectPath;
|
||||
logger.Info(Debug::LogCategory::General, infoMessage.c_str());
|
||||
|
||||
m_lastWindowTitle.clear();
|
||||
UpdateWindowTitle();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Application::SaveProjectState() {
|
||||
m_imguiSession.SaveSettings();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user