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
NavigationSystem Class Reference

#include <navscreen.h>

Classes

class  CachedSectorIterator
 
class  CachedSystemIterator
 
class  SystemIterator
 

Public Member Functions

 NavigationSystem ()
 
 ~NavigationSystem ()
 
void setCurrentSystem (string newSystem)
 
std::string getCurrentSystem ()
 
std::string getSelectedSystem ()
 
std::string getFocusedSystem ()
 
std::string getDestinationSystem ()
 
void DrawButton (float &x1, float &x2, float &y1, float &y2, int button_number, bool outline)
 
void DrawButtonOutline (float &x1, float &x2, float &y1, float &y2, const GFXColor &col)
 
void DrawCursor (float x, float y, float wid, float hei, const GFXColor &col)
 
void DrawGrid (float &screen_x1, float &screen_x2, float &screen_y1, float &screen_y2, const GFXColor &col)
 
bool TestIfInRange (float &x1, float &x2, float &y1, float &y2, float tx, float ty)
 
bool TestIfInRangeBlk (float &x1, float &x2, float size, float tx, float ty)
 
bool TestIfInRangeRad (float &x, float &y, float size, float tx, float ty)
 
bool ParseFile (string filename)
 
bool CheckDraw ()
 
void DrawSystem ()
 
void DrawGalaxy ()
 
void DrawMission ()
 
void DrawShip ()
 
void DrawSectorList ()
 
void DrawObjectives ()
 
void SetMouseFlipStatus ()
 
void ScreenToCoord (float &x)
 
void IntersectBorder (float &x, float &y, const float &x1, const float &y1) const
 
void Draw ()
 
void Setup ()
 
void SetDraw (bool n)
 
void ClearPriorities ()
 
void updatePath ()
 
void scroll (signed int scrollamt)
 

Static Public Member Functions

static void DrawCircle (float x, float y, float size, const GFXColor &col)
 
static void DrawHalfCircleTop (float x, float y, float size, const GFXColor &col)
 
static void DrawHalfCircleBottom (float x, float y, float size, const GFXColor &col)
 
static void DrawPlanet (float x, float y, float size, const GFXColor &col)
 
static void DrawStation (float x, float y, float size, const GFXColor &col)
 
static void DrawJump (float x, float y, float size, const GFXColor &col)
 
static void DrawMissile (float x, float y, float size, const GFXColor &col)
 
static void DrawTargetCorners (float x, float y, float size, const GFXColor &col)
 
static void DrawNavCircle (float x, float y, float rot_x, float rot_y, float size, const GFXColor &col)
 
static void mouseDrag (int x, int y)
 
static void mouseMotion (int x, int y)
 
static void mouseClick (int button, int state, int x, int y)
 
static int getMouseButtonStatus ()
 
static class QVector dxyz (class QVector, double x_, double y_, double z_)
 

Public Attributes

PathManagerpathman
 

Static Public Attributes

static int mousex = 0
 
static int mousey = 0
 
static int mousestat
 

Friends

class NavComputer
 
class CurrentPathNode
 
class TargetPathNode
 
class AbsolutePathNode
 
class CriteriaContains
 
class CriteriaOwnedBy
 
class CriteriaSector
 
class NavPath
 

Detailed Description

Definition at line 18 of file navscreen.h.

Constructor & Destructor Documentation

NavigationSystem::NavigationSystem ( )

Definition at line 47 of file navscreen.cpp.

References i, NavComputer, NAVTOTALMESHCOUNT, and pathman.

48 {
49  draw = -1;
50  whattodraw = (1|2);
51  pathman = new PathManager();
52  navcomp = new NavComputer( this );
53  for (int i = 0; i < NAVTOTALMESHCOUNT; i++)
54  mesh[i] = NULL;
55  factioncolours = NULL;
56 }
NavigationSystem::~NavigationSystem ( )

Definition at line 58 of file navscreen.cpp.

59 {
60  draw = 0;
61  //delete mesh;
62  delete screenoccupation;
63  delete mesh[0];
64  delete mesh[1];
65  delete mesh[2];
66  delete mesh[3];
67  delete mesh[4];
68  delete mesh[5];
69  delete mesh[6];
70  delete mesh[7];
71  delete factioncolours;
72 }

Member Function Documentation

bool NavigationSystem::CheckDraw ( )

Definition at line 1373 of file navscreen.cpp.

Referenced by GameCockpit::CanDrawNavSystem(), Draw(), GameCockpit::DrawNavSystem(), and GameCockpit::ScrollAllVDU().

1374 {
1375  return draw == 1;
1376 }
void NavigationSystem::ClearPriorities ( )

Definition at line 844 of file navscreen.cpp.

References unsetbit().

Referenced by SetDraw().

845 {
846  unsetbit( buttonstates, 1 );
847  currentselection = NULL;
848 //rx = 1.0; // resetting rotations is up to hitting the 2d/3d button
849 //ry = 1.0;
850 //rz = 0.0;
851 //rx_s = 1.0;
852 //ry_s = 1.0;
853 //rz_s = 0.0;
854 }
void NavigationSystem::Draw ( )

Definition at line 352 of file navscreen.cpp.

References _Universe, Universe::AccessCamera(), Universe::AccessCockpit(), Universe::activateLightMap(), checkbit(), CheckDraw(), DEPTHTEST, DEPTHWRITE, Mesh::Draw(), DrawButton(), DrawCursor(), DrawGalaxy(), DrawGrid(), DrawMission(), DrawNavCircle(), DrawObjectives(), DrawSectorList(), DrawShip(), DrawSystem(), float, g_game, Camera::GetOrientation(), Cockpit::GetParent(), Camera::GetPosition(), VegaConfig::getVariable(), GFXBlendMode(), GFXColor4f(), GFXDisable(), GFXEnable(), GFXFALSE, GFXHudMode(), GFXTRUE, i, INVSRCALPHA, LIGHTING, mousex, mousey, NAVTOTALMESHCOUNT, XMLSupport::parse_float(), Mesh::ProcessUndrawnMeshes(), Mesh::ProcessZFarMeshes(), q, QVector, navscreenoccupied::reset(), SetMouseFlipStatus(), SRCALPHA, TEXTURE0, TEXTURE1, Camera::UpdateGFX(), Vector, vs_config, game_data_t::x_resolution, and game_data_t::y_resolution.

Referenced by GameCockpit::DrawNavSystem().

353 {
354  if ( !CheckDraw() )
355  return;
356  if (_Universe->AccessCockpit()->GetParent() == NULL)
357  return;
358 
359  //DRAW THE SCREEN MODEL
360  //**********************************
361  Vector p, q, r;
362  static float zrange =
363  XMLSupport::parse_float( vs_config->getVariable( "graphics", "cockpit_nav_zrange", "10" ) );
364  static float zfloor =
365  XMLSupport::parse_float( vs_config->getVariable( "graphics", "cockpit_nav_zfloor", "0.1" ) );
366  _Universe->AccessCamera()->GetOrientation( p, q, r );
368  GFXTRUE,
369  GFXFALSE,
370  GFXTRUE,
371  zfloor,
372  zfloor+zrange );
373 
375  for (int i = 0; i < NAVTOTALMESHCOUNT; i++) {
376  float screen_x = 0.0;
377  float screen_y = 0.0;
378  float screen_z = 0.0;
379 
380  screen_x = meshcoordinate_x[i];
381  screen_y = meshcoordinate_y[i];
382  screen_z = meshcoordinate_z[i];
383  if ( checkbit( buttonstates, (i-1) ) ) //button1 = 0, starts at -1, returning 0, no addition done
384  screen_z += meshcoordinate_z_delta[i];
386 
387  //offset horizontal
388  //***************
389  pos = (p.Cast()*screen_x)+pos;
390  //***************
391 
392  //offset vertical
393  //***************
394  pos = (q.Cast()*screen_y)+pos;
395  //***************
396 
397  //offset sink
398  //***************
399  pos = (r.Cast()*screen_z)+pos;
400  //***************
401 
402  Matrix mat( p, q, r, pos );
403  if (mesh[i]) {
404  mesh[i]->Draw(
405  FLT_MAX, // lod
406  mat );
407  }
408  }
410  Mesh::ProcessUndrawnMeshes(false,true);
412  GFXColor4f( 1, 1, 1, 1 );
413  GFXDisable( TEXTURE0 );
414  GFXDisable( TEXTURE1 );
415  GFXDisable( LIGHTING );
416 
417  GFXHudMode( true );
420  //**********************************
421 
422  screenoccupation->reset();
423 
424  //Save current mouse location
425  //**********************************
426  mouse_x_current = ( -1+float(mousex)/(.5*g_game.x_resolution) );
427  mouse_y_current = ( 1+float(-1*mousey)/(.5*g_game.y_resolution) );
428  //**********************************
429 
430  //Set Mouse
431  //**********************************
432  SetMouseFlipStatus(); //define bools 'mouse_wentdown[]' 'mouse_wentup[]'
433  //**********************************
434  //Draw the Navscreen Functions
435  //**********************************
436  if ( checkbit( whattodraw, 1 ) ) {
437  if ( checkbit( whattodraw, 2 ) ) {
438  if (galaxy_view == VIEW_3D) {
439  DrawNavCircle( ( (screenskipby4[0]+screenskipby4[1])/2.0 ), ( (screenskipby4[2]+screenskipby4[3])/2.0 ),
440  0.6,
441  rx, ry, GFXColor( 1, 1, 1,
442  0.2 ) );
443  } else {
444  DrawGrid( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3], GFXColor( 1, 1, 1, 0.2 ) );
445  }
446  DrawGalaxy();
447  } else {
448  if (system_view == VIEW_3D) {
449  DrawNavCircle( ( (screenskipby4[0]+screenskipby4[1])/2.0 ), ( (screenskipby4[2]+screenskipby4[3])/2.0 ),
450  0.6,
451  rx_s, ry_s, GFXColor( 1, 1, 1,
452  0.2 ) );
453  } else {
454  DrawGrid( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3], GFXColor( 1, 1, 1, 0.2 ) );
455  }
456  DrawSystem();
457  }
458  } else {
459  if ( checkbit( whattodraw, 3 ) )
460  DrawSectorList();
461  else if ( checkbit( whattodraw, 2 ) )
462  DrawShip();
463  else
464  DrawMission();
465  }
466  //**********************************
467 
468  DrawObjectives();
469 
470  //Draw Button Outlines
471  //**********************************
472  bool outlinebuttons = 0;
473  if (configmode > 0)
474  outlinebuttons = 1;
475  DrawButton( buttonskipby4_1[0], buttonskipby4_1[1], buttonskipby4_1[2], buttonskipby4_1[3], 1, outlinebuttons );
476  DrawButton( buttonskipby4_2[0], buttonskipby4_2[1], buttonskipby4_2[2], buttonskipby4_2[3], 2, outlinebuttons );
477  DrawButton( buttonskipby4_3[0], buttonskipby4_3[1], buttonskipby4_3[2], buttonskipby4_3[3], 3, outlinebuttons );
478  DrawButton( buttonskipby4_4[0], buttonskipby4_4[1], buttonskipby4_4[2], buttonskipby4_4[3], 4, outlinebuttons );
479  DrawButton( buttonskipby4_5[0], buttonskipby4_5[1], buttonskipby4_5[2], buttonskipby4_5[3], 5, outlinebuttons );
480  DrawButton( buttonskipby4_6[0], buttonskipby4_6[1], buttonskipby4_6[2], buttonskipby4_6[3], 6, outlinebuttons );
481  DrawButton( buttonskipby4_7[0], buttonskipby4_7[1], buttonskipby4_7[2], buttonskipby4_7[3], 7, outlinebuttons );
482  //**********************************
483 
484  //Draw the screen basics
485  //**********************************
486  DrawCursor( mouse_x_current, mouse_y_current, .1, .2, GFXColor( 1, 1, 1, 0.5 ) );
487  //**********************************
488 
489  //Save current mouse location as previous for next cycle
490  //**********************************
491  mouse_x_previous = ( -1+float(mousex)/(.5*g_game.x_resolution) );
492  mouse_y_previous = ( 1+float(-1*mousey)/(.5*g_game.y_resolution) );
493  //**********************************
494 
495  GFXEnable( TEXTURE0 );
496  GFXHudMode( false );
497 }
void NavigationSystem::DrawButton ( float x1,
float x2,
float y1,
float y2,
int  button_number,
bool  outline 
)

!! DEPRESS !!!

!! RELEASE !!!

!! OUT OF BOUNDS !!!

Definition at line 1009 of file navscreen.cpp.

References TextPlane::bgcol, checkbit(), TextPlane::col, dosetbit(), TextPlane::Draw(), DrawButtonOutline(), flipbit(), float, VegaConfig::getVariable(), XMLSupport::parse_bool(), XMLSupport::parse_float(), NavComputer::run(), TextPlane::SetPos(), TextPlane::SetText(), TestIfInRange(), unsetbit(), and vs_config.

Referenced by Draw().

