Handling of all viewports. More...
#include "stdafx.h"
#include "landscape.h"
#include "viewport_func.h"
#include "station_base.h"
#include "waypoint_base.h"
#include "town.h"
#include "signs_base.h"
#include "signs_func.h"
#include "vehicle_base.h"
#include "vehicle_gui.h"
#include "blitter/factory.hpp"
#include "strings_func.h"
#include "zoom_func.h"
#include "vehicle_func.h"
#include "company_func.h"
#include "core/alloc_func.hpp"
#include "core/alloc_type.hpp"
#include "core/smallvec_type.hpp"
#include "waypoint_func.h"
#include "window_func.h"
#include "tilehighlight_func.h"
#include "window_gui.h"
#include "slope_func.h"
#include "copy_paste.h"
#include "table/strings.h"
#include <map>
#include "table/autorail.h"
#include "table/animcursors.h"
Go to the source code of this file.
Data Structures | |
struct | StringSpriteToDraw |
struct | TileSpriteToDraw |
struct | ChildScreenSpriteToDraw |
struct | ParentSpriteToDraw |
Parent sprite that should be drawn. More... | |
struct | ViewportDrawer |
Data structure storing rendering information. More... | |
Typedefs | |
typedef SmallVector < TileSpriteToDraw, 64 > | TileSpriteToDrawVector |
typedef SmallVector < StringSpriteToDraw, 4 > | StringSpriteToDrawVector |
typedef SmallVector < ParentSpriteToDraw, 64 > | ParentSpriteToDrawVector |
typedef SmallVector < ParentSpriteToDraw *, 64 > | ParentSpriteToSortVector |
typedef SmallVector < ChildScreenSpriteToDraw, 16 > | ChildScreenSpriteToDrawVector |
Enumerations | |
enum | FoundationPart { FOUNDATION_PART_NONE = 0xFF, FOUNDATION_PART_NORMAL = 0, FOUNDATION_PART_HALFTILE = 1, FOUNDATION_PART_END } |
Enumeration of multi-part foundations. More... | |
enum | SpriteCombineMode { SPRITE_COMBINE_NONE, SPRITE_COMBINE_PENDING, SPRITE_COMBINE_ACTIVE } |
Mode of "sprite combining". More... | |
Functions | |
static Point | MapXYZToViewport (const ViewPort *vp, int x, int y, int z) |
void | DeleteWindowViewport (Window *w) |
void | InitializeWindowViewport (Window *w, int x, int y, int width, int height, uint32 follow_flags, ZoomLevel zoom) |
Initialize viewport of the window for use. | |
static void | DoSetViewportPosition (const Window *w, int left, int top, int width, int height) |
static void | SetViewportPosition (Window *w, int x, int y) |
ViewPort * | IsPtInWindowViewport (const Window *w, int x, int y) |
Is a xy position inside the viewport of the window? | |
static Point | TranslateXYToTileCoord (const ViewPort *vp, int x, int y) |
Translate screen coordinate in a viewport to a tile coordinate. | |
static Point | GetTileFromScreenXY (int x, int y, int zoom_x, int zoom_y) |
Point | GetTileBelowCursor () |
Point | GetTileZoomCenterWindow (bool in, Window *w) |
void | HandleZoomMessage (Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out) |
Update the status of the zoom-buttons according to the zoom-level of the viewport. | |
static void | AddTileSpriteToDraw (SpriteID image, PaletteID pal, int32 x, int32 y, int32 z, const SubSprite *sub=NULL, int extra_offs_x=0, int extra_offs_y=0) |
Schedules a tile sprite for drawing. | |
static void | AddChildSpriteToFoundation (SpriteID image, PaletteID pal, const SubSprite *sub, FoundationPart foundation_part, int extra_offs_x, int extra_offs_y) |
Adds a child sprite to the active foundation. | |
void | DrawGroundSpriteAt (SpriteID image, PaletteID pal, int32 x, int32 y, int z, const SubSprite *sub, int extra_offs_x, int extra_offs_y) |
Draws a ground sprite at a specific world-coordinate relative to the current tile. | |
void | DrawGroundSprite (SpriteID image, PaletteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y) |
Draws a ground sprite for the current tile. | |
void | OffsetGroundSprite (int x, int y) |
Called when a foundation has been drawn for the current tile. | |
static void | AddCombinedSprite (SpriteID image, PaletteID pal, int x, int y, int z, const SubSprite *sub) |
Adds a child sprite to a parent sprite. | |
void | AddSortableSpriteToDraw (SpriteID image, PaletteID pal, int x, int y, int w, int h, int dz, int z, bool transparent, int bb_offset_x, int bb_offset_y, int bb_offset_z, const SubSprite *sub) |
Draw a (transparent) sprite at given coordinates with a given bounding box. | |
void | StartSpriteCombine () |
Starts a block of sprites, which are "combined" into a single bounding box. | |
void | EndSpriteCombine () |
Terminates a block of sprites started by StartSpriteCombine. | |
static bool | IsInRangeInclusive (int begin, int end, int check) |
Check if the parameter "check" is inside the interval between begin and end, including both begin and end. | |
bool | IsInsideRotatedRectangle (int x, int y) |
Checks whether a point is inside the selected a diagonal rectangle given by _thd.size and _thd.pos. | |
void | AddChildSpriteScreen (SpriteID image, PaletteID pal, int x, int y, bool transparent, const SubSprite *sub) |
Add a child sprite to a parent sprite. | |
static void | AddStringToDraw (int x, int y, StringID string, uint64 params_1, uint64 params_2, Colours colour, uint16 width) |
static void | DrawSelectionSprite (SpriteID image, PaletteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part) |
Draws sprites between ground sprite and everything above. | |
static void | DrawTileSelectionRect (const TileInfo *ti, PaletteID pal) |
Draws a selection rectangle on a tile. | |
static void | DrawPreviewSprite (SpriteID image, SpriteID pal, uint x, uint y, uint z) |
static bool | IsPartOfAutoLine (int px, int py) |
static void | DrawPreviewTile (const TileInfo *ti) |
static void | DrawAutorailSelection (const TileInfo *ti, uint autorail_type) |
Draws autorail highlights. | |
static void | DrawTileSelection (const TileInfo *ti) |
Checks if the specified tile is selected and if so draws selection using correct selectionstyle. | |
static Point | GetTileCoordFromScreenCoord (int x, int y) |
Given a screen coordinate (x,y) as e.g. | |
static Point | GetMinTileCoordsIgnoringHeight (int x, int y) |
Assume a region, given by screen coordinates (x1,y1,x2,y2), as defined in _vd.dpi. | |
static Point | GetMaxTileCoordsIgnoringHeight (int x, int y) |
Assume a region, given by screen coordinates (x1,y1,x2,y2), as defined in _vd.dpi. | |
static int | GetTileColumnFromTileCoord (Point tile_coord) |
Given a tile coordinate as returned by TileX / TileY, this returns its column. | |
static int | GetViewportY (Point tile) |
Returns the y coordinate in the viewport coordinate system where the given tile is painted. | |
static Point | GetNorthernEndOfColumn (Point tile) |
Returns the position of the tile at the northern end of the column of the given tile. | |
static Point | GetSouthernEndOfColumn (Point tile) |
Returns the position of the tile at the southern end of the column of the given tile. | |
static Point | GetMiddleTile (Point upper_tile, Point lower_tile) |
Returns the tile exactly in the middle between two given tiles. | |
int | GetRowAtTile (int viewport_y, Point tile) |
Given a tile coordinate ignoring height, this returns the row actually painted at this tile coordinate if one recognizes height. | |
static Point | GetBottomTileOfColumn (Point upper_tile, Point lower_right_tile) |
Returns the bottom tile of the column of upper_tile shown on the viewport, given upper_tile and the lower right tile shown on the viewport. | |
static void | ViewportAddLandscape () |
void | ViewportAddString (const DrawPixelInfo *dpi, ZoomLevel small_from, const ViewportSign *sign, StringID string_normal, StringID string_small, StringID string_small_shadow, uint64 params_1, uint64 params_2, Colours colour) |
Add a string to draw in the viewport. | |
static void | ViewportAddTownNames (DrawPixelInfo *dpi) |
static void | ViewportAddStationNames (DrawPixelInfo *dpi) |
static void | ViewportAddSigns (DrawPixelInfo *dpi) |
static void | ViewportDrawTileSprites (const TileSpriteToDrawVector *tstdv) |
static void | ViewportSortParentSprites (ParentSpriteToSortVector *psdv) |
Sort parent sprites pointer array. | |
static void | ViewportDrawParentSprites (const ParentSpriteToSortVector *psd, const ChildScreenSpriteToDrawVector *csstdv) |
static void | ViewportDrawBoundingBoxes (const ParentSpriteToSortVector *psd) |
Draws the bounding boxes of all ParentSprites. | |
static void | ViewportDrawStrings (DrawPixelInfo *dpi, const StringSpriteToDrawVector *sstdv) |
void | ViewportDoDraw (const ViewPort *vp, int left, int top, int right, int bottom) |
static void | ViewportDrawChk (const ViewPort *vp, int left, int top, int right, int bottom) |
Make sure we don't draw a too big area at a time. | |
static void | ViewportDraw (const ViewPort *vp, int left, int top, int right, int bottom) |
uint16 | GetMaxScrollOutsideMap () |
How far should I allow scrolling outside the map? | |
static void | ClampViewportToMap (const ViewPort *vp, int &x, int &y) |
void | UpdateViewportPosition (Window *w) |
Update the viewport position being displayed. | |
static void | MarkViewportDirty (const ViewPort *vp, int left, int top, int right, int bottom) |
Marks a viewport as dirty for repaint if it displays (a part of) the area the needs to be repainted. | |
void | MarkAllViewportsDirty (int left, int top, int right, int bottom) |
Mark all viewports that display an area as dirty (in need of repaint). | |
void | MarkTileDirtyByTile (TileIndex tile) |
Mark a tile given by its index dirty for repaint. | |
void | MarkTileDirtyByTileOutsideMap (int x, int y) |
static void | SetSelectionTilesDirty () |
Marks the selected tiles as dirty. | |
void | SetSelectionRed (bool b) |
static bool | CheckClickOnViewportSign (const ViewPort *vp, int x, int y, const ViewportSign *sign) |
Test whether a sign is below the mouse. | |
static bool | CheckClickOnTown (const ViewPort *vp, int x, int y) |
static bool | CheckClickOnStation (const ViewPort *vp, int x, int y) |
static bool | CheckClickOnSign (const ViewPort *vp, int x, int y) |
static bool | CheckClickOnLandscape (const ViewPort *vp, int x, int y) |
static void | PlaceObject () |
bool | HandleViewportClicked (const ViewPort *vp, int x, int y) |
bool | ScrollWindowTo (int x, int y, int z, Window *w, bool instant) |
Scrolls the viewport in a window to a given location. | |
bool | ScrollWindowToTile (TileIndex tile, Window *w, bool instant) |
Scrolls the viewport in a window to a given location. | |
bool | ScrollMainWindowToTile (TileIndex tile, bool instant) |
Scrolls the viewport of the main window to a given location. | |
void | SetRedErrorSquare (TileIndex tile) |
Set a tile to display a red error square. | |
void | SetTileSelectSize (int w, int h) |
Highlight w by h tiles at the cursor. | |
void | SetTileSelectBigSize (int ox, int oy, int sx, int sy) |
static HighLightStyle | GetAutorailHT (int x, int y) |
returns the best autorail highlight type from map coordinates | |
void | UpdateTileSelection () |
Updates tile highlighting for all cases. | |
static void | ShowMeasurementTooltips (StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond=TCC_LEFT_CLICK) |
Displays the measurement tooltips when selecting multiple tiles. | |
void | VpStartPlaceSizing (TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process) |
highlighting tiles while only going over them with the mouse | |
void | VpSetPlaceSizingLimit (int limit) |
void | VpSetPresizeRange (TileIndex from, TileIndex to) |
Highlights all tiles between a set of two tiles. | |
static void | VpStartPreSizing () |
static HighLightStyle | Check2x1AutoRail (int mode) |
returns information about the 2x1 piece to be build. | |
static bool | SwapDirection (HighLightStyle style, TileIndex start_tile, TileIndex end_tile) |
Check if the direction of start and end tile should be swapped based on the dragging-style. | |
static int | CalcHeightdiff (HighLightStyle style, uint distance, TileIndex start_tile, TileIndex end_tile) |
Calculates height difference between one tile and another. | |
static void | CheckUnderflow (int &test, int &other, int mult) |
Check for underflowing the map. | |
static void | CheckOverflow (int &test, int &other, int max, int mult) |
Check for overflowing the map. | |
static void | CalcRaildirsDrawstyle (int x, int y, int method) |
while dragging | |
void | VpSelectTilesWithMethod (int x, int y, ViewportPlaceMethod method) |
Selects tiles while dragging. | |
EventState | VpHandlePlaceSizingDrag () |
Handle the mouse while dragging for placement/resizing. | |
void | SetObjectToPlaceWnd (CursorID icon, PaletteID pal, HighLightStyle mode, Window *w) |
void | SetObjectToPlace (CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num) |
void | ResetObjectToPlace () |
Variables | |
Point | _tile_fract_coords |
static ViewportDrawer | _vd |
TileHighlightData | _thd |
static TileInfo * | _cur_ti |
bool | _draw_bounding_boxes = false |
static Point | _vp_move_offs |
static const HighLightStyle | _autorail_type [6][2] |
static const StringID | measure_strings_length [] = {STR_NULL, STR_MEASURE_LENGTH, STR_MEASURE_LENGTH_HEIGHTDIFF} |
Handling of all viewports.
* The in-game coordinate system looks like this * * * * ^ Z * * | * * | * * | * * | * * / \ * * / \ * * / \ * * / \ * * X < > Y * *
Definition in file viewport.cpp.
enum FoundationPart |
Enumeration of multi-part foundations.
FOUNDATION_PART_NONE |
Neither foundation nor groundsprite drawn yet. |
FOUNDATION_PART_NORMAL |
First part (normal foundation or no foundation). |
FOUNDATION_PART_HALFTILE |
Second part (halftile foundation). |
Definition at line 110 of file viewport.cpp.
enum SpriteCombineMode |
Mode of "sprite combining".
SPRITE_COMBINE_NONE |
Every AddSortableSpriteToDraw start its own bounding box. |
SPRITE_COMBINE_PENDING |
Sprite combining will start with the next unclipped sprite. |
SPRITE_COMBINE_ACTIVE |
Sprite combining is active. AddSortableSpriteToDraw outputs child sprites. |
Definition at line 121 of file viewport.cpp.
void AddChildSpriteScreen | ( | SpriteID | image, | |
PaletteID | pal, | |||
int | x, | |||
int | y, | |||
bool | transparent, | |||
const SubSprite * | sub | |||
) |
Add a child sprite to a parent sprite.
image | the image to draw. | |
pal | the provided palette. | |
x | sprite x-offset (screen coordinates) relative to parent sprite. | |
y | sprite y-offset (screen coordinates) relative to parent sprite. | |
transparent | if true, switch the palette between the provided palette and the transparent palette, | |
sub | Only draw a part of the sprite. |
Definition at line 804 of file viewport.cpp.
References SmallVector< T, S >::Append(), ViewportDrawer::last_foundation_child, SmallVector< T, S >::Length(), MAX_SPRITES, ChildScreenSpriteToDraw::next, PALETTE_MODIFIER_TRANSPARENT, PALETTE_TO_TRANSPARENT, SetBit(), SPRITE_MASK, and ChildScreenSpriteToDraw::sub.
Referenced by AddChildSpriteToFoundation(), AddCombinedSprite(), and DrawCommonTileSeq().
static void AddChildSpriteToFoundation | ( | SpriteID | image, | |
PaletteID | pal, | |||
const SubSprite * | sub, | |||
FoundationPart | foundation_part, | |||
int | extra_offs_x, | |||
int | extra_offs_y | |||
) | [static] |
Adds a child sprite to the active foundation.
The pixel offset of the sprite relative to the ParentSprite is the sum of the offset passed to OffsetGroundSprite() and extra_offs_?.
image | the image to draw. | |
pal | the provided palette. | |
sub | Only draw a part of the sprite. | |
foundation_part | Foundation part. | |
extra_offs_x | Pixel X offset for the sprite position. | |
extra_offs_y | Pixel Y offset for the sprite position. |
Definition at line 513 of file viewport.cpp.
References AddChildSpriteScreen(), ViewportDrawer::foundation, ViewportDrawer::foundation_offset, IsInsideMM(), and ViewportDrawer::last_foundation_child.
Referenced by DrawGroundSpriteAt(), and DrawSelectionSprite().
static void AddCombinedSprite | ( | SpriteID | image, | |
PaletteID | pal, | |||
int | x, | |||
int | y, | |||
int | z, | |||
const SubSprite * | sub | |||
) | [static] |
Adds a child sprite to a parent sprite.
In contrast to "AddChildSpriteScreen()" the sprite position is in world coordinates
image | the image to draw. | |
pal | the provided palette. | |
x | position x of the sprite. | |
y | position y of the sprite. | |
z | position z of the sprite. | |
sub | Only draw a part of the sprite. |
Definition at line 609 of file viewport.cpp.
References AddChildSpriteScreen(), SmallVector< T, S >::End(), Sprite::height, ParentSpriteToDraw::left, RemapCoords(), SPRITE_MASK, ST_NORMAL, ParentSpriteToDraw::top, Sprite::width, Sprite::x_offs, and Sprite::y_offs.
Referenced by AddSortableSpriteToDraw().
void AddSortableSpriteToDraw | ( | SpriteID | image, | |
PaletteID | pal, | |||
int | x, | |||
int | y, | |||
int | w, | |||
int | h, | |||
int | dz, | |||
int | z, | |||
bool | transparent, | |||
int | bb_offset_x, | |||
int | bb_offset_y, | |||
int | bb_offset_z, | |||
const SubSprite * | sub | |||
) |
Draw a (transparent) sprite at given coordinates with a given bounding box.
The bounding box extends from (x + bb_offset_x, y + bb_offset_y, z + bb_offset_z) to (x + w - 1, y + h - 1, z + dz - 1), both corners included. Bounding boxes with bb_offset_x == w or bb_offset_y == h or bb_offset_z == dz are allowed and produce thin slices.
image | the image to combine and draw, | |
pal | the provided palette, | |
x | position X (world) of the sprite, | |
y | position Y (world) of the sprite, | |
w | bounding box extent towards positive X (world), | |
h | bounding box extent towards positive Y (world), | |
dz | bounding box extent towards positive Z (world), | |
z | position Z (world) of the sprite, | |
transparent | if true, switch the palette between the provided palette and the transparent palette, | |
bb_offset_x | bounding box extent towards negative X (world), | |
bb_offset_y | bounding box extent towards negative Y (world), | |
bb_offset_z | bounding box extent towards negative Z (world) | |
sub | Only draw a part of the sprite. |
Definition at line 649 of file viewport.cpp.
References AddCombinedSprite(), SmallVector< T, S >::Append(), ViewportDrawer::combine_sprites, ParentSpriteToDraw::comparison_done, ParentSpriteToDraw::first_child, Sprite::height, ParentSpriteToDraw::image, ParentSpriteToDraw::left, max(), MAX_SPRITES, min(), ParentSpriteToDraw::pal, PALETTE_MODIFIER_TRANSPARENT, PALETTE_TO_TRANSPARENT, RemapCoords(), SetBit(), SPRITE_COMBINE_ACTIVE, SPRITE_COMBINE_PENDING, SPRITE_MASK, ST_NORMAL, ParentSpriteToDraw::sub, ParentSpriteToDraw::top, Sprite::width, ParentSpriteToDraw::x, Sprite::x_offs, ParentSpriteToDraw::xmax, ParentSpriteToDraw::xmin, ParentSpriteToDraw::y, Sprite::y_offs, ParentSpriteToDraw::ymax, ParentSpriteToDraw::ymin, ParentSpriteToDraw::zmax, and ParentSpriteToDraw::zmin.
Referenced by DoDrawVehicle(), DrawBridgeMiddle(), DrawBridgeTramBits(), DrawCatenary(), DrawCatenaryOnBridge(), DrawCatenaryOnTunnel(), DrawCatenaryRailway(), DrawCommonTileSeq(), DrawFoundation(), DrawPillar(), DrawRoadDetail(), DrawTile_Town(), DrawTile_TunnelBridge(), DrawTrackFence_NS_1(), DrawTrackFence_NS_2(), DrawTrackFence_WE_1(), DrawTrackFence_WE_2(), DrawTramCatenary(), and DrawWaterTileStruct().
static void AddTileSpriteToDraw | ( | SpriteID | image, | |
PaletteID | pal, | |||
int32 | x, | |||
int32 | y, | |||
int32 | z, | |||
const SubSprite * | sub = NULL , |
|||
int | extra_offs_x = 0 , |
|||
int | extra_offs_y = 0 | |||
) | [static] |
Schedules a tile sprite for drawing.
image | the image to draw. | |
pal | the provided palette. | |
x | position x (world coordinates) of the sprite. | |
y | position y (world coordinates) of the sprite. | |
z | position z (world coordinates) of the sprite. | |
sub | Only draw a part of the sprite. | |
extra_offs_x | Pixel X offset for the sprite position. | |
extra_offs_y | Pixel Y offset for the sprite position. |
Definition at line 488 of file viewport.cpp.
References SmallVector< T, S >::Append(), MAX_SPRITES, RemapCoords(), SPRITE_MASK, TileSpriteToDraw::sub, TileSpriteToDraw::x, and TileSpriteToDraw::y.
Referenced by DrawGroundSpriteAt(), and DrawSelectionSprite().
static int CalcHeightdiff | ( | HighLightStyle | style, | |
uint | distance, | |||
TileIndex | start_tile, | |||
TileIndex | end_tile | |||
) | [static] |
Calculates height difference between one tile and another.
Multiplies the result to suit the standard given by TILE_HEIGHT_STEP.
To correctly get the height difference we need the direction we are dragging in, as well as with what kind of tool we are dragging. For example a horizontal autorail tool that starts in bottom and ends at the top of a tile will need the maximum of SW, S and SE, N corners respectively. This is handled by the lookup table below See _tileoffs_by_dir in map.cpp for the direction enums if you can't figure out the values yourself.
style | Highlighting style of the drag. This includes direction and style (autorail, rect, etc.) | |
distance | Number of tiles dragged, important for horizontal/vertical drags, ignored for others. | |
start_tile | Start tile of the drag operation. | |
end_tile | End tile of the drag operation. |
Definition at line 2772 of file viewport.cpp.
References HT_DIR_VL, HT_DRAG_MASK, HT_POINT, HT_RECT, lengthof, max(), Swap(), SwapDirection(), TILE_ADD, TILE_HEIGHT_STEP, TileHeight(), TileX(), and ToTileIndexDiff().
Referenced by CalcRaildirsDrawstyle(), and VpSelectTilesWithMethod().
static HighLightStyle Check2x1AutoRail | ( | int | mode | ) | [static] |
returns information about the 2x1 piece to be build.
The lower bits (0-3) are the track type.
Definition at line 2694 of file viewport.cpp.
References TileHighlightData::selend, and TILE_UNIT_MASK.
Referenced by CalcRaildirsDrawstyle().
static bool CheckClickOnViewportSign | ( | const ViewPort * | vp, | |
int | x, | |||
int | y, | |||
const ViewportSign * | sign | |||
) | [static] |
Test whether a sign is below the mouse.
vp | the clicked viewport | |
x | X position of click | |
y | Y position of click | |
sign | the sign to check |
Definition at line 2232 of file viewport.cpp.
References ViewportSign::center, FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL, ViewPort::left, ScaleByZoom(), ViewportSign::top, ViewPort::top, ViewPort::virtual_left, ViewPort::virtual_top, VPSM_BOTTOM, VPSM_TOP, ViewportSign::width_normal, ViewportSign::width_small, and ViewPort::zoom.
static void CheckOverflow | ( | int & | test, | |
int & | other, | |||
int | max, | |||
int | mult | |||
) | [static] |
Check for overflowing the map.
test | the variable to test for overflowing | |
other | the other variable to update to keep the line | |
max | the maximum value for the test variable | |
mult | the constant to multiply the difference by for other |
Definition at line 2867 of file viewport.cpp.
Referenced by CalcRaildirsDrawstyle().
static void CheckUnderflow | ( | int & | test, | |
int & | other, | |||
int | mult | |||
) | [static] |
Check for underflowing the map.
test | the variable to test for underflowing | |
other | the other variable to update to keep the line | |
mult | the constant to multiply the difference by for other |
Definition at line 2852 of file viewport.cpp.
Referenced by CalcRaildirsDrawstyle().
static void DrawAutorailSelection | ( | const TileInfo * | ti, | |
uint | autorail_type | |||
) | [static] |
Draws autorail highlights.
*ti | TileInfo Tile that is being drawn | |
autorail_type | Offset into _AutorailTilehSprite[][] |
Definition at line 988 of file viewport.cpp.
References DrawSelectionSprite(), GetHalftileSlopeCorner(), IsHalftileSlope(), TileHighlightData::make_square_red, OppositeCorner(), PALETTE_SEL_TILE_RED, RemoveHalftileSlope(), SlopeWithThreeCornersRaised(), and TileInfo::tileh.
Referenced by DrawTileSelection().
void DrawGroundSprite | ( | SpriteID | image, | |
PaletteID | pal, | |||
const SubSprite * | sub, | |||
int | extra_offs_x, | |||
int | extra_offs_y | |||
) |
Draws a ground sprite for the current tile.
If the current tile is drawn on top of a foundation the sprite is added as child sprite to the "foundation"-ParentSprite.
image | the image to draw. | |
pal | the provided palette. | |
sub | Only draw a part of the sprite. | |
extra_offs_x | Pixel X offset for the sprite position. | |
extra_offs_y | Pixel Y offset for the sprite position. |
Definition at line 565 of file viewport.cpp.
References DrawGroundSpriteAt().
Referenced by DrawCommonTileSeq(), DrawRoadBits(), DrawSeaWater(), DrawTile_Road(), DrawTile_Town(), DrawTile_TunnelBridge(), DrawTileLayout(), DrawTrackBits(), DrawWaterLock(), and DrawWaterSprite().
void DrawGroundSpriteAt | ( | SpriteID | image, | |
PaletteID | pal, | |||
int32 | x, | |||
int32 | y, | |||
int | z, | |||
const SubSprite * | sub, | |||
int | extra_offs_x, | |||
int | extra_offs_y | |||
) |
Draws a ground sprite at a specific world-coordinate relative to the current tile.
If the current tile is drawn on top of a foundation the sprite is added as child sprite to the "foundation"-ParentSprite.
image | the image to draw. | |
pal | the provided palette. | |
x | position x (world coordinates) of the sprite relative to current tile. | |
y | position y (world coordinates) of the sprite relative to current tile. | |
z | position z (world coordinates) of the sprite relative to current tile. | |
sub | Only draw a part of the sprite. | |
extra_offs_x | Pixel X offset for the sprite position. | |
extra_offs_y | Pixel Y offset for the sprite position. |
Definition at line 542 of file viewport.cpp.
References AddChildSpriteToFoundation(), AddTileSpriteToDraw(), ViewportDrawer::foundation, ViewportDrawer::foundation_part, FOUNDATION_PART_NONE, RemapCoords(), TileInfo::x, TileInfo::y, and TileInfo::z.
Referenced by DrawBridgeMiddle(), DrawGroundSprite(), and DrawRoadBits().
static void DrawSelectionSprite | ( | SpriteID | image, | |
PaletteID | pal, | |||
const TileInfo * | ti, | |||
int | z_offset, | |||
FoundationPart | foundation_part | |||
) | [static] |
Draws sprites between ground sprite and everything above.
The sprite is either drawn as TileSprite or as ChildSprite of the active foundation.
image | the image to draw. | |
pal | the provided palette. | |
ti | TileInfo Tile that is being drawn | |
z_offset | Z offset relative to the groundsprite. Only used for the sprite position, not for sprite sorting. | |
foundation_part | Foundation part the sprite belongs to. |
Definition at line 860 of file viewport.cpp.
References AddChildSpriteToFoundation(), AddTileSpriteToDraw(), ViewportDrawer::foundation, TileInfo::x, TileInfo::y, and TileInfo::z.
Referenced by DrawAutorailSelection(), DrawTileSelection(), and DrawTileSelectionRect().
static void DrawTileSelection | ( | const TileInfo * | ti | ) | [static] |
Checks if the specified tile is selected and if so draws selection using correct selectionstyle.
Definition at line 1022 of file viewport.cpp.
References Delta(), TileHighlightData::diagonal, DrawAutorailSelection(), DrawSelectionSprite(), TileHighlightData::drawstyle, DrawTileSelectionRect(), GetHalftileSlopeCorner(), HT_DIR_END, HT_DIR_X, HT_DIR_Y, HT_DRAG_MASK, HT_NONE, HT_POINT, HT_PREVIEW, HT_RAIL, HT_RECT, IsHalftileSlope(), IsInsideBS(), IsInsideRotatedRectangle(), IsSteepSlope(), TileHighlightData::make_square_red, TileHighlightData::offs, TileHighlightData::outersize, PALETTE_SEL_TILE_BLUE, PALETTE_SEL_TILE_RED, PALETTE_TILE_RED_PULSATING, TileHighlightData::pos, TileHighlightData::redsq, RemoveHalftileSlope(), TileHighlightData::selstart, TileHighlightData::size, SLOPE_N, SLOPE_STEEP_N, TileInfo::tile, TILE_HEIGHT, TileInfo::tileh, TileVirtXY(), TileX(), TileY(), TileInfo::x, TileInfo::y, and ZOOM_LVL_DETAIL.
Draws a selection rectangle on a tile.
Definition at line 878 of file viewport.cpp.
References DrawSelectionSprite(), FOUNDATION_PART_HALFTILE, FOUNDATION_PART_NORMAL, GetHalftileSlopeCorner(), IsHalftileSlope(), IsSteepSlope(), IsValidTile(), OppositeCorner(), SlopeToSpriteOffset(), SlopeWithOneCornerRaised(), TileInfo::tile, TILE_HEIGHT, and TileInfo::tileh.
Referenced by DrawTileSelection().
void EndSpriteCombine | ( | ) |
Terminates a block of sprites started by StartSpriteCombine.
Take a look there for details.
Definition at line 756 of file viewport.cpp.
References ViewportDrawer::combine_sprites, and SPRITE_COMBINE_NONE.
Referenced by DrawBridgeMiddle(), DrawBridgeTramBits(), and DrawTile_TunnelBridge().
Returns the bottom tile of the column of upper_tile shown on the viewport, given upper_tile and the lower right tile shown on the viewport.
upper_tile | any tile inside the map | |
lower_right_tile | the tile shown at the southeast edge of the viewport (ignoring height). Note that this tile may be located northeast of the upper_tile, because upper_tile is usually calculated by shifting a tile southwards until we reach the northern map border. |
Definition at line 1372 of file viewport.cpp.
uint16 GetMaxScrollOutsideMap | ( | ) |
How far should I allow scrolling outside the map?
Definition at line 1949 of file viewport.cpp.
References AllowMoreHeightlevels().
static Point GetMaxTileCoordsIgnoringHeight | ( | int | x, | |
int | y | |||
) | [static] |
Assume a region, given by screen coordinates (x1,y1,x2,y2), as defined in _vd.dpi.
This function basically takes (x2,y2) (i.e. the lower right corner of that region) and returns the tile coordinate of the tile, which would be painted at (x2,y2) if one assumes height zero at that position.
However, in detail: Imagine tiles being split up into their upper left,upper right, etc. isometric sections. We return a tile where the lower right corner of the mentioned region is either in its upper left section or in a neighbor tile above / left of that section. By doing so, we want to enforce that we can travel to north or west from that point without leaving the region again.
x | some x screen coordinate. | |
y | some y screen coordinate. |
Definition at line 1159 of file viewport.cpp.
References GetTileCoordFromScreenCoord().
Returns the tile exactly in the middle between two given tiles.
Definition at line 1251 of file viewport.cpp.
References Swap().
Referenced by GetRowAtTile().
static Point GetMinTileCoordsIgnoringHeight | ( | int | x, | |
int | y | |||
) | [static] |
Assume a region, given by screen coordinates (x1,y1,x2,y2), as defined in _vd.dpi.
This function basically takes (x1,y1) (i.e. the upper left corner of that region) and returns the tile coordinate of the tile, which would be painted at (x1,y1) if one assumes height zero at that position.
However, in detail: Imagine tiles being split up into their upper left,upper right, etc. isometric sections. We return a tile where the upper left corner of the mentioned region is either in its lower right section or in a neighbor tile below / right of that section. By doing so, we want to enforce that we can travel to east or south from that point without leaving the region again.
x | some x screen coordinate. | |
y | some y screen coordinate. |
Definition at line 1131 of file viewport.cpp.
References GetTileCoordFromScreenCoord().
Returns the position of the tile at the northern end of the column of the given tile.
tile | Any tile. |
Definition at line 1202 of file viewport.cpp.
References MapMaxX(), and MapMaxY().
Referenced by GetRowAtTile().
int GetRowAtTile | ( | int | viewport_y, | |
Point | tile | |||
) |
Given a tile coordinate ignoring height, this returns the row actually painted at this tile coordinate if one recognizes height.
The problem concerning this calculation is that we have not enough information to calculate this in one closed formula. Which row we search rather depends on the height distribution on the map. So we have to search.
First, the searched tile may be located outside map. Then, we know that we are not too far outside map, so we can step tile by tile, starting at the given tile, until we have passed the searched tile.
If the searched tile is inside map, searching is more difficult. A linear search on some thousand tiles would be not that efficient. But, we can solve the problem by interval intersection. We know for sure, that the searched tile is south of the given tile, simply because mountains of height > 0 (and we have only such mountains) are always painted north of their tile. So we choose a tile half way between the given tile and the southern end of the map, have a look wether it is north or south of the given position, and intersect again. Until our interval has length 1, then we take the upper one.
tile | some tile coordinate. | |
viewport_y | the viewport y corresponding to tile, if one assumes height zero for that tile. |
Definition at line 1291 of file viewport.cpp.
References DEBUG, GetMiddleTile(), GetNorthernEndOfColumn(), GetSouthernEndOfColumn(), and GetViewportY().
Returns the position of the tile at the southern end of the column of the given tile.
tile | any tile. |
Definition at line 1226 of file viewport.cpp.
References MapMaxX(), and MapMaxY().
Referenced by GetRowAtTile().
static int GetTileColumnFromTileCoord | ( | Point | tile_coord | ) | [static] |
Given a tile coordinate as returned by TileX / TileY, this returns its column.
Examples: GetTileColumnFromTileCoord(0,0) = 0. GetTileColumnFromTileCoord(1,1) = 0. GetTileColumnFromTileCoord(1,0) = -1. GetTileColumnFromTileCoord(0,1) = 1.
Definition at line 1180 of file viewport.cpp.
static Point GetTileCoordFromScreenCoord | ( | int | x, | |
int | y | |||
) | [inline, static] |
Given a screen coordinate (x,y) as e.g.
stored in _vd.dpi, this function returns the tile coordinate of the tile which would be painted at (x,y) if one assumes height zero at that position.
x | some x screen coordinate. | |
y | some y screen coordinate. |
Definition at line 1101 of file viewport.cpp.
References InverseRemapCoords(), and TILE_SIZE.
Referenced by GetMaxTileCoordsIgnoringHeight(), and GetMinTileCoordsIgnoringHeight().
static int GetViewportY | ( | Point | tile | ) | [static] |
Returns the y coordinate in the viewport coordinate system where the given tile is painted.
tile | Any tile. |
Definition at line 1191 of file viewport.cpp.
References GetTileMaxZOutsideMap(), and TILE_SIZE.
Referenced by GetRowAtTile().
void HandleZoomMessage | ( | Window * | w, | |
const ViewPort * | vp, | |||
byte | widget_zoom_in, | |||
byte | widget_zoom_out | |||
) |
Update the status of the zoom-buttons according to the zoom-level of the viewport.
This will update their status and invalidate accordingly
w | Window pointer to the window that has the zoom buttons | |
vp | pointer to the viewport whose zoom-level the buttons represent | |
widget_zoom_in | widget index for window with zoom-in button | |
widget_zoom_out | widget index for window with zoom-out button |
Definition at line 467 of file viewport.cpp.
References Window::SetWidgetDirty(), Window::SetWidgetDisabledState(), ViewPort::zoom, ZOOM_LVL_MAX, and ZOOM_LVL_MIN.
Referenced by WatchCompany::OnInvalidateData(), ExtraViewportWindow::OnInvalidateData(), ScenarioEditorToolbarWindow::OnInvalidateData(), and MainToolbarWindow::OnInvalidateData().
void InitializeWindowViewport | ( | Window * | w, | |
int | x, | |||
int | y, | |||
int | width, | |||
int | height, | |||
uint32 | follow_flags, | |||
ZoomLevel | zoom | |||
) |
Initialize viewport of the window for use.
w | Window to use/display the viewport in | |
x | Offset of left edge of viewport with respect to left edge window w | |
y | Offset of top edge of viewport with respect to top edge window w | |
width | Width of the viewport | |
height | Height of the viewport | |
follow_flags | Flags controlling the viewport.
| |
zoom | Zoomlevel to display |
Definition at line 185 of file viewport.cpp.
References ViewportData::dest_scrollpos_x, ViewportData::dest_scrollpos_y, ViewportData::follow_vehicle, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), ViewPort::height, INVALID_VEHICLE, Window::left, ViewPort::left, ScaleByZoom(), ViewportData::scrollpos_x, ViewportData::scrollpos_y, TILE_SIZE, TileX(), TileY(), Window::top, ViewPort::top, Window::viewport, ViewPort::virtual_height, ViewPort::virtual_left, ViewPort::virtual_top, ViewPort::virtual_width, ViewPort::width, Vehicle::x_pos, Vehicle::y_pos, Vehicle::z_pos, and ViewPort::zoom.
Referenced by NWidgetViewport::InitializeViewport().
static bool IsInRangeInclusive | ( | int | begin, | |
int | end, | |||
int | check | |||
) | [static] |
Check if the parameter "check" is inside the interval between begin and end, including both begin and end.
begin
or end
is the biggest does not matter. This method will account for that. begin | The begin of the interval. | |
end | The end of the interval. | |
check | The value to check. |
Definition at line 771 of file viewport.cpp.
References Swap().
Referenced by IsInsideRotatedRectangle().
bool IsInsideRotatedRectangle | ( | int | x, | |
int | y | |||
) |
Checks whether a point is inside the selected a diagonal rectangle given by _thd.size and _thd.pos.
x | The x coordinate of the point to be checked. | |
y | The y coordinate of the point to be checked. |
Definition at line 783 of file viewport.cpp.
References IsInRangeInclusive(), TileHighlightData::pos, and TileHighlightData::size.
Referenced by DrawTileSelection().
Is a xy position inside the viewport of the window?
w | Window to examine its viewport | |
x | X coordinate of the xy position | |
y | Y coordinate of the xy position |
NULL
is returned. Definition at line 356 of file viewport.cpp.
References ViewPort::height, IsInsideMM(), ViewPort::left, ViewPort::top, Window::viewport, and ViewPort::width.
Referenced by HandleAutoscroll(), and WatchCompany::OnScroll().
void OffsetGroundSprite | ( | int | x, | |
int | y | |||
) |
Called when a foundation has been drawn for the current tile.
Successive ground sprites for the current tile will be drawn as child sprites of the "foundation"-ParentSprite, not as TileSprites.
x | sprite x-offset (screen coordinates) of ground sprites relative to the "foundation"-ParentSprite. | |
y | sprite y-offset (screen coordinates) of ground sprites relative to the "foundation"-ParentSprite. |
Definition at line 577 of file viewport.cpp.
References ViewportDrawer::foundation, ViewportDrawer::foundation_offset, ViewportDrawer::foundation_part, FOUNDATION_PART_NONE, FOUNDATION_PART_NORMAL, ViewportDrawer::last_foundation_child, and SmallVector< T, S >::Length().
Referenced by DrawFoundation().
bool ScrollMainWindowToTile | ( | TileIndex | tile, | |
bool | instant | |||
) |
Scrolls the viewport of the main window to a given location.
tile | Desired tile to center on. | |
instant | Jump to the location instead of slowly moving to it. |
Definition at line 2421 of file viewport.cpp.
References ScrollMainWindowTo(), TILE_SIZE, TileX(), and TileY().
Referenced by DEF_CONSOLE_CMD(), GenerateWorld(), WaypointWindow::OnClick(), VehicleViewWindow::OnClick(), TownDirectoryWindow::OnClick(), TownViewWindow::OnClick(), StationViewWindow::OnClick(), CompanyStationsWindow::OnClick(), ProgramWindow::OnClick(), OrdersWindow::OnClick(), NewsWindow::OnClick(), IndustryDirectoryWindow::OnClick(), IndustryViewWindow::OnClick(), DepotWindow::OnClick(), and CompanyWindow::OnClick().
bool ScrollWindowTo | ( | int | x, | |
int | y, | |||
int | z, | |||
Window * | w, | |||
bool | instant | |||
) |
Scrolls the viewport in a window to a given location.
x | Desired x location of the map to scroll to (world coordinate). | |
y | Desired y location of the map to scroll to (world coordinate). | |
z | Desired z location of the map to scroll to (world coordinate). Use -1 to scroll to the height of the map at the x, y location. | |
w | Window containing the viewport. | |
instant | Jump to the location instead of slowly moving to it. |
Definition at line 2376 of file viewport.cpp.
References ViewportData::dest_scrollpos_x, ViewportData::dest_scrollpos_y, ViewportData::follow_vehicle, INVALID_VEHICLE, MapSizeX(), MapSizeY(), ViewportData::scrollpos_x, ViewportData::scrollpos_y, TILE_SIZE, TileHeightOutsideMap(), and Window::viewport.
Referenced by ScrollMainWindowTo(), and ScrollWindowToTile().
Scrolls the viewport in a window to a given location.
tile | Desired tile to center on. | |
w | Window containing the viewport. | |
instant | Jump to the location instead of slowly moving to it. |
Definition at line 2410 of file viewport.cpp.
References ScrollWindowTo(), TILE_SIZE, TileX(), and TileY().
Referenced by WaypointWindow::OnInvalidateData(), WaypointWindow::OnResize(), TownViewWindow::OnResize(), and IndustryViewWindow::OnResize().
void SetRedErrorSquare | ( | TileIndex | tile | ) |
Set a tile to display a red error square.
tile | Tile that should show the red error square. |
Definition at line 2430 of file viewport.cpp.
References INVALID_TILE, MarkTileDirtyByTile(), and TileHighlightData::redsq.
Referenced by CcBuildRailTunnel(), and CcBuildRoadTunnel().
void SetTileSelectSize | ( | int | w, | |
int | h | |||
) |
Highlight w by h tiles at the cursor.
w | Width of the highlighted tiles rectangle. | |
h | Height of the highlighted tiles rectangle. |
Definition at line 2448 of file viewport.cpp.
References TileHighlightData::new_outersize, TileHighlightData::new_size, and TILE_SIZE.
Referenced by BuildRailClick_Remove(), CopyPasteWindow::OnClick(), CompanyWindow::OnClick(), ScenarioEditorLandscapeGenerationWindow::OnPaint(), BuildRoadStationWindow::OnPaint(), BuildRailStationWindow::OnPaint(), BuildDocksStationWindow::OnPaint(), and VpHandlePlaceSizingDrag().
static void ShowMeasurementTooltips | ( | StringID | str, | |
uint | paramcount, | |||
const uint64 | params[], | |||
TooltipCloseCondition | close_cond = TCC_LEFT_CLICK | |||
) | [inline, static] |
Displays the measurement tooltips when selecting multiple tiles.
str | String to be displayed | |
paramcount | number of params to deal with | |
params | (optional) up to 5 pieces of additional information that may be added to a tooltip | |
close_cond | Condition for closing this tooltip. |
Definition at line 2620 of file viewport.cpp.
References _settings_client, TileHighlightData::GetCallbackWnd(), ClientSettings::gui, GuiShowTooltips(), and GUISettings::measure_tooltip.
Referenced by CalcRaildirsDrawstyle(), VpSelectTilesWithMethod(), and VpSetPresizeRange().
void StartSpriteCombine | ( | ) |
Starts a block of sprites, which are "combined" into a single bounding box.
Subsequent calls to AddSortableSpriteToDraw will be drawn into the same bounding box. That is: The first sprite that is not clipped by the viewport defines the bounding box, and the following sprites will be child sprites to that one.
That implies:
The block is terminated by EndSpriteCombine.
You cannot nest "combined" blocks.
Definition at line 746 of file viewport.cpp.
References ViewportDrawer::combine_sprites, and SPRITE_COMBINE_NONE.
Referenced by DrawBridgeMiddle(), DrawBridgeTramBits(), and DrawTile_TunnelBridge().
static bool SwapDirection | ( | HighLightStyle | style, | |
TileIndex | start_tile, | |||
TileIndex | end_tile | |||
) | [static] |
Check if the direction of start and end tile should be swapped based on the dragging-style.
Default directions are: in the case of a line (HT_RAIL, HT_LINE): DIR_NE, DIR_NW, DIR_N, DIR_E in the case of a rect (HT_RECT, HT_POINT): DIR_S, DIR_E For example dragging a rectangle area from south to north should be swapped to north-south (DIR_S) to obtain the same results with less code. This is what the return value signifies.
style | HighLightStyle dragging style | |
start_tile | start tile of drag | |
end_tile | end tile of drag |
Definition at line 2738 of file viewport.cpp.
References HT_DRAG_MASK, HT_LINE, HT_POINT, HT_RAIL, HT_RECT, TileX(), and TileY().
Referenced by CalcHeightdiff().
Translate screen coordinate in a viewport to a tile coordinate.
vp | Viewport that contains the (x, y) screen coordinate | |
x | Screen x coordinate | |
y | Screen y coordinate |
Definition at line 375 of file viewport.cpp.
References _settings_game, Clamp(), GameSettings::construction, ConstructionSettings::freeform_edges, GetMaxTileHeight(), ViewPort::height, ViewPort::left, MapMaxX(), MapMaxY(), max(), ScaleByZoom(), TILE_SIZE, ViewPort::top, ViewPort::virtual_left, ViewPort::virtual_top, ViewPort::width, and ViewPort::zoom.
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 2508 of file viewport.cpp.
References TileHighlightData::diagonal, TileHighlightData::dirty, TileHighlightData::drawstyle, GetAutorailHT(), HT_DIR_HL, HT_DIR_HU, HT_DIR_MASK, HT_DIR_VL, HT_DIR_VR, HT_DIR_X, HT_DIR_Y, HT_DRAG_MASK, HT_LINE, HT_NONE, HT_POINT, HT_PREVIEW, HT_RAIL, HT_RECT, HT_SPECIAL, TileHighlightData::IsDraggingDiagonal(), TileHighlightData::new_outersize, TileHighlightData::new_pos, TileHighlightData::new_size, TileHighlightData::next_drawstyle, TileHighlightData::outersize, TileHighlightData::place_mode, TileHighlightData::pos, TileHighlightData::selend, TileHighlightData::selstart, SetSelectionTilesDirty(), TileHighlightData::size, Swap(), TILE_SIZE, and TILE_UNIT_MASK.
Referenced by StationJoinerNeeded().
void UpdateViewportPosition | ( | Window * | w | ) |
Update the viewport position being displayed.
w | Window owning the viewport. |
Definition at line 1986 of file viewport.cpp.
References _settings_client, Clamp(), ViewportData::dest_scrollpos_x, ViewportData::dest_scrollpos_y, ViewportData::follow_vehicle, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), ClientSettings::gui, INVALID_VEHICLE, ScaleByMapSize1D(), ViewportData::scrollpos_x, ViewportData::scrollpos_y, GUISettings::smooth_scroll, Window::viewport, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by UpdateWindows().
void ViewportAddString | ( | const DrawPixelInfo * | dpi, | |
ZoomLevel | small_from, | |||
const ViewportSign * | sign, | |||
StringID | string_normal, | |||
StringID | string_small, | |||
StringID | string_small_shadow, | |||
uint64 | params_1, | |||
uint64 | params_2, | |||
Colours | colour | |||
) |
Add a string to draw in the viewport.
dpi | current viewport area | |
small_from | Zoomlevel from when the small font should be used | |
sign | sign position and dimension | |
string_normal | String for normal and 2x zoom level | |
string_small | String for 4x and 8x zoom level | |
string_small_shadow | Shadow string for 4x and 8x zoom level; or STR_NULL if no shadow | |
colour | colour of the sign background; or 0 if transparent |
Definition at line 1553 of file viewport.cpp.
References ViewportSign::center, FONT_HEIGHT_NORMAL, ScaleByZoom(), ViewportSign::top, VPSM_BOTTOM, VPSM_TOP, ViewportSign::width_normal, and ViewportSign::width_small.
static void ViewportDrawBoundingBoxes | ( | const ParentSpriteToSortVector * | psd | ) | [static] |
Draws the bounding boxes of all ParentSprites.
psd | Array of ParentSprites |
Definition at line 1760 of file viewport.cpp.
References SmallVector< T, S >::Begin(), DrawBox(), SmallVector< T, S >::End(), RemapCoords(), ParentSpriteToDraw::xmax, ParentSpriteToDraw::xmin, ParentSpriteToDraw::ymax, ParentSpriteToDraw::ymin, ParentSpriteToDraw::zmax, and ParentSpriteToDraw::zmin.
static void ViewportDrawChk | ( | const ViewPort * | vp, | |
int | left, | |||
int | top, | |||
int | right, | |||
int | bottom | |||
) | [static] |
Make sure we don't draw a too big area at a time.
If we do, the sprite memory will overflow.
Definition at line 1889 of file viewport.cpp.
References ViewPort::left, ScaleByZoom(), ViewPort::top, ViewPort::virtual_left, ViewPort::virtual_top, and ViewPort::zoom.
EventState VpHandlePlaceSizingDrag | ( | ) |
Handle the mouse while dragging for placement/resizing.
Definition at line 3296 of file viewport.cpp.
References _left_button_down, _special_mouse_mode, TileHighlightData::GetCallbackWnd(), HT_DRAG_MASK, HT_POINT, HT_RAIL, HT_RECT, TileHighlightData::next_drawstyle, Window::OnPlaceDrag(), Window::OnPlaceMouseUp(), TileHighlightData::place_mode, TileHighlightData::select_method, TileHighlightData::select_proc, TileHighlightData::selend, TileHighlightData::selstart, SetTileSelectSize(), TileVirtXY(), VPM_RAILDIRS, VPM_SIGNALDIRS, and WSM_SIZING.
void VpSelectTilesWithMethod | ( | int | x, | |
int | y, | |||
ViewportPlaceMethod | method | |||
) |
Selects tiles while dragging.
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 3096 of file viewport.cpp.
References _settings_client, abs(), CalcHeightdiff(), CalcRaildirsDrawstyle(), Clamp(), Delta(), DistanceFromEdge(), DistanceManhattan(), TileHighlightData::GetCallbackWnd(), GetTileMaxZ(), ClientSettings::gui, GuiShowTooltips(), HT_DRAG_MASK, HT_LINE, HT_POINT, HT_RECT, TileHighlightData::IsDraggingDiagonal(), GUISettings::measure_tooltip, TileHighlightData::next_drawstyle, TileHighlightData::selend, TileHighlightData::selstart, ShowMeasurementTooltips(), TileHighlightData::sizelimit, TILE_HEIGHT, TILE_HEIGHT_STEP, TILE_SIZE, TileVirtXY(), TileX(), TileY(), VPM_A_B_LINE, VPM_FIX_X, VPM_FIX_Y, VPM_RAILDIRS, VPM_SIGNALDIRS, VPM_X_AND_Y, VPM_X_AND_Y_LIMITED, VPM_X_LIMITED, VPM_X_OR_Y, and VPM_Y_LIMITED.
Referenced by BuildTreesWindow::OnPlaceDrag(), ScenarioEditorLandscapeGenerationWindow::OnPlaceDrag(), TerraformToolbarWindow::OnPlaceDrag(), BuildRoadToolbarWindow::OnPlaceDrag(), BuildRailToolbarWindow::OnPlaceDrag(), BuildDocksToolbarWindow::OnPlaceDrag(), CopyPasteWindow::OnPlaceDrag(), and BuildAirToolbarWindow::OnPlaceDrag().
Highlights all tiles between a set of two tiles.
Used in dock and tunnel placement
from | TileIndex of the first tile to highlight | |
to | TileIndex of the last tile to highlight |
Definition at line 2670 of file viewport.cpp.
References DistanceManhattan(), TileHighlightData::next_drawstyle, TileHighlightData::selend, TileHighlightData::selstart, ShowMeasurementTooltips(), TILE_SIZE, TileX(), and TileY().
Referenced by BuildRoadToolbarWindow::OnPlacePresize(), BuildRailToolbarWindow::OnPlacePresize(), and BuildDocksToolbarWindow::OnPlacePresize().
const HighLightStyle _autorail_type[6][2] [static] |