Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
EngineBar.cpp
Go to the documentation of this file.
1
#include "
../Instrument.h
"
2
#include "
../../Bus.h
"
3
4
EngineBar::EngineBar
(
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
logger
->
AddToCallStack
(
"EngineBar::ctor"
);
10
defaultFont
= 1;
11
12
engineIndex
= prmEngineIndex;
13
box
=
new
Sprite
(
logger
,
pDevice
,
"Textures/Instruments/engine-barbox.png"
, prmX, prmY, prmZ-0.05f, 0, 0, 9, 43, 0xFFFFFFFF);
14
bar
=
new
Sprite
(
logger
,
pDevice
,
"Textures/Instruments/engine-bargraph.png"
, prmX + 2, prmY + 1, prmZ+0.05f, 0, 0, 5, 41, 0xFF000000);
15
}
16
17
void
EngineBar::Render
()
18
{
19
box
->
Draw
();
20
21
bar
->
Draw
(
color
);
22
}
23
24
void
EngineBar::FrameMove
(
float
)
25
{
26
if
(
engineIndex
>
MAX_ENGINES
)
27
logger
->
Log
(
"EngineBar::FrameMove Engine Index Out-Of-Bounds HIGH"
,
Logger::Level::Fatal
);
28
29
bottomBias
=
static_cast<
int
>
(39.0f * fabsf(
bus
->
EngineThrustOutput
[
engineIndex
- 1]));
30
yBias
=
y
+ 41 -
bottomBias
;
31
32
if
(
engineIndex
< 1 ||
33
(
engineIndex
== 1 &&
ourcockpit
.
vdat
.
leftengine
< 64) ||
34
(
engineIndex
== 2 &&
ourcockpit
.
engines
== 2 &&
ourcockpit
.
vdat
.
rightengine
< 64) ||
35
(
engineIndex
== 2 &&
ourcockpit
.
engines
== 3 &&
ourcockpit
.
vdat
.
clengine
< 64) ||
36
(
engineIndex
== 3 &&
ourcockpit
.
engines
== 3 &&
ourcockpit
.
vdat
.
rightengine
< 64) ||
37
engineIndex
>
ourcockpit
.
engines
)
38
{
39
if
((
flasher
> 0.0f &&
oldflasher
<= 0.0f) || (
flasher
> 0.2f &&
oldflasher
<= 0.2f))
40
color
= 0xFFFF0000;
41
else
42
color
= 0xFFC40000;
43
}
44
else
45
color
= 0xFF00FF00;
46
47
// grow from bottom so y goes up and bottom goes down
48
bar
->
SetLocation
(
x
+ 2,
yBias
);
49
bar
->
SetRectangle
(0, 0, 5,
bottomBias
);
50
bar
->
Update
();
51
}
Bus.h
Instrument.h
MAX_ENGINES
#define MAX_ENGINES
Definition
ServerTypes.h:201
Bus
Definition
Bus.h:20
Bus::EngineThrustOutput
float EngineThrustOutput[MAX_ENGINES]
Definition
Bus.h:54
DeviceObject
Definition
DeviceObject.h:8
EngineBar::FrameMove
void FrameMove(float fElapsed) override
Definition
EngineBar.cpp:24
EngineBar::bottomBias
int bottomBias
Definition
Instrument.h:220
EngineBar::bar
Sprite * bar
Definition
Instrument.h:216
EngineBar::Render
void Render() override
Definition
EngineBar.cpp:17
EngineBar::yBias
int yBias
Definition
Instrument.h:219
EngineBar::EngineBar
EngineBar(int prmX, int prmY, float prmZ, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts, int prmEngineIndex)
Definition
EngineBar.cpp:4
EngineBar::engineIndex
int engineIndex
Definition
Instrument.h:217
EngineBar::color
DWORD color
Definition
Instrument.h:218
EngineBar::box
Sprite * box
Definition
Instrument.h:215
Instrument::bus
Bus * bus
Definition
Instrument.h:22
Instrument::x
int x
Definition
Instrument.h:17
Instrument::y
int y
Definition
Instrument.h:18
Instrument::Instrument
Instrument(int prmX, int prmY, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts)
Definition
Instrument.h:36
Instrument::logger
Logger * logger
Definition
Instrument.h:23
Instrument::pDevice
DeviceObject * pDevice
Definition
Instrument.h:21
Instrument::defaultFont
UINT defaultFont
Definition
Instrument.h:24
Logger
Definition
Logger.h:11
Logger::Log
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition
Logger.cpp:283
Logger::AddToCallStack
void AddToCallStack(const char *msg)
Definition
Logger.cpp:355
Logger::Fatal
@ Fatal
Definition
Logger.h:29
Sprite::SetLocation
void SetLocation(int absoluteX, int absoluteY)
Definition
Sprite.cpp:99
Sprite::Sprite
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
Sprite::Draw
void Draw(RiseMath::Color prmColor)
Definition
Sprite.cpp:75
Sprite::Update
void Update()
Definition
Sprite.cpp:50
Sprite::SetRectangle
void SetRectangle(int top, int left, int right, int bottom)
Definition
Sprite.cpp:105
flasher
float flasher
Definition
globals.cpp:49
ourcockpit
Scockpit ourcockpit
Definition
globals.cpp:114
oldflasher
float oldflasher
Definition
globals.cpp:50
SVesselDC::leftengine
char leftengine
Definition
ServerTypes.h:240
SVesselDC::rightengine
char rightengine
Definition
ServerTypes.h:240
SVesselDC::clengine
char clengine
Definition
ServerTypes.h:240
Scockpit::vdat
SVesselDC vdat
Definition
globals.h:664
Scockpit::engines
char engines
Definition
globals.h:630
Instruments
EICAS
EngineBar.cpp
Generated on
for Rise by
1.18.0