1010 {
1011  float mx = mouse_x_current;
1012  float my = mouse_y_current;
1013  bool inrange = TestIfInRange( x1, x2, y1, y2, mx, my );
1014 
1015  string label;
1016  if (button_number == 1) {
1017  label = "Nav/Info";
1018  } else if (button_number == 3) {
1019  label = "Target Selected";
1020  } else if (button_number == 7) {
1021  label = "2D/Ortho/3D";
1022  } else if ( checkbit( whattodraw, 1 ) ) {
1023  if (button_number == 2)
1024  label = "Path On/Off/Only";
1025  else if (button_number == 4)
1026  label = "Up";
1027  else if (button_number == 5)
1028  label = "Down";
1029  else if (button_number == 6)
1030  label = "Axis Swap";
1031  } else {
1032  if (button_number == 2)
1033  label = "Sectors";
1034  else if (button_number == 4)
1035  label = "Ship";
1036  else if (button_number == 5)
1037  label = "Mission";
1038  else if (button_number == 6)
1039  label = "Nav Comp";
1040  }
1041  TextPlane a_label;
1042  a_label.col = GFXColor( 1, 1, 1, 1 );
1043  int length = label.size();
1044  float offset = (float(length)*0.0065);
1045  float xl = (x1+x2)/2.0;
1046  float yl = (y1+y2)/2.0;
1047  a_label.SetPos( (xl-offset)-(checkbit( buttonstates, button_number-1 ) ? 0.006 : 0), (yl+0.025) );
1048  a_label.SetText( label );
1049  static bool nav_button_labels =
1050  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "draw_nav_button_labels", "true" ) );
1051  if (nav_button_labels) {
1052  static float background_alpha =
1053  XMLSupport::parse_float( vs_config->getVariable( "graphics", "hud", "text_background_alpha", "0.0625" ) );
1054  GFXColor tpbg = a_label.bgcol;
1055  bool automatte = (0 == tpbg.a);
1056  if (automatte) a_label.bgcol = GFXColor( 0, 0, 0, background_alpha );
1057  a_label.Draw( label, 0, true, false, automatte );
1058  a_label.bgcol = tpbg;
1059  }
1061  if ( (inrange == 1) && (mouse_wentdown[0] == 1) ) {
1062  currentselection = NULL; //any new button depression means no depression on map, no selection made
1063 
1064  //******************************************************
1065  //** DEPRESS FUNCTION ** DEPRESS ALL
1066  //******************************************************
1067 
1068  dosetbit( buttonstates, (button_number-1) ); //all buttons go down
1069 
1070  //******************************************************
1071  }
1073  if ( (inrange == 1) && ( checkbit( buttonstates, (button_number-1) ) ) && (mouse_wentup[0]) ) {
1074  //******************************************************
1075  //** MISSION MODE ** UNSET BITS WHEN ENTERING MISSION MODE
1076  //******************************************************
1077  if ( !checkbit( whattodraw, 1 ) )
1078  unsetbit( buttonstates, (button_number-1) ); //all are up in mission mode
1079  else
1080  unsetbit( buttonstates, (button_number-1) ); //all are up in navigation mode
1081  //******************************************************
1082  //******************************************************
1083  //** BUTTON 1 FUNCTION ** NAV-INFO vs STATUS-INFO
1084  //******************************************************
1085  if (button_number == 1) //releasing #1, toggle the draw (nav / mission)
1086  flipbit( whattodraw, 1 );
1087  //******************************************************
1088  //******************************************************
1089  //** BUTTON 2 FUNCTION ** PATH options
1090  //******************************************************
1091  if (button_number == 2) {
1092  //releasing #2, toggle the path viewing settings(off/on/only)
1093  if ( ( checkbit( whattodraw, 1 ) ) && ( checkbit( whattodraw, 2 ) ) )
1094  path_view = (path_view+1)%PATH_MAXIMUM;
1095  else if ( !checkbit( whattodraw, 1 ) )
1096  dosetbit( whattodraw, 3 );
1097  }
1098  //******************************************************
1099  //******************************************************
1100  //** BUTTON 3 FUNCTION ** TARGET SELECTED SYSTEM
1101  //******************************************************
1102  if (button_number == 3) {
1103  //hit --TARGET--
1104  if ( ( ( checkbit( whattodraw, 1 ) ) && ( checkbit( whattodraw, 2 ) ) ) //Nav-Galaxy Mode
1105  || ( ( !checkbit( whattodraw, 1 ) ) && ( checkbit( whattodraw, 3 ) ) ) ) //Mission-Sector Mode
1106  setDestinationSystemIndex( systemselectionindex );
1107  }
1108  //******************************************************
1109  //******************************************************
1110  //** BUTTON 4 FUNCTION ** UP
1111  //******************************************************
1112  if (button_number == 4) {
1113  //hit --UP--
1114  if ( checkbit( whattodraw, 1 ) ) {
1115  //if in nav system NOT mission
1116  dosetbit( whattodraw, 2 ); //draw galaxy
1117  setFocusedSystemIndex( currentsystemindex );
1118  systemselectionindex = currentsystemindex;
1119  } else {
1120  //if in mission mode
1121  unsetbit( whattodraw, 3 );
1122  dosetbit( whattodraw, 2 ); //draw shipstats
1123  }
1124  }
1125  //******************************************************
1126  //******************************************************
1127  //** BUTTON 5 FUNCTION ** DOWN
1128  //******************************************************
1129  if (button_number == 5) {
1130  //hit --DOWN--
1131  if ( checkbit( whattodraw, 1 ) ) {
1132  //if in nav system NOT mission
1133 
1134  unsetbit( whattodraw, 2 ); //draw system
1135  } else {
1136  //if in mission mode
1137  unsetbit( whattodraw, 3 );
1138  unsetbit( whattodraw, 2 ); //draw mission
1139  }
1140  }
1141  //******************************************************
1142  //******************************************************
1143  //** BUTTON 6 FUNCTION ** AXIS
1144  //******************************************************
1145  if (button_number == 6) {
1146  //releasing #1, toggle the draw (nav / mission)
1147  if ( checkbit( whattodraw, 1 ) ) {
1148  //if in nav system NOT mission
1149  zoom = 1.8;
1150  zoom_s = 1.8;
1151 
1152  axis = axis-1;
1153  if (axis == 0)
1154  axis = 3;
1155  camera_z = 0;
1156  } else {
1157  //if in mission mode
1158 
1159  navcomp->run();
1160  }
1161  }
1162  //******************************************************
1163  //******************************************************
1164  //** BUTTON 7 FUNCTION ** 2D/3D
1165  //******************************************************
1166  if (button_number == 7) {
1167  if ( ( checkbit( whattodraw, 1 ) ) && ( checkbit( whattodraw, 2 ) ) && galaxy_multi_dimensional ) {
1168  galaxy_view = (galaxy_view+1)%VIEW_MAX;
1169  rx = -0.5;
1170  ry = 0.5;
1171  rz = 0.0;
1172  }
1173  if ( ( checkbit( whattodraw, 1 ) ) && ( !checkbit( whattodraw, 2 ) ) && system_multi_dimensional ) {
1174  system_view = (system_view+1)%VIEW_MAX;
1175  rx_s = -0.5;
1176  ry_s = 0.5;
1177  rz_s = 0.0;
1178  }
1179  camera_z = 0;
1180  }
1181  //******************************************************
1182  }
1184  //******************************************************
1185  //** OUT OF RANGE ** ALL DIE
1186  //******************************************************
1187  if (inrange == 0)
1188  unsetbit( buttonstates, (button_number-1) );
1189  //******************************************************
1190  //******************************************************
1191  //** TRACE OUTLINES FOR EZ SETUP ** ARTIST DEV UTIL
1192  //******************************************************
1193  if (outline == 1) {
1194  if (inrange == 1) {
1195  if ( checkbit( buttonstates, (button_number-1) ) )
1196  DrawButtonOutline( x1, x2, y1, y2, GFXColor( 1, 0, 0, 1 ) );
1197 
1198  else
1199  DrawButtonOutline( x1, x2, y1, y2, GFXColor( 1, 1, 0, 1 ) );
1200  } else {
1201  if ( checkbit( buttonstates, (button_number-1) ) )
1202  DrawButtonOutline( x1, x2, y1, y2, GFXColor( 1, 0, 0, 1 ) );
1203  else
1204  DrawButtonOutline( x1, x2, y1, y2, GFXColor( 1, 1, 1, 1 ) );
1205  }
1206  }
1207  //******************************************************
1208 }
void NavigationSystem::DrawButtonOutline ( float x1,
float x2,
float y1,
float y2,
const GFXColor col 
)

Definition at line 1213 of file navscreen.cpp.

References GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXVertex3f(), INVSRCALPHA, LIGHTING, SRCALPHA, and TEXTURE0.

Referenced by DrawButton().

1214 {
1215  GFXColorf( col );
1216  GFXDisable( TEXTURE0 );
1217  GFXDisable( LIGHTING );
1219 
1220  GFXBegin( GFXLINE );
1221  GFXVertex3f( x1, y1, 0 );
1222  GFXVertex3f( x1, y2, 0 );
1223  GFXVertex3f( x2, y1, 0 );
1224  GFXVertex3f( x2, y2, 0 );
1225  GFXVertex3f( x1, y1, 0 );
1226  GFXVertex3f( x2, y1, 0 );
1227  GFXVertex3f( x1, y2, 0 );
1228  GFXVertex3f( x2, y2, 0 );
1229  GFXEnd();
1230 
1231  GFXEnable( TEXTURE0 );
1232 }
void NavigationSystem::DrawCircle ( float  x,
float  y,
float  size,
const GFXColor col 
)
static

Definition at line 80 of file navitemstodraw.h.

References UniverseUtil::cos(), GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXVertex3f(), i, INVSRCALPHA, LIGHTING, UniverseUtil::sin(), SRCALPHA, and TEXTURE0.

Referenced by drawlistitem(), and DrawNode().

81 {
82  GFXColorf( col );
86 
87  float i = 0.0;
88  GFXBegin( GFXLINE );
89  for ( i = 0; i < 6.28; i += (6.28/20) ) {
90  GFXVertex3f( ( x+( 0.5*size*cos( i ) ) ), ( y+( 0.5*size*sin( i ) ) ), 0 );
91  GFXVertex3f( ( x+( 0.5*size*cos( i+(6.28/20) ) ) ), ( y+( 0.5*size*sin( i+(6.28/20) ) ) ), 0 );
92  }
93  GFXEnd();
95 }
void NavigationSystem::DrawCursor ( float  x,
float  y,
float  wid,
float  hei,
const GFXColor col 
)

Definition at line 3 of file navitemstodraw.h.

References BILINEAR, DEPTHTEST, VegaConfig::getVariable(), GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXTRUE, GFXVertex3f(), GUI_OPAQUE_WHITE(), INVSRCALPHA, LIGHTING, XMLSupport::parse_bool(), SRCALPHA, TEXTURE0, TEXTURE1, and vs_config.

Referenced by Draw().

4 {
5  float sizex, sizey;
6  static bool modern_nav_cursor =
7  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "nav", "modern_mouse_cursor", "true" ) );
8  if (modern_nav_cursor) {
9  static string mouse_cursor_sprite = vs_config->getVariable( "graphics", "nav", "mouse_cursor_sprite", "mouse.spr" );
10  static VSSprite MouseVSSprite( mouse_cursor_sprite.c_str(), BILINEAR, GFXTRUE );
13 
14  //Draw the cursor sprite.
18  MouseVSSprite.GetSize( sizex, sizey );
19  MouseVSSprite.SetPosition( x+sizex/2, y+sizey/2 );
20  MouseVSSprite.Draw();
21  } else {
22  GFXColorf( col );
26  GFXBegin( GFXLINE );
27  GFXVertex3f( x, y, 0 );
28  GFXVertex3f( x, (y-hei), 0 );
29 
30  GFXVertex3f( x, y, 0 );
31  GFXVertex3f( (x+wid), float( y-(0.75*hei) ), 0 );
32 
33  GFXVertex3f( x, (y-hei), 0 );
34  GFXVertex3f( ( x+(0.35*wid) ), ( y-(0.6*hei) ), 0 );
35 
36  GFXVertex3f( ( x+(0.35*wid) ), ( y-(0.6*hei) ), 0 );
37  GFXVertex3f( (x+wid), float( y-(0.75*hei) ), 0 );
38  GFXEnd();
40  }
41 }
void NavigationSystem::DrawGalaxy ( )

Definition at line 732 of file drawgalaxy.cpp.

References GFXColor::a, Beautify(), TextPlane::col, NavigationSystem::CachedSystemIterator::done(), TextPlane::Draw(), DrawNode(), DrawTargetCorners(), float, NavigationSystem::CachedSystemIterator::SystemInfo::GetColor(), getCurrentSystem(), NavigationSystem::CachedSystemIterator::SystemInfo::GetDestinationIndex(), NavigationSystem::CachedSystemIterator::SystemInfo::GetDestinationSize(), NavigationSystem::CachedSystemIterator::getIndex(), GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnd(), GFXLINE, GFXVertex3f(), i, IntersectBorder(), INVSRCALPHA, NavigationSystem::CachedSystemIterator::SystemInfo::isDrawable(), LIGHTING, MAXZOOM, NavigationSystem::CachedSystemIterator::SystemInfo::part_of_path, NavigationSystem::CachedSystemIterator::SystemInfo::paths, NavigationSystem::CachedSystemIterator::SystemInfo::Position(), QVector, NavigationSystem::CachedSystemIterator::seek(), TextPlane::SetPos(), TextPlane::SetText(), UniverseUtil::sqrt(), SRCALPHA, SYSTEM_DEFAULT_SIZE, systemambiguous, StarSystemGent::systemname, TestIfInRange(), TestIfInRangeRad(), TEXTURE0, Vector, and vsmax().

Referenced by Draw().

733 {
734 //systemdrawlist mainlist;//(0, screenoccupation, factioncolours); // lists of items to draw that are in mouse range
735 
736  systemdrawlist mouselist; //(1, screenoccupation, factioncolours); // lists of items to draw that are in mouse range
737 
738  string csector, csystem;
739 
740  Beautify( getCurrentSystem(), csector, csystem );
741  //what's my name
742  //***************************
743  TextPlane systemname; //will be used to display shits names
744  string systemnamestring = "Current System : "+csystem+" in the "+csector+" Sector.";
745 
746 //int length = systemnamestring.size();
747 //float offset = (float(length)*0.005);
748  systemname.col = GFXColor( 1, 1, .7, 1 );
749  systemname.SetPos( screenskipby4[0], screenskipby4[3] ); //Looks ugly when name is too long and goes off the edge.
750 //systemname.SetPos( (((screenskipby4[0]+screenskipby4[1])/2)-offset) , screenskipby4[3]);
751  systemname.SetText( systemnamestring );
752 //systemname.SetCharSize(1, 1);
753  systemname.Draw();
754  //***************************
755 
756  QVector pos; //item position
757  QVector pos_flat; //item position flat on plane
758 
759  float zdistance = 0.0;
760  float zscale = 1.0;
761  int l;
762 
763  Adjust3dTransformation( galaxy_view == VIEW_3D, 0 );
764 
765  float center_nav_x = ( (screenskipby4[0]+screenskipby4[1])/2 );
766  float center_nav_y = ( (screenskipby4[2]+screenskipby4[3])/2 );
767  //**********************************
768 
769  glEnable( GL_ALPHA );
770  GFXDisable( LIGHTING );
772  if (!camera_z) {
773  float max_x = 0.0;
774  float min_x = 0.0;
775  float max_y = 0.0;
776  float min_y = 0.0;
777  float max_z = 0.0;
778  float min_z = 0.0;
779 
780 //themaxvalue = fabs(pos.i);
781  themaxvalue = 0.0;
782 
783  {
784  {
785  systemIter.seek( focusedsystemindex );
786  pos = systemIter->Position();
787  ReplaceAxes( pos );
788 //if(galaxy_view==VIEW_3D){pos = dxyz(pos, 0, ry, 0);pos = dxyz(pos, rx, 0, 0);}
789 
790  max_x = (float) pos.i;
791  min_x = (float) pos.i;
792  max_y = (float) pos.j;
793  min_y = (float) pos.j;
794  max_z = (float) pos.k;
795  min_z = (float) pos.k;
796 
797  //Find Centers
798  //**********************************
799  //This will use the current system as the center
800  center_x = pos.i;
801  center_y = pos.j;
802  center_z = pos.k;
803  //**********************************
804 
805  unsigned destsize = systemIter->GetDestinationSize();
806  if (destsize != 0) {
807  for (unsigned i = 0; i < destsize; ++i) {
808  QVector posoth = systemIter[systemIter->GetDestinationIndex( i )].Position();
809  ReplaceAxes( posoth );
810 //if(galaxy_view==VIEW_3D){posoth = dxyz(pos, 0, ry, 0);posoth = dxyz(pos, rx, 0, 0);}
811 
812  RecordMinAndMax( posoth, min_x, max_x, min_y, max_y, min_z, max_z, themaxvalue );
813  }
814  }
815  }
816  }
817 
818  //Find Centers
819  //**********************************
820  //this will make the center be the center of the displayable area.
821 //center_x = (min_x + max_x)/2;
822 //center_y = (min_y + max_y)/2;
823 //center_z = (min_z + max_z)/2;
824  //**********************************
825 
826 /* min_x = (min_x+center_x)/2;
827  * min_y = (min_y+center_y)/2;
828  * min_z = (min_z+center_z)/2;
829  * max_x = (max_x+center_x)/2;
830  * max_y = (max_y+center_y)/2;
831  * max_z = (max_z+center_z)/2;
832  */
833  //Set Camera Distance
834  //**********************************
835 
836 #define SQRT3 1.7320508
837 //themaxvalue = sqrt(themaxvalue*themaxvalue + themaxvalue*themaxvalue + themaxvalue*themaxvalue);
838 //themaxvalue = SQRT3*themaxvalue;
839 
840  themaxvalue *= 3;
841 
842  {
843  float half_x = vsmax( max_x-center_x, center_x-min_x );
844  float half_y = vsmax( max_y-center_y, center_y-min_y );
845  float half_z = vsmax( max_z-center_z, center_z-min_z );
846 
847 //float half_x =(0.5*(max_x - min_x));
848 //float half_y =(0.5*(max_y - min_y));
849 //float half_z =(0.5*(max_z - min_z));
850 
851  camera_z = sqrt( (half_x*half_x)+(half_y*half_y)+(half_z*half_z) );
852 
853 //float halfmax = 0.5*themaxvalue;
854 //camera_z = sqrt( (halfmax*halfmax) + (halfmax*halfmax) + (halfmax*halfmax) );
855 //camera_z = 4.0*themaxvalue;
856 //camera_z = tihemaxvalue;
857  }
858 
859  //**********************************
860  }
861  DrawOriginOrientationTri( center_nav_x, center_nav_y, 0 );
862 
863  //Enlist the items and attributes
864  //**********************************
865  systemIter.seek();
866  while ( !systemIter.done() ) {
867  //this draws the points
868  //IGNORE UNDRAWABLE SYSTEMS
869  //**********************************
870  if ( !systemIter->isDrawable() ) {
871  ++systemIter;
872  continue;
873  }
874  //**********************************
875 
876  //Retrieve unit data
877  //**********************************
878  unsigned temp = systemIter.getIndex();
879 
880  pos = systemIter->Position();
881 
882  ReplaceAxes( pos ); //poop
883 
884  //Modify by old rotation amount
885  //*************************
886 //if(galaxy_view==VIEW_3D){pos = dxyz(pos, 0, ry, 0);pos = dxyz(pos, rx, 0, 0);}
887  //*************************
888  //*************************
889 
890  GFXColor col = systemIter->GetColor();
891  Vector oldpos = pos;
892  float the_x, the_y, the_x_flat, the_y_flat, system_item_scale_temp;
893  TranslateCoordinates( pos,
894  pos_flat,
895  center_nav_x,
896  center_nav_y,
897  themaxvalue,
898  zscale,
899  zdistance,
900  the_x,
901  the_y,
902  the_x_flat,
903  the_y_flat,
904  system_item_scale_temp,
905  0 );
906  float alphaadd;
907  {
908  float tmp = ( 1-(zoom/MAXZOOM) );
909  alphaadd = (tmp*tmp)-.5;
910 //if (alphaadd<=0)
911 //alphaadd=0;
912 //else
913  alphaadd *= 4;
914  }
915  col.a = (system_item_scale_temp-minimumitemscaledown)/(maximumitemscaleup-minimumitemscaledown)+alphaadd;
916 //col.a=GetAlpha(oldpos,center_x,center_y,center_z,zdistance);
917  //IGNORE DIM AND OFF SCREEN SYETEMS
918  //**********************************
919  if ( (col.a < .05)
920  || ( !TestIfInRange( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3], the_x, the_y ) ) ) {
921  ++systemIter;
922  continue;
923  }
924  //**********************************
925 
926  //FIND OUT IF SYSTEM IS PART OF A VISIBLE PATH
927  //**********************************
928  bool isPath = false;
929  if (path_view != PATH_OFF) {
930  if (systemIter->part_of_path) {
931  for (std::set< NavPath* >::iterator paths = systemIter->paths.begin();
932  paths != systemIter->paths.end();
933  ++paths)
934  if ( (*paths)->getVisible() ) {
935  isPath = true;
936  break;
937  }
938  }
939  }
940  //**********************************
941  //IGNORE NON-PATH SYSTEMS IN PATH_ONLY MODE
942  //**********************************
943  if (!isPath && path_view == PATH_ONLY) {
944  ++systemIter;
945  continue;
946  }
947  //**********************************
948 
949  int insert_type = systemambiguous;
950  float insert_size = SYSTEM_DEFAULT_SIZE;
951  if ( system_item_scale_temp > (system_item_scale*3) )
952  system_item_scale_temp = (system_item_scale*3);
953  insert_size *= system_item_scale_temp/3;
954  if (currentsystemindex == temp)
955  DrawTargetCorners( the_x, the_y, (insert_size), currentcol );
956  if (destinationsystemindex == temp)
957  DrawTargetCorners( the_x, the_y, (insert_size)*1.2, destinationcol );
958  if (systemselectionindex == temp)
959  DrawTargetCorners( the_x, the_y, (insert_size)*1.4, selectcol );
960  bool moused = false;
961  DrawNode( insert_type, insert_size, the_x, the_y,
962  (*systemIter).GetName(), screenoccupation, moused, isPath ? pathcol : col, false, false,
963  isPath ? "" : csector );
964  if (std::fabs(zdistance) < 2.0f * camera_z)
965  {
966  DisplayOrientationLines( the_x, the_y, the_x_flat, the_y_flat, 0 );
967  }
968  if ( TestIfInRangeRad( the_x, the_y, insert_size, mouse_x_current, mouse_y_current ) ) {
969  mouselist.push_back( systemdrawnode( insert_type, insert_size, the_x, the_y, (*systemIter).GetName(),
970  systemIter.getIndex(), screenoccupation, false, isPath ? pathcol : col ) );
971  moused = true;
972  }
973  unsigned destsize = systemIter->GetDestinationSize();
974  if (destsize != 0) {
975  GFXDisable( LIGHTING );
976  GFXDisable( TEXTURE0 );
977  GFXBegin( GFXLINE );
978  for (unsigned i = 0; i < destsize; ++i) {
979  CachedSystemIterator::SystemInfo &oth = systemIter[systemIter->GetDestinationIndex( i )];
980  if ( oth.isDrawable() ) {
981  QVector posoth = oth.Position();
982  ReplaceAxes( posoth );
983  Vector oldposoth = posoth;
984  float the_new_x, the_new_y, new_system_item_scale_temp, the_new_x_flat, the_new_y_flat;
985  //WARNING: SOME VARIABLES FOR ORIGINAL SYSTEM MAY BE MODIFIED HERE!!!
986  TranslateCoordinates( posoth,
987  pos_flat,
988  center_nav_x,
989  center_nav_y,
990  themaxvalue,
991  zscale,
992  zdistance,
993  the_new_x,
994  the_new_y,
995  the_new_x_flat,
996  the_new_y_flat,
997  new_system_item_scale_temp,
998  0 );
999  GFXColor othcol = oth.GetColor();
1000  othcol.a =
1001  (new_system_item_scale_temp
1002  -minimumitemscaledown)/(maximumitemscaleup-minimumitemscaledown)+alphaadd;
1003  //GetAlpha(oldposoth,center_x,center_y,center_z,zdistance);
1004  IntersectBorder( the_new_x, the_new_y, the_x, the_y );
1005 
1006  bool isConnectionPath = false;
1007  if (path_view != PATH_OFF) {
1008  if (systemIter->part_of_path && oth.part_of_path) {
1009  for (std::set< NavPath* >::iterator paths = systemIter->paths.begin();
1010  paths != systemIter->paths.end();
1011  ++paths)
1012  if ( (*paths)->getVisible() ) {
1013  if ( (*paths)->isNeighborPath( temp, systemIter->GetDestinationIndex( i ) ) ) {
1014  isConnectionPath = true;
1015  GFXColorf( pathcol );
1016  GFXVertex3f( the_x, the_y, 0 );
1017  GFXColorf( pathcol );
1018  GFXVertex3f( the_new_x, the_new_y, 0 );
1019  break;
1020  }
1021  }
1022  }
1023  }
1024  if (!isConnectionPath && path_view != PATH_ONLY) {
1025  GFXColorf( col );
1026  GFXVertex3f( the_x, the_y, 0 );
1027  GFXColorf( othcol );
1028  GFXVertex3f( the_new_x, the_new_y, 0 );
1029  }
1030  }
1031  }
1032  GFXEnd();
1033  }
1034  ++systemIter;
1035  }
1036  //**********************************
1037  //Adjust mouse list for 'n' kliks
1038  //**********************************
1039  //STANDARD : (1 3 2) ~ [0] [2] [1]
1040  //VS : (1 2 3) ~ [0] [1] [2] <-- use this
1041  if (mouselist.size() > 0) {
1042  //mouse is over a target when this is > 0
1043  if (mouse_wentdown[2] == 1) //mouse button went down for mouse button 2(standard)
1044  rotations += 1;
1045  }
1046  if ( rotations >= static_cast<int>(mouselist.size()) ) //dont rotate more than there is
1047  rotations = 0;
1048  systemdrawlist tmpv;
1049  int siz = mouselist.size();
1050  for (l = 0; l < siz; ++l)
1051  tmpv.push_back( mouselist[( (unsigned int) (l+rotations) )%( (unsigned int) siz )] );
1052  mouselist.swap( tmpv );
1053  //**********************************
1054  //Give back the selected tail IF there is one
1055  //**********************************
1056  if (mouselist.size() > 0) {
1057  //mouse is over a target when this is > 0
1058  if (mouse_wentdown[0] == 1) {
1059  //mouse button went down for mouse button 1
1060  unsigned oldselection = systemselectionindex;
1061  systemselectionindex = mouselist.back().getIndex();
1062  //JUST FOR NOW, target == current selection. later it'll be used for other shit, that will then set target.
1063  if (systemselectionindex == oldselection)
1064  setFocusedSystemIndex( systemselectionindex );
1065  }
1066  }
1067  //**********************************
1068 
1069  //Clear the lists
1070  //**********************************
1071  {
1072  for (systemdrawlist::iterator it = mouselist.begin(); it != mouselist.end(); ++it)
1073  (*it).draw( true, &(*it) == &mouselist.back() );
1074  }
1075 
1076  mouselist.clear(); //whipe mouse over'd list
1077  //**********************************
1078 }
void NavigationSystem::DrawGrid ( float screen_x1,
float screen_x2,
float screen_y1,
float screen_y2,
const GFXColor col 
)

Definition at line 46 of file navitemstodraw.h.

References VegaConfig::getVariable(), GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXVertex3f(), i, INVSRCALPHA, LIGHTING, XMLSupport::parse_bool(), SRCALPHA, TEXTURE0, and vs_config.

Referenced by Draw().

47 {
48  static bool draw_grid = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "draw_nav_grid", "true" ) );
49  if (!draw_grid)
50  return;
51  GFXColorf( col );
55 
56  float deltax = x2-x1;
57  deltax = deltax/10;
58  float deltay = y2-y1;
59  deltay = deltay/10;
60 
61  GFXBegin( GFXLINE );
62  int i;
63  for (i = 1; i < 10; i++) {
64  GFXVertex3f( x1+(i*deltax), y1, 0 );
65  GFXVertex3f( x1+(i*deltax), y2, 0 );
66  }
67 //GFXEnd();
68 //GFXBegin(GFXLINE);
69  for (i = 1; i < 10; i++) {
70  GFXVertex3f( x1, y1+(i*deltay), 0 );
71  GFXVertex3f( x2, y1+(i*deltay), 0 );
72  }
73  GFXEnd();
75 }
void NavigationSystem::DrawHalfCircleBottom ( float  x,
float  y,
float  size,
const GFXColor col 
)
static

Definition at line 120 of file navitemstodraw.h.

References UniverseUtil::cos(), GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXVertex3f(), i, INVSRCALPHA, LIGHTING, UniverseUtil::sin(), SRCALPHA, and TEXTURE0.

121 {
122  GFXColorf( col );
123  GFXDisable( TEXTURE0 );
124  GFXDisable( LIGHTING );
126 
127  float i = 0.0;
128  GFXBegin( GFXLINE );
129  for ( i = 3.14; i < ( 6.28-(6.28/20) ); i += (6.28/20) ) {
130  GFXVertex3f( ( x+( 0.5*size*cos( i ) ) ), ( (0.25*size)+y+( 0.5*size*sin( i ) ) ), 0 );
131  GFXVertex3f( ( x+( 0.5*size*cos( i+(6.28/20) ) ) ), ( (0.25*size)+y+( 0.5*size*sin( i+(6.28/20) ) ) ), 0 );
132  }
133  GFXEnd();
134  GFXEnable( TEXTURE0 );
135 }
void NavigationSystem::DrawHalfCircleTop ( float  x,
float  y,
float  size,
const GFXColor col 
)
static

Definition at line 100 of file navitemstodraw.h.

References UniverseUtil::cos(), GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXVertex3f(), i, INVSRCALPHA, LIGHTING, UniverseUtil::sin(), SRCALPHA, and TEXTURE0.

Referenced by drawlistitem().

101 {
102  GFXColorf( col );
103  GFXDisable( TEXTURE0 );
104  GFXDisable( LIGHTING );
106 
107  float i = 0.0;
108  GFXBegin( GFXLINE );
109  for ( i = 0; i < ( 3.14-(6.28/20) ); i += (6.28/20) ) {
110  GFXVertex3f( ( x+( 0.5*size*cos( i ) ) ), ( y-(0.25*size)+( 0.5*size*sin( i ) ) ), 0 );
111  GFXVertex3f( ( x+( 0.5*size*cos( i+(6.28/20) ) ) ), ( y-(0.25*size)+( 0.5*size*sin( i+(6.28/20) ) ) ), 0 );
112  }
113  GFXEnd();
114  GFXEnable( TEXTURE0 );
115 }
void NavigationSystem::DrawJump ( float  x,
float  y,
float  size,
const GFXColor col 
)
static

Definition at line 194 of file navitemstodraw.h.

References UniverseUtil::cos(), GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXVertex3f(), i, INVSRCALPHA, LIGHTING, UniverseUtil::sin(), SRCALPHA, and TEXTURE0.

Referenced by drawlistitem().

195 {
196  GFXColorf( col );
197  GFXDisable( TEXTURE0 );
198  GFXDisable( LIGHTING );
200 
201  float i = 0.0;
202  GFXBegin( GFXLINE );
203  for ( i = 0; i < 6.28; i += (6.28/20) ) {
204  GFXVertex3f( ( x+( 0.5*size*cos( i ) ) ), ( y+( 0.5*size*sin( i ) ) ), 0 );
205  GFXVertex3f( ( x+( 0.5*size*cos( i+(6.28/20) ) ) ), ( y+( 0.5*size*sin( i+(6.28/20) ) ) ), 0 );
206  }
207  GFXVertex3f( x, float( y+(0.5*size) ), 0 );
208  GFXVertex3f( ( x+(0.125*size) ), ( y+(0.125*size) ), 0 );
209 
210  GFXVertex3f( x, float( y+(0.5*size) ), 0 );
211  GFXVertex3f( ( x-(0.125*size) ), ( y+(0.125*size) ), 0 );
212 
213  GFXVertex3f( x, float( y-(0.5*size) ), 0 );
214  GFXVertex3f( ( x+(0.125*size) ), ( y-(0.125*size) ), 0 );
215 
216  GFXVertex3f( x, float( y-(0.5*size) ), 0 );
217  GFXVertex3f( ( x-(0.125*size) ), ( y-(0.125*size) ), 0 );
218 
219  GFXVertex3f( float( x-(0.5*size) ), y, 0 );
220  GFXVertex3f( ( x-(0.125*size) ), ( y+(0.125*size) ), 0 );
221 
222  GFXVertex3f( float( x-(0.5*size) ), y, 0 );
223  GFXVertex3f( ( x-(0.125*size) ), ( y-(0.125*size) ), 0 );
224 
225  GFXVertex3f( float( x+(0.5*size) ), y, 0 );
226  GFXVertex3f( ( x+(0.125*size) ), ( y+(0.125*size) ), 0 );
227 
228  GFXVertex3f( float( x+(0.5*size) ), y, 0 );
229  GFXVertex3f( ( x+(0.125*size) ), ( y-(0.125*size) ), 0 );
230 
231  GFXEnd();
232  GFXEnable( TEXTURE0 );
233 }
void NavigationSystem::DrawMissile ( float  x,
float  y,
float  size,
const GFXColor col 
)
static

Definition at line 239 of file navitemstodraw.h.

References GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXVertex3f(), INVSRCALPHA, LIGHTING, SRCALPHA, and TEXTURE0.

Referenced by drawlistitem().

240 {
241  GFXColorf( col );
242  GFXDisable( TEXTURE0 );
243  GFXDisable( LIGHTING );
245 
246  GFXBegin( GFXLINE );
247  GFXVertex3f( ( x-(0.5*size) ), ( y-(0.125*size) ), 0 );
248  GFXVertex3f( x, float( y+(0.375*size) ), 0 );
249 
250  GFXVertex3f( ( x+(0.5*size) ), ( y-(0.125*size) ), 0 );
251  GFXVertex3f( x, float( y+(0.375*size) ), 0 );
252 
253  GFXVertex3f( ( x-(0.25*size) ), ( y-(0.125*size) ), 0 );
254  GFXVertex3f( ( x-(0.25*size) ), ( y+(0.125*size) ), 0 );
255 
256  GFXVertex3f( ( x+(0.25*size) ), ( y-(0.125*size) ), 0 );
257  GFXVertex3f( ( x+(0.25*size) ), ( y+(0.125*size) ), 0 );
258 
259  GFXVertex3f( ( x-(0.25*size) ), ( y+(0.125*size) ), 0 );
260  GFXVertex3f( x, float( y-(0.125*size) ), 0 );
261 
262  GFXVertex3f( ( x+(0.25*size) ), ( y+(0.125*size) ), 0 );
263  GFXVertex3f( x, float( y-(0.125*size) ), 0 );
264  GFXEnd();
265 
266  GFXEnable( TEXTURE0 );
267 }
void NavigationSystem::DrawMission ( )

Definition at line 502 of file navscreen.cpp.

References _Universe, Universe::AccessCockpit(), active_missions, TextPlane::col, colors, Delta(), TextPlane::Draw(), drawdescription(), UniverseUtil::getCurrentPlayer(), FactionUtil::GetFactionName(), SaveGame::getMissionData(), FactionUtil::GetNumFactions(), UniverseUtil::getPlayerX(), UnitUtil::getRelationFromFaction(), FactionUtil::GetSparkColor(), VegaConfig::getVariable(), GFXBlendMode(), GFXDisable(), GFXEnable(), i, int, INVSRCALPHA, j, LIGHTING, Cockpit::savegame, TextPlane::SetCharSize(), TextPlane::SetPos(), TextPlane::SetSize(), TextPlane::SetText(), size, SRCALPHA, TEXTURE0, XMLSupport::tostring(), and vs_config.

Referenced by Draw().

503 {
504  GFXDisable( TEXTURE0 );
505  GFXDisable( LIGHTING );
507 
508  navdrawlist factionlist( 0, screenoccupation, factioncolours );
509 
510  float deltax = screenskipby4[1]-screenskipby4[0];
511  float deltay = screenskipby4[3]-screenskipby4[2];
512  float originx = screenskipby4[0]; //left
513  float originy = screenskipby4[3]; //top
514  vector< float > *killlist = &_Universe->AccessCockpit()->savegame->getMissionData( string( "kills" ) );
515  string relationskills = "Relations";
516  if (killlist->size() > 0)
517  relationskills += " | Kills";
518  drawdescription( relationskills, ( originx+(0.1*deltax) ), (originy), 1, 1, 0, screenoccupation, GFXColor( .3, 1, .3, 1 ) );
519  drawdescription( " ", ( originx+(0.1*deltax) ), (originy), 1, 1, 0, screenoccupation, GFXColor( .3, 1, .3, 1 ) );
520 
521  drawdescription( " ", ( originx+(0.3*deltax) ), (originy), 1, 1, 0, screenoccupation, GFXColor( .3, 1, .3, 1 ) );
522  drawdescription( " ", ( originx+(0.3*deltax) ), (originy), 1, 1, 0, screenoccupation, GFXColor( .3, 1, .3, 1 ) );
523 
524  size_t numfactions = FactionUtil::GetNumFactions();
525  size_t i = 0;
526  string factionname = "factionname";
527  float relation = 0.0;
528  static string disallowedFactions = vs_config->getVariable( "graphics", "unprintable_factions", "" );
529  static string disallowedExtension = vs_config->getVariable( "graphics", "unprintable_faction_extension", "citizen" );
530  int totkills = 0;
531  size_t fac_loc_before = 0, fac_loc = 0, fac_loc_after = 0;
532  for (; i < numfactions; ++i) {
533  factionname = FactionUtil::GetFactionName( i );
534  if (factionname != "neutral" && factionname != "privateer" && factionname != "planets" && factionname != "upgrades") {
535  if ( i < killlist->size() )
536  totkills += (int) (*killlist)[i];
537  if (factionname.find( disallowedExtension ) != string::npos)
538  continue;
539  fac_loc_after = 0;
540  fac_loc = disallowedFactions.find( factionname, fac_loc_after );
541  while (fac_loc != string::npos) {
542  fac_loc_before = fac_loc-1;
543  if (fac_loc_before < 0)
544  fac_loc_before = 0;
545  fac_loc_after = fac_loc+factionname.size();
546  if ( (fac_loc == 0 || disallowedFactions[fac_loc_before] == ' ' || disallowedFactions[fac_loc_before]
547  == '\t')
548  && (disallowedFactions[fac_loc_after] == ' ' || disallowedFactions[fac_loc_after] == '\t'
549  || disallowedFactions[fac_loc_after] == '\0') )
550  break;
551  fac_loc = disallowedFactions.find( factionname, fac_loc_after );
552  }
553  if (fac_loc != string::npos)
554  continue;
556 
557  //draw faction name
558  const float *colors = FactionUtil::GetSparkColor( i );
560  i ), ( originx+(0.1*deltax) ), (originy), 1, 1, 0, screenoccupation,
561  GFXColor( colors[0], colors[1], colors[2], 1. ) );
562 
563  float relation01 = relation*0.5+0.5;
564  relation = ( (relation > 1 ? 1 : relation) < -1 ? -1 : relation );
565  int percent = (int) (relation*100.0);
566  string relationtext( XMLSupport::tostring( percent ) );
567  if ( i < killlist->size() ) {
568  relationtext += " | ";
569  relationtext += XMLSupport::tostring( (int) (*killlist)[i] );
570  }
571  drawdescription( relationtext, ( originx+(0.3*deltax) ), (originy), 1, 1, 0, screenoccupation,
572  GFXColor( (1.0-relation01), (relation01), ( 1.0-( 2.0*Delta( relation01, 0.5 ) ) ), 1 ) );
573  }
574  }
575  string relationtext( "Total Kills: " );
576  relation = 1;
577 
578  relationtext += XMLSupport::tostring( totkills );
579  drawdescription( relationtext, ( originx+(0.2*deltax) ), ( originy-(0.95*deltay) ), 1, 1, 0, screenoccupation,
580  GFXColor( (1.0-relation), relation, ( 1.0-( 2.0*Delta( relation, 0.5 ) ) ), 1 ) );
581 
582 //drawdescription(" Terran : ", (originx + (0.1*deltax)),(originy - (0.1*deltay)), 1, 1, 0, screenoccupation, GFXColor(.3,1,.3,1));
583 //drawdescription(" Rlaan : ", (originx + (0.1*deltax)),(originy - (0.1*deltay)), 1, 1, 0, screenoccupation, GFXColor(1,.3,.3,1));
584 //drawdescription(" Aera : ", (originx + (0.1*deltax)),(originy - (0.1*deltay)), 1, 1, 0, screenoccupation, GFXColor(.3,.3,1,1));
585 
586 //float love_from_terran = FactionUtil::getRelation(1);
587 //float love_from_rlaan = FactionUtil::getRelation(2);
588 //float love_from_aera = FactionUtil::getRelation(3);
589 
590  TextPlane displayname;
591  displayname.col = GFXColor( 1, 1, 1, 1 );
592  displayname.SetSize( .42, -.7 );
593  displayname.SetPos( originx+(.1*deltax)+.37, originy /*+(1*deltay)*/ );
594  std::string text;
595  if (active_missions.size() > 1) {
596  for (unsigned int i = 1; i < active_missions.size(); ++i) {
597  text += active_missions[i]->mission_name+":\n";
598  for (unsigned int j = 0; j < active_missions[i]->objectives.size(); ++j)
599  text += active_missions[i]->objectives[j].objective+": "
600  +XMLSupport::tostring( (int) (active_missions[i]->objectives[j].completeness*100) )+"%\n";
601  }
602  text += "\n";
603  }
604  text +=
605  "#FFA000 PRESS SHIFT-M TO TOGGLE THIS MENU \n\n\n\n#000000*******#00a6FFVega Strike 0.5#000000*********\nWelcome to VS. Your ship undocks stopped; #8080FFArrow keys/mouse/joystick#000000 steer your ship. Use #8080FF+#000000 & #8080FF-#000000 to adjust cruise control, or #8080FF/#000000 & #8080FF[backspace]#000000 to go to max governor setting or full-stop, respectively. Use #8080FFy#000000 to toggle between maneuver and travel settings for your relative velocity governors. Use #8080ff[home]#000000 & #8080FF[end]#000000 to set and unset velocity reference point to the current target (non-hostile targets only). Use #8080FFTab#000000 to activate Overdrive(if present).\n\nPress #8080FFn#000000 to cycle nav points, #8080FFt#000000 to cycle targets, and #8080FFp#000000 to target objects in front of you.\n\n#8080FF[space]#000000 fires guns, and #8080ff[Enter]#000000 fires missiles.\n\nThe #8080FFa#000000 key activates SPEC drive for insystem FTL.\nInterstellar Travel requires a #FFBB11 jump drive#000000 and #FFBB11FTL Capacitors#000000 to be installed. To jump, fly into the green wireframe nav-marker; hit #8080FFj#000000 to jump to the linked system.\n\nTo dock, target a base, planet or large vessel and hail with #8080FF0#000000 to request docking clearance. When you get close, a green box will appear. Fly to the box. When inside the box, #8080FFd#000000 will dock.\n\n#FF0000If Vega Strike halts or acts oddly,#000000\n#FFFF00immediately#000000 post stderr.txt & stdout.txt\nto http://vegastrike.sourceforge.net/forums\nbefore you restart Vega Strike.\n";
606  displayname.SetText( text );
607  displayname.SetCharSize( 1, 1 );
608  displayname.Draw();
609 /*
610  * string exitinfo("To exit help press #8080FFshift-M#000000\n#8080FFShift-M#000000 will bring up this\nhelp menu any time.\nThe right buttons access the galaxy and system maps");
611  *
612  * displayname.SetSize (.6,-.8);
613  * displayname.SetPos(originx-.02, originy-1.2);
614  * displayname.SetText (exitinfo);
615  * displayname.SetCharSize (1,1);
616  * displayname.Draw();*/
617  GFXEnable( TEXTURE0 );
618 }
void NavigationSystem::DrawNavCircle ( float  x,
float  y,
float  rot_x,
float  rot_y,
float  size,
const GFXColor col 
)
static

Definition at line 312 of file navitemstodraw.h.

References GFXColor::a, GFXColor::b, UniverseUtil::cos(), dxyz(), float, GFXColor::g, GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXVertex3f(), i, INVSRCALPHA, j, LIGHTING, QVector, GFXColor::r, UniverseUtil::sin(), size, SRCALPHA, TEXTURE0, x, and y.

Referenced by Draw().

313 {
314  GFXColorf( col );
315  GFXDisable( TEXTURE0 );
316  GFXDisable( LIGHTING );
318 
319  float alpha = 0.15;
320  int circles = 4;
321 
322  float i = 0.0;
323  GFXBegin( GFXLINE );
324  float segments = 20.0;
325  for ( i = 0; i < 6.28; i += (6.28/segments) ) {
326  QVector pos1( ( 0.6*size*cos( i ) ), ( 0.6*size*sin( i ) ), 0 );
327  QVector pos2( ( 0.6*size*cos( i+(6.28/segments) ) ), ( 0.6*size*sin( i+(6.28/segments) ) ), 0 );
328  pos1 = dxyz( pos1, 0, 0, rot_y );
329  pos1 = dxyz( pos1, rot_x, 0, 0 );
330 
331  pos2 = dxyz( pos2, 0, 0, rot_y );
332  pos2 = dxyz( pos2, rot_x, 0, 0 );
333 
334  float standard_unit = 0.25*1.2*size;
335  float zdistance1 = ( (1.2*size)-pos1.k );
336  float zdistance2 = ( (1.2*size)-pos2.k );
337  float zscale1 = standard_unit/zdistance1;
338  float zscale2 = standard_unit/zdistance2;
339  pos1 *= (zscale1*5.0);
340  pos2 *= (zscale2*5.0);
341  //pos1 *= (-0.6*size)/((pos1.k) + (0.6*size));
342  //pos2 *= (-0.6*size)/((pos2.k) + (0.6*size));
343 
344  GFXColorf( GFXColor( col.r, col.g, ( col.b*fabs( sin( i/2.0 ) ) ), col.a ) );
345  for (int j = circles; j > 0; j--) {
346  pos1 *= ( float(j)/float(circles) );
347  pos2 *= ( float(j)/float(circles) );
348 
349  QVector pos1t( (x+pos1.i), ( y+(pos1.j) ), 0 );
350  QVector pos2t( (x+pos2.i), ( y+(pos2.j) ), 0 );
351 
352  GFXVertex3f( pos1t.i, pos1t.j, 0.0 );
353  GFXVertex3f( pos2t.i, pos2t.j, 0.0 );
354  }
355  }
356  for ( i = 0; i < 6.28; i += (6.28/12.0) ) {
357  QVector pos1( ( 0.6*size*cos( i )/float(circles*2) ), ( 0.6*size*sin( i )/float(circles*2) ), 0 );
358  QVector pos2( ( 0.6*size*cos( i ) ), ( 0.6*size*sin( i ) ), 0 );
359  if ( (fabs( i-1.57 ) < 0.01) || (fabs( i-3.14 ) < 0.01) || (fabs( i-4.71 ) < 0.01) || (i < 0.01) )
360  pos2 *= 1.1;
361  pos1 = dxyz( pos1, 0, 0, rot_y );
362  pos1 = dxyz( pos1, rot_x, 0, 0 );
363 
364  pos2 = dxyz( pos2, 0, 0, rot_y );
365  pos2 = dxyz( pos2, rot_x, 0, 0 );
366 
367  float standard_unit = 0.25*1.2*size;
368  float zdistance1 = ( (1.2*size)-pos1.k );
369  float zdistance2 = ( (1.2*size)-pos2.k );
370  float zscale1 = standard_unit/zdistance1;
371  float zscale2 = standard_unit/zdistance2;
372  pos1 *= (zscale1*5.0);
373  pos2 *= (zscale2*5.0);
374 //pos1 *= (pos1.k + size)/size;
375 //pos2 *= (pos2.k + size)/size;
376 
377 //pos1.j *= 1.33333;
378 //pos2.j *= 1.33333;
379 
380  pos1.i += x;
381  pos1.j += y;
382  pos2.i += x;
383  pos2.j += y;
384 
385  GFXColorf( GFXColor( col.r, col.g, ( col.b*fabs( sin( i/2.0 ) ) ), col.a ) );
386 
387  GFXVertex3f( pos1.i, pos1.j, 0.0 );
388  GFXVertex3f( pos2.i, pos2.j, 0.0 );
389  }
390  GFXEnd();
391  GFXEnable( TEXTURE0 );
392 }
void NavigationSystem::DrawObjectives ( )

Definition at line 819 of file navscreen.cpp.

References _Universe, Universe::AccessCockpit(), checkbit(), DrawObjectivesTextPlane(), and Cockpit::GetParent().

Referenced by Draw().

820 {
821  if ( checkbit( whattodraw, 4 ) )
822  //Draw the objectives screen!
823  DrawObjectivesTextPlane( &screen_objectives, scrolloffset, _Universe->AccessCockpit()->GetParent() );
824 }
void NavigationSystem::DrawPlanet ( float  x,
float  y,
float  size,
const GFXColor col 
)
static

Definition at line 140 of file navitemstodraw.h.

References UniverseUtil::cos(), GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXVertex3f(), i, INVSRCALPHA, LIGHTING, UniverseUtil::sin(), SRCALPHA, and TEXTURE0.

Referenced by drawlistitem().

141 {
142  GFXColorf( col );
143  GFXDisable( TEXTURE0 );
144  GFXDisable( LIGHTING );
146 
147  float i = 0.0;
148  GFXBegin( GFXLINE );
149  for ( i = 0; i < 6.28; i += (6.28/20) ) {
150  GFXVertex3f( ( x+( 0.5*size*cos( i ) ) ), ( y+( 0.5*size*sin( i ) ) ), 0 );
151  GFXVertex3f( ( x+( 0.5*size*cos( i+(6.28/20) ) ) ), ( y+( 0.5*size*sin( i+(6.28/20) ) ) ), 0 );
152  }
153  GFXVertex3f( float( x-(0.5*size) ), float(y), 0 );
154  GFXVertex3f( float(x), float( y+(0.2*size) ), 0 );
155 
156  GFXVertex3f( float(x), float( y+(0.2*size) ), 0 );
157  GFXVertex3f( float(x), float( y-(0.2*size) ), 0 );
158 
159  GFXVertex3f( float(x), float( y-(0.2*size) ), 0 );
160  GFXVertex3f( float( x+(0.5*size) ), float(y), 0 );
161 
162  GFXEnd();
163  GFXEnable( TEXTURE0 );
164 }
void NavigationSystem::DrawSectorList ( )

Definition at line 660 of file navscreen.cpp.

References Beautify(), NavigationSystem::CachedSectorIterator::done(), drawdescription(), NavigationSystem::CachedSectorIterator::getIndex(), NavigationSystem::CachedSectorIterator::SectorInfo::GetName(), NavigationSystem::CachedSectorIterator::SectorInfo::GetSubsystemIndex(), NavigationSystem::CachedSectorIterator::SectorInfo::GetSubsystemSize(), GFXBlendMode(), GFXDisable(), height, i, index, INVSRCALPHA, LIGHTING, NavigationSystem::CachedSectorIterator::seek(), NavigationSystem::CachedSectorIterator::size(), SRCALPHA, TestIfInRange(), TEXTURE0, and width.

Referenced by Draw().

661 {
662  GFXDisable( TEXTURE0 );
663  GFXDisable( LIGHTING );
665 
666  float deltax = screenskipby4[1]-screenskipby4[0];
667  float deltay = screenskipby4[3]-screenskipby4[2];
668  float originx = screenskipby4[0]; //left
669  float originy = screenskipby4[3]; //top
670  float width = (deltax/6);
671  float height = (0.031*deltay);
672  const unsigned numRows = 26;
673  float the_x, the_y, the_x1, the_y1, the_x2, the_y2;
674  GFXColor color;
675  unsigned count, index, row;
676 
677  //Draw Title of Column
678  drawdescription( "Sectors", originx+(0.5*width), originy-(0.0*deltay), 1, 1, 1, screenoccupation,
679  GFXColor( .3, 1, .3, 1 ) );
680 
681  //Draw Scroll Pieces
682  color = GFXColor( 0.7, 0.3, 0.3, 1.0 );
683 
684  the_x = width*(0.5)+originx;
685  the_y = originy-(0.05*deltay);
686  the_x1 = the_x-width/2;
687  the_y1 = the_y-height;
688  the_x2 = the_x+width/2;
689  the_y2 = the_y;
690  if ( TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
691  if (mouse_wentdown[0] == 1) //mouse button went down for mouse button 1
692  if (sectorOffset > 0)
693  --sectorOffset;
694  }
695  drawdescription( "Up", the_x, the_y, 1, 1, 1, screenoccupation, color );
696 
697  the_x = width*(0.5)+originx;
698  the_y = originy-(0.05*deltay)-height*(29);
699  the_x1 = the_x-width/2;
700  the_y1 = the_y-height;
701  the_x2 = the_x+width/2;
702  the_y2 = the_y;
703  if ( TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
704  if (mouse_wentdown[0] == 1) //mouse button went down for mouse button 1
705  if ( sectorOffset < (sectorIter.size()-numRows) )
706  ++sectorOffset;
707  }
708  drawdescription( "Down", the_x, the_y, 1, 1, 1, screenoccupation, color );
709 
710  count = 0;
711  for (sectorIter.seek(); !sectorIter.done(); ++sectorIter) {
712  bool drawable = false;
713  for (unsigned i = 0; i < sectorIter->GetSubsystemSize(); i++)
714  if ( systemIter[sectorIter->GetSubsystemIndex( i )].isDrawable() ) {
715  drawable = true;
716  break;
717  }
718  if (!drawable)
719  continue;
720  if ( ( (count-sectorOffset) < 0 ) || ( (count-sectorOffset) >= numRows ) ) {
721  ++count;
722  continue;
723  }
724  row = (count-sectorOffset)%numRows;
725  the_x = width*(0.5)+originx;
726  the_y = originy-(0.05*deltay)-height*(row+2);
727  the_x1 = the_x-width/2;
728  the_y1 = the_y-height;
729  the_x2 = the_x+width/2;
730  the_y2 = the_y;
731  if ( TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
732  if (mouse_wentdown[0] == 1) {
733  //mouse button went down for mouse button 1
734  sectorselectionindex = sectorIter.getIndex();
735  systemOffset = 0;
736  }
737  }
738  if (sectorIter.getIndex() == sectorselectionindex)
739  color = selectcol;
740  else
741  color = GFXColor( 0.7, 0.3, 0.3, 1.0 );
742  drawdescription( sectorIter->GetName(), the_x, the_y, 1, 1, 1, screenoccupation, color );
743  ++count;
744  }
745  drawdescription( "Systems", originx+(1.5)*width, originy-(0.0*deltay), 1, 1, 1, screenoccupation,
746  GFXColor( .3, 1, .3, 1 ) );
747 
748  //Draw Scroll Pieces
749  color = GFXColor( 0.7, 0.3, 0.3, 1.0 );
750 
751  the_x = width*(1.5)+originx;
752  the_y = originy-(0.05*deltay);
753  the_x1 = the_x-width/2;
754  the_y1 = the_y-height;
755  the_x2 = the_x+width/2;
756  the_y2 = the_y;
757  if ( TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
758  if (mouse_wentdown[0] == 1) //mouse button went down for mouse button 1
759  if (systemOffset > 0)
760  --systemOffset;
761  }
762  drawdescription( "Up", the_x, the_y, 1, 1, 1, screenoccupation, color );
763 
764  the_x = width*(1.5)+originx;
765  the_y = originy-(0.05*deltay)-height*(29);
766  the_x1 = the_x-width/2;
767  the_y1 = the_y-height;
768  the_x2 = the_x+width/2;
769  the_y2 = the_y;
770  if ( TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
771  if (mouse_wentdown[0] == 1) //mouse button went down for mouse button 1
772  if ( systemOffset < (sectorIter[sectorselectionindex].GetSubsystemSize()-numRows) )
773  ++systemOffset;
774  }
775  drawdescription( "Down", the_x, the_y, 1, 1, 1, screenoccupation, color );
776 
777  count = 0;
778  sectorIter.seek( sectorselectionindex );
779  for (unsigned i = 0; i < sectorIter->GetSubsystemSize(); ++i) {
780  index = sectorIter->GetSubsystemIndex( i );
781  if ( !systemIter[index].isDrawable() )
782  continue;
783  if ( ( (count-systemOffset) < 0 ) || ( (count-systemOffset) >= numRows ) ) {
784  ++count;
785  continue;
786  }
787  row = (count-systemOffset)%numRows;
788  the_x = width*(1.5)+originx;
789  the_y = originy-(0.05*deltay)-height*(row+2);
790  the_x1 = the_x-width/2;
791  the_y1 = the_y-height;
792  the_x2 = the_x+width/2;
793  the_y2 = the_y;
794  if ( TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
795  if (mouse_wentdown[0] == 1) {
796  //mouse button went down for mouse button 1
797  unsigned oldselection = systemselectionindex;
798  systemselectionindex = index;
799  if (systemselectionindex == oldselection)
800  setFocusedSystemIndex( systemselectionindex );
801  }
802  }
803  if (index == destinationsystemindex)
804  color = destinationcol;
805  else if (index == focusedsystemindex)
806  color = currentcol;
807  else if (index == systemselectionindex)
808  color = selectcol;
809  else
810  color = GFXColor( 0.7, 0.3, 0.3, 1.0 );
811  string csector, csystem;
812  Beautify( systemIter[index].GetName(), csector, csystem );
813 
814  drawdescription( csystem, the_x, the_y, 1, 1, 1, screenoccupation, color );
815  ++count;
816  }
817 }
void NavigationSystem::DrawShip ( )

Definition at line 624 of file navscreen.cpp.

References _Universe, Universe::AccessCockpit(), TextPlane::col, Cockpit::GetParent(), VegaConfig::getVariable(), GFXBlendMode(), GFXDisable(), GFXEnable(), INVSRCALPHA, LIGHTING, MakeUnitXMLPretty(), XMLSupport::parse_float(), SRCALPHA, TEXTURE0, vs_config, and Unit::WriteUnitString().

Referenced by Draw().

625 {
626  GFXDisable( TEXTURE0 );
627  GFXDisable( LIGHTING );
629 
630  navdrawlist factionlist( 0, screenoccupation, factioncolours );
631 
632  float deltax = screenskipby4[1]-screenskipby4[0];
633  float deltay = screenskipby4[3]-screenskipby4[2];
634  float originx = screenskipby4[0]; //left
635  float originy = screenskipby4[3]; //top
636  string writethis;
637  Unit *par;
638  int foundpos = 0;
639  if ( ( par = _Universe->AccessCockpit()->GetParent() ) )
640  writethis = MakeUnitXMLPretty( par->WriteUnitString(), par );
641  TextPlane displayname;
642  displayname.col = GFXColor( .3, 1, .3, 1 );
643  displayname.SetSize( .7, -.8 );
644  displayname.SetPos( originx-(.1*deltax), originy /*+(1*deltay)*/ );
645  displayname.SetText( writethis );
646  displayname.SetCharSize( 1, 1 );
647  static float background_alpha =
648  XMLSupport::parse_float( vs_config->getVariable( "graphics", "hud", "text_background_alpha", "0.0625" ) );
649  GFXColor tpbg = displayname.bgcol;
650  bool automatte = (0 == tpbg.a);
651  if (automatte) displayname.bgcol = GFXColor( 0, 0, 0, background_alpha );
652  displayname.Draw( writethis, 0, true, false, automatte );
653  displayname.bgcol = tpbg;
654 
655 //factionlist.drawdescription(writethis, (originx + (0.1*deltax)),(originy - (0.1*deltay)), 1, 1, 1, GFXColor(1,1,1,1));
656 
657  GFXEnable( TEXTURE0 );
658 }
void NavigationSystem::DrawStation ( float  x,
float  y,
float  size,
const GFXColor col 
)
static

Definition at line 169 of file navitemstodraw.h.

References GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXVertex3f(), i, INVSRCALPHA, LIGHTING, SRCALPHA, and TEXTURE0.

Referenced by drawlistitem().

170 {
171  GFXColorf( col );
172  GFXDisable( TEXTURE0 );
173  GFXDisable( LIGHTING );
175 
176  float segment = size/3;
177  GFXBegin( GFXLINE );
178  int i;
179  for (i = 0; i < 4; i++) {
180  GFXVertex3f( ( x-(0.5*size) ), ( ( y-(0.5*size) )+(i*segment) ), 0 );
181  GFXVertex3f( ( x+(0.5*size) ), ( ( y-(0.5*size) )+(i*segment) ), 0 );
182  }
183  for (i = 0; i < 4; i++) {
184  GFXVertex3f( ( ( x-(0.5*size) )+(i*segment) ), ( y-(0.5*size) ), 0 );
185  GFXVertex3f( ( ( x-(0.5*size) )+(i*segment) ), ( y+(0.5*size) ), 0 );
186  }
187  GFXEnd();
188  GFXEnable( TEXTURE0 );
189 }
void NavigationSystem::DrawSystem ( )

Definition at line 48 of file drawsystem.cpp.

References _Universe, Universe::AccessCockpit(), Universe::activeStarSystem(), ASTEROIDPTR, TextPlane::bgcol, blah, bleh, checkbit(), TextPlane::col, TextPlane::Draw(), navdrawlist::draw(), drawlistitem(), DrawTargetCorners(), StarSystemGent::faction, float, navdrawlist::get_n_contents(), VegaConfig::getColor(), UniverseUtil::getCurrentPlayer(), FactionUtil::GetFactionIndex(), FactionUtil::GetFactionName(), StarSystem::getFileName(), UniverseUtil::GetGalaxyFaction(), StarSystem::getName(), Cockpit::GetParent(), UniverseUtil::getPlayerX(), getStarSystemSector(), navdrawlist::gettailunit(), UnitContainer::GetUnit(), UniverseUtil::getUnitList(), VegaConfig::getVariable(), Unit::InRange(), navdrawlist::insert(), UnitUtil::isPlayerStarship(), UnitUtil::isSignificant(), UnitUtil::isSun(), MISSILEPTR, navambiguous, navambiguoussize, navasteroid, navasteroidsize, navcapship, navcapshipsize, navfighter, navfightersize, navjump, navjumpsize, navmissile, navmissilesize, navnebula, navnebulasize, navplanet, navplanetsize, navstation, navstationsize, navsun, navsunsize, NEBULAPTR, XMLSupport::parse_float(), PLANETPTR, QVector, navdrawlist::rotate(), TextPlane::SetPos(), TextPlane::SetText(), UniverseUtil::sqrt(), StarSystemGent::systemname, Unit::Target(), TestIfInRange(), TestIfInRangeBlk(), TestIfInRangeRad(), UNITPTR, unsetbit(), vs_config, and navdrawlist::wipe().

Referenced by Draw().

49 {
51  if ( !(*bleh) )
52  return;
53 //string mystr ("3d "+XMLSupport::tostring (system_view));
54 //UniverseUtil::IOmessage (0,"game","all",mystr);
55 
56  //what's my name
57  //***************************
58  TextPlane systemname; //will be used to display shits names
60  //GFXColor factioncolor = factioncolours[faction];
61  string systemnamestring = "#ff0000Sector: #ffff00"+getStarSystemSector( _Universe->activeStarSystem()->getFileName() )
62  +" #ff0000Current System: #ffff00"+_Universe->activeStarSystem()->getName()+" ("
63  +FactionUtil::GetFactionName( faction )
64  +"#ffff00)";
65  //int length = systemnamestring.size();
66  //float offset = (float(length)*0.001);
67  //systemname.SetPos( (((screenskipby4[0]+screenskipby4[1])/2)-offset) , screenskipby4[3]); // middle position
68  systemname.SetPos( screenskipby4[0]+0.03, screenskipby4[3]+0.02 ); //left position
69  systemname.col = GFXColor( 1, 1, .7, 1 );
70  systemname.SetText( systemnamestring );
71 //systemname.SetCharSize(1, 1);
72  static float background_alpha =
73  XMLSupport::parse_float( vs_config->getVariable( "graphics", "hud", "text_background_alpha", "0.0625" ) );
74  GFXColor tpbg = systemname.bgcol;
75  bool automatte = (0 == tpbg.a);
76  if (automatte) systemname.bgcol = GFXColor( 0, 0, 0, background_alpha );
77  systemname.Draw( systemnamestring, 0, true, false, automatte );
78  systemname.bgcol = tpbg;
79  //***************************
80 
81 //navdrawlist mainlist(0, screenoccupation, factioncolours); // lists of items to draw
82 //mainlist.unselectedalpha = unselectedalpha;
83  navdrawlist mouselist( 1, screenoccupation, factioncolours ); //lists of items to draw that are in mouse range
84 
85  QVector pos; //item position
86  QVector pos_flat; //item position flat on plane
87 
88  float zdistance = 0.0;
89  float zscale = 0.0;
90 
91  Adjust3dTransformation( system_view == VIEW_3D, 1 );
92  //Set up first item to compare to + centres
93  //**********************************
94  while ( (*bleh) && ( _Universe->AccessCockpit()->GetParent() != (*bleh) )
95  && ( UnitUtil::isSun( *bleh ) || !UnitUtil::isSignificant( *bleh ) ) ) //no sun's in initial setup
96  ++bleh;
97  if ( !(*bleh) ) //nothing there that's significant, just do it all
99  //GET THE POSITION
100  //*************************
101  pos = (*bleh)->Position();
102  ReplaceAxes( pos );
103  //*************************
104 
105  //Modify by old rotation amount
106  //*************************
107 //if(system_view==VIEW_3D)
108 //{
109 //pos = dxyz(pos, 0, ry_s, 0);
110 //pos = dxyz(pos, rx_s, 0, 0);
111 //}
112  //*************************
113 
114  float max_x = (float) pos.i;
115  float min_x = (float) pos.i;
116  float max_y = (float) pos.j;
117  float min_y = (float) pos.j;
118  float max_z = (float) pos.k;
119  float min_z = (float) pos.k;
120 
121 //float themaxvalue = fabs(pos.i);
122  themaxvalue = 0.0;
123 
124  float center_nav_x = ( (screenskipby4[0]+screenskipby4[1])/2 );
125  float center_nav_y = ( (screenskipby4[2]+screenskipby4[3])/2 );
126  //**********************************
127  //Retrieve unit data min/max
128  //**********************************
129  while (*bleh) {
130  //this goes through one time to get the major components locations, and scales its output appropriately
131  if ( UnitUtil::isSun( *bleh ) ) {
132  ++bleh;
133  continue;
134  }
135  string temp = (*bleh)->name;
136  pos = (*bleh)->Position();
137  ReplaceAxes( pos );
138  //Modify by old rotation amount
139  //*************************
140 //if(system_view==VIEW_3D)
141 //{
142 //pos = dxyz(pos, 0, ry_s, 0);
143 //pos = dxyz(pos, rx_s, 0, 0);
144 //}
145  //*************************
146  //*************************
147  if ( ( UnitUtil::isSignificant( *bleh ) ) || ( _Universe->AccessCockpit()->GetParent() == (*bleh) ) )
148  RecordMinAndMax( pos, min_x, max_x, min_y, max_y, min_z, max_z, themaxvalue );
149  ++bleh;
150  }
151  //**********************************
152 
153  //Find Centers
154  //**********************************
155  center_x = (min_x+max_x)/2;
156  center_y = (min_y+max_y)/2;
157  center_z = (min_z+max_z)/2;
158  //**********************************
159 
160  max_x = 2*max_x-center_x;
161  max_y = 2*max_y-center_y;
162  max_z = 2*max_z-center_z;
163  min_x = 2*min_x-center_x;
164  min_y = 2*min_y-center_y;
165  min_z = 2*min_z-center_z;
166 
167  themaxvalue *= 2;
168 
169 //#define SQRT3 1.7320508
170 //themaxvalue = sqrt(themaxvalue*themaxvalue + themaxvalue*themaxvalue + themaxvalue*themaxvalue);
171 //themaxvalue = SQRT3*themaxvalue;
172 
173  //Set Camera Distance
174  //**********************************
175 //{
176  float half_x = (max_x-min_x);
177  float half_y = (max_y-min_y);
178  float half_z = (max_z-min_z);
179 
180  camera_z = sqrt( (half_x*half_x)+(half_y*half_y)+(half_z*half_z) );
181 
182 //float halfmax = 0.5*themaxvalue;
183 //camera_z = sqrt( (halfmax*halfmax) + (halfmax*halfmax) + (halfmax*halfmax) );
184 //camera_z = 4.0*themaxvalue;
185 //}
186 
187  //**********************************
188 
189  DrawOriginOrientationTri( center_nav_x, center_nav_y, 1 );
190 
191 /*
192  * string mystr ("max x "+XMLSupport::tostring (max_x));
193  * UniverseUtil::IOmessage (0,"game","all",mystr);
194  *
195  * string mystr2 ("min x "+XMLSupport::tostring (min_x));
196  * UniverseUtil::IOmessage (0,"game","all",mystr2);
197  *
198  * string mystr3 ("max y "+XMLSupport::tostring (max_y));
199  * UniverseUtil::IOmessage (0,"game","all",mystr3);
200  *
201  * string mystr4 ("min y "+XMLSupport::tostring (min_y));
202  * UniverseUtil::IOmessage (0,"game","all",mystr4);
203  *
204  * string mystrcx ("center x "+XMLSupport::tostring (center_x));
205  * UniverseUtil::IOmessage (0,"game","all",mystrcx);
206  *
207  * string mystrcy ("center y "+XMLSupport::tostring (center_y));
208  * UniverseUtil::IOmessage (0,"game","all",mystrcy);
209  */
210 
212 
213  //Enlist the items and attributes
214  //**********************************
216  while (*blah) {
217  //this draws the points
218 
219  //Retrieve unit data
220  //**********************************
221  string temp = (*blah)->name;
222 
223  pos = (*blah)->Position();
224  ReplaceAxes( pos );
225 
226  float the_x, the_y, the_x_flat, the_y_flat, system_item_scale_temp;
227  TranslateCoordinates( pos,
228  pos_flat,
229  center_nav_x,
230  center_nav_y,
231  themaxvalue,
232  zscale,
233  zdistance,
234  the_x,
235  the_y,
236  the_x_flat,
237  the_y_flat,
238  system_item_scale_temp,
239  1 );
240  //IGNORE OFF SCREEN
241  //**********************************
242  if ( !TestIfInRange( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3], the_x, the_y ) ) {
243  ++blah;
244  continue;
245  }
246  //**********************************
247 
248  //Now starts the test that determines the type of things and inserts
249  //|
250  //|
251  //\/
252 
253  float insert_size = 0.0;
254  int insert_type = navambiguous;
255  if ( (*blah)->isUnit() == UNITPTR ) {
256  //unit
257  /*if(UnitUtil::isPlayerStarship(*blah) > -1) // is a PLAYER SHIP
258  * {
259  * if (UnitUtil::isPlayerStarship (*blah)==UniverseUtil::getCurrentPlayer()) // is THE PLAYER
260  * {
261  * insert_type = navcurrentplayer;
262  * insert_size = navcurrentplayersize;
263  * }
264  * else // is A PLAYER
265  * {
266  * insert_type = navplayer;
267  * insert_size = navplayersize;
268  * }
269  * }
270  * else // is a non player ship
271  * {*/
272  if ( UnitUtil::isSignificant( *blah ) ) {
273  //capship or station
274  if ( (*blah)->GetComputerData().max_speed() == 0 ) {
275  //is this item STATIONARY?
276  insert_type = navstation;
277  insert_size = navstationsize;
278  } else {
279  //it moves = capship
280  if ( ThePlayer->InRange( (*blah), false, false ) ) {
281  //only insert if in range
282  insert_type = navcapship;
283  insert_size = navcapshipsize;
284  } else {
285  //skip unit completely if not in range
286  ++blah;
287  continue;
288  }
289  }
290  } else {
291  //fighter
292  /*if(ThePlayer->InRange((*blah),false,false)) // only insert if in range
293  * {
294  * insert_type = navfighter;
295  * insert_size = navfightersize;
296  * }
297  * else // skip unit completely if not in range
298  * {
299  * ++blah;
300  * continue;
301  * }*/
302  if (UnitUtil::isPlayerStarship( *blah ) > -1) {
303  //is THE PLAYER
304  insert_type = navfighter;
305  insert_size = navfightersize;
306  } else {
307  //skip unit completely if not in range
308  ++blah;
309  continue;
310  }
311  }
312  //}
313  } else if ( (*blah)->isUnit() == PLANETPTR ) {
314  //is it a PLANET?
315  if ( UnitUtil::isSun( *blah ) ) {
316  //is this a SUN?
317  insert_type = navsun;
318  insert_size = navsunsize;
319  } else if ( !( (*blah)->GetDestinations().empty() ) ) {
320  //is a jump point (has destinations)
321  insert_type = navjump;
322  insert_size = navjumpsize;
323  } else {
324  //its a planet
325  insert_type = navplanet;
326  insert_size = navplanetsize;
327  }
328  } else if ( (*blah)->isUnit() == MISSILEPTR ) {
329  //a missile
330  insert_type = navmissile;
331  insert_size = navmissilesize;
332  } else if ( (*blah)->isUnit() == ASTEROIDPTR ) {
333  //an asteroid
334  insert_type = navasteroid;
335  insert_size = navasteroidsize;
336  } else if ( (*blah)->isUnit() == NEBULAPTR ) {
337  //a nebula
338  insert_type = navnebula;
339  insert_size = navnebulasize;
340  } else {
341  //undefined non unit
342  insert_type = navambiguous;
343  insert_size = navambiguoussize;
344  }
345  if ( system_item_scale_temp > (system_item_scale*3) )
346  system_item_scale_temp = (system_item_scale*3);
347  insert_size *= system_item_scale_temp;
348  if ( _Universe->AccessCockpit()->GetParent()->Target() == (*blah) ) {
349  //Get a color from the config
350  static float col[4] = {1, 0.3, 0.3, 0.8};
351  static bool init = false;
352  if (!init) {
353  vs_config->getColor( "nav", "targeted_unit", col, true );
354  init = true;
355  }
356  DrawTargetCorners( the_x, the_y, insert_size, GFXColor( col[0], col[1], col[2], col[3] ) );
357  }
358  bool tests_in_range = 0;
359  if (insert_type == navstation)
360  tests_in_range = TestIfInRangeBlk( the_x, the_y, insert_size, mouse_x_current, mouse_y_current );
361  else
362  tests_in_range = TestIfInRangeRad( the_x, the_y, insert_size, mouse_x_current, mouse_y_current );
363  Unit *myunit = (*blah);
364 
365  ++blah;
366  DisplayOrientationLines( the_x, the_y, the_x_flat, the_y_flat, 1 );
367  if (tests_in_range) {
368  mouselist.insert( insert_type, insert_size, the_x, the_y, myunit );
369  } else {
370  drawlistitem( insert_type,
371  insert_size,
372  the_x,
373  the_y,
374  myunit,
375  screenoccupation,
376  false,
377  (*blah) ? true : false,
378  unselectedalpha,
379  factioncolours );
380  }
381  }
382  //********************************** // done enlisting items and attributes
383  //Adjust mouse list for 'n' kliks
384  //**********************************
385  //STANDARD : (1 3 2) ~ [0] [2] [1]
386  //VS : (1 2 3) ~ [0] [1] [2] <-- use this
387  if (mouselist.get_n_contents() > 0) {
388  //mouse is over a target when this is > 0
389  if (mouse_wentdown[2] == 1) //mouse button went down for mouse button 2(standard)
390  rotations += 1;
391  }
392  if ( rotations >= mouselist.get_n_contents() ) //dont rotate more than there is
393  rotations = 0;
394  int r = 0;
395  while (r < rotations) {
396  //rotate whatver rotations, leaving n rotated items, tail on top
397  mouselist.rotate();
398  r += 1;
399  }
400  //**********************************
401  //Draw the damn shit
402  //**********************************
403 //mainlist.draw(); // draw the items
404 //mainlist.wipe(); // whipe the list
405  //**********************************
406  //Check for selection query
407  //give back the selected tail IF there is one
408  //IF given back, undo the selection state
409  //**********************************
410  if ( 1 || checkbit( buttonstates, 1 ) ) {
411  //button #2 is down, wanting a (selection)
412  if (mouselist.get_n_contents() > 0) {
413  //mouse is over a target when this is > 0
414  if (mouse_wentdown[0] == 1) {
415  //mouse button went down for mouse button 1
416  currentselection = mouselist.gettailunit();
417  unsetbit( buttonstates, 1 );
418  //JUST FOR NOW, target == current selection. later it'll be used for other shit, that will then set target.
419  if ( currentselection.GetUnit() ) {
420  ( UniverseUtil::getPlayerX( UniverseUtil::getCurrentPlayer() ) )->Target( currentselection.GetUnit() );
421  ( UniverseUtil::getPlayerX( UniverseUtil::getCurrentPlayer() ) )->LockTarget( currentselection.GetUnit() );
422  }
423  }
424  }
425  }
426  //**********************************
427 
428  //Clear the lists
429  //**********************************
430  mouselist.draw(); //draw mouse over'd items
431  mouselist.wipe(); //whipe mouse over'd list
432  //**********************************
433 }
void NavigationSystem::DrawTargetCorners ( float  x,
float  y,
float  size,
const GFXColor col 
)
static

Definition at line 272 of file navitemstodraw.h.

References GFXBegin(), GFXBlendMode(), GFXColorf(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLINE, GFXVertex3f(), INVSRCALPHA, LIGHTING, SRCALPHA, and TEXTURE0.

Referenced by DrawGalaxy(), and DrawSystem().

273 {
274  GFXColorf( col );
275  GFXDisable( TEXTURE0 );
276  GFXDisable( LIGHTING );
278 
279  GFXBegin( GFXLINE );
280 
281  GFXVertex3f( ( x-(0.5*size) ), ( y+(0.5*size) ), 0 );
282  GFXVertex3f( ( x-(0.3*size) ), ( y+(0.5*size) ), 0 );
283 
284  GFXVertex3f( ( x-(0.5*size) ), ( y+(0.5*size) ), 0 );
285  GFXVertex3f( ( x-(0.5*size) ), ( y+(0.3*size) ), 0 );
286 
287  GFXVertex3f( ( x+(0.5*size) ), ( y+(0.5*size) ), 0 );
288  GFXVertex3f( ( x+(0.3*size) ), ( y+(0.5*size) ), 0 );
289 
290  GFXVertex3f( ( x+(0.5*size) ), ( y+(0.5*size) ), 0 );
291  GFXVertex3f( ( x+(0.5*size) ), ( y+(0.3*size) ), 0 );
292 
293  GFXVertex3f( ( x-(0.5*size) ), ( y-(0.5*size) ), 0 );
294  GFXVertex3f( ( x-(0.3*size) ), ( y-(0.5*size) ), 0 );
295 
296  GFXVertex3f( ( x-(0.5*size) ), ( y-(0.5*size) ), 0 );
297  GFXVertex3f( ( x-(0.5*size) ), ( y-(0.3*size) ), 0 );
298 
299  GFXVertex3f( ( x+(0.5*size) ), ( y-(0.5*size) ), 0 );
300  GFXVertex3f( ( x+(0.3*size) ), ( y-(0.5*size) ), 0 );
301 
302  GFXVertex3f( ( x+(0.5*size) ), ( y-(0.5*size) ), 0 );
303  GFXVertex3f( ( x+(0.5*size) ), ( y-(0.3*size) ), 0 );
304 
305  GFXEnd();
306  GFXEnable( TEXTURE0 );
307 }
QVector NavigationSystem::dxyz ( class QVector  vector,
double  x_,
double  y_,
double  z_ 
)
static

Definition at line 897 of file navscreen.cpp.

References UniverseUtil::cos(), UniverseUtil::sin(), and UniverseUtil::sqrt().

Referenced by DrawNavCircle().

898 {
899 /*
900  * void Roll (QFLOAT rad){
901  * QFLOAT theta = atan2 (j,i)+rad;
902  * QFloat len = XSQRT (j*j+i*i);
903  * j = sin (theta)*len;
904  * i = cos (theta)*len;
905  * }
906  */
907  if (x_ != 0) {
908  float distance_yz = sqrt( (vector.j*vector.j)+(vector.k*vector.k) );
909  float current_angle = atan2( vector.k, vector.j );
910  current_angle += x_;
911  vector.j = cos( current_angle )*distance_yz;
912  vector.k = sin( current_angle )*distance_yz;
913  }
914  if (y_ != 0) {
915  float distance_xz = sqrt( (vector.i*vector.i)+(vector.k*vector.k) );
916  float current_angle = atan2( vector.k, vector.i );
917  current_angle += y_;
918  vector.i = cos( current_angle )*distance_xz;
919  vector.k = sin( current_angle )*distance_xz;
920  }
921  if (z_ != 0) {
922  float distance_xy = sqrt( (vector.i*vector.i)+(vector.j*vector.j) );
923  float current_angle = atan2( vector.j, vector.i );
924  current_angle += z_;
925  vector.i = cos( current_angle )*distance_xy;
926  vector.j = sin( current_angle )*distance_xy;
927  }
928  return vector;
929 }
std::string NavigationSystem::getCurrentSystem ( )

Definition at line 971 of file navscreen.cpp.

References _Universe, Universe::activeStarSystem(), StarSystem::getFileName(), and NavigationSystem::CachedSystemIterator::size().

Referenced by GameCockpit::Draw(), and DrawGalaxy().

972 {
973  if ( factioncolours == NULL || focusedsystemindex >= systemIter.size() )
975  return systemIter[currentsystemindex].GetName();
976 }
std::string NavigationSystem::getDestinationSystem ( )

Definition at line 983 of file navscreen.cpp.

References _Universe, Universe::activeStarSystem(), StarSystem::getFileName(), and NavigationSystem::CachedSystemIterator::size().

984 {
985  if ( factioncolours == NULL || focusedsystemindex >= systemIter.size() )
987  return systemIter[destinationsystemindex].GetName();
988 }
std::string NavigationSystem::getFocusedSystem ( )

Definition at line 989 of file navscreen.cpp.

References _Universe, Universe::activeStarSystem(), StarSystem::getFileName(), and NavigationSystem::CachedSystemIterator::size().

990 {
991  if ( factioncolours == NULL || focusedsystemindex >= systemIter.size() )
993  return systemIter[focusedsystemindex].GetName();
994 }
static int NavigationSystem::getMouseButtonStatus ( )
inlinestatic

Definition at line 345 of file navscreen.h.

References mousestat.

Referenced by SetMouseFlipStatus().

346  {
347  return mousestat;
348  }
std::string NavigationSystem::getSelectedSystem ( )

Definition at line 977 of file navscreen.cpp.

References _Universe, Universe::activeStarSystem(), StarSystem::getFileName(), and NavigationSystem::CachedSystemIterator::size().

Referenced by GameCockpit::Draw(), and GameCockpit::GetNavSelectedSystem().

978 {
979  if ( factioncolours == NULL || focusedsystemindex >= systemIter.size() )
981  return systemIter[systemselectionindex].GetName();
982 }
void NavigationSystem::IntersectBorder ( float x,
float y,
const float x1,
const float y1 
) const

Definition at line 1300 of file navscreen.cpp.

References intersect().

Referenced by DrawGalaxy().

1301 {
1302  float ansx;
1303  float ansy;
1304  if ( intersect( x, y, x1, y1, screenskipby4[1], screenskipby4[3], screenskipby4[0], screenskipby4[3], ansx, ansy )
1305  || intersect( x, y, x1, y1, screenskipby4[0], screenskipby4[2], screenskipby4[0], screenskipby4[3], ansx, ansy )
1306  || intersect( x, y, x1, y1, screenskipby4[0], screenskipby4[2], screenskipby4[1], screenskipby4[2], ansx, ansy )
1307  || intersect( x, y, x1, y1, screenskipby4[1], screenskipby4[3], screenskipby4[1], screenskipby4[2], ansx, ansy ) ) {
1308  x = ansx;
1309  y = ansy;
1310  }
1311 }
void NavigationSystem::mouseClick ( int  button,
int  state,
int  x,
int  y 
)
static

Definition at line 83 of file navscreen.cpp.

References lookupMouseButton(), mousestat, mousex, mousey, WS_MOUSE_DOWN, WS_WHEEL_DOWN, WS_WHEEL_UP, x, and y.

Referenced by BaseInterface::ClickWin().

84 {
85  mousex = x;
86  mousey = y;
87  if (state == WS_MOUSE_DOWN)
88  mousestat |= ( 1<<lookupMouseButton( button ) );
89  else if (button != WS_WHEEL_UP && button != WS_WHEEL_DOWN)
90  mousestat &= ( ~( 1<<lookupMouseButton( button ) ) );
91 }
void NavigationSystem::mouseDrag ( int  x,
int  y 
)
static

Definition at line 73 of file navscreen.cpp.

References mousex, mousey, x, and y.

Referenced by BaseInterface::ActiveMouseOverWin().

74 {
75  mousex = x;
76  mousey = y;
77 }
void NavigationSystem::mouseMotion ( int  x,
int  y 
)
static

Definition at line 78 of file navscreen.cpp.

References mousex, mousey, x, and y.

Referenced by BaseInterface::PassiveMouseOverWin().

79 {
80  mousex = x;
81  mousey = y;
82 }
bool NavigationSystem::ParseFile ( string  filename)

Definition at line 6 of file navparse.h.

References GFXColor::a, GFXColor::b, VSFileSystem::CockpitFile, dosetbit(), f, GFXColor::g, FactionUtil::GetFactionName(), FactionUtil::GetNumFactions(), k, Mesh::LoadMesh(), next, VSFileSystem::Ok, GFXColor::r, retrievedata(), ScreenToCoord(), TextPlane::SetPos(), TextPlane::SetSize(), and Vector.

Referenced by Setup().

7 {
8  string expression = "";
9  string tag = "";
10  string data = "";
11  char next = ' ';
12  int totalitems = 0;
13 
14  //ifstream dataset_file;
15  //dataset_file.open("navdata.xml");
16  VSFile f;
17  VSError err = f.OpenReadOnly( "nav/navdata.xml", CockpitFile );
18  //if (dataset_file.fail())
19  if (err > Ok)
20  return 0;
21  while ( !f.Eof() ) {
22  if (next == '<') {
23  //trap <*>
24  //- know what type it is
25  f.Read( &next, 1 ); //
26  while (next != '>') {
27  //
28  //
29  expression = expression+next; //
30  f.Read( &next, 1 ); //
31  } //
32  if (expression[0] == '!') {
33  //doesnt catch comment in comment
34  while ( (expression[expression.size()-1] != '>') || (expression[expression.size()-2] != '-') ) {
35  expression = expression+next;
36  f.Read( &next, 1 );
37  }
38  expression = "";
39  continue;
40  }
41  if ( (expression[0] != '/') && (expression[expression.size()-1] != '/') ) {
42  //starter
43  tag = expression;
44  expression = "";
45  } else if (expression[0] == '/') {
46  //terminator = no more to be done
47  data = "";
48  tag = "";
49  expression = "";
50  } else if (expression[expression.size()-1] == '/') {
51  //data
52  data = expression;
53  if (tag == "console") {
54  string mesh_ = retrievedata( data, "file" );
55  float x_small = atof( ( retrievedata( data, "x_small" ) ).c_str() );
56  float x_large = atof( ( retrievedata( data, "x_large" ) ).c_str() );
57  float y_small = atof( ( retrievedata( data, "y_small" ) ).c_str() );
58  float y_large = atof( ( retrievedata( data, "y_large" ) ).c_str() );
59  float scale_ = atof( ( retrievedata( data, "scale" ) ).c_str() );
60  float x_mesh_coord = atof( ( retrievedata( data, "x_mesh_coord" ) ).c_str() );
61  float y_mesh_coord = atof( ( retrievedata( data, "y_mesh_coord" ) ).c_str() );
62  float z_mesh_coord = atof( ( retrievedata( data, "z_mesh_coord" ) ).c_str() );
63  meshcoordinate_x[0] = x_mesh_coord;
64  meshcoordinate_y[0] = y_mesh_coord;
65  meshcoordinate_z[0] = z_mesh_coord;
66  screenskipby4[0] = x_small;
67  screenskipby4[1] = x_large;
68  screenskipby4[2] = y_small;
69  screenskipby4[3] = y_large;
70  mesh[0] = Mesh::LoadMesh( mesh_.c_str(), Vector( scale_, scale_, scale_ ), 0, NULL );
71  } else if (tag == "button1") {
72  string mesh_ = retrievedata( data, "file" );
73  float x_ = atof( ( retrievedata( data, "x" ) ).c_str() );
74  float y_ = atof( ( retrievedata( data, "y" ) ).c_str() );
75  float dx_ = atof( ( retrievedata( data, "dx" ) ).c_str() );
76  float dy_ = atof( ( retrievedata( data, "dy" ) ).c_str() );
77  float scale_ = atof( ( retrievedata( data, "scale" ) ).c_str() );
78  float x_mesh_coord = atof( ( retrievedata( data, "x_mesh_coord" ) ).c_str() );
79  float y_mesh_coord = atof( ( retrievedata( data, "y_mesh_coord" ) ).c_str() );
80  float z_mesh_coord = atof( ( retrievedata( data, "z_mesh_coord" ) ).c_str() );
81  float z_mesh_coord_delta = atof( ( retrievedata( data, "z_mesh_coord_delta" ) ).c_str() );
82 
83  meshcoordinate_x[1] = x_mesh_coord;
84  meshcoordinate_y[1] = y_mesh_coord;
85  meshcoordinate_z[1] = z_mesh_coord;
86  meshcoordinate_z_delta[1] = z_mesh_coord_delta;
87  buttonskipby4_1[0] = x_;
88  buttonskipby4_1[1] = x_+dx_;
89  buttonskipby4_1[2] = y_;
90  buttonskipby4_1[3] = y_+dy_;
91 
92  mesh[1] = Mesh::LoadMesh( mesh_.c_str(), Vector( scale_, scale_, scale_ ), 0, NULL );
93  } else if (tag == "button2") {
94  string mesh_ = retrievedata( data, "file" );
95  float x_ = atof( ( retrievedata( data, "x" ) ).c_str() );
96  float y_ = atof( ( retrievedata( data, "y" ) ).c_str() );
97  float dx_ = atof( ( retrievedata( data, "dx" ) ).c_str() );
98  float dy_ = atof( ( retrievedata( data, "dy" ) ).c_str() );
99  float scale_ = atof( ( retrievedata( data, "scale" ) ).c_str() );
100 
101  float x_mesh_coord = atof( ( retrievedata( data, "x_mesh_coord" ) ).c_str() );
102  float y_mesh_coord = atof( ( retrievedata( data, "y_mesh_coord" ) ).c_str() );
103  float z_mesh_coord = atof( ( retrievedata( data, "z_mesh_coord" ) ).c_str() );
104  float z_mesh_coord_delta = atof( ( retrievedata( data, "z_mesh_coord_delta" ) ).c_str() );
105 
106  meshcoordinate_x[2] = x_mesh_coord;
107  meshcoordinate_y[2] = y_mesh_coord;
108  meshcoordinate_z[2] = z_mesh_coord;
109  meshcoordinate_z_delta[2] = z_mesh_coord_delta;
110 
111  buttonskipby4_2[0] = x_;
112  buttonskipby4_2[1] = x_+dx_;
113  buttonskipby4_2[2] = y_;
114  buttonskipby4_2[3] = y_+dy_;
115 
116  mesh[2] = Mesh::LoadMesh( mesh_.c_str(), Vector( scale_, scale_, scale_ ), 0, NULL );
117  } else if (tag == "button3") {
118  string mesh_ = retrievedata( data, "file" );
119  float x_ = atof( ( retrievedata( data, "x" ) ).c_str() );
120  float y_ = atof( ( retrievedata( data, "y" ) ).c_str() );
121  float dx_ = atof( ( retrievedata( data, "dx" ) ).c_str() );
122  float dy_ = atof( ( retrievedata( data, "dy" ) ).c_str() );
123  float scale_ = atof( ( retrievedata( data, "scale" ) ).c_str() );
124 
125  float x_mesh_coord = atof( ( retrievedata( data, "x_mesh_coord" ) ).c_str() );
126  float y_mesh_coord = atof( ( retrievedata( data, "y_mesh_coord" ) ).c_str() );
127  float z_mesh_coord = atof( ( retrievedata( data, "z_mesh_coord" ) ).c_str() );
128  float z_mesh_coord_delta = atof( ( retrievedata( data, "z_mesh_coord_delta" ) ).c_str() );
129 
130  meshcoordinate_x[3] = x_mesh_coord;
131  meshcoordinate_y[3] = y_mesh_coord;
132  meshcoordinate_z[3] = z_mesh_coord;
133  meshcoordinate_z_delta[3] = z_mesh_coord_delta;
134 
135  buttonskipby4_3[0] = x_;
136  buttonskipby4_3[1] = x_+dx_;
137  buttonskipby4_3[2] = y_;
138  buttonskipby4_3[3] = y_+dy_;
139 
140  mesh[3] = Mesh::LoadMesh( mesh_.c_str(), Vector( scale_, scale_, scale_ ), 0, NULL );
141  } else if (tag == "button4") {
142  string mesh_ = retrievedata( data, "file" );
143  float x_ = atof( ( retrievedata( data, "x" ) ).c_str() );
144  float y_ = atof( ( retrievedata( data, "y" ) ).c_str() );
145  float dx_ = atof( ( retrievedata( data, "dx" ) ).c_str() );
146  float dy_ = atof( ( retrievedata( data, "dy" ) ).c_str() );
147  float scale_ = atof( ( retrievedata( data, "scale" ) ).c_str() );
148 
149  float x_mesh_coord = atof( ( retrievedata( data, "x_mesh_coord" ) ).c_str() );
150  float y_mesh_coord = atof( ( retrievedata( data, "y_mesh_coord" ) ).c_str() );
151  float z_mesh_coord = atof( ( retrievedata( data, "z_mesh_coord" ) ).c_str() );
152  float z_mesh_coord_delta = atof( ( retrievedata( data, "z_mesh_coord_delta" ) ).c_str() );
153 
154  meshcoordinate_x[4] = x_mesh_coord;
155  meshcoordinate_y[4] = y_mesh_coord;
156  meshcoordinate_z[4] = z_mesh_coord;
157  meshcoordinate_z_delta[4] = z_mesh_coord_delta;
158 
159  buttonskipby4_4[0] = x_;
160  buttonskipby4_4[1] = x_+dx_;
161  buttonskipby4_4[2] = y_;
162  buttonskipby4_4[3] = y_+dy_;
163 
164  mesh[4] = Mesh::LoadMesh( mesh_.c_str(), Vector( scale_, scale_, scale_ ), 0, NULL );
165  } else if (tag == "button5") {
166  string mesh_ = retrievedata( data, "file" );
167  float x_ = atof( ( retrievedata( data, "x" ) ).c_str() );
168  float y_ = atof( ( retrievedata( data, "y" ) ).c_str() );
169  float dx_ = atof( ( retrievedata( data, "dx" ) ).c_str() );
170  float dy_ = atof( ( retrievedata( data, "dy" ) ).c_str() );
171  float scale_ = atof( ( retrievedata( data, "scale" ) ).c_str() );
172 
173  float x_mesh_coord = atof( ( retrievedata( data, "x_mesh_coord" ) ).c_str() );
174  float y_mesh_coord = atof( ( retrievedata( data, "y_mesh_coord" ) ).c_str() );
175  float z_mesh_coord = atof( ( retrievedata( data, "z_mesh_coord" ) ).c_str() );
176  float z_mesh_coord_delta = atof( ( retrievedata( data, "z_mesh_coord_delta" ) ).c_str() );
177 
178  meshcoordinate_x[5] = x_mesh_coord;
179  meshcoordinate_y[5] = y_mesh_coord;
180  meshcoordinate_z[5] = z_mesh_coord;
181  meshcoordinate_z_delta[5] = z_mesh_coord_delta;
182 
183  buttonskipby4_5[0] = x_;
184  buttonskipby4_5[1] = x_+dx_;
185  buttonskipby4_5[2] = y_;
186  buttonskipby4_5[3] = y_+dy_;
187 
188  mesh[5] = Mesh::LoadMesh( mesh_.c_str(), Vector( scale_, scale_, scale_ ), 0, NULL );
189  } else if (tag == "button6") {
190  string mesh_ = retrievedata( data, "file" );
191  float x_ = atof( ( retrievedata( data, "x" ) ).c_str() );
192  float y_ = atof( ( retrievedata( data, "y" ) ).c_str() );
193  float dx_ = atof( ( retrievedata( data, "dx" ) ).c_str() );
194  float dy_ = atof( ( retrievedata( data, "dy" ) ).c_str() );
195  float scale_ = atof( ( retrievedata( data, "scale" ) ).c_str() );
196 
197  float x_mesh_coord = atof( ( retrievedata( data, "x_mesh_coord" ) ).c_str() );
198  float y_mesh_coord = atof( ( retrievedata( data, "y_mesh_coord" ) ).c_str() );
199  float z_mesh_coord = atof( ( retrievedata( data, "z_mesh_coord" ) ).c_str() );
200  float z_mesh_coord_delta = atof( ( retrievedata( data, "z_mesh_coord_delta" ) ).c_str() );
201 
202  meshcoordinate_x[6] = x_mesh_coord;
203  meshcoordinate_y[6] = y_mesh_coord;
204  meshcoordinate_z[6] = z_mesh_coord;
205  meshcoordinate_z_delta[6] = z_mesh_coord_delta;
206 
207  buttonskipby4_6[0] = x_;
208  buttonskipby4_6[1] = x_+dx_;
209  buttonskipby4_6[2] = y_;
210  buttonskipby4_6[3] = y_+dy_;
211 
212  mesh[6] = Mesh::LoadMesh( mesh_.c_str(), Vector( scale_, scale_, scale_ ), 0, NULL );
213  } else if (tag == "button7") {
214  string mesh_ = retrievedata( data, "file" );
215  float x_ = atof( ( retrievedata( data, "x" ) ).c_str() );
216  float y_ = atof( ( retrievedata( data, "y" ) ).c_str() );
217  float dx_ = atof( ( retrievedata( data, "dx" ) ).c_str() );
218  float dy_ = atof( ( retrievedata( data, "dy" ) ).c_str() );
219  float scale_ = atof( ( retrievedata( data, "scale" ) ).c_str() );
220 
221  float x_mesh_coord = atof( ( retrievedata( data, "x_mesh_coord" ) ).c_str() );
222  float y_mesh_coord = atof( ( retrievedata( data, "y_mesh_coord" ) ).c_str() );
223  float z_mesh_coord = atof( ( retrievedata( data, "z_mesh_coord" ) ).c_str() );
224  float z_mesh_coord_delta = atof( ( retrievedata( data, "z_mesh_coord_delta" ) ).c_str() );
225 
226  meshcoordinate_x[7] = x_mesh_coord;
227  meshcoordinate_y[7] = y_mesh_coord;
228  meshcoordinate_z[7] = z_mesh_coord;
229  meshcoordinate_z_delta[7] = z_mesh_coord_delta;
230 
231  buttonskipby4_7[0] = x_;
232  buttonskipby4_7[1] = x_+dx_;
233  buttonskipby4_7[2] = y_;
234  buttonskipby4_7[3] = y_+dy_;
235 
236  mesh[7] = Mesh::LoadMesh( mesh_.c_str(), Vector( scale_, scale_, scale_ ), 0, NULL );
237  } else if (tag == "objectives") {
238  float x_ = atof( ( retrievedata( data, "x" ) ).c_str() );
239  float y_ = atof( ( retrievedata( data, "y" ) ).c_str() );
240  float dx_ = x_+atof( ( retrievedata( data, "dx" ) ).c_str() );
241  float dy_ = y_+atof( ( retrievedata( data, "dy" ) ).c_str() );
242  ScreenToCoord( x_ );
243  ScreenToCoord( y_ );
244  ScreenToCoord( dx_ );
245  ScreenToCoord( dy_ );
246 
247  screen_objectives.SetPos( x_, dy_ );
248  screen_objectives.SetSize( dx_-x_, y_-dy_ );
249  dosetbit( whattodraw, 4 );
250  } else if (tag == "systemiteminfo") {
251  float scale_ = atof( ( retrievedata( data, "itemscale" ) ).c_str() );
252  float zmult_ = atof( ( retrievedata( data, "zshiftmultiplier" ) ).c_str() );
253  float zfactor_ = atof( ( retrievedata( data, "itemzscalefactor" ) ).c_str() );
254  float _unselectedalpha = atof( ( retrievedata( data, "unselectedalpha" ) ).c_str() );
255  float _minimumitemscaledown = atof( ( retrievedata( data, "minimumitemscaledown" ) ).c_str() );
256  float _maximumitemscaleup = atof( ( retrievedata( data, "maximumitemscaleup" ) ).c_str() );
257 
258  unselectedalpha = _unselectedalpha;
259  minimumitemscaledown = _minimumitemscaledown;
260  maximumitemscaleup = _maximumitemscaleup;
261  if (scale_ < 0.5)
262  system_item_scale = 0.5;
263  else if (scale_ > 4)
264  system_item_scale = 4;
265  else
266  system_item_scale = scale_;
267  if (zmult_ < 0.5)
268  zshiftmultiplier = 0.5;
269  else if (zmult_ > 6)
270  zshiftmultiplier = 6;
271  else
272  zshiftmultiplier = zmult_;
273  if (zfactor_ < 1.0)
274  item_zscalefactor = 1.0;
275  else if (zfactor_ > 8)
276  item_zscalefactor = 8;
277  else
278  item_zscalefactor = zfactor_;
279  } else if (tag == "dimensions") {
280  int how_many_sys = atoi( ( retrievedata( data, "system" ) ).c_str() );
281  int how_many_gal = atoi( ( retrievedata( data, "galaxy" ) ).c_str() );
282  string multi_sys = retrievedata( data, "systemmultidimensional" );
283  string multi_gal = retrievedata( data, "galaxymultidimensional" );
284  if (how_many_sys == 3)
285  system_view = VIEW_3D;
286  else
287  system_view = VIEW_2D;
288  if (how_many_gal == 3)
289  galaxy_view = VIEW_3D;
290  else
291  galaxy_view = VIEW_2D;
292  if (multi_sys == "yes")
293  system_multi_dimensional = 1;
294  else
295  system_multi_dimensional = 0;
296  if (multi_gal == "yes")
297  galaxy_multi_dimensional = 1;
298  else
299  galaxy_multi_dimensional = 0;
300  } else if (tag == "factioncolours") {
301  string factionname = retrievedata( data, "faction" );
302  float r_ = atof( ( retrievedata( data, "r" ) ).c_str() );
303  float g_ = atof( ( retrievedata( data, "g" ) ).c_str() );
304  float b_ = atof( ( retrievedata( data, "b" ) ).c_str() );
305  float a_ = atof( ( retrievedata( data, "a" ) ).c_str() );
306  for (unsigned int k = 0; k < FactionUtil::GetNumFactions(); k++)
307  if ( ( FactionUtil::GetFactionName( k ) ) == factionname ) {
308  factioncolours[k].r = r_;
309  factioncolours[k].g = g_;
310  factioncolours[k].b = b_;
311  factioncolours[k].a = a_;
312  }
313  } else if (tag == "configmode") {
314  int configmode_ = atoi( ( retrievedata( data, "configmode" ) ).c_str() );
315  configmode = configmode_;
316  }
317  data = "";
318  //tag = "";
319  expression = "";
320  continue;
321  } else {
322  continue;
323  }
324  }
325  f.Read( &next, 1 );
326  //do something
327  }
328  f.Close();
329  if (totalitems == 0)
330  return 1;
331  else
332  return 0;
333 }
void NavigationSystem::ScreenToCoord ( float x)

Definition at line 1364 of file navscreen.cpp.

Referenced by ParseFile(), and Setup().

1365 {
1366  x -= .5;
1367  x *= 2;
1368 }
void NavigationSystem::scroll ( signed int  scrollamt)
inline

Definition at line 334 of file navscreen.h.

Referenced by GameCockpit::ScrollAllVDU().

335  {
336  scrolloffset += scrollamt;
337  }
void NavigationSystem::setCurrentSystem ( string  newSystem)

Definition at line 933 of file navscreen.cpp.

References i, and NavigationSystem::CachedSystemIterator::size().

Referenced by GameCockpit::visitSystem().

934 {
935  for (unsigned i = 0; i < systemIter.size(); ++i)
936  if (systemIter[i].GetName() == newSystem) {
937  setCurrentSystemIndex( i );
938  break;
939  }
940 }
void NavigationSystem::SetDraw ( bool  n)

Definition at line 828 of file navscreen.cpp.

References ClearPriorities(), and Setup().

Referenced by GameCockpit::SetDrawNavSystem().

829 {
830  if (draw == -1) {
831  Setup();
832  draw = 0;
833  }
834  if ( n != (draw == 1) ) {
835  ClearPriorities();
836  scrolloffset = 0;
837  draw = n ? 1 : 0;
838  }
839 }
void NavigationSystem::SetMouseFlipStatus ( )

Definition at line 860 of file navscreen.cpp.

References getMouseButtonStatus(), i, and mousestat.

Referenced by Draw().

861 {
862 //getMouseButtonStatus()&1 = mouse button 1 standard = button 1 VS
863 //getMouseButtonStatus()&2 = mouse button 3 standard = button 2 VS
864 //getMouseButtonStatus()&4 = mouse button 2 standard = button 3 VS
865 //getMouseButtonStatus()&8 = mouse wheel up
866 //getMouseButtonStatus()&16 = mouse wheel down
867 
868  //use the VS scheme, (1 2 3 4 5) , instead of standard (1 3 2 4 5)
869  //state 0 = up
870  //state 1 = down
871 
872  bool status = 0;
873  int i;
874  for (i = 0; i < 5; i++) {
875  status = ( getMouseButtonStatus()&(1<<i) ) ? 1 : 0;
876  if ( (status == 1) && (mouse_previous_state[i] == 0) ) {
877  mouse_wentdown[i] = 1;
878  mouse_wentup[i] = 0;
879  } else if ( (status == 0) && (mouse_previous_state[i] == 1) ) {
880  mouse_wentup[i] = 1;
881  mouse_wentdown[i] = 0;
882  } else {
883  mouse_wentup[i] = 0;
884  mouse_wentdown[i] = 0;
885  if (i == 3 || i == 4)
886  mousestat &= ( ~(1<<i) );
887  }
888  }
889  for (i = 0; i < 5; i++)
890  mouse_previous_state[i] = ( getMouseButtonStatus()&(1<<i) ); //button 'i+1' state VS
891 }
void NavigationSystem::Setup ( )

Definition at line 93 of file navscreen.cpp.

References _Universe, GFXColor::a, Universe::AccessCockpit(), Universe::activeStarSystem(), GFXColor::b, float, GFXColor::g, g_game, VegaConfig::getColor(), StarSystem::getFileName(), FactionUtil::GetNumFactions(), getSaveData(), UniverseUtil::getSystemFile(), VegaConfig::getVariable(), i, NavComputer::init(), NavigationSystem::CachedSystemIterator::init(), NavigationSystem::CachedSectorIterator::init(), mousex, mousey, NAVTOTALMESHCOUNT, XMLSupport::parse_bool(), XMLSupport::parse_int(), ParseFile(), GFXColor::r, ScreenToCoord(), unsetbit(), Cockpit::visitSystem(), vs_config, VSFileSystem::vs_fprintf(), game_data_t::x_resolution, and game_data_t::y_resolution.

Referenced by GameCockpit::Draw(), and SetDraw().

94 {
96 
97  configmode = 0;
98 
99  rotations = 0;
100 
101  minimumitemscaledown = 0.2;
102  maximumitemscaleup = 3.0;
103 
104  axis = 3;
105 
106  rx = -0.5; //galaxy mode settings
107  ry = 0.5;
108  rz = 0.0;
109  zoom = 1.8;
110 
111  rx_s = -0.5; //system mode settings
112  ry_s = 1.5;
113  rz_s = 0.0;
114  zoom_s = 1.8;
115 
116  scrolloffset = 0;
117 
118  camera_z = 1.0; //updated after a pass
119  center_x = 0.0; //updated after a pass
120  center_y = 0.0; //updated after a pass
121  center_z = 0.0; //updated after a pass
122 
123  path_view = PATH_ON;
124  static bool start_sys_ortho = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "system_map_ortho_view", "false" ) );
125  static bool start_sec_ortho = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "sector_map_ortho_view", "false" ) );
126  system_view = start_sys_ortho ? VIEW_ORTHO : VIEW_2D;
127  galaxy_view = start_sec_ortho ? VIEW_ORTHO : VIEW_2D;
128  system_multi_dimensional = 1;
129  galaxy_multi_dimensional = 1;
130 
131  zshiftmultiplier = 2.5; //shrink the output
132  item_zscalefactor = 1.0; //camera distance prespective multiplier for affecting item sizes
133  system_item_scale = 1.0;
134  mouse_previous_state[0] = 0; //could have used a loop, but this way the system uses immediate instead of R type.
135  mouse_previous_state[1] = 0;
136  mouse_previous_state[2] = 0;
137  mouse_previous_state[3] = 0;
138  mouse_previous_state[4] = 0;
139  mouse_wentup[0] = 0;
140  mouse_wentup[1] = 0;
141  mouse_wentup[2] = 0;
142  mouse_wentup[3] = 0;
143  mouse_wentup[4] = 0;
144  mouse_wentdown[0] = 0;
145  mouse_wentdown[1] = 0;
146  mouse_wentdown[2] = 0;
147  mouse_wentdown[3] = 0;
148  mouse_wentdown[4] = 0;
149  mouse_x_previous = ( -1+float(mousex)/(.5*g_game.x_resolution) );
150  mouse_y_previous = ( 1+float(-1*mousey)/(.5*g_game.y_resolution) );
151 
152  static int max_map_nodes = XMLSupport::parse_int( vs_config->getVariable( "graphics", "max_map_nodes", "256000" ) );
153  systemIter.init( UniverseUtil::getSystemFile(), max_map_nodes );
154  sectorIter.init( systemIter );
155  systemselectionindex = 0;
156  sectorselectionindex = 0;
157  destinationsystemindex = 0;
158  currentsystemindex = 0;
159  setFocusedSystemIndex( 0 );
160 
161  static int time_to_helpscreen = XMLSupport::parse_int( vs_config->getVariable( "general", "times_to_show_help_screen", "3" ) );
162  buttonstates = 0;
163  if (getSaveData( 0, "436457r1K3574r7uP71m35", 0 ) <= time_to_helpscreen)
164  whattodraw = 0;
165  else
166  whattodraw = (1|2);
167  currentselection = NULL;
168  factioncolours = new GFXColor[FactionUtil::GetNumFactions()];
169  unselectedalpha = 1.0;
170 
171  sectorOffset = systemOffset = 0;
172 
173  unsigned int p;
174  for (p = 0; p < FactionUtil::GetNumFactions(); p++) {
175  factioncolours[p].r = 1;
176  factioncolours[p].g = 1;
177  factioncolours[p].b = 1;
178  factioncolours[p].a = 1;
179  }
180  for (p = 0; p < NAVTOTALMESHCOUNT; p++)
181  meshcoordinate_x[p] = 0.0;
182  for (p = 0; p < NAVTOTALMESHCOUNT; p++)
183  meshcoordinate_y[p] = 0.0;
184  for (p = 0; p < NAVTOTALMESHCOUNT; p++)
185  meshcoordinate_z[p] = 0.0;
186  for (p = 0; p < NAVTOTALMESHCOUNT; p++)
187  meshcoordinate_z_delta[p] = 0.0;
188  //select target
189  //NAV/MISSION toggle
190  //
191 
192 //HERE GOES THE PARSING
193 
194 //*************************
195  screenskipby4[0] = .3;
196  screenskipby4[1] = .7;
197  screenskipby4[2] = .3;
198  screenskipby4[3] = .7;
199 
200  buttonskipby4_1[0] = .75;
201  buttonskipby4_1[1] = .95;
202  buttonskipby4_1[2] = .85;
203  buttonskipby4_1[3] = .90;
204 
205  buttonskipby4_2[0] = .75;
206  buttonskipby4_2[1] = .95;
207  buttonskipby4_2[2] = .75;
208  buttonskipby4_2[3] = .80;
209 
210  buttonskipby4_3[0] = .75;
211  buttonskipby4_3[1] = .95;
212  buttonskipby4_3[2] = .65;
213  buttonskipby4_3[3] = .70;
214 
215  buttonskipby4_4[0] = .75;
216  buttonskipby4_4[1] = .95;
217  buttonskipby4_4[2] = .55;
218  buttonskipby4_4[3] = .60;
219 
220  buttonskipby4_5[0] = .75;
221  buttonskipby4_5[1] = .95;
222  buttonskipby4_5[2] = .45;
223  buttonskipby4_5[3] = .50;
224 
225  buttonskipby4_6[0] = .75;
226  buttonskipby4_6[1] = .95;
227  buttonskipby4_6[2] = .35;
228  buttonskipby4_6[3] = .40;
229 
230  buttonskipby4_7[0] = .75;
231  buttonskipby4_7[1] = .95;
232  buttonskipby4_7[2] = .25;
233  buttonskipby4_7[3] = .30;
234  if ( !ParseFile( "navdata.xml" ) ) {
235  //start DUMMP VARS
236  screenskipby4[0] = .3;
237  screenskipby4[1] = .7;
238  screenskipby4[2] = .3;
239  screenskipby4[3] = .7;
240 
241  buttonskipby4_1[0] = .75;
242  buttonskipby4_1[1] = .95;
243  buttonskipby4_1[2] = .85;
244  buttonskipby4_1[3] = .90;
245 
246  buttonskipby4_2[0] = .75;
247  buttonskipby4_2[1] = .95;
248  buttonskipby4_2[2] = .75;
249  buttonskipby4_2[3] = .80;
250 
251  buttonskipby4_3[0] = .75;
252  buttonskipby4_3[1] = .95;
253  buttonskipby4_3[2] = .65;
254  buttonskipby4_3[3] = .70;
255 
256  buttonskipby4_4[0] = .75;
257  buttonskipby4_4[1] = .95;
258  buttonskipby4_4[2] = .55;
259  buttonskipby4_4[3] = .60;
260 
261  buttonskipby4_5[0] = .75;
262  buttonskipby4_5[1] = .95;
263  buttonskipby4_5[2] = .45;
264  buttonskipby4_5[3] = .50;
265 
266  buttonskipby4_6[0] = .75;
267  buttonskipby4_6[1] = .95;
268  buttonskipby4_6[2] = .35;
269  buttonskipby4_6[3] = .40;
270 
271  buttonskipby4_7[0] = .75;
272  buttonskipby4_7[1] = .95;
273  buttonskipby4_7[2] = .25;
274  buttonskipby4_7[3] = .30;
275 
276  unsetbit( whattodraw, 4 );
277  for (int i = 0; i < NAVTOTALMESHCOUNT; i++)
278  mesh[i] = NULL;
279  vs_fprintf( stderr, "ERROR: Map mesh file not found!!! Using default: blank mesh.\n" );
280  //end DUMMY VARS
281  }
282  ScreenToCoord( screenskipby4[0] );
283  ScreenToCoord( screenskipby4[1] );
284  ScreenToCoord( screenskipby4[2] );
285  ScreenToCoord( screenskipby4[3] );
286 
287  ScreenToCoord( buttonskipby4_1[0] );
288  ScreenToCoord( buttonskipby4_1[1] );
289  ScreenToCoord( buttonskipby4_1[2] );
290  ScreenToCoord( buttonskipby4_1[3] );
291 
292  ScreenToCoord( buttonskipby4_2[0] );
293  ScreenToCoord( buttonskipby4_2[1] );
294  ScreenToCoord( buttonskipby4_2[2] );
295  ScreenToCoord( buttonskipby4_2[3] );
296 
297  ScreenToCoord( buttonskipby4_3[0] );
298  ScreenToCoord( buttonskipby4_3[1] );
299  ScreenToCoord( buttonskipby4_3[2] );
300  ScreenToCoord( buttonskipby4_3[3] );
301 
302  ScreenToCoord( buttonskipby4_4[0] );
303  ScreenToCoord( buttonskipby4_4[1] );
304  ScreenToCoord( buttonskipby4_4[2] );
305  ScreenToCoord( buttonskipby4_4[3] );
306 
307  ScreenToCoord( buttonskipby4_5[0] );
308  ScreenToCoord( buttonskipby4_5[1] );
309  ScreenToCoord( buttonskipby4_5[2] );
310  ScreenToCoord( buttonskipby4_5[3] );
311 
312  ScreenToCoord( buttonskipby4_6[0] );
313  ScreenToCoord( buttonskipby4_6[1] );
314  ScreenToCoord( buttonskipby4_6[2] );
315  ScreenToCoord( buttonskipby4_6[3] );
316 
317  ScreenToCoord( buttonskipby4_7[0] );
318  ScreenToCoord( buttonskipby4_7[1] );
319  ScreenToCoord( buttonskipby4_7[2] );
320  ScreenToCoord( buttonskipby4_7[3] );
321 
322 //reverse = XMLSupport::parse_bool (vs_config->getVariable ("joystick","reverse_mouse_spr","true"))?1:-1;
323 
324  reverse = -1;
325  if ( (screenskipby4[1]-screenskipby4[0]) < (screenskipby4[3]-screenskipby4[2]) )
326  system_item_scale *= (screenskipby4[1]-screenskipby4[0]); //is actually over 1, which is itself
327  else
328  system_item_scale *= (screenskipby4[3]-screenskipby4[2]);
329  screenoccupation = new navscreenoccupied( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3], 1 );
330 
331  //Get special colors from the config
332  float tempcol1[4] = {1, 0.3, 0.3, 1.0};
333  vs_config->getColor( "nav", "current_system", tempcol1, true );
334  currentcol = GFXColor( tempcol1[0], tempcol1[1], tempcol1[2], tempcol1[3] );
335  float tempcol2[4] = {1, 0.77, 0.3, 1.0};
336  vs_config->getColor( "nav", "destination_system", tempcol2, true );
337  destinationcol = GFXColor( tempcol2[0], tempcol2[1], tempcol2[2], tempcol2[3] );
338  float tempcol3[4] = {0.3, 1, 0.3, 1.0};
339  vs_config->getColor( "nav", "selection_system", tempcol3, true );
340  selectcol = GFXColor( tempcol3[0], tempcol3[1], tempcol3[2], tempcol3[3] );
341  float tempcol4[4] = {1, 0.3, 0.3, 1.0};
342  vs_config->getColor( "nav", "path_system", tempcol4, true );
343  pathcol = GFXColor( tempcol4[0], tempcol4[1], tempcol4[2], tempcol4[3] );
344 
345  navcomp->init();
346 }
bool NavigationSystem::TestIfInRange ( float x1,
float x2,
float y1,
float y2,
float  tx,
float  ty 
)

Definition at line 1315 of file navscreen.cpp.

Referenced by DrawButton(), DrawGalaxy(), DrawSectorList(), and DrawSystem().

1316 {
1317  if ( ( (tx < x2) && (tx > x1) ) && ( (ty < y2) && (ty > y1) ) )
1318  return 1;
1319  else
1320  return 0;
1321 }
bool NavigationSystem::TestIfInRangeBlk ( float x1,
float x2,
float  size,
float  tx,
float  ty 
)

Definition at line 1338 of file navscreen.cpp.

References Delta().

Referenced by DrawSystem().

1339 {
1340  if ( ( Delta( tx, x ) < (0.5*size) ) && ( Delta( ty, y ) < (0.5*size) ) )
1341  return 1;
1342  else
1343  return 0;
1344 }
bool NavigationSystem::TestIfInRangeRad ( float x,
float y,
float  size,
float  tx,
float  ty 
)

Definition at line 1326 of file navscreen.cpp.

Referenced by DrawGalaxy(), and DrawSystem().

1327 {
1328  if ( ( ( (x-tx)*(x-tx) )+( (y-ty)*(y-ty) ) ) < ( (0.5*size)*(0.5*size) ) )
1329  return 1;
1330  else
1331  return 0;
1332 }
void NavigationSystem::updatePath ( )

