diff --git a/src/openrct2/paint/Painter.cpp b/src/openrct2/paint/Painter.cpp index 1d06b62029..8bbcc05e11 100644 --- a/src/openrct2/paint/Painter.cpp +++ b/src/openrct2/paint/Painter.cpp @@ -12,6 +12,7 @@ #include "../Game.h" #include "../Intro.h" #include "../OpenRCT2.h" +#include "../ReplayManager.h" #include "../config/Config.h" #include "../drawing/Drawing.h" #include "../drawing/IDrawingEngine.h" @@ -57,6 +58,15 @@ void Painter::Paint(IDrawingEngine& de) de.PaintRain(); } + auto* replayManager = GetContext()->GetReplayManager(); + if (replayManager != nullptr) + { + if (replayManager->IsReplaying()) + PaintReplayNotice(dpi, false); + else if (replayManager->IsRecording()) + PaintReplayNotice(dpi, true); + } + if (gConfigGeneral.show_fps) { PaintFPS(dpi); @@ -64,6 +74,33 @@ void Painter::Paint(IDrawingEngine& de) gCurrentDrawCount++; } +void OpenRCT2::Paint::Painter::PaintReplayNotice(rct_drawpixelinfo* dpi, bool isRecording) +{ + int32_t x = _uiContext->GetWidth() / 2; + int32_t y = _uiContext->GetHeight() - 24; + + // Format string + utf8 buffer[64] = { 0 }; + utf8* ch = buffer; + ch = utf8_write_codepoint(ch, FORMAT_MEDIUMFONT); + ch = utf8_write_codepoint(ch, FORMAT_OUTLINE); + ch = utf8_write_codepoint(ch, FORMAT_RED); + + if (isRecording) + snprintf(ch, 64 - (ch - buffer), "Recording..."); + else + snprintf(ch, 64 - (ch - buffer), "Replaying..."); + + int32_t stringWidth = gfx_get_string_width(buffer); + x = x - stringWidth; + + if (((gCurrentTicks >> 1) & 0xF) > 4) + gfx_draw_string(dpi, buffer, COLOUR_SATURATED_RED, x, y); + + // Make area dirty so the text doesn't get drawn over the last + gfx_set_dirty_blocks(x, y, x + stringWidth, y + 16); +} + void Painter::PaintFPS(rct_drawpixelinfo* dpi) { int32_t x = _uiContext->GetWidth() / 2; diff --git a/src/openrct2/paint/Painter.h b/src/openrct2/paint/Painter.h index a3f1ade37b..4437a513ab 100644 --- a/src/openrct2/paint/Painter.h +++ b/src/openrct2/paint/Painter.h @@ -44,6 +44,7 @@ namespace OpenRCT2 void Paint(Drawing::IDrawingEngine& de); private: + void PaintReplayNotice(rct_drawpixelinfo* dpi, bool isRecording); void PaintFPS(rct_drawpixelinfo* dpi); void MeasureFPS(); };