Prevent duplicate tooltips appearing on screen

Tooltips will no longer be added to the screen if that message is already being displayed. This prevents the same message (e.g. the ready room F4 message) from appearing multiple times if the player keeps pressing F4.
This commit is contained in:
RGreenlees 2023-09-15 11:35:37 +01:00 committed by pierow
parent f9a8db4963
commit eb91c70a75
2 changed files with 13 additions and 1 deletions

View file

@ -554,9 +554,20 @@ void AvHHud::AddTooltip(const char* inMessageText, bool inIsToolTip, float inToo
{
if(gEngfuncs.pfnGetCvarFloat(kvAutoHelp) || !inIsToolTip)
{
string theNewMessage = string(inMessageText);
// Don't add the tool tip if it is already on screen
for (AvHTooltip tip : mTooltips)
{
if (tip.GetText() == theNewMessage)
{
return;
}
}
AvHTooltip theNewTooltip;
theNewTooltip.SetText(string(inMessageText));
theNewTooltip.SetText(theNewMessage);
theNewTooltip.SetNormalizedScreenX(1.0f - inTooltipWidth - kHelpMessageLeftEdgeInset);
theNewTooltip.SetNormalizedScreenY(0.01f);
theNewTooltip.SetCentered(false);

View file

@ -77,6 +77,7 @@ public:
void SetBoldR(int inR);
void SetBoldG(int inG);
void SetBoldB(int inB);
string GetText() { return mText; }
private:
bool ChopStringOfMaxScreenWidth(int inMaxScreenWidth, string& ioBaseString, string& outChoppedString);