Skip to content

Commit

Permalink
#5727: Entries in the "All Skins" subtree didn't have their full path…
Browse files Browse the repository at this point in the history
… set in the corresponding tree model column.

Add DeclFileInfo element to SkinChooser.
  • Loading branch information
codereader committed Jun 16, 2022
1 parent 05f5e5a commit f404615
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/wxutil/DeclFileInfo.h
Expand Up @@ -30,7 +30,7 @@ class DeclFileInfo :

auto sizer = new wxBoxSizer(wxHORIZONTAL);

sizer->Add(new wxStaticText(this, wxID_ANY, decl::getTypeName(declType)), 0, wxALIGN_CENTER_VERTICAL, 0);
sizer->Add(new wxStaticText(this, wxID_ANY, decl::getTypeName(declType) + " "), 0, wxALIGN_CENTER_VERTICAL, 0);
sizer->Add(_nameLabel, 0, wxALIGN_CENTER_VERTICAL, 0);
sizer->Add(new wxStaticText(this, wxID_ANY, _(" defined in ")), 0, wxALIGN_CENTER_VERTICAL, 0);
sizer->Add(_fileLabel, 0, wxALIGN_CENTER_VERTICAL, 0);
Expand Down
24 changes: 21 additions & 3 deletions radiant/ui/einspector/SkinChooser.cpp
Expand Up @@ -31,6 +31,7 @@ SkinChooser::SkinChooser() :
_treeStore(new wxutil::TreeModel(_columns)),
_treeView(nullptr),
_materialsList(nullptr),
_fileInfo(nullptr),
_lastSkin("")
{
FitToScreen(0.6f, 0.6f);
Expand Down Expand Up @@ -100,13 +101,16 @@ void SkinChooser::populateWindow()
sigc::mem_fun(*_preview, &wxutil::ModelPreview::queueDraw)
);

_fileInfo = new wxutil::DeclFileInfo(leftPanel, decl::Type::Skin);

leftPanel->GetSizer()->Add(_treeView, 1, wxEXPAND);
leftPanel->GetSizer()->Add(_fileInfo, 0, wxEXPAND | wxTOP, 6);
leftPanel->GetSizer()->Add(_materialsList, 0, wxEXPAND | wxTOP, 6);

// Pack treeview and preview
splitter->SplitVertically(leftPanel, _preview->getWidget());

FitToScreen(0.6f, 0.8f);
FitToScreen(0.8f, 0.8f);

// Set the default size of the window
splitter->SetSashPosition(static_cast<int>(GetSize().GetWidth() * 0.3f));
Expand Down Expand Up @@ -224,7 +228,7 @@ void SkinChooser::populateSkins()

row[_columns.displayName] = wxVariant(wxDataViewIconText(displayPath,
!isFolder ? skinIcon : folderIcon));
row[_columns.fullName] = leafName;
row[_columns.fullName] = path;
row[_columns.isFolder] = isFolder;
});
}
Expand Down Expand Up @@ -303,9 +307,23 @@ void SkinChooser::onMainFrameShuttingDown()

void SkinChooser::handleSelectionChange()
{
auto selectedSkin = getSelectedSkin();

// Set the model preview to show the model with the selected skin
_preview->setModel(_model);
_preview->setSkin(getSelectedSkin());
_preview->setSkin(selectedSkin);

if (!selectedSkin.empty())
{
_fileInfo->setName(selectedSkin);
auto& skin = GlobalModelSkinCache().capture(selectedSkin);
_fileInfo->setPath(skin.getSkinFileName());
}
else
{
_fileInfo->setName("-");
_fileInfo->setPath("-");
}

updateMaterialsList();
}
Expand Down
3 changes: 3 additions & 0 deletions radiant/ui/einspector/SkinChooser.h
Expand Up @@ -8,6 +8,7 @@

#include "wxutil/dialog/DialogBase.h"
#include "wxutil/preview/ModelPreview.h"
#include "wxutil/DeclFileInfo.h"
#include <string>

#include "wxutil/dataview/TreeModel.h"
Expand Down Expand Up @@ -52,6 +53,8 @@ class SkinChooser :
wxutil::TreeView* _treeView;
MaterialsList* _materialsList;

wxutil::DeclFileInfo* _fileInfo;

// The model name to use for skin matching
std::string _model;

Expand Down

0 comments on commit f404615

Please sign in to comment.