Fix tool tips disappearing too quickly

This commit is contained in:
ζeh Matt 2023-05-18 18:07:57 +03:00
parent 053c00218f
commit bdbb9023da
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
6 changed files with 24 additions and 19 deletions

View File

@ -56,7 +56,7 @@ static uint8_t _currentScrollArea;
ScreenCoordsXY gInputDragLast;
uint16_t gTooltipTimeout;
uint32_t gTooltipCloseTimeout;
WidgetRef gTooltipWidget;
ScreenCoordsXY gTooltipCursor;
@ -482,7 +482,7 @@ static void InputWindowPositionContinue(
static void InputWindowPositionEnd(WindowBase& w, const ScreenCoordsXY& screenCoords)
{
_inputState = InputState::Normal;
gTooltipTimeout = 0;
gTooltipCloseTimeout = 0;
gTooltipWidget = _dragWidget;
WindowEventMovedCall(&w, screenCoords);
}
@ -513,7 +513,7 @@ static void InputWindowResizeContinue(WindowBase& w, const ScreenCoordsXY& scree
static void InputWindowResizeEnd()
{
_inputState = InputState::Normal;
gTooltipTimeout = 0;
gTooltipCloseTimeout = 0;
gTooltipWidget = _dragWidget;
}
@ -1403,7 +1403,7 @@ void InputStateWidgetPressed(
}
_inputState = InputState::Normal;
gTooltipTimeout = 0;
gTooltipCloseTimeout = 0;
gTooltipWidget.widget_index = cursor_widgetIndex;
gTooltipWidget.window_classification = cursor_w_class;
gTooltipWidget.window_number = cursor_w_number;
@ -1427,7 +1427,7 @@ void InputStateWidgetPressed(
return;
}
gTooltipTimeout = 0;
gTooltipCloseTimeout = 0;
gTooltipWidget.widget_index = cursor_widgetIndex;
if (w == nullptr)
@ -1515,19 +1515,23 @@ static void InputUpdateTooltip(WindowBase* w, WidgetIndex widgetIndex, const Scr
{
if (gTooltipCursor == screenCoords)
{
_tooltipNotShownTicks++;
if (_tooltipNotShownTicks > 50 && w != nullptr && WidgetIsVisible(*w, widgetIndex))
if (gCurrentRealTimeTicks >= _tooltipNotShownTimeout && w != nullptr && WidgetIsVisible(*w, widgetIndex))
{
gTooltipTimeout = 0;
gTooltipCloseTimeout = gCurrentRealTimeTicks + 8000;
WindowTooltipOpen(w, widgetIndex, screenCoords);
}
}
else
{
ResetTooltipNotShown();
}
gTooltipTimeout = 0;
gTooltipCloseTimeout = gCurrentRealTimeTicks + 8000;
gTooltipCursor = screenCoords;
}
else
{
gTooltipCursor = screenCoords;
ResetTooltipNotShown();
if (w == nullptr || gTooltipWidget.window_classification != w->classification
@ -1537,8 +1541,7 @@ static void InputUpdateTooltip(WindowBase* w, WidgetIndex widgetIndex, const Scr
WindowTooltipClose();
}
gTooltipTimeout += gCurrentDeltaTime;
if (gTooltipTimeout >= 8000)
if (gCurrentRealTimeTicks >= gTooltipCloseTimeout)
{
WindowCloseByClass(WindowClass::Tooltip);
}

View File

@ -648,7 +648,7 @@ public:
case WIDX_GUESTS:
case WIDX_PARK_RATING:
case WIDX_DATE:
gTooltipTimeout = 2000;
gTooltipCloseTimeout = gCurrentRealTimeTicks + 2000;
break;
}
return cursorId;

View File

@ -252,7 +252,7 @@ public:
CursorID OnCursor(WidgetIndex, const ScreenCoordsXY&, CursorID cursorId) override
{
gTooltipTimeout = 2000;
gTooltipCloseTimeout = gCurrentRealTimeTicks + 2000;
return cursorId;
}

View File

@ -11,6 +11,7 @@
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/Game.h>
#include <openrct2/Input.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatter.h>
@ -126,7 +127,7 @@ private:
void WindowTooltipReset(const ScreenCoordsXY& screenCoords)
{
gTooltipCursor = screenCoords;
gTooltipTimeout = 0;
gTooltipCloseTimeout = 0;
gTooltipWidget.window_classification = WindowClass::Null;
InputSetState(InputState::Normal);
InputSetFlag(INPUT_FLAG_4, false);
@ -188,6 +189,6 @@ void WindowTooltipOpen(WindowBase* widgetWindow, WidgetIndex widgetIndex, const
void WindowTooltipClose()
{
WindowCloseByClass(WindowClass::Tooltip);
gTooltipTimeout = 0;
gTooltipCloseTimeout = 0;
gTooltipWidget.window_classification = WindowClass::Null;
}

View File

@ -10,6 +10,7 @@
#include "Input.h"
#include "Context.h"
#include "Game.h"
InputState _inputState;
uint8_t _inputFlags;
@ -18,7 +19,7 @@ uint8_t gInputPlaceObjectModifier;
WidgetRef gHoverWidget;
WidgetRef gPressedWidget;
uint16_t _tooltipNotShownTicks;
uint32_t _tooltipNotShownTimeout;
Tool gCurrentToolId;
WidgetRef gCurrentToolWidget;
@ -75,7 +76,7 @@ InputState InputGetState()
void ResetTooltipNotShown()
{
_tooltipNotShownTicks = 0;
_tooltipNotShownTimeout = gCurrentRealTimeTicks + 50;
}
void InputResetPlaceObjModifier()

View File

@ -80,7 +80,7 @@ extern ScreenCoordsXY gInputDragLast;
extern WidgetRef gHoverWidget;
extern WidgetRef gPressedWidget;
extern uint16_t gTooltipTimeout;
extern uint32_t gTooltipCloseTimeout;
extern WidgetRef gTooltipWidget;
extern ScreenCoordsXY gTooltipCursor;
@ -90,7 +90,7 @@ extern WidgetRef gCurrentToolWidget;
// TODO: Move to openrct2-ui and make static again
extern InputState _inputState;
extern uint8_t _inputFlags;
extern uint16_t _tooltipNotShownTicks;
extern uint32_t _tooltipNotShownTimeout;
void InputWindowPositionBegin(WindowBase& w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords);