Skip to content

Commit

Permalink
#5091: Add "Choose skin" button to model property editor for user con…
Browse files Browse the repository at this point in the history
…venience.
  • Loading branch information
codereader committed Jan 5, 2020
1 parent 12f38b3 commit 6f24b32
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
21 changes: 19 additions & 2 deletions radiant/ui/einspector/ModelPropertyEditor.cpp
Expand Up @@ -16,6 +16,8 @@
#include <wx/artprov.h>
#include <wx/sizer.h>

#include "SkinChooser.h"

namespace ui
{

Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}

}
1 change: 1 addition & 0 deletions radiant/ui/einspector/ModelPropertyEditor.h
Expand Up @@ -21,6 +21,7 @@ class ModelPropertyEditor :
private:

void _onModelButton(wxCommandEvent& ev);
void _onSkinButton(wxCommandEvent& ev);
void _onParticleButton(wxCommandEvent& ev);

public:
Expand Down

0 comments on commit 6f24b32

Please sign in to comment.