Rise
The Vieneo Province
EngineBox.cpp
Go to the documentation of this file.
1 #include "../Instrument.h"
2 #include "../../Bus.h"
3 
4 EngineBox::EngineBox(int prmX, int prmY, float prmXScale, float prmYScale, Bus* prmBus, Logger* prmLogger, DeviceObject* prmDevice, std::vector<Font*> prmFonts, int prmEngineIndex) :
5  Instrument(prmX, prmY, prmXScale, prmYScale, prmBus, prmLogger, prmDevice, prmFonts)
6 {
7  logger->AddToCallStack("EngineBox::ctor");
8  defaultFont = 0;
9 
10  engineIndex = prmEngineIndex;
11  box = new Sprite(logger, pDevice, "Textures/Instruments/engine-textbox.png", prmX, prmY, 0.1f, 0, 0, 33, 33, 0xFF0C3B5B);
12  swprintf_s(label, 5, L"ENG%i", engineIndex);
13 }
14 
16 {
17  box->Draw();
18 
19  DrawTextW(label, 8, 10, 0.2f, DT_NOCLIP, 0xFFFFFFFF, 3);
20 
21  DrawTextW(percent, 6, 16, 0.2f, DT_NOCLIP, color, 1);
22 
24  {
25  if ((flasher > 0.0f && oldflasher <= 0.0f) || (flasher > 0.2f && oldflasher <= 0.2f))
26  DrawTextW(L"REV", 9, 0, 0.2f, DT_NOCLIP, 0xFFFFFF00, 1);
27  else
28  DrawTextW(L"REV", 9, 0, 0.2f, DT_NOCLIP, 0xFFC4C400, 1);
29  }
30 }
31 
33 {
35  logger->Log("EngineBox::FrameMove Engine Index Out-Of-Bounds HIGH", Logger::Level::Fatal);
36 
37  if (engineIndex < 1 ||
38  (engineIndex == 1 && ourcockpit.vdat.leftengine < 64) ||
39  (engineIndex == 2 && ourcockpit.engines == 2 && ourcockpit.vdat.rightengine < 64) ||
40  (engineIndex == 2 && ourcockpit.engines == 3 && ourcockpit.vdat.clengine < 64) ||
41  (engineIndex == 3 && ourcockpit.engines == 3 && ourcockpit.vdat.rightengine < 64) ||
43  {
44  if ((flasher > 0.0f && oldflasher <= 0.0f) || (flasher > 0.2f && oldflasher <= 0.2f))
45  color = 0xFFFF0000;
46  else
47  color = 0xFFC40000;
48  }
49  else
50  color = 0xFF00FF00;
51 
52  if (fabsf(bus->EngineThrustOutput[engineIndex - 1]) >= 0.9995f)
53  wcscpy_s(percent, 5, L"100%");
54  else
55  swprintf_s(percent, 5, L"%04.1f", fabsf(bus->EngineThrustOutput[engineIndex - 1]) * 100.0f);
56 }
Scockpit ourcockpit
Definition: globals.cpp:176
WCHAR percent[5]
Definition: Instrument.h:171
#define MAX_ENGINES
Definition: Bus.h:14
float oldflasher
Definition: globals.cpp:66
Sprite * box
Definition: Instrument.h:168
void FrameMove(float fElapsed) override
Definition: EngineBox.cpp:32
Definition: Logger.h:9
void Render() override
Definition: EngineBox.cpp:15
int engineIndex
Definition: Instrument.h:169
DeviceObject * pDevice
Definition: Instrument.h:17
void Draw(D3DXCOLOR prmColor)
Definition: Sprite.cpp:66
Definition: Bus.h:16
bool ThrustReverserCommand[MAX_ENGINES]
Definition: Bus.h:61
Definition: Sprite.h:7
Bus * bus
Definition: Instrument.h:18
DWORD color
Definition: Instrument.h:172
EngineBox(int prmX, int prmY, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font *> prmFonts, int prmEngineIndex)
Definition: EngineBox.cpp:4
UINT defaultFont
Definition: Instrument.h:20
char engines
Definition: globals.h:627
float EngineThrustOutput[MAX_ENGINES]
Definition: Bus.h:43
float flasher
Definition: globals.cpp:65
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition: Logger.cpp:11
Logger * logger
Definition: Instrument.h:19
void AddToCallStack(const char *msg)
Definition: Logger.cpp:86
WCHAR label[5]
Definition: Instrument.h:170
SVesselDC vdat
Definition: globals.h:669