From 6f24b32612e71ffcf8fe60ddd03374e18eb2baa2 Mon Sep 17 00:00:00 2001 From: codereader Date: Sun, 5 Jan 2020 05:08:35 +0100 Subject: [PATCH] #5091: Add "Choose skin" button to model property editor for user convenience. --- radiant/ui/einspector/ModelPropertyEditor.cpp | 21 +++++++++++++++++-- radiant/ui/einspector/ModelPropertyEditor.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/radiant/ui/einspector/ModelPropertyEditor.cpp b/radiant/ui/einspector/ModelPropertyEditor.cpp index fac2b576da..51616dea35 100644 --- a/radiant/ui/einspector/ModelPropertyEditor.cpp +++ b/radiant/ui/einspector/ModelPropertyEditor.cpp @@ -16,6 +16,8 @@ #include #include +#include "SkinChooser.h" + namespace ui { @@ -39,16 +41,21 @@ ModelPropertyEditor::ModelPropertyEditor(wxWindow* parent, Entity* entity, // Browse button for models wxButton* browseButton = new wxButton(mainVBox, wxID_ANY, _("Choose model...")); browseButton->SetBitmap(PropertyEditorFactory::getBitmapFor("model")); - browseButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(ModelPropertyEditor::_onModelButton), NULL, this); + browseButton->Bind(wxEVT_BUTTON, &ModelPropertyEditor::_onModelButton, this); + + wxButton* skinButton = new wxButton(mainVBox, wxID_ANY, _("Choose skin...")); + skinButton->SetBitmap(PropertyEditorFactory::getBitmapFor("skin")); + skinButton->Bind(wxEVT_BUTTON, &ModelPropertyEditor::_onSkinButton, this); // Browse button for particles wxButton* particleButton = new wxButton(mainVBox, wxID_ANY, _("Choose particle...")); particleButton->SetBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "particle16.png")); - particleButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(ModelPropertyEditor::_onParticleButton), NULL, this); + particleButton->Bind(wxEVT_BUTTON, &ModelPropertyEditor::_onParticleButton, this); // The panel will use the entire height of the editor frame in the entity inspector // use vertical centering to position it in the middle mainVBox->GetSizer()->Add(browseButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6); + mainVBox->GetSizer()->Add(skinButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6); mainVBox->GetSizer()->Add(particleButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6); } @@ -103,5 +110,15 @@ void ModelPropertyEditor::_onParticleButton(wxCommandEvent& ev) } } +void ModelPropertyEditor::_onSkinButton(wxCommandEvent& ev) +{ + // Display the SkinChooser to get a skin from the user + std::string modelName = _entity->getKeyValue("model"); + std::string prevSkin = _entity->getKeyValue(_key); + std::string skin = SkinChooser::chooseSkin(modelName, prevSkin); + + // Apply the key to the entity + setKeyValue("skin", skin); +} } diff --git a/radiant/ui/einspector/ModelPropertyEditor.h b/radiant/ui/einspector/ModelPropertyEditor.h index ff8cf681e0..e1fed10f8b 100644 --- a/radiant/ui/einspector/ModelPropertyEditor.h +++ b/radiant/ui/einspector/ModelPropertyEditor.h @@ -21,6 +21,7 @@ class ModelPropertyEditor : private: void _onModelButton(wxCommandEvent& ev); + void _onSkinButton(wxCommandEvent& ev); void _onParticleButton(wxCommandEvent& ev); public: