MCPcopy Create free account
hub / github.com/bwapi/bwapi / updateGraphicData

Method updateGraphicData

bwapi/BWAPI/Source/BW/CImage.cpp:18–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 return Position(this->horizontalOffset, this->verticalOffset) + this->spriteOwner->position;
17 }
18 void CImage::updateGraphicData()
19 {
20 grpHead *pGrpHead = this->GRPFile;
21 grpFrame *pGrpFrame = this->getCurrentFrame();
22
23 if ( !(this->flags & 2) ) // Sets the left boundary of the image
24 this->mapPosition.x = this->getPosition().x - pGrpHead->width/2 + pGrpFrame->x;
25 else // Not sure
26 this->mapPosition.x = this->getPosition().x + pGrpHead->width/2 - (pGrpFrame->wid + pGrpFrame->x);
27
28 if ( !(this->flags & 4) ) // Sets the top boundary of the image
29 this->mapPosition.y = this->getPosition().y - pGrpHead->height/2 + pGrpFrame->y;
30
31 rect bounds = { 0, 0, pGrpFrame->wid, pGrpFrame->hgt };
32 BW::Position screen(this->mapPosition);
33 screen -= Position(static_cast<short>(BW::BWDATA::MoveToX), static_cast<short>(BW::BWDATA::MoveToY));
34
35 if ( screen.x < 0 )
36 {
37 bounds.right += screen.x; // screenX is negative
38 bounds.left += -screen.x; // -screenX is positive
39 screen.x = 0;
40 }
41 if ( screen.y < 0 )
42 {
43 bounds.bottom += screen.y; // screenY is negative
44 bounds.top += -screen.y; // -screenY is positive
45 screen.y = 0;
46 }
47 bounds.right = static_cast<s16>(std::min<int>(bounds.right, BW::BWDATA::GameScreenBuffer.width() - screen.x));
48 bounds.bottom = static_cast<s16>(std::min<int>(bounds.bottom, BW::BWDATA::GameScreenBuffer.height() - screen.y));
49
50 this->screenPosition = screen;
51 this->grpBounds = bounds;
52 }
53
54 void CImage::drawImage()
55 {

Callers

nothing calls this directly

Calls 5

getCurrentFrameMethod · 0.95
getPositionMethod · 0.95
PositionClass · 0.50
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected