void MapPropertiesDialog::populateModChoice(const String& mod) {
            m_modChoice->Clear();

            IO::FileManager fileManager;
            Preferences::PreferenceManager& prefs = Preferences::PreferenceManager::preferences();
            const String& quakePath = prefs.getString(Preferences::QuakePath);
            if (fileManager.exists(quakePath) && fileManager.isDirectory(quakePath)) {
                const StringList modDirs = fileManager.directoryContents(quakePath, "", true, false);

                int id1Index = -1;
                int selectionIndex = -1;
                for (size_t i = 0; i < modDirs.size(); i++) {
                    const String& item = modDirs[i];
                    m_modChoice->Append(item);
                    if (Utility::equalsString(item, "id1", false))
                        id1Index = static_cast<int>(i);
                    if (Utility::equalsString(item, mod, false))
                        selectionIndex = static_cast<int>(i);
                }

                if (selectionIndex == -1)
                    selectionIndex = id1Index;
                m_modChoice->SetSelection(selectionIndex);
            }
        }
Ejemplo n.º 2
0
 StringList EntityDefinitionManager::builtinDefinitionFiles() {
     StringList result;
     
     IO::FileManager fileManager;
     const String resourcePath = fileManager.resourceDirectory();
     const String defPath = fileManager.appendPathComponent(resourcePath, "Defs");
     
     const StringList defFiles = fileManager.directoryContents(defPath, "def");
     const StringList fgdFiles = fileManager.directoryContents(defPath, "fgd");
     
     result.insert(result.end(), defFiles.begin(), defFiles.end());
     result.insert(result.end(), fgdFiles.begin(), fgdFiles.end());
     
     std::sort(result.begin(), result.end());
     return result;
 }