/
SoundPropertyEditor.cpp
44 lines (35 loc) · 1.06 KB
/
SoundPropertyEditor.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 "SoundPropertyEditor.h"
#include "PropertyEditorFactory.h"
#include "ui/iresourcechooser.h"
#include "ui/idialogmanager.h"
#include "i18n.h"
#include "ientity.h"
#include <wx/panel.h>
#include <wx/button.h>
#include <wx/sizer.h>
namespace ui
{
// Main constructor
SoundPropertyEditor::SoundPropertyEditor(wxWindow* parent, IEntitySelection& entities,
const std::string& name,
const std::string& options)
: PropertyEditor(entities),
_key(name)
{
constructBrowseButtonPanel(parent, _("Choose sound..."),
PropertyEditorFactory::getBitmapFor("sound"));
}
void SoundPropertyEditor::onBrowseButtonClick()
{
IResourceChooser* chooser = GlobalDialogManager().createSoundShaderChooser(wxGetTopLevelParent(getWidget()));
// Use a SoundChooser dialog to get a selection from the user
std::string picked = chooser->chooseResource(getKeyValue(_key));
// Selection will be empy if user clicked cancel or X
if (!picked.empty())
{
// Apply the change to the entity
setKeyValue(_key, picked);
}
chooser->destroyDialog();
}
} // namespace ui