Advanced Strategic Command
unitinfodialog.cpp
Go to the documentation of this file.
1 
2 /***************************************************************************
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  ***************************************************************************/
10 
11 #include <pgimage.h>
12 #include <pgeventsupplier.h>
13 #include "../paradialog.h"
14 #include "../typen.h"
15 #include "../vehicletype.h"
16 #include "../vehicle.h"
17 #include "../iconrepository.h"
18 #include "../spfst.h"
19 #include "../spfst-legacy.h"
20 #include "../dialog.h"
21 
22 #include "../textfiletags.h"
23 #include "../windowing.h"
24 
25 void assignWeaponInfo ( Panel* panel, PG_Widget* widget, const SingleWeapon& weapon )
26 {
27  int scalarType = weapon.service() ? cwservicen : weapon.getScalarWeaponType();
28  panel->setImage( "weapon_symbol1", IconRepository::getIcon(SingleWeapon::getIconFileName( scalarType ) + "-small.png"), widget );
29 
30  panel->setLabelText( "weapon_text1", weapon.getName(), widget );
31  panel->setLabelText( "weapon_reactionfire", weapon.reactionFireShots, widget );
32  panel->setLabelText( "weapon_maxammo", weapon.count, widget );
33  panel->setLabelText( "weapon_canshoot", weapon.shootable()? "yes" : "no", widget );
34  panel->setLabelText( "weapon_canrefuel", weapon.canRefuel()? "yes" : "no", widget );
35  panel->setLabelText( "weapon_strenghtmax", weapon.maxstrength, widget );
36  panel->setLabelText( "weapon_strenghtmin", weapon.minstrength, widget );
37  panel->setLabelText( "weapon_distancemin", (weapon.mindistance+9)/10, widget );
38  panel->setLabelText( "weapon_distancemax", weapon.maxdistance/10, widget );
39 
40  for ( int i = 0; i < 8; ++i ) {
41  if ( weapon.targ & (1<< i)) {
42  panel->setWidgetTransparency( ASCString("weapon_notarget_") + heightTags[i] , 255 );
43  panel->setWidgetTransparency( ASCString("weapon_target_") + heightTags[i] , 0 );
44  } else {
45  panel->setWidgetTransparency( ASCString("weapon_notarget_") + heightTags[i] , 0 );
46  panel->setWidgetTransparency( ASCString("weapon_target_") + heightTags[i] , 255 );
47  }
48 
49  if ( weapon.sourceheight & (1<< i)) {
50  panel->setWidgetTransparency( ASCString("weapon_nosource_") + heightTags[i] , 255 );
51  panel->setWidgetTransparency( ASCString("weapon_source_") + heightTags[i] , 0 );
52  } else {
53  panel->setWidgetTransparency( ASCString("weapon_nosource_") + heightTags[i] , 0 );
54  panel->setWidgetTransparency( ASCString("weapon_source_") + heightTags[i] , 255 );
55  }
56  }
57 }
58 
59 const int paneNum = 5;
60 static const char* paneName[paneNum] = { "information", "movement", "weapons", "transport", "description" };
61 
62 class UnitInfoDialog : public Panel {
63  const Vehicle* veh;
64  const VehicleType* vt;
65  PG_Widget* weaponGraph;
66  int currentWeapon;
67  typedef vector< pair<int,int> > EntranceHeights;
68  EntranceHeights entranceHeights;
69  Surface infoImage;
70 
71  bool eventKeyDown(const SDL_KeyboardEvent* key)
72  {
73  if ( key->keysym.sym == SDLK_ESCAPE ) {
74  QuitModal();
75  return true;
76  }
77  return false;
78  };
79 
80 
81 
82  void registerSpecialDisplay( const ASCString& name )
83  {
84  SpecialDisplayWidget* sdw = dynamic_cast<SpecialDisplayWidget*>( FindChild( name, true ) );
85  if ( sdw )
86  sdw->display.connect( sigc::mem_fun( *this, &UnitInfoDialog::painter ));
87  };
88 
89  void registerSpecialInput( const ASCString& name )
90  {
91  SpecialInputWidget* siw = dynamic_cast<SpecialInputWidget*>( FindChild( name, true ) );
92  if ( siw ) {
93  siw->sigMouseButtonDown.connect( sigc::mem_fun( *this, &UnitInfoDialog::onClick ));
94  siw->sigMouseButtonUp.connect( sigc::mem_fun( *this, &UnitInfoDialog::onRelease ));
95  }
96  };
97 
98  bool onClick ( PG_MessageObject* obj, const SDL_MouseButtonEvent* event ) {
99  PG_Widget* w = dynamic_cast<PG_Widget*>(obj);
100  if ( w ) {
101  click( w->GetName() );
102  return true;
103  }
104  return false;
105  };
106 
107  bool onRelease ( PG_MessageObject* obj, const SDL_MouseButtonEvent* event ) {
108  PG_Widget* w = dynamic_cast<PG_Widget*>(obj);
109  if ( w ) {
110  release( w->GetName() );
111  return true;
112  }
113  return false;
114  };
115 
116 
117  bool onEntranceClick ( PG_MessageObject* obj, const SDL_MouseButtonEvent* event, int entranceNum ) {
118  if ( vt ) {
119  PG_Widget* swi = FindChild( "single_weapon_info", true );
120  if ( swi ) {
122  setWidgetTransparency( "pad_transport_in", tio.mode & ContainerBaseType::TransportationIO::In ? 0 : 255 );
123  setWidgetTransparency( "pad_transport_out", tio.mode & ContainerBaseType::TransportationIO::Out ? 0 : 255 );
124  setWidgetTransparency( "pad_transport_docking", tio.mode & ContainerBaseType::TransportationIO::Docking ? 0 : 255 );
125 
126  for ( int i = 0; i < cmovemalitypenum; ++i )
127  if ( (vt->vehicleCategoriesStorable & (1<<i)) && (tio.vehicleCategoriesLoadable & (1<<i)))
128  setImage( ASCString("unitpad_transport_") + unitCategoryTags[i], IconRepository::getIcon("pad_symbol_ok.png") );
129  else
130  setImage( ASCString("unitpad_transport_") + unitCategoryTags[i], IconRepository::getIcon("pad_symbol_no.png") );
131 
132  ASCString s;
133  for ( int i = 0; i < ContainerBaseType::functionNum; ++i )
134  if ( tio.requiresUnitFeature.test( i )) {
135  if ( s.length() )
136  s += ", ";
138  }
139  setLabelText( "unitpad_transport_specialfunctions", s );
140 
141  setLabelText( "unitpad_transport_attackafterwards", tio.disableAttack ? "no" : "yes" );
142 
143  entranceHeights.clear();
144  for ( int i = 0; i < 8; ++i )
145  if ( vt->height & (1 << i) & tio.container_height )
146  for ( int j = 0; j < 8; ++j )
147  if ( !tio.height_abs || tio.height_abs & (1 <<j ))
148  if ( tio.height_rel == -100 || getheightdelta( i, j ) == tio.height_rel )
149  entranceHeights.push_back( make_pair(i,j));
150 
151  PG_Widget* w = FindChild( "unitpad_transport_leveldisplay", true );
152  if ( w )
153  w->Update();
154  }
155 
156  for ( int i = 0; i < vt->entranceSystems.size(); ++i ) {
157  ASCString n = "pad_transport_square" + ASCString::toString(i);
158  PG_Widget* w = FindChild( n, true );
159  if ( w ) {
160  if ( i == entranceNum )
161  w->SetTransparency( 0 );
162  // w->SetVisible(true );
163  else
164  w->SetTransparency( 255 );
165  // w->SetVisible(false );
166  // w->Update();
167  }
168  }
169  Update();
170  }
171  return true;
172  };
173 
174  bool onWeaponClick ( PG_MessageObject* obj, const SDL_MouseButtonEvent* event, int weaponNum ) {
175  if ( vt ) {
176  PG_Widget* swi = FindChild( "single_weapon_info", true );
177  if ( swi )
178  assignWeaponInfo( this, swi, vt->weapons.weapon[weaponNum] );
179 
180  for ( int i = 0; i < vt->weapons.count; ++i ) {
181  ASCString n = "pad_weaponbar" + ASCString::toString(i);
182  PG_Widget* w = FindChild( n, true );
183  if ( w ) {
184  if ( i == weaponNum )
185  w->SetTransparency( 0 );
186  // w->SetVisible(true );
187  else
188  // w->SetVisible(false );
189  w->SetTransparency( 255 );
190  // w->Update();
191  }
192  }
193  Update();
194  currentWeapon = weaponNum;
195  if ( weaponGraph )
196  weaponGraph->GetParent()->Update();
197  }
198  return true;
199  };
200 
201  SPoint getWeaponGraphCoords( int maxdist, int maxstrength, int dist, int strength )
202  {
203  const int border = 0;
204  SPoint p;
205  if( maxdist < 2 )
206  maxdist = 2;
207 
208  p.x = (weaponGraph->Width() - 2 * border ) * dist / maxdist + border;
209  p.y = weaponGraph->Height() - border - (weaponGraph->Height() - 2 * border ) * strength / maxstrength ;
210  p.x += weaponGraph->my_xpos;
211  p.y += weaponGraph->my_ypos;
212  return p;
213  }
214 
215  void painter ( const PG_Rect &src, const ASCString& name, const PG_Rect &dst)
216  {
217  Surface screen = Surface::Wrap( PG_Application::GetScreen() );
218 
219  if ( name == "unitpad_unitsymbol" )
220  if ( vt ) {
221  if ( veh )
222  vt->paint( screen, SPoint( dst.x, dst.y ), veh->getMap()->getPlayer(veh).getPlayerColor() );
223  else
224  vt->paint( screen, SPoint( dst.x, dst.y ));
225  }
226 
227  if ( name == "unitpad_weapon_diagram" ) {
228  if ( vt && weaponGraph ) {
229  int maxdist = 0;
230  int maxstrength = 0;
231  for ( int i = 0; i < vt->weapons.count; ++i )
232  if ( vt->weapons.weapon[i].shootable() ) {
233  maxdist = max ( maxdist, vt->weapons.weapon[i].maxdistance );
234  maxstrength = max ( maxstrength, vt->weapons.weapon[i].maxstrength );
235  }
236 
237  setLabelText( "unitpad_weapon_diagram_maxdist", max(maxdist / maxmalq, 2 ) );
238  setLabelText( "unitpad_weapon_diagram_maxstrength", maxstrength );
239 
240  if( maxdist > 0 && maxstrength > 0 )
241  for ( int i = 0; i < vt->weapons.count; ++i ) {
242  int mind = (vt->weapons.weapon[i].mindistance+maxmalq-1) / maxmalq;
243  int maxd = vt->weapons.weapon[i].maxdistance / maxmalq;
244  int linewidth;
245  int linecolor;
246  if ( currentWeapon == i ) {
247  linewidth = 2;
248  linecolor = 0xff7777;
249  } else {
250  linewidth = 1;
251  linecolor = 0xffffff;
252  }
253 
254  if ( mind == maxd ) {
255  SPoint p = getWeaponGraphCoords( maxdist/maxmalq, maxstrength, mind, vt->weapons.weapon[i].maxstrength );
256  PG_Draw::DrawLine( PG_Application::GetScreen(), p.x , p.y - 2, p.x , p.y + 2, linecolor, linewidth );
257  PG_Draw::DrawLine( PG_Application::GetScreen(), p.x - 2, p.y , p.x + 2, p.y , linecolor, linewidth );
258  } else {
259  SPoint p = getWeaponGraphCoords( maxdist/maxmalq, maxstrength, mind, vt->weapons.weapon[i].maxstrength );
260  SPoint p2 = getWeaponGraphCoords( maxdist/maxmalq, maxstrength, maxd, vt->weapons.weapon[i].minstrength );
261  PG_Draw::DrawLine( PG_Application::GetScreen(), p.x , p.y , p2.x, p2.y , linecolor, linewidth );
262  }
263  }
264  }
265  }
266  if ( name == "unitpad_transport_leveldisplay" ) {
267  int xoffs = 0;
268  for ( EntranceHeights::iterator i = entranceHeights.begin(); i != entranceHeights.end(); ++i ) {
269  for ( int j = 0; j < 2; ++j ) {
270  Surface& icon = IconRepository::getIcon( ASCString("height-a") + ASCString::toString( j==0 ? i->second : i->first) + ".png");
271  int y;
272  if ( j == 0)
273  y = 27;
274  else
275  y = 2;
276  screen.Blit( icon, SPoint( dst.x + xoffs+2, dst.y+y ));
277  }
278  Surface& icon = IconRepository::getIcon("pad_transport_leveldisplay.png");
279  screen.Blit( icon, SPoint( dst.x + xoffs, dst.y ));
280  xoffs += icon.w() + 3;
281  }
282  }
283  };
284 
285  void activate( const ASCString& pane ) {
286  BulkGraphicUpdates bgu ( this );
287 
288  for ( int i = 0; i < paneNum; ++i )
289  if ( ASCString( paneName[i]) != pane )
290  hide( paneName[i] );
291 
292  for ( int i = 0; i < paneNum; ++i )
293  if ( ASCString( paneName[i]) == pane )
294  show( paneName[i] );
295  };
296 
297  void release( const ASCString& name ) {
298  if ( name == "padclick_exit" ) {
299  QuitModal();
300  }
301 
302  }
303 
304  void click( const ASCString& name ) {
305  for ( int i = 0; i < paneNum; ++i)
306  if ( name == ASCString("padclick_") + paneName[i] )
307  activate(paneName[i]);
308  };
309 
310  public:
311 
312 
313  UnitInfoDialog (PG_Widget *parent, const Vehicle* vehicle, const VehicleType* vehicleType )
314  : Panel( parent, PG_Rect::null, "UnitInfoDialog", false ), veh(vehicle), vt( vehicleType ), weaponGraph(NULL), currentWeapon(-1) {
315  sigClose.connect( sigc::mem_fun( *this, &UnitInfoDialog::QuitModal ));
316 
317  if( veh )
318  vt = veh->typ;
319 
320  try {
321  setup();
322  }
323  catch ( ParsingError err ) {
324  displaymessage( err.getMessage(), 1 );
325  return;
326  }
327  catch ( ... ) {
328  displaymessage( "unknown exception", 1 );
329  return;
330  }
331 
332  if ( !vt->infoImageFilename.empty() && exist( vt->infoImageFilename )) {
333  PG_Image* img = dynamic_cast<PG_Image*>(FindChild( "unitpad_3dpic", true ));
334  if ( img ) {
336  infoImage.readImageFile( stream );
337  img->SetDrawMode( PG_Draw::STRETCH );
338  img->SetImage( infoImage.getBaseSurface(), false );
339  img->SizeWidget( img->GetParent()->w, img->GetParent()->h );
340  }
341  }
342 
343  if ( veh )
344  setLabelText( "unitpad_unitname", veh->getName() );
345  else
346  if ( vt )
347  setLabelText( "unitpad_unitname", vt->getName() );
348 
349  setLabelText( "unitpad_unitcategory", cmovemalitypes[ vt->movemalustyp ] );
350  registerSpecialDisplay( "unitpad_unitsymbol");
351  registerSpecialDisplay( "unitpad_weapon_diagram");
352  registerSpecialDisplay( "unitpad_transport_transporterlevel");
353  registerSpecialDisplay( "unitpad_transport_unitlevel");
354  registerSpecialDisplay( "unitpad_transport_leveldisplay");
355 
356  weaponGraph = FindChild( "unitpad_weapon_diagram", true );
357 
358  if ( vt ) {
359  setLabelText( "unitpad_unitarmor", vt->armor );
360  setLabelText( "unitpad_unitweight", vt->weight );
361  setLabelText( "unitpad_unitview", vt->view );
362  setLabelText( "unitpad_unitjamming", vt->jamming );
363  setLabelText( "unitpad_unitcostenergy", vt->productionCost.energy );
364  setLabelText( "unitpad_unitcostmaterial", vt->productionCost.material );
365  setLabelText( "unitpad_unitcostfuel", vt->productionCost.fuel );
366  setLabelText( "unitpad_unittankfuel", vt->getStorageCapacity(0).fuel );
367  setLabelText( "unitpad_unittankenergy", vt->getStorageCapacity(0).energy );
368  setLabelText( "unitpad_unittankmaterial", vt->getStorageCapacity(0).material );
369 
370 
371  ASCString abilities = "#indent=0,15#";
372  for ( int i = 0; i < ContainerBaseType::functionNum; ++i )
375  if ( vt->wait )
376  abilities += "Wait for attack\n";
377  setLabelText( "unitpad_unitabilities", abilities );
378 
379 
380  setLabelText( "unitpad_unitmove_unitfuelconsumption", vt->fuelConsumption );
381  for ( int i = 0; i< 8; ++i )
382  setLabelText( ASCString("unitpad_unitmove_") + heightTags[i], vt->movement[i] );
383 
384  if ( vt->maxwindspeedonwater < 255 && vt->maxwindspeedonwater > 0 )
385  setLabelText( "unitpad_unitmove_windresistance", vt->maxwindspeedonwater );
386  else
387  setLabelText( "unitpad_unitmove_windresistance", "-" );
388 
389  if ( vt->maxLoadableUnits ) {
390  setLabelText( "unitpad_transport_maxtotalweight", vt->maxLoadableWeight );
391  setLabelText( "unitpad_transport_maxsingleweight", vt->maxLoadableUnitSize );
392  setLabelText( "unitpad_transport_loadableunits", vt->maxLoadableUnits );
393  }
394  if ( vt->weapons.count >= 1 )
395  onWeaponClick( NULL, NULL, 0 );
396  }
397 
398 
399  for ( int i = 0; i < paneNum; ++i )
400  registerSpecialInput( ASCString("padclick_") + paneName[i] );
401  registerSpecialInput( "padclick_exit" );
402 
403  setLabelText( "unitpad_description_text", vt->infotext );
404 
405  activate(paneName[0]);
406  Show();
407 
408  };
409 
410  void userHandler( const ASCString& label, PropertyReadingContainer& pc, PG_Widget* parent, WidgetParameters widgetParams )
411  {
412  if ( label == "unitpad_heightchange" && vt ) {
413  int yoffset = 0;
414  for ( int i = 0; i < vt->heightChangeMethodNum; ++i ) {
415  int srcLevelCount = 0;
416  for ( int j = 0; j < 8; ++j )
417  if ( vt->height & vt->heightChangeMethod[i].startHeight & (1 << j))
418  ++srcLevelCount;
419 
420  pc.openBracket( "LineWidget" );
421  PG_Rect r = parseRect( pc, parent);
422  r.y += yoffset;
423  r.my_height *= (srcLevelCount-1) / 3 + 1;
424  widgetParams.runTextIO( pc );
425 
426  SpecialInputWidget* sw = new SpecialInputWidget ( parent, r );
427  parsePanelASCTXT( pc, sw, widgetParams );
428  pc.closeBracket();
429  yoffset += sw->Height();
430 
431 
432 
433  int counter = 0;
434  for ( int j = 0; j < 8; ++j )
435  if ( vt->height & vt->heightChangeMethod[i].startHeight & (1 << j)) {
436  ASCString filename = "height-a" + ASCString::toString(j) + ".png";
437  int xoffs = 3 + IconRepository::getIcon(filename).w() * (counter % 3 );
438  int yoffs = 2 + IconRepository::getIcon(filename).h() * (counter / 3 );
439  new PG_Image( sw, PG_Point( xoffs, yoffs ), IconRepository::getIcon(filename).getBaseSurface(), false );
440  ++counter;
441  }
442 
443  ASCString delta = ASCString::toString( vt->heightChangeMethod[i].heightDelta );
444  if ( vt->heightChangeMethod[i].heightDelta > 0 )
445  delta = "+" + delta;
446  setLabelText( "unitpad_move_changeheight_change", delta, sw );
447 
448  setLabelText( "unitpad_move_changeheight_movepoints", vt->heightChangeMethod[i].moveCost, sw );
449  setLabelText( "unitpad_move_changeheight_distance", vt->heightChangeMethod[i].dist, sw );
450  }
451  }
452  if ( label == "unitpad_terrainaccess" && vt ) {
453  int yoffset = 0;
454  for ( int i = 0; i < terrainPropertyNum ; ++i ) {
455  if ( vt->terrainaccess.terrain.test(i) || vt->terrainaccess.terrainkill.test(i) || vt->terrainaccess.terrainnot.test(i) || vt->terrainaccess.terrainreq.test(i) ) {
456  pc.openBracket( "LineWidget" );
457  widgetParams.runTextIO( pc );
458  PG_Rect r = parseRect( pc, parent);
459  r.y += yoffset;
460 
461 
462  SpecialInputWidget* sw = new SpecialInputWidget ( parent, r );
463  parsePanelASCTXT( pc, sw, widgetParams );
464  pc.closeBracket();
465  yoffset += sw->Height();
466 
467  setLabelText( "unitpad_unitmove_terraintype", terrainProperty[i], sw);
468 
469  PG_Widget* w = sw->FindChild("unitpad_unitmove_terrainaccess", true);
470  if ( w ) {
471  int xoffs = 0;
472  static const char* iconName[] = {"pad_symbol_ok.png", "pad_symbol_warn.png", "pad_symbol_no.png", "pad_symbol_kill.png" };
474  for ( int icon = 0; icon < 4; ++icon ) {
475  bool set = bits[icon]->test(i);
476 
477  if ( set ) {
478  PG_Image* img = new PG_Image( w, PG_Point( xoffs, 0 ), IconRepository::getIcon( iconName[icon] ).getBaseSurface(), false );
479  xoffs += img->Width();
480  }
481  }
482  }
483  }
484  }
485  }
486  if ( label == "unitpad_weaponlist" && vt ) {
487  int yoffset = 0;
488  for ( int i = 0; i < vt->weapons.count ; ++i ) {
489  pc.openBracket( "LineWidget" );
490  widgetParams.runTextIO( pc );
491  PG_Rect r = parseRect( pc, parent);
492  r.y += yoffset;
493 
494 
495  SpecialInputWidget* sw = new SpecialInputWidget ( parent, r );
496  parsePanelASCTXT( pc, sw, widgetParams );
497  rename( "pad_weaponbar", "pad_weaponbar" + ASCString::toString( i ));
498  pc.closeBracket();
499  yoffset += sw->Height();
500 
501  assignWeaponInfo( this, sw, vt->weapons.weapon[i] );
502  sw->sigMouseButtonDown.connect( sigc::bind( sigc::mem_fun( *this, &UnitInfoDialog::onWeaponClick ), i));
503  }
504  }
505  if ( label == "entrancesystems" && vt ) {
506  int xoffset = 0;
507  for ( int i = 0; i < vt->entranceSystems.size() ; ++i ) {
508  pc.openBracket( "LineWidget" );
509  widgetParams.runTextIO( pc );
510  PG_Rect r = parseRect( pc, parent);
511  r.x += xoffset;
512 
513  SpecialInputWidget* sw = new SpecialInputWidget ( parent, r );
514  parsePanelASCTXT( pc, sw, widgetParams );
515  rename( "pad_transport_square", "pad_transport_square" + ASCString::toString( i ));
516  pc.closeBracket();
517 
518  setLabelText( "unitpad_transport_entrancenumber", i+1, sw );
519 
520  xoffset += sw->Width();
521 
522  // assignWeaponInfo( this, sw, vt->weapons.weapon[i] );
523  sw->sigMouseButtonDown.connect( sigc::bind( sigc::mem_fun( *this, &UnitInfoDialog::onEntranceClick ), i));
524  }
525  }
526  };
527 
528 };
529 
530 void unitInfoDialog( const VehicleType* vt )
531 {
532  if ( vt ) {
533  UnitInfoDialog uid ( NULL, NULL, vt );
534  uid.Show();
535  uid.RunModal();
536  } else {
537  MapField* fld = actmap->getField( actmap->getCursor() );
538  if ( fld && fld->vehicle ) {
539  UnitInfoDialog uid ( NULL, fld->vehicle, NULL );
540  uid.Show();
541  uid.RunModal();
542  } else
543  displaymessage2("please select a unit" );
544  }
545 }
546 
int fuel
Definition: typen.h:101
static const char * getFunctionName(ContainerFunctions function)
bool wait
If the unit cannot attack in the same turn after it has moved, it has to wait.
Definition: vehicletype.h:197
Player & getPlayer(PlayerID p)
Definition: gamemap.h:257
MapCoordinate & getCursor()
Definition: gamemap.cpp:933
int maxLoadableUnits
the maximum number of units that can be loaded
ASCString getName(void) const
bool service(void) const
DisplayHook display
Definition: paradialog.h:182
Vehicle * vehicle
Definition: mapfield.h:89
int energy
Definition: typen.h:99
#define cwservicen
Definition: vehicletype.h:88
int getheightdelta(const ContainerBase *c1, const ContainerBase *c2)
calculate the height difference between two levels of height.
Definition: spfst.cpp:393
UnitWeapon weapons
The weapons.
Definition: vehicletype.h:248
int sourceheight
the weapon can be shot from these levels of height (bitmapped)
Definition: vehicletype.h:108
bool shootable(void) const
int targ
the weapon can attack targets at these levels of height (bitmapped)
Definition: vehicletype.h:105
bool hasFunction(ContainerFunctions function) const
bool canRefuel(void) const
const char * cmovemalitypes[cmovemalitypenum]
the names of the different MoveMalusTypes
Definition: typen.cpp:43
PlayerColor getPlayerColor() const
Definition: player.cpp:268
void setImage(const ASCString &widgetName, Surface &image, PG_Widget *parent=NULL)
Definition: windowing.cpp:739
int count
amount of ammunition the unit having this weapon can carry
Definition: vehicletype.h:117
static const int functionNum
SingleWeapon weapon[16]
Definition: vehicletype.h:170
ASCString getName() const
a single field of the map
Definition: mapfield.h:26
SDL_Surface * getBaseSurface()
Definition: surface.h:116
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
void setWidgetTransparency(const ASCString &widgetName, int transparency, PG_Widget *parent=NULL)
Definition: windowing.cpp:757
const int terrainPropertyNum
the number of bits that specify the terrain of a field
Definition: terraintype.h:28
int vehicleCategoriesStorable
bitmapped: vehicle categories that can be stored the container
vector< int > movement
the distance a unit can travel each round. One value for each of the 8 levels of height ...
Definition: vehicletype.h:203
int view
the visibility range
int maxLoadableUnitSize
the maximum size of a unit that may enter the building
int getScalarWeaponType(void) const
void parsePanelASCTXT(PropertyReadingContainer &pc, PG_Widget *parent, WidgetParameters widgetParams)
Definition: windowing.cpp:370
The class describing properties that are common to all vehicles of a certain kind.
Definition: vehicletype.h:177
static ASCString toString(int i)
converts the parameter to a String
Definition: ascstring.cpp:193
#define maxmalq
Constants that specify the layout of ASC.
Definition: typen.h:429
const int paneNum
int mindistance
the minimal distance the weapon can shoot
Definition: vehicletype.h:114
the properties of a terrain describing which units can move onto this field and which can't ...
Definition: terraintype.h:32
int height_rel
a height of a loadable unit have this height relative to the container; -100 if not used ...
int minstrength
strength of the weapon when fired over the maximum distance
Definition: vehicletype.h:123
TerrainBits terrainreq
ALL these bits must be set in the terrain.
Definition: terraintype.h:50
int reactionFireShots
Definition: vehicletype.h:145
int movemalustyp
The category of the unit. Original used only to distinguish only between different movement costs for...
Definition: vehicletype.h:206
const int cmovemalitypenum
The number of vehicle categories; Each category has its own move malus.
Definition: typen.h:384
ASCString getName() const
returns the units name or, if it does not exist, the unit type's name or description ...
Definition: vehicle.cpp:1569
int jamming
the radar jamming power
void displaymessage(const char *formatstring, int num,...)
displays a dialog box with a message
Definition: dlg_box.cpp:1849
TerrainBits terrainnot
if one of these bits is set, the field will NOT be accessible
Definition: terraintype.h:53
ASCString infoImageFilename
the filename of an image that is shown in info dialogs
EntranceSystems entranceSystems
static ASCString getIconFileName(int weaponType)
int maxdistance
the maximum distance the weapon can shoot
Definition: vehicletype.h:111
A single weapon of a #Vehicletype.
Definition: vehicletype.h:100
int material
Definition: typen.h:100
const char * heightTags[choehenstufennum]
const ASCString & getMessage(void) const
Definition: errors.h:42
void show(const ASCString &widgetName, PG_Widget *parent=NULL)
Definition: windowing.cpp:778
SDLmm::SPoint SPoint
Definition: surface.h:27
int weight
the weight of the unit, without fuel or other cargo
Definition: vehicletype.h:218
TerrainBits terrainkill
if a terrain is not accessible AND one of these bits is matched, the unit will be destroyed ...
Definition: terraintype.h:56
void rename(const ASCString &widgetName, const ASCString &newname, PG_Widget *parent=NULL)
Definition: windowing.cpp:675
static PG_Rect parseRect(PropertyReadingContainer &pc, PG_Widget *parent)
Definition: windowing.cpp:319
int vehicleCategoriesLoadable
bitmapped: vehicle categories that may enter the container
Resources getStorageCapacity(int mode) const
returns the Storage capacity of the unit
vector< HeightChangeMethod > heightChangeMethod
Definition: vehicletype.h:294
const char * unitCategoryTags[cmovemalitypenum]
int height
the levels of height which this unit can enter
void displaymessage2(const char *formatstring,...)
displays a message in the status line of ASC
TerrainBits terrain
at least one of these bits must match on of the terrain
Definition: terraintype.h:47
int fuelConsumption
the fuel consumption to move a single field
Definition: vehicletype.h:200
int heightChangeMethodNum
Definition: vehicletype.h:281
virtual void closeBracket()
const VehicleType * typ
Definition: vehicle.h:83
static Surface & getIcon(const ASCString &name)
void runTextIO(PropertyReadingContainer &pc)
Definition: windowing.cpp:166
int maxwindspeedonwater
the maximum speed of the wind that the unit can survive when on open water without sinking ...
Definition: vehicletype.h:209
int height_abs
a loadable unit must be on this level of height; 0 if not used
const char * terrainProperty[terrainPropertyNum+1]
Definition: terraintype.cpp:30
void paint(Surface &s, SPoint pos, const PlayerColor &player, int direction=0) const
static const char * paneName[paneNum]
GameMap * actmap
Definition: spfst.cpp:64
GameMap * getMap() const
static Surface Wrap(SDL_Surface *surface)
Definition: surface.h:76
virtual void openBracket(const ASCString &name)
bool exist(const ASCString &s)
does a file s exist (wildcards allowed)
Definition: basestrm.cpp:2444
const T & max(const T &a, const T &b, const T &c)
Definition: misc.h:97
void hide(const ASCString &widgetName, PG_Widget *parent=NULL)
Definition: windowing.cpp:768
ASCString infotext
an extensive information about the unit/building which may be several paragraphs long ...
int maxstrength
strength of the weapon when fired over the minimal distance
Definition: vehicletype.h:120
void readImageFile(tnstream &stream)
Definition: surface.cpp:380
void assignWeaponInfo(Panel *panel, PG_Widget *widget, const SingleWeapon &weapon)
void userHandler(const ASCString &label, PropertyReadingContainer &pc, PG_Widget *parent, WidgetParameters widgetParams)
int maxLoadableWeight
the maximum total weight of all loaded units
UnitInfoDialog(PG_Widget *parent, const Vehicle *vehicle, const VehicleType *vehicleType)
SDL_Surface * screen
Definition: graphics.cpp:31
TerrainAccess terrainaccess
the terrain this unit can move to
Definition: vehicletype.h:221
void unitInfoDialog(const VehicleType *vt)
void setLabelText(const ASCString &widgetName, const ASCString &text, PG_Widget *parent=NULL)
Definition: windowing.cpp:685
int container_height
the container must be on this height
MapField * getField(int x, int y)
Definition: gamemap.h:465