Broken undo
This commit is contained in:
@@ -27,6 +27,7 @@ struct EntityWrapper
|
||||
bool HasComponent(const std::string& componentType);
|
||||
void AttachComponent(const char* componentName);
|
||||
EntityWrapper Parent();
|
||||
EntityWrapper BaseParent();
|
||||
EntityWrapper FirstChildByName(const std::string& name);
|
||||
EntityWrapper FirstParentWithComponent(const std::string& componentType);
|
||||
EntityWrapper Clone(EntityWrapper parent = EntityWrapper::Invalid);
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
World(const World& other);
|
||||
|
||||
// Create empty entity
|
||||
EntityID CreateEntity(EntityID parent = 0);
|
||||
EntityID CreateEntity(EntityID parent = EntityID_Invalid);
|
||||
// Delete entity and all components within
|
||||
void DeleteEntity(EntityID entity);
|
||||
// Check if an entity exists
|
||||
|
||||
@@ -91,7 +91,13 @@ public:
|
||||
// Called when the user selects a widget space.
|
||||
typedef std::function<void(WidgetSpace)> OnWidgetSpace_t;
|
||||
void SetWidgetSpaceCallback(OnWidgetSpace_t f) { m_OnWidgetSpace = f; }
|
||||
|
||||
// Called when anything is modified making the world dirty
|
||||
// @param EntityWrapper The entity that was changed and marked as dirty
|
||||
typedef std::function<void(EntityWrapper)> OnDirty_t;
|
||||
void SetDirtyCallback(OnDirty_t f) { m_OnDirty = f; }
|
||||
// Called when the user wishes to undo
|
||||
typedef std::function<void()> OnUndo_t;
|
||||
void SetUndoCallback(OnUndo_t f) { m_OnUndo = f; }
|
||||
private:
|
||||
World* m_World;
|
||||
EventBroker* m_EventBroker;
|
||||
@@ -132,6 +138,8 @@ private:
|
||||
OnWidgetMode_t m_OnWidgetMode = nullptr;
|
||||
OnWidgetSpace_t m_OnWidgetSpace = nullptr;
|
||||
OnEntityPaste_t m_OnEntityPaste = nullptr;
|
||||
OnDirty_t m_OnDirty = nullptr;
|
||||
OnUndo_t m_OnUndo = nullptr;
|
||||
|
||||
// Events
|
||||
EventRelay<EditorGUI, Events::KeyDown> m_EKeyDown;
|
||||
|
||||
@@ -36,6 +36,7 @@ private:
|
||||
EditorCameraInputController<EditorSystem>* m_EditorCameraInputController;
|
||||
EditorGUI* m_EditorGUI;
|
||||
EditorStats* m_EditorStats;
|
||||
std::vector<World> m_UndoLevels;
|
||||
|
||||
// State
|
||||
double m_LastTime = 0.f;
|
||||
@@ -44,6 +45,7 @@ private:
|
||||
EditorGUI::WidgetSpace m_WidgetSpace = EditorGUI::WidgetSpace::Global;
|
||||
EntityWrapper m_Widget = EntityWrapper::Invalid;
|
||||
EntityWrapper m_CurrentSelection = EntityWrapper::Invalid;
|
||||
bool m_SaveUndoLevel = false; // Only save undo state once per update
|
||||
|
||||
// Utility functions
|
||||
EntityWrapper importEntity(EntityWrapper parent, boost::filesystem::path filePath);
|
||||
@@ -60,6 +62,8 @@ private:
|
||||
void OnComponentAttach(EntityWrapper entity, const std::string& componentType);
|
||||
void OnComponentDelete(EntityWrapper entity, const std::string& componentType);
|
||||
void OnWidgetSpace(EditorGUI::WidgetSpace widgetSpace);
|
||||
void OnDirty(EntityWrapper entity);
|
||||
void OnUndo();
|
||||
|
||||
// Events
|
||||
EventRelay<EditorSystem, Events::MousePress> m_EMousePress;
|
||||
|
||||
Reference in New Issue
Block a user