OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
OpenXcom::Screen Class Reference

A display screen, handles rendering onto the game window. More...

#include <Screen.h>

Public Member Functions

 Screen ()
 Creates a new display screen. More...
 
 ~Screen ()
 Cleans up the display screen. More...
 
int getDX ()
 Get horizontal offset. More...
 
int getDY ()
 Get vertical offset. More...
 
SurfacegetSurface ()
 Gets the internal buffer. More...
 
void handle (Action *action)
 Handles keyboard events. More...
 
void flip ()
 Renders the screen onto the game window. More...
 
void clear ()
 Clears the screen. More...
 
void setPalette (SDL_Color *colors, int firstcolor=0, int ncolors=256, bool immediately=false)
 Sets the screen's 8bpp palette. More...
 
SDL_Color * getPalette () const
 Gets the screen's 8bpp palette. More...
 
int getWidth () const
 Gets the screen's width. More...
 
int getHeight () const
 Gets the screen's height. More...
 
void resetDisplay (bool resetVideo=true)
 Resets the screen display. More...
 
double getXScale () const
 Gets the screen's X scale. More...
 
double getYScale () const
 Gets the screen's Y scale. More...
 
int getCursorTopBlackBand () const
 Gets the screen's top black forbidden to cursor band's height. More...
 
int getCursorLeftBlackBand () const
 Gets the screen's left black forbidden to cursor band's width. More...
 
void screenshot (const std::string &filename) const
 Takes a screenshot. More...
 

Static Public Member Functions

static bool isHQXEnabled ()
 Checks whether HQX is requested and works for the selected resolution. More...
 
static bool isOpenGLEnabled ()
 Checks whether OpenGL output is requested. More...
 
static void updateScale (int &type, int selection, int &x, int &y, bool change)
 update the game scale as required. More...
 

Detailed Description

A display screen, handles rendering onto the game window.

In SDL a Screen is treated like a Surface, so this is just a specialized version of a Surface with functionality more relevant for display screens. Contains a Surface buffer where all the contents are kept, so any filters or conversions can be applied before rendering the screen.

Constructor & Destructor Documentation

OpenXcom::Screen::Screen ( )

Creates a new display screen.

Initializes a new display screen for the game to render contents to.

The screen is set up based on the current options.

OpenXcom::Screen::~Screen ( )

Cleans up the display screen.

Deletes the buffer from memory.

The display screen itself is automatically freed once SDL shuts down.

Member Function Documentation

void OpenXcom::Screen::clear ( )

Clears the screen.

Clears all the contents out of the internal buffer.

void OpenXcom::Screen::flip ( )

Renders the screen onto the game window.

Renders the buffer's contents onto the screen, applying any necessary filters or conversions in the process.

If the scaling factor is bigger than 1, the entire contents of the buffer are resized by that factor (eg. 2 = doubled) before being put on screen.

int OpenXcom::Screen::getCursorLeftBlackBand ( ) const

Gets the screen's left black forbidden to cursor band's width.

Returns the screen's left black forbidden to cursor band's width.

Returns
Width in pixel.
int OpenXcom::Screen::getCursorTopBlackBand ( ) const

Gets the screen's top black forbidden to cursor band's height.

Returns the screen's top black forbidden to cursor band's height.

Returns
Height in pixel.
int OpenXcom::Screen::getDX ( )

Get horizontal offset.

Gets the Horizontal offset from the mid-point of the screen, in pixels.

Returns
the horizontal offset.
int OpenXcom::Screen::getDY ( )

Get vertical offset.

Gets the Vertical offset from the mid-point of the screen, in pixels.

Returns
the vertical offset.
int OpenXcom::Screen::getHeight ( ) const

Gets the screen's height.

Returns the height of the screen.

Returns
Height in pixels
SDL_Color * OpenXcom::Screen::getPalette ( ) const

Gets the screen's 8bpp palette.

Returns the screen's 8bpp palette.

Returns
Pointer to the palette's colors.
Surface * OpenXcom::Screen::getSurface ( )

Gets the internal buffer.

Returns the screen's internal buffer surface.

Any contents that need to be shown will be blitted to this.

Returns
Pointer to the buffer surface.
int OpenXcom::Screen::getWidth ( ) const

Gets the screen's width.

Returns the width of the screen.

Returns
Width in pixels.
double OpenXcom::Screen::getXScale ( ) const

Gets the screen's X scale.

Returns the screen's X scale.

Returns
Scale factor.
double OpenXcom::Screen::getYScale ( ) const

Gets the screen's Y scale.

Returns the screen's Y scale.

Returns
Scale factor.
void OpenXcom::Screen::handle ( Action action)

Handles keyboard events.

Handles screen key shortcuts.

Parameters
actionPointer to an action.
bool OpenXcom::Screen::isHQXEnabled ( )
static

Checks whether HQX is requested and works for the selected resolution.

Check whether useHQXFilter is set in Options and a compatible resolution has been selected.

Returns
if it is enabled.
bool OpenXcom::Screen::isOpenGLEnabled ( )
static

Checks whether OpenGL output is requested.

Check if OpenGL is enabled.

Returns
if it is enabled.
void OpenXcom::Screen::resetDisplay ( bool  resetVideo = true)

Resets the screen display.

Resets the screen surfaces based on the current display options, as they don't automatically take effect.

Parameters
resetVideoReset display surface.
void OpenXcom::Screen::screenshot ( const std::string &  filename) const

Takes a screenshot.

Saves a screenshot of the screen's contents.

Parameters
filenameFilename of the PNG file.
void OpenXcom::Screen::setPalette ( SDL_Color *  colors,
int  firstcolor = 0,
int  ncolors = 256,
bool  immediately = false 
)

Sets the screen's 8bpp palette.

Changes the 8bpp palette used to render the screen's contents.

Parameters
colorsPointer to the set of colors.
firstcolorOffset of the first color to replace.
ncolorsAmount of colors to replace.
immediatelyApply palette changes immediately, otherwise wait for next blit.
void OpenXcom::Screen::updateScale ( int &  type,
int  selection,
int &  width,
int &  height,
bool  change 
)
static

update the game scale as required.

Changes a given scale, and if necessary, switch the current base resolution.

Parameters
typereference to which scale option we are using, battlescape or geoscape.
selectionthe new scale level.
widthreference to which x scale to adjust.
heightreference to which y scale to adjust.
changeshould we change the current scale.

The documentation for this class was generated from the following files: