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
drawgalaxy.cpp File Reference
#include <algorithm>
#include <cmath>
#include "vs_globals.h"
#include "vegastrike.h"
#include "gfx/gauge.h"
#include "gfx/cockpit.h"
#include "universe.h"
#include "star_system.h"
#include "cmd/unit_generic.h"
#include "cmd/unit_factory.h"
#include "cmd/collection.h"
#include "gfx/hud.h"
#include "gfx/vdu.h"
#include "lin_time.h"
#include "config_xml.h"
#include "cmd/images.h"
#include "cmd/script/mission.h"
#include "cmd/script/msgcenter.h"
#include "cmd/ai/flyjoystick.h"
#include "cmd/ai/firekeyboard.h"
#include "cmd/ai/aggressive.h"
#include "main_loop.h"
#include <assert.h>
#include "savegame.h"
#include "gfx/animation.h"
#include "gfx/mesh.h"
#include "universe_util.h"
#include "in_mouse.h"
#include "gui/glut_support.h"
#include "networking/netclient.h"
#include "cmd/unit_util.h"
#include "hashtable.h"
#include "navscreen.h"
#include "gfx/masks.h"
#include "navscreenoccupied.h"

Go to the source code of this file.

Classes

class  systemdrawnode
 

Macros

#define SQRT3   1.7320508
 

Typedefs

typedef vector< systemdrawnodesystemdrawlist
 

Functions

static void DrawNodeDescription (string text, float x_, float y_, float size_x, float size_y, bool ignore_occupied_areas, const GFXColor &col, navscreenoccupied *screenoccupation)
 
static char GetSystemColor (string source)
 
static void DrawNode (int type, float size, float x, float y, std::string source, navscreenoccupied *screenoccupation, bool moused, GFXColor race, bool mouseover=false, bool willclick=false, string insector="")
 
bool testandset (bool &b, bool val)
 
bool checkedVisited (const std::string &n)
 
float vsmax (float x, float y)
 

Variables

float SYSTEM_DEFAULT_SIZE = 0.02
 
const int systemambiguous = 0
 
static GFXColor GrayColor (.5,.5,.5,.5)
 
float GrayColorArray [4] = {.5, .5, .5, .5}
 
float screensmash = 1
 
static
NavigationSystem::CachedSystemIterator::SystemInfo 
nullPair ("-", QVector(0, 0, 0), std::vector< std::string >(), NULL)
 
static
NavigationSystem::CachedSectorIterator::SectorInfo 
nullSectorPair ("-")
 

Macro Definition Documentation

#define SQRT3   1.7320508

Typedef Documentation

typedef vector< systemdrawnode > systemdrawlist

Definition at line 226 of file drawgalaxy.cpp.

Function Documentation

bool checkedVisited ( const std::string &  n)

Definition at line 288 of file drawgalaxy.cpp.

References _Universe, Universe::AccessCockpit(), SaveGame::getMissionData(), VegaConfig::getVariable(), XMLSupport::parse_bool(), Cockpit::savegame, v, and vs_config.

Referenced by NavigationSystem::CachedSystemIterator::SystemInfo::isDrawable().

289 {
290  static bool dontbothervisiting = !XMLSupport::parse_bool( vs_config->getVariable( "graphics", "explore_for_map", "false" ) );
291  if (dontbothervisiting) {
292  return true;
293  } else {
294  string key( string( "visited_" )+n );
295  vector< float > *v = &_Universe->AccessCockpit()->savegame->getMissionData( key );
296  if (v->size() > 0)
297  return true;
298  return false;
299  }
300 }
static void DrawNode ( int  type,
float  size,
float  x,
float  y,
std::string  source,
navscreenoccupied screenoccupation,
bool  moused,
GFXColor  race,
bool  mouseover = false,
bool  willclick = false,
string  insector = "" 
)
static

Definition at line 102 of file drawgalaxy.cpp.

References GFXColor::b, Beautify(), NavigationSystem::DrawCircle(), DrawNodeDescription(), GFXColor::g, VegaConfig::getColor(), GetSystemColor(), GrayColor, GFXColor::r, and vs_config.

Referenced by systemdrawnode::draw(), and NavigationSystem::DrawGalaxy().

