Time played displayed in save/load menus

sceneinput
Jeffrey Haines 10 years ago
parent 232dfdc07e
commit e86891d6e1

@ -1,5 +1,8 @@
#include "savegamedialog.hpp"
#include <sstream>
#include <iomanip>
#include <MyGUI_ComboBox.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_ListBox.h>
@ -309,6 +312,21 @@ namespace MWGui
onSlotSelected(mSaveList, MyGUI::ITEM_NONE);
}
std::string formatTimeplayed(const long int timePlayed)
{
int days = timePlayed / 60 / 60 / 24;
int hours = (timePlayed / 60 / 60) % 24;
int minutes = (timePlayed / 60) % 60;
int seconds = timePlayed % 60;
std::stringstream stream;
stream << std::setfill('0') << std::setw(2) << days << ":";
stream << std::setfill('0') << std::setw(2) << hours << ":";
stream << std::setfill('0') << std::setw(2) << minutes << ":";
stream << std::setfill('0') << std::setw(2) << seconds;
return stream.str();
}
void SaveGameDialog::onSlotSelected(MyGUI::ListBox *sender, size_t pos)
{
mOkButton->setEnabled(pos != MyGUI::ITEM_NONE || mSaving);
@ -349,7 +367,6 @@ namespace MWGui
text << buffer << "\n";
text << "#{sLevel} " << mCurrentSlot->mProfile.mPlayerLevel << "\n";
text << "#{sCell=" << mCurrentSlot->mProfile.mPlayerCell << "}\n";
// text << "Time played: " << slot->mProfile.mTimePlayed << "\n";
int hour = int(mCurrentSlot->mProfile.mInGameTime.mGameHour);
bool pm = hour >= 12;
@ -359,7 +376,9 @@ namespace MWGui
text
<< mCurrentSlot->mProfile.mInGameTime.mDay << " "
<< MWBase::Environment::get().getWorld()->getMonthName(mCurrentSlot->mProfile.mInGameTime.mMonth)
<< " " << hour << " " << (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}");
<< " " << hour << " " << (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}")<< "\n";
text << "Time played: " << formatTimeplayed((int)floor(mCurrentSlot->mProfile.mTimePlayed));
mInfoText->setCaptionWithReplacing(text.str());

Loading…
Cancel
Save