Rise
The Vieneo Province
Loading...
Searching...
No Matches
CarRadio.cpp
Go to the documentation of this file.
1#include "Instrument.h"
2#include "../Bus.h"
3
4CarRadio::CarRadio(int prmX, int prmY, float prmXScale, float prmYScale, Bus* prmBus, Logger* prmLogger, DeviceObject* prmDevice, std::vector<Font*> prmFonts) :
5 Instrument(prmX, prmY, prmXScale, prmYScale, prmBus, prmLogger, prmDevice, prmFonts)
6{
7 logger->AddToCallStack("CarRadio::ctor");
8 defaultFont = 1;
9
10 background = new Sprite(logger, pDevice, "Textures/Instruments/CarRadio.png", prmX, prmY, 0.2f, 0, 0, 102, 35, 0xFFFFFFFF);
11 station1 = new Sprite(logger, pDevice, "Textures/Radio/1.png", prmX + 24, prmY, 0.3f, 0, 0, 78, 23, 0xFFFFFFFF);
12 station2 = new Sprite(logger, pDevice, "Textures/Radio/2.png", prmX + 24, prmY, 0.3f, 0, 0, 78, 23, 0xFFFFFFFF);
13 station3 = new Sprite(logger, pDevice, "Textures/Radio/3.png", prmX + 24, prmY, 0.3f, 0, 0, 78, 23, 0xFFFFFFFF);
14 station4 = new Sprite(logger, pDevice, "Textures/Radio/4.png", prmX + 24, prmY, 0.3f, 0, 0, 78, 23, 0xFFFFFFFF);
15 station5 = new Sprite(logger, pDevice, "Textures/Radio/5.png", prmX + 24, prmY, 0.3f, 0, 0, 78, 23, 0xFFFFFFFF);
16}
17
19{
21 return;
22
24
25 if (!ourcockpit.radioPower || ourcockpit.power <= 0.7f)
26 return;
27
28 switch (bus->station)
29 {
30 case 1: // looks like we support 14 each line
31 station1->Draw();
32 DrawText(L"FM1", 4, -2, 0.3f, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255));
33 break;
34 case 2:
35 station2->Draw();
36 DrawText(L"FM2", 4, -2, 0.3f, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255));
37 break;
38 case 3:
39 station3->Draw();
40 DrawText(L"FM3", 4, -2, 0.3f, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255));
41 break;
42 case 4:
43 station4->Draw();
44 DrawText(L"FM4", 4, -2, 0.3f, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255));
45 break;
46 case 5:
47 station5->Draw();
48 DrawText(L"FM5", 4, -2, 0.3f, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255));
49 break;
50 }
51
52 DrawText(nowPlaying, 0, 23, 0.3f, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255));
53}
54
55void CarRadio::FrameMove(float fElapsed)
56{
58 return;
59
61 {
62 nowPlaying[0] = 0;// wcscpy_s(nowPlaying, 99, L"NOW PLAYING >>> UNKNOWN");
63 textpos = 0.0f;
64 return;
65 }
66
67 WCHAR str[99];
68 swprintf_s(str, 99, L"NOW PLAYING >>> %S", ourcockpit.radioplaying);
69
70 m_fAnimateFrame += fElapsed;
71 if (m_fAnimateFrame > 0.0416667f) // 24 fps
72 {
73 m_fAnimateFrame = 0.0f;
74
75 textpos += 0.1f;
76 if (textpos >= static_cast<float>(wcslen(str)))
77 textpos = 0.0f;
78
79 if (textpos >= (static_cast<float>(wcslen(str)) - 20))
80 {
81 short nonstat = static_cast<short>(wcslen(str)) - 20;
82 if (nonstat < 0)
83 nonstat = 0;
84
85 wcscpy_s(nowPlaying, 99, &str[nonstat]);
86 }
87 else // 664 147
88 {
89 short nonstat = static_cast<short>(textpos);
90 swprintf_s(nowPlaying, 99, L"%.20s", &str[nonstat]);
91 }
92 }
93}
Definition Bus.h:20
short station
Definition Bus.h:506
Sprite * station1
Definition Instrument.h:483
Sprite * background
Definition Instrument.h:482
CarRadio(int prmX, int prmY, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts)
Definition CarRadio.cpp:4
float textpos
Definition Instrument.h:489
Sprite * station5
Definition Instrument.h:487
Sprite * station4
Definition Instrument.h:486
float m_fAnimateFrame
Definition Instrument.h:488
Sprite * station2
Definition Instrument.h:484
WCHAR nowPlaying[99]
Definition Instrument.h:490
void FrameMove(float fElapsed) override
Definition CarRadio.cpp:55
void Render() override
Definition CarRadio.cpp:18
Sprite * station3
Definition Instrument.h:485
Bus * bus
Definition Instrument.h:22
void DrawText(const WCHAR *str, int relativeX, int relativeY, float prmZ, int flags, RiseMath::Color color, int font=-1, std::string elementName="", int width=0, int height=0) const
Definition Instrument.h:49
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 AddToCallStack(const char *msg)
Definition Logger.cpp:355
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
Scockpit ourcockpit
Definition globals.cpp:114
constexpr PackedColor ColorARGB(unsigned a, unsigned r, unsigned g, unsigned b)
char radioplaying[99]
Definition globals.h:628
float power
Definition globals.h:599
bool radioPower
Definition globals.h:597
bool radioEquipped
Definition globals.h:669