Skip to content

Commit

Permalink
#5482: Add separate folder in ModelSelector containing the modelDef d…
Browse files Browse the repository at this point in the history
…eclarations
  • Loading branch information
codereader committed Jan 5, 2021
1 parent 7962a67 commit b1340f3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
4 changes: 1 addition & 3 deletions radiant/ui/modelselector/ModelDataInserter.h
Expand Up @@ -18,8 +18,6 @@ namespace
const char* MODEL_ICON = "model16green.png";
const char* SKIN_ICON = "skin16.png";
const char* FOLDER_ICON = "folder16.png";

const char* MODELS_FOLDER = "models/";
}

/**
Expand Down Expand Up @@ -69,7 +67,7 @@ class ModelDataInserter :
std::string displayName = path.substr(path.rfind("/") + 1);

// Pathname is the model VFS name for a model, and blank for a folder
std::string fullPath = isExplicit ? (MODELS_FOLDER + path) : "";
std::string fullPath = isExplicit ? path : "";

bool isFavourite = isExplicit && _favourites.count(fullPath) > 0;

Expand Down
32 changes: 31 additions & 1 deletion radiant/ui/modelselector/ModelPopulator.h
Expand Up @@ -7,6 +7,7 @@
#include "EventRateLimiter.h"

#include "ifilesystem.h"
#include "ieclass.h"
#include "i18n.h"
#include "string/string.h"
#include "os/path.h"
Expand Down Expand Up @@ -63,6 +64,7 @@ class ModelPopulator final :
void PopulateModel(const wxutil::TreeModel::Ptr& model) override
{
wxutil::VFSTreePopulator populator(model);
constexpr const char* MODELS_FOLDER = "models/";

// Search for model files
GlobalFileSystem().forEachFile(
Expand All @@ -72,19 +74,47 @@ class ModelPopulator final :
// Only add visible models
if (fileInfo.visibility == vfs::Visibility::NORMAL)
{
visitModelFile(fileInfo.name, populator);
visitModelFile(MODELS_FOLDER + fileInfo.name, populator);
}
},
0
);

ThrowIfCancellationRequested();

// Model Defs Folder
wxIcon folderIcon;
folderIcon.CopyFromBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + FOLDER_ICON));

reportProgress(_("Building tree..."));

// Fill in the column data (TRUE = including skins)
ModelDataInserter inserterSkins(_columns, true);
populator.forEachNode(inserterSkins);

reportProgress(_("Adding Model Definitions..."));

// Model Defs
wxutil::TreeModel::Row modelDefs(model->AddItem());
modelDefs[_columns.iconAndName] = wxVariant(wxDataViewIconText(_("Model Definitions"), folderIcon));
modelDefs[_columns.fullName] = _("Model Definitions");
modelDefs[_columns.modelPath] = "";
modelDefs[_columns.leafName] = _("Model Definitions");
modelDefs[_columns.skin] = std::string();
modelDefs[_columns.isSkin] = false;
modelDefs[_columns.isFolder] = true;
modelDefs[_columns.isFavourite] = false;
modelDefs.SendItemAdded();

wxutil::VFSTreePopulator modelDefPopulator(model, modelDefs.getItem());

GlobalEntityClassManager().forEachModelDef([&](const IModelDefPtr& def)
{
ThrowIfCancellationRequested();
modelDefPopulator.addPath(def->name);
});

modelDefPopulator.forEachNode(inserterSkins);
}

void SortModel(const wxutil::TreeModel::Ptr& model) override
Expand Down

0 comments on commit b1340f3

Please sign in to comment.