113 {
114  char color = GetSystemColor( source );
115  if (moused)
116  return;
117  if (willclick == true && mouseover == false)
118  //Perhaps some key binding or mouseclick will be set in the future to do this.
119  mouseover = true;
120  static bool inited = false;
121  static GFXColor highlighted_tail_col;
122  static GFXColor highlighted_tail_text;
123  if (!inited) {
124  float col1[4] = {1, .3, .3, .8};
125  vs_config->getColor( "nav", "highlighted_unit_on_tail", col1, true );
126  highlighted_tail_col = GFXColor( col1[0], col1[1], col1[2], col1[3] );
127 
128  float col2[4] = {1, 1, .7, 1};
129  vs_config->getColor( "nav", "highlighted_text_on_tail", col2, true );
130  highlighted_tail_text = GFXColor( col2[0], col2[1], col2[2], col2[3] );
131  inited = true;
132  }
133  if (color == 'm')
134  race = GrayColor;
135  if (mouseover) {
136  if (willclick) {
137  race = highlighted_tail_col;
138  } else {
139  //Leave just a faint resemblence of the original color,
140  //but also make it look whiteish.
141  race.r += .75;
142  race.g += .75;
143  race.b += .75;
144  }
145  }
147  if ( (!mouseover) || (willclick) ) {
148  string tsector, nam;
149  Beautify( source, tsector, nam );
150  if (willclick) {
151  race = highlighted_tail_text;
152  nam = tsector+" / "+nam;
153  }
154  if ( willclick || !( insector.compare( "" ) ) || !( insector.compare( tsector ) ) )
155  DrawNodeDescription( nam, x, y, 1.0, 1.0, 0, race, screenoccupation );
156  }
157 }
static void DrawNodeDescription ( string  text,
float  x_,
float  y_,
float  size_x,
float  size_y,
bool  ignore_occupied_areas,
const GFXColor col,
navscreenoccupied screenoccupation 
)
static

Definition at line 49 of file drawgalaxy.cpp.

References GFXColor::a, TextPlane::bgcol, TextPlane::col, TextPlane::Draw(), navscreenoccupied::findfreesector(), float, VegaConfig::getVariable(), XMLSupport::parse_float(), TextPlane::SetCharSize(), TextPlane::SetPos(), TextPlane::SetText(), and vs_config.

Referenced by DrawNode().

57 {
58  //take the head and stick it in the back
59  if (text.size() == 0)
60  return;
61  TextPlane displayname; //will be used to display shits names
62  displayname.col = col;
63  static float background_alpha =
64  XMLSupport::parse_float( vs_config->getVariable( "graphics", "hud", "text_background_alpha", "0.0625" ) );
65  int length = text.size();
66  float offset = (float(length)*0.005);
67  if (ignore_occupied_areas) {
68  displayname.SetPos( (x_-offset), y_ );
69  displayname.SetText( text );
70  displayname.SetCharSize( size_x, size_y );
71 
72  GFXColor tpbg = displayname.bgcol;
73  bool automatte = (0 == tpbg.a);
74  if (automatte) displayname.bgcol = GFXColor( 0, 0, 0, background_alpha );
75  displayname.Draw( text, 0, true, false, automatte );
76  displayname.bgcol = tpbg;
77  } else {
78  float new_y = screenoccupation->findfreesector( x_, y_ );
79  displayname.SetPos( (x_-offset), new_y );
80  displayname.SetText( text );
81  displayname.SetCharSize( size_x, size_y );
82  GFXColor tpbg = displayname.bgcol;
83  bool automatte = (0 == tpbg.a);
84  if (automatte) displayname.bgcol = GFXColor( 0, 0, 0, background_alpha );
85  displayname.Draw( text, 0, true, false, automatte );
86  displayname.bgcol = tpbg;
87  }
88 }
static char GetSystemColor ( string  source)
static

Definition at line 90 of file drawgalaxy.cpp.

References _Universe, Universe::AccessCockpit(), SaveGame::getMissionData(), k, Cockpit::savegame, and v.

Referenced by DrawNode().

91 {
92  //FIXME: update me!!!
93  vector< float > *v = &_Universe->AccessCockpit()->savegame->getMissionData( "visited_"+source );
94  if ( v->size() ) {
95  float k = (*v)[0];
96  if (k >= 2)
97  return k == 2 ? 'm' : '?';
98  }
99  return 'v';
100 }
bool testandset ( bool b,
bool  val 
)

Definition at line 229 of file drawgalaxy.cpp.

References b.

Referenced by NavigationSystem::SystemIterator::operator++().

230 {
231  bool tmp = b;
232  b = val;
233  return tmp;
234 }
float vsmax ( float  x,
float  y 
)

Definition at line 727 of file drawgalaxy.cpp.

References y.

Referenced by NavigationSystem::DrawGalaxy().

728 {
729  return x > y ? x : y;
730 }

Variable Documentation

GFXColor GrayColor(.5,.5,.5,.5)
static

Referenced by DrawNode().

float GrayColorArray[4] = {.5, .5, .5, .5}
float screensmash = 1

Definition at line 236 of file drawgalaxy.cpp.

Referenced by NavigationSystem::SystemIterator::Position().

float SYSTEM_DEFAULT_SIZE = 0.02

Definition at line 44 of file drawgalaxy.cpp.

Referenced by NavigationSystem::DrawGalaxy().

const int systemambiguous = 0

Definition at line 45 of file drawgalaxy.cpp.

Referenced by NavigationSystem::DrawGalaxy().