MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / ActionMenuState

Method ActionMenuState

src/Battlescape/ActionMenuState.cpp:52–139  ·  view source on GitHub ↗

* Initializes all the elements in the Action Menu window. * @param game Pointer to the core game. * @param action Pointer to the action. * @param x Position on the x-axis. * @param y position on the y-axis. */

Source from the content-addressed store, hash-verified

50 * @param y position on the y-axis.
51 */
52ActionMenuState::ActionMenuState(Game *game, BattleAction *action, int x, int y) : State(game), _action(action)
53{
54 _screen = false;
55
56 // Set palette
57 setPalette("PAL_BATTLESCAPE");
58
59 for (int i = 0; i < 6; ++i)
60 {
61 _actionMenu[i] = new ActionMenuItem(i, _game, x, y);
62 add(_actionMenu[i]);
63 _actionMenu[i]->setVisible(false);
64 _actionMenu[i]->onMouseClick((ActionHandler)&ActionMenuState::btnActionMenuItemClick);
65 }
66
67 // Build up the popup menu
68 int id = 0;
69 RuleItem *weapon = _action->weapon->getRules();
70
71 // throwing (if not a fixed weapon)
72 if (!weapon->isFixed())
73 {
74 addItem(BA_THROW, "STR_THROW", &id);
75 }
76
77 // priming
78 if ((weapon->getBattleType() == BT_GRENADE || weapon->getBattleType() == BT_PROXIMITYGRENADE)
79 && _action->weapon->getFuseTimer() == -1)
80 {
81 addItem(BA_PRIME, "STR_PRIME_GRENADE", &id);
82 }
83
84 if (weapon->getBattleType() == BT_FIREARM)
85 {
86 if (weapon->isWaypoint() || (_action->weapon->getAmmoItem() && _action->weapon->getAmmoItem()->getRules()->isWaypoint()))
87 {
88 addItem(BA_LAUNCH, "STR_LAUNCH_MISSILE", &id);
89 }
90 else
91 {
92 if (weapon->getAccuracyAuto() != 0)
93 {
94 addItem(BA_AUTOSHOT, "STR_AUTO_SHOT", &id);
95 }
96 if (weapon->getAccuracySnap() != 0)
97 {
98 addItem(BA_SNAPSHOT, "STR_SNAP_SHOT", &id);
99 }
100 if (weapon->getAccuracyAimed() != 0)
101 {
102 addItem(BA_AIMEDSHOT, "STR_AIMED_SHOT", &id);
103 }
104 }
105 }
106
107 if (weapon->getTUMelee())
108 {
109 // stun rod

Callers

nothing calls this directly

Calls 14

onMouseClickMethod · 0.80
isFixedMethod · 0.80
getBattleTypeMethod · 0.80
isWaypointMethod · 0.80
getAccuracyAutoMethod · 0.80
getAccuracySnapMethod · 0.80
getAccuracyAimedMethod · 0.80
getTUMeleeMethod · 0.80
getDamageTypeMethod · 0.80
setVisibleMethod · 0.45
getRulesMethod · 0.45
getFuseTimerMethod · 0.45

Tested by

no test coverage detected