1 #ifndef WL_WUI_SAVEGAMEDATA_H 2 #define WL_WUI_SAVEGAMEDATA_H 3 4 #include <string> 5 #include <ctime> 6 7 #include "io/filesystem/filesystem.h" 8 #include "logic/game_controller.h" 9 #include "logic/widelands.h" 10 11 /** 12 * Data about a savegame/replay that we're interested in. 13 */ 14 class SavegameData { 15 public: 16 enum class SavegameType { kSavegame, kParentDirectory, kSubDirectory }; 17 /// The filename of the currenty selected file 18 std::string filename; 19 /// The name of the map that the game is based on 20 std::string mapname; 21 /// The win condition that was played 22 std::string wincondition; 23 /// Filename of the minimap or empty if none available 24 std::string minimap_path; 25 /// "saved on ..." 26 std::string savedatestring; 27 /// Verbose date and time 28 std::string savedonstring; 29 /// An error message or empty if no error occurred 30 std::string errormessage; 31 32 /// Compact gametime information 33 std::string gametime; 34 /// Number of players on the map 35 std::string nrplayers; 36 /// The version of Widelands that the game was played with 37 std::string version; 38 /// Gametime as time stamp. For games, it's the time the game ended. For replays, it's the time 39 /// the game started. 40 time_t savetimestamp; 41 /// Single payer, nethost, netclient or replay 42 GameController::GameType gametype; 43 44 SavegameData(); 45 SavegameData(const std::string& filename); 46 SavegameData(const std::string& filename, const SavegameType& type); 47 static SavegameData create_parent_dir(const std::string& current_dir); 48 static SavegameData create_sub_dir(const std::string& directory); 49 50 /// Converts timestamp to UI string and assigns it to gametime 51 void set_gametime(uint32_t input_gametime); 52 /// Sets the number of players on the map as a string 53 void set_nrplayers(Widelands::PlayerNumber input_nrplayers); 54 /// Sets the mapname as a localized string 55 void set_mapname(const std::string& input_mapname); 56 57 bool is_directory() const; 58 59 bool is_parent_directory() const; 60 61 bool is_sub_directory() const; 62 63 bool is_multiplayer() const; 64 65 bool is_multiplayer_host() const; 66 67 bool is_multiplayer_client() const; 68 69 bool is_singleplayer() const; 70 71 bool is_replay() const; 72 73 bool compare_save_time(const SavegameData& other) const; 74 75 bool compare_directories(const SavegameData& other) const; 76 77 bool compare_map_name(const SavegameData& other) const; 78 79 private: 80 /// Savegame or directory 81 SavegameType type_; 82 }; 83 const std::string as_filename_list(const std::vector<SavegameData>& savefiles); 84 #endif // WL_WUI_SAVEGAMEDATA_H 85