actionwidget.cpp

Go to the documentation of this file.
00001 /*
00002      This file is part of Advanced Strategic Command; http://www.asc-hq.org
00003      Copyright (C) 1994-2010  Martin Bickel
00004 
00005      This program is free software; you can redistribute it and/or modify
00006      it under the terms of the GNU General Public License as published by
00007      the Free Software Foundation; either version 2 of the License, or
00008      (at your option) any later version.
00009 
00010      This program is distributed in the hope that it will be useful,
00011      but WITHOUT ANY WARRANTY; without even the implied warranty of
00012      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013      GNU General Public License for more details.
00014 
00015      You should have received a copy of the GNU General Public License
00016      along with this program; see the file COPYING. If not, write to the
00017      Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00018      Boston, MA  02111-1307  USA
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 

Generated on Mon May 14 01:31:39 2012 for Advanced Strategic Command by  doxygen 1.5.1