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

Method DisplayDamageNumberString

src/Utilities/GeneralUtils.cpp:217–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217void GeneralUtils::DisplayDamageNumberString(int damage, DamageDisplayType type, CoordStruct coords, int& offset)
218{
219 if (damage == 0)
220 return;
221
222 ColorStruct color;
223
224 switch (type)
225 {
226 case DamageDisplayType::Regular:
227 color = damage > 0 ? ColorStruct { 255, 0, 0 } : ColorStruct { 0, 255, 0 };
228 break;
229 case DamageDisplayType::Shield:
230 color = damage > 0 ? ColorStruct { 0, 160, 255 } : ColorStruct { 0, 255, 230 };
231 break;
232 case DamageDisplayType::Intercept:
233 color = damage > 0 ? ColorStruct { 255, 128, 128 } : ColorStruct { 128, 255, 128 };
234 break;
235 default:
236 break;
237 }
238
239 int maxOffset = Unsorted::CellWidthInPixels / 2;
240 int width = 0, height = 0;
241 wchar_t damageStr[0x20];
242 swprintf_s(damageStr, L"%d", damage);
243
244 BitFont::Instance->GetTextDimension(damageStr, &width, &height, 120);
245
246 if (offset >= maxOffset || offset == INT32_MIN)
247 offset = -maxOffset;
248
249 FlyingStrings::Add(damageStr, coords, color, Point2D { offset - (width / 2), 0 });
250
251 offset = offset + width;
252}
253
254DynamicVectorClass<ColorScheme*>* GeneralUtils::BuildPalette(const char* paletteFileName)
255{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected