OpenTTD Source: src/tilehighlight_func.h File Reference

OpenTTD Source 12.2

Functions | Variables
tilehighlight_func.h File Reference
`#include "gfx_type.h"`
`#include "tilehighlight_type.h"`

Go to the source code of this file.

## Functions
void | PlaceProc_DemolishArea (TileIndex tile)
| Start a drag for demolishing an area. More...
bool | GUIPlaceProcDragXY (ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
| A central place to handle all X_AND_Y dragged GUI functions. More...
bool | HandlePlacePushButton (Window *w, int widget, CursorID cursor, HighLightStyle mode)
| This code is shared for the majority of the pushbuttons. More...
void | SetObjectToPlaceWnd (CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
| Change the cursor and mouse click/drag handling to a mode for performing special operations like tile area selection, object placement, etc. More...
void | SetObjectToPlace (CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num)
| Change the cursor and mouse click/drag handling to a mode for performing special operations like tile area selection, object placement, etc. More...
void | ResetObjectToPlace ()
| Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void | VpSelectTilesWithMethod (int x, int y, ViewportPlaceMethod method)
| Selects tiles while dragging. More...
void | VpStartDragging (ViewportDragDropSelectionProcess process)
| Drag over the map while holding the left mouse down.
void | VpStartPlaceSizing (TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
| highlighting tiles while only going over them with the mouse
void | VpSetPresizeRange (TileIndex from, TileIndex to)
| Highlights all tiles between a set of two tiles. More...
void | VpSetPlaceSizingLimit (int limit)
void | UpdateTileSelection ()
| Updates tile highlighting for all cases. More...

## Variables
TileHighlightData | _thd

## Detailed Description

Functions related to tile highlights.

Definition in file tilehighlight_func.h.

## Function Documentation

## ◆ GUIPlaceProcDragXY()

bool GUIPlaceProcDragXY | ( | ViewportDragDropSelectionProcess | proc,
|  | TileIndex | start_tile,
|  | TileIndex | end_tile
| ) |  |

A central place to handle all X_AND_Y dragged GUI functions.

Parameters

  proc | Procedure related to the dragging
  start_tile | Begin of the dragging
  end_tile | End of the dragging

Returns
  Returns true if the action was found and handled, and false otherwise. This allows for additional implements that are more local. For example X_Y drag of convertrail which belongs in rail_gui.cpp and not terraform_gui.cpp

Definition at line 107 of file terraform_gui.cpp.

References _ctrl_pressed, _settings_game, CMD_CLEAR_AREA, CMD_MSG, GameSettings::construction, DDSP_DEMOLISH_AREA, DoCommandP(), ConstructionSettings::freeform_edges, MapMaxX(), MapMaxY(), TileDiffXY(), TileX(), and TileY().

Referenced by BuildAirToolbarWindow::OnPlaceMouseUp(), and BuildDocksToolbarWindow::OnPlaceMouseUp().

## ◆ HandlePlacePushButton()

bool HandlePlacePushButton | ( | Window * | w,
|  | int | widget,
|  | CursorID | cursor,
|  | HighLightStyle | mode
| ) |  |

This code is shared for the majority of the pushbuttons.

Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters

Parameters

  w | Window which called the function
  widget | ID of the widget (=button) that called this function
  cursor | How should the cursor image change? E.g. cursor with depot image in it
  mode | Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground

Returns
  true if the button is clicked, false if it's unclicked

Definition at line 61 of file main_gui.cpp.

References _settings_client, SoundSettings::click_beep, Window::IsWidgetDisabled(), and ClientSettings::sound.

Referenced by BuildAirToolbarWindow::OnClick(), BuildDocksToolbarWindow::OnClick(), TerraformToolbarWindow::OnClick(), BuildRailToolbarWindow::OnClick(), ScenarioEditorLandscapeGenerationWindow::OnClick(), and FoundTownWindow::OnClick().

## ◆ PlaceProc_DemolishArea()

void PlaceProc_DemolishArea | ( | TileIndex | tile | ) |

Start a drag for demolishing an area.

Parameters

  tile | Position of one corner.

Definition at line 146 of file terraform_gui.cpp.

References DDSP_DEMOLISH_AREA, VPM_X_AND_Y, and VpStartPlaceSizing().

Referenced by BuildAirToolbarWindow::OnPlaceObject(), TerraformToolbarWindow::OnPlaceObject(), BuildRailToolbarWindow::OnPlaceObject(), and ScenarioEditorLandscapeGenerationWindow::OnPlaceObject().

## ◆ SetObjectToPlace()

void SetObjectToPlace | ( | CursorID | icon,
|  | PaletteID | pal,
|  | HighLightStyle | mode,
|  | WindowClass | window_class,
|  | WindowNumber | window_num
| ) |  |

Change the cursor and mouse click/drag handling to a mode for performing special operations like tile area selection, object placement, etc.

Parameters

  icon | New shape of the mouse cursor.
  pal | Palette to use.
  mode | Mode to perform.
  window_class | Window class of the window requesting the mode change.
  window_num | Number of the window in its class requesting the mode change.

Definition at line 3375 of file viewport.cpp.

Referenced by ResetObjectToPlace(), and SetObjectToPlaceWnd().

## ◆ SetObjectToPlaceWnd()

void SetObjectToPlaceWnd | ( | CursorID | icon,
|  | PaletteID | pal,
|  | HighLightStyle | mode,
|  | Window * | w
| ) |  |

Change the cursor and mouse click/drag handling to a mode for performing special operations like tile area selection, object placement, etc.

Parameters

  icon | New shape of the mouse cursor.
  pal | Palette to use.
  mode | Mode to perform.
  w | Window requesting the mode change.

Definition at line 3360 of file viewport.cpp.

References SetObjectToPlace(), Window::window_class, and Window::window_number.

Referenced by RefitWindow::OnClick(), OrdersWindow::OrderClick_Goto(), and BuildObjectWindow::SelectOtherObject().

## ◆ UpdateTileSelection()

void UpdateTileSelection | ( |  | ) |

Updates tile highlighting for all cases.

Uses _thd.selstart and _thd.selend and _thd.place_mode (set elsewhere) to determine _thd.pos and _thd.size Also drawstyle is determined. Uses _thd.new.* as a buffer and calls SetSelectionTilesDirty() twice, Once for the old and once for the new selection. _thd is TileHighlightData, found in viewport.h

Definition at line 2532 of file viewport.cpp.

Referenced by StationJoinerNeeded().

## ◆ VpSelectTilesWithMethod()

void VpSelectTilesWithMethod | ( | int | x,
|  | int | y,
|  | ViewportPlaceMethod | method
| ) |  |

Selects tiles while dragging.

Parameters

  x | X coordinate of end of selection
  y | Y coordinate of end of selection
  method | modifies the way tiles are selected. Possible methods are VPM_* in viewport.h

Definition at line 3139 of file viewport.cpp.

Referenced by BuildAirToolbarWindow::OnPlaceDrag(), BuildDocksToolbarWindow::OnPlaceDrag(), TerraformToolbarWindow::OnPlaceDrag(), BuildRailToolbarWindow::OnPlaceDrag(), and ScenarioEditorLandscapeGenerationWindow::OnPlaceDrag().

## ◆ VpSetPresizeRange()

void VpSetPresizeRange | ( | TileIndex | from,
|  | TileIndex | to
| ) |  |

Highlights all tiles between a set of two tiles.

Used in dock and tunnel placement

Parameters

  from | TileIndex of the first tile to highlight
  to | TileIndex of the last tile to highlight

Definition at line 2709 of file viewport.cpp.

References DistanceManhattan().

Referenced by BuildDocksToolbarWindow::OnPlacePresize(), and BuildRailToolbarWindow::OnPlacePresize().