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
images.h
Go to the documentation of this file.
1 #ifndef _IMAGES_H
2 #define _IMAGES_H
3 
4 #include <string>
5 #include <vector>
6 #include "gfx/vec.h"
7 #include "container.h"
8 #include "../SharedPool.h"
9 #include "gfx/sprite.h"
10 #include "gfx/animation.h"
11 
13 {
14  struct Type
15  {
16  enum Value
17  {
20 
21  // Unconnected types corresponds to the old true/false values
22  OUTSIDE = 0,
23  INSIDE = 1,
24 
27 
30 
31  DEFAULT = OUTSIDE
32  };
33 
34  static bool IsConnected(const Value& type)
35  {
36  switch (type)
37  {
38  case OUTSIDE:
39  case INSIDE:
40  return false;
41  default:
42  return true;
43  }
44  }
45 
46  static bool IsInside(const Value& type)
47  {
48  switch (type)
49  {
50  case INSIDE:
51  case CONNECTED_INSIDE:
52  case WAYPOINT_INSIDE:
53  return true;
54  default:
55  return false;
56  }
57  }
58 
59  static bool IsWaypoint(const Value& type)
60  {
61  switch (type)
62  {
63  case WAYPOINT_OUTSIDE:
64  case WAYPOINT_INSIDE:
65  return true;
66  default:
67  return false;
68  }
69  }
70  };
71 
73  : radius(0),
74  isInside(false),
75  isConnected(false),
76  isWaypoint(false),
77  isOccupied(false)
78  {}
79 
80  DockingPorts(const Vector &center, float radius, float minradius, const Type::Value& type)
81  : center(center),
82  radius(radius),
83  isInside(Type::IsInside(type)),
84  isConnected(Type::IsConnected(type)),
85  isWaypoint(Type::IsWaypoint(type)),
86  isOccupied(isWaypoint) // Waypoints are always occupied
87  {}
88 
89  DockingPorts(const Vector &min, const Vector &max, float minradius, const Type::Value& type)
90  : center((min + max) / 2.0f),
91  radius((max - min).Magnitude() / 2.0f),
92  isInside(Type::IsInside(type)),
93  isConnected(Type::IsConnected(type)),
94  isWaypoint(Type::IsWaypoint(type)),
95  isOccupied(isWaypoint) // Waypoints are always occupied
96  {}
97 
98  float GetRadius() const { return radius; }
99 
100  const Vector& GetPosition() const { return center; }
101 
102  // Waypoints are always marked as occupied.
103  bool IsOccupied() const { return isOccupied; }
104  void Occupy(bool yes) { isOccupied = yes; }
105 
106  // Does port have connecting waypoints?
107  bool IsConnected() const { return isConnected; }
108 
109  // Port is located inside or outside the station
110  bool IsInside() const { return isInside; }
111 
112  bool IsDockable() const { return !isWaypoint; }
113 
114 private:
115  Vector center;
116  float radius;
117  bool isInside;
118  bool isConnected;
119  bool isWaypoint;
120  bool isOccupied;
121 };
122 
124 {
126  unsigned int whichdock;
127  DockedUnits( Unit *un, unsigned int w ) : uc( un )
128  , whichdock( w ) {}
129 };
130 
131 class Cargo
132 {
133 public:
137  int quantity;
138  float price;
139  float mass;
140  float volume;
141  bool mission;
142  bool installed;
146  {
147  mass = 0;
148  volume = 0;
149  price = 0;
150  quantity = 1;
151  mission = false;
152  installed = false;
154  }
155  Cargo( std::string name, std::string cc, float pp, int qq, float mm, float vv, float func, float maxfunc ) :
156  content( name )
157  , category( cc )
158  {
159  quantity = qq;
160  price = pp;
161  mass = mm;
162  volume = vv;
163  mission = false;
164  installed = false;
165  functionality = func;
166  maxfunctionality = maxfunc;
167  }
168  Cargo( std::string name, std::string cc, float pp, int qq, float mm, float vv ) :
169  content( name )
170  , category( cc )
171  {
172  quantity = qq;
173  price = pp;
174  mass = mm;
175  volume = vv;
176  mission = false;
177  installed = false;
178  }
180  {
181  return functionality;
182  }
184  {
185  return maxfunctionality;
186  }
187  void SetFunctionality( float func )
188  {
189  functionality = func;
190  }
191  void SetMaxFunctionality( float func )
192  {
193  maxfunctionality = func;
194  }
195  void SetMissionFlag( bool flag )
196  {
197  this->mission = flag;
198  }
199  void SetPrice( float price )
200  {
201  this->price = price;
202  }
203  void SetMass( float mass )
204  {
205  this->mass = mass;
206  }
207  void SetVolume( float vol )
208  {
209  this->volume = vol;
210  }
211  void SetQuantity( int quantity )
212  {
213  this->quantity = quantity;
214  }
215  void SetContent( const std::string &content )
216  {
217  this->content = content;
218  }
219  void SetCategory( const std::string &category )
220  {
221  this->category = category;
222  }
223 
224  bool GetMissionFlag() const
225  {
226  return this->mission;
227  }
228  const std::string& GetCategory() const
229  {
230  return category;
231  }
232  const std::string& GetContent() const
233  {
234  return content;
235  }
236  const std::string& GetDescription() const
237  {
238  return description;
239  }
240  std::string GetCategoryPython()
241  {
242  return GetCategory();
243  }
244  std::string GetContentPython()
245  {
246  return GetContent();
247  }
248  std::string GetDescriptionPython()
249  {
250  return GetDescription();
251  }
252  int GetQuantity() const
253  {
254  return quantity;
255  }
256  float GetVolume() const
257  {
258  return volume;
259  }
260  float GetMass() const
261  {
262  return mass;
263  }
264  float GetPrice() const
265  {
266  return price;
267  }
268  bool operator==( const Cargo &other ) const
269  {
270  return content == other.content;
271  }
272  bool operator<( const Cargo &other ) const
273  {
274  return (category == other.category) ? (content < other.content) : (category < other.category);
275  }
276 };
277 
278 class Box;
279 class VSSprite;
280 class Animation;
281 
282 template < typename BOGUS >
283 //added by chuck starchaser, to try to break dependency to VSSprite in vegaserver
285 {
287 /* {
288 * VSCONSTRUCT1( 'i' )
289 * // pHudImage = NULL;
290 * pExplosion = NULL;
291 * }*/
292  virtual ~UnitImages();
293 /* {
294 * delete pExplosion;
295 * // delete pHudImage;
296 * VSDESTRUCT1
297 * }*/
298  StringPool::Reference cockpitImage;
299  StringPool::Reference explosion_type;
304  float timeexplode;
305  float *cockpit_damage; //0 is radar, 1 to MAXVDU is vdus and >MAXVDU is gauges
308  int ecm;
310  unsigned char repair_droid;
312  unsigned int next_repair_cargo; //(~0 : select randomly)
314  float cloakenergy;
316  int cloakrate; //short fix
320  bool forcejump;
322  float CargoVolume;
323  float equipment_volume; //this one should be more general--might want to apply it to radioactive goods, passengers, ships (hangar), etc
325  std::vector< Cargo > cargo;
326  std::vector< string >destination;
327  std::vector< DockingPorts >dockingports;
329  std::vector< Unit* > clearedunits;
330  std::vector< DockedUnits* >dockedunits;
332  float unitscale; //for output
342  enum GAUGES
343  {
344  //Image-based gauges
348  //target gauges
350  KPS, //KEEP KPS HERE - it marks the start of text-based gauges
352  AUTOPILOT_MODAL, //KEEP first multimodal gauge HERE -- it marks the start of multi-modal gauges
356  NUMGAUGES //KEEP THIS LAST - obvious reasons, marks the end of all gauges
357  };
359  {
362  };
363 };
364 
366 {
367  int engine;
368  int shield;
369  int armor;
370  int hull;
371  int explode;
372  int cloak;
373  int jump;
374 };
375 
376 //From star_system_jump.cpp
377 class StarSystem;
379 {
384  float delay;
387  bool ready;
390  Unit *jumppoint,
391  StarSystem *orig,
392  StarSystem *dest,
393  float delay,
394  int ani,
395  bool justloaded,
396  QVector use_coordinates /*set to 0,0,0 for crap*/ ) : un( un )
397  , jumppoint( jumppoint )
398  , orig( orig )
399  , dest( dest )
400  , delay( delay )
401  , animation( ani )
402  , justloaded( justloaded )
403  , ready( true )
404  , final_location( use_coordinates ) {}
405 };
406 
407 #endif
408