mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 12:39:55 +00:00
Time played displayed in save/load menus
This commit is contained in:
parent
232dfdc07e
commit
e86891d6e1
@ -1,5 +1,8 @@
|
|||||||
#include "savegamedialog.hpp"
|
#include "savegamedialog.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
#include <MyGUI_ComboBox.h>
|
#include <MyGUI_ComboBox.h>
|
||||||
#include <MyGUI_ImageBox.h>
|
#include <MyGUI_ImageBox.h>
|
||||||
#include <MyGUI_ListBox.h>
|
#include <MyGUI_ListBox.h>
|
||||||
@ -309,6 +312,21 @@ namespace MWGui
|
|||||||
onSlotSelected(mSaveList, MyGUI::ITEM_NONE);
|
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)
|
void SaveGameDialog::onSlotSelected(MyGUI::ListBox *sender, size_t pos)
|
||||||
{
|
{
|
||||||
mOkButton->setEnabled(pos != MyGUI::ITEM_NONE || mSaving);
|
mOkButton->setEnabled(pos != MyGUI::ITEM_NONE || mSaving);
|
||||||
@ -349,7 +367,6 @@ namespace MWGui
|
|||||||
text << buffer << "\n";
|
text << buffer << "\n";
|
||||||
text << "#{sLevel} " << mCurrentSlot->mProfile.mPlayerLevel << "\n";
|
text << "#{sLevel} " << mCurrentSlot->mProfile.mPlayerLevel << "\n";
|
||||||
text << "#{sCell=" << mCurrentSlot->mProfile.mPlayerCell << "}\n";
|
text << "#{sCell=" << mCurrentSlot->mProfile.mPlayerCell << "}\n";
|
||||||
// text << "Time played: " << slot->mProfile.mTimePlayed << "\n";
|
|
||||||
|
|
||||||
int hour = int(mCurrentSlot->mProfile.mInGameTime.mGameHour);
|
int hour = int(mCurrentSlot->mProfile.mInGameTime.mGameHour);
|
||||||
bool pm = hour >= 12;
|
bool pm = hour >= 12;
|
||||||
@ -359,7 +376,9 @@ namespace MWGui
|
|||||||
text
|
text
|
||||||
<< mCurrentSlot->mProfile.mInGameTime.mDay << " "
|
<< mCurrentSlot->mProfile.mInGameTime.mDay << " "
|
||||||
<< MWBase::Environment::get().getWorld()->getMonthName(mCurrentSlot->mProfile.mInGameTime.mMonth)
|
<< 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());
|
mInfoText->setCaptionWithReplacing(text.str());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user