Avionics
Dropship Simulator
Component.h
Go to the documentation of this file.
1 #include "Condition.h"
2 
3 class Component
4 {
5 public:
6  std::string guid;
7  std::string busval;
8  Bus* ptrBus = nullptr;
9  float* ptrValue = nullptr;
11  float modulate = 1.0f;
12  std::vector<Condition> conditions;
13 
14  void Render()
15  {
16  for (UINT j = 0; j < conditions.size(); j++)
17  {
18  if (!ptrValue || !ptrFault || conditions.at(j).MeetsCondition(*ptrValue, *ptrFault))
19  {
20  // Draw all the sprites
21  for (UINT k = 0; k < conditions.at(j).sprites.size(); k++)
22  {
23  conditions.at(j).sprites.at(k).Draw();
24  }
25 
26  // Draw all the text
27  for (UINT k = 0; k < conditions.at(j).text.size(); k++)
28  {
29  WCHAR format[99];
30  swprintf_s(format, 99, L"%S", conditions.at(j).text.at(k).formattedText.c_str());
31  if (conditions.at(j).text.at(k).formattedText.find('%') != std::string::npos)
32  {
33  WCHAR str[99];
34  if (ptrValue)
35  swprintf_s(str, 99, format, *ptrValue * modulate);
36  else if (!busval.empty())
37  {
38  if (busval == "NextWaypointIdentifier" && ptrBus->waypoints.size() > 0)
39  swprintf_s(str, 99, format, ptrBus->waypoints.at(0).FixId.c_str());
40  else if (busval == "NextWaypointDistance" && ptrBus->waypoints.size() > 0)
41  {
42  D3DXVECTOR3 result = ptrBus->Location - ptrBus->waypoints.at(0).absoluteLocation();
43  D3DXVECTOR2 result2 = D3DXVECTOR2(result.x, result.y);
44  swprintf_s(str, 99, format, D3DXVec2Length(&result2));
45  }
46  else
47  str[0] = 0;
48  }
49  else
50  str[0] = 0;
51  conditions.at(j).text.at(k).Draw(str);
52  }
53  else
54  {
55  conditions.at(j).text.at(k).Draw(format);
56  }
57  }
58  break;
59  }
60  }
61  }
62 };
float * ptrValue
Definition: Component.h:9
Bus * ptrBus
Definition: Component.h:8
std::vector< Waypoint > waypoints
Definition: Bus.h:367
Definition: Bus.h:12
void Render()
Definition: Component.h:14
float modulate
Definition: Component.h:11
Systems::Fault * ptrFault
Definition: Component.h:10
std::string busval
Definition: Component.h:7
std::vector< Condition > conditions
Definition: Component.h:12
std::string guid
Definition: Component.h:6
D3DXVECTOR3 Location
Definition: Bus.h:359