unitinfodialog.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 <pgimage.h>
00012 #include <pgeventsupplier.h>
00013 #include "../paradialog.h"
00014 #include "../typen.h"
00015 #include "../vehicletype.h"
00016 #include "../vehicle.h"
00017 #include "../iconrepository.h"
00018 #include "../spfst.h"
00019 #include "../spfst-legacy.h"
00020 #include "../dialog.h"
00021 
00022 #include "../textfiletags.h"
00023 #include "../windowing.h"
00024 
00025 void assignWeaponInfo ( Panel* panel, PG_Widget* widget, const SingleWeapon& weapon )
00026 {
00027    int scalarType = weapon.service() ? cwservicen : weapon.getScalarWeaponType();
00028    panel->setImage( "weapon_symbol1", IconRepository::getIcon(SingleWeapon::getIconFileName( scalarType ) + "-small.png"), widget );
00029 
00030    panel->setLabelText( "weapon_text1", weapon.getName(), widget );
00031    panel->setLabelText( "weapon_reactionfire", weapon.reactionFireShots, widget );
00032    panel->setLabelText( "weapon_maxammo", weapon.count, widget );
00033    panel->setLabelText( "weapon_canshoot", weapon.shootable()? "yes" : "no", widget );
00034    panel->setLabelText( "weapon_canrefuel", weapon.canRefuel()? "yes" : "no", widget );
00035    panel->setLabelText( "weapon_strenghtmax", weapon.maxstrength, widget );
00036    panel->setLabelText( "weapon_strenghtmin", weapon.minstrength, widget );
00037    panel->setLabelText( "weapon_distancemin", (weapon.mindistance+9)/10, widget );
00038    panel->setLabelText( "weapon_distancemax", weapon.maxdistance/10, widget );
00039 
00040    for ( int i = 0; i < 8; ++i ) {
00041       if ( weapon.targ & (1<< i)) {
00042          panel->setWidgetTransparency( ASCString("weapon_notarget_") + heightTags[i] , 255 );
00043          panel->setWidgetTransparency( ASCString("weapon_target_") + heightTags[i] , 0 );
00044       } else {
00045          panel->setWidgetTransparency( ASCString("weapon_notarget_") + heightTags[i] , 0 );
00046          panel->setWidgetTransparency( ASCString("weapon_target_") + heightTags[i] , 255 );
00047       }
00048 
00049       if ( weapon.sourceheight & (1<< i)) {
00050          panel->setWidgetTransparency( ASCString("weapon_nosource_") + heightTags[i] , 255 );
00051          panel->setWidgetTransparency( ASCString("weapon_source_") + heightTags[i] , 0 );
00052       } else {
00053          panel->setWidgetTransparency( ASCString("weapon_nosource_") + heightTags[i] , 0 );
00054          panel->setWidgetTransparency( ASCString("weapon_source_") + heightTags[i] , 255 );
00055       }
00056    }
00057 }
00058 
00059 const int paneNum = 5;
00060 static const char* paneName[paneNum]  = { "information", "movement", "weapons", "transport", "description" };
00061 
00062 class UnitInfoDialog : public Panel {
00063         const Vehicle* veh;
00064         const VehicleType* vt;
00065         PG_Widget* weaponGraph;
00066         int currentWeapon;
00067         typedef vector< pair<int,int> > EntranceHeights;
00068         EntranceHeights entranceHeights;
00069         Surface infoImage;
00070 
00071         bool eventKeyDown(const SDL_KeyboardEvent* key)
00072         {
00073            if ( key->keysym.sym == SDLK_ESCAPE ) {
00074               QuitModal();
00075               return true;
00076            }
00077            return false;
00078         };
00079 
00080 
00081 
00082          void registerSpecialDisplay( const ASCString& name )
00083          {
00084             SpecialDisplayWidget* sdw = dynamic_cast<SpecialDisplayWidget*>( FindChild( name, true ) );
00085             if ( sdw )
00086                sdw->display.connect( SigC::slot( *this, &UnitInfoDialog::painter ));
00087          };
00088 
00089          void registerSpecialInput( const ASCString& name )
00090          {
00091             SpecialInputWidget* siw = dynamic_cast<SpecialInputWidget*>( FindChild( name, true ) );
00092             if ( siw ) {
00093                siw->sigMouseButtonDown.connect( SigC::slot( *this, &UnitInfoDialog::onClick ));
00094                siw->sigMouseButtonUp.connect( SigC::slot( *this, &UnitInfoDialog::onRelease ));
00095             }
00096          };
00097 
00098          bool onClick ( PG_MessageObject* obj, const SDL_MouseButtonEvent* event ) {
00099             PG_Widget* w = dynamic_cast<PG_Widget*>(obj);
00100             if ( w ) {
00101                click( w->GetName() );
00102                return true;
00103             } 
00104             return false;
00105          };
00106 
00107          bool onRelease ( PG_MessageObject* obj, const SDL_MouseButtonEvent* event ) {
00108             PG_Widget* w = dynamic_cast<PG_Widget*>(obj);
00109             if ( w ) {
00110                release( w->GetName() );
00111                return true;
00112             } 
00113             return false;
00114          };
00115          
00116          
00117          bool onEntranceClick ( PG_MessageObject* obj, const SDL_MouseButtonEvent* event, int entranceNum ) {
00118             if ( vt ) {
00119                PG_Widget* swi = FindChild( "single_weapon_info", true );
00120                if ( swi ) {
00121                   ContainerBaseType::TransportationIO tio = vt->entranceSystems[entranceNum];
00122                   setWidgetTransparency( "pad_transport_in",      tio.mode & ContainerBaseType::TransportationIO::In      ? 0 : 255 );
00123                   setWidgetTransparency( "pad_transport_out",     tio.mode & ContainerBaseType::TransportationIO::Out     ? 0 : 255 );
00124                   setWidgetTransparency( "pad_transport_docking", tio.mode & ContainerBaseType::TransportationIO::Docking ? 0 : 255 );
00125 
00126                   for ( int i = 0; i < cmovemalitypenum; ++i )
00127                      if ( (vt->vehicleCategoriesStorable & (1<<i)) && (tio.vehicleCategoriesLoadable & (1<<i)))
00128                         setImage( ASCString("unitpad_transport_") + unitCategoryTags[i], IconRepository::getIcon("pad_symbol_ok.png") );
00129                      else
00130                         setImage( ASCString("unitpad_transport_") + unitCategoryTags[i], IconRepository::getIcon("pad_symbol_no.png") );
00131 
00132                   ASCString s;
00133                   for ( int i = 0; i < ContainerBaseType::functionNum; ++i )
00134                      if ( tio.requiresUnitFeature.test( i )) {
00135                         if ( s.length() )
00136                            s += ", ";
00137                         s += ContainerBaseType::getFunctionName( ContainerBaseType::ContainerFunctions(i));
00138                      }
00139                   setLabelText( "unitpad_transport_specialfunctions", s );
00140 
00141                   setLabelText( "unitpad_transport_attackafterwards", tio.disableAttack ? "no" : "yes" );
00142 
00143                   entranceHeights.clear();
00144                   for ( int i = 0; i < 8; ++i )
00145                      if ( vt->height & (1 << i) & tio.container_height )
00146                         for ( int j = 0; j < 8; ++j )
00147                            if ( !tio.height_abs || tio.height_abs & (1 <<j ))
00148                               if ( tio.height_rel == -100 || getheightdelta( i, j ) == tio.height_rel  )
00149                                  entranceHeights.push_back( make_pair(i,j)); 
00150 
00151                   PG_Widget* w = FindChild( "unitpad_transport_leveldisplay", true );
00152                   if ( w )
00153                      w->Update();
00154                }
00155 
00156                for ( int i = 0; i < vt->entranceSystems.size(); ++i ) {
00157                   ASCString n = "pad_transport_square" + ASCString::toString(i);
00158                   PG_Widget* w = FindChild( n, true );
00159                   if ( w ) {
00160                      if ( i == entranceNum ) 
00161                         w->SetTransparency( 0 );
00162                         // w->SetVisible(true );
00163                      else
00164                         w->SetTransparency( 255 );
00165                         // w->SetVisible(false  );
00166                      // w->Update();
00167                   }
00168                }
00169                Update();
00170             }
00171             return true;
00172          };
00173 
00174          bool onWeaponClick ( PG_MessageObject* obj, const SDL_MouseButtonEvent* event, int weaponNum ) {
00175             if ( vt ) {
00176                PG_Widget* swi = FindChild( "single_weapon_info", true );
00177                if ( swi )
00178                   assignWeaponInfo( this, swi, vt->weapons.weapon[weaponNum] );
00179 
00180                for ( int i = 0; i < vt->weapons.count; ++i ) {
00181                   ASCString n = "pad_weaponbar" + ASCString::toString(i);
00182                   PG_Widget* w = FindChild( n, true );
00183                   if ( w ) {
00184                      if ( i == weaponNum )
00185                         w->SetTransparency( 0 );
00186                         // w->SetVisible(true );
00187                      else
00188                         // w->SetVisible(false );
00189                         w->SetTransparency( 255 );
00190                      // w->Update();
00191                   }
00192                }
00193                Update();
00194                currentWeapon = weaponNum;
00195                if ( weaponGraph )
00196                   weaponGraph->GetParent()->Update();
00197             }
00198             return true;
00199          };
00200 
00201          SPoint getWeaponGraphCoords( int maxdist, int maxstrength, int dist, int strength )
00202          {
00203             const int border  = 0;
00204             SPoint p;
00205             if( maxdist < 2 )
00206                maxdist = 2;
00207 
00208             p.x = (weaponGraph->Width() - 2 * border ) * dist / maxdist + border;
00209             p.y = weaponGraph->Height() - border - (weaponGraph->Height() - 2 * border ) * strength / maxstrength ;
00210             p.x += weaponGraph->my_xpos;
00211             p.y += weaponGraph->my_ypos;
00212             return p;
00213          }
00214 
00215          void painter ( const PG_Rect &src, const ASCString& name, const PG_Rect &dst)
00216          {
00217             Surface screen = Surface::Wrap( PG_Application::GetScreen() );
00218 
00219             if ( name == "unitpad_unitsymbol" ) 
00220                if ( vt ) {
00221                   if ( veh ) 
00222                      vt->paint( screen, SPoint( dst.x, dst.y ), veh->getMap()->getPlayer(veh).getPlayerColor() );
00223                   else
00224                      vt->paint( screen, SPoint( dst.x, dst.y ));
00225                }
00226 
00227             if ( name == "unitpad_weapon_diagram" ) {
00228                if ( vt && weaponGraph ) {
00229                   int maxdist  = 0;
00230                   int maxstrength = 0;
00231                   for ( int i = 0; i < vt->weapons.count; ++i )
00232                      if ( vt->weapons.weapon[i].shootable() ) {
00233                         maxdist = max ( maxdist, vt->weapons.weapon[i].maxdistance );
00234                         maxstrength = max ( maxstrength, vt->weapons.weapon[i].maxstrength );
00235                      }
00236 
00237                   setLabelText( "unitpad_weapon_diagram_maxdist", max(maxdist / maxmalq, 2 ) );
00238                   setLabelText( "unitpad_weapon_diagram_maxstrength", maxstrength );
00239 
00240                   if( maxdist > 0 && maxstrength > 0 )
00241                      for ( int i = 0; i < vt->weapons.count; ++i ) {
00242                         int mind = (vt->weapons.weapon[i].mindistance+maxmalq-1) / maxmalq;
00243                         int maxd = vt->weapons.weapon[i].maxdistance / maxmalq;
00244                         int linewidth;
00245                         int linecolor;
00246                         if ( currentWeapon == i ) {
00247                            linewidth = 2;
00248                            linecolor = 0xff7777;
00249                         } else {
00250                            linewidth = 1;
00251                            linecolor = 0xffffff;
00252                         }
00253 
00254                         if ( mind == maxd ) {
00255                            SPoint p = getWeaponGraphCoords( maxdist/maxmalq, maxstrength, mind, vt->weapons.weapon[i].maxstrength );
00256                            PG_Draw::DrawLine( PG_Application::GetScreen(), p.x , p.y - 2, p.x , p.y + 2, linecolor, linewidth );
00257                            PG_Draw::DrawLine( PG_Application::GetScreen(), p.x - 2, p.y , p.x + 2, p.y , linecolor, linewidth );
00258                         } else {
00259                            SPoint p = getWeaponGraphCoords( maxdist/maxmalq, maxstrength, mind, vt->weapons.weapon[i].maxstrength );
00260                            SPoint p2 = getWeaponGraphCoords( maxdist/maxmalq, maxstrength, maxd, vt->weapons.weapon[i].minstrength );
00261                            PG_Draw::DrawLine( PG_Application::GetScreen(), p.x , p.y , p2.x, p2.y , linecolor, linewidth );
00262                         }
00263                      }
00264                }
00265             }
00266             if ( name == "unitpad_transport_leveldisplay" ) {
00267                int xoffs = 0;
00268                for ( EntranceHeights::iterator i = entranceHeights.begin(); i != entranceHeights.end(); ++i ) {
00269                   for ( int j = 0; j < 2; ++j ) {
00270                      Surface& icon = IconRepository::getIcon( ASCString("height-a") + ASCString::toString( j==0 ? i->second : i->first) + ".png");
00271                      int y;
00272                      if ( j == 0)
00273                         y = 27;
00274                      else  
00275                         y = 2;
00276                      screen.Blit( icon, SPoint( dst.x + xoffs+2, dst.y+y ));
00277                   }
00278                   Surface& icon = IconRepository::getIcon("pad_transport_leveldisplay.png");
00279                   screen.Blit( icon, SPoint( dst.x + xoffs, dst.y ));
00280                   xoffs += icon.w() + 3;
00281                }
00282             }
00283          };
00284 
00285          void activate( const ASCString& pane ) {
00286             BulkGraphicUpdates bgu ( this );
00287 
00288             for ( int i = 0; i < paneNum; ++i )
00289                 if ( ASCString( paneName[i]) != pane )
00290                    hide( paneName[i] );
00291                    
00292             for ( int i = 0; i < paneNum; ++i )
00293                 if ( ASCString( paneName[i]) == pane )
00294                    show( paneName[i] );
00295          };
00296 
00297          void release( const ASCString& name ) {
00298             if ( name == "padclick_exit" ) {
00299                QuitModal();
00300             }
00301             
00302          }
00303          
00304          void click( const ASCString& name ) {
00305             for ( int i = 0; i < paneNum; ++i)
00306                if ( name == ASCString("padclick_") + paneName[i] ) 
00307                   activate(paneName[i]);
00308          };
00309 
00310      public:
00311         
00312         
00313         UnitInfoDialog (PG_Widget *parent, const Vehicle* vehicle, const VehicleType* vehicleType ) 
00314            : Panel( parent, PG_Rect::null, "UnitInfoDialog", false ), veh(vehicle), vt( vehicleType ), weaponGraph(NULL), currentWeapon(-1) {
00315                sigClose.connect( SigC::slot( *this, &UnitInfoDialog::QuitModal ));
00316 
00317                if( veh )
00318                   vt = veh->typ;
00319 
00320                try {
00321                   setup();
00322                }
00323                catch ( ParsingError err ) {
00324                   displaymessage( err.getMessage(), 1 );
00325                   return;
00326                }
00327                catch ( ... ) {
00328                   displaymessage( "unknown exception", 1 );
00329                   return;
00330                }
00331 
00332                if ( !vt->infoImageFilename.empty() && exist( vt->infoImageFilename )) {
00333                   PG_Image* img = dynamic_cast<PG_Image*>(FindChild( "unitpad_3dpic", true ));
00334                   if ( img ) {
00335                      tnfilestream stream ( vt->infoImageFilename, tnstream::reading );
00336                      infoImage.readImageFile( stream );
00337                      img->SetDrawMode( PG_Draw::STRETCH );
00338                      img->SetImage( infoImage.getBaseSurface(), false );
00339                      img->SizeWidget( img->GetParent()->w, img->GetParent()->h );
00340                   }
00341                }
00342 
00343                if ( veh )
00344                   setLabelText( "unitpad_unitname", veh->getName() );
00345                else
00346                   if ( vt )
00347                      setLabelText( "unitpad_unitname", vt->getName() );
00348 
00349                setLabelText( "unitpad_unitcategory", cmovemalitypes[ vt->movemalustyp ] );
00350                registerSpecialDisplay( "unitpad_unitsymbol");
00351                registerSpecialDisplay( "unitpad_weapon_diagram");
00352                registerSpecialDisplay( "unitpad_transport_transporterlevel");
00353                registerSpecialDisplay( "unitpad_transport_unitlevel");
00354                registerSpecialDisplay( "unitpad_transport_leveldisplay");
00355                
00356                weaponGraph = FindChild( "unitpad_weapon_diagram", true );
00357 
00358                if ( vt ) {
00359                   setLabelText( "unitpad_unitarmor", vt->armor );
00360                   setLabelText( "unitpad_unitweight", vt->weight );
00361                   setLabelText( "unitpad_unitview", vt->view );
00362                   setLabelText( "unitpad_unitjamming", vt->jamming );
00363                   setLabelText( "unitpad_unitcostenergy", vt->productionCost.energy );
00364                   setLabelText( "unitpad_unitcostmaterial", vt->productionCost.material );
00365                   setLabelText( "unitpad_unitcostfuel", vt->productionCost.fuel );
00366                   setLabelText( "unitpad_unittankfuel", vt->getStorageCapacity(0).fuel );
00367                   setLabelText( "unitpad_unittankenergy", vt->getStorageCapacity(0).energy );
00368                   setLabelText( "unitpad_unittankmaterial", vt->getStorageCapacity(0).material );
00369 
00370 
00371                   ASCString abilities = "#indent=0,15#";
00372                   for ( int i = 0; i < ContainerBaseType::functionNum; ++i )
00373                      if ( vt->hasFunction(ContainerBaseType::ContainerFunctions(i)))
00374                         abilities += ContainerBaseType::getFunctionName(ContainerBaseType::ContainerFunctions(i)) + ASCString("\n");
00375                   if ( vt->wait )
00376                      abilities += "Wait for attack\n"; 
00377                   setLabelText( "unitpad_unitabilities", abilities );
00378 
00379 
00380                   setLabelText( "unitpad_unitmove_unitfuelconsumption", vt->fuelConsumption );
00381                   for ( int i = 0; i< 8; ++i )
00382                      setLabelText( ASCString("unitpad_unitmove_") + heightTags[i], vt->movement[i] );
00383 
00384                   if ( vt->maxwindspeedonwater < 255 && vt->maxwindspeedonwater > 0 )
00385                      setLabelText( "unitpad_unitmove_windresistance", vt->maxwindspeedonwater );
00386                   else
00387                      setLabelText( "unitpad_unitmove_windresistance", "-" );
00388 
00389                   if ( vt->maxLoadableUnits ) {
00390                      setLabelText( "unitpad_transport_maxtotalweight", vt->maxLoadableWeight );
00391                      setLabelText( "unitpad_transport_maxsingleweight", vt->maxLoadableUnitSize );
00392                      setLabelText( "unitpad_transport_loadableunits", vt->maxLoadableUnits );
00393                   }
00394                   if ( vt->weapons.count >= 1 )
00395                      onWeaponClick( NULL, NULL, 0 );
00396                }
00397 
00398 
00399                for ( int i = 0; i < paneNum; ++i )
00400                   registerSpecialInput( ASCString("padclick_") + paneName[i] );
00401                registerSpecialInput( "padclick_exit" );
00402 
00403                setLabelText( "unitpad_description_text", vt->infotext );
00404                
00405               activate(paneName[0]);
00406               Show();
00407                
00408            };
00409 
00410       void userHandler( const ASCString& label, PropertyReadingContainer& pc, PG_Widget* parent, WidgetParameters widgetParams ) 
00411       {
00412          if ( label == "unitpad_heightchange" && vt ) {
00413             int yoffset = 0;
00414             for ( int i = 0; i < vt->heightChangeMethodNum; ++i ) {
00415                int srcLevelCount = 0;
00416                for ( int j = 0; j < 8; ++j )
00417                   if ( vt->height & vt->heightChangeMethod[i].startHeight & (1 << j)) 
00418                      ++srcLevelCount;
00419 
00420                pc.openBracket( "LineWidget" );
00421                PG_Rect r = parseRect( pc, parent);
00422                r.y += yoffset;
00423                r.my_height *= (srcLevelCount-1) / 3 + 1;
00424                widgetParams.runTextIO( pc );
00425 
00426                SpecialInputWidget* sw = new SpecialInputWidget ( parent, r );
00427                parsePanelASCTXT( pc, sw, widgetParams );
00428                pc.closeBracket();
00429                yoffset += sw->Height();
00430 
00431 
00432 
00433                int counter = 0;
00434                for ( int j = 0; j < 8; ++j )
00435                   if ( vt->height & vt->heightChangeMethod[i].startHeight & (1 << j))  {
00436                      ASCString filename = "height-a" + ASCString::toString(j) + ".png";
00437                      int xoffs = 3 + IconRepository::getIcon(filename).w() * (counter % 3 );
00438                      int yoffs = 2 + IconRepository::getIcon(filename).h() * (counter / 3 );
00439                      new PG_Image( sw, PG_Point( xoffs, yoffs ), IconRepository::getIcon(filename).getBaseSurface(), false );
00440                      ++counter;
00441                   }
00442 
00443                ASCString delta = ASCString::toString( vt->heightChangeMethod[i].heightDelta );
00444                if ( vt->heightChangeMethod[i].heightDelta > 0 )
00445                   delta = "+" + delta;
00446                setLabelText( "unitpad_move_changeheight_change", delta, sw );
00447                
00448                setLabelText( "unitpad_move_changeheight_movepoints", vt->heightChangeMethod[i].moveCost, sw );
00449                setLabelText( "unitpad_move_changeheight_distance", vt->heightChangeMethod[i].dist, sw );
00450             }
00451          }
00452          if ( label == "unitpad_terrainaccess" && vt ) {
00453             int yoffset = 0;
00454             for ( int i = 0; i < terrainPropertyNum ; ++i ) {
00455                if ( vt->terrainaccess.terrain.test(i) || vt->terrainaccess.terrainkill.test(i) || vt->terrainaccess.terrainnot.test(i) || vt->terrainaccess.terrainreq.test(i) ) {
00456                   pc.openBracket( "LineWidget" );
00457                   widgetParams.runTextIO( pc );
00458                   PG_Rect r = parseRect( pc, parent);
00459                   r.y += yoffset;
00460 
00461                   
00462                   SpecialInputWidget* sw = new SpecialInputWidget ( parent, r );
00463                   parsePanelASCTXT( pc, sw, widgetParams );
00464                   pc.closeBracket();
00465                   yoffset += sw->Height();
00466 
00467                   setLabelText( "unitpad_unitmove_terraintype", terrainProperty[i], sw);
00468 
00469                   PG_Widget* w = sw->FindChild("unitpad_unitmove_terrainaccess", true);
00470                   if ( w ) {
00471                      int xoffs = 0;
00472                      static const char* iconName[] = {"pad_symbol_ok.png", "pad_symbol_warn.png", "pad_symbol_no.png", "pad_symbol_kill.png" };  
00473                      const TerrainBits* bits[] = { &vt->terrainaccess.terrain, &vt->terrainaccess.terrainreq, &vt->terrainaccess.terrainnot, &vt->terrainaccess.terrainkill };
00474                      for ( int icon = 0; icon < 4; ++icon ) {
00475                         bool set = bits[icon]->test(i);
00476 
00477                         if ( set ) {
00478                            PG_Image* img = new PG_Image( w, PG_Point( xoffs, 0 ), IconRepository::getIcon( iconName[icon] ).getBaseSurface(), false );
00479                            xoffs += img->Width();
00480                         }
00481                      }
00482                   }
00483                }
00484             }
00485          }
00486          if ( label == "unitpad_weaponlist" && vt ) {
00487             int yoffset = 0;
00488             for ( int i = 0; i < vt->weapons.count ; ++i ) {
00489                pc.openBracket( "LineWidget" );
00490                widgetParams.runTextIO( pc );
00491                PG_Rect r = parseRect( pc, parent);
00492                r.y += yoffset;
00493 
00494                
00495                SpecialInputWidget* sw = new SpecialInputWidget ( parent, r );
00496                parsePanelASCTXT( pc, sw, widgetParams );
00497                rename( "pad_weaponbar", "pad_weaponbar" + ASCString::toString( i ));
00498                pc.closeBracket();
00499                yoffset += sw->Height();
00500 
00501                assignWeaponInfo( this, sw, vt->weapons.weapon[i] );
00502                sw->sigMouseButtonDown.connect( SigC::bind( SigC::slot( *this, &UnitInfoDialog::onWeaponClick ), i));
00503             }
00504          }
00505          if ( label == "entrancesystems" && vt ) {
00506             int xoffset = 0;
00507             for ( int i = 0; i < vt->entranceSystems.size() ; ++i ) {
00508                pc.openBracket( "LineWidget" );
00509                widgetParams.runTextIO( pc );
00510                PG_Rect r = parseRect( pc, parent);
00511                r.x += xoffset;
00512 
00513                SpecialInputWidget* sw = new SpecialInputWidget ( parent, r );
00514                parsePanelASCTXT( pc, sw, widgetParams );
00515                rename( "pad_transport_square", "pad_transport_square" + ASCString::toString( i ));
00516                pc.closeBracket();
00517 
00518                setLabelText( "unitpad_transport_entrancenumber", i+1, sw );
00519 
00520                xoffset += sw->Width();
00521 
00522                // assignWeaponInfo( this, sw, vt->weapons.weapon[i] );
00523                sw->sigMouseButtonDown.connect( SigC::bind( SigC::slot( *this, &UnitInfoDialog::onEntranceClick ), i));
00524             }
00525          }
00526       }; 
00527         
00528 };
00529 
00530 void unitInfoDialog( const VehicleType* vt )
00531 {
00532    if ( vt ) {
00533       UnitInfoDialog uid ( NULL, NULL, vt );
00534       uid.Show();
00535       uid.RunModal();
00536    } else {
00537       MapField* fld = actmap->getField( actmap->getCursor() );
00538       if ( fld && fld->vehicle ) {
00539          UnitInfoDialog uid ( NULL, fld->vehicle, NULL );
00540          uid.Show();
00541          uid.RunModal();
00542       } else
00543          displaymessage2("please select a unit" );
00544   }
00545 }
00546 

Generated on Mon May 21 01:26:39 2012 for Advanced Strategic Command by  doxygen 1.5.1