2016-06-04 00:06:22 +02:00
|
|
|
/*****************************************************************************
|
2020-07-21 15:04:34 +02:00
|
|
|
* Copyright (c) 2014-2020 OpenRCT2 developers
|
2016-06-04 00:06:22 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2016-06-04 00:06:22 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2016-06-04 00:06:22 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2020-09-13 00:32:26 +02:00
|
|
|
#include "Weather.h"
|
2018-06-22 22:59:03 +02:00
|
|
|
|
2017-09-18 17:05:28 +02:00
|
|
|
#include "../config/Config.h"
|
2018-01-11 00:26:19 +01:00
|
|
|
#include "../interface/Viewport.h"
|
2018-03-19 23:28:40 +01:00
|
|
|
#include "../ride/TrackDesign.h"
|
|
|
|
#include "../scenario/Scenario.h"
|
2018-06-15 08:46:04 +02:00
|
|
|
#include "../ui/UiContext.h"
|
|
|
|
#include "../world/Climate.h"
|
|
|
|
#include "Drawing.h"
|
2016-06-04 00:06:22 +02:00
|
|
|
#include "IDrawingEngine.h"
|
|
|
|
|
2018-06-15 08:46:04 +02:00
|
|
|
using namespace OpenRCT2;
|
2017-03-25 04:16:40 +01:00
|
|
|
using namespace OpenRCT2::Drawing;
|
|
|
|
|
2020-09-14 21:36:30 +02:00
|
|
|
static void DrawLightRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
|
|
|
|
static void DrawHeavyRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
|
2016-06-04 00:06:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x009AC058
|
|
|
|
*/
|
2020-09-14 21:36:30 +02:00
|
|
|
const DrawWeatherFunc DrawRainFunctions[] = {
|
2018-06-25 23:54:31 +02:00
|
|
|
nullptr,
|
|
|
|
&DrawLightRain,
|
|
|
|
&DrawHeavyRain,
|
|
|
|
};
|
2016-06-04 00:06:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00684218
|
|
|
|
*/
|
2020-09-14 21:36:30 +02:00
|
|
|
void DrawWeather(rct_drawpixelinfo* dpi, IWeatherDrawer* weatherDrawer)
|
2016-06-04 00:06:22 +02:00
|
|
|
{
|
2018-06-15 08:46:04 +02:00
|
|
|
if (gConfigGeneral.render_weather_effects)
|
2016-06-04 00:06:22 +02:00
|
|
|
{
|
2018-12-05 19:29:51 +01:00
|
|
|
uint32_t viewFlags = 0;
|
|
|
|
|
|
|
|
rct_viewport* viewport = window_get_viewport(window_get_main());
|
|
|
|
if (viewport != nullptr)
|
|
|
|
viewFlags = viewport->flags;
|
|
|
|
|
2018-06-15 08:46:04 +02:00
|
|
|
// Get rain draw function and draw rain
|
2020-09-14 21:36:30 +02:00
|
|
|
WeatherLevel rainType = gClimateCurrent.Level;
|
|
|
|
if (rainType != WeatherLevel::None && !gTrackDesignSaveMode && !(viewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES))
|
2018-06-15 08:46:04 +02:00
|
|
|
{
|
2020-07-28 18:19:45 +02:00
|
|
|
auto drawFunc = DrawRainFunctions[static_cast<int8_t>(rainType)];
|
2018-06-15 08:46:04 +02:00
|
|
|
auto uiContext = GetContext()->GetUiContext();
|
2020-09-14 21:36:30 +02:00
|
|
|
uiContext->DrawWeatherAnimation(weatherDrawer, dpi, drawFunc);
|
2018-06-15 08:46:04 +02:00
|
|
|
}
|
2016-06-04 00:06:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00684114
|
|
|
|
*/
|
2020-09-14 21:36:30 +02:00
|
|
|
static void DrawLightRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
|
2016-06-04 00:06:22 +02:00
|
|
|
{
|
2020-04-22 17:09:29 +02:00
|
|
|
int32_t x_start = -static_cast<int32_t>(gScenarioTicks) + 8;
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t y_start = (gScenarioTicks * 3) + 7;
|
2016-06-04 00:06:22 +02:00
|
|
|
y_start = -y_start;
|
|
|
|
x_start += left;
|
|
|
|
y_start += top;
|
2020-09-14 21:36:30 +02:00
|
|
|
weatherDrawer->Draw(left, top, width, height, x_start, y_start);
|
2016-06-04 00:06:22 +02:00
|
|
|
|
2020-04-22 17:09:29 +02:00
|
|
|
x_start = -static_cast<int32_t>(gScenarioTicks) + 0x18;
|
2016-06-04 00:06:22 +02:00
|
|
|
y_start = (gScenarioTicks * 4) + 0x0D;
|
|
|
|
y_start = -y_start;
|
|
|
|
x_start += left;
|
|
|
|
y_start += top;
|
2020-09-14 21:36:30 +02:00
|
|
|
weatherDrawer->Draw(left, top, width, height, x_start, y_start);
|
2016-06-04 00:06:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068416D
|
|
|
|
*/
|
2020-09-14 21:36:30 +02:00
|
|
|
static void DrawHeavyRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
|
2016-06-04 00:06:22 +02:00
|
|
|
{
|
2020-04-22 17:09:29 +02:00
|
|
|
int32_t x_start = -static_cast<int32_t>(gScenarioTicks);
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t y_start = gScenarioTicks * 5;
|
2016-06-04 00:06:22 +02:00
|
|
|
y_start = -y_start;
|
|
|
|
x_start += left;
|
|
|
|
y_start += top;
|
2020-09-14 21:36:30 +02:00
|
|
|
weatherDrawer->Draw(left, top, width, height, x_start, y_start);
|
2016-06-04 00:06:22 +02:00
|
|
|
|
2020-04-22 17:09:29 +02:00
|
|
|
x_start = -static_cast<int32_t>(gScenarioTicks) + 0x10;
|
2016-06-04 00:06:22 +02:00
|
|
|
y_start = (gScenarioTicks * 6) + 5;
|
|
|
|
y_start = -y_start;
|
|
|
|
x_start += left;
|
|
|
|
y_start += top;
|
2020-09-14 21:36:30 +02:00
|
|
|
weatherDrawer->Draw(left, top, width, height, x_start, y_start);
|
2016-06-04 00:06:22 +02:00
|
|
|
|
2020-04-22 17:09:29 +02:00
|
|
|
x_start = -static_cast<int32_t>(gScenarioTicks) + 8;
|
2016-06-04 00:06:22 +02:00
|
|
|
y_start = (gScenarioTicks * 3) + 7;
|
|
|
|
y_start = -y_start;
|
|
|
|
x_start += left;
|
|
|
|
y_start += top;
|
2020-09-14 21:36:30 +02:00
|
|
|
weatherDrawer->Draw(left, top, width, height, x_start, y_start);
|
2016-06-04 00:06:22 +02:00
|
|
|
|
2020-04-22 17:09:29 +02:00
|
|
|
x_start = -static_cast<int32_t>(gScenarioTicks) + 0x18;
|
2016-06-04 00:06:22 +02:00
|
|
|
y_start = (gScenarioTicks * 4) + 0x0D;
|
|
|
|
y_start = -y_start;
|
|
|
|
x_start += left;
|
|
|
|
y_start += top;
|
2020-09-14 21:36:30 +02:00
|
|
|
weatherDrawer->Draw(left, top, width, height, x_start, y_start);
|
2016-06-04 00:06:22 +02:00
|
|
|
}
|