author | KUDr |
Sat, 21 Apr 2007 08:23:57 +0000 | |
branch | cpp_gui |
changeset 6308 | 646711c5feaa |
parent 6307 | f40e88cff863 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6307 | 3 |
/** @file viewport.h */ |
4 |
||
0 | 5 |
#ifndef VIEWPORT_H |
6 |
#define VIEWPORT_H |
|
7 |
||
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6258
diff
changeset
|
8 |
#include "window.h" |
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6258
diff
changeset
|
9 |
|
0 | 10 |
struct ViewPort { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
11 |
int left,top; // screen coordinates for the viewport |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
12 |
int width, height; // screen width/height for the viewport |
0 | 13 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
14 |
int virtual_left, virtual_top; // virtual coordinates |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
15 |
int virtual_width, virtual_height; // these are just width << zoom, height << zoom |
0 | 16 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
17 |
byte zoom; |
0 | 18 |
}; |
19 |
||
1990
90eb49e87b90
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1977
diff
changeset
|
20 |
void SetSelectionRed(bool); |
90eb49e87b90
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1977
diff
changeset
|
21 |
|
6307 | 22 |
/* viewport.cpp */ |
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6258
diff
changeset
|
23 |
void InitViewports(); |
6258
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
5919
diff
changeset
|
24 |
void DeleteWindowViewport(BaseWindow *w); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
5919
diff
changeset
|
25 |
void AssignWindowViewport(BaseWindow *w, int x, int y, |
0 | 26 |
int width, int height, uint32 follow_flags, byte zoom); |
6258
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
5919
diff
changeset
|
27 |
ViewPort *IsPtInWindowViewport(const BaseWindow *w, int x, int y); |
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6258
diff
changeset
|
28 |
Point GetTileBelowCursor(); |
6258
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
5919
diff
changeset
|
29 |
void UpdateViewportPosition(BaseWindow *w); |
5044
7e70387677e5
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
30 |
|
7e70387677e5
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
31 |
enum { |
7e70387677e5
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
32 |
ZOOM_IN = 0, |
7e70387677e5
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
33 |
ZOOM_OUT = 1, |
7e70387677e5
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
34 |
ZOOM_NONE = 2, // hack, used to update the button status |
7e70387677e5
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
35 |
}; |
7e70387677e5
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
36 |
|
6258
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
5919
diff
changeset
|
37 |
bool DoZoomInOutWindow(int how, BaseWindow *w); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
5919
diff
changeset
|
38 |
void ZoomInOrOutToCursorWindow(bool in, BaseWindow * w); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
5919
diff
changeset
|
39 |
Point GetTileZoomCenterWindow(bool in, BaseWindow * w); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
5919
diff
changeset
|
40 |
void HandleZoomMessage(BaseWindow *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out); |
0 | 41 |
|
6258
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
5919
diff
changeset
|
42 |
static inline void MaxZoomInOut(int how, BaseWindow *w) |
5046
2b2375affc0a
(svn r7095) -Codechange: Move MaxZoomIn function to viewport.h and change it to MaxZoomInOut
Darkvater
parents:
5045
diff
changeset
|
43 |
{ |
2b2375affc0a
(svn r7095) -Codechange: Move MaxZoomIn function to viewport.h and change it to MaxZoomInOut
Darkvater
parents:
5045
diff
changeset
|
44 |
while (DoZoomInOutWindow(how, w) ) {}; |
2b2375affc0a
(svn r7095) -Codechange: Move MaxZoomIn function to viewport.h and change it to MaxZoomInOut
Darkvater
parents:
5045
diff
changeset
|
45 |
} |
2b2375affc0a
(svn r7095) -Codechange: Move MaxZoomIn function to viewport.h and change it to MaxZoomInOut
Darkvater
parents:
5045
diff
changeset
|
46 |
|
0 | 47 |
void OffsetGroundSprite(int x, int y); |
48 |
||
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
49 |
void DrawGroundSprite(SpriteID image, SpriteID pal); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
50 |
void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
51 |
void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, byte dz, byte z); |
5026
c8b7148798ac
(svn r7067) Remove the unused parameter params_3 from AddStringToDraw()
tron
parents:
4799
diff
changeset
|
52 |
void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2); |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
53 |
void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y); |
0 | 54 |
|
55 |
||
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6258
diff
changeset
|
56 |
void StartSpriteCombine(); |
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6258
diff
changeset
|
57 |
void EndSpriteCombine(); |
0 | 58 |
|
2116 | 59 |
void HandleViewportClicked(const ViewPort *vp, int x, int y); |
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6258
diff
changeset
|
60 |
void PlaceObject(); |
0 | 61 |
void SetRedErrorSquare(TileIndex tile); |
62 |
void SetTileSelectSize(int w, int h); |
|
63 |
void SetTileSelectBigSize(int ox, int oy, int sx, int sy); |
|
64 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1863
diff
changeset
|
65 |
void VpStartPlaceSizing(TileIndex tile, int user); |
0 | 66 |
void VpSetPresizeRange(uint from, uint to); |
67 |
void VpSetPlaceSizingLimit(int limit); |
|
68 |
||
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6258
diff
changeset
|
69 |
Vehicle *CheckMouseOverVehicle(); |
0 | 70 |
|
71 |
enum { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
72 |
VPM_X_OR_Y = 0, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
73 |
VPM_FIX_X = 1, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
74 |
VPM_FIX_Y = 2, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
75 |
VPM_RAILDIRS = 3, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
76 |
VPM_X_AND_Y = 4, |
0 | 77 |
VPM_X_AND_Y_LIMITED = 5, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
78 |
VPM_SIGNALDIRS = 6 |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
79 |
}; |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
80 |
|
6307 | 81 |
/* viewport highlight mode (for highlighting tiles below cursor) */ |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
82 |
enum { |
6307 | 83 |
VHM_NONE = 0, ///< default |
84 |
VHM_RECT = 1, ///< rectangle (stations, depots, ...) |
|
85 |
VHM_POINT = 2, ///< point (lower land, raise land, level land, ...) |
|
86 |
VHM_SPECIAL = 3, ///< special mode used for highlighting while dragging (and for tunnels/docks) |
|
87 |
VHM_DRAG = 4, ///< dragging items in the depot windows |
|
88 |
VHM_RAIL = 5, ///< rail pieces |
|
0 | 89 |
}; |
90 |
||
91 |
void VpSelectTilesWithMethod(int x, int y, int method); |
|
92 |
||
6307 | 93 |
/* highlighting draw styles */ |
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
94 |
typedef byte HighLightStyle; |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
95 |
enum HighLightStyles { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
96 |
HT_NONE = 0x00, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
97 |
HT_RECT = 0x80, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
98 |
HT_POINT = 0x40, |
6307 | 99 |
HT_LINE = 0x20, ///< used for autorail highlighting (longer streches) |
100 |
///< (uses lower bits to indicate direction) |
|
101 |
HT_RAIL = 0x10, ///< autorail (one piece) |
|
102 |
///< (uses lower bits to indicate direction) |
|
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
103 |
HT_DRAG_MASK = 0xF0, ///< masks the drag-type |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
104 |
|
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1093
diff
changeset
|
105 |
/* lower bits (used with HT_LINE and HT_RAIL): |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
106 |
* (see ASCII art in autorail.h for a visual interpretation) */ |
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
107 |
HT_DIR_X = 0, ///< X direction |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
108 |
HT_DIR_Y = 1, ///< Y direction |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
109 |
HT_DIR_HU = 2, ///< horizontal upper |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
110 |
HT_DIR_HL = 3, ///< horizontal lower |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
111 |
HT_DIR_VL = 4, ///< vertical left |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
112 |
HT_DIR_VR = 5, ///< vertical right |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
113 |
HT_DIR_MASK = 0x7 ///< masks the drag-direction |
0 | 114 |
}; |
115 |
||
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6258
diff
changeset
|
116 |
struct TileHighlightData { |
0 | 117 |
Point size; |
118 |
Point outersize; |
|
119 |
Point pos; |
|
120 |
Point offs; |
|
121 |
||
122 |
Point new_pos; |
|
123 |
Point new_size; |
|
124 |
Point new_outersize; |
|
125 |
||
126 |
Point selend, selstart; |
|
127 |
||
128 |
byte dirty; |
|
129 |
byte sizelimit; |
|
130 |
||
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
131 |
byte drawstyle; // lower bits 0-3 are reserved for detailed highlight information information |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
132 |
byte new_drawstyle; // only used in UpdateTileSelection() to as a buffer to compare if there was a change between old and new |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
133 |
byte next_drawstyle; // queued, but not yet drawn style |
0 | 134 |
|
135 |
byte place_mode; |
|
136 |
bool make_square_red; |
|
873
46e892485be3
(svn r1354) Use WindowClass/WindowNumber to store/pass window class/number, not some arbitrary data types
tron
parents:
849
diff
changeset
|
137 |
WindowClass window_class; |
46e892485be3
(svn r1354) Use WindowClass/WindowNumber to store/pass window class/number, not some arbitrary data types
tron
parents:
849
diff
changeset
|
138 |
WindowNumber window_number; |
0 | 139 |
|
140 |
int userdata; |
|
141 |
TileIndex redsq; |
|
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6258
diff
changeset
|
142 |
}; |
0 | 143 |
|
144 |
||
6307 | 145 |
/* common button handler */ |
6258
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
5919
diff
changeset
|
146 |
bool HandlePlacePushButton(BaseWindow *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc); |
0 | 147 |
|
148 |
VARDEF Point _tile_fract_coords; |
|
149 |
||
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1109
diff
changeset
|
150 |
extern TileHighlightData _thd; |
0 | 151 |
|
152 |
||
430 | 153 |
void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom); |
154 |
||
155 |
#endif /* VIEWPORT_H */ |