void iwSaveLoad::RefreshTable() { static bool loadedOnce = false; GetCtrl<ctrlTable>(0)->DeleteAllItems(); std::vector<std::string> saveFiles = ListDir(GetFilePath(FILE_PATHS[85]), "sav"); for(std::vector<std::string>::iterator it = saveFiles.begin(); it != saveFiles.end(); ++it) { Savegame save; // Datei öffnen if(!save.Load(*it, false, false)) { // Show errors only first time this is loaded if(!loadedOnce) { LOG.write(_("Invalid Savegame %1%! Reason: %2%\n")) % *it % (save.GetLastErrorMsg().empty() ? _("Unknown") : save.GetLastErrorMsg()); } continue; } // Zeitstring erstellen std::string dateStr = TIME.FormatTime("%d.%m.%Y - %H:%i", &save.save_time); // Dateiname noch rausextrahieren aus dem Pfad bfs::path path = *it; if(!path.has_filename()) continue; bfs::path fileName = path.filename(); // ".sav" am Ende weg RTTR_Assert(fileName.has_extension()); fileName.replace_extension(); std::string fileNameStr = cvWideStringToUTF8(fileName.wstring()); std::string startGF = helpers::toString(save.start_gf); // Und das Zeug zur Tabelle hinzufügen GetCtrl<ctrlTable>(0)->AddRow(0, fileNameStr.c_str(), save.mapName.c_str(), dateStr.c_str(), startGF.c_str(), it->c_str()); } // Nach Zeit Sortieren bool bFalse = false; GetCtrl<ctrlTable>(0)->SortRows(2, &bFalse); loadedOnce = true; }
void iwSaveLoad::RefreshTable() { static bool loadedOnce = false; GetCtrl<ctrlTable>(0)->DeleteAllItems(); std::vector<std::string> saveFiles = ListDir(RTTRCONFIG.ExpandPath(FILE_PATHS[85]), "sav"); for(auto& saveFile : saveFiles) { Savegame save; // Datei öffnen if(!save.Load(saveFile, false, false)) { // Show errors only first time this is loaded if(!loadedOnce) { LOG.write(_("Invalid Savegame %1%! Reason: %2%\n")) % saveFile % (save.GetLastErrorMsg().empty() ? _("Unknown") : save.GetLastErrorMsg()); } continue; } // Zeitstring erstellen std::string dateStr = s25util::Time::FormatTime("%d.%m.%Y - %H:%i", save.GetSaveTime()); // Dateiname noch rausextrahieren aus dem Pfad bfs::path path = saveFile; if(!path.has_filename()) continue; // Just filename w/o extension bfs::path fileName = path.stem(); std::string startGF = helpers::toString(save.start_gf); // Und das Zeug zur Tabelle hinzufügen GetCtrl<ctrlTable>(0)->AddRow(0, fileName.string().c_str(), save.GetMapName().c_str(), dateStr.c_str(), startGF.c_str(), saveFile.c_str()); } // Nach Zeit Sortieren bool bFalse = false; GetCtrl<ctrlTable>(0)->SortRows(2, &bFalse); loadedOnce = true; }