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 d939df144..46a725755 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1433,6 +1433,23 @@ void CInterfaceManager::flushDebugWindow() ChatDisplayer->update(); } +// ------------------------------------------------------------------------------------------------ +// Make sure 0.166 is displayed as 16% and 0.167 as 17% +// because they belong to different weather conditions +static float roundWeatherValue(float weatherValue) +{ + // Number of possible weather setups in server + const static uint NB_WEATHER_SETUPS = 6; + float floorValue = floorf(weatherValue * 100.f) / 100.f; + uint weatherIndex = min((uint)(weatherValue * NB_WEATHER_SETUPS), NB_WEATHER_SETUPS - 1); + uint floorIndex = min((uint)(floorValue * NB_WEATHER_SETUPS), NB_WEATHER_SETUPS - 1); + + if (weatherIndex > floorIndex) + return ceilf(weatherValue * 100.f) / 100.f; + + return weatherValue; +} + // ------------------------------------------------------------------------------------------------ void CInterfaceManager::updateFrameEvents() { @@ -1471,20 +1488,31 @@ void CInterfaceManager::updateFrameEvents() // Update string if some waiting CEncyclopediaManager::getInstance()->updateAllFrame(); - // Setup the weather setup in the player's map - if ((T0 - _UpdateWeatherTime) > (1 * 5 * 1000)) + // Setup the weather setup in the player's map every 3 sec (1 ingame minute) + if ((T0 - _UpdateWeatherTime) > (1 * 3 * 1000)) { _UpdateWeatherTime = T0; ucstring str = CI18N::get ("uiTheSeasonIs") + CI18N::get ("uiSeason"+toStringEnum(computeCurrSeason())) + CI18N::get ("uiAndTheWeatherIs") + - CI18N::get (WeatherManager.getCurrWeatherState().LocalizedName); + CI18N::get (WeatherManager.getCurrWeatherState().LocalizedName) + + toString(", %d", (uint)(roundWeatherValue(WeatherManager.getWeatherValue()) * 100.f)) + "% " +CI18N::get("uiHumidity"); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather")); 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(); @@ -1498,7 +1526,8 @@ void CInterfaceManager::updateFrameEvents() // literal version // str = CI18N::get("uiDate"); - str += toString("%02d", (sint)RT.getRyzomTime()) + CI18N::get("uiMissionTimerHour") + " - "; + uint minutes = ((RT.getRyzomTime() - (sint)RT.getRyzomTime()) * (float) RYZOM_HOUR_IN_MINUTES); + str += toString("%02d:%02d", (sint)RT.getRyzomTime(), minutes) + " - "; str += CI18N::get("ui"+WEEKDAY::toString( (WEEKDAY::EWeekDay)RT.getRyzomDayOfWeek() )) + ", "; str += CI18N::get("ui"+MONTH::toString( (MONTH::EMonth)RT.getRyzomMonthInCurrentCycle() )) + " "; str += toString("%02d", RT.getRyzomDayOfMonth()+1) + ", "; 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); diff --git a/code/ryzom/common/src/game_share/time_weather_season/time_and_season.h b/code/ryzom/common/src/game_share/time_weather_season/time_and_season.h index 62f144119..d712302aa 100644 --- a/code/ryzom/common/src/game_share/time_weather_season/time_and_season.h +++ b/code/ryzom/common/src/game_share/time_weather_season/time_and_season.h @@ -23,6 +23,7 @@ const uint RYZOM_HOURS_IN_TICKS = 1800; const uint RYZOM_DAY_IN_HOUR = 24; +const uint RYZOM_HOUR_IN_MINUTES = 60; const uint RYZOM_DAY_IN_TICKS = RYZOM_HOURS_IN_TICKS * RYZOM_DAY_IN_HOUR; const uint RYZOM_SEASON_IN_DAY = 90; const uint RYZOM_MONTH_IN_DAY = 30;