This repository was archived by the owner on Feb 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 511
/
Copy pathDISPLAY.H
320 lines (273 loc) · 11.4 KB
/
DISPLAY.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/*
** Command & Conquer(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Header: F:\projects\c&c\vcs\code\display.h_v 2.15 16 Oct 1995 16:47:42 JOE_BOSTIC $ */
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : Command & Conquer *
* *
* File Name : DISPLAY.H *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : May 1, 1994 *
* *
* Last Update : May 1, 1994 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef DISPLAY_H
#define DISPLAY_H
#include "map.h"
#include "layer.h"
#define ICON_PIXEL_W 24
#define ICON_PIXEL_H 24
#define ICON_LEPTON_W 256
#define ICON_LEPTON_H 256
#define CELL_PIXEL_W ICON_PIXEL_W
#define CELL_PIXEL_H ICON_PIXEL_H
#define CELL_LEPTON_W ICON_LEPTON_W
#define CELL_LEPTON_H ICON_LEPTON_H
// -----------------------------------------------------------
#define PIXEL_LEPTON_W (ICON_LEPTON_W/ICON_PIXEL_W)
#define PIXEL_LEPTON_H (ICON_LEPTON_H/ICON_PIXEL_H)
extern COORDINATE Coord_Add(COORDINATE coord1, COORDINATE coord2);
class DisplayClass: public MapClass
{
public:
/*
** This indicates the theater that the display is to represent.
*/
TheaterType Theater;
/*
** The tactical map display position is indicated by the cell of the
** upper left hand corner. These should not be altered directly. Use
** the Set_Tactical_Position function instead.
*/
COORDINATE TacticalCoord;
/*
** The dimensions (in cells) of the visible window onto the game map. This tactical
** map is how the player interacts and views the game world.
*/
int TacLeptonWidth;
int TacLeptonHeight;
/*
** These layer control elements are used to group the displayable objects
** so that proper overlap can be obtained.
*/
static LayerClass Layer[LAYER_COUNT];
/*
** This records the position and shape of a placement cursor to display
** over the map. This cursor is used when placing buildings and also used
** extensively by the scenario editor.
*/
CELL ZoneCell;
short ZoneOffset;
short const *CursorSize;
bool ProximityCheck; // Is proximity check ok?
/*
** This holds the building type that is about to be placed upon the map.
** It is only valid during the building placement state. The PendingLegal
** flag is updated as the cursor moves and it reflects the legality of
** placing the building at the desired location.
*/
ObjectClass * PendingObjectPtr;
ObjectTypeClass const * PendingObject;
HousesType PendingHouse;
static unsigned char FadingBrighten[256];
static unsigned char FadingShade[256];
static unsigned char FadingLight[256];
static unsigned char RemapTables[HOUSE_COUNT][3][256];
static unsigned char FadingGreen[256];
static unsigned char FadingYellow[256];
static unsigned char FadingRed[256];
static unsigned char TranslucentTable[(MAGIC_COL_COUNT+1)*256];
static unsigned char WhiteTranslucentTable[(1+1)*256];
static unsigned char MouseTranslucentTable[(4+1)*256];
static void const *TransIconset;
static unsigned char UnitShadow[(USHADOW_COL_COUNT+1)*256];
static unsigned char SpecialGhost[2*256];
//-------------------------------------------------------------------------
DisplayClass(void);
virtual void Read_INI(char *buffer);
void Write_INI(char *buffer);
/*
** Initialization
*/
virtual void One_Time(void); // One-time inits
virtual void Init_Clear(void); // Clears all to known state
virtual void Init_IO(void); // Inits button list
virtual void Init_Theater(TheaterType theater); // Theater-specific inits
/*
** General display/map/interface support functionality.
*/
virtual void AI(KeyNumType &input, int x, int y);
virtual void Draw_It(bool complete=false);
/*
** Added functionality.
*/
void Center_Map(void);
virtual bool Map_Cell(CELL cell, HouseClass *house);
virtual CELL Click_Cell_Calc(int x, int y);
virtual void Help_Text(int , int =-1, int =-1, int =YELLOW, bool =false, int =0) {};
virtual MouseType Get_Mouse_Shape(void) const = 0;
virtual bool Scroll_Map(DirType facing, int & distance, bool really);
virtual void Refresh_Cells(CELL cell, short const *list);
virtual void Set_View_Dimensions(int x, int y, int width=-1, int height=-1);
/*
** Pending object placement control.
*/
virtual void Put_Place_Back(TechnoClass * ) {}; // Affects 'pending' system.
void Cursor_Mark(CELL pos, bool on);
void Set_Cursor_Shape(short const * list);
CELL Set_Cursor_Pos(CELL pos = -1);
void Get_Occupy_Dimensions(int & w, int & h, short const *list);
/*
** Tactical map only functionality.
*/
virtual void Set_Tactical_Position(COORDINATE coord);
void Refresh_Band(void);
void Select_These(COORDINATE coord1, COORDINATE coord2);
COORDINATE Pixel_To_Coord(int x, int y);
bool Coord_To_Pixel(COORDINATE coord, int &x, int &y);
bool Push_Onto_TacMap(COORDINATE &source, COORDINATE &dest);
void Remove(ObjectClass const *object, LayerType layer);
void Submit(ObjectClass const *object, LayerType layer);
CELL Calculated_Cell(SourceType dir, HousesType house);
bool In_View(register CELL cell);
bool Passes_Proximity_Check(ObjectTypeClass const *object);
ObjectClass * Cell_Object(CELL cell, int x=0, int y=0);
ObjectClass * Next_Object(ObjectClass * object);
ObjectClass * Prev_Object(ObjectClass * object);
int Cell_Shadow(CELL cell);
short const * Text_Overlap_List(char const * text, int x, int y, int lines = 1);
bool Is_Spot_Free(COORDINATE coord) const;
COORDINATE Closest_Free_Spot(COORDINATE coord, bool any=false) const;
void Sell_Mode_Control(int control);
void Repair_Mode_Control(int control);
void Flag_Cell(CELL cell) {
Flag_To_Redraw(false);
IsToRedraw = true;
CellRedraw[cell] = true;
};
bool Is_Cell_Flagged(CELL cell) const {return CellRedraw.Is_True(cell);};
/*
** Computes starting position based on player's units' Coords.
*/
void Compute_Start_Pos(void);
/*
** File I/O.
*/
virtual void Code_Pointers(void);
virtual void Decode_Pointers(void);
protected:
virtual void Mouse_Right_Press(void);
virtual void Mouse_Left_Press(int x, int y);
virtual void Mouse_Left_Up(bool shadow, ObjectClass * object, ActionType action, bool wwsmall = false);
virtual void Mouse_Left_Held(int x, int y);
virtual void Mouse_Left_Release(CELL cell, int x, int y, ObjectClass * object, ActionType action, bool wwsmall = false);
public:
/*
** This is the pixel offset for the upper left corner of the tactical map.
*/
int TacPixelX;
int TacPixelY;
/*
** This is the coordinate that the tactical map should be in at next available opportunity.
*/
COORDINATE DesiredTacticalCoord;
/*
** If something in the tactical map is to be redrawn, this flag is set to true.
*/
unsigned IsToRedraw:1;
/*
** If the player is currently wielding a wrench (to select buildings for repair),
** then this flag is true. In such a state, normal movement and combat orders
** are preempted.
*/
unsigned IsRepairMode:1;
/*
** If the player is currently in "sell back" mode, then this flag will be
** true. While in this mode, anything clicked on will be sold back to the
** "factory".
*/
unsigned IsSellMode:1;
/*
** If the player is currently in ion cannon targetting mode, then this
** flag will be true. While in this mode, anything clicked on will be
** be destroyed by the ION cannon.
*/
unsigned IsTargettingMode:2;
protected:
/*
** If it is currently in rubber band mode (multi unit selection), then this
** flag will be true. While in such a mode, normal input is prempted while
** the extended selection is in progress.
*/
unsigned IsRubberBand:1;
/*
** The moment the mouse is held down, this flag gets set. If the mouse is dragged
** a sufficient distance while held down, then true rubber band mode selection
** can begin. Using a minimum distance prevents accidental rubber band selection
** mode from being initiated.
*/
unsigned IsTentative:1;
/*
** This gadget class is used for capturing input to the tactical map. All mouse input
** will be routed through this gadget.
*/
class TacticalClass : public GadgetClass {
public:
TacticalClass(void) : GadgetClass(0,0,0,0,LEFTPRESS|LEFTRELEASE|LEFTHELD|LEFTUP|RIGHTPRESS,true) {};
protected:
virtual int Action(unsigned flags, KeyNumType & key);
};
friend class TacticalClass;
/*
** This is the "button" that tracks all input to the tactical map.
** It must be available to derived classes, for Save/Load purposes.
*/
static TacticalClass TacButton;
private:
/*
** This is a utility flag that is set during the icon draw process only if there
** was at least one shadow icon detected that should be redrawn. When the shadow
** drawing logic is to take place, but this flag is false, then the shadow drawing
** will be skipped since it would perform no function.
*/
unsigned IsShadowPresent:1;
/*
** Rubber band mode consists of stretching a box from the anchor point (specified
** here) to the current cursor position.
*/
int BandX,BandY;
int NewX,NewY;
static void const *ShadowShapes;
static unsigned char ShadowTrans[(SHADOW_COL_COUNT+1)*256];
void Redraw_Icons(int draw_flags=0);
void Redraw_Shadow(void);
void Redraw_Shadow_Rects(void);
/*
** This bit array is used to flag cells to be redrawn. If the icon needs to
** be redrawn for a cell, then the corresponding flag will be true.
*/
static BooleanVectorClass CellRedraw;
};
#endif