Avionics
Dropship Simulator
AlertMessageStack.cpp
Go to the documentation of this file.
1 #include "Instrument.h"
2 
3 AlertMessageStack::AlertMessageStack(int prmX, int prmY, float prmXScale, float prmYScale): Instrument(prmX, prmY, prmXScale, prmYScale)
4 {
5  standardWidth = 254;
6  standardHeight = 384;
7 }
8 
9 void AlertMessageStack::Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip)
10 {
11  Instrument::Initialize(prmBus, prmLogger, prmDevice, prmScreenWidth, prmScreenHeight, prmFonts, prmFlip);
12 
13  sprite.pathAndFilename = "Textures\\Pixel.png";
14  sprite.elementName = "AlertMessageStack";
15  sprite.width = 238;
16  sprite.height = 23;
17  sprite.Initialize(logger, bus, pDevice, screenHeight, 0, 0, prmFlip);
18 }
19 
20 void AlertMessageStack::Render(float fElapsed)
21 {
22  int yy = y;
23  int xx = x + 15;
24  int envCount = 0, warnCount = 0, cautionCount = 0, advisoryCount = 0, statusCount = 0;
25  bool messageFlashState = fmodf(static_cast<float>(bus->ProgramTime), 2.0f) > 1.0f;
26  for (UINT i = 0; i < bus->messages.size(); i++)
27  {
28  if (bus->messages.at(i).level == MessageLevel::Environmental)
29  {
30  envCount++;
32  D3DXCOLOR m_clr;
33  if (!bus->messages.at(i).acknowledged && messageFlashState)
34  {
35  m_clr = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
36  sprite.color = D3DXCOLOR(1.0f, 0.0f, 1.0f, 1.0f);
37  sprite.x = x;
38  sprite.y = yy;
39  sprite.Update();
40  sprite.Draw();
41  }
42  else
43  {
44  m_clr = D3DXCOLOR(1.0f, 0.0f, 1.0f, 1.0f);
45  }
46  DrawText(bus->messages.at(i).text.c_str(), xx, yy, DT_NOCLIP, m_clr, 0, "EnvironmentalAlertMessageStack");
47  yy += 24;
48  }
49  }
50  for (UINT i = 0; i < bus->messages.size(); i++)
51  {
52  if (bus->messages.at(i).level == MessageLevel::Warning)
53  {
54  warnCount++;
56  D3DXCOLOR m_clr;
57  if (!bus->messages.at(i).acknowledged && messageFlashState)
58  {
59  m_clr = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
60  sprite.color = D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f);
61  sprite.x = x;
62  sprite.y = yy;
63  sprite.Update();
64  sprite.Draw();
65  }
66  else
67  {
68  m_clr = D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f);
69  }
70  DrawText(bus->messages.at(i).text.c_str(), xx, yy, DT_NOCLIP, m_clr, 0, "WarningAlertMessageStack");
71  yy += 24;
72  }
73  }
74  for (UINT i = 0; i < bus->messages.size(); i++)
75  {
76  if (bus->messages.at(i).level == MessageLevel::Caution)
77  {
78  cautionCount++;
80  D3DXCOLOR m_clr;
81  if (!bus->messages.at(i).acknowledged && messageFlashState)
82  {
83  m_clr = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f);
84  sprite.color = D3DXCOLOR(1.0f, 1.0f, 0.0f, 1.0f);
85  sprite.x = x;
86  sprite.y = yy;
87  sprite.Update();
88  sprite.Draw();
89  }
90  else
91  {
92  m_clr = D3DXCOLOR(1.0f, 1.0f, 0.0f, 1.0f);
93  }
94  DrawText(bus->messages.at(i).text.c_str(), xx, yy, DT_NOCLIP, m_clr, 0, "CautionAlertMessageStack");
95  yy += 24;
96  }
97  }
98  for (UINT i = 0; i < bus->messages.size(); i++)
99  {
100  if (bus->messages.at(i).level == MessageLevel::Advisory)
101  {
102  advisoryCount++;
104  D3DXCOLOR m_clr;
105  if (!bus->messages.at(i).acknowledged && messageFlashState)
106  {
107  m_clr = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
108  sprite.color = D3DXCOLOR(0.0f, 1.0f, 1.0f, 1.0f);
109  sprite.x = x;
110  sprite.y = yy;
111  sprite.Update();
112  sprite.Draw();
113  }
114  else
115  {
116  m_clr = D3DXCOLOR(0.0f, 1.0f, 1.0f, 1.0f);
117  }
118  DrawText(bus->messages.at(i).text.c_str(), xx, yy, DT_NOCLIP, m_clr, 0, "AdvisoryAlertMessageStack");
119  yy += 24;
120  }
121  }
122  for (UINT i = 0; i < bus->messages.size(); i++)
123  {
124  if (bus->messages.at(i).level == MessageLevel::Status)
125  {
126  statusCount++;
128  D3DXCOLOR m_clr = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
129  DrawText(bus->messages.at(i).text.c_str(), xx, yy, DT_NOCLIP, m_clr, 0, "StatusAlertMessageStack");
130  yy += 24;
131  }
132  }
133 
135  D3DXCOLOR m_clr = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
136  DrawTextW(L" END", xx, yy, DT_NOCLIP, m_clr, 0, "AlertMessageStack");
137 
139 }
std::vector< Message > messages
Definition: Bus.h:23
virtual void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip)
Definition: Instrument.h:45
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
double ProgramTime
Identified a need for these in modules.
Definition: Bus.h:289
void DrawText(const WCHAR *str, int x, int y, int flags, D3DXCOLOR color, int font, std::string elementName)
Definition: Instrument.h:56
Definition: Logger.h:5
int y
Definition: Sprite.h:16
int standardHeight
Definition: Instrument.h:32
void Update()
Definition: Sprite.h:50
Definition: Message.h:8
int x
Definition: Sprite.h:16
int height
Definition: Sprite.h:16
Definition: Bus.h:12
Bus * bus
Definition: Instrument.h:21
void Draw()
Definition: Sprite.h:64
D3DXCOLOR color
Definition: Sprite.h:20
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
int width
Definition: Sprite.h:16
std::string elementName
Definition: Sprite.h:19
AlertMessageStack(int prmX, int prmY, float prmXScale, float prmYScale)
void Render(float fElapsed) override
int standardWidth
Definition: Instrument.h:32
std::string pathAndFilename
Definition: Sprite.h:18
Logger * logger
Definition: Instrument.h:22
Definition: Message.h:11
int screenHeight
Definition: Instrument.h:23
void Initialize(Logger *prmLogger, Bus *prmBus, DEVICE_OBJECT *prmpDevice, int prmScreenHeight, int prmElementX, int prmElementY, bool prmFlip)
Definition: Sprite.h:26
Definition: Message.h:9