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
navscreen.h
Go to the documentation of this file.
1 #ifndef _NAVSCREEN_H_
2 #define _NAVSCREEN_H_
3 
4 #include "gui/glut_support.h"
5 #include "navscreenoccupied.h"
6 #include "drawlist.h"
7 #include "navitemtypes.h"
8 #include "gfx/masks.h"
9 #include "navcomputer.h"
10 #include "navpath.h"
11 #include "gfx/hud.h"
12 #include "gnuhash.h"
13 
14 #define NAVTOTALMESHCOUNT 8 //same as the button count, 1 mesh for screen and 1 per button(1+7)
15 #define MAXZOOM 10
16 
17 void Beautify( string systemfile, string &sector, string &system );
19 {
20 public:
22  {
23  vector< string >vstack;
24  unsigned int which;
25  unsigned int count;
26  unsigned int maxcount;
27  vsUMap< string, bool >visited;
28 
29 public: SystemIterator( string current_system, unsigned int max = 2 );
30  bool done() const;
31  QVector Position();
32  string operator*();
35  };
36 
38  {
39 public:
40 //typedef std::pair<string, QVector> SystemInfo;
41  struct SystemInfo
42  {
43  string name;
45  std::vector< unsigned >lowerdestinations;
48  std::set< NavPath* >paths;
49  void UpdateColor();
50  string & GetName();
51  const string& GetName() const;
52  bool isDrawable() const;
53  QVector& Position();
54  const QVector& Position() const;
55  unsigned GetDestinationIndex( unsigned index ) const;
56  unsigned GetDestinationSize() const;
58  SystemInfo( const string &name );
59  SystemInfo( const string &name,
60  const QVector &position,
61  const std::vector< std::string > &destinations,
62  CachedSystemIterator *csi );
63  void loadData( map< string, unsigned > *index_table );
64  };
65 
66 private:
67  friend struct SystemInfo; //inner class needs to be friend in gcc-295
68  vector< SystemInfo >systems;
69  unsigned currentPosition;
70  CachedSystemIterator( const CachedSystemIterator &other ); //May be really slow. Don't try this at home.
71  CachedSystemIterator operator++( int ); //Also really slow because it has to use the copy constructor.
72 
73 public: CachedSystemIterator();
74  CachedSystemIterator( string current_system, unsigned max_systems = 2 );
75  void init( string current_system, unsigned max_systems = 2 );
76  bool seek( unsigned position = 0 );
77  unsigned getIndex() const;
78  unsigned size() const;
79  bool done() const;
80  SystemInfo& operator[]( unsigned pos );
81  const SystemInfo& operator[]( unsigned pos ) const;
83  const SystemInfo & operator*() const;
85  const SystemInfo* operator->() const;
88  };
89 
91  {
92 public:
93  class SectorInfo
94  {
95 public:
96  string name;
97  std::vector< unsigned >subsystems;
98  string& GetName();
99  const string& GetName() const;
100  unsigned GetSubsystemIndex( unsigned index ) const;
101  unsigned GetSubsystemSize() const;
102  SectorInfo( const string &name );
103  void AddSystem( unsigned index );
104  };
105 
106 private:
107  friend class SectorInfo; //inner class needs to be friend in gcc-295
108  vector< SectorInfo >sectors;
109  unsigned currentPosition;
110  CachedSectorIterator( const CachedSectorIterator &other ); //May be really slow. Don't try this at home.
111  CachedSectorIterator operator++( int ); //Also really slow because it has to use the copy constructor.
112 
113 public: CachedSectorIterator();
115  void init( CachedSystemIterator &systemIter );
116  bool seek( unsigned position = 0 );
117  unsigned getIndex() const;
118  unsigned size() const;
119  bool done() const;
120  SectorInfo& operator[]( unsigned pos );
121  const SectorInfo& operator[]( unsigned pos ) const;
123  const SectorInfo & operator*() const;
125  const SectorInfo* operator->() const;
128  };
129 
131 private:
132  friend class NavComputer;
133  friend class CurrentPathNode;
134  friend class TargetPathNode;
135  friend class AbsolutePathNode;
136  friend class CriteriaContains;
137  friend class CriteriaOwnedBy;
138  friend class CriteriaSector;
139  friend class NavPath;
140  NavComputer *navcomp;
141  unsigned currentsystemindex;
142  unsigned focusedsystemindex;
143  unsigned destinationsystemindex;
144  unsigned systemselectionindex;
145  unsigned sectorselectionindex;
146  CachedSystemIterator systemIter;
147  CachedSectorIterator sectorIter;
148  std::vector< unsigned >path;
149  class navscreenoccupied*screenoccupation;
150  class Mesh*mesh[NAVTOTALMESHCOUNT];
151  int reverse;
152  int rotations; //tried to change to unsigned but gazillions of comparisons to int crop up --chuck_starchaser
153  int axis;
154  int configmode;
155 
156  float rx; //galaxy
157  float ry;
158  float rz;
159  float zoom;
160 
161  float rx_s; //system
162  float ry_s;
163  float rz_s;
164  float zoom_s;
165 
166  float camera_z;
167  float themaxvalue;
168  float zshiftmultiplier;
169  float item_zscalefactor;
170  float minimumitemscaledown;
171  float maximumitemscaleup;
172 
173  enum ViewType {VIEW_2D, VIEW_ORTHO, VIEW_3D, VIEW_MAX};
174  int system_view;
175  int galaxy_view;
176 
177  int path_view;
178  enum PathType {PATH_OFF, PATH_ON, PATH_ONLY, PATH_MAXIMUM};
179 
180  bool system_multi_dimensional;
181  bool galaxy_multi_dimensional;
182 
183  float center_x;
184  float center_y;
185  float center_z;
186 
187  signed int scrolloffset;
188 
189  float mouse_x_previous;
190  float mouse_y_previous;
191  float mouse_x_current;
192  float mouse_y_current;
193  signed char draw;
194  bool mouse_previous_state[5];
195  bool mouse_wentup[5];
196  bool mouse_wentdown[5];
197  UnitContainer currentselection;
198  GFXColor *factioncolours;
199  GFXColor currentcol;
200  GFXColor destinationcol;
201  GFXColor selectcol;
202  GFXColor pathcol;
203 
204 //DrawSectorList's scroll control variables
205  unsigned sectorOffset;
206  unsigned systemOffset;
207 
208  int whattodraw;
209 //bit 0 = undefined
210 //bit 1 = draw system screen / mission screen
211 //bit 2 = draw galaxy/system ship/mission screen
212 //bit 3 = draw sector list screen in mission mode
213 
214 //coordinates done 'over left->right' by 'up bottom->top'
215 //values are 1/100 of the screen width and height
216  float screenskipby4[4]; //0 = x-small 1 = x-large 2 = y-small 3 = y-large
217  float buttonskipby4_1[4];
218  float buttonskipby4_2[4];
219  float buttonskipby4_3[4];
220  float buttonskipby4_4[4];
221  float buttonskipby4_5[4];
222  float buttonskipby4_6[4];
223  float buttonskipby4_7[4];
224  TextPlane screen_objectives;
225  float meshcoordinate_x[NAVTOTALMESHCOUNT];
226  float meshcoordinate_y[NAVTOTALMESHCOUNT];
227  float meshcoordinate_z[NAVTOTALMESHCOUNT];
228  float meshcoordinate_z_delta[NAVTOTALMESHCOUNT];
229 
230  int buttonstates; //bit0 = button1, bit1 = button2, etc
231  float system_item_scale;
232  float unselectedalpha;
233 
234 //Drawing helper functions
235 //*************************
236  void Adjust3dTransformation( bool three_d, bool is_system_not_galaxy );
237  void ReplaceAxes( QVector &pos );
238  void RecordMinAndMax( const QVector &pos,
239  float &min_x,
240  float &max_x,
241  float &min_y,
242  float &max_y,
243  float &min_z,
244  float &max_z,
245  float &max_all );
246  void DrawOriginOrientationTri( float center_nav_x, float center_nav_y, bool system_not_galaxy );
247 
248  float CalculatePerspectiveAdjustment( float &zscale,
249  float &zdistance,
250  QVector &pos,
251  QVector &pos_flat,
252  float &system_item_scale_temp,
253  bool system_not_galaxy );
254 
255  void TranslateCoordinates( QVector &pos,
256  QVector &pos_flat,
257  float center_nav_x,
258  float center_nav_y,
259  float themaxvalue,
260  float &zscale,
261  float &zdistance,
262  float &the_x,
263  float &the_y,
264  float &the_x_flat,
265  float &the_y_flat,
266  float &system_item_scale_temp,
267  bool system_not_galaxy );
268 
269  void TranslateAndDisplay( QVector &pos,
270  QVector &pos_flat,
271  float center_nav_x,
272  float center_nav_y,
273  float themaxvalue,
274  float &zscale,
275  float &zdistance,
276  float &the_x,
277  float &the_y,
278  float &system_item_scale_temp,
279  bool system_not_galaxy );
280 
281  void DisplayOrientationLines( float the_x, float the_y, float the_x_flat, float the_y_flat, bool system_not_galaxy );
282 
283  bool CheckForSelectionQuery();
284  void setCurrentSystemIndex( unsigned newSystemIndex );
285  void setFocusedSystemIndex( unsigned newSystemIndex );
286  void setDestinationSystemIndex( unsigned newSystemIndex );
287 
288  bool BFS( unsigned originIndex, unsigned destIndex );
289  bool DoubleRootedBFS( unsigned originIndex, unsigned destIndex );
290 //*************************
291 
292 public: NavigationSystem();
294  static void DrawCircle( float x, float y, float size, const GFXColor &col );
295  static void DrawHalfCircleTop( float x, float y, float size, const GFXColor &col );
296  static void DrawHalfCircleBottom( float x, float y, float size, const GFXColor &col );
297  static void DrawPlanet( float x, float y, float size, const GFXColor &col );
298  static void DrawStation( float x, float y, float size, const GFXColor &col );
299  static void DrawJump( float x, float y, float size, const GFXColor &col );
300  static void DrawMissile( float x, float y, float size, const GFXColor &col );
301  static void DrawTargetCorners( float x, float y, float size, const GFXColor &col );
302  static void DrawNavCircle( float x, float y, float rot_x, float rot_y, float size, const GFXColor &col );
303  void setCurrentSystem( string newSystem );
304  std::string getCurrentSystem();
305  std::string getSelectedSystem();
306  std::string getFocusedSystem();
307  std::string getDestinationSystem();
308 
309  void DrawButton( float &x1, float &x2, float &y1, float &y2, int button_number, bool outline );
310  void DrawButtonOutline( float &x1, float &x2, float &y1, float &y2, const GFXColor &col );
311  void DrawCursor( float x, float y, float wid, float hei, const GFXColor &col );
312  void DrawGrid( float &screen_x1, float &screen_x2, float &screen_y1, float &screen_y2, const GFXColor &col );
313 
314  bool TestIfInRange( float &x1, float &x2, float &y1, float &y2, float tx, float ty );
315  bool TestIfInRangeBlk( float &x1, float &x2, float size, float tx, float ty );
316  bool TestIfInRangeRad( float &x, float &y, float size, float tx, float ty );
317  bool ParseFile( string filename );
318  bool CheckDraw();
319  void DrawSystem();
320  void DrawGalaxy();
321  void DrawMission();
322  void DrawShip();
323  void DrawSectorList();
324  void DrawObjectives();
325  void SetMouseFlipStatus();
326  void ScreenToCoord( float &x );
327  void IntersectBorder( float &x, float &y, const float &x1, const float &y1 ) const;
328  void Draw();
329  void Setup();
330  void SetDraw( bool n );
331  void ClearPriorities();
332  void updatePath();
333 
334  void scroll( signed int scrollamt )
335  {
336  scrolloffset += scrollamt;
337  }
338 
339  static int mousex;
340  static int mousey;
341  static int mousestat;
342  static void mouseDrag( int x, int y );
343  static void mouseMotion( int x, int y );
344  static void mouseClick( int button, int state, int x, int y );
345  static int getMouseButtonStatus()
346  {
347  return mousestat;
348  }
349  static class QVector dxyz( class QVector, double x_, double y_, double z_ );
350 
351 //float Delta(float a, float b);
352 };
353 
354 #endif
355