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
cockpit_generic.h
Go to the documentation of this file.
1 #ifndef _COCKPIT_GENERIC_H_
2 #define _COCKPIT_GENERIC_H_
3 #include "xml_support.h"
4 #include "cmd/container.h"
5 #include <vector>
6 #include "gfx/vec.h"
7 #include "vsfilesystem.h"
8 using namespace XMLSupport;
10 {
13 };
14 #ifdef NETCOMM_WEBCAM
15 #define MAXVDUS (13)
16 #else
17 #define MAXVDUS (12)
18 #endif
19 class Unit;
20 class Camera;
21 class Animation;
22 class NavigationSystem;
23 namespace Radar
24 {
25  class Sensor;
26 }
27 #include "in.h"
28 #include "cmd/images.h"
34 class Cockpit
35 {
36 protected:
40  float radar_time;
41  float gauge_time[UnitImages < void > ::NUMGAUGES];
43 
45  float StartArmor[9]; //short fix
46 
48  float maxfuel, maxhull;
54  float shakin;
56  std::string unitmodname;
59 //Gauge *gauges[UnitImages::NUMGAUGES];
60 //0 means no autopilot...positive autopilto in progress
66  float cockpit_offset, viewport_offset;
67  virtual void LoadXML( const char *file ) {}
68  virtual void LoadXML( VSFileSystem::VSFile &f ) {}
69  static void beginElement( void *userData, const XML_Char *name, const XML_Char **atts );
70  static void endElement( void *userData, const XML_Char *name );
71  virtual void beginElement( const string &name, const AttributeList &attributes ) {}
72  virtual void endElement( const string &name ) {}
74  virtual void Delete();
76  virtual void DrawNavigationSymbol( const Vector &loc, const Vector &p, const Vector &q, float size ) {}
78  virtual float computeLockingSymbol( Unit *par )
79  {
80  return 1;
81  }
82  virtual void DrawTargetBox() {}
84  virtual void DrawTargetBoxes(const Radar::Sensor&) {}
86  virtual void DrawTurretTargetBoxes() {}
88  virtual void DrawTacticalTargetBox() {}
90  virtual void DrawRadar(const Radar::Sensor&) {}
92  virtual void DrawGauges( Unit *un ) {}
93  float cockpit_time;
94  bool ejecting;
97 
98 private:
99  std::vector< std::string > unitfilename;
100  std::vector< std::string > unitsystemname;
101  std::vector< std::string > unitbasename;
102 
103 public:
106  unsigned int retry_dock;
108  char jumpok;
109  virtual void setTargetLabel( const string &msg ) {}
110  virtual string getTargetLabel()
111  {
112  return string();
113  }
114  void updateAttackers();
115  static bool tooManyAttackers(); //checks config file and declares if too many folks are attacking any of the players (to avoid expensive tests where unnecessary).
116  virtual void ReceivedTargetInfo() {}
118  {
119  return autopilot_time > 0;
120  }
121  bool unitInAutoRegion( Unit *un );
122 
124  void SetView( const enum VIEWSTYLE tmp )
125  {
126  view = tmp;
127  }
128  enum VIEWSTYLE GetView()
129  {
130  return view;
131  }
132  virtual void InitStatic();
133  virtual void Shake( float amt, int level /*0 = shield, 1 = armor 2 = hull*/ ) {}
134  float godliness;
135  virtual int Autopilot( Unit *target );
136  void RestoreGodliness();
138  virtual void RestoreViewPort() {}
139 
140  std::string& GetUnitFileName(unsigned int which = 0)
141  {
142  while ( which >= unitfilename.size() )
143  unitfilename.push_back("");
144  return unitfilename[which];
145  }
146 
147  std::string& GetUnitSystemName(unsigned int which = 0)
148  {
149  while ( which >= unitsystemname.size() )
150  unitsystemname.push_back("");
151  return unitsystemname[which];
152  }
153 
154  std::string& GetUnitBaseName(unsigned int which = 0)
155  {
156  while ( which >= unitbasename.size() )
157  unitbasename.push_back("");
158  return unitbasename[which];
159  }
160 
161  const std::string& GetUnitFileName(unsigned int which = 0) const;
162  const std::string& GetUnitSystemName(unsigned int which = 0) const;
163  const std::string& GetUnitBaseName(unsigned int which = 0) const;
164 
165  void RemoveUnit(unsigned int which = 0);
166 
167  static std::string MakeBaseName(const Unit *base);
168 
169  std::string GetUnitModifications()
170  {
171  return unitmodname;
172  }
173 
174  size_t GetNumUnits() const
175  {
176  return unitfilename.size();
177  }
178 
179  void PackUnitInfo(vector< std::string > &info) const;
180 
181  void UnpackUnitInfo(vector< std::string > &info);
182 
184  float credits; //how much money player has
186  float zoomfactor;
187  Cockpit( const char *file, Unit *parent, const std::string &pilotname );
188  virtual ~Cockpit();
190  virtual float LookupTargetStat( int stat, Unit *target )
191  {
192  return 1;
193  }
195  virtual void Init( const char *file, bool defaultCockpit = false );
196  void recreate( const std::string &pilotname );
198 //unsigned int whichcockpit;//0 is the first player, 1 is the second and so forth
200  class StarSystem*activeStarSystem; //used for context switch in Universe
201  virtual void SetParent( Unit *unit, const char *filename, const char *unitmodname, const QVector &startloc );
203  {
204  return parent.GetUnit();
205  }
206  Unit * GetSaveParent();
208  virtual void Draw() {}
209  bool Update(); //respawns and the like. Returns true if starsystem was reloaded
210  virtual void UpdAutoPilot();
212  virtual void SetupViewPort( bool clip = true ) {}
213  virtual int getVDUMode( int vdunum )
214  {
215  return 0;
216  }
217  virtual void VDUSwitch( int vdunum ) {}
218  virtual void ScrollVDU( int vdunum, int howmuch ) {}
219  virtual void ScrollAllVDU( int howmuch ) {}
220  virtual int getScrollOffset( unsigned int whichtype )
221  {
222  return 1;
223  }
224  virtual void SelectProperCamera() {}
225  virtual void Eject();
226  virtual void EjectDock();
227  virtual void SetInsidePanYawSpeed( float speed );
228  virtual void SetInsidePanPitchSpeed( float speed );
229  static void Respawn( const KBData&, KBSTATE ) {}
230  static void SwitchControl( const KBData&, KBSTATE ) {}
231  static void ForceSwitchControl( const KBData&, KBSTATE ) {}
232  static void TurretControl( const KBData&, KBSTATE ) {}
233  virtual void SetCommAnimation( Animation *ani, Unit *un ) {}
234  virtual void SetStaticAnimation() {}
238  {
239  return NULL;
240  }
241  virtual std::string GetNavSelectedSystem()
242  {
243  return "";
244  }
246  virtual Camera * AccessCamera()
247  {
248  return NULL;
249  }
251  virtual Camera * AccessCamera( int )
252  {
253  return NULL;
254  }
256  virtual void SelectCamera( int ) {}
258  virtual void SetViewport() {}
259  virtual void visitSystem( std::string systemName );
260  virtual bool SetDrawNavSystem( bool )
261  {
262  return false;
263  }
264  virtual bool CanDrawNavSystem()
265  {
266  return false;
267  }
268  virtual bool DrawNavSystem()
269  {
270  return false;
271  }
272  virtual bool CheckCommAnimation( Unit *un )
273  {
274  return false;
275  }
276  // Cockpit events
277  virtual void OnPauseBegin() {}
278  virtual void OnPauseEnd() {}
279  virtual void OnDockEnd(Unit *, Unit *) {}
280  virtual void OnJumpBegin(Unit *) {}
281  virtual void OnJumpEnd(Unit *) {}
282 };
283 #endif
284