// // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved // LICENSE: Atomic Game Engine Editor and Tools EULA // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for // license information: https://github.com/AtomicGameEngine/AtomicGameEngine // #pragma once #include #include namespace Atomic { class Node; class Component; } using namespace Atomic; namespace AtomicEditor { enum SceneEditType { SCENEEDIT_UNKNOWN = 0, SCENEEDIT_SELECTION }; class SceneEditOp { public: SceneEditOp(Scene* scene, SceneEditType type) { type_ = type; scene_ = scene;} virtual ~SceneEditOp() { } virtual bool Undo() = 0; virtual bool Redo() = 0; /// Returns true if the states are identical bool CompareStates(const VectorBuffer& stateOne, const VectorBuffer& stateTwo) const { if (stateOne.GetSize() != stateTwo.GetSize()) return false; if (memcmp(stateOne.GetData(), stateTwo.GetData(), stateOne.GetSize())) return false; return true; } SharedPtr scene_; SceneEditType type_; }; class SelectionEditOp : public SceneEditOp { public: SelectionEditOp(Scene* scene); ~SelectionEditOp(); bool Undo(); bool Redo(); void RegisterEdit(); void SetNodes(Vector>& nodes); void AddNode(Node* node); void NodeAdded(Node* node, Node* parent); void NodeRemoved(Node* node, Node* parent); bool Commit(); private: struct EditComponent { SharedPtr component_; SharedPtr nodeBegin_; SharedPtr nodeEnd_; VectorBuffer stateBegin_; VectorBuffer stateEnd_; }; struct EditNode { SharedPtr node_; SharedPtr parentBegin_; SharedPtr parentEnd_; VectorBuffer stateBegin_; VectorBuffer stateEnd_; PODVector components_; }; PODVector editNodes_; }; }