2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-04-04 04:08:47 +00:00
|
|
|
/** @file viewport.h */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#ifndef VIEWPORT_H
|
|
|
|
#define VIEWPORT_H
|
|
|
|
|
2007-05-15 14:08:39 +00:00
|
|
|
#include "zoom.hpp"
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
struct ViewPort {
|
2006-08-22 14:38:37 +00:00
|
|
|
int left,top; // screen coordinates for the viewport
|
|
|
|
int width, height; // screen width/height for the viewport
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
int virtual_left, virtual_top; // virtual coordinates
|
|
|
|
int virtual_width, virtual_height; // these are just width << zoom, height << zoom
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-05-15 14:08:39 +00:00
|
|
|
ZoomLevel zoom;
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2005-06-29 08:14:09 +00:00
|
|
|
void SetSelectionRed(bool);
|
|
|
|
|
2007-04-04 04:08:47 +00:00
|
|
|
/* viewport.cpp */
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitViewports();
|
2006-11-18 13:54:33 +00:00
|
|
|
void DeleteWindowViewport(Window *w);
|
2004-09-10 19:02:27 +00:00
|
|
|
void AssignWindowViewport(Window *w, int x, int y,
|
2007-05-15 14:08:39 +00:00
|
|
|
int width, int height, uint32 follow_flags, ZoomLevel zoom);
|
2005-07-17 20:14:58 +00:00
|
|
|
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
|
2007-03-07 11:47:46 +00:00
|
|
|
Point GetTileBelowCursor();
|
2006-11-07 13:01:36 +00:00
|
|
|
void UpdateViewportPosition(Window *w);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ZOOM_IN = 0,
|
|
|
|
ZOOM_OUT = 1,
|
|
|
|
ZOOM_NONE = 2, // hack, used to update the button status
|
|
|
|
};
|
|
|
|
|
|
|
|
bool DoZoomInOutWindow(int how, Window *w);
|
2004-09-03 19:59:05 +00:00
|
|
|
void ZoomInOrOutToCursorWindow(bool in, Window * w);
|
|
|
|
Point GetTileZoomCenterWindow(bool in, Window * w);
|
2006-11-07 13:06:02 +00:00
|
|
|
void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-11-07 13:08:42 +00:00
|
|
|
static inline void MaxZoomInOut(int how, Window *w)
|
|
|
|
{
|
|
|
|
while (DoZoomInOutWindow(how, w) ) {};
|
|
|
|
}
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
void OffsetGroundSprite(int x, int y);
|
|
|
|
|
2007-01-14 19:57:49 +00:00
|
|
|
void DrawGroundSprite(SpriteID image, SpriteID pal);
|
|
|
|
void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z);
|
|
|
|
void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, byte dz, byte z);
|
2006-11-05 11:52:19 +00:00
|
|
|
void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2);
|
2007-01-14 19:57:49 +00:00
|
|
|
void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void StartSpriteCombine();
|
|
|
|
void EndSpriteCombine();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-07-17 20:14:58 +00:00
|
|
|
void HandleViewportClicked(const ViewPort *vp, int x, int y);
|
2007-03-07 11:47:46 +00:00
|
|
|
void PlaceObject();
|
2004-08-09 17:04:08 +00:00
|
|
|
void SetRedErrorSquare(TileIndex tile);
|
|
|
|
void SetTileSelectSize(int w, int h);
|
|
|
|
void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void VpStartPlaceSizing(TileIndex tile, int user);
|
2004-08-09 17:04:08 +00:00
|
|
|
void VpSetPresizeRange(uint from, uint to);
|
|
|
|
void VpSetPlaceSizingLimit(int limit);
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
Vehicle *CheckMouseOverVehicle();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
VPM_X_OR_Y = 0,
|
|
|
|
VPM_FIX_X = 1,
|
|
|
|
VPM_FIX_Y = 2,
|
|
|
|
VPM_RAILDIRS = 3,
|
|
|
|
VPM_X_AND_Y = 4,
|
2004-08-09 17:04:08 +00:00
|
|
|
VPM_X_AND_Y_LIMITED = 5,
|
2006-08-22 14:38:37 +00:00
|
|
|
VPM_SIGNALDIRS = 6
|
2005-01-19 20:55:23 +00:00
|
|
|
};
|
|
|
|
|
2007-04-04 04:08:47 +00:00
|
|
|
/* viewport highlight mode (for highlighting tiles below cursor) */
|
2005-01-19 20:55:23 +00:00
|
|
|
enum {
|
2007-04-04 04:08:47 +00:00
|
|
|
VHM_NONE = 0, ///< default
|
|
|
|
VHM_RECT = 1, ///< rectangle (stations, depots, ...)
|
|
|
|
VHM_POINT = 2, ///< point (lower land, raise land, level land, ...)
|
|
|
|
VHM_SPECIAL = 3, ///< special mode used for highlighting while dragging (and for tunnels/docks)
|
|
|
|
VHM_DRAG = 4, ///< dragging items in the depot windows
|
|
|
|
VHM_RAIL = 5, ///< rail pieces
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void VpSelectTilesWithMethod(int x, int y, int method);
|
|
|
|
|
2007-04-04 04:08:47 +00:00
|
|
|
/* highlighting draw styles */
|
2006-10-10 14:05:39 +00:00
|
|
|
typedef byte HighLightStyle;
|
|
|
|
enum HighLightStyles {
|
2006-08-22 14:38:37 +00:00
|
|
|
HT_NONE = 0x00,
|
|
|
|
HT_RECT = 0x80,
|
|
|
|
HT_POINT = 0x40,
|
2007-04-04 04:08:47 +00:00
|
|
|
HT_LINE = 0x20, ///< used for autorail highlighting (longer streches)
|
|
|
|
///< (uses lower bits to indicate direction)
|
|
|
|
HT_RAIL = 0x10, ///< autorail (one piece)
|
|
|
|
///< (uses lower bits to indicate direction)
|
2006-10-10 14:05:39 +00:00
|
|
|
HT_DRAG_MASK = 0xF0, ///< masks the drag-type
|
2005-01-19 20:55:23 +00:00
|
|
|
|
2005-01-23 13:09:35 +00:00
|
|
|
/* lower bits (used with HT_LINE and HT_RAIL):
|
2005-01-19 20:55:23 +00:00
|
|
|
* (see ASCII art in autorail.h for a visual interpretation) */
|
2006-10-10 14:05:39 +00:00
|
|
|
HT_DIR_X = 0, ///< X direction
|
|
|
|
HT_DIR_Y = 1, ///< Y direction
|
|
|
|
HT_DIR_HU = 2, ///< horizontal upper
|
|
|
|
HT_DIR_HL = 3, ///< horizontal lower
|
|
|
|
HT_DIR_VL = 4, ///< vertical left
|
|
|
|
HT_DIR_VR = 5, ///< vertical right
|
|
|
|
HT_DIR_MASK = 0x7 ///< masks the drag-direction
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct TileHighlightData {
|
2004-08-09 17:04:08 +00:00
|
|
|
Point size;
|
|
|
|
Point outersize;
|
|
|
|
Point pos;
|
|
|
|
Point offs;
|
|
|
|
|
|
|
|
Point new_pos;
|
|
|
|
Point new_size;
|
|
|
|
Point new_outersize;
|
|
|
|
|
|
|
|
Point selend, selstart;
|
|
|
|
|
|
|
|
byte dirty;
|
|
|
|
byte sizelimit;
|
|
|
|
|
2005-01-19 20:55:23 +00:00
|
|
|
byte drawstyle; // lower bits 0-3 are reserved for detailed highlight information information
|
|
|
|
byte new_drawstyle; // only used in UpdateTileSelection() to as a buffer to compare if there was a change between old and new
|
|
|
|
byte next_drawstyle; // queued, but not yet drawn style
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
byte place_mode;
|
|
|
|
bool make_square_red;
|
2005-01-03 21:29:59 +00:00
|
|
|
WindowClass window_class;
|
|
|
|
WindowNumber window_number;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
int userdata;
|
|
|
|
TileIndex redsq;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
|
2007-04-04 04:08:47 +00:00
|
|
|
/* common button handler */
|
2007-01-10 18:56:51 +00:00
|
|
|
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
VARDEF Point _tile_fract_coords;
|
|
|
|
|
2005-05-27 15:05:54 +00:00
|
|
|
extern TileHighlightData _thd;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
|
2004-11-15 19:25:59 +00:00
|
|
|
void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom);
|
|
|
|
|
|
|
|
#endif /* VIEWPORT_H */
|