OpenTTD Source: src/dock_gui.cpp Source File

OpenTTD Source 15.0-RC2

dock_gui.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "stdafx.h"
11#include "terraform_gui.h"
12#include "window_gui.h"
13#include "station_gui.h"
14#include "command_func.h"
15#include "water.h"
16#include "window_func.h"
17#include "vehicle_func.h"
18#include "sound_func.h"
19#include "viewport_func.h"
20#include "gfx_func.h"
21#include "company_func.h"
22#include "slope_func.h"
23#include "tilehighlight_func.h"
24#include "company_base.h"
25#include "hotkeys.h"
26#include "gui.h"
27#include "zoom_func.h"
28#include "tunnelbridge_cmd.h"
29#include "dock_cmd.h"
30#include "station_cmd.h"
31#include "water_cmd.h"
32#include "waypoint_cmd.h"
33#include "timer/timer.h"
34#include "timer/timer_game_calendar.h"
35
36#include "widgets/dock_widget.h"
37
38#include "table/sprites.h"
39#include "table/strings.h"
40
41#include "safeguards.h"
42
43static void ShowBuildDockStationPicker(Window *parent);
44static void ShowBuildDocksDepotPicker(Window *parent);
45
46static Axis _ship_depot_direction;
47
48void CcBuildDocks(Commands, const CommandCost &result, TileIndex tile)
49{
50 if (result.Failed()) return;
51
52 if (_settings_client.sound.confirm) SndPlayTileFx(SND_02_CONSTRUCTION_WATER, tile);
53 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
54}
55
56void CcPlaySound_CONSTRUCTION_WATER(Commands, const CommandCost &result, TileIndex tile)
57{
58 if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_02_CONSTRUCTION_WATER, tile);
59}
60
61
68 static TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to = nullptr)
69{
70 auto [slope, z] = GetTileSlopeZ(tile_from);
71 DiagDirection dir = GetInclinedSlopeDirection(slope);
72
73 /* If the direction isn't right, just return the next tile so the command
74 * complains about the wrong slope instead of the ends not matching up.
75 * Make sure the coordinate is always a valid tile within the map, so we
76 * don't go "off" the map. That would cause the wrong error message. */
77 if (!IsValidDiagDirection(dir)) return TileAddXY(tile_from, TileX(tile_from) > 2 ? -1 : 1, 0);
78
79 /* Direction the aqueduct is built to. */
80 TileIndexDiff offset = TileOffsByDiagDir(ReverseDiagDir(dir));
81 /* The maximum length of the aqueduct. */
82 int max_length = std::min<int>(_settings_game.construction.max_bridge_length, DistanceFromEdgeDir(tile_from, ReverseDiagDir(dir)) - 1);
83
84 TileIndex endtile = tile_from;
85 for (int length = 0; IsValidTile(endtile) && TileX(endtile) != 0 && TileY(endtile) != 0; length++) {
86 endtile = TileAdd(endtile, offset);
87
88 if (length > max_length) break;
89
90 if (GetTileMaxZ(endtile) > z) {
91 if (tile_to != nullptr) *tile_to = endtile;
92 break;
93 }
94 }
95
96 return endtile;
97}
98
100 struct BuildDocksToolbarWindow : Window {
101 WidgetID last_clicked_widget = INVALID_WIDGET;
102
103 BuildDocksToolbarWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
104 {
105 this->InitNested(window_number);
106 this->OnInvalidateData();
107 if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
108 }
109
110 void Close([[maybe_unused]] int data = 0) override
111 {
112 if (_game_mode == GM_NORMAL && this->IsWidgetLowered(WID_DT_STATION)) SetViewportCatchmentStation(nullptr, true);
113 if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
114 this->Window::Close();
115 }
116
122 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
123 {
124 if (!gui_scope) return;
125
126 bool can_build = CanBuildVehicleInfrastructure(VEH_SHIP);
127 this->SetWidgetsDisabledState(!can_build,
128 WID_DT_DEPOT,
129 WID_DT_STATION,
130 WID_DT_BUOY);
131 if (!can_build) {
132 CloseWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
133 CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);
134 }
135
136 if (_game_mode != GM_EDITOR) {
137 if (!can_build) {
138 /* Show in the tooltip why this button is disabled. */
139 this->GetWidget<NWidgetCore>(WID_DT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
140 this->GetWidget<NWidgetCore>(WID_DT_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
141 this->GetWidget<NWidgetCore>(WID_DT_BUOY)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
142 } else {
143 this->GetWidget<NWidgetCore>(WID_DT_DEPOT)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP);
144 this->GetWidget<NWidgetCore>(WID_DT_STATION)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP);
145 this->GetWidget<NWidgetCore>(WID_DT_BUOY)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP);
146 }
147 }
148 }
149
150 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
151 {
152 switch (widget) {
153 case WID_DT_CANAL: // Build canal button
154 if (_game_mode == GM_EDITOR) {
155 HandlePlacePushButton(this, WID_DT_CANAL, SPR_CURSOR_CANAL, HT_RECT);
156 } else {
157 HandlePlacePushButton(this, WID_DT_CANAL, SPR_CURSOR_CANAL, HT_RECT | HT_DIAGONAL);
158 }
159 break;
160
161 case WID_DT_LOCK: // Build lock button
162 HandlePlacePushButton(this, WID_DT_LOCK, SPR_CURSOR_LOCK, HT_SPECIAL);
163 break;
164
165 case WID_DT_DEMOLISH: // Demolish aka dynamite button
166 HandlePlacePushButton(this, WID_DT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
167 break;
168
169 case WID_DT_DEPOT: // Build depot button
170 if (HandlePlacePushButton(this, WID_DT_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT)) ShowBuildDocksDepotPicker(this);
171 break;
172
173 case WID_DT_STATION: // Build station button
174 if (HandlePlacePushButton(this, WID_DT_STATION, SPR_CURSOR_DOCK, HT_SPECIAL)) ShowBuildDockStationPicker(this);
175 break;
176
177 case WID_DT_BUOY: // Build buoy button
178 HandlePlacePushButton(this, WID_DT_BUOY, SPR_CURSOR_BUOY, HT_RECT);
179 break;
180
181 case WID_DT_RIVER: // Build river button (in scenario editor)
182 if (_game_mode != GM_EDITOR) return;
183 HandlePlacePushButton(this, WID_DT_RIVER, SPR_CURSOR_RIVER, HT_RECT | HT_DIAGONAL);
184 break;
185
186 case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button
187 HandlePlacePushButton(this, WID_DT_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, HT_SPECIAL);
188 break;
189
190 default: return;
191 }
192 this->last_clicked_widget = widget;
193 }
194
195 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
196 {
197 switch (this->last_clicked_widget) {
198 case WID_DT_CANAL: // Build canal button
199 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_WATER);
200 break;
201
202 case WID_DT_LOCK: // Build lock button
203 Command<CMD_BUILD_LOCK>::Post(STR_ERROR_CAN_T_BUILD_LOCKS, CcBuildDocks, tile);
204 break;
205
206 case WID_DT_DEMOLISH: // Demolish aka dynamite button
207 PlaceProc_DemolishArea(tile);
208 break;
209
210 case WID_DT_DEPOT: // Build depot button
211 Command<CMD_BUILD_SHIP_DEPOT>::Post(STR_ERROR_CAN_T_BUILD_SHIP_DEPOT, CcBuildDocks, tile, _ship_depot_direction);
212 break;
213
214 case WID_DT_STATION: { // Build station button
215 /* Determine the watery part of the dock. */
216 DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
217 TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile, ReverseDiagDir(dir)) : tile);
218
219 bool adjacent = _ctrl_pressed;
220 auto proc = [=](bool test, StationID to_join) -> bool {
221 if (test) {
222 return Command<CMD_BUILD_DOCK>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_DOCK>()), tile, StationID::Invalid(), adjacent).Succeeded();
223 } else {
224 return Command<CMD_BUILD_DOCK>::Post(STR_ERROR_CAN_T_BUILD_DOCK_HERE, CcBuildDocks, tile, to_join, adjacent);
225 }
226 };
227
228 ShowSelectStationIfNeeded(TileArea(tile, tile_to), proc);
229 break;
230 }
231
232 case WID_DT_BUOY: // Build buoy button
233 Command<CMD_BUILD_BUOY>::Post(STR_ERROR_CAN_T_POSITION_BUOY_HERE, CcBuildDocks, tile);
234 break;
235
236 case WID_DT_RIVER: // Build river button (in scenario editor)
237 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_RIVER);
238 break;
239
240 case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button
241 Command<CMD_BUILD_BRIDGE>::Post(STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE, CcBuildBridge, tile, GetOtherAqueductEnd(tile), TRANSPORT_WATER, 0, 0);
242 break;
243
244 default: NOT_REACHED();
245 }
246 }
247
248 void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
249 {
250 VpSelectTilesWithMethod(pt.x, pt.y, select_method);
251 }
252
253 Point OnInitialPosition(int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override
254 {
255 return AlignInitialConstructionToolbar(sm_width);
256 }
257
258 void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
259 {
260 if (pt.x != -1) {
261 switch (select_proc) {
262 case DDSP_DEMOLISH_AREA:
263 GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
264 break;
265 case DDSP_CREATE_WATER:
266 if (_game_mode == GM_EDITOR) {
267 Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, _ctrl_pressed ? WaterClass::Sea : WaterClass::Canal, false);
268 } else {
269 Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WaterClass::Canal, _ctrl_pressed);
270 }
271 break;
272 case DDSP_CREATE_RIVER:
273 Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WaterClass::River, _ctrl_pressed);
274 break;
275
276 default: break;
277 }
278 }
279 }
280
281 void OnPlaceObjectAbort() override
282 {
283 if (_game_mode != GM_EDITOR && this->IsWidgetLowered(WID_DT_STATION)) SetViewportCatchmentStation(nullptr, true);
284
285 this->RaiseButtons();
286
287 CloseWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
288 CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);
289 CloseWindowById(WC_SELECT_STATION, 0);
290 CloseWindowByClass(WC_BUILD_BRIDGE);
291 }
292
293 void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile_from) override
294 {
295 TileIndex tile_to = tile_from;
296
297 if (this->last_clicked_widget == WID_DT_BUILD_AQUEDUCT) {
298 GetOtherAqueductEnd(tile_from, &tile_to);
299 } else {
300 DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from));
301 if (IsValidDiagDirection(dir)) {
302 /* Locks and docks always select the tile "down" the slope. */
303 tile_to = TileAddByDiagDir(tile_from, ReverseDiagDir(dir));
304 /* Locks also select the tile "up" the slope. */
305 if (this->last_clicked_widget == WID_DT_LOCK) tile_from = TileAddByDiagDir(tile_from, dir);
306 }
307 }
308
309 VpSetPresizeRange(tile_from, tile_to);
310 }
311
317 static EventState DockToolbarGlobalHotkeys(int hotkey)
318 {
319 if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
320 Window *w = ShowBuildDocksToolbar();
321 if (w == nullptr) return ES_NOT_HANDLED;
322 return w->OnHotkey(hotkey);
323 }
324
325 static inline HotkeyList hotkeys{"dockstoolbar", {
326 Hotkey('1', "canal", WID_DT_CANAL),
327 Hotkey('2', "lock", WID_DT_LOCK),
328 Hotkey('3', "demolish", WID_DT_DEMOLISH),
329 Hotkey('4', "depot", WID_DT_DEPOT),
330 Hotkey('5', "dock", WID_DT_STATION),
331 Hotkey('6', "buoy", WID_DT_BUOY),
332 Hotkey('7', "river", WID_DT_RIVER),
333 Hotkey({'B', '8'}, "aqueduct", WID_DT_BUILD_AQUEDUCT),
334 }, DockToolbarGlobalHotkeys};
335};
336
341 static constexpr std::initializer_list<NWidgetPart> _nested_build_docks_toolbar_widgets = {
342 NWidget(NWID_HORIZONTAL),
343 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
344 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_WATERWAYS_TOOLBAR_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
345 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
346 EndContainer(),
347 NWidget(NWID_HORIZONTAL_LTR),
348 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_CANAL), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_BUILD_CANALS_TOOLTIP),
349 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_LOCK), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
350 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetToolbarSpacerMinimalSize(), SetFill(1, 1), EndContainer(),
351 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEMOLISH), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
352 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEPOT), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_SHIP_DEPOT, STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP),
353 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_STATION), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_SHIP_DOCK, STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP),
354 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUOY), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUOY, STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP),
355 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUILD_AQUEDUCT), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
356 EndContainer(),
357};
358
359static WindowDesc _build_docks_toolbar_desc(
360 WDP_MANUAL, "toolbar_water", 0, 0,
361 WC_BUILD_TOOLBAR, WC_NONE,
362 WindowDefaultFlag::Construction,
363 _nested_build_docks_toolbar_widgets,
364 &BuildDocksToolbarWindow::hotkeys
365);
366
374 Window *ShowBuildDocksToolbar()
375{
376 if (!Company::IsValidID(_local_company)) return nullptr;
377
378 CloseWindowByClass(WC_BUILD_TOOLBAR);
379 return AllocateWindowDescFront<BuildDocksToolbarWindow>(_build_docks_toolbar_desc, TRANSPORT_WATER);
380}
381
386 static constexpr std::initializer_list<NWidgetPart> _nested_build_docks_scen_toolbar_widgets = {
387 NWidget(NWID_HORIZONTAL),
388 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
389 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_WATERWAYS_TOOLBAR_CAPTION_SE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
390 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
391 EndContainer(),
392 NWidget(NWID_HORIZONTAL),
393 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_CANAL), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_CREATE_LAKE_TOOLTIP),
394 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_LOCK), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
395 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetToolbarSpacerMinimalSize(), SetFill(1, 1), EndContainer(),
396 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEMOLISH), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
397 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_RIVER), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUILD_RIVER, STR_WATERWAYS_TOOLBAR_CREATE_RIVER_TOOLTIP),
398 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUILD_AQUEDUCT), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
399 EndContainer(),
400};
401
403 static WindowDesc _build_docks_scen_toolbar_desc(
404 WDP_AUTO, "toolbar_water_scen", 0, 0,
405 WC_SCEN_BUILD_TOOLBAR, WC_NONE,
406 WindowDefaultFlag::Construction,
407 _nested_build_docks_scen_toolbar_widgets
408);
409
415 Window *ShowBuildDocksScenToolbar()
416{
417 return AllocateWindowDescFront<BuildDocksToolbarWindow>(_build_docks_scen_toolbar_desc, TRANSPORT_WATER);
418}
419
420 struct BuildDocksStationWindow : public PickerWindowBase {
421public:
422 BuildDocksStationWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent)
423 {
424 this->InitNested(TRANSPORT_WATER);
425 this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BDSW_LT_OFF);
426 }
427
428 void Close([[maybe_unused]] int data = 0) override
429 {
430 CloseWindowById(WC_SELECT_STATION, 0);
431 this->PickerWindowBase::Close();
432 }
433
434 void OnPaint() override
435 {
436 int rad = (_settings_game.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
437
438 this->DrawWidgets();
439
440 if (_settings_client.gui.station_show_coverage) {
441 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
442 } else {
443 SetTileSelectSize(1, 1);
444 }
445
446 /* strings such as 'Size' and 'Coverage Area' */
447 Rect r = this->GetWidget<NWidgetBase>(WID_BDSW_ACCEPTANCE)->GetCurrentRect();
448 const int bottom = r.bottom;
449 r.bottom = INT_MAX; // Allow overflow as we want to know the required height.
450 r.top = DrawStationCoverageAreaText(r, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal;
451 r.top = DrawStationCoverageAreaText(r, SCT_ALL, rad, true);
452 /* Resize background if the window is too small.
453 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
454 * (This is the case, if making the window bigger moves the mouse into the window.) */
455 if (r.top > bottom) {
456 ResizeWindow(this, 0, r.top - bottom, false);
457 }
458 }
459
460 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
461 {
462 switch (widget) {
463 case WID_BDSW_LT_OFF:
464 case WID_BDSW_LT_ON:
465 this->RaiseWidget(_settings_client.gui.station_show_coverage + WID_BDSW_LT_OFF);
466 _settings_client.gui.station_show_coverage = (widget != WID_BDSW_LT_OFF);
467 this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BDSW_LT_OFF);
468 SndClickBeep();
469 this->SetDirty();
470 SetViewportCatchmentStation(nullptr, true);
471 break;
472 }
473 }
474
475 void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
476 {
477 CheckRedrawStationCoverage(this);
478 }
479
480 const IntervalTimer<TimerGameCalendar> yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) {
481 this->InvalidateData();
482 }};
483};
484
486 static constexpr std::initializer_list<NWidgetPart> _nested_build_dock_station_widgets = {
487 NWidget(NWID_HORIZONTAL),
488 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
489 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_STATION_BUILD_DOCK_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
490 EndContainer(),
491 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BDSW_BACKGROUND),
492 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), SetPadding(WidgetDimensions::unscaled.picker),
493 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_picker, 0),
494 NWidget(WWT_LABEL, INVALID_COLOUR, WID_BDSW_INFO), SetStringTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE), SetFill(1, 0),
495 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize), SetPIP(14, 0, 14),
496 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDSW_LT_OFF), SetMinimalSize(60, 12), SetFill(1, 0), SetStringTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
497 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDSW_LT_ON), SetMinimalSize(60, 12), SetFill(1, 0), SetStringTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
498 EndContainer(),
499 EndContainer(),
500 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BDSW_ACCEPTANCE), SetResize(0, 1), SetMinimalTextLines(2, WidgetDimensions::unscaled.vsep_normal),
501 EndContainer(),
502 EndContainer(),
503};
504
505static WindowDesc _build_dock_station_desc(
506 WDP_AUTO, {}, 0, 0,
507 WC_BUILD_STATION, WC_BUILD_TOOLBAR,
508 WindowDefaultFlag::Construction,
509 _nested_build_dock_station_widgets
510);
511
512static void ShowBuildDockStationPicker(Window *parent)
513{
514 new BuildDocksStationWindow(_build_dock_station_desc, parent);
515}
516
517 struct BuildDocksDepotWindow : public PickerWindowBase {
518private:
519 static void UpdateDocksDirection()
520 {
521 if (_ship_depot_direction != AXIS_X) {
522 SetTileSelectSize(1, 2);
523 } else {
524 SetTileSelectSize(2, 1);
525 }
526 }
527
528public:
529 BuildDocksDepotWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent)
530 {
531 this->InitNested(TRANSPORT_WATER);
532 this->LowerWidget(WID_BDD_X + _ship_depot_direction);
533 UpdateDocksDirection();
534 }
535
536 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
537 {
538 switch (widget) {
539 case WID_BDD_X:
540 case WID_BDD_Y:
541 size.width = ScaleGUITrad(96) + WidgetDimensions::scaled.fullbevel.Horizontal();
542 size.height = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Vertical();
543 break;
544 }
545 }
546
547 void DrawWidget(const Rect &r, WidgetID widget) const override
548 {
549 DrawPixelInfo tmp_dpi;
550
551 switch (widget) {
552 case WID_BDD_X:
553 case WID_BDD_Y: {
554 Axis axis = widget == WID_BDD_X ? AXIS_X : AXIS_Y;
555
556 Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
557 if (FillDrawPixelInfo(&tmp_dpi, ir)) {
558 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
559 int x = (ir.Width() - ScaleSpriteTrad(96)) / 2;
560 int y = (ir.Height() - ScaleSpriteTrad(64)) / 2;
561 int x1 = ScaleSpriteTrad(63);
562 int x2 = ScaleSpriteTrad(31);
563 DrawShipDepotSprite(x + (axis == AXIS_X ? x1 : x2), y + ScaleSpriteTrad(17), axis, DepotPart::North);
564 DrawShipDepotSprite(x + (axis == AXIS_X ? x2 : x1), y + ScaleSpriteTrad(33), axis, DepotPart::South);
565 }
566 break;
567 }
568 }
569 }
570
571 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
572 {
573 switch (widget) {
574 case WID_BDD_X:
575 case WID_BDD_Y:
576 this->RaiseWidget(WID_BDD_X + _ship_depot_direction);
577 _ship_depot_direction = (widget == WID_BDD_X ? AXIS_X : AXIS_Y);
578 this->LowerWidget(WID_BDD_X + _ship_depot_direction);
579 SndClickBeep();
580 UpdateDocksDirection();
581 this->SetDirty();
582 break;
583 }
584 }
585};
586
587static constexpr std::initializer_list<NWidgetPart> _nested_build_docks_depot_widgets = {
588 NWidget(NWID_HORIZONTAL),
589 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
590 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_DEPOT_BUILD_SHIP_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
591 EndContainer(),
592 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BDD_BACKGROUND),
593 NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1), SetPadding(WidgetDimensions::unscaled.picker),
594 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDD_X), SetToolTip(STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP),
595 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDD_Y), SetToolTip(STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP),
596 EndContainer(),
597 EndContainer(),
598};
599
600static WindowDesc _build_docks_depot_desc(
601 WDP_AUTO, {}, 0, 0,
602 WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
603 WindowDefaultFlag::Construction,
604 _nested_build_docks_depot_widgets
605);
606
607
608static void ShowBuildDocksDepotPicker(Window *parent)
609{
610 new BuildDocksDepotWindow(_build_docks_depot_desc, parent);
611}
612
613
614void InitializeDockGui()
615{
616 _ship_depot_direction = AXIS_X;
617}
CcBuildBridge
void CcBuildBridge(Commands, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, uint8_t)
Callback executed after a build Bridge CMD has been called.
Definition bridge_gui.cpp:57
CommandCost
Common return value for all commands.
Definition command_type.h:24
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition command_type.h:168
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition command_type.h:177
IntervalTimer
An interval timer will fire every interval, and will continue to fire until it is deleted.
Definition timer.h:76
PickerWindowBase
Base class for windows opened from a toolbar.
Definition window_gui.h:992
PickerWindowBase::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition window.cpp:3599
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition window_gui.h:58
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel thickness.
Definition window_gui.h:39
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
command_func.h
Functions related to commands.
CommandFlagsToDCFlags
static constexpr DoCommandFlags CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
Definition command_func.h:48
Commands
Commands
List of commands.
Definition command_type.h:196
company_base.h
Definition of stuff that is very close to a company, like the company struct itself.
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition company_cmd.cpp:55
company_func.h
Functions related to companies.
ReverseDiagDir
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Definition direction_func.h:118
IsValidDiagDirection
bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
Definition direction_func.h:21
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition direction_type.h:123
AXIS_X
@ AXIS_X
The X axis.
Definition direction_type.h:124
AXIS_Y
@ AXIS_Y
The y axis.
Definition direction_type.h:125
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition direction_type.h:78
INVALID_DIAGDIR
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
Definition direction_type.h:85
dock_cmd.h
Command definitions related to docks.
_nested_build_docks_toolbar_widgets
static constexpr std::initializer_list< NWidgetPart > _nested_build_docks_toolbar_widgets
Nested widget parts of docks toolbar, game version.
Definition dock_gui.cpp:341
_nested_build_dock_station_widgets
static constexpr std::initializer_list< NWidgetPart > _nested_build_dock_station_widgets
Nested widget parts of a build dock station window.
Definition dock_gui.cpp:486
GetOtherAqueductEnd
static TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to=nullptr)
Gets the other end of the aqueduct, if possible.
Definition dock_gui.cpp:68
ShowBuildDocksScenToolbar
Window * ShowBuildDocksScenToolbar()
Open the build water toolbar window for the scenario editor.
Definition dock_gui.cpp:415
ShowBuildDocksToolbar
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
Definition dock_gui.cpp:374
_nested_build_docks_scen_toolbar_widgets
static constexpr std::initializer_list< NWidgetPart > _nested_build_docks_scen_toolbar_widgets
Nested widget parts of docks toolbar, scenario editor version.
Definition dock_gui.cpp:386
_build_docks_scen_toolbar_desc
static WindowDesc _build_docks_scen_toolbar_desc(WDP_AUTO, "toolbar_water_scen", 0, 0, WC_SCEN_BUILD_TOOLBAR, WC_NONE, WindowDefaultFlag::Construction, _nested_build_docks_scen_toolbar_widgets)
Window definition for the build docks in scenario editor window.
dock_widget.h
Types related to the dock widgets.
WID_DT_CANAL
@ WID_DT_CANAL
Build canal button.
Definition dock_widget.h:31
WID_DT_DEMOLISH
@ WID_DT_DEMOLISH
Demolish aka dynamite button.
Definition dock_widget.h:33
WID_DT_STATION
@ WID_DT_STATION
Build station button.
Definition dock_widget.h:35
WID_DT_RIVER
@ WID_DT_RIVER
Build river button (in scenario editor).
Definition dock_widget.h:37
WID_DT_LOCK
@ WID_DT_LOCK
Build lock button.
Definition dock_widget.h:32
WID_DT_DEPOT
@ WID_DT_DEPOT
Build depot button.
Definition dock_widget.h:34
WID_DT_BUOY
@ WID_DT_BUOY
Build buoy button.
Definition dock_widget.h:36
WID_DT_BUILD_AQUEDUCT
@ WID_DT_BUILD_AQUEDUCT
Build aqueduct button.
Definition dock_widget.h:38
WID_BDD_X
@ WID_BDD_X
X-direction button.
Definition dock_widget.h:16
WID_BDD_Y
@ WID_BDD_Y
Y-direction button.
Definition dock_widget.h:17
WID_BDD_BACKGROUND
@ WID_BDD_BACKGROUND
Background of the window.
Definition dock_widget.h:15
WID_BDSW_ACCEPTANCE
@ WID_BDSW_ACCEPTANCE
Acceptance info.
Definition dock_widget.h:26
WID_BDSW_LT_OFF
@ WID_BDSW_LT_OFF
'Off' button of coverage high light.
Definition dock_widget.h:23
WID_BDSW_INFO
@ WID_BDSW_INFO
'Coverage highlight' label.
Definition dock_widget.h:25
WID_BDSW_BACKGROUND
@ WID_BDSW_BACKGROUND
Background panel.
Definition dock_widget.h:22
WID_BDSW_LT_ON
@ WID_BDSW_LT_ON
'On' button of coverage high light.
Definition dock_widget.h:24
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition gfx.cpp:38
FillDrawPixelInfo
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Definition gfx.cpp:1565
gfx_func.h
Functions related to the gfx engine.
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition widget_type.h:1219
SetSpriteTip
constexpr NWidgetPart SetSpriteTip(SpriteID sprite, StringID tip={})
Widget part function for setting the sprite and tooltip.
Definition widget_type.h:1251
SetToolbarMinimalSize
constexpr NWidgetPart SetToolbarMinimalSize(int width)
Widget part function to setting the minimal size for a toolbar button.
Definition widget_type.h:1175
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition widget_type.h:1375
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition widget_type.h:1332
SetStringTip
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
Definition widget_type.h:1240
SetToolbarSpacerMinimalSize
constexpr NWidgetPart SetToolbarSpacerMinimalSize()
Widget part function to setting the minimal size for a toolbar spacer.
Definition widget_type.h:1165
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition widget_type.h:1156
SetToolTip
constexpr NWidgetPart SetToolTip(StringID tip)
Widget part function for setting tooltip and clearing the widget data.
Definition widget_type.h:1318
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1229
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1424
SetMinimalTextLines
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition widget_type.h:1187
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition widget_type.h:1145
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition widget_type.h:1387
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition window.cpp:966
gui.h
GUI functions that shouldn't be here.
hotkeys.h
Hotkey related functions.
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition main_gui.cpp:63
DistanceFromEdgeDir
uint DistanceFromEdgeDir(TileIndex tile, DiagDirection dir)
Gets the distance to the edge of the map in given direction.
Definition map.cpp:235
TileAddXY
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
Definition map_func.h:482
TileAddByDiagDir
TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
Definition map_func.h:623
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition map_func.h:437
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition map_func.h:427
TileAdd
constexpr TileIndex TileAdd(TileIndex tile, TileIndexDiff offset)
Adds a given offset to a tile.
Definition map_func.h:469
TileOffsByDiagDir
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition map_func.h:582
TileIndexDiff
int32_t TileIndexDiff
An offset value between two tiles.
Definition map_type.h:23
safeguards.h
A number of safeguards to prevent using unsafe methods.
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
slope_func.h
Functions related to slopes.
GetInclinedSlopeDirection
DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
Definition slope_func.h:239
SndClickBeep
void SndClickBeep()
Play a beep sound for a click event if enabled in settings.
Definition sound.cpp:253
sound_func.h
Functions related to sound.
SND_02_CONSTRUCTION_WATER
@ SND_02_CONSTRUCTION_WATER
0 == 0x00 Construction: water infrastructure
Definition sound_type.h:47
sprites.h
This file contains all sprite-related enums and defines.
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition sprites.h:1522
station_cmd.h
Command definitions related to stations.
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
Definition station_gui.cpp:2475
DrawStationCoverageAreaText
int DrawStationCoverageAreaText(const Rect &r, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
Definition station_gui.cpp:77
CheckRedrawStationCoverage
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Definition station_gui.cpp:159
station_gui.h
Contains enums and function declarations connected with stations GUI.
SCT_ALL
@ SCT_ALL
Draw all cargoes.
Definition station_gui.h:24
CA_DOCK
static constexpr uint CA_DOCK
Catchment for docks with "modified catchment" enabled.
Definition station_type.h:118
CA_UNMODIFIED
static constexpr uint CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition station_type.h:120
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
AutoRestoreBackup
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Definition backup_type.hpp:150
BuildDocksDepotWindow
Definition dock_gui.cpp:517
BuildDocksDepotWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition dock_gui.cpp:547
BuildDocksDepotWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition dock_gui.cpp:571
BuildDocksDepotWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
Definition dock_gui.cpp:536
BuildDocksStationWindow
Definition dock_gui.cpp:420
BuildDocksStationWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition dock_gui.cpp:460
BuildDocksStationWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition dock_gui.cpp:434
BuildDocksStationWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition dock_gui.cpp:475
BuildDocksStationWindow::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition dock_gui.cpp:428
BuildDocksToolbarWindow
Toolbar window for constructing water infrastructure.
Definition dock_gui.cpp:100
BuildDocksToolbarWindow::last_clicked_widget
WidgetID last_clicked_widget
Contains the last widget that has been clicked on this toolbar.
Definition dock_gui.cpp:101
BuildDocksToolbarWindow::OnPlacePresize
void OnPlacePresize(Point pt, TileIndex tile_from) override
The user moves over the map when a tile highlight mode has been set when the special mouse mode has b...
Definition dock_gui.cpp:293
BuildDocksToolbarWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition dock_gui.cpp:150
BuildDocksToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition dock_gui.cpp:281
BuildDocksToolbarWindow::DockToolbarGlobalHotkeys
static EventState DockToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildDocksToolbarWindow.
Definition dock_gui.cpp:317
BuildDocksToolbarWindow::OnInitialPosition
Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
Compute the initial position of the window.
Definition dock_gui.cpp:253
BuildDocksToolbarWindow::OnPlaceDrag
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
The user is dragging over the map when the tile highlight mode has been set.
Definition dock_gui.cpp:248
BuildDocksToolbarWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition dock_gui.cpp:195
BuildDocksToolbarWindow::OnPlaceMouseUp
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
The user has dragged over the map when the tile highlight mode has been set.
Definition dock_gui.cpp:258
BuildDocksToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition dock_gui.cpp:122
BuildDocksToolbarWindow::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition dock_gui.cpp:110
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition settings_type.h:653
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition settings_type.h:650
CommandHelper
Definition command_func.h:83
ConstructionSettings::max_bridge_length
uint16_t max_bridge_length
maximum length of bridges
Definition settings_type.h:413
Coord2D< int >
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition geometry_type.hpp:56
DrawPixelInfo
Data about how and where to blit pixels.
Definition gfx_type.h:157
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition settings_type.h:225
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition settings_type.h:224
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition settings_type.h:176
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition settings_type.h:635
GameSettings::station
StationSettings station
settings related to station management
Definition settings_type.h:644
HotkeyList
List of hotkeys for a window.
Definition hotkeys.h:37
Hotkey
All data for a single hotkey.
Definition hotkeys.h:21
PoolID< uint16_t, struct StationIDTag, 64000, 0xFFFF >
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition pool_type.hpp:376
RectPadding::Horizontal
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition geometry_type.hpp:89
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition geometry_type.hpp:95
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition geometry_type.hpp:101
Rect::Width
int Width() const
Get width of Rect.
Definition geometry_type.hpp:111
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition geometry_type.hpp:124
Rect::Height
int Height() const
Get height of Rect.
Definition geometry_type.hpp:117
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition settings_type.h:275
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition settings_type.h:593
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
WindowDesc
High level window description.
Definition window_gui.h:168
WindowNumber
Number to differentiate different windows of the same class.
Definition window_type.h:760
Window
Data structure for an opened window.
Definition window_gui.h:274
Window::Close
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition window.cpp:1102
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition widget.cpp:766
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition window.cpp:3234
Window::parent
Window * parent
Parent window.
Definition window_gui.h:329
Window::RaiseWidget
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition window_gui.h:470
Window::resize
ResizeInfo resize
Resize information.
Definition window_gui.h:315
Window::SetWidgetsDisabledState
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition window_gui.h:516
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition window_gui.h:492
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition window.cpp:530
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition window_gui.h:461
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1820
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition window.cpp:570
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:303
GUIPlaceProcDragXY
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
A central place to handle all X_AND_Y dragged GUI functions.
Definition terraform_gui.cpp:112
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition terraform_gui.cpp:151
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition terraform_gui.cpp:364
terraform_gui.h
GUI stuff related to terraforming.
GetTileSlopeZ
std::tuple< Slope, int > GetTileSlopeZ(TileIndex tile)
Return the slope of a given tile inside the map.
Definition tile_map.cpp:55
GetTileMaxZ
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
Definition tile_map.cpp:136
IsValidTile
bool IsValidTile(Tile tile)
Checks if a tile is valid.
Definition tile_map.h:161
GetTileSlope
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
Definition tile_map.h:279
TileArea
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition tilearea_type.h:102
tilehighlight_func.h
Functions related to tile highlights.
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition viewport.cpp:3573
VpSetPresizeRange
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Definition viewport.cpp:2853
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition viewport.cpp:3291
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition viewport.cpp:2798
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition tilehighlight_type.h:28
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition tilehighlight_type.h:21
HT_SPECIAL
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
Definition tilehighlight_type.h:23
timer.h
Definition of Interval and OneShot timers.
timer_game_calendar.h
Definition of the game-calendar-timer.
TRANSPORT_WATER
@ TRANSPORT_WATER
Transport over water.
Definition transport_type.h:27
tunnelbridge_cmd.h
Command definitions related to tunnels and bridges.
CanBuildVehicleInfrastructure
bool CanBuildVehicleInfrastructure(VehicleType type, uint8_t subtype)
Check whether we can build infrastructure for the given vehicle type.
Definition vehicle.cpp:1903
vehicle_func.h
Functions related to vehicles.
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition vehicle_type.h:27
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition viewport.cpp:2619
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition viewport.cpp:3713
viewport_func.h
Functions related to (drawing on) viewports.
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition viewport_type.h:96
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition viewport_type.h:100
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition viewport_type.h:115
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition viewport_type.h:116
DDSP_CREATE_WATER
@ DDSP_CREATE_WATER
Create a canal.
Definition viewport_type.h:122
DDSP_CREATE_RIVER
@ DDSP_CREATE_RIVER
Create rivers.
Definition viewport_type.h:123
water.h
Functions related to water (management)
water_cmd.h
Command definitions related to water tiles.
WaterClass::River
@ River
River.
WaterClass::Canal
@ Canal
Canal.
WaterClass::Sea
@ Sea
Sea.
DepotPart::South
@ South
Southern part of a depot.
DepotPart::North
@ North
Northern part of a depot.
waypoint_cmd.h
Command definitions related to waypoints.
ScaleGUITrad
static RectPadding ScaleGUITrad(const RectPadding &r)
Scale a RectPadding to GUI zoom level.
Definition widget.cpp:49
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition widget_type.h:41
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition widget_type.h:48
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:44
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition widget_type.h:57
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:52
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:68
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:37
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition widget_type.h:67
EqualSize
@ EqualSize
Containers should keep all their (resizing) children equally large.
Definition widget_type.h:541
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition window.cpp:1193
ResizeWindow
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen, bool schedule_resize)
Resize the window.
Definition window.cpp:2096
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition window.cpp:1205
AlignInitialConstructionToolbar
Point AlignInitialConstructionToolbar(int window_width)
Compute the position of the construction toolbars.
Definition window.cpp:1699
window_func.h
Window functions not directly related to making/drawing windows.
window_gui.h
Functions, definitions and such used only by the GUI.
WindowDefaultFlag::Construction
@ Construction
This window is used for construction; close it whenever changing company.
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition window_gui.h:144
WDP_MANUAL
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition window_gui.h:143
WidgetID
int WidgetID
Widget ID.
Definition window_type.h:20
EventState
EventState
State of handling an event.
Definition window_type.h:780
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition window_type.h:782
INVALID_WIDGET
static constexpr WidgetID INVALID_WIDGET
An invalid widget index.
Definition window_type.h:23
WC_BUILD_STATION
@ WC_BUILD_STATION
Build station; Window numbers:
Definition window_type.h:408
WC_SCEN_BUILD_TOOLBAR
@ WC_SCEN_BUILD_TOOLBAR
Scenario build toolbar; Window numbers:
Definition window_type.h:85
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition window_type.h:78
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:50
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition window_type.h:460
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition window_type.h:247
WC_BUILD_DEPOT
@ WC_BUILD_DEPOT
Build depot; Window numbers:
Definition window_type.h:428
WC_BUILD_BRIDGE
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Definition window_type.h:400
zoom_func.h
Functions related to zooming.
ScaleSpriteTrad
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition zoom_func.h:107