MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / addFile

Method addFile

radiant/ui/common/ImageFilePopulator.cpp:44–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 {}
43
44 void addFile(const vfs::FileInfo& fileInfo)
45 {
46 const std::string ddsPrefix = "dds/";
47 std::string fullPath = fileInfo.fullPath();
48
49 // Sort into the tree and set the values
50 addPath(fullPath, [&](wxutil::TreeModel::Row& row, const std::string& path,
51 const std::string& leafName, bool isFolder)
52 {
53 // The map expressions don't need any file extensions
54 auto imageFilePath = os::removeExtension(path);
55
56 // Cut off the dds prefix, it won't be valid when set in a material
57 if (string::istarts_with(path, ddsPrefix))
58 {
59 imageFilePath = imageFilePath.substr(ddsPrefix.length());
60 }
61
62 bool isCubeMapTexture = false;
63
64 // For cubemaps, cut off the suffixes
65 if (string::istarts_with(imageFilePath, "env/"))
66 {
67 auto underscorePos = imageFilePath.find_last_of('_');
68
69 if (underscorePos != std::string::npos)
70 {
71 auto suffix = imageFilePath.substr(underscorePos);
72 string::to_lower(suffix);
73
74 if (_cubemapSuffixes.count(suffix) != 0)
75 {
76 imageFilePath = imageFilePath.substr(0, imageFilePath.length() - suffix.length());
77 isCubeMapTexture = true;
78 }
79 }
80 }
81
82 row[_columns.iconAndName] = wxVariant(wxDataViewIconText(leafName, isFolder ? _folderIcon : _fileIcon));
83 row[_columns.leafName] = leafName;
84 row[_columns.fullName] = imageFilePath;
85 row[_columns.isFolder] = isFolder;
86 row[_columns.isFavourite] = false;
87 row[_columns.isCubeMapTexture] = isCubeMapTexture;
88
89 row.SendItemAdded();
90 });
91 }
92};
93
94ImageFilePopulator::ImageFilePopulator(const ImageFileSelector::Columns& columns) :

Callers 1

PopulateModelMethod · 0.80

Calls 7

removeExtensionFunction · 0.85
istarts_withFunction · 0.85
to_lowerFunction · 0.85
fullPathMethod · 0.80
lengthMethod · 0.80
SendItemAddedMethod · 0.80
countMethod · 0.45

Tested by

no test coverage detected