2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#ifndef VIEWPORT_H
|
|
|
|
#define VIEWPORT_H
|
|
|
|
|
|
|
|
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
|
|
|
|
2004-09-10 19:02:27 +00:00
|
|
|
byte zoom;
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2005-06-29 08:14:09 +00:00
|
|
|
void SetSelectionRed(bool);
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
/* viewport.c */
|
2004-09-10 19:02:27 +00:00
|
|
|
void AssignWindowViewport(Window *w, int x, int y,
|
2004-08-09 17:04:08 +00:00
|
|
|
int width, int height, uint32 follow_flags, byte zoom);
|
2005-07-17 20:14:58 +00:00
|
|
|
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
|
2005-01-22 20:23:18 +00:00
|
|
|
Point GetTileBelowCursor(void);
|
2004-09-03 19:59:05 +00:00
|
|
|
void ZoomInOrOutToCursorWindow(bool in, Window * w);
|
|
|
|
Point GetTileZoomCenterWindow(bool in, Window * w);
|
2004-08-09 17:04:08 +00:00
|
|
|
void UpdateViewportPosition(Window *w);
|
|
|
|
|
|
|
|
void OffsetGroundSprite(int x, int y);
|
|
|
|
|
|
|
|
void DrawGroundSprite(uint32 image);
|
2005-01-03 08:50:44 +00:00
|
|
|
void DrawGroundSpriteAt(uint32 image, int32 x, int32 y, byte z);
|
2004-08-09 17:04:08 +00:00
|
|
|
void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz, byte z);
|
2004-12-31 18:57:24 +00:00
|
|
|
void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2, uint32 params_3);
|
2004-08-09 17:04:08 +00:00
|
|
|
void AddChildSpriteScreen(uint32 image, int x, int y);
|
|
|
|
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void StartSpriteCombine(void);
|
|
|
|
void EndSpriteCombine(void);
|
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);
|
2005-01-22 20:23:18 +00:00
|
|
|
void PlaceObject(void);
|
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);
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
Vehicle *CheckMouseOverVehicle(void);
|
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
|
|
|
};
|
|
|
|
|
|
|
|
// viewport highlight mode (for highlighting tiles below cursor)
|
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
VHM_NONE = 0, // default
|
|
|
|
VHM_RECT = 1, // rectangle (stations, depots, ...)
|
|
|
|
VHM_POINT = 2, // point (lower land, raise land, level land, ...)
|
2005-01-19 20:55:23 +00:00
|
|
|
VHM_SPECIAL = 3, // special mode used for highlighting while dragging (and for tunnels/docks)
|
2006-08-22 14:38:37 +00:00
|
|
|
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);
|
|
|
|
|
2005-01-19 20:55:23 +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,
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct TileHighlightData {
|
|
|
|
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;
|
|
|
|
} TileHighlightData;
|
|
|
|
|
|
|
|
|
|
|
|
// common button handler
|
|
|
|
bool HandlePlacePushButton(Window *w, int widget, uint32 cursor, int mode, PlaceProc *placeproc);
|
|
|
|
|
|
|
|
/* viewport.c */
|
2004-12-22 21:37:28 +00:00
|
|
|
// XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar)
|
|
|
|
VARDEF ViewPort _viewports[25 - 2];
|
2004-08-09 17:04:08 +00:00
|
|
|
VARDEF uint32 _active_viewports;
|
|
|
|
|
|
|
|
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 */
|