Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vdu.h File Reference
#include "cockpit_generic.h"
#include "cmd/unit_generic.h"
#include "sprite.h"
#include <string>
#include <vector>

Go to the source code of this file.

Classes

class  VDU
 

Functions

void DrawObjectivesTextPlane (TextPlane *tp, int scrolloffset, Unit *parent)
 
int parse_vdu_type (const char *s)
 
GFXColor colLerp (GFXColor a, GFXColor b, float bweight)
 
GFXColor MountColor (Mount *mnt)
 

Function Documentation

GFXColor colLerp ( GFXColor  a,
GFXColor  b,
float  bweight 
)

Definition at line 156 of file vdu.cpp.

References GFXColor::a, GFXColor::b, GFXColor::g, and GFXColor::r.

Referenced by MountColor().

157 {
158  float aweight = 1-bweight;
159  return GFXColor( a.r*aweight+b.r*bweight,
160  a.g*aweight+b.g*bweight,
161  a.b*aweight+b.b*bweight,
162  a.a*aweight+b.a*bweight );
163 }
void DrawObjectivesTextPlane ( TextPlane tp,
int  scrolloffset,
Unit parent 
)

Definition at line 1726 of file vdu.cpp.

References active_missions, TextPlane::bgcol, TextPlane::Draw(), GetColorFromSuccess(), VegaConfig::getVariable(), j, mission_name, XMLSupport::parse_bool(), XMLSupport::parse_float(), XMLSupport::tostring(), and vs_config.

Referenced by NavigationSystem::DrawObjectives().

1727 {
1728  std::string rez( "\n" );
1729  for (unsigned int i = 0; i < active_missions.size(); ++i)
1730  if ( !active_missions[i]->objectives.empty() ) {
1731  rez += "#FFFFFF";
1732  static bool force_anonymous_missions =
1733  XMLSupport::parse_bool( vs_config->getVariable( "general", "force_anonymous_mission_names", "true" ) );
1734  if (active_missions[i]->mission_name.empty() || force_anonymous_missions)
1735  rez += "Mission "+XMLSupport::tostring( (int) i )+"\n";
1736  else
1737  rez += active_missions[i]->mission_name+"\n";
1738  vector< Mission::Objective >::iterator j = active_missions[i]->objectives.begin();
1739  for (; j != active_missions[i]->objectives.end(); ++j)
1740  if (j->getOwner() == NULL || j->getOwner() == parent) {
1741  if ( (*j).objective.length() ) {
1742  rez += GetColorFromSuccess( (*j).completeness );
1743  rez += (*j).objective;
1744  rez += '\n';
1745  }
1746  }
1747  rez += '\n';
1748  }
1749  static float background_alpha =
1750  XMLSupport::parse_float( vs_config->getVariable( "graphics", "hud", "text_background_alpha", "0.0625" ) );
1751  GFXColor tpbg = tp->bgcol;
1752  bool automatte = (0 == tpbg.a);
1753  if (automatte) tp->bgcol = GFXColor( 0, 0, 0, background_alpha );
1754  tp->Draw( rez, scrolloffset, false, false, automatte );
1755  tp->bgcol = tpbg;
1756 }
GFXColor MountColor ( Mount mnt)

Definition at line 1562 of file vdu.cpp.

References Mount::ACTIVE, Mount::ammo, weapon_info::BEAM, colLerp(), Mount::DESTROYED, Mount::functionality, Mount::REF::gun, Mount::INACTIVE, Mount::ref, weapon_info::Refire(), Mount::REF::refire, Beam::refireTime(), Mount::status, weapon_info::type, Mount::type, and Mount::UNCHOSEN.

1563 {
1564  GFXColor mountcolor;
1565  switch (mnt->ammo != 0 ? mnt->status : 127)
1566  {
1567  case Mount::ACTIVE: {
1568  if (mnt->functionality == 1)
1569  {
1570  float ref = 1;
1571  float tref = mnt->type->Refire();
1572  float cref = 0;
1573  if (mnt->type->type == weapon_info::BEAM) {
1574  if (mnt->ref.gun)
1575  cref = mnt->ref.gun->refireTime();
1576  } else {
1577  cref = mnt->ref.refire;
1578  }
1579  if (cref < tref)
1580  ref = cref/tref;
1581  if (ref == 1.0)
1582  mountcolor = GFXColor( 0, 1, .2 );
1583  else
1584  mountcolor = colLerp( GFXColor( .2, .2, .2 ), GFXColor( 0, 1, 1 ), ref );
1585  } else // damaged
1586  {
1587  mountcolor = colLerp( GFXColor( 1, 0, 0 ), GFXColor( 0, 1, .2 ), mnt->functionality );
1588  }
1589  break;
1590  }
1591  case Mount::DESTROYED:
1592  mountcolor = GFXColor( 1, 0, 0, 1 );
1593  break;
1594  case Mount::INACTIVE:
1595  mountcolor = GFXColor( 1, 1, 1, 1 );
1596  break;
1597  case Mount::UNCHOSEN:
1598  mountcolor = GFXColor( 1, 1, 1, 1 );
1599  break;
1600  case 127:
1601  mountcolor = GFXColor( 0, .2, 0, 1 );
1602  break;
1603  default:
1604  mountcolor = GFXColor( 0, 1, .2, 1 );
1605  break;
1606  }
1607  return mountcolor;
1608 }
int parse_vdu_type ( const char *  s)

Definition at line 137 of file vdu.cpp.

References vdu_lookup().

138 {
139  char *mystr = strdup( x );
140  char *s = mystr;
141  int retval = 0;
142  while (s[0] != '\0')
143  retval |= vdu_lookup( s );
144  free( mystr );
145  return retval;
146 }