MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / AddMoneyString

Method AddMoneyString

src/Misc/FlyingStrings.cpp:33–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33void FlyingStrings::AddMoneyString(int amount, ObjectClass* pSource, HouseClass* pOwner,
34 AffectedHouse displayToHouses, const CoordStruct& coords, Point2D pixelOffset)
35{
36 if (amount == 0 || MapClass::Instance.IsLocationShrouded(coords))
37 return;
38
39 if (displayToHouses != AffectedHouse::All && !EnumFunctions::CanTargetHouse(displayToHouses, pOwner, HouseClass::CurrentPlayer))
40 return;
41
42 if (pSource && pSource->VisualCharacter(false, nullptr) == VisualType::Hidden)
43 return;
44
45 const bool isPositive = amount > 0;
46 const ColorStruct color = isPositive ? ColorStruct { 0, 255, 0 } : ColorStruct { 255, 0, 0 };
47 wchar_t moneyStr[0x20];
48 swprintf_s(moneyStr, L"%ls%ls%d", isPositive ? L"+" : L"-", Phobos::UI::CostLabel, std::abs(amount));
49
50 int width = 0, height = 0;
51 BitFont::Instance->GetTextDimension(moneyStr, &width, &height, 120);
52 pixelOffset.X -= (width / 2);
53
54 FlyingStrings::Add(moneyStr, coords, color, pixelOffset);
55}
56
57void FlyingStrings::UpdateAll()
58{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected