MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / displayImplementation

Method displayImplementation

game/ui/general/aequipmentsheet.cpp:44–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44void AEquipmentSheet::displayImplementation(sp<AEquipment> item, const AEquipmentType &itemType,
45 bool researched)
46{
47 if (!researched)
48 {
49 displayAlien(item, itemType);
50 return;
51 }
52
53 form->findControlTyped<Label>("ITEM_NAME")->setText(itemType.name);
54 form->findControlTyped<Graphic>("SELECTED_IMAGE")
55 ->setImage(item ? item->getEquipmentImage() : itemType.equipscreen_sprite);
56
57 // when possible, the actual item's weight takes precedence
58 form->findControlTyped<Label>("LABEL_1_L")->setText(tr("Weight"));
59 form->findControlTyped<Label>("LABEL_1_R")
60 ->setText(format("%d", item ? item->getWeight() : itemType.weight));
61
62 switch (itemType.type)
63 {
64 case AEquipmentType::Type::Grenade:
65 displayGrenade(item, itemType);
66 break;
67 case AEquipmentType::Type::Ammo:
68 displayAmmo(item, itemType);
69 break;
70 case AEquipmentType::Type::Weapon:
71 if (itemType.ammo_types.empty()) // weapon with built-in ammo like stun grapple
72 {
73 displayAmmo(item, itemType);
74 }
75 else if (item && item->getPayloadType()) // weapon with equipped ammo
76 {
77 displayAmmo(item, *item->getPayloadType());
78 }
79 else if (itemType.ammo_types.size() ==
80 1) // weapon without ammo but a single ammo type like lawpistol
81 {
82 displayAmmo(item, **itemType.ammo_types.begin());
83 }
84 else
85 {
86 displayWeapon(
87 item,
88 itemType); // weapon without ammo but multiple ammo types like the autocannon
89 }
90 break;
91 case AEquipmentType::Type::Armor:
92 displayArmor(item, itemType);
93 break;
94 default:
95 displayOther(item, itemType);
96 }
97}
98
99void AEquipmentSheet::displayGrenade(sp<AEquipment> item [[maybe_unused]],
100 const AEquipmentType &itemType)

Callers

nothing calls this directly

Calls 10

trFunction · 0.85
formatFunction · 0.85
emptyMethod · 0.80
getPayloadTypeMethod · 0.80
setTextMethod · 0.45
setImageMethod · 0.45
getEquipmentImageMethod · 0.45
getWeightMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected