MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / Execute

Method Execute

Engine/source/platform/nativeDialogs/fileDialog.cpp:191–324  ·  view source on GitHub ↗

Execute Method

Source from the content-addressed store, hash-verified

189// Execute Method
190//
191bool FileDialog::Execute()
192{
193 String strippedFilters;
194
195 U32 filtersCount = StringUnit::getUnitCount(mData.mFilters, "|");
196
197 for (U32 i = 1; i < filtersCount; ++i)
198 {
199 //The first of each pair is the name, which we'll skip because NFD doesn't support named filters atm
200 String filter = StringUnit::getUnit(mData.mFilters, i, "|");
201
202 if (!String::compare(filter.c_str(), "*.*"))
203 continue;
204
205 U32 subFilterCount = StringUnit::getUnitCount(filter, ";");
206
207 //if we have a 'super filter', break it down to sub-options as well
208 if (subFilterCount > 1)
209 {
210 String suffixFilter;
211 String subFilters;
212
213 for (U32 f = 0; f < subFilterCount; ++f)
214 {
215 String subFilter = StringUnit::getUnit(filter, f, ";");
216
217 suffixFilter += String::ToLower(subFilter) + "," + String::ToUpper(subFilter) + ",";
218 subFilters += String::ToLower(subFilter) + "," + String::ToUpper(subFilter) + ";";
219 }
220
221 suffixFilter = suffixFilter.substr(0, suffixFilter.length() - 1);
222 suffixFilter += ";";
223
224 strippedFilters += suffixFilter + subFilters;
225 }
226 else //otherwise, just add the filter
227 {
228 strippedFilters += String::ToLower(filter) + "," + String::ToUpper(filter) + ";";
229 }
230
231 ++i;
232 if (i < filtersCount - 2)
233 strippedFilters += String(";");
234 }
235
236 //strip the last character, if it's unneeded
237 if (strippedFilters.endsWith(";"))
238 {
239 strippedFilters = strippedFilters.substr(0, strippedFilters.length() - 1);
240 }
241
242 strippedFilters.replace("*.", "");
243
244 // Get the current working directory, so we can back up to it once Windows has
245 // done its craziness and messed with it.
246 StringTableEntry cwd = Platform::getCurrentDirectory();
247 if (mData.mDefaultPath == StringTable->lookup("") || !Platform::isDirectory(mData.mDefaultPath))
248 mData.mDefaultPath = cwd;

Callers 2

fileDialog.cppFile · 0.45
handleCommandLineMethod · 0.45

Calls 15

getUnitCountFunction · 0.85
getUnitFunction · 0.85
compareFunction · 0.85
NFD_GetErrorFunction · 0.85
getReturnBufferFunction · 0.85
NFD_PathSet_GetCountFunction · 0.85
NFD_PathSet_GetPathFunction · 0.85
getIntArgFunction · 0.85
substrMethod · 0.80
endsWithMethod · 0.80
replaceMethod · 0.80
ToLowerFunction · 0.50

Tested by

no test coverage detected