Friends And Related Function Documentation

friend class AbsolutePathNode
friend

Definition at line 135 of file navscreen.h.

friend class CriteriaContains
friend

Definition at line 136 of file navscreen.h.

friend class CriteriaOwnedBy
friend

Definition at line 137 of file navscreen.h.

friend class CriteriaSector
friend

Definition at line 138 of file navscreen.h.

friend class CurrentPathNode
friend

Definition at line 133 of file navscreen.h.

friend class NavComputer
friend

Definition at line 132 of file navscreen.h.

Referenced by NavigationSystem().

friend class NavPath
friend

Definition at line 139 of file navscreen.h.

friend class TargetPathNode
friend

Definition at line 134 of file navscreen.h.

Member Data Documentation

int NavigationSystem::mousestat
static

Definition at line 341 of file navscreen.h.

Referenced by getMouseButtonStatus(), mouseClick(), and SetMouseFlipStatus().

int NavigationSystem::mousex = 0
static

Definition at line 339 of file navscreen.h.

Referenced by Draw(), mouseClick(), mouseDrag(), mouseMotion(), and Setup().

int NavigationSystem::mousey = 0
static

Definition at line 340 of file navscreen.h.

Referenced by Draw(), mouseClick(), mouseDrag(), mouseMotion(), and Setup().


The documentation for this class was generated from the following files: