MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / OnClick

Method OnClick

src/signs_gui.cpp:472–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

470 }
471
472 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
473 {
474 switch (widget) {
475 case WID_QES_LOCATION: {
476 const Sign *si = Sign::Get(this->cur_sign);
477 TileIndex tile = TileVirtXY(si->x, si->y);
478 if (_ctrl_pressed) {
479 ShowExtraViewportWindow(tile);
480 } else {
481 ScrollMainWindowToTile(tile);
482 }
483 break;
484 }
485
486 case WID_QES_PREVIOUS:
487 case WID_QES_NEXT: {
488 const Sign *si = this->PrevNextSign(widget == WID_QES_NEXT);
489
490 /* Rebuild the sign list */
491 this->signs.ForceRebuild();
492 this->signs.NeedResort();
493 this->BuildSignsList();
494 this->SortSignsList();
495
496 /* Scroll to sign and reopen window */
497 ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
498 UpdateSignEditWindow(si);
499 break;
500 }
501
502 case WID_QES_OK:
503 if (RenameSign(this->cur_sign, this->name_editbox.text.GetText())) break;
504 [[fallthrough]];
505
506 case WID_QES_CANCEL:
507 this->Close();
508 break;
509
510 case WID_QES_DELETE:
511 /* Only need to set the buffer to null, the rest is handled as the OK button */
512 RenameSign(this->cur_sign, "");
513 /* don't delete this, we are deleted in Sign::~Sign() -> DeleteRenameSignWindow() */
514 break;
515
516 case WID_QES_MOVE:
517 HandlePlacePushButton(this, WID_QES_MOVE, SPR_CURSOR_SIGN, HT_RECT);
518 this->last_user_action = widget;
519 break;
520 }
521 }
522
523 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
524 {

Callers

nothing calls this directly

Calls 12

PrevNextSignMethod · 0.95
TileVirtXYFunction · 0.85
ShowExtraViewportWindowFunction · 0.85
ScrollMainWindowToTileFunction · 0.85
RenameSignFunction · 0.85
HandlePlacePushButtonFunction · 0.85
ForceRebuildMethod · 0.80
NeedResortMethod · 0.80
BuildSignsListMethod · 0.80
SortSignsListMethod · 0.80
GetTextMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected