19 #ifndef OPENXCOM_SURFACE_H
20 #define OPENXCOM_SURFACE_H
23 #include <SDL_image.h>
42 SDL_Surface *_surface;
44 SDL_Rect _crop, _clear;
45 bool _visible, _hidden, _redraw;
49 void resize(
int width,
int height);
52 Surface(
int width,
int height,
int x = 0,
int y = 0,
int bpp = 8);
58 void loadScr(
const std::string &filename);
60 void loadSpk(
const std::string &filename);
62 void loadBdy(
const std::string &filename);
64 void loadImage(
const std::string &filename);
68 void offset(
int off,
int min = -1,
int max = -1,
int mul = 1);
82 void drawRect(SDL_Rect *rect, Uint8 color);
84 void drawRect(Sint16 x, Sint16 y, Sint16 w, Sint16 h, Uint8 color);
86 void drawLine(Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 color);
88 void drawCircle(Sint16 x, Sint16 y, Sint16 r, Uint8 color);
90 void drawPolygon(Sint16 *x, Sint16 *y,
int n, Uint8 color);
94 void drawString(Sint16 x, Sint16 y,
const char *s, Uint8 color);
96 virtual void setPalette(SDL_Color *colors,
int firstcolor = 0,
int ncolors = 256);
103 return _surface->format->palette->colors;
106 virtual void setX(
int x);
116 virtual void setY(
int y);
146 ((Uint8 *)_surface->pixels)[y * _surface->pitch + x * _surface->format->BytesPerPixel] = pixel;
178 return ((Uint8 *)_surface->pixels)[y * _surface->pitch + x * _surface->format->BytesPerPixel];
215 void blitNShade(
Surface *surface,
int x,
int y,
int off,
bool half =
false,
int newBaseColor = 0);
virtual void setY(int y)
Sets the Y position of the surface.
Definition: Surface.cpp:645
void drawRect(SDL_Rect *rect, Uint8 color)
Draws a filled rectangle on the surface.
Definition: Surface.cpp:546
int getWidth() const
Returns the width of the surface.
Definition: Surface.h:192
void clear()
Clears the surface's contents.
Definition: Surface.cpp:388
void drawLine(Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 color)
Draws a line on the surface.
Definition: Surface.cpp:577
virtual ~Surface()
Cleans up the surface.
Definition: Surface.cpp:207
virtual void setX(int x)
Sets the X position of the surface.
Definition: Surface.cpp:636
void blitNShade(Surface *surface, int x, int y, int off, bool half=false, int newBaseColor=0)
Specific blit function to blit battlescape terrain data in different shades in a fast way...
Definition: Surface.cpp:805
void setVisible(bool visible)
Sets the surface's visibility.
Definition: Surface.cpp:655
SDL_Color * getPalette() const
Returns the surface's 8bpp palette.
Definition: Surface.h:101
virtual void draw()
Draws the surface's graphic.
Definition: Surface.cpp:488
void loadImage(const std::string &filename)
Loads a general image file.
Definition: Surface.cpp:250
Uint8 getPixel(int x, int y) const
Returns the color of a specified pixel in the surface.
Definition: Surface.h:172
int getY() const
Returns the position of the surface in the Y axis.
Definition: Surface.h:121
void setTooltip(const std::string &tooltip)
Sets the tooltip of the surface.
Definition: Surface.cpp:848
Contains strings used throughout the game for localization.
Definition: Language.h:42
Takes care of loading and storing each character in a sprite font.
Definition: Font.h:40
void unlock()
Unlocks the surface.
Definition: Surface.cpp:730
SDL_Rect * getCrop()
Gets the cropping rectangle for the surface.
Definition: Surface.cpp:685
virtual void blit(Surface *surface)
Blits this surface onto another one.
Definition: Surface.cpp:501
void invalidate()
Invalidate the surface: force it to be redrawn.
Definition: Surface.cpp:828
void drawString(Sint16 x, Sint16 y, const char *s, Uint8 color)
Draws a string on the surface.
Definition: Surface.cpp:627
void loadBdy(const std::string &filename)
Loads a TFTD BDY graphic.
Definition: Surface.cpp:334
void setPixel(int x, int y, Uint8 pixel)
Changes the color of a pixel in the surface, relative to the top-left corner of the surface...
Definition: Surface.h:140
void loadSpk(const std::string &filename)
Loads an X-Com SPK graphic.
Definition: Surface.cpp:278
virtual void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256)
Sets the surface's palette.
Definition: Surface.cpp:696
Element that is blit (rendered) onto the screen.
Definition: Surface.h:39
bool getVisible() const
Gets the surface's visibility.
Definition: Surface.cpp:664
int getHeight() const
Returns the height of the surface.
Definition: Surface.h:202
void resize(int width, int height)
Recreates the surface with a new size.
Definition: Surface.cpp:860
virtual void think()
Runs surface functionality every cycle.
Definition: Surface.cpp:477
Surface(int width, int height, int x=0, int y=0, int bpp=8)
Creates a new surface with the specified size and position.
Definition: Surface.cpp:137
void invert(Uint8 mid)
Inverts the surface's colors.
Definition: Surface.cpp:451
SDL_Surface * getSurface() const
Returns the internal SDL_Surface for SDL calls.
Definition: Surface.h:184
void loadScr(const std::string &filename)
Loads an X-Com SCR graphic.
Definition: Surface.cpp:220
void copy(Surface *surface)
Copies a portion of another surface into this one.
Definition: Surface.cpp:531
void drawPolygon(Sint16 *x, Sint16 *y, int n, Uint8 color)
Draws a filled polygon on the surface.
Definition: Surface.cpp:601
void setHidden(bool hidden)
Sets the surface's special hidden flag.
Definition: Surface.cpp:709
void lock()
Locks the surface.
Definition: Surface.cpp:720
void setPixelIterative(int *x, int *y, Uint8 pixel)
Changes the color of a pixel in the surface and returns the next pixel position.
Definition: Surface.h:156
int getX() const
Returns the position of the surface in the X axis.
Definition: Surface.h:111
void drawCircle(Sint16 x, Sint16 y, Sint16 r, Uint8 color)
Draws a filled circle on the surface.
Definition: Surface.cpp:589
virtual void setWidth(int width)
Sets the width of the surface.
Definition: Surface.cpp:894
void resetCrop()
Resets the cropping rectangle for the surface.
Definition: Surface.cpp:673
std::string getTooltip() const
Gets the tooltip of the surface.
Definition: Surface.cpp:838
virtual void initText(Font *, Font *, Language *)
Initializes the surface's various text resources.
Definition: Surface.h:78
virtual void setHeight(int height)
Sets the height of the surface.
Definition: Surface.cpp:906
void offset(int off, int min=-1, int max=-1, int mul=1)
Offsets the surface's colors by a set amount.
Definition: Surface.cpp:403
void drawTexturedPolygon(Sint16 *x, Sint16 *y, int n, Surface *texture, int dx, int dy)
Draws a textured polygon on the surface.
Definition: Surface.cpp:615