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

Method OnClick

src/town_gui.cpp:475–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473 }
474
475 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
476 {
477 switch (widget) {
478 case WID_TV_CENTER_VIEW: // scroll to location
479 if (_ctrl_pressed) {
480 ShowExtraViewportWindow(this->town->xy);
481 } else {
482 ScrollMainWindowToTile(this->town->xy);
483 }
484 break;
485
486 case WID_TV_SHOW_AUTHORITY: // town authority
487 ShowTownAuthorityWindow(this->window_number);
488 break;
489
490 case WID_TV_CHANGE_NAME: // rename
491 ShowQueryString(GetString(STR_TOWN_NAME, this->window_number), STR_TOWN_VIEW_RENAME_TOWN_BUTTON, MAX_LENGTH_TOWN_NAME_CHARS, this, CS_ALPHANUMERAL, {QueryStringFlag::EnableDefault, QueryStringFlag::LengthIsInChars});
492 break;
493
494 case WID_TV_CATCHMENT:
495 SetViewportCatchmentTown(Town::Get(this->window_number), !this->IsWidgetLowered(WID_TV_CATCHMENT));
496 break;
497
498 case WID_TV_EXPAND: // expand town - only available on Scenario editor
499 Command<CMD_EXPAND_TOWN>::Post(STR_ERROR_CAN_T_EXPAND_TOWN, static_cast<TownID>(this->window_number), 0, {TownExpandMode::Buildings, TownExpandMode::Roads});
500 break;
501
502 case WID_TV_EXPAND_BUILDINGS: // expand buildings of town - only available on Scenario editor
503 Command<CMD_EXPAND_TOWN>::Post(STR_ERROR_CAN_T_EXPAND_TOWN, static_cast<TownID>(this->window_number), 0, {TownExpandMode::Buildings});
504 break;
505
506 case WID_TV_EXPAND_ROADS: // expand roads of town - only available on Scenario editor
507 Command<CMD_EXPAND_TOWN>::Post(STR_ERROR_CAN_T_EXPAND_TOWN, static_cast<TownID>(this->window_number), 0, {TownExpandMode::Roads});
508 break;
509
510 case WID_TV_DELETE: // delete town - only available on Scenario editor
511 Command<CMD_DELETE_TOWN>::Post(STR_ERROR_TOWN_CAN_T_DELETE, static_cast<TownID>(this->window_number));
512 break;
513
514 case WID_TV_GRAPH: {
515 ShowTownCargoGraph(this->window_number);
516 break;
517 }
518 }
519 }
520
521 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
522 {

Callers

nothing calls this directly

Calls 8

ShowExtraViewportWindowFunction · 0.85
ScrollMainWindowToTileFunction · 0.85
ShowTownAuthorityWindowFunction · 0.85
ShowQueryStringFunction · 0.85
SetViewportCatchmentTownFunction · 0.85
ShowTownCargoGraphFunction · 0.85
IsWidgetLoweredMethod · 0.80
GetStringFunction · 0.70

Tested by

no test coverage detected