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

Method eventOccurred

game/ui/base/basescreen.cpp:219–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217void BaseScreen::finish() {}
218
219void BaseScreen::eventOccurred(Event *e)
220{
221 form->eventOccured(e);
222
223 if (e->type() == EVENT_KEY_DOWN)
224 {
225 if (form->findControlTyped<TextEdit>("TEXT_BASE_NAME")->isFocused())
226 return;
227 if (e->keyboard().KeyCode == SDLK_ESCAPE || e->keyboard().KeyCode == SDLK_RETURN ||
228 e->keyboard().KeyCode == SDLK_KP_ENTER)
229 {
230 form->findControl("BUTTON_OK")->click();
231 return;
232 }
233 if (e->keyboard().KeyCode == SDLK_F10)
234 {
235 for (auto &facility : state->current_base->facilities)
236 {
237 {
238 facility->buildTime = 0;
239 }
240 }
241 return;
242 }
243 }
244
245 if (e->type() == EVENT_MOUSE_MOVE)
246 {
247 mousePos = {e->mouse().X, e->mouse().Y};
248 }
249
250 if (e->type() == EVENT_FORM_INTERACTION)
251 {
252 if (e->forms().RaisedBy == baseView)
253 {
254 if (e->forms().EventFlag == FormEventType::MouseMove)
255 {
256 selection = {e->forms().MouseInfo.X, e->forms().MouseInfo.Y};
257 selection /= BaseGraphics::TILE_SIZE;
258 if (!drag)
259 {
260 selFacility = state->current_base->getFacility(selection);
261 }
262 return;
263 }
264 else if (e->forms().EventFlag == FormEventType::MouseLeave)
265 {
266 selection = NO_SELECTION;
267 selFacility = nullptr;
268 return;
269 }
270 }
271 if (e->forms().RaisedBy->Name == "LISTBOX_FACILITIES")
272 {
273 if (!drag && e->forms().EventFlag == FormEventType::ListBoxChangeHover)
274 {
275 auto list = form->findControlTyped<ListBox>("LISTBOX_FACILITIES");
276 auto dragFacilityName = list->getHoveredData<UString>();

Callers

nothing calls this directly

Calls 15

trFunction · 0.85
formatFunction · 0.85
typeMethod · 0.80
findControlMethod · 0.80
getFacilityMethod · 0.80
stageQueueCommandMethod · 0.80
canBuildFacilityMethod · 0.80
buildFacilityMethod · 0.80
getPlayerBalanceMethod · 0.80
canDestroyFacilityMethod · 0.80
destroyFacilityMethod · 0.80
refreshViewMethod · 0.80

Tested by

no test coverage detected