Skip to content

Commit

Permalink
#6303: Add/delete conversation entity commands are now undable
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jan 13, 2024
1 parent 1fa67ff commit cd0675d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 3 additions & 1 deletion plugins/dm.conversation/ConversationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,13 @@ void ConversationDialog::onAddEntity(wxCommandEvent& ev)

if (eclass)
{
UndoableCommand addEntityCommand("addConversationEntity");

// Construct a Node of this entity type
IEntityNodePtr node(GlobalEntityModule().createEntity(eclass));

// Create a random offset
node->getEntity().setKeyValue(
node->getEntity().setKeyValue(
"origin", RandomOrigin::generate(128)
);

Expand Down
17 changes: 10 additions & 7 deletions plugins/dm.conversation/ConversationEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "i18n.h"
#include "itextstream.h"
#include "ientity.h"
#include "iundo.h"

#include "string/convert.h"

Expand All @@ -28,15 +29,17 @@ ConversationEntity::ConversationEntity(const scene::INodePtr& node) :
}

// Delete the entity's world node
void ConversationEntity::deleteWorldNode()
void ConversationEntity::deleteWorldNode()
{
// Try to convert the weak_ptr reference to a shared_ptr
scene::INodePtr node = _entityNode.lock();
UndoableCommand deleteCommand("removeConversationEntity");

if (node && node->getParent())
{
node->getParent()->removeChildNode(node);
}
// Try to convert the weak_ptr reference to a shared_ptr
auto node = _entityNode.lock();

if (node && node->getParent())
{
node->getParent()->removeChildNode(node);
}
}

int ConversationEntity::getHighestIndex()
Expand Down

0 comments on commit cd0675d

Please sign in to comment.