diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index e04ee0f67..dd956399d 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -2271,12 +2271,14 @@ void Renderer::renderClock() { const Vec4f fontColor = game->getGui()->getDisplay()->getColor(); if(config.getBool("InGameClock","true") == true) { - int hours = world->getTimeFlow()->getTime(); - int minutes = (world->getTimeFlow()->getTime() - hours) * 100 * 0.6; // scale 100 to 60 - Lang &lang= Lang::getInstance(); - char szBuf[200]=""; - snprintf(szBuf,200,"%s %.2d:%.2d",lang.getString("GameTime","",true).c_str(),hours,minutes); + char szBuf[501]=""; + + //int hours = world->getTimeFlow()->getTime(); + //int minutes = (world->getTimeFlow()->getTime() - hours) * 100 * 0.6; // scale 100 to 60 + //snprintf(szBuf,200,"%s %.2d:%.2d",lang.getString("GameTime","",true).c_str(),hours,minutes); + // string header2 = lang.getString("GameDurationTime","",true) + ": " + getTimeString(stats.getFramesToCalculatePlaytime()); + snprintf(szBuf,500,"%s %s",lang.getString("GameDurationTime","",true).c_str(),getTimeDuationString(world->getFrameCount(),GameConstants::updateFps).c_str()); if(str != "") { str += " "; } diff --git a/source/glest_game/main/battle_end.cpp b/source/glest_game/main/battle_end.cpp index 911d5f49a..87a599ebc 100644 --- a/source/glest_game/main/battle_end.cpp +++ b/source/glest_game/main/battle_end.cpp @@ -347,27 +347,6 @@ void BattleEnd::initBackgroundVideo() { } } -const string BattleEnd::getTimeString(int frames) { - int framesleft=frames; - int hours=(int) frames / (float)GameConstants::updateFps / 3600.0; - framesleft=framesleft-hours*3600*GameConstants::updateFps; - int minutes=(int) framesleft / (float)GameConstants::updateFps / 60.0; - framesleft=framesleft-minutes*60*GameConstants::updateFps; - int seconds=(int) framesleft / (float)GameConstants::updateFps; - //framesleft=framesleft-seconds*GameConstants::updateFps; - - string hourstr=intToStr(hours); - if(hours<10) hourstr="0"+hourstr; - - string minutestr=intToStr(minutes); - if(minutes<10) minutestr="0"+minutestr; - - string secondstr=intToStr(seconds); - if(seconds<10) secondstr="0"+secondstr; - - return hourstr+":"+minutestr+":"+secondstr; -} - void BattleEnd::update() { if(Config::getInstance().getBool("AutoTest")){ AutoTest::getInstance().updateBattleEnd(program); @@ -610,7 +589,7 @@ void BattleEnd::render() { if(stats.getPlayerName(i) != "") { string textToRender=stats.getPlayerName(i); if(stats.getPlayerLeftBeforeEnd(i)==true){ - textToRender+="\n("+getTimeString(stats.getTimePlayerLeft(i))+")"; + textToRender+="\n("+getTimeDuationString(stats.getTimePlayerLeft(i),GameConstants::updateFps) + ")"; } textRenderer->render(textToRender.c_str(), textX, bm+400, false, &color); @@ -719,7 +698,7 @@ void BattleEnd::render() { //GameConstants::updateFps //string header2 = lang.getString("GameDurationTime","",true) + " " + floatToStr(stats.getWorldTimeElapsed() / 24.0,2); - string header2 = lang.getString("GameDurationTime","",true) + ": " + getTimeString(stats.getFramesToCalculatePlaytime()); + string header2 = lang.getString("GameDurationTime","",true) + ": " + getTimeDuationString(stats.getFramesToCalculatePlaytime(),GameConstants::updateFps); textRenderer->render(header2, lm+250, bm+530); header2 = lang.getString("GameMaxConcurrentUnitCount") + ": " + intToStr(stats.getMaxConcurrentUnitCount()); diff --git a/source/glest_game/main/battle_end.h b/source/glest_game/main/battle_end.h index 62991b6b1..9434fcd36 100644 --- a/source/glest_game/main/battle_end.h +++ b/source/glest_game/main/battle_end.h @@ -65,7 +65,6 @@ public: virtual void reloadUI(); private: - const string getTimeString(int frames); void initBackgroundVideo(); std::pair getBattleEndVideo(bool won); diff --git a/source/shared_lib/include/util/conversion.h b/source/shared_lib/include/util/conversion.h index 3b29f5015..836ba997d 100644 --- a/source/shared_lib/include/util/conversion.h +++ b/source/shared_lib/include/util/conversion.h @@ -43,6 +43,8 @@ bool IsNumeric(const char *p, bool allowNegative=true); string formatNumber(uint64 f); +string getTimeDuationString(int frames, int updateFps); + }}//end namespace #endif diff --git a/source/shared_lib/sources/util/conversion.cpp b/source/shared_lib/sources/util/conversion.cpp index 49cc0b36f..51409f837 100644 --- a/source/shared_lib/sources/util/conversion.cpp +++ b/source/shared_lib/sources/util/conversion.cpp @@ -215,4 +215,31 @@ string formatNumber(uint64 f) { return out.str(); } +string getTimeDuationString(int frames, int updateFps) { + int framesleft = frames; + int hours = (int) frames / (float)updateFps / 3600.0; + framesleft = framesleft - hours * 3600 * updateFps; + int minutes = (int) framesleft / (float)updateFps / 60.0; + framesleft = framesleft - minutes * 60 * updateFps; + int seconds = (int) framesleft / (float)updateFps; + //framesleft=framesleft-seconds*GameConstants::updateFps; + + string hourstr = intToStr(hours); + if(hours < 10) { + hourstr = "0" + hourstr; + } + + string minutestr = intToStr(minutes); + if(minutes < 10) { + minutestr = "0" + minutestr; + } + + string secondstr = intToStr(seconds); + if(seconds < 10) { + secondstr = "0" + secondstr; + } + + return hourstr + ":" + minutestr + ":" + secondstr; +} + }}//end namespace