GUI: Refactor default savegame description creation.
Formerly the GMM, AGI and SCI duplicated the logic for USE_SAVEGAME_TIMESTAMP. Now I added a method to SaveLoadChooser instead, which takes care of this. This might not be the best placement of such a functionality, thus I added a TODO which talks about moving it to a better place.
This commit is contained in:
parent
7c5cf1b400
commit
49fafb48a7
5 changed files with 31 additions and 27 deletions
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "common/config-manager.h"
|
||||
#include "common/translation.h"
|
||||
#include "common/system.h"
|
||||
|
||||
#include "gui/widgets/list.h"
|
||||
#include "gui/message.h"
|
||||
|
@ -126,6 +127,18 @@ const Common::String &SaveLoadChooser::getResultString() const {
|
|||
return (selItem >= 0) ? _list->getSelectedString() : _resultString;
|
||||
}
|
||||
|
||||
Common::String SaveLoadChooser::createDefaultSaveDescription(const int slot) const {
|
||||
#if defined(USE_SAVEGAME_TIMESTAMP)
|
||||
TimeDate curTime;
|
||||
g_system->getTimeAndDate(curTime);
|
||||
curTime.tm_year += 1900; // fixup year
|
||||
curTime.tm_mon++; // fixup month
|
||||
return Common::String::format("%04d.%02d.%02d / %02d:%02d:%02d", curTime.tm_year, curTime.tm_mon, curTime.tm_mday, curTime.tm_hour, curTime.tm_min, curTime.tm_sec);
|
||||
#else
|
||||
return Common::String::format("Save %d", slot + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||
int selItem = _list->getSelected();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue