Skip to content

Commit 55a6145

Browse files
committed
Fixed timed helptexts
1 parent 76d2427 commit 55a6145

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

ChaosMod/Components/HelpTextQueue.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
#include "Memory/Hooks/GetLabelTextHook.h"
66

7-
void HelpTextQueue::DisplayLabel(std::string_view label, std::uint8_t durationSecs)
7+
void HelpTextQueue::DisplayLabel(std::string label, std::uint8_t durationSecs)
88
{
99
if (durationSecs == 0)
1010
return;
1111

12-
m_HelpTextQueue.emplace(label, durationSecs / 1000.f);
12+
m_HelpTextQueue.emplace(label, durationSecs);
1313
}
1414

1515
void HelpTextQueue::OnModPauseCleanup()
@@ -19,14 +19,21 @@ void HelpTextQueue::OnModPauseCleanup()
1919

2020
void HelpTextQueue::OnRun()
2121
{
22-
if (m_HelpTextQueue.empty() || IS_HELP_MESSAGE_BEING_DISPLAYED())
22+
if (m_HelpTextQueue.empty())
2323
return;
2424

2525
auto &helpText = m_HelpTextQueue.front();
2626

27-
BEGIN_TEXT_COMMAND_DISPLAY_HELP(helpText.Text.data());
28-
END_TEXT_COMMAND_DISPLAY_HELP(0, false, false, 0);
27+
auto text = helpText.Text;
2928

30-
if ((helpText.TimerSecs -= GET_FRAME_TIME()) < 0.f)
31-
m_HelpTextQueue.pop();
29+
if (!IS_HELP_MESSAGE_BEING_DISPLAYED()
30+
|| (BEGIN_TEXT_COMMAND_IS_THIS_HELP_MESSAGE_BEING_DISPLAYED(text.data()),
31+
END_TEXT_COMMAND_IS_THIS_HELP_MESSAGE_BEING_DISPLAYED(0)))
32+
{
33+
BEGIN_TEXT_COMMAND_DISPLAY_HELP(text.data());
34+
END_TEXT_COMMAND_DISPLAY_HELP(0, false, false, -1);
35+
36+
if ((helpText.TimerSecs -= GET_FRAME_TIME()) < 0.f)
37+
m_HelpTextQueue.pop();
38+
}
3239
}

ChaosMod/Components/HelpTextQueue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ class HelpTextQueue : public Component
88
{
99
struct HelpText
1010
{
11-
std::string_view Text;
11+
std::string Text;
1212
float TimerSecs;
1313
};
1414
std::queue<HelpText> m_HelpTextQueue;
1515

1616
public:
17-
void DisplayLabel(std::string_view label, std::uint8_t durationSecs);
17+
void DisplayLabel(std::string label, std::uint8_t durationSecs);
1818

1919
virtual void OnModPauseCleanup() override;
2020
virtual void OnRun() override;

0 commit comments

Comments
 (0)