Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

playerselector.cpp

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  *                                                                         *
00009  ***************************************************************************/
00010 
00011 #include "playerselector.h"
00012 
00013 
00014 PlayerSelector :: PlayerSelector (PG_Widget *parent, const PG_Rect &r, GameMap* map, bool multiselect, int suppress ) : MultiListBox( parent, r), gamemap ( map ), suppressPlayers(suppress)
00015 {
00016    setup();
00017 };
00018 
00019 void PlayerSelector :: setup()
00020 {
00021    for ( int i = 0; i < gamemap->getPlayerCount(); ++i )
00022       if ( gamemap->getPlayer(i).exist() && !(suppressPlayers & (1<<i)) )
00023          new Item( getListBox(), 15, gamemap->getPlayer(i).getName(), i );
00024 }
00025 
00026 
00027 int PlayerSelector :: getSelectedPlayers()
00028 {
00029    int result = 0;
00030    for ( int i = 0; i < getListBox()->GetWidgetCount(); ++i ) {
00031       Item* bi = dynamic_cast< Item* >( getListBox()->FindWidget(i) );
00032       if ( bi && bi->IsSelected() )
00033          result |= 1 << bi->getData();
00034     }
00035     return result;
00036 }
00037 
00038 void PlayerSelector :: setSelection( int s )
00039 {
00040    for ( int i = 0; i < getListBox()->GetWidgetCount(); ++i ) {
00041       Item* bi = dynamic_cast< Item* >( getListBox()->FindWidget(i) );
00042       if ( bi )
00043          bi->Select ( s & (1 << bi->getData()));
00044          // getListBox()->SelectItem( bi, s & (1 << bi->getData()));
00045     }
00046 }
00047 
00048 
00049 

Generated on Tue Jun 24 01:27:50 2008 for Advanced Strategic Command by  doxygen 1.4.2