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
drawlist.h File Reference
#include <stdlib.h>
#include <string>
#include "cmd/unit_generic.h"
#include "navscreenoccupied.h"
#include "gui/glut_support.h"
#include "navscreen.h"
#include "navitemtypes.h"

Go to the source code of this file.

Classes

class  navdrawnode
 
class  navdrawlist
 

Functions

void drawdescription (Unit *source, float x, float y, float size_x, float size_y, bool ignore_occupied_areas, navscreenoccupied *screenoccupation, const GFXColor &col)
 
void drawdescription (string text, float x, float y, float size_x, float size_y, bool ignore_occupied_areas, navscreenoccupied *screenoccupation, const GFXColor &col)
 
void drawlistitem (int type, float size, float x, float y, Unit *source, navscreenoccupied *screenoccupation, bool inmouserange, bool currentistail, float unselectedalpha, GFXColor *factioncolours)
 

Function Documentation

void drawdescription ( Unit source,
float  x,
float  y,
float  size_x,
float  size_y,
bool  ignore_occupied_areas,
navscreenoccupied screenoccupation,
const GFXColor col 
)

Definition at line 123 of file drawlist.cpp.

References drawdescription(), and getUnitNameAndFgNoBase().

Referenced by drawdescription(), drawlistitem(), NavigationSystem::DrawMission(), and NavigationSystem::DrawSectorList().

131 {
132  if (source == NULL)
133  return;
134  drawdescription( getUnitNameAndFgNoBase( source ), x_, y_, size_x, size_y, ignore_occupied_areas, screenoccupation, col );
135 }
void drawdescription ( string  text,
float  x,
float  y,
float  size_x,
float  size_y,
bool  ignore_occupied_areas,
navscreenoccupied screenoccupation,
const GFXColor col 
)

Definition at line 137 of file drawlist.cpp.

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

145 {
146  if (text.size() == 0)
147  return;
148  TextPlane displayname; //will be used to display shits names
149 
150  displayname.col = col;
151 
152  int length = text.size();
153  float offset = (float(length)*0.005);
154  if (ignore_occupied_areas) {
155  displayname.SetPos( (x_-offset), y_ );
156  displayname.SetText( text );
157  displayname.SetCharSize( size_x, size_y );
158  } else {
159  float new_y = screenoccupation->findfreesector( x_, y_ );
160  displayname.SetPos( (x_-offset), new_y );
161  displayname.SetText( text );
162  displayname.SetCharSize( size_x, size_y );
163  }
164  static float background_alpha =
165  XMLSupport::parse_float( vs_config->getVariable( "graphics", "hud", "text_background_alpha", "0.0625" ) );
166  GFXColor tpbg = displayname.bgcol;
167  bool automatte = (0 == tpbg.a);
168  if (automatte) displayname.bgcol = GFXColor( 0, 0, 0, background_alpha );
169  displayname.Draw( text, 0, true, false, automatte );
170  displayname.bgcol = tpbg;
171 }
void drawlistitem ( int  type,
float  size,
float  x,
float  y,
Unit source,
navscreenoccupied screenoccupation,
bool  inmouserange,
bool  currentistail,
float  unselectedalpha,
GFXColor factioncolours 
)

Definition at line 200 of file drawlist.cpp.

References GFXColor::a, Delta(), NavigationSystem::DrawCircle(), drawdescription(), NavigationSystem::DrawHalfCircleTop(), NavigationSystem::DrawJump(), NavigationSystem::DrawMissile(), NavigationSystem::DrawPlanet(), NavigationSystem::DrawStation(), Unit::faction, VegaConfig::getColor(), UniverseUtil::getCurrentPlayer(), UniverseUtil::getPlayerX(), Unit::getRelation(), getUnitTypeColor(), INIT_COL_ARRAY, navasteroid, navcapship, navcurrentplayer, navfighter, navjump, navmissile, navnebula, navplanet, navplayer, navstation, navsun, and vs_config.

Referenced by navdrawlist::draw(), and NavigationSystem::DrawSystem().

