Advanced Strategic Command
actionwidget.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Advanced Strategic Command; http://www.asc-hq.org
3  Copyright (C) 1994-2010 Martin Bickel
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to the
17  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  Boston, MA 02111-1307 USA
19 */
20 
21 #include "actionwidget.h"
22 #include "../widgets/vehicletypeimage.h"
23 
24 #include "../gamemap.h"
25 #include "../actions/unitcommand.h"
26 #include "../itemrepository.h"
27 
28 
29 ActionWidget::ActionWidget( PG_Widget* parent, const PG_Point& pos, int width, const Command& action, GameMap* map )
30  : SelectionWidget( parent, PG_Rect( pos.x, pos.y, width, fieldsizey )), act( action )
31 {
32 
33  int offset = 0;
34 
35  const UnitCommand* uc = dynamic_cast<const UnitCommand*>(&action);
36  if ( uc != NULL && uc->getUnitTypeID() > 0 ) {
37  VehicleType* vt = vehicleTypeRepository.getObject_byID( uc->getUnitTypeID() );
38  if ( vt ) {
39  PG_Widget* w = new VehicleTypeImage( this, PG_Point( 25, 0), vt, map->getCurrentPlayer() );
40  offset += w->Width() + 5;
41  }
42  }
43  PG_Label* lbl1 = new PG_Label( this, PG_Rect( 25 + offset, 0, Width()-30, Height() ), action.getDescription() );
44  lbl1->SetFontSize( lbl1->GetFontSize() -2 );
45 
46  SetTransparency( 255 );
47 };
48 
50 {
51  return act.getDescription();
52 };
53 
54 vector<MapCoordinate> ActionWidget::getCoordinates() const
55 {
56  return act.getCoordinates();
57 }
58 
59 
60 void ActionWidget::display( SDL_Surface * surface, const PG_Rect & src, const PG_Rect & dst )
61 {
62 }
63 ;
64 
65 
Player & getCurrentPlayer()
Definition: gamemap.h:268
void display(SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
virtual ASCString getDescription() const =0
vector< MapCoordinate > getCoordinates() const
A Command is an action that the player initiates.
Definition: command.h:114
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
#define fieldsizey
Definition: typen.h:441
The class describing properties that are common to all vehicles of a certain kind.
Definition: vehicletype.h:177
const Command & act
Definition: actionwidget.h:39
ItemRepositoryLoader< VehicleType > vehicleTypeRepository("vehicletype")
int getUnitTypeID() const
Definition: unitcommand.cpp:84
ASCString getName() const
virtual vector< MapCoordinate > getCoordinates() const
this is for informational purposes, so the player can see where a Command has taken place when review...
Definition: command.cpp:77
ActionWidget(PG_Widget *parent, const PG_Point &pos, int width, const Command &action, GameMap *map)
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182