00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "actionwidget.h"
00022 #include "../widgets/vehicletypeimage.h"
00023
00024 #include "../gamemap.h"
00025 #include "../actions/unitcommand.h"
00026 #include "../itemrepository.h"
00027
00028
00029 ActionWidget::ActionWidget( PG_Widget* parent, const PG_Point& pos, int width, const Command& action, GameMap* map )
00030 : SelectionWidget( parent, PG_Rect( pos.x, pos.y, width, fieldsizey )), act( action )
00031 {
00032
00033 int offset = 0;
00034
00035 const UnitCommand* uc = dynamic_cast<const UnitCommand*>(&action);
00036 if ( uc != NULL && uc->getUnitTypeID() > 0 ) {
00037 VehicleType* vt = vehicleTypeRepository.getObject_byID( uc->getUnitTypeID() );
00038 if ( vt ) {
00039 PG_Widget* w = new VehicleTypeImage( this, PG_Point( 25, 0), vt, map->getCurrentPlayer() );
00040 offset += w->Width() + 5;
00041 }
00042 }
00043 PG_Label* lbl1 = new PG_Label( this, PG_Rect( 25 + offset, 0, Width()-30, Height() ), action.getDescription() );
00044 lbl1->SetFontSize( lbl1->GetFontSize() -2 );
00045
00046 SetTransparency( 255 );
00047 };
00048
00049 ASCString ActionWidget::getName() const
00050 {
00051 return act.getDescription();
00052 };
00053
00054 vector<MapCoordinate> ActionWidget::getCoordinates() const
00055 {
00056 return act.getCoordinates();
00057 }
00058
00059
00060 void ActionWidget::display( SDL_Surface * surface, const PG_Rect & src, const PG_Rect & dst )
00061 {
00062 }
00063 ;
00064
00065