Avionics
Dropship Simulator
Instrument.h
Go to the documentation of this file.
1 #pragma once
2 
9 #include "../Bus.h"
10 #include "../Rendering/DeviceObject.h"
11 #include "../Rendering/Sprite.h"
12 #include "../Rendering/Font.h"
13 #include "../Rendering/Text.h"
14 
16 {
17 private:
18  Instrument();
19 
20 protected:
21  Bus* bus = nullptr;
22  Logger* logger = nullptr;
23  int screenWidth = 0, screenHeight = 0;
24  DEVICE_OBJECT* pDevice = nullptr;
25  std::vector<Font>* fonts = nullptr;
26  bool flip = false;
27 
28  // config items
29  int x, y;
30  int width = 0, height = 0;
31  float xScale, yScale;
33 
35 
36 public:
37  Instrument(int prmX, int prmY, float prmXScale, float prmYScale)
38  {
39  x = prmX;
40  y = prmY;
41  xScale = prmXScale;
42  yScale = prmYScale;
43  };
44 
45  virtual void Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip)
46  {
47  bus = prmBus;
48  logger = prmLogger;
49  pDevice = prmDevice;
50  screenWidth = prmScreenWidth;
51  screenHeight = prmScreenHeight;
52  fonts = prmFonts;
53  flip = prmFlip;
54  }
55 
56  void DrawText(const WCHAR* str, int x, int y, int flags, D3DXCOLOR color, int font, std::string elementName)
57  {
58  D3DXCOLOR newcolor;
59  if (bus->IsDim(elementName))
60  newcolor = color * 0.5f;
61  else
62  newcolor = color;
63 
64  RECT rc;
65  rc.left = x;
66  rc.top = y;
67  rc.bottom = rc.right = 0;
68  HRESULT hr;
69  V(fonts->at(font).pFont->DrawText(pDevice->pSprite, str, -1, &rc, flags, newcolor));
70 
72  //V(pDevice->pSprite->SetProjectionTransform(&screenMatrix));
73  }
74 
75  virtual void Render(float fElapsed) = 0;
76 
80  virtual ~Instrument()
81  {
82  }
83 };
84 
86 
87 #pragma region PFD
88 class IndicatedAirSpeedTape : public Instrument
90 {
91 private:
93  std::string textureFile;
94  float tvpitchscale = 0.0f;
95  float vertoffset = 0.0f;
96  float tvrange = 0.0f;
97  float ias = 0.0f;
98  UINT font = 1;
99  float modulateKm = 0.0f;
100 
101 public:
102  IndicatedAirSpeedTape(int prmX, int prmY, int prmWidth, int prmHeight, std::string prmTextureFile, float prmModulateKm);
103  void Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip) override;
104  void Render(float fElapsed) override;
105 };
106 
109 {
110 private:
111  Sprite sprite; // artificial horizon
114  Sprite glideslopebug; // also used for localizer
117  std::string textureFile;
118  float tvpitchscale = 0.0f, cbpitchscale = 0.0f;
119  float tvvertoffset = 0.0f, cbvertoffset = 0.0f;
120  float tvrange = 0.0f;
121  float pitch = 0.0f, roll = 0.0f;
122 
123 public:
124  AttitudeIndicator(int prmX, int prmY, int prmWidth, int prmHeight, std::string prmTextureFile);
125  void Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip) override;
126  void Render(float fElapsed) override;
127 };
128 
130 class AltitudeTape : public Instrument
131 {
132 private:
134  std::string textureFile;
135  float tvpitchscale = 0.0f;
136  float vertoffset = 0.0f;
137  float alt = 0.0f;
138  UINT font = 0;
139  float modulateKm = 0.0f;
140 
141 public:
142  AltitudeTape(int prmX, int prmY, int prmWidth, int prmHeight, std::string prmTextureFile, float prmModulateKm);
143  void Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip) override;
144  void Render(float fElapsed) override;
145 };
146 
149 {
150 private:
152  float hdg = 0.0f;
153  UINT font = 0;
154 
155 public:
156  HeadingIndicator(int prmX, int prmY, float prmXScale, float prmYScale);
157  void Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip) override;
158  void Render(float fElapsed) override;
159 };
160 
163 {
164 private:
166  Bus::Afcs::LateralModes oldActiveLateralMode = Bus::Afcs::LateralModes::LateralMode_Off;
167  float lateralModeTimer = 3.0f;
168  Bus::Afcs::VerticalModes oldActiveVerticalMode = Bus::Afcs::VerticalModes::VerticalMode_Off;
169  float verticalModeTimer = 3.0f;
170  bool oldAutopilotEngaged = false;
171  float autopilotModeTimer = 3.0f;
172  UINT font = 1;
173 
174 public:
175  FlightModeAnnunciator(int prmX, int prmY, float prmXScale, float prmYScale);
176  void Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip) override;
177  void Render(float fElapsed) override;
178 };
179 
180 #pragma endregion
181 
182 #pragma region EICAS
183 class AlertMessageStack : public Instrument
185 {
186 private:
188 
189 public:
190  AlertMessageStack(int prmX, int prmY, float prmXScale, float prmYScale);
191  void Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip) override;
192  void Render(float fElapsed) override;
193 };
194 
196 class Diagnostics : public Instrument
197 {
198 public:
199  Diagnostics(int prmX, int prmY, float prmXScale, float prmYScale);
200  void Render(float fElapsed) override;
201 };
202 
204 class N1Indicator : public Instrument
205 {
206 private:
208  //Sprite commanded;
212  float n1 = 0.0f; // for smoothing
213  //UINT font = 0;
216  float* n1GetFloatPtr = nullptr;
217  //int engineOrdinal = -1;
218  std::string guid1;
219  std::string guid2;
220 
221 public:
222  N1Indicator(int prmX, int prmY, float prmXScale, float prmYScale, std::string prmGuid1, std::string prmGuid2, int prmOrdinal);
223  void Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip) override;
224  void Render(float fElapsed) override;
225 };
226 
228 class ITTIndicator : public Instrument
229 {
230 private:
232  //Sprite pixel;
235  float itt = 2.0f; // for smoothing
236  //UINT font = 0;
237  float* ignitorAGetFloatPtr = nullptr;
238  //DWORD* ittFaultPtr = NULL;
239  float* ittGetFloatPtr = nullptr;
240  int engineOrdinal = -1;
241  std::string guid1;
242  std::string guid2;
243 
244 public:
245  ITTIndicator(int prmX, int prmY, float prmXScale, float prmYScale, std::string prmGuid1, std::string prmGuid2, int prmOrdinal);
246  void Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip) override;
247  void Render(float fElapsed) override;
248 };
249 
250 #pragma endregion
251 
252 #pragma region MFD
253 class MovingMap : public Instrument
255 {
256 private:
260 
261 public:
262  MovingMap(int prmX, int prmY, float prmXScale, float prmYScale);
263  void Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip) override;
264  void Render(float fElapsed) override;
265 };
266 #pragma endregion
Definition: Text.h:46
Forward definitions for the instruments are below.
Definition: Instrument.h:89
virtual void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip)
Definition: Instrument.h:45
ID3DX10Sprite * pSprite
Definition: DeviceObject.h:9
std::string textureFile
Definition: Instrument.h:134
std::string guid1
Definition: Instrument.h:218
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
AltitudeTape(int prmX, int prmY, int prmWidth, int prmHeight, std::string prmTextureFile, float prmModulateKm)
Definition: AltitudeTape.cpp:3
void Render(float fElapsed) override
void DrawText(const WCHAR *str, int x, int y, int flags, D3DXCOLOR color, int font, std::string elementName)
Definition: Instrument.h:56
Systems::Fault * n1FaultPtr
Definition: Instrument.h:215
Sprite sprite
Definition: Instrument.h:133
Bus::Afcs::VerticalModes oldActiveVerticalMode
Definition: Instrument.h:168
float modulateKm
Definition: Instrument.h:139
Sprite compassMoving
Definition: Instrument.h:151
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
Definition: Logger.h:5
int engineOrdinal
Definition: Instrument.h:240
Text digital
Definition: Instrument.h:210
int height
Definition: Instrument.h:30
N1Indicator(int prmX, int prmY, float prmXScale, float prmYScale, std::string prmGuid1, std::string prmGuid2, int prmOrdinal)
Definition: N1Indicator.cpp:3
Systems::Fault * fadecFaultPtr
Definition: Instrument.h:214
Sprite glideslopebug
Definition: Instrument.h:114
IndicatedAirSpeedTape(int prmX, int prmY, int prmWidth, int prmHeight, std::string prmTextureFile, float prmModulateKm)
int standardHeight
Definition: Instrument.h:32
Alert Message Stack (CAS)
Definition: Instrument.h:184
int screenWidth
Definition: Instrument.h:23
Sprite waypointSprite
Definition: Instrument.h:258
Bus::Afcs::LateralModes oldActiveLateralMode
Definition: Instrument.h:166
std::string textureFile
Definition: Instrument.h:93
Sprite compass
Definition: Instrument.h:257
std::string guid2
Definition: Instrument.h:219
Instrument(int prmX, int prmY, float prmXScale, float prmYScale)
Definition: Instrument.h:37
Definition: Bus.h:12
void Render(float fElapsed) override
Sprite pixel
Definition: Instrument.h:209
HeadingIndicator(int prmX, int prmY, float prmXScale, float prmYScale)
float tvpitchscale
Definition: Instrument.h:135
Definition: Sprite.h:4
MovingMap.
Definition: Instrument.h:254
float * n1GetFloatPtr
Definition: Instrument.h:216
Bus * bus
Definition: Instrument.h:21
Sprite course
Definition: Instrument.h:259
float xScale
Definition: Instrument.h:31
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
Abstract base class for instrumentation By definition, instruments don&#39;t do any of the work (they don...
Definition: Instrument.h:15
DEVICE_OBJECT * pDevice
Definition: Instrument.h:24
std::string guid1
Definition: Instrument.h:241
LateralModes
Definition: Bus.h:100
float * ittGetFloatPtr
Definition: Instrument.h:239
float vertoffset
Definition: Instrument.h:136
void Render(float fElapsed) override
Diagnostics(int prmX, int prmY, float prmXScale, float prmYScale)
Definition: Diagnostics.cpp:4
void Render(float fElapsed) override
virtual ~Instrument()
Definition: Instrument.h:80
AlertMessageStack(int prmX, int prmY, float prmXScale, float prmYScale)
void Render(float fElapsed) override
void Render(float fElapsed) override
Definition: Diagnostics.cpp:8
int standardWidth
Definition: Instrument.h:32
void Render(float fElapsed) override
Definition: MovingMap.cpp:34
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
Definition: N1Indicator.cpp:10
ITTIndicator(int prmX, int prmY, float prmXScale, float prmYScale, std::string prmGuid1, std::string prmGuid2, int prmOrdinal)
Definition: ITTIndicator.cpp:3
void Render(float fElapsed) override
std::string guid2
Definition: Instrument.h:242
Logger * logger
Definition: Instrument.h:22
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
Sprite needle
Definition: Instrument.h:231
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
Altitude.
Definition: Instrument.h:130
std::vector< Font > * fonts
Definition: Instrument.h:25
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
Definition: MovingMap.cpp:7
MovingMap(int prmX, int prmY, float prmXScale, float prmYScale)
Definition: MovingMap.cpp:3
virtual void Render(float fElapsed)=0
AttitudeIndicator(int prmX, int prmY, int prmWidth, int prmHeight, std::string prmTextureFile)
bool IsDim(std::string elementName)
Definition: Bus.h:300
FlightModeAnnunciator(int prmX, int prmY, float prmXScale, float prmYScale)
void Render(float fElapsed) override
Sprite needle
Definition: Instrument.h:207
VerticalModes
so I guess we allow them to fly until they get to x degrees off
Definition: Bus.h:86
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
float * ignitorAGetFloatPtr
Definition: Instrument.h:237
bool flip
Definition: Instrument.h:26
int screenHeight
Definition: Instrument.h:23
std::string textureFile
Definition: Instrument.h:117
float yScale
Definition: Instrument.h:31
void Render(float fElapsed) override
Definition: N1Indicator.cpp:56
Diagnostics.
Definition: Instrument.h:196