diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 1d0dea5b82..c9c2073b2d 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -635,16 +635,12 @@ namespace OpenRCT2::Ui::Windows auto& objManager = GetContext()->GetObjectManager(); auto* animObj = objManager.GetLoadedObject(staff->AnimationObjectIndex); - int32_t imageIndex = animObj->GetPeepAnimation(staff->AnimationGroup).base_image + 1; - int32_t offset = 0; - + const auto& anim = animObj->GetPeepAnimation(staff->AnimationGroup); + int32_t animFrame = 0; if (page == WINDOW_STAFF_OVERVIEW) - { - offset = _tabAnimationOffset; - offset = floor2(offset, 4); - } - imageIndex += offset; + animFrame = _tabAnimationOffset / 4; + auto imageIndex = anim.base_image + 1 + anim.frame_offsets[animFrame] * 4; GfxDrawSprite(clip_dpi, ImageId(imageIndex, staff->TshirtColour, staff->TrousersColour), screenCoords); } @@ -694,12 +690,25 @@ namespace OpenRCT2::Ui::Windows void OverviewUpdate() { - _tabAnimationOffset++; - _tabAnimationOffset %= 24; + auto* staff = GetStaff(); + auto& objManager = GetContext()->GetObjectManager(); + auto* animObj = objManager.GetLoadedObject(staff->AnimationObjectIndex); - // Update pickup animation, can only happen in this tab. + // Get walking animation length + const auto& walkingAnim = animObj->GetPeepAnimation(staff->AnimationGroup, PeepAnimationType::Walking); + const auto walkingAnimLength = walkingAnim.frame_offsets.size(); + + // Overview tab animation offset + _tabAnimationOffset++; + _tabAnimationOffset %= walkingAnimLength * 4; + + // Get pickup animation length + const auto& pickAnim = animObj->GetPeepAnimation(staff->AnimationGroup, PeepAnimationType::Hanging); + const auto pickAnimLength = pickAnim.frame_offsets.size(); + + // Update pickup animation frame picked_peep_frame++; - picked_peep_frame %= 48; + picked_peep_frame %= pickAnimLength * 4; InvalidateWidget(WIDX_TAB_1); } @@ -741,8 +750,8 @@ namespace OpenRCT2::Ui::Windows auto& objManager = GetContext()->GetObjectManager(); auto* animObj = objManager.GetLoadedObject(staff->AnimationObjectIndex); - auto baseImageId = animObj->GetPeepAnimation(staff->AnimationGroup, PeepAnimationType::Hanging).base_image; - baseImageId += picked_peep_frame >> 2; + auto& pickupAnim = animObj->GetPeepAnimation(staff->AnimationGroup, PeepAnimationType::Hanging); + auto baseImageId = pickupAnim.base_image + pickupAnim.frame_offsets[picked_peep_frame >> 2]; gPickupPeepImage = ImageId(baseImageId, staff->TshirtColour, staff->TrousersColour); } diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 24b5e02e7c..2fd81fa4ce 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -189,26 +189,29 @@ namespace OpenRCT2::Ui::Windows void OnUpdate() override { - _tabAnimationIndex++; - if (_tabAnimationIndex >= 24) + auto animPeepType = AnimationPeepType(static_cast(_selectedTab) + 1); + auto* animObj = findPeepAnimationsObjectForType(animPeepType); + if (animObj != nullptr) { - _tabAnimationIndex = 0; - } - else - { - InvalidateWidget(WIDX_STAFF_LIST_HANDYMEN_TAB + _selectedTab); + auto& anim = animObj->GetPeepAnimation(PeepAnimationGroup::Normal); + _tabAnimationIndex++; - // Enable highlighting of these staff members in map window - auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager(); - if (windowMgr->FindByClass(WindowClass::Map) != nullptr) + if (_tabAnimationIndex >= anim.frame_offsets.size() * 4) + _tabAnimationIndex = 0; + + InvalidateWidget(WIDX_STAFF_LIST_HANDYMEN_TAB + _selectedTab); + } + + // Enable highlighting of these staff members in map window + auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager(); + if (windowMgr->FindByClass(WindowClass::Map) != nullptr) + { + for (auto peep : EntityList()) { - for (auto peep : EntityList()) + EntitySetFlashing(peep, false); + if (peep->AssignedStaffType == GetSelectedStaffType()) { - EntitySetFlashing(peep, false); - if (peep->AssignedStaffType == GetSelectedStaffType()) - { - EntitySetFlashing(peep, true); - } + EntitySetFlashing(peep, true); } } } @@ -624,8 +627,10 @@ namespace OpenRCT2::Ui::Windows auto widgetIndex = WIDX_STAFF_LIST_HANDYMEN_TAB + tabIndex; const auto& widget = widgets[widgetIndex]; - auto imageId = (_selectedTab == tabIndex ? (_tabAnimationIndex & ~3) : 0); - imageId += animObj->GetPeepAnimation(PeepAnimationGroup::Normal).base_image + 1; + auto frame = _selectedTab == tabIndex ? _tabAnimationIndex / 4 : 0; + auto& anim = animObj->GetPeepAnimation(PeepAnimationGroup::Normal); + auto imageId = anim.base_image + 1 + anim.frame_offsets[frame] * 4; + GfxDrawSprite( dpi, ImageId(imageId, colour), windowPos + ScreenCoordsXY{ (widget.left + widget.right) / 2, widget.bottom - 6 }); @@ -645,8 +650,10 @@ namespace OpenRCT2::Ui::Windows clippedDpi, dpi, windowPos + ScreenCoordsXY{ widget.left + 1, widget.top + 1 }, widget.right - widget.left - 1, widget.bottom - widget.top - 1)) { - auto imageId = (_selectedTab == 3 ? (_tabAnimationIndex & ~3) : 0); - imageId += animObj->GetPeepAnimation(PeepAnimationGroup::Normal).base_image + 1; + auto frame = _selectedTab == tabIndex ? _tabAnimationIndex / 4 : 0; + auto& anim = animObj->GetPeepAnimation(PeepAnimationGroup::Normal); + auto imageId = anim.base_image + 1 + anim.frame_offsets[frame] * 4; + GfxDrawSprite(clippedDpi, ImageId(imageId), { 15, 23 }); } }