Advanced Strategic Command
vehicletypeimage.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * This program is free software; you can redistribute it and/or modify *
4  * it under the terms of the GNU General Public License as published by *
5  * the Free Software Foundation; either version 2 of the License, or *
6  * (at your option) any later version. *
7  * *
8  ***************************************************************************/
9 
10 #include <pgdraw.h>
11 
12 #include "vehicletypeimage.h"
13 
14 #include "../typen.h"
15 #include "../player.h"
16 #include "../vehicletype.h"
17 
18 #include <pgapplication.h>
19 
20 VehicleTypeImage::VehicleTypeImage( PG_Widget* parent, const PG_Point& pos, const VehicleType* vehicletype, const Player& owningPlayer )
21  : PG_Widget( parent, PG_Rect( pos.x, pos.y, fieldsizex, fieldsizey )),
22  vt( vehicletype ), player( owningPlayer )
23 {
24 
25 }
26 
27 
28 Surface VehicleTypeImage::clippingSurface;
29 
30 void VehicleTypeImage::display( SDL_Surface * surface, const PG_Rect & src, const PG_Rect & dst )
31 {
32  if ( !getClippingSurface().valid() )
33  getClippingSurface() = Surface::createSurface( fieldsizex + 10, fieldsizey + 10, 32, 0 );
34 
35  getClippingSurface().Fill(0);
36 
37  vt->paint( getClippingSurface(), SPoint(5,5), player.getPlayerColor(), 0 );
38  PG_Draw::BlitSurface( getClippingSurface().getBaseSurface(), PG_Rect( src.x + 5, src.y + 5, src.w, src.h), surface, dst);
39 }
40 
41 void VehicleTypeImage::eventBlit ( SDL_Surface * surface, const PG_Rect & src, const PG_Rect & dst )
42 {
43  display( PG_Application::GetScreen(), src, dst );
44 };
45 
PlayerColor getPlayerColor() const
Definition: player.cpp:268
static Surface createSurface(int width, int height, SDLmm::Color color=255)
Definition: surface.cpp:387
void eventBlit(SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
#define fieldsizey
Definition: typen.h:441
The class describing properties that are common to all vehicles of a certain kind.
Definition: vehicletype.h:177
#define fieldsizex
Definition: typen.h:440
SDLmm::SPoint SPoint
Definition: surface.h:27
VehicleTypeImage(PG_Widget *parent, const PG_Point &pos, const VehicleType *vehicletype, const Player &owningPlayer)
void paint(Surface &s, SPoint pos, const PlayerColor &player, int direction=0) const
void display(SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
the different players in ASC. There may be 8 players (0..7) and neutral units (8) ...
Definition: player.h:99