Avionics
Dropship Simulator
Page.cpp
Go to the documentation of this file.
1 #include "Page.h"
2 
3 void Page::Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmpDevice, int screenWidth, int screenHeight, std::vector<Font>* fonts, bool prmFlip)
4 {
5  bus = prmBus;
6  logger = prmLogger;
7  pDevice = prmpDevice;
8  flip = prmFlip;
9 
10  for (UINT k = 0; k < elements.size(); k++)
11  {
12  for (UINT h = 0; h < elements.at(k).components.size(); h++)
13  {
14  if (!elements.at(k).components.at(h).guid.empty())
15  {
16  elements.at(k).components.at(h).ptrValue = bus->GetComponentCurrentStatePtr(elements.at(k).components.at(h).guid);
17  elements.at(k).components.at(h).ptrFault = bus->GetComponentFaultStatePtr(elements.at(k).components.at(h).guid);
18  }
19  elements.at(k).components.at(h).ptrBus = bus;
20  for (UINT l = 0; l < elements.at(k).components.at(h).conditions.size(); l++)
21  {
22  for (UINT m = 0; m < elements.at(k).components.at(h).conditions.at(l).sprites.size(); m++)
23  {
24  Sprite* sprite = &elements.at(k).components.at(h).conditions.at(l).sprites.at(m);
25  sprite->Initialize(logger, bus, pDevice, screenHeight, elements.at(k).x, elements.at(k).y, flip);
26  }
27  for (UINT m = 0; m < elements.at(k).components.at(h).conditions.at(l).text.size(); m++)
28  {
29  Text* text = &elements.at(k).components.at(h).conditions.at(l).text.at(m);
30  text->Initialize(logger, bus, pDevice, elements.at(k).x, elements.at(k).y, fonts->at(text->font).pFont, flip);
31  }
32  }
33  }
34  }
35  for (UINT k = 0; k < instruments.size(); k++)
36  {
37  Instrument* instrument = instruments.at(k);
38  instrument->Initialize(bus, logger, pDevice, screenWidth, screenHeight, fonts, flip);
39  }
40 }
41 
42 void Page::Render(float fElapsed)
43 {
44  for (UINT i = 0; i < instruments.size(); i++)
45  {
46  Instrument* instrument = instruments.at(i); // otherwise Doxygen doesn't see it!
47  instrument->Render(fElapsed);
48  }
49 
50  for (UINT i = 0; i < elements.size(); i++)
51  {
52  elements.at(i).Render();
53  }
54 }
55 
57 {
58  for (std::vector<Instrument*>::iterator it = instruments.begin(); it != instruments.end(); ++it)
59  {
60  delete *it;
61  }
62 }
Definition: Text.h:46
std::vector< Element > elements
Definition: Page.h:18
virtual void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip)
Definition: Instrument.h:45
Definition: Logger.h:5
Systems::Fault * GetComponentFaultStatePtr(std::string guidStr)
Definition: Bus.cpp:141
int font
Definition: Text.h:64
Definition: Bus.h:12
Definition: Sprite.h:4
Bus * bus
Definition: Page.h:9
Abstract base class for instrumentation By definition, instruments don&#39;t do any of the work (they don...
Definition: Instrument.h:15
void Render(float fElapsed)
Definition: Page.cpp:42
bool flip
Definition: Page.h:12
Logger * logger
Definition: Page.h:10
DEVICE_OBJECT * pDevice
Definition: Page.h:11
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmpDevice, int screenWidth, int screenHeight, std::vector< Font > *fonts, bool flip)
Definition: Page.cpp:3
virtual void Render(float fElapsed)=0
void Initialize(Logger *prmLogger, Bus *prmBus, DEVICE_OBJECT *prmpDevice, int elementX, int elementY, ID3DX10Font *prmFont, bool prmFlip)
Definition: Text.h:66
void Destroy()
Definition: Page.cpp:56
void Initialize(Logger *prmLogger, Bus *prmBus, DEVICE_OBJECT *prmpDevice, int prmScreenHeight, int prmElementX, int prmElementY, bool prmFlip)
Definition: Sprite.h:26
std::vector< Instrument * > instruments
Definition: Page.h:17