OpenXcom
1.0
Open-source clone of the original X-Com
|
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... | |
Surface * | getSurface () |
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... | |
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.
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.
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.
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.
int OpenXcom::Screen::getDX | ( | ) |
Get horizontal offset.
Gets the Horizontal offset from the mid-point of the screen, in pixels.
int OpenXcom::Screen::getDY | ( | ) |
Get vertical offset.
Gets the Vertical offset from the mid-point of the screen, in pixels.
int OpenXcom::Screen::getHeight | ( | ) | const |
Gets the screen's height.
Returns the height of the screen.
SDL_Color * OpenXcom::Screen::getPalette | ( | ) | const |
Gets the screen's 8bpp palette.
Returns the screen's 8bpp palette.
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.
int OpenXcom::Screen::getWidth | ( | ) | const |
Gets the screen's width.
Returns the width of the screen.
double OpenXcom::Screen::getXScale | ( | ) | const |
Gets the screen's X scale.
Returns the screen's X scale.
double OpenXcom::Screen::getYScale | ( | ) | const |
Gets the screen's Y scale.
Returns the screen's Y scale.
void OpenXcom::Screen::handle | ( | Action * | action | ) |
Handles keyboard events.
Handles screen key shortcuts.
action | Pointer to an action. |
|
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.
|
static |
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.
resetVideo | Reset display surface. |
void OpenXcom::Screen::screenshot | ( | const std::string & | filename | ) | const |
Takes a screenshot.
Saves a screenshot of the screen's contents.
filename | Filename 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.
colors | Pointer to the set of colors. |
firstcolor | Offset of the first color to replace. |
ncolors | Amount of colors to replace. |
immediately | Apply palette changes immediately, otherwise wait for next blit. |
|
static |
update the game scale as required.
Changes a given scale, and if necessary, switch the current base resolution.
type | reference to which scale option we are using, battlescape or geoscape. |
selection | the new scale level. |
width | reference to which x scale to adjust. |
height | reference to which y scale to adjust. |
change | should we change the current scale. |