MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / DrawAmmoSelector

Method DrawAmmoSelector

TombEngine/Game/gui.cpp:2637–2705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2635 }
2636
2637 void GuiController::DrawAmmoSelector()
2638 {
2639 if (!AmmoSelectorFlag)
2640 return;
2641
2642 float opacity = AmmoSelectorFadeVal / 128.0f;
2643
2644 // Don't draw fading UI elements if opacity is lower than minimal threshold.
2645 if (opacity <= 0.1f)
2646 return;
2647
2648 int xPos = (2 * PHD_CENTER_X - OBJLIST_SPACING) / 2;
2649 if (NumAmmoSlots == 2)
2650 xPos -= OBJLIST_SPACING / 2;
2651 else if (NumAmmoSlots == 3)
2652 xPos -= OBJLIST_SPACING;
2653
2654 if (NumAmmoSlots > 0)
2655 {
2656 for (int n = 0; n < NumAmmoSlots; n++)
2657 {
2658 auto* invObject = &InventoryObjectTable[AmmoObjectList[n].InventoryItem];
2659
2660 if (n == *CurrentAmmoType)
2661 {
2662 if (invObject->RotFlags & INV_ROT_X)
2663 AmmoObjectList[n].Orientation.x += ANGLE(5.0f / g_Renderer.GetFramerateMultiplier());
2664
2665 if (invObject->RotFlags & INV_ROT_Y)
2666 AmmoObjectList[n].Orientation.y += ANGLE(5.0f / g_Renderer.GetFramerateMultiplier());
2667
2668 if (invObject->RotFlags & INV_ROT_Z)
2669 AmmoObjectList[n].Orientation.z += ANGLE(5.0f / g_Renderer.GetFramerateMultiplier());
2670 }
2671 else
2672 SpinBack(AmmoObjectList[n].Orientation);
2673
2674 int x = PHD_CENTER_X - 300 + xPos;
2675 int y = 480;
2676 int objectNumber = ConvertInventoryItemToObject(AmmoObjectList[n].InventoryItem);
2677 float scale = InventoryObjectTable[AmmoObjectList[n].InventoryItem].Scale1;
2678
2679 if (n == *CurrentAmmoType)
2680 {
2681 char invTextBuffer[256];
2682
2683 if (AmmoObjectList[n].Amount == NO_VALUE)
2684 {
2685 sprintf(&invTextBuffer[0], g_GameFlow->GetString(STRING_UNLIMITED), g_GameFlow->GetString(InventoryObjectTable[AmmoObjectList[n].InventoryItem].ObjectName));
2686 }
2687 else
2688 {
2689 sprintf(&invTextBuffer[0], "%d x %s", AmmoObjectList[n].Amount, g_GameFlow->GetString(InventoryObjectTable[AmmoObjectList[n].InventoryItem].ObjectName));
2690 }
2691
2692 auto color = g_GameFlow->GetSettings()->UI.OptionTextColor;
2693 color.SetA(opacity * UCHAR_MAX);
2694 g_Renderer.AddString(PHD_CENTER_X, 380, &invTextBuffer[0], color, (int)PrintStringFlags::Center | (int)PrintStringFlags::Outline);

Callers 1

RenderNewInventoryMethod · 0.80

Calls 10

ANGLEFunction · 0.85
sprintfFunction · 0.85
GetStringMethod · 0.80
GetSettingsMethod · 0.80
AddStringMethod · 0.80
DrawObjectIn2DSpaceMethod · 0.80
Vector2Function · 0.50
SetAMethod · 0.45

Tested by

no test coverage detected