forked from TheSuperHackers/GeneralsGameCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplay.h
More file actions
229 lines (194 loc) · 11.4 KB
/
Display.h
File metadata and controls
229 lines (194 loc) · 11.4 KB
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
/*
** Command & Conquer Generals Zero Hour(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/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: Display.h ////////////////////////////////////////////////////////////
// The graphics display singleton
// Author: Michael S. Booth, March 2001
#pragma once
#include "Common/SubsystemInterface.h"
#include "GameClient/Color.h"
#include "GameClient/GameFont.h"
#include "GameClient/View.h"
struct ShroudLevel
{
Short m_currentShroud; ///< A Value of 1 means shrouded. 0 is not. Negative is the count of people looking.
Short m_activeShroudLevel;///< A Value of 0 means passive shroud. Positive is the count of people shrouding.
};
class VideoBuffer;
class VideoStreamInterface;
class DebugDisplayInterface;
class Radar;
class Image;
class DisplayString;
enum StaticGameLODLevel CPP_11(: Int);
/**
* The Display class implements the Display interface
*/
class Display : public SubsystemInterface
{
public:
enum DrawImageMode
{
DRAW_IMAGE_SOLID,
DRAW_IMAGE_GRAYSCALE, //draw image without blending and ignoring alpha
DRAW_IMAGE_ALPHA, //alpha blend the image into frame buffer
DRAW_IMAGE_ADDITIVE //additive blend the image into frame buffer
};
typedef void (DebugDisplayCallback)( DebugDisplayInterface *debugDisplay, void *userData, FILE *fp );
Display();
virtual ~Display() override;
virtual void init() override { }; ///< Initialize
virtual void reset() override; ///< Reset system
virtual void update() override; ///< Update system
//---------------------------------------------------------------------------------------
// Display attribute methods
virtual void setWidth( UnsignedInt width ); ///< Sets the width of the display
virtual void setHeight( UnsignedInt height ); ///< Sets the height of the display
virtual UnsignedInt getWidth() { return m_width; } ///< Returns the width of the display
virtual UnsignedInt getHeight() { return m_height; } ///< Returns the height of the display
virtual void setBitDepth( UnsignedInt bitDepth ) { m_bitDepth = bitDepth; }
virtual UnsignedInt getBitDepth() { return m_bitDepth; }
virtual void setWindowed( Bool windowed ) { m_windowed = windowed; } ///< set windowed/fullscreen flag
virtual Bool getWindowed() { return m_windowed; } ///< return widowed/fullscreen flag
virtual Bool setDisplayMode( UnsignedInt xres, UnsignedInt yres, UnsignedInt bitdepth, Bool windowed ); ///<sets screen resolution/mode
virtual Int getDisplayModeCount() {return 0;} ///<return number of display modes/resolutions supported by video card.
virtual void getDisplayModeDescription(Int modeIndex, Int *xres, Int *yres, Int *bitDepth) {} ///<return description of mode
virtual void setGamma(Real gamma, Real bright, Real contrast, Bool calibrate) {};
virtual Bool testMinSpecRequirements(Bool *videoPassed, Bool *cpuPassed, Bool *memPassed,StaticGameLODLevel *idealVideoLevel=nullptr, Real *cpuTime=nullptr) {*videoPassed=*cpuPassed=*memPassed=true; return true;}
virtual void doSmartAssetPurgeAndPreload(const char* usageFileName) = 0;
#if defined(RTS_DEBUG)
virtual void dumpAssetUsage(const char* mapname) = 0;
#endif
//---------------------------------------------------------------------------------------
// View management
virtual void attachView( View *view ); ///< Attach the given view to the world
virtual View *getFirstView() { return m_viewList; } ///< Return the first view of the world
virtual View *getNextView( View *view )
{
if( view )
return view->getNextView();
return nullptr;
}
virtual void drawViews(); ///< Render all views of the world
virtual void updateViews (); ///< Updates state of world views
virtual void stepViews(); ///< Update views for every fixed time step
virtual VideoBuffer* createVideoBuffer() = 0; ///< Create a video buffer that can be used for this display
//---------------------------------------------------------------------------------------
// Drawing management
virtual void setClipRegion( IRegion2D *region ) = 0; ///< Set clip rectangle for 2D draw operations.
virtual Bool isClippingEnabled() = 0;
virtual void enableClipping( Bool onoff ) = 0;
virtual void step() {}; ///< Do one fixed time step
virtual void draw() override; ///< Redraw the entire display
virtual void setTimeOfDay( TimeOfDay tod ) = 0; ///< Set the time of day for this display
virtual void createLightPulse( const Coord3D *pos, const RGBColor *color, Real innerRadius,Real attenuationWidth,
UnsignedInt increaseFrameTime, UnsignedInt decayFrameTime//, Bool donut = FALSE
) = 0;
/// draw a line on the display in pixel coordinates with the specified color
virtual void drawLine( Int startX, Int startY, Int endX, Int endY,
Real lineWidth, UnsignedInt lineColor ) = 0;
/// draw a line on the display in pixel coordinates with the specified 2 colors
virtual void drawLine( Int startX, Int startY, Int endX, Int endY,
Real lineWidth, UnsignedInt lineColor1, UnsignedInt lineColor2 ) = 0;
/// draw a rect border on the display in pixel coordinates with the specified color
virtual void drawOpenRect( Int startX, Int startY, Int width, Int height,
Real lineWidth, UnsignedInt lineColor ) = 0;
/// draw a filled rect on the display in pixel coords with the specified color
virtual void drawFillRect( Int startX, Int startY, Int width, Int height,
UnsignedInt color ) = 0;
/// Draw a percentage of a rectangle, much like a clock
virtual void drawRectClock(Int startX, Int startY, Int width, Int height, Int percent, UnsignedInt color) = 0;
virtual void drawRemainingRectClock(Int startX, Int startY, Int width, Int height, Int percent, UnsignedInt color) = 0;
/// draw an image fit within the screen coordinates
virtual void drawImage( const Image *image, Int startX, Int startY,
Int endX, Int endY, Color color = 0xFFFFFFFF, DrawImageMode mode=DRAW_IMAGE_ALPHA) = 0;
/// draw a video buffer fit within the screen coordinates
virtual void drawScaledVideoBuffer( VideoBuffer *buffer, VideoStreamInterface *stream ) = 0;
virtual void drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY,
Int endX, Int endY ) = 0;
/// FullScreen video playback
virtual void playLogoMovie( AsciiString movieName, Int minMovieLength, Int minCopyrightLength );
virtual void playMovie( AsciiString movieName );
virtual void stopMovie();
virtual Bool isMoviePlaying();
/// Register debug display callback
virtual void setDebugDisplayCallback( DebugDisplayCallback *callback, void *userData = nullptr );
virtual DebugDisplayCallback *getDebugDisplayCallback();
virtual void setShroudLevel(Int x, Int y, CellShroudStatus setting ) = 0; ///< set shroud
virtual void clearShroud() = 0; ///< empty the entire shroud
virtual void setBorderShroudLevel(UnsignedByte level) = 0; ///<color that will appear in unused border terrain.
#if defined(RTS_DEBUG)
virtual void dumpModelAssets(const char *path) = 0; ///< dump all used models/textures to a file.
#endif
virtual void preloadModelAssets( AsciiString model ) = 0; ///< preload model asset
virtual void preloadTextureAssets( AsciiString texture ) = 0; ///< preload texture asset
virtual void takeScreenShot() = 0; ///< saves screenshot to a file
virtual void toggleMovieCapture() = 0; ///< starts saving frames to an avi or frame sequence
virtual void toggleLetterBox() = 0; ///< enabled letter-boxed display
virtual void enableLetterBox(Bool enable) = 0; ///< forces letter-boxed display on/off
virtual Bool isLetterBoxFading() { return FALSE; } ///< returns true while letterbox fades in/out
virtual Bool isLetterBoxed() { return FALSE; } //WST 10/2/2002. Added query interface
virtual void setCinematicText( AsciiString string ) { m_cinematicText = string; }
virtual void setCinematicFont( GameFont *font ) { m_cinematicFont = font; }
virtual void setCinematicTextFrames( Int frames ) { m_cinematicTextFrames = frames; }
virtual Real getAverageFPS() = 0; ///< returns the average FPS.
virtual Real getCurrentFPS() = 0; ///< returns the current FPS.
virtual Int getLastFrameDrawCalls() = 0; ///< returns the number of draw calls issued in the previous frame
protected:
virtual void deleteViews(); ///< delete all views
UnsignedInt m_width, m_height; ///< Dimensions of the display
UnsignedInt m_bitDepth; ///< bit depth of the display
Bool m_windowed; ///< TRUE when windowed, FALSE when fullscreen
View *m_viewList; ///< All of the views into the world
// Cinematic text data
AsciiString m_cinematicText; ///< string of the cinematic text that should be displayed
GameFont *m_cinematicFont; ///< font for cinematic text
Int m_cinematicTextFrames; ///< count of how long the cinematic text should be displayed
// Video playback data
VideoBuffer *m_videoBuffer; ///< Video playback buffer
VideoStreamInterface *m_videoStream; ///< Video stream;
AsciiString m_currentlyPlayingMovie; ///< The currently playing video. Used to notify TheScriptEngine of completed videos.
// Debug display data
DebugDisplayInterface *m_debugDisplay; ///< Actual debug display
DebugDisplayCallback *m_debugDisplayCallback; ///< Code to update the debug display
void *m_debugDisplayUserData; ///< Data for debug display update handler
Real m_letterBoxFadeLevel; ///<tracks the current alpha level for fading letter-boxed mode in/out.
Bool m_letterBoxEnabled; ///<current state of letterbox
UnsignedInt m_letterBoxFadeStartTime; ///< time of letterbox fade start
Int m_movieHoldTime; ///< time that we hold on the last frame of the movie
Int m_copyrightHoldTime; ///< time that the copyright must be on the screen
UnsignedInt m_elapsedMovieTime; ///< used to make sure we show the stuff long enough
UnsignedInt m_elapsedCopywriteTime; ///< Hold on the last frame until both have expired
DisplayString *m_copyrightDisplayString;///< this'll hold the display string
};
// the singleton
extern Display *TheDisplay;
extern void StatDebugDisplay( DebugDisplayInterface *dd, void *, FILE *fp = nullptr );
//Necessary for display resolution confirmation dialog box
//Holds the previous and current display settings
typedef struct _DisplaySettings
{
Int xRes; //Resolution width
Int yRes; //Resolution height
Int bitDepth; //Color Depth
Bool windowed; //Window mode TRUE: we're windowed, FALSE: we're not windowed
} DisplaySettings;