From 3752884a91c8944e6faf82954e3c4357557f8b55 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Wed, 3 May 2017 20:52:02 +0300 Subject: [PATCH] Changed: Add next weather tooltip to ingame map --HG-- branch : develop --- code/ryzom/client/data/gamedev/interfaces_v3/map.xml | 3 ++- code/ryzom/client/src/interface_v3/interface_manager.cpp | 9 +++++++++ code/ryzom/client/src/weather_manager_client.cpp | 7 +++++++ code/ryzom/client/src/weather_manager_client.h | 6 ++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/map.xml b/code/ryzom/client/data/gamedev/interfaces_v3/map.xml index 4370e5593..dcc2515ea 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/map.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/map.xml @@ -194,6 +194,7 @@ + @@ -447,4 +448,4 @@ - \ No newline at end of file + diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 968760546..46a725755 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1504,6 +1504,15 @@ void CInterfaceManager::updateFrameEvents() if (pVT != NULL) pVT->setText(str); + CCtrlBase *pTooltip= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather_tt")); + if (pTooltip != NULL) + { + ucstring tt = toString("%02d", WeatherManager.getNextWeatherHour()) + CI18N::get("uiMissionTimerHour") + + " - " + CI18N::get("uiHumidity") + " " + + toString("%d", (uint)(roundWeatherValue(WeatherManager.getNextWeatherValue()) * 100.f)) + "%"; + pTooltip->setDefaultContextHelp(tt); + } + // The date feature is temporarily disabled str.clear(); diff --git a/code/ryzom/client/src/weather_manager_client.cpp b/code/ryzom/client/src/weather_manager_client.cpp index 96f7bebf7..8c0018fdf 100644 --- a/code/ryzom/client/src/weather_manager_client.cpp +++ b/code/ryzom/client/src/weather_manager_client.cpp @@ -144,6 +144,13 @@ void CWeatherManagerClient::update(uint64 day, float hour, const CWeatherContext // get the weather value for the current date nlassert(wc.WFP); float weatherValue = ::getBlendedWeather(day, hour, *(wc.WFP), wc.WF); + + // calculate next weather cycle and ingame hour for it + uint64 cycle = ((day * wc.WFP->DayLength) + (uint) hour) / wc.WFP->CycleLength; + uint64 cycleDay = ((cycle + 1) * wc.WFP->CycleLength) / wc.WFP->DayLength; + _NextWeatherHour = ((cycle + 1) * wc.WFP->CycleLength) % wc.WFP->DayLength; + _NextWeatherValue = ::getBlendedWeather(cycleDay, _NextWeatherHour, *(wc.WFP), wc.WF); + // build current weather state EGSPD::CSeason::TSeason season = CRyzomTime::getSeasonByDay((uint32)day); // diff --git a/code/ryzom/client/src/weather_manager_client.h b/code/ryzom/client/src/weather_manager_client.h index 97388a7a4..f3c6ae07e 100644 --- a/code/ryzom/client/src/weather_manager_client.h +++ b/code/ryzom/client/src/weather_manager_client.h @@ -76,6 +76,10 @@ public: void update(uint64 day, float hour, const CWeatherContext &wc, const NLMISC::CMatrix &camMat, const class CContinent &continent); /// Get the current weather value. Updated after each call to 'update' float getWeatherValue() const { return _WeatherValue; } + /// Get the weather value for next cycle + float getNextWeatherValue() const { return _NextWeatherValue; } + /// Get the hour for next weather cycle + uint32 getNextWeatherHour() const { return _NextWeatherHour; } /** Does the same than 'update', but let the user choose the weather value. The weather value ranges from 0 to 1. * The day and hour are needed only to manage phenomena like thunder (need a clock to know when there are thunder strikes) * Small update, only to update current weather state @@ -123,6 +127,8 @@ private: float _LastEvalHour; uint64 _LastEvalDay; float _LocalPrecipitationFactor; + uint32 _NextWeatherHour; + float _NextWeatherValue; private: void initPrecipitationFXs(); void setupFXs(const NLMISC::CMatrix &camMat, NLPACS::UGlobalRetriever *gr, const class CContinent &continent);