/
EntityPropertyEditor.cpp
44 lines (34 loc) · 1.08 KB
/
EntityPropertyEditor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "EntityPropertyEditor.h"
#include "i18n.h"
#include "iscenegraph.h"
#include "iundo.h"
#include "ientity.h"
#include "PropertyEditorFactory.h"
#include <wx/panel.h>
#include <wx/button.h>
#include <wx/artprov.h>
#include <wx/sizer.h>
#include "ui/common/EntityChooser.h"
namespace ui
{
EntityPropertyEditor::EntityPropertyEditor(wxWindow* parent, IEntitySelection& entities, const ITargetKey::Ptr& key) :
PropertyEditor(entities),
_key(key)
{
constructBrowseButtonPanel(parent, _("Choose target entity..."),
PropertyEditorFactory::getBitmapFor("entity"));
}
void EntityPropertyEditor::onBrowseButtonClick()
{
// Use a new dialog window to get a selection from the user
auto previousValue = _entities.getSharedKeyValue(_key->getFullKey(), false);
std::string selection = EntityChooser::ChooseEntity(previousValue);
// Only apply non-empty selections if the value has actually changed
if (!selection.empty() && selection != previousValue)
{
UndoableCommand cmd("changeKeyValue");
// Apply the change
setKeyValue(_key->getFullKey(), selection);
}
}
} // namespace ui