Fix editor scene persistence and XC scene workflow
This commit is contained in:
@@ -3,14 +3,22 @@
|
||||
namespace XCEngine {
|
||||
namespace Debug {
|
||||
|
||||
EditorConsoleSink* EditorConsoleSink::s_instance = nullptr;
|
||||
|
||||
EditorConsoleSink* EditorConsoleSink::GetInstance() {
|
||||
static EditorConsoleSink instance;
|
||||
return &instance;
|
||||
static EditorConsoleSink fallbackInstance;
|
||||
return s_instance ? s_instance : &fallbackInstance;
|
||||
}
|
||||
|
||||
EditorConsoleSink::EditorConsoleSink() = default;
|
||||
EditorConsoleSink::EditorConsoleSink() {
|
||||
s_instance = this;
|
||||
}
|
||||
|
||||
EditorConsoleSink::~EditorConsoleSink() = default;
|
||||
EditorConsoleSink::~EditorConsoleSink() {
|
||||
if (s_instance == this) {
|
||||
s_instance = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void EditorConsoleSink::Log(const LogEntry& entry) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
@@ -26,7 +34,8 @@ void EditorConsoleSink::Log(const LogEntry& entry) {
|
||||
void EditorConsoleSink::Flush() {
|
||||
}
|
||||
|
||||
const std::vector<LogEntry>& EditorConsoleSink::GetLogs() const {
|
||||
std::vector<LogEntry> EditorConsoleSink::GetLogs() const {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
return m_logs;
|
||||
}
|
||||
|
||||
@@ -40,4 +49,4 @@ void EditorConsoleSink::SetCallback(std::function<void()> callback) {
|
||||
}
|
||||
|
||||
} // namespace Debug
|
||||
} // namespace XCEngine
|
||||
} // namespace XCEngine
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
void Log(const LogEntry& entry) override;
|
||||
void Flush() override;
|
||||
|
||||
const std::vector<LogEntry>& GetLogs() const;
|
||||
std::vector<LogEntry> GetLogs() const;
|
||||
void Clear();
|
||||
void SetCallback(std::function<void()> callback);
|
||||
|
||||
@@ -27,8 +27,9 @@ private:
|
||||
mutable std::mutex m_mutex;
|
||||
std::vector<LogEntry> m_logs;
|
||||
std::function<void()> m_callback;
|
||||
static EditorConsoleSink* s_instance;
|
||||
static constexpr size_t MAX_LOGS = 1000;
|
||||
};
|
||||
|
||||
} // namespace Debug
|
||||
} // namespace XCEngine
|
||||
} // namespace XCEngine
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
EditorContext()
|
||||
: m_eventBus(std::make_unique<EventBus>())
|
||||
, m_selectionManager(std::make_unique<SelectionManager>(*m_eventBus))
|
||||
, m_sceneManager(std::make_unique<SceneManager>())
|
||||
, m_sceneManager(std::make_unique<SceneManager>(m_eventBus.get()))
|
||||
, m_projectManager(std::make_unique<ProjectManager>()) {
|
||||
|
||||
m_entityDeletedHandlerId = m_eventBus->Subscribe<EntityDeletedEvent>([this](const EntityDeletedEvent& event) {
|
||||
|
||||
@@ -6,24 +6,30 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Editor {
|
||||
|
||||
template<typename T>
|
||||
struct EventTypeId {
|
||||
static uint32_t Get() {
|
||||
static const uint32_t id = s_nextId++;
|
||||
return id;
|
||||
class EventTypeRegistry {
|
||||
public:
|
||||
static uint32_t NextId() {
|
||||
return s_nextId.fetch_add(1, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
private:
|
||||
static uint32_t s_nextId;
|
||||
inline static std::atomic<uint32_t> s_nextId{0};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
uint32_t EventTypeId<T>::s_nextId = 0;
|
||||
struct EventTypeId {
|
||||
static uint32_t Get() {
|
||||
static const uint32_t id = EventTypeRegistry::NextId();
|
||||
return id;
|
||||
}
|
||||
};
|
||||
|
||||
class EventBus {
|
||||
public:
|
||||
|
||||
@@ -22,8 +22,18 @@ public:
|
||||
virtual ::XCEngine::Components::GameObject::ID DuplicateEntity(::XCEngine::Components::GameObject::ID id) = 0;
|
||||
virtual void MoveEntity(::XCEngine::Components::GameObject::ID id, ::XCEngine::Components::GameObject::ID newParent) = 0;
|
||||
virtual bool HasClipboardData() const = 0;
|
||||
virtual void NewScene(const std::string& name = "Untitled Scene") = 0;
|
||||
virtual bool LoadScene(const std::string& filePath) = 0;
|
||||
virtual bool SaveScene() = 0;
|
||||
virtual bool SaveSceneAs(const std::string& filePath) = 0;
|
||||
virtual bool LoadStartupScene(const std::string& projectPath) = 0;
|
||||
virtual bool HasActiveScene() const = 0;
|
||||
virtual bool IsSceneDirty() const = 0;
|
||||
virtual void MarkSceneDirty() = 0;
|
||||
virtual const std::string& GetCurrentScenePath() const = 0;
|
||||
virtual const std::string& GetCurrentSceneName() const = 0;
|
||||
virtual void CreateDemoScene() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user