MCPcopy Create free account
hub / github.com/crossuo/crossuo / GetAnimationDimensions

Method GetAnimationDimensions

src/Managers/AnimationManager.cpp:1498–1538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1496static std::unordered_map<AnimationId, AnimationFrameInfo> s_DimensionsCache;
1497
1498AnimationFrameInfo
1499CAnimationManager::GetAnimationDimensions(uint8_t frameIndex, AnimationState anim, bool isCorpse)
1500{
1501 AnimationFrameInfo result = {};
1502 const auto animId = AnimId(anim);
1503 const auto animation = uo_animation_get(animId);
1504 if (animation == nullptr)
1505 return result;
1506
1507 const auto it = s_DimensionsCache.find(animId);
1508 if (it != s_DimensionsCache.end())
1509 return it->second;
1510
1511 int fc = animation->FrameCount;
1512 if (fc > 0)
1513 {
1514 if (frameIndex >= fc)
1515 {
1516 frameIndex = 0;
1517 }
1518
1519 if (animation->Frames != nullptr)
1520 {
1521 auto &frame = animation->Frames[frameIndex];
1522 auto spr = (CSprite *)frame.UserData;
1523 if (spr)
1524 {
1525 result.Width = spr->Width;
1526 result.Height = spr->Height;
1527 result.CenterX = frame.CenterX;
1528 result.CenterY = frame.CenterY;
1529 s_DimensionsCache[animId] = result;
1530 return result;
1531 }
1532 }
1533 }
1534
1535 g_FileManager.LoadAnimationFrameInfo(result, anim, frameIndex, isCorpse);
1536 s_DimensionsCache[animId] = result;
1537 return result;
1538}
1539
1540AnimationFrameInfo CAnimationManager::GetAnimationDimensions(
1541 uint8_t animIndex, AnimationState anim, bool isMounted, bool isCorpse, uint8_t frameIndex)

Callers 7

UpdateTextCoordinatesMethod · 0.80
AddTileToRenderListMethod · 0.80
DrawGameWindowMethod · 0.80
UpdateOffsetsMethod · 0.80

Calls 5

AnimIdFunction · 0.85
uo_animation_getFunction · 0.85
findMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected