From 1c1fbcb811338591703c51db526a23d8c70e5192 Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Sat, 30 Oct 2021 18:25:49 +0300 Subject: [PATCH] TTextBox: fixed DrawText texts getting overwritten by full redraw. This bug is from the original 3DPB. --- SpaceCadetPinball/TTextBox.cpp | 10 +++++++++- SpaceCadetPinball/TTextBox.h | 2 +- SpaceCadetPinball/fullscrn.cpp | 2 +- SpaceCadetPinball/pb.cpp | 6 ++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/SpaceCadetPinball/TTextBox.cpp b/SpaceCadetPinball/TTextBox.cpp index db01c7e..03d31f6 100644 --- a/SpaceCadetPinball/TTextBox.cpp +++ b/SpaceCadetPinball/TTextBox.cpp @@ -153,7 +153,7 @@ void TTextBox::Display(const wchar_t* text, float time) } } -void TTextBox::Draw() +void TTextBox::Draw(bool redraw) { auto bmp = BgBmp; if (bmp) @@ -172,6 +172,12 @@ void TTextBox::Draw() bool display = false; while (Message1) { + if (redraw) + { + display = true; + break; + } + if (Message1->Time == -1.0f) { if (!Message1->NextMessage) @@ -183,6 +189,8 @@ void TTextBox::Draw() } else if (Message1->TimeLeft() >= -2.0f) { + if (Timer > 0) + timer::kill(Timer); Timer = timer::set(max(Message1->TimeLeft(), 0.25f), this, TimerExpired); display = true; break; diff --git a/SpaceCadetPinball/TTextBox.h b/SpaceCadetPinball/TTextBox.h index a9dc04e..b21499d 100644 --- a/SpaceCadetPinball/TTextBox.h +++ b/SpaceCadetPinball/TTextBox.h @@ -22,7 +22,7 @@ public: int Message(int code, float value) override; void Clear(); void Display(const wchar_t* text, float time); - void Draw(); + void Draw(bool redraw = false); static void TimerExpired(int timerId, void* tb); }; diff --git a/SpaceCadetPinball/fullscrn.cpp b/SpaceCadetPinball/fullscrn.cpp index c7084e4..edcbf0b 100644 --- a/SpaceCadetPinball/fullscrn.cpp +++ b/SpaceCadetPinball/fullscrn.cpp @@ -377,7 +377,7 @@ void fullscrn::paint() fillRect(WindowRect1.right, menuHeight + WindowRect1.bottom, 0, 0); } } - render::paint(); + pb::paint(); fullscrn_flag1 = 0; } diff --git a/SpaceCadetPinball/pb.cpp b/SpaceCadetPinball/pb.cpp index e1dda2b..2f061c7 100644 --- a/SpaceCadetPinball/pb.cpp +++ b/SpaceCadetPinball/pb.cpp @@ -135,6 +135,12 @@ void pb::firsttime_setup() void pb::paint() { render::paint(); + if (score::msg_fontp == nullptr) + { + // DrawText writes to screen directly, text gets overwritten by full vScreen blit. + pinball::InfoTextBox->Draw(true); + pinball::MissTextBox->Draw(true); + } } void pb::mode_change(int mode)