All Classes Functions
HookClass.h
1 // ==============================================================
2 // ORBITER MODULE: LaunchMFD
3 // Part of the ORBITER SDK
4 //
5 // Copyright (C) 2004 rjcroy - robust time based pitch autopilot (borrowed code)
6 // Copyright (C) 2004 Dave "Daver" Rowbotham - conversion of rjcroy's autopolot to C++ (borrowed code)
7 // Copyright (C) 2004 Erik H. "Sputnik" Anderson - conversion of the autopilot to energy based (borrowed code)
8 // Copyright (C) 2007 "Vanguard" - dressing up azimuth calcualtions into an MFD (author)
9 // Copyright (C) 2007 Pawel "She'da'Lier" Stiasny - yaw error visual representation (contributor)
10 // Copyright (C) 2008 Mohd "Computerex" Ali - borrowed his code (multiple vessels support) (borrowed code)
11 // Copyright (C) 2008 Chris "Kwan" Jeppesen - borrowed his code (peg guidance) (borrowed code)
12 // Copyright (C) 2008 Steve "agentgonzo" Arch - peg integration, offplane correction, compass, hud display (co-developer)
13 // Copyright (C) 2007-2012 Szymon "Enjo" Ender - everything else ;> (author and maintainer)
14 // All rights reserved
15 //
16 // HookClass.h - Flight Director's hooking magic
17 // Authors - Steve "agentgonzo" Arch
18 //
19 // This module calculates the appropriate launch azimuth given
20 // desired orbital inclination and desired orbit altitude. This
21 // MFD takes the planets rotation into account, which provides a
22 // much more accurate azimuth. The calculations are performed
23 // 'on the fly' (technically and methaphorically), meaning that
24 // you get info about necessary course corrections.
25 //
26 // This file is part of LaunchMFD.
27 //
28 // LaunchMFD is free software: you can redistribute it and/or modify
29 // it under the terms of the GNU General Public License as published by
30 // the Free Software Foundation, either version 3 of the License, or
31 // (at your option) any later version.
32 //
33 // LaunchMFD is distributed in the hope that it will be useful,
34 // but WITHOUT ANY WARRANTY; without even the implied warranty of
35 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 // GNU General Public License for more details.
37 //
38 // You should have received a copy of the GNU General Public License
39 // along with LaunchMFD. If not, see <http://www.gnu.org/licenses/>.
40 // ==============================================================
41 
42 #pragma once
43 #include "Orbitersdk.h"
44 #include "vesselapi.h"
45 #include "MyDC.h"
46 
47 class HookClass : public
48 #ifdef ORB2006
49 VESSEL2
50 #else
51 VESSEL3
52 #endif
53 {
54 public:
55  void Hook();
56  void UnHook();
57  static void FocusChanged(OBJHANDLE new_focus, OBJHANDLE old_focus);
58 
59  static class LaunchMFD* launchMFD;
60 
61 public:
62  HookClass(OBJHANDLE, int);
63  ~HookClass(void);
64 
65  // Callback functions
66  virtual void clbkSetClassCaps (FILEHANDLE cfg) {};
67  virtual void clbkSaveState (FILEHANDLE scn) {};
68  virtual void clbkLoadStateEx (FILEHANDLE scn, void *status) {};
69  virtual void clbkSetStateEx (const void *status) {};
70  virtual void clbkPostCreation () {};
71  virtual void clbkFocusChanged (bool getfocus, OBJHANDLE hNewVessel, OBJHANDLE hOldVessel) {};
72  virtual void clbkPreStep (double simt, double simdt, double mjd) {};
73  virtual void clbkPostStep (double simt, double simdt, double mjd) {};
74  virtual bool clbkPlaybackEvent (double simt, double event_t, const char *event_type, const char *event) {return 0;};
75  virtual void clbkVisualCreated (VISHANDLE vis, int refcount) {};
76  virtual void clbkVisualDestroyed (VISHANDLE vis, int refcount) {};
78  virtual void clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, HDC hDC);
80  virtual void clbkRCSMode (int mode) {};
81  virtual void clbkADCtrlMode (DWORD mode) {};
82  virtual void clbkHUDMode (int mode) {};
83  virtual void clbkMFDMode (int mfd, int mode) {};
84  virtual void clbkNavMode (int mode, bool active) {};
85  virtual void clbkDockEvent (int dock, OBJHANDLE mate) {};
86  virtual void clbkAnimate (double simt) {};
87  virtual int clbkConsumeDirectKey (char *keystate) {return 0;};
88  virtual int clbkConsumeBufferedKey (DWORD key, bool down, char *keystate) {return 0;};
89  virtual bool clbkLoadGenericCockpit () {return 0;};
90  virtual bool clbkLoadPanel (int id) {return 0;};
91  virtual bool clbkPanelMouseEvent (int id, int event, int mx, int my) {return 0;};
92  virtual bool clbkPanelRedrawEvent (int id, int event, SURFHANDLE surf) {return 0;};
93  virtual bool clbkLoadVC (int id) {return 0;};
94  virtual bool clbkVCMouseEvent (int id, int event, VECTOR3 &p) {return 0;};
95  virtual bool clbkVCRedrawEvent (int id, int event, SURFHANDLE surf) {return 0;};
96  #ifdef ORB2009
97  virtual bool clbkPanelMouseEvent (int id, int event, int mx, int my, void *context) {return true;}
98  virtual bool clbkPanelRedrawEvent (int id, int event, SURFHANDLE surf, void *context) {return true;}
99  virtual int clbkGeneric (int msgid=0, int prm=0, void *context=NULL) {return 0;}
100  virtual bool clbkLoadPanel2D (int id, PANELHANDLE hPanel, DWORD viewW, DWORD viewH) {return true;}
102  virtual bool clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, MyDC hDC);
104  virtual void clbkRenderHUD (int mode, const HUDPAINTSPEC *hps, SURFHANDLE hDefaultTex) {}
105  virtual void clbkGetRadiationForce (const VECTOR3 &mflux, VECTOR3 &F, VECTOR3 &pos) {}
106  #endif
107  virtual void OldclbkSetClassCaps (FILEHANDLE cfg) {};
108  virtual void OldclbkSaveState (FILEHANDLE scn) {};
109  virtual void OldclbkLoadStateEx (FILEHANDLE scn, void *status) {};
110  virtual void OldclbkSetStateEx (const void *status) {};
111  virtual void OldclbkPostCreation () {};
112  virtual void OldclbkFocusChanged (bool getfocus, OBJHANDLE hNewVessel, OBJHANDLE hOldVessel) {};
113  virtual void OldclbkPreStep (double simt, double simdt, double mjd) {};
114  virtual void OldclbkPostStep (double simt, double simdt, double mjd) {};
115  virtual bool OldclbkPlaybackEvent (double simt, double event_t, const char *event_type, const char *event) {return 0;};
116  virtual void OldclbkVisualCreated (VISHANDLE vis, int refcount) {};
117  virtual void OldclbkVisualDestroyed (VISHANDLE vis, int refcount) {};
118  virtual void OldclbkDrawHUD (int mode, const HUDPAINTSPEC *hps, HDC hDC);
119  virtual void OldclbkRCSMode (int mode) {};
120  virtual void OldclbkADCtrlMode (DWORD mode) {};
121  virtual void OldclbkHUDMode (int mode) {};
122  virtual void OldclbkMFDMode (int mfd, int mode) {};
123  virtual void OldclbkNavMode (int mode, bool active) {};
124  virtual void OldclbkDockEvent (int dock, OBJHANDLE mate) {};
125  virtual void OldclbkAnimate (double simt) {};
126  virtual int OldclbkConsumeDirectKey (char *keystate) {return 0;};
127  virtual int OldclbkConsumeBufferedKey (DWORD key, bool down, char *keystate) {return 0;};
128  virtual bool OldclbkLoadGenericCockpit () {return 0;};
129  virtual bool OldclbkLoadPanel (int id) {return 0;};
130  virtual bool OldclbkPanelMouseEvent (int id, int event, int mx, int my) {return 0;};
131  virtual bool OldclbkPanelRedrawEvent (int id, int event, SURFHANDLE surf) {return 0;};
132  virtual bool OldclbkLoadVC (int id) {return 0;};
133  virtual bool OldclbkVCMouseEvent (int id, int event, VECTOR3 &p) {return 0;};
134  virtual bool OldclbkVCRedrawEvent (int id, int event, SURFHANDLE surf) {return 0;};
135 
136  #ifdef ORB2009
137  virtual bool OldclbkPanelMouseEvent (int id, int event, int mx, int my, void *context) {return true;}
138  virtual bool OldclbkPanelRedrawEvent (int id, int event, SURFHANDLE surf, void *context) {return true;}
139  virtual int OldclbkGeneric (int msgid=0, int prm=0, void *context=NULL) {return 0;}
140  virtual bool OldclbkLoadPanel2D (int id, PANELHANDLE hPanel, DWORD viewW, DWORD viewH) {return true;}
141  virtual bool OldclbkDrawHUD (int mode, const HUDPAINTSPEC *hps, MyDC hDC);
142  virtual void OldclbkRenderHUD (int mode, const HUDPAINTSPEC *hps, SURFHANDLE hDefaultTex) {}
143  virtual void OldclbkGetRadiationForce (const VECTOR3 &mflux, VECTOR3 &F, VECTOR3 &pos) {}
144  #endif
145 };
146 
147