/
TexturePropertyEditor.cpp
46 lines (36 loc) · 1.08 KB
/
TexturePropertyEditor.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
45
46
#include "TexturePropertyEditor.h"
#include "ui/materials/MaterialChooser.h"
#include "PropertyEditorFactory.h"
#include "i18n.h"
#include "ientity.h"
#include <wx/panel.h>
#include <wx/button.h>
#include <wx/sizer.h>
namespace ui
{
// Main constructor
TexturePropertyEditor::TexturePropertyEditor(wxWindow* parent, IEntitySelection& entities, const ITargetKey::Ptr& key)
: PropertyEditor(entities),
_key(key)
{
constructBrowseButtonPanel(parent, _("Choose texture..."),
PropertyEditorFactory::getBitmapFor("texture"));
}
// Browse button callback
void TexturePropertyEditor::onBrowseButtonClick()
{
auto dialog = new MaterialChooser(getWidget(), MaterialSelector::TextureFilter::Lights);
dialog->SetSelectedDeclName(getKeyValueFromSelection(_key->getFullKey()));
if (dialog->ShowModal() == wxID_OK)
{
// Return the last selection to calling process
std::string texture = dialog->GetSelectedDeclName();
if (!texture.empty())
{
// Apply the keyvalue immediately
setKeyValueOnSelection(_key->getFullKey(), texture);
}
}
dialog->Destroy();
}
} // namespace ui