From e86891d6e16508229732dfb55dd9bae27780ceb7 Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Wed, 19 Aug 2015 10:05:08 -0400 Subject: [PATCH 1/5] Time played displayed in save/load menus --- apps/openmw/mwgui/savegamedialog.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 82dd0d8a9..4559fc695 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -1,5 +1,8 @@ #include "savegamedialog.hpp" +#include +#include + #include #include #include @@ -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()); From 69729046bf669235e69f0de7b750358da1b9f769 Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Wed, 19 Aug 2015 10:11:40 -0400 Subject: [PATCH 2/5] Updated parameter name to reflect units --- apps/openmw/mwgui/savegamedialog.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 4559fc695..83b458a2b 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -312,12 +312,12 @@ namespace MWGui onSlotSelected(mSaveList, MyGUI::ITEM_NONE); } - std::string formatTimeplayed(const long int timePlayed) + std::string formatTimeplayed(const long int timeInSeconds) { - int days = timePlayed / 60 / 60 / 24; - int hours = (timePlayed / 60 / 60) % 24; - int minutes = (timePlayed / 60) % 60; - int seconds = timePlayed % 60; + int days = timeInSeconds / 60 / 60 / 24; + int hours = (timeInSeconds / 60 / 60) % 24; + int minutes = (timeInSeconds / 60) % 60; + int seconds = timeInSeconds % 60; std::stringstream stream; stream << std::setfill('0') << std::setw(2) << days << ":"; From d91f197119ac6cfb1ed6002c48ff1c50f83674c3 Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Wed, 19 Aug 2015 11:31:43 -0400 Subject: [PATCH 3/5] Time played display setting --- apps/openmw/mwgui/savegamedialog.cpp | 7 +++++-- files/settings-default.cfg | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 83b458a2b..0375bfda3 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -376,9 +376,12 @@ namespace MWGui text << mCurrentSlot->mProfile.mInGameTime.mDay << " " << MWBase::Environment::get().getWorld()->getMonthName(mCurrentSlot->mProfile.mInGameTime.mMonth) - << " " << hour << " " << (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}")<< "\n"; + << " " << hour << " " << (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}"); - text << "Time played: " << formatTimeplayed((int)floor(mCurrentSlot->mProfile.mTimePlayed)); + if (Settings::Manager::getBool("timeplayed","Saves")) + { + text << "\n" << "Time played: " << formatTimeplayed((int)floor(mCurrentSlot->mProfile.mTimePlayed)); + } mInfoText->setCaptionWithReplacing(text.str()); diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 0f7349eb9..f2b6aa34f 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -177,6 +177,8 @@ show owned = 0 character = # Save when resting autosave = true +# display time played +timeplayed = false [Windows] inventory x = 0 From 61bb55aff40d9efb594ced44799b7bda98d2ca23 Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Wed, 19 Aug 2015 13:23:40 -0400 Subject: [PATCH 4/5] Removed long int parameter --- apps/openmw/mwgui/savegamedialog.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 0375bfda3..3d509e9fd 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -1,5 +1,6 @@ #include "savegamedialog.hpp" +#include #include #include @@ -312,12 +313,13 @@ namespace MWGui onSlotSelected(mSaveList, MyGUI::ITEM_NONE); } - std::string formatTimeplayed(const long int timeInSeconds) + std::string formatTimeplayed(const double timeInSeconds) { - int days = timeInSeconds / 60 / 60 / 24; - int hours = (timeInSeconds / 60 / 60) % 24; - int minutes = (timeInSeconds / 60) % 60; - int seconds = timeInSeconds % 60; + int timePlayed = (int)floor(timeInSeconds); + 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 << ":"; @@ -380,7 +382,7 @@ namespace MWGui if (Settings::Manager::getBool("timeplayed","Saves")) { - text << "\n" << "Time played: " << formatTimeplayed((int)floor(mCurrentSlot->mProfile.mTimePlayed)); + text << "\n" << "Time played: " << formatTimeplayed(mCurrentSlot->mProfile.mTimePlayed); } mInfoText->setCaptionWithReplacing(text.str()); From f94d3237fcb9bae1a51e8f442029b2d4496060cb Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Wed, 19 Aug 2015 13:28:01 -0400 Subject: [PATCH 5/5] Removed unused cmake import --- apps/openmw/mwgui/savegamedialog.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 3d509e9fd..be9ef2139 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -1,6 +1,5 @@ #include "savegamedialog.hpp" -#include #include #include