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

Method eventOccurred

game/ui/components/locationscreen.cpp:83–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81void LocationScreen::finish() {}
82
83void LocationScreen::eventOccurred(Event *e)
84{
85 menuform->eventOccured(e);
86 if (menuform->eventIsWithin(e))
87 {
88 return;
89 }
90
91 if (e->type() == EVENT_KEY_DOWN)
92 {
93 if (e->keyboard().KeyCode == SDLK_ESCAPE || e->keyboard().KeyCode == SDLK_RETURN ||
94 e->keyboard().KeyCode == SDLK_KP_ENTER)
95 {
96 menuform->findControl("BUTTON_QUIT")->click();
97 return;
98 }
99 }
100
101 if (e->type() == EVENT_FORM_INTERACTION && e->forms().EventFlag == FormEventType::ButtonClick)
102 {
103 if (e->forms().RaisedBy->Name == "BUTTON_QUIT")
104 {
105 fw().stageQueueCommand({StageCmd::Command::POP});
106 return;
107 }
108 if (e->forms().RaisedBy->Name == "BUTTON_EQUIPAGENT")
109 {
110 if (agentAssignment->currentAgent)
111 {
112 fw().stageQueueCommand(
113 {StageCmd::Command::PUSH,
114 mksp<AEquipScreen>(this->state, agentAssignment->currentAgent)});
115 }
116 return;
117 }
118 if (e->forms().RaisedBy->Name == "BUTTON_EQUIPVEHICLE")
119 {
120 if (agentAssignment->currentVehicle)
121 {
122 auto equipScreen = mksp<VEquipScreen>(this->state);
123 equipScreen->setSelectedVehicle(agentAssignment->currentVehicle);
124 fw().stageQueueCommand({StageCmd::Command::PUSH, equipScreen});
125 }
126 return;
127 }
128 }
129}
130
131void LocationScreen::update() { menuform->update(); }
132

Callers

nothing calls this directly

Calls 7

eventIsWithinMethod · 0.80
typeMethod · 0.80
findControlMethod · 0.80
stageQueueCommandMethod · 0.80
setSelectedVehicleMethod · 0.80
eventOccuredMethod · 0.45
clickMethod · 0.45

Tested by

no test coverage detected