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

Method OnPageElementClick

src/story_gui.cpp:531–586  ·  view source on GitHub ↗

* Internal event handler for when a page element is clicked. * @param pe The clicked page element. */

Source from the content-addressed store, hash-verified

529 * @param pe The clicked page element.
530 */
531 void OnPageElementClick(const StoryPageElement &pe)
532 {
533 switch (pe.type) {
534 case SPET_TEXT:
535 /* Do nothing. */
536 break;
537
538 case SPET_LOCATION:
539 if (_ctrl_pressed) {
540 ShowExtraViewportWindow((TileIndex)pe.referenced_id);
541 } else {
542 ScrollMainWindowToTile((TileIndex)pe.referenced_id);
543 }
544 break;
545
546 case SPET_GOAL:
547 ShowGoalsList(this->window_number);
548 break;
549
550 case SPET_BUTTON_PUSH:
551 if (this->active_button_id != StoryPageElementID::Invalid()) ResetObjectToPlace();
552 this->active_button_id = pe.index;
553 this->SetTimeout();
554 this->SetWidgetDirty(WID_SB_PAGE_PANEL);
555
556 Command<CMD_STORY_PAGE_BUTTON>::Post(TileIndex{}, pe.index, VehicleID::Invalid());
557 break;
558
559 case SPET_BUTTON_TILE:
560 if (this->active_button_id == pe.index) {
561 ResetObjectToPlace();
562 this->active_button_id = StoryPageElementID::Invalid();
563 } else {
564 CursorID cursor = TranslateStoryPageButtonCursor(StoryPageButtonData{ pe.referenced_id }.GetCursor());
565 SetObjectToPlaceWnd(cursor, PAL_NONE, HT_RECT, this);
566 this->active_button_id = pe.index;
567 }
568 this->SetWidgetDirty(WID_SB_PAGE_PANEL);
569 break;
570
571 case SPET_BUTTON_VEHICLE:
572 if (this->active_button_id == pe.index) {
573 ResetObjectToPlace();
574 this->active_button_id = StoryPageElementID::Invalid();
575 } else {
576 CursorID cursor = TranslateStoryPageButtonCursor(StoryPageButtonData{ pe.referenced_id }.GetCursor());
577 SetObjectToPlaceWnd(cursor, PAL_NONE, HT_VEHICLE, this);
578 this->active_button_id = pe.index;
579 }
580 this->SetWidgetDirty(WID_SB_PAGE_PANEL);
581 break;
582
583 default:
584 NOT_REACHED();
585 }
586 }
587
588public:

Callers 1

OnClickMethod · 0.95

Calls 11

ShowExtraViewportWindowFunction · 0.85
ScrollMainWindowToTileFunction · 0.85
ShowGoalsListFunction · 0.85
InvalidFunction · 0.85
ResetObjectToPlaceFunction · 0.85
SetObjectToPlaceWndFunction · 0.85
NOT_REACHEDFunction · 0.85
SetTimeoutMethod · 0.80
SetWidgetDirtyMethod · 0.80
GetCursorMethod · 0.80

Tested by

no test coverage detected