210 {
211  float relation = 0.0;
212  static GFXColor unhighlighted_sun_col;
213  static GFXColor unhighlighted_sun_text;
214  static GFXColor unhighlighted_planet_text;
215  static GFXColor unhighlighted_c_player_col;
216  static GFXColor unhighlighted_c_player_text;
217  static GFXColor unhighlighted_player_col;
218  static GFXColor unhighlighted_player_text;
219  static GFXColor unhighlighted_asteroid_col;
220  static GFXColor unhighlighted_asteroid_text;
221  static GFXColor unhighlighted_nebula_col;
222  static GFXColor unhighlighted_nebula_text;
223  static GFXColor unhighlighted_jump_col;
224  static GFXColor unhighlighted_jump_text;
225  static GFXColor unhighlighted_station_text;
226  static GFXColor unhighlighted_fighter_text;
227  static GFXColor unhighlighted_unit_text;
228  static GFXColor highlighted_tail_col;
229  static GFXColor highlighted_tail_text;
230  static GFXColor highlighted_untail_col;
231  static GFXColor unhighlighted_capship_text;
232  static bool init = false;
233  if (!init) {
234  //Get a color from the config
235  float col[4];
236 
237  INIT_COL_ARRAY( col, 1, .3, .3, .8 );
238  vs_config->getColor( "nav", "highlighted_unit_on_tail", col, true );
239  highlighted_tail_col = GFXColor( col[0], col[1], col[2], col[3] );
240 
241  INIT_COL_ARRAY( col, 1, 1, .7, 1 );
242  vs_config->getColor( "nav", "highlighted_text_on_tail", col, true );
243  highlighted_tail_text = GFXColor( col[0], col[1], col[2], col[3] );
244 
245  INIT_COL_ARRAY( col, 1, 1, 1, .8 );
246  vs_config->getColor( "nav", "highlighted_unit_off_tail", col, true );
247  highlighted_untail_col = GFXColor( col[0], col[1], col[2], col[3] );
248 
249  INIT_COL_ARRAY( col, 0, 0, 0, 0 ); //If not found, use defaults
250  unhighlighted_sun_col = getUnitTypeColor( "sun", false, col, unselectedalpha );
251  INIT_COL_ARRAY( col, 0, 0, 0, 0 );
252  unhighlighted_sun_text = getUnitTypeColor( "sun", true, col, unselectedalpha );
253 
254  //Planet color is the relation color, so is not defined here.
255  INIT_COL_ARRAY( col, 0, 0, 0, 0 );
256  unhighlighted_planet_text = getUnitTypeColor( "planet", true, col, unselectedalpha );
257 
258  INIT_COL_ARRAY( col, .3, .3, 1, .8 ); //If not found, use defaults
259  unhighlighted_c_player_col = getUnitTypeColor( "curplayer", false, col, .8 );
260  INIT_COL_ARRAY( col, .3, .3, 1, 0 );
261  unhighlighted_c_player_text = getUnitTypeColor( "curplayer", true, col, unselectedalpha );
262 
263  INIT_COL_ARRAY( col, .3, .3, 1, .8 ); //If not found, use defaults
264  unhighlighted_player_col = getUnitTypeColor( "player", false, col, .8 );
265  INIT_COL_ARRAY( col, .3, .3, 1, 0 );
266  unhighlighted_player_text = getUnitTypeColor( "player", true, col, unselectedalpha );
267 
268  INIT_COL_ARRAY( col, .3, .3, 1, .8 ); //If not found, use defaults
269  unhighlighted_player_col = getUnitTypeColor( "player", false, col, .8 );
270  INIT_COL_ARRAY( col, .3, .3, 1, 0 );
271  unhighlighted_player_text = getUnitTypeColor( "player", true, col, unselectedalpha );
272 
273  INIT_COL_ARRAY( col, 1, .8, .8, .6 ); //If not found, use defaults
274  unhighlighted_asteroid_col = getUnitTypeColor( "asteroid", false, col, .6 );
275  INIT_COL_ARRAY( col, 0, 0, 0, 0 );
276  unhighlighted_asteroid_text = getUnitTypeColor( "asteroid", true, col, unselectedalpha );
277 
278  INIT_COL_ARRAY( col, 1, .5, 1, .6 ); //If not found, use defaults
279  unhighlighted_nebula_col = getUnitTypeColor( "nebula", false, col, .6 );
280  INIT_COL_ARRAY( col, 0, 0, 0, 0 );
281  unhighlighted_nebula_text = getUnitTypeColor( "nebula", true, col, unselectedalpha );
282 
283  INIT_COL_ARRAY( col, .5, .9, .9, .6 ); //If not found, use defaults
284  unhighlighted_jump_col = getUnitTypeColor( "jump", false, col, .6 );
285  INIT_COL_ARRAY( col, .3, 1, .8, 0 );
286  unhighlighted_jump_text = getUnitTypeColor( "jump", true, col, unselectedalpha );
287 
288  //Basic unit types:
289  INIT_COL_ARRAY( col, 0, 0, 0, 0 );
290  unhighlighted_station_text = getUnitTypeColor( "station", true, col, unselectedalpha );
291  INIT_COL_ARRAY( col, 0, 0, 0, 0 );
292  unhighlighted_fighter_text = getUnitTypeColor( "fighter", true, col, unselectedalpha );
293  INIT_COL_ARRAY( col, 0, 0, 0, 0 );
294  unhighlighted_capship_text = getUnitTypeColor( "capship", true, col, unselectedalpha );
295  INIT_COL_ARRAY( col, 0, 0, 0, 0 );
296  unhighlighted_unit_text = getUnitTypeColor( "unit", true, col, unselectedalpha );
297 
298  init = true;
299  }
300 //if(source != NULL)
301 //relation = FactionUtil::GetIntRelation( ( UniverseUtil::getPlayerX(UniverseUtil::getCurrentPlayer()) )->faction ,source->faction);
302 //else
303 //relation = 0;
304  //the realtime relationship
305  if (source != NULL)
307  else
308  relation = 0;
309  relation = relation*0.5;
310  relation = relation+0.5;
311 
312 //to avoid duplicate code
313  GFXColor relColor( (1.0-relation), relation, ( 1.0-( 2.0*Delta( relation, 0.5 ) ) ), .7 );
314 //GFXColor((1.0-relation),relation,(1.0-(2.0*Delta(relation, 0.5))),1)
315  if (type == navsun) {
316  if (!inmouserange) {
317  NavigationSystem::DrawCircle( x, y, size, unhighlighted_sun_col );
318  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, unhighlighted_sun_text );
319  } else {
320  if (currentistail)
321  NavigationSystem::DrawCircle( x, y, size, highlighted_tail_col );
322  else
323  NavigationSystem::DrawCircle( x, y, size, highlighted_untail_col );
324  }
325  } else if (type == navplanet) {
326  if (!inmouserange) {
327  NavigationSystem::DrawPlanet( x, y, size, relColor );
328  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, unhighlighted_planet_text );
329  } else {
330  if (currentistail)
331  NavigationSystem::DrawPlanet( x, y, size, highlighted_tail_col );
332  else
333  NavigationSystem::DrawPlanet( x, y, size, highlighted_untail_col );
334  }
335  } else if (type == navcurrentplayer) {
336  if (!inmouserange) {
337  NavigationSystem::DrawHalfCircleTop( x, y, size, unhighlighted_c_player_col );
338  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, unhighlighted_c_player_text );
339  } else {
340  if (currentistail)
341  NavigationSystem::DrawHalfCircleTop( x, y, size, highlighted_tail_col );
342  else
343  NavigationSystem::DrawHalfCircleTop( x, y, size, highlighted_untail_col );
344  }
345  } else if (type == navplayer) {
346  if (!inmouserange) {
347  NavigationSystem::DrawHalfCircleTop( x, y, size, unhighlighted_player_col );
348  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, unhighlighted_player_col );
349  } else {
350  if (currentistail)
351  NavigationSystem::DrawHalfCircleTop( x, y, size, highlighted_tail_col );
352  else
353  NavigationSystem::DrawHalfCircleTop( x, y, size, highlighted_untail_col );
354  }
355  } else if (type == navstation) {
356  if (!inmouserange) {
357  NavigationSystem::DrawStation( x, y, size, relColor );
358  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, unhighlighted_station_text );
359  } else {
360  if (currentistail)
361  NavigationSystem::DrawStation( x, y, size, highlighted_tail_col );
362  else
363  NavigationSystem::DrawStation( x, y, size, highlighted_untail_col );
364  }
365  } else if (type == navfighter) {
366  if (!inmouserange) {
367  if (factioncolours == NULL) {
369  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, unhighlighted_fighter_text );
370  } else {
372  GFXColor thecolor = factioncolours[source->faction];
373  thecolor.a = unselectedalpha;
374  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, thecolor );
375  }
376  } else {
377  if (currentistail)
378  NavigationSystem::DrawHalfCircleTop( x, y, size, highlighted_tail_col );
379  else
380  NavigationSystem::DrawHalfCircleTop( x, y, size, highlighted_untail_col );
381  }
382  } else if (type == navcapship) {
383  if (!inmouserange) {
384  if (factioncolours == NULL) {
385  NavigationSystem::DrawCircle( x, y, size, relColor );
386  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, unhighlighted_capship_text );
387  } else {
388  NavigationSystem::DrawCircle( x, y, size, relColor );
389  GFXColor thecolor = factioncolours[source->faction];
390 
391  thecolor.a = unselectedalpha;
392 
393  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, thecolor );
394  }
395  } else {
396  if (currentistail)
397  NavigationSystem::DrawCircle( x, y, size, highlighted_tail_col );
398  else
399  NavigationSystem::DrawCircle( x, y, size, highlighted_untail_col );
400  }
401  } else if (type == navmissile) {
402  if (!inmouserange) {
403  NavigationSystem::DrawMissile( x, y, size, relColor );
404 //drawdescription(source, x, y, 1.0, 1.0, false, screenoccupation, GFXColor(.2, 1, .5, unselectedalpha));
405  }
406  //NOT DRAWING NAME OF MISSILE TO MAKE ROOM FOR IMPORTANT TEXT ON SCREEN
407  else {
408  if (currentistail)
409  NavigationSystem::DrawMissile( x, y, size, highlighted_tail_col );
410  else
411  NavigationSystem::DrawMissile( x, y, size, highlighted_untail_col );
412  }
413  } else if (type == navasteroid) {
414  if (!inmouserange) {
415  NavigationSystem::DrawCircle( x, y, size, unhighlighted_asteroid_col );
416  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, unhighlighted_asteroid_text );
417  } else {
418  if (currentistail)
419  NavigationSystem::DrawCircle( x, y, size, highlighted_tail_col );
420  else
421  NavigationSystem::DrawCircle( x, y, size, highlighted_untail_col );
422  }
423  } else if (type == navnebula) {
424  if (!inmouserange) {
425  NavigationSystem::DrawCircle( x, y, size, unhighlighted_nebula_col );
426  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, unhighlighted_nebula_text );
427  } else {
428  if (currentistail)
429  NavigationSystem::DrawCircle( x, y, size, highlighted_tail_col );
430  else
431  NavigationSystem::DrawCircle( x, y, size, highlighted_untail_col );
432  }
433  } else if (type == navjump) {
434  if (!inmouserange) {
435  NavigationSystem::DrawJump( x, y, size, unhighlighted_jump_col );
436  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, unhighlighted_jump_text );
437  } else {
438  if (currentistail)
439  NavigationSystem::DrawJump( x, y, size, highlighted_tail_col );
440  else
441  NavigationSystem::DrawJump( x, y, size, highlighted_untail_col );
442  }
443  } else {
444  if (!inmouserange) {
446  GFXColor( (1.0-relation), relation, ( 1.0-( 2.0*Delta( relation, 0.5 ) ) ), .6 ) );
447  drawdescription( source, x, y, 1.0, 1.0, false, screenoccupation, unhighlighted_unit_text );
448  } else {
449  if (currentistail)
450  NavigationSystem::DrawCircle( x, y, size, highlighted_tail_col );
451  else
452  NavigationSystem::DrawCircle( x, y, size, highlighted_untail_col );
453  }
454  }
455  //SHOW THE NAME ALL BIG AND SHIT
456  if ( (currentistail) && (inmouserange == 1) )
457  //DISPLAY THE NAME
458  drawdescription( source, x, y, 2.0, 2.0, false, screenoccupation, GFXColor( 1, 1, .7, 1 ) );
459 }