Rise
The Vieneo Province
Loading...
Searching...
No Matches
EngineBox.cpp
Go to the documentation of this file.
1#include "../Instrument.h"
2#include "../../Bus.h"
3
4EngineBox::EngineBox(int prmX, int prmY, float prmZ, 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 if (prmZ == -1.0f)
8 prmZ = 0.15f;
9 z = prmZ;
10
11 logger->AddToCallStack("EngineBox::ctor");
12 defaultFont = 0;
13
14 engineIndex = prmEngineIndex;
15 box = new Sprite(logger, pDevice, "Textures/Instruments/engine-textbox.png", prmX, prmY, prmZ - 0.05f, 0, 0, 33, 33, 0xFF0C3B5B);
16 swprintf_s(label, 5, L"ENG%i", engineIndex);
17}
18
20{
21 box->Draw();
22
23 DrawTextW(label, 8, 10, z + 0.05f, DT_NOCLIP, 0xFFFFFFFF, 3);
24
25 DrawTextW(percent, 6, 16, z + 0.05f, DT_NOCLIP, color, 1);
26
28 {
29 if ((flasher > 0.0f && oldflasher <= 0.0f) || (flasher > 0.2f && oldflasher <= 0.2f))
30 DrawTextW(L"REV", 9, 0, 0.2f, DT_NOCLIP, 0xFFFFFF00, 1);
31 else
32 DrawTextW(L"REV", 9, 0, 0.2f, DT_NOCLIP, 0xFFC4C400, 1);
33 }
34}
35
37{
39 logger->Log("EngineBox::FrameMove Engine Index Out-Of-Bounds HIGH", Logger::Level::Fatal);
40
41 if (engineIndex < 1 ||
42 (engineIndex == 1 && ourcockpit.vdat.leftengine < 64) ||
44 (engineIndex == 2 && ourcockpit.engines == 3 && ourcockpit.vdat.clengine < 64) ||
47 {
48 if ((flasher > 0.0f && oldflasher <= 0.0f) || (flasher > 0.2f && oldflasher <= 0.2f))
49 color = 0xFFFF0000;
50 else
51 color = 0xFFC40000;
52 }
53 else
54 color = 0xFF00FF00;
55
56 if (fabsf(bus->EngineThrustOutput[engineIndex - 1]) >= 0.9995f)
57 wcscpy_s(percent, 5, L"100%");
58 else
59 swprintf_s(percent, 5, L"%04.1f", fabsf(bus->EngineThrustOutput[engineIndex - 1]) * 100.0f);
60}
#define MAX_ENGINES
Definition Bus.h:20
float EngineThrustOutput[MAX_ENGINES]
Definition Bus.h:54
bool ThrustReverserCommand[MAX_ENGINES]
Definition Bus.h:72
void Render() override
Definition EngineBox.cpp:19
WCHAR percent[5]
Definition Instrument.h:204
void FrameMove(float fElapsed) override
Definition EngineBox.cpp:36
int engineIndex
Definition Instrument.h:201
Sprite * box
Definition Instrument.h:200
DWORD color
Definition Instrument.h:205
WCHAR label[5]
Definition Instrument.h:203
EngineBox(int prmX, int prmY, float prmZ, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts, int prmEngineIndex)
Definition EngineBox.cpp:4
Bus * bus
Definition Instrument.h:22
Instrument(int prmX, int prmY, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts)
Definition Instrument.h:36
Logger * logger
Definition Instrument.h:23
DeviceObject * pDevice
Definition Instrument.h:21
UINT defaultFont
Definition Instrument.h:24
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition Logger.cpp:283
void AddToCallStack(const char *msg)
Definition Logger.cpp:355
@ Fatal
Definition Logger.h:29
Sprite(Logger *prmLogger, DeviceObject *prmpDevice, std::string prmPathAndFilename, int prmX, int prmY, float prmZ, int prmTop, int prmLeft, int prmWidth, int prmHeight, DWORD prmColor, float scaleX=1.0f, float scaleY=1.0f)
Definition Sprite.cpp:5
void Draw(RiseMath::Color prmColor)
Definition Sprite.cpp:75
float flasher
Definition globals.cpp:49
Scockpit ourcockpit
Definition globals.cpp:114
float oldflasher
Definition globals.cpp:50
char leftengine
char rightengine
char clengine
SVesselDC vdat
Definition globals.h:664
char engines
Definition globals.h:630