OpenTTD Source: src/dock_gui.cpp Source File

OpenTTD Source 15.0-beta1

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 <http://www.gnu.org/licenses/>.
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 DockToolbarWidgets last_clicked_widget;
102
103 BuildDocksToolbarWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
104 {
105 this->last_clicked_widget = WID_DT_INVALID;
106 this->InitNested(window_number);
107 this->OnInvalidateData();
108 if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
109 }
110
111 void Close([[maybe_unused]] int data = 0) override
112 {
113 if (_game_mode == GM_NORMAL && this->IsWidgetLowered(WID_DT_STATION)) SetViewportCatchmentStation(nullptr, true);
114 if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
115 this->Window::Close();
116 }
117
123 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
124 {
125 if (!gui_scope) return;
126
127 bool can_build = CanBuildVehicleInfrastructure(VEH_SHIP);
128 this->SetWidgetsDisabledState(!can_build,
129 WID_DT_DEPOT,
130 WID_DT_STATION,
131 WID_DT_BUOY);
132 if (!can_build) {
133 CloseWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
134 CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);
135 }
136
137 if (_game_mode != GM_EDITOR) {
138 if (!can_build) {
139 /* Show in the tooltip why this button is disabled. */
140 this->GetWidget<NWidgetCore>(WID_DT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
141 this->GetWidget<NWidgetCore>(WID_DT_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
142 this->GetWidget<NWidgetCore>(WID_DT_BUOY)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
143 } else {
144 this->GetWidget<NWidgetCore>(WID_DT_DEPOT)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP);
145 this->GetWidget<NWidgetCore>(WID_DT_STATION)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP);
146 this->GetWidget<NWidgetCore>(WID_DT_BUOY)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP);
147 }
148 }
149 }
150
151 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
152 {
153 switch (widget) {
154 case WID_DT_CANAL: // Build canal button
155 HandlePlacePushButton(this, WID_DT_CANAL, SPR_CURSOR_CANAL, HT_RECT);
156 break;
157
158 case WID_DT_LOCK: // Build lock button
159 HandlePlacePushButton(this, WID_DT_LOCK, SPR_CURSOR_LOCK, HT_SPECIAL);
160 break;
161
162 case WID_DT_DEMOLISH: // Demolish aka dynamite button
163 HandlePlacePushButton(this, WID_DT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
164 break;
165
166 case WID_DT_DEPOT: // Build depot button
167 if (HandlePlacePushButton(this, WID_DT_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT)) ShowBuildDocksDepotPicker(this);
168 break;
169
170 case WID_DT_STATION: // Build station button
171 if (HandlePlacePushButton(this, WID_DT_STATION, SPR_CURSOR_DOCK, HT_SPECIAL)) ShowBuildDockStationPicker(this);
172 break;
173
174 case WID_DT_BUOY: // Build buoy button
175 HandlePlacePushButton(this, WID_DT_BUOY, SPR_CURSOR_BUOY, HT_RECT);
176 break;
177
178 case WID_DT_RIVER: // Build river button (in scenario editor)
179 if (_game_mode != GM_EDITOR) return;
180 HandlePlacePushButton(this, WID_DT_RIVER, SPR_CURSOR_RIVER, HT_RECT | HT_DIAGONAL);
181 break;
182
183 case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button
184 HandlePlacePushButton(this, WID_DT_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, HT_SPECIAL);
185 break;
186
187 default: return;
188 }
189 this->last_clicked_widget = (DockToolbarWidgets)widget;
190 }
191
192 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
193 {
194 switch (this->last_clicked_widget) {
195 case WID_DT_CANAL: // Build canal button
196 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_WATER);
197 break;
198
199 case WID_DT_LOCK: // Build lock button
200 Command<CMD_BUILD_LOCK>::Post(STR_ERROR_CAN_T_BUILD_LOCKS, CcBuildDocks, tile);
201 break;
202
203 case WID_DT_DEMOLISH: // Demolish aka dynamite button
204 PlaceProc_DemolishArea(tile);
205 break;
206
207 case WID_DT_DEPOT: // Build depot button
208 Command<CMD_BUILD_SHIP_DEPOT>::Post(STR_ERROR_CAN_T_BUILD_SHIP_DEPOT, CcBuildDocks, tile, _ship_depot_direction);
209 break;
210
211 case WID_DT_STATION: { // Build station button
212 /* Determine the watery part of the dock. */
213 DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
214 TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile, ReverseDiagDir(dir)) : tile);
215
216 bool adjacent = _ctrl_pressed;
217 auto proc = [=](bool test, StationID to_join) -> bool {
218 if (test) {
219 return Command<CMD_BUILD_DOCK>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_DOCK>()), tile, INVALID_STATION, adjacent).Succeeded();
220 } else {
221 return Command<CMD_BUILD_DOCK>::Post(STR_ERROR_CAN_T_BUILD_DOCK_HERE, CcBuildDocks, tile, to_join, adjacent);
222 }
223 };
224
225 ShowSelectStationIfNeeded(TileArea(tile, tile_to), proc);
226 break;
227 }
228
229 case WID_DT_BUOY: // Build buoy button
230 Command<CMD_BUILD_BUOY>::Post(STR_ERROR_CAN_T_POSITION_BUOY_HERE, CcBuildDocks, tile);
231 break;
232
233 case WID_DT_RIVER: // Build river button (in scenario editor)
234 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_RIVER);
235 break;
236
237 case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button
238 Command<CMD_BUILD_BRIDGE>::Post(STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE, CcBuildBridge, tile, GetOtherAqueductEnd(tile), TRANSPORT_WATER, 0, 0);
239 break;
240
241 default: NOT_REACHED();
242 }
243 }
244
245 void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
246 {
247 VpSelectTilesWithMethod(pt.x, pt.y, select_method);
248 }
249
250 void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
251 {
252 if (pt.x != -1) {
253 switch (select_proc) {
254 case DDSP_DEMOLISH_AREA:
255 GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
256 break;
257 case DDSP_CREATE_WATER:
258 Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, (_game_mode == GM_EDITOR && _ctrl_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL, false);
259 break;
260 case DDSP_CREATE_RIVER:
261 Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WATER_CLASS_RIVER, _ctrl_pressed);
262 break;
263
264 default: break;
265 }
266 }
267 }
268
269 void OnPlaceObjectAbort() override
270 {
271 if (_game_mode != GM_EDITOR && this->IsWidgetLowered(WID_DT_STATION)) SetViewportCatchmentStation(nullptr, true);
272
273 this->RaiseButtons();
274
275 CloseWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
276 CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);
277 CloseWindowById(WC_SELECT_STATION, 0);
278 CloseWindowByClass(WC_BUILD_BRIDGE);
279 }
280
281 void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile_from) override
282 {
283 TileIndex tile_to = tile_from;
284
285 if (this->last_clicked_widget == WID_DT_BUILD_AQUEDUCT) {
286 GetOtherAqueductEnd(tile_from, &tile_to);
287 } else {
288 DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from));
289 if (IsValidDiagDirection(dir)) {
290 /* Locks and docks always select the tile "down" the slope. */
291 tile_to = TileAddByDiagDir(tile_from, ReverseDiagDir(dir));
292 /* Locks also select the tile "up" the slope. */
293 if (this->last_clicked_widget == WID_DT_LOCK) tile_from = TileAddByDiagDir(tile_from, dir);
294 }
295 }
296
297 VpSetPresizeRange(tile_from, tile_to);
298 }
299
305 static EventState DockToolbarGlobalHotkeys(int hotkey)
306 {
307 if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
308 Window *w = ShowBuildDocksToolbar();
309 if (w == nullptr) return ES_NOT_HANDLED;
310 return w->OnHotkey(hotkey);
311 }
312
313 static inline HotkeyList hotkeys{"dockstoolbar", {
314 Hotkey('1', "canal", WID_DT_CANAL),
315 Hotkey('2', "lock", WID_DT_LOCK),
316 Hotkey('3', "demolish", WID_DT_DEMOLISH),
317 Hotkey('4', "depot", WID_DT_DEPOT),
318 Hotkey('5', "dock", WID_DT_STATION),
319 Hotkey('6', "buoy", WID_DT_BUOY),
320 Hotkey('7', "river", WID_DT_RIVER),
321 Hotkey({'B', '8'}, "aqueduct", WID_DT_BUILD_AQUEDUCT),
322 }, DockToolbarGlobalHotkeys};
323};
324
329 static constexpr NWidgetPart _nested_build_docks_toolbar_widgets[] = {
330 NWidget(NWID_HORIZONTAL),
331 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
332 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WATERWAYS_TOOLBAR_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
333 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
334 EndContainer(),
335 NWidget(NWID_HORIZONTAL_LTR),
336 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_CANAL), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_BUILD_CANALS_TOOLTIP),
337 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_LOCK), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
338 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(5, 22), SetFill(1, 1), EndContainer(),
339 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEMOLISH), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
340 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEPOT), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_SHIP_DEPOT, STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP),
341 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_STATION), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_SHIP_DOCK, STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP),
342 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUOY), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUOY, STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP),
343 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUILD_AQUEDUCT), SetMinimalSize(23, 22), SetFill(0, 1), SetDataTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
344 EndContainer(),
345};
346
347static WindowDesc _build_docks_toolbar_desc(
348 WDP_ALIGN_TOOLBAR, "toolbar_water", 0, 0,
349 WC_BUILD_TOOLBAR, WC_NONE,
350 WDF_CONSTRUCTION,
351 _nested_build_docks_toolbar_widgets,
352 &BuildDocksToolbarWindow::hotkeys
353);
354
362 Window *ShowBuildDocksToolbar()
363{
364 if (!Company::IsValidID(_local_company)) return nullptr;
365
366 CloseWindowByClass(WC_BUILD_TOOLBAR);
367 return AllocateWindowDescFront<BuildDocksToolbarWindow>(_build_docks_toolbar_desc, TRANSPORT_WATER);
368}
369
374 static constexpr NWidgetPart _nested_build_docks_scen_toolbar_widgets[] = {
375 NWidget(NWID_HORIZONTAL),
376 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
377 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WATERWAYS_TOOLBAR_CAPTION_SE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
378 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
379 EndContainer(),
380 NWidget(NWID_HORIZONTAL),
381 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_CANAL), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_CREATE_LAKE_TOOLTIP),
382 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_LOCK), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
383 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(5, 22), SetFill(1, 1), EndContainer(),
384 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEMOLISH), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
385 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_RIVER), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_RIVER, STR_WATERWAYS_TOOLBAR_CREATE_RIVER_TOOLTIP),
386 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUILD_AQUEDUCT), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
387 EndContainer(),
388};
389
391 static WindowDesc _build_docks_scen_toolbar_desc(
392 WDP_AUTO, "toolbar_water_scen", 0, 0,
393 WC_SCEN_BUILD_TOOLBAR, WC_NONE,
394 WDF_CONSTRUCTION,
395 _nested_build_docks_scen_toolbar_widgets
396);
397
403 Window *ShowBuildDocksScenToolbar()
404{
405 return AllocateWindowDescFront<BuildDocksToolbarWindow>(_build_docks_scen_toolbar_desc, TRANSPORT_WATER);
406}
407
409 enum BuildDockStationWidgets {
410 BDSW_BACKGROUND,
411 BDSW_LT_OFF,
412 BDSW_LT_ON,
413 BDSW_INFO,
414 BDSW_ACCEPTANCE,
415};
416
417 struct BuildDocksStationWindow : public PickerWindowBase {
418public:
419 BuildDocksStationWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent)
420 {
421 this->InitNested(TRANSPORT_WATER);
422 this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
423 }
424
425 void Close([[maybe_unused]] int data = 0) override
426 {
427 CloseWindowById(WC_SELECT_STATION, 0);
428 this->PickerWindowBase::Close();
429 }
430
431 void OnPaint() override
432 {
433 int rad = (_settings_game.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
434
435 this->DrawWidgets();
436
437 if (_settings_client.gui.station_show_coverage) {
438 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
439 } else {
440 SetTileSelectSize(1, 1);
441 }
442
443 /* strings such as 'Size' and 'Coverage Area' */
444 Rect r = this->GetWidget<NWidgetBase>(BDSW_ACCEPTANCE)->GetCurrentRect();
445 int top = r.top;
446 top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal;
447 top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true);
448 /* Resize background if the window is too small.
449 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
450 * (This is the case, if making the window bigger moves the mouse into the window.) */
451 if (top > r.bottom) {
452 ResizeWindow(this, 0, top - r.bottom, false);
453 }
454 }
455
456 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
457 {
458 switch (widget) {
459 case BDSW_LT_OFF:
460 case BDSW_LT_ON:
461 this->RaiseWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
462 _settings_client.gui.station_show_coverage = (widget != BDSW_LT_OFF);
463 this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
464 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
465 this->SetDirty();
466 SetViewportCatchmentStation(nullptr, true);
467 break;
468 }
469 }
470
471 void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
472 {
473 CheckRedrawStationCoverage(this);
474 }
475
476 IntervalTimer<TimerGameCalendar> yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) {
477 this->InvalidateData();
478 }};
479};
480
482 static constexpr NWidgetPart _nested_build_dock_station_widgets[] = {
483 NWidget(NWID_HORIZONTAL),
484 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
485 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_DOCK_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
486 EndContainer(),
487 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BDSW_BACKGROUND),
488 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), SetPadding(WidgetDimensions::unscaled.picker),
489 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_picker, 0),
490 NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BDSW_INFO), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
491 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(14, 0, 14),
492 NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_OFF), SetMinimalSize(60, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
493 NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_ON), SetMinimalSize(60, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
494 EndContainer(),
495 EndContainer(),
496 NWidget(WWT_EMPTY, COLOUR_GREY, BDSW_ACCEPTANCE), SetResize(0, 1), SetMinimalTextLines(2, WidgetDimensions::unscaled.vsep_normal),
497 EndContainer(),
498 EndContainer(),
499};
500
501static WindowDesc _build_dock_station_desc(
502 WDP_AUTO, nullptr, 0, 0,
503 WC_BUILD_STATION, WC_BUILD_TOOLBAR,
504 WDF_CONSTRUCTION,
505 _nested_build_dock_station_widgets
506);
507
508static void ShowBuildDockStationPicker(Window *parent)
509{
510 new BuildDocksStationWindow(_build_dock_station_desc, parent);
511}
512
513 struct BuildDocksDepotWindow : public PickerWindowBase {
514private:
515 static void UpdateDocksDirection()
516 {
517 if (_ship_depot_direction != AXIS_X) {
518 SetTileSelectSize(1, 2);
519 } else {
520 SetTileSelectSize(2, 1);
521 }
522 }
523
524public:
525 BuildDocksDepotWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent)
526 {
527 this->InitNested(TRANSPORT_WATER);
528 this->LowerWidget(WID_BDD_X + _ship_depot_direction);
529 UpdateDocksDirection();
530 }
531
532 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
533 {
534 switch (widget) {
535 case WID_BDD_X:
536 case WID_BDD_Y:
537 size.width = ScaleGUITrad(96) + WidgetDimensions::scaled.fullbevel.Horizontal();
538 size.height = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Vertical();
539 break;
540 }
541 }
542
543 void DrawWidget(const Rect &r, WidgetID widget) const override
544 {
545 DrawPixelInfo tmp_dpi;
546
547 switch (widget) {
548 case WID_BDD_X:
549 case WID_BDD_Y: {
550 Axis axis = widget == WID_BDD_X ? AXIS_X : AXIS_Y;
551
552 Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
553 if (FillDrawPixelInfo(&tmp_dpi, ir)) {
554 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
555 int x = (ir.Width() - ScaleSpriteTrad(96)) / 2;
556 int y = (ir.Height() - ScaleSpriteTrad(64)) / 2;
557 int x1 = ScaleSpriteTrad(63);
558 int x2 = ScaleSpriteTrad(31);
559 DrawShipDepotSprite(x + (axis == AXIS_X ? x1 : x2), y + ScaleSpriteTrad(17), axis, DEPOT_PART_NORTH);
560 DrawShipDepotSprite(x + (axis == AXIS_X ? x2 : x1), y + ScaleSpriteTrad(33), axis, DEPOT_PART_SOUTH);
561 }
562 break;
563 }
564 }
565 }
566
567 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
568 {
569 switch (widget) {
570 case WID_BDD_X:
571 case WID_BDD_Y:
572 this->RaiseWidget(WID_BDD_X + _ship_depot_direction);
573 _ship_depot_direction = (widget == WID_BDD_X ? AXIS_X : AXIS_Y);
574 this->LowerWidget(WID_BDD_X + _ship_depot_direction);
575 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
576 UpdateDocksDirection();
577 this->SetDirty();
578 break;
579 }
580 }
581};
582
583static constexpr NWidgetPart _nested_build_docks_depot_widgets[] = {
584 NWidget(NWID_HORIZONTAL),
585 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
586 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_DEPOT_BUILD_SHIP_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
587 EndContainer(),
588 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BDD_BACKGROUND),
589 NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1), SetPadding(WidgetDimensions::unscaled.picker),
590 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDD_X), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP),
591 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDD_Y), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP),
592 EndContainer(),
593 EndContainer(),
594};
595
596static WindowDesc _build_docks_depot_desc(
597 WDP_AUTO, nullptr, 0, 0,
598 WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
599 WDF_CONSTRUCTION,
600 _nested_build_docks_depot_widgets
601);
602
603
604static void ShowBuildDocksDepotPicker(Window *parent)
605{
606 new BuildDocksDepotWindow(_build_docks_depot_desc, parent);
607}
608
609
610void InitializeDockGui()
611{
612 _ship_depot_direction = AXIS_X;
613}
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:23
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition command_type.h:162
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition command_type.h:171
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:986
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:3524
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:28
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition window_gui.h:60
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel thickness.
Definition window_gui.h:41
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:96
command_func.h
Functions related to commands.
CommandFlagsToDCFlags
static constexpr DoCommandFlag 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:187
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:52
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:116
AXIS_X
@ AXIS_X
The X axis.
Definition direction_type.h:117
AXIS_Y
@ AXIS_Y
The y axis.
Definition direction_type.h:118
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition direction_type.h:73
INVALID_DIAGDIR
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
Definition direction_type.h:80
dock_cmd.h
Command definitions related to docks.
BuildDockStationWidgets
BuildDockStationWidgets
Widget numbers of the build-dock GUI.
Definition dock_gui.cpp:409
BDSW_LT_OFF
@ BDSW_LT_OFF
'Off' button of coverage high light.
Definition dock_gui.cpp:411
BDSW_BACKGROUND
@ BDSW_BACKGROUND
Background panel.
Definition dock_gui.cpp:410
BDSW_INFO
@ BDSW_INFO
'Coverage highlight' label.
Definition dock_gui.cpp:413
BDSW_ACCEPTANCE
@ BDSW_ACCEPTANCE
Acceptance info.
Definition dock_gui.cpp:414
BDSW_LT_ON
@ BDSW_LT_ON
'On' button of coverage high light.
Definition dock_gui.cpp:412
_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, WDF_CONSTRUCTION, _nested_build_docks_scen_toolbar_widgets)
Window definition for the build docks in scenario editor window.
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:403
ShowBuildDocksToolbar
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
Definition dock_gui.cpp:362
_nested_build_docks_scen_toolbar_widgets
static constexpr NWidgetPart _nested_build_docks_scen_toolbar_widgets[]
Nested widget parts of docks toolbar, scenario editor version.
Definition dock_gui.cpp:374
_nested_build_docks_toolbar_widgets
static constexpr NWidgetPart _nested_build_docks_toolbar_widgets[]
Nested widget parts of docks toolbar, game version.
Definition dock_gui.cpp:329
_nested_build_dock_station_widgets
static constexpr NWidgetPart _nested_build_dock_station_widgets[]
Nested widget parts of a build dock station window.
Definition dock_gui.cpp:482
dock_widget.h
Types related to the dock widgets.
DockToolbarWidgets
DockToolbarWidgets
Widgets of the BuildDocksToolbarWindow class.
Definition dock_widget.h:21
WID_DT_CANAL
@ WID_DT_CANAL
Build canal button.
Definition dock_widget.h:22
WID_DT_DEMOLISH
@ WID_DT_DEMOLISH
Demolish aka dynamite button.
Definition dock_widget.h:24
WID_DT_STATION
@ WID_DT_STATION
Build station button.
Definition dock_widget.h:26
WID_DT_RIVER
@ WID_DT_RIVER
Build river button (in scenario editor).
Definition dock_widget.h:28
WID_DT_LOCK
@ WID_DT_LOCK
Build lock button.
Definition dock_widget.h:23
WID_DT_DEPOT
@ WID_DT_DEPOT
Build depot button.
Definition dock_widget.h:25
WID_DT_INVALID
@ WID_DT_INVALID
Used to initialize a variable.
Definition dock_widget.h:31
WID_DT_BUOY
@ WID_DT_BUOY
Build buoy button.
Definition dock_widget.h:27
WID_DT_BUILD_AQUEDUCT
@ WID_DT_BUILD_AQUEDUCT
Build aqueduct button.
Definition dock_widget.h:29
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
_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:1548
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:1181
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:1271
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:1228
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition widget_type.h:1202
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition widget_type.h:1137
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1320
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1191
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:1149
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition widget_type.h:1126
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:1283
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition window.cpp:940
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:223
TileAddXY
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
Definition map_func.h:467
TileAddByDiagDir
TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
Definition map_func.h:608
TileAdd
constexpr TileIndex TileAdd(TileIndex tile, TileIndexDiff offset)
Adds a given offset to a tile.
Definition map_func.h:454
TileY
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition map_func.h:425
TileX
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
Definition map_func.h:415
TileOffsByDiagDir
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition map_func.h:567
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:57
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:56
slope_func.h
Functions related to slopes.
GetInclinedSlopeDirection
DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
Definition slope_func.h:239
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
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition sound_type.h:66
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:1508
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:2483
CheckRedrawStationCoverage
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Definition station_gui.cpp:160
DrawStationCoverageAreaText
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
Definition station_gui.cpp:77
station_gui.h
Contains enums and function declarations connected with stations GUI.
SCT_ALL
@ SCT_ALL
Draw all cargoes.
Definition station_gui.h:23
CA_DOCK
static constexpr uint CA_DOCK
Catchment for docks with "modified catchment" enabled.
Definition station_type.h:81
CA_UNMODIFIED
static constexpr uint CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition station_type.h:83
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:513
BuildDocksDepotWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition dock_gui.cpp:543
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:567
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:532
BuildDocksStationWindow
Definition dock_gui.cpp:417
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:456
BuildDocksStationWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition dock_gui.cpp:431
BuildDocksStationWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition dock_gui.cpp:471
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:425
BuildDocksToolbarWindow
Toolbar window for constructing water infrastructure.
Definition dock_gui.cpp:100
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:281
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:151
BuildDocksToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition dock_gui.cpp:269
BuildDocksToolbarWindow::DockToolbarGlobalHotkeys
static EventState DockToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildDocksToolbarWindow.
Definition dock_gui.cpp:305
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:245
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:192
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:250
BuildDocksToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition dock_gui.cpp:123
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:111
BuildDocksToolbarWindow::last_clicked_widget
DockToolbarWidgets last_clicked_widget
Contains the last widget that has been clicked on this toolbar.
Definition dock_gui.cpp:101
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition settings_type.h:613
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition settings_type.h:610
CommandHelper
Definition command_func.h:83
ConstructionSettings::max_bridge_length
uint16_t max_bridge_length
maximum length of bridges
Definition settings_type.h:385
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition geometry_type.hpp:30
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:198
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition settings_type.h:197
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition settings_type.h:150
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition settings_type.h:594
GameSettings::station
StationSettings station
settings related to station management
Definition settings_type.h:604
HotkeyList
List of hotkeys for a window.
Definition hotkeys.h:37
Hotkey
All data for a single hotkey.
Definition hotkeys.h:21
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition widget_type.h:1075
Point
Coordinates of a point in 2D.
Definition geometry_type.hpp:21
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition pool_type.hpp:328
RectPadding::Horizontal
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition geometry_type.hpp:63
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition geometry_type.hpp:69
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition geometry_type.hpp:75
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition geometry_type.hpp:98
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition settings_type.h:249
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition settings_type.h:248
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition settings_type.h:565
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:159
Window
Data structure for an opened window.
Definition window_gui.h:273
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:1047
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition widget.cpp:732
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:3159
Window::parent
Window * parent
Parent window.
Definition window_gui.h:328
Window::RaiseWidget
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition window_gui.h:475
Window::resize
ResizeInfo resize
Resize information.
Definition window_gui.h:314
Window::SetWidgetsDisabledState
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition window_gui.h:521
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition window_gui.h:497
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition window.cpp:525
Window::top
int top
y position of top edge of the window
Definition window_gui.h:310
Window::GetWidget
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
Definition window_gui.h:977
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition window_gui.h:466
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1746
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition window.cpp:565
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:302
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:368
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:3498
VpSetPresizeRange
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Definition viewport.cpp:2777
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition viewport.cpp:3216
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition viewport.cpp:2722
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:29
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:1922
vehicle_func.h
Functions related to vehicles.
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition vehicle_type.h:26
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition viewport.cpp:2542
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition viewport.cpp:3618
viewport_func.h
Functions related to (drawing on) viewports.
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:111
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition viewport_type.h:112
DDSP_CREATE_WATER
@ DDSP_CREATE_WATER
Create a canal.
Definition viewport_type.h:118
DDSP_CREATE_RIVER
@ DDSP_CREATE_RIVER
Create rivers.
Definition viewport_type.h:119
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition viewport_type.h:92
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition viewport_type.h:96
water.h
Functions related to water (management)
water_cmd.h
Command definitions related to water tiles.
DEPOT_PART_NORTH
@ DEPOT_PART_NORTH
Northern part of a depot.
Definition water_map.h:59
DEPOT_PART_SOUTH
@ DEPOT_PART_SOUTH
Southern part of a depot.
Definition water_map.h:60
WATER_CLASS_SEA
@ WATER_CLASS_SEA
Sea.
Definition water_map.h:40
WATER_CLASS_CANAL
@ WATER_CLASS_CANAL
Canal.
Definition water_map.h:41
WATER_CLASS_RIVER
@ WATER_CLASS_RIVER
River.
Definition water_map.h:42
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:35
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition widget_type.h:524
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition widget_type.h:52
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition widget_type.h:57
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:75
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:55
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:50
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition widget_type.h:66
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:61
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:77
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:69
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:48
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition widget_type.h:76
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:1140
ResizeWindow
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen, bool schedule_resize)
Resize the window.
Definition window.cpp:2022
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition window.cpp:1152
window_func.h
Window functions not directly related to making/drawing windows.
window_gui.h
Functions, definitions and such used only by the GUI.
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition window_gui.h:203
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition window_gui.h:147
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition window_gui.h:149
WidgetID
int WidgetID
Widget ID.
Definition window_type.h:18
WindowNumber
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition window_type.h:740
EventState
EventState
State of handling an event.
Definition window_type.h:743
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition window_type.h:745
WC_BUILD_STATION
@ WC_BUILD_STATION
Build station; Window numbers:
Definition window_type.h:403
WC_SCEN_BUILD_TOOLBAR
@ WC_SCEN_BUILD_TOOLBAR
Scenario build toolbar; Window numbers:
Definition window_type.h:80
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition window_type.h:73
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:45
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition window_type.h:455
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition window_type.h:242
WC_BUILD_DEPOT
@ WC_BUILD_DEPOT
Build depot; Window numbers:
Definition window_type.h:423
WC_BUILD_BRIDGE
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Definition window_type.h:395
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