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);
            }
        }
예제 #2
0
void Console::logToFile(const LogMessage& message) {
#if defined __APPLE__
    NSLogWrapper(message.string());
#else
    IO::FileManager fileManager;
    const String logDirectory = fileManager.logDirectory();
    if (logDirectory.empty())
        return;
    if (!fileManager.exists(logDirectory))
        fileManager.makeDirectory(logDirectory);
    const String logFilePath = fileManager.appendPath(logDirectory, "TrenchBroom.log");
    std::fstream logStream(logFilePath.c_str(), std::ios::out | std::ios::app);
    if (logStream.is_open()) {
        wxDateTime now = wxDateTime::Now();
        logStream << wxGetProcessId() << " " << now.FormatISOCombined(' ') << ": " << message.string() << std::endl;
    }
#endif
}