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

Method OnClick

src/smallmap_gui.cpp:1699–1812  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1697 }
1698
1699 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1700 {
1701 switch (widget) {
1702 case WID_SM_MAP: { // Map window
1703 if (click_count > 0) this->mouse_capture_widget = widget;
1704
1705 const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP);
1706 Window *w = GetMainWindow();
1707 int sub;
1708 pt = this->PixelToTile(pt.x - wid->pos_x, pt.y - wid->pos_y, &sub);
1709 ScrollWindowTo(this->scroll_x + pt.x * TILE_SIZE, this->scroll_y + pt.y * TILE_SIZE, -1, w);
1710
1711 this->SetDirty();
1712 break;
1713 }
1714
1715 case WID_SM_ZOOM_IN:
1716 case WID_SM_ZOOM_OUT: {
1717 const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP);
1718 Point zoom_pt = { (int)wid->current_x / 2, (int)wid->current_y / 2};
1719 this->SetZoomLevel((widget == WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &zoom_pt);
1720 SndClickBeep();
1721 break;
1722 }
1723
1724 case WID_SM_CONTOUR: // Show land contours
1725 case WID_SM_VEHICLES: // Show vehicles
1726 case WID_SM_INDUSTRIES: // Show industries
1727 case WID_SM_LINKSTATS: // Show route map
1728 case WID_SM_ROUTES: // Show transport routes
1729 case WID_SM_VEGETATION: // Show vegetation
1730 case WID_SM_OWNERS: // Show land owners
1731 this->SwitchMapType((SmallMapType)(widget - WID_SM_CONTOUR));
1732 SndClickBeep();
1733 break;
1734
1735 case WID_SM_CENTERMAP: // Center the smallmap again
1736 this->SmallMapCenterOnCurrentPos();
1737 this->HandleButtonClick(WID_SM_CENTERMAP);
1738 break;
1739
1740 case WID_SM_TOGGLETOWNNAME: // Toggle town names
1741 this->show_towns = !this->show_towns;
1742 this->SetWidgetLoweredState(WID_SM_TOGGLETOWNNAME, this->show_towns);
1743
1744 this->SetDirty();
1745 SndClickBeep();
1746 break;
1747
1748 case WID_SM_SHOW_IND_NAMES: // Toggle industry names
1749 this->show_ind_names = !this->show_ind_names;
1750 this->SetWidgetLoweredState(WID_SM_SHOW_IND_NAMES, this->show_ind_names);
1751
1752 this->SetDirty();
1753 SndClickBeep();
1754 break;
1755
1756 case WID_SM_LEGEND: // Legend

Callers

nothing calls this directly

Calls 15

PixelToTileMethod · 0.95
SetZoomLevelMethod · 0.95
SwitchMapTypeMethod · 0.95
GetPositionOnLegendMethod · 0.95
SelectLegendItemMethod · 0.95
SetOverlayCargoMaskMethod · 0.95
GetMainWindowFunction · 0.85
ScrollWindowToFunction · 0.85
SndClickBeepFunction · 0.85
NOT_REACHEDFunction · 0.85

Tested by

no test coverage detected