From 3c87ae6a923b2281f70353551937c87b60953f5d Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 10 Dec 2024 22:52:05 +0100 Subject: [PATCH] Guest window: make pickup animation lengths dynamic --- src/openrct2-ui/windows/Guest.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index e7f12100e0..8d78da66cd 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -875,21 +875,30 @@ namespace OpenRCT2::Ui::Windows void OnUpdateOverview() { - _guestAnimationFrame++; - _guestAnimationFrame %= 24; - - // Update pickup animation, can only happen in this tab. - picked_peep_frame++; - picked_peep_frame %= 48; - - WidgetInvalidate(*this, WIDX_TAB_1); - WidgetInvalidate(*this, WIDX_TAB_2); - const auto peep = GetGuest(); if (peep == nullptr) { return; } + + auto& objManager = GetContext()->GetObjectManager(); + auto* animObj = objManager.GetLoadedObject(peep->AnimationObjectIndex); + + // Overview tab animation offset + _guestAnimationFrame++; + _guestAnimationFrame %= 24; + + // Get pickup animation length + const auto& pickAnim = animObj->GetPeepAnimation(peep->AnimationGroup, PeepAnimationType::Hanging); + const auto pickAnimLength = pickAnim.frame_offsets.size(); + + // Update pickup animation, can only happen in this tab. + picked_peep_frame++; + picked_peep_frame %= pickAnimLength * 4; + + WidgetInvalidate(*this, WIDX_TAB_1); + WidgetInvalidate(*this, WIDX_TAB_2); + if (peep->WindowInvalidateFlags & PEEP_INVALIDATE_PEEP_ACTION) { peep->WindowInvalidateFlags &= ~PEEP_INVALIDATE_PEEP_ACTION;