Rise
The Vieneo Province
Loading...
Searching...
No Matches
ContactList.cpp
Go to the documentation of this file.
1#include "Instrument.h"
2#include "../Bus.h"
3#include "../MathUtilities.h"
4
5ContactList::ContactList(int prmX, int prmY, float prmXScale, float prmYScale, Bus* prmBus, Logger* prmLogger, DeviceObject* prmDevice, std::vector<Font*> prmFonts) :
6 Instrument(prmX, prmY, prmXScale, prmYScale, prmBus, prmLogger, prmDevice, prmFonts)
7{
8 logger->AddToCallStack("ContactList::ctor");
9 defaultFont = 1;
10 cacheFixedText = true;
11}
12
14{
15 WCHAR str[99];
16 RiseMath::Vector3 result;
17
18 /*if (!playerships[0].groundvehicle || ourcockpit.texturelib == VehicleType::T27)
19 {
20
21 bus->m_spriteVector->Begin(Rendering::SpriteFlags::AlphaBlend | Rendering::SpriteFlags::SortTexture);
22
23 if (ourcockpit.nextgen)
24 {
25 RiseMath::Matrix transform;
26 RiseMath::MatrixTranslation(&transform, 207, 0, 0); // 773 by default
27 bus->m_spriteVector->SetTransform(&transform);
28 }*/
29
30 long yText = 11; // start 11 down from top
31 const long yTextIncr = 11; // each line
33 if (!ourcockpit.spaceCapable) // not spaceships
34 {
35 if (bus->targetC < -1)
36 {
37 bus->targetC = -1; // if stations, select user WP
38 Command command;
39 command.name = "EventSelectTarget";
40 bus->AddCommand(command, false);
41 }
42 }
43
44 if (bus->scanscroll > 0)
45 DrawTextW(L" ^^^ MORE ^^^", 22, yText, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 0));
46 // Last waypoint
47 else if (bus->lastWaypointLocation.x != 0.0f && ourcockpit.power > 0.5f)
48 {
49 static bool tripped = true;
50 const float lastWaypointDistance = GetArcDist(playerships[0].position, bus->lastWaypointLocation, true);
51 if (lastWaypointDistance > bus->waypointDistanceKm && !tripped)
52 {
53 // tripped
54 flashtime = 3.0f;
55 Command command;
56 command.name = "SoundMidwayTarget";
57 bus->AddCommand(command, false);
58 tripped = true;
59 }
60 else if (lastWaypointDistance < bus->waypointDistanceKm)
61 {
62 tripped = false;
63 }
64
65 if (lastWaypointDistance > 10000.0f)
66 swprintf_s(str, 99, L" LAST %.3f kkm", lastWaypointDistance * 0.001f);
67 else
68 swprintf_s(str, 99, L" LAST %.3f km", lastWaypointDistance);
69
70 if (flashtime > 0.0f)
71 {
72 if (fmodf(flashtime, 1.0f) > 0.5f)
73 hi = Rendering::ColorARGB(255, 255, 255, 255); // white
74 else
75 hi = Rendering::ColorARGB(255, 0, 127, 127); // dark cyan
76 }
77 else
78 hi = Rendering::ColorARGB(255, 0, 127, 127); // dark cyan
79
80 DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
81 }
82 yText += yTextIncr;
83
84 char thji;
85 if (bus->targetC == -1)
86 thji = '>';
87 else
88 thji = ' ';
89
90 // User Waypoint
91 if (bus->WPtargetC < 0 || bus->WPtargetC >= static_cast<long>(bus->waypoint.size()))
92 {
93 char msg[199];
94 sprintf_s(msg, sizeof msg, "Trying to display AV/SV contact list with a waypoint that doesn't exist in collection: %i (%zu)", bus->WPtargetC, bus->waypoint.size());
96 bus->WPtargetC = 0;
97 strcpy_s(bus->TimeToNextFix, 6, "--:--");
98 }
99 else
100 {
101 if (bus->GroundSpeedKms < 0.0005f)
102 strcpy_s(bus->TimeToNextFix, 6, "--:--");
103 else
104 {
105 const float hours = bus->waypointDistanceKm / bus->GroundSpeedKms / 60.0f / 60.0f;
106 const float minutes = floorf((hours - floorf(hours)) * 60.0f);
107 if (hours > 99.0f)
108 strcpy_s(bus->TimeToNextFix, 6, "++:++");
109 else
110 sprintf_s(bus->TimeToNextFix, 6, "%02.0f:%02.0f", floorf(hours), minutes);
111 }
112 }
113
114 if (bus->waypointDistanceKm >= 0)
115 {
116 if (bus->waypointDistanceKm > 10000.0f)
117 swprintf_s(str, 99, L"%CWAYPT %.3f kkm", thji, bus->waypointDistanceKm * 0.001f);
118 else
119 swprintf_s(str, 99, L"%CWAYPT %.3f km", thji, bus->waypointDistanceKm);
120 }
121 else
122 swprintf_s(str, 99, L"%CWAYPT Unused", thji);
123
124 hi = Rendering::ColorARGB(255, 0, 255, 255); // cyan
125 DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
126 yText += yTextIncr;
127
128
129 for (short t = 0; t < ourcockpit.scanDisplayVesselLimit; t++)
130 {
134 {
136 hi = Rendering::ColorARGB(255, 255, 127, 0); // orange
138 hi = Rendering::ColorARGB(255, 192, 192, 192); // white
139 else
140 {
141 // blue is a color that is available but the concern is that it is hard to see
142 if (playerships[bus->scanslot[t + bus->scanscroll]].align == 4) // owned
143 hi = Rendering::ColorARGB(255, 192, 192, 0); // yellow
144 else if (playerships[bus->scanslot[t + bus->scanscroll]].align == 3) // partner
145 hi = Rendering::ColorARGB(255, 192, 0, 192); // purple
146 else if (playerships[bus->scanslot[t + bus->scanscroll]].align == 2) // ally
147 hi = Rendering::ColorARGB(255, 0, 192, 0); // green
148 else if (playerships[bus->scanslot[t + bus->scanscroll]].align == 0) // enemy
149 hi = Rendering::ColorARGB(255, 192, 0, 0); // red
150 else
151 hi = Rendering::ColorARGB(255, 192, 192, 192); // white
153 {
154 hi.r *= 1.328125f;
155 hi.g *= 1.328125f;
156 hi.b *= 1.328125f;
157 }
158 }
159
160 char ivr[7];
162 strcpy_s(ivr, sizeof ivr, playerships[bus->scanslot[t + bus->scanscroll]].IVR);
163 else
164 strcpy_s(ivr, sizeof ivr, "PRONLY");
165
166 if ((t + bus->scanscroll) == bus->targetC)
167 swprintf_s(str, 99, L">%-6S %.3f km", ivr, bus->scandist[t + bus->scanscroll]);
168 else
169 swprintf_s(str, 99, L" %-6S %.3f km", ivr, bus->scandist[t + bus->scanscroll]);
170 DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
171 yText += yTextIncr;
172 }
173 }
174
176 {
177 if (bus->targetC == -4)
178 {
179 thji = '>';
181 }
182 else
183 thji = ' ';
184 // SENTRY STATION
185 if (playerships[0].portassigned != -1 && playerships[0].reference == REF_DOCKYSP)
186 {
187 if (playerships[0].docked)
189 else
190 result = playerships[0].dockoffset - dockMarker;
191 swprintf_s(str, 99, L"%CYSP%i %.3f km", thji, playerships[0].portassigned, RiseMath::Vec3Length(&result));
192 }
193 else
194 {
195 if (allobjects[2].distance > 10000.0f)
196 swprintf_s(str, 99, L"%CYSP %.3f kkm", thji, allobjects[2].distance * 0.001f);
197 else
198 swprintf_s(str, 99, L"%CYSP %.3f km", thji, allobjects[2].distance);
199 }
200
201 hi = Rendering::ColorARGB(255, 0, 255, 255); // cyan
202 DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
203 yText += yTextIncr;
204
205
206 if (bus->targetC == -3)
207 {
208 thji = '>';
210 }
211 else
212 thji = ' ';
213 // EASYDOCK
214 if (playerships[0].portassigned != -1 && playerships[0].reference == REF_DOCKTAC)
215 {
216 if (playerships[0].docked)
218 else
219 result = playerships[0].dockoffset - dockMarker;
220 swprintf_s(str, 99, L"%CTAC%i %.3f km", thji, playerships[0].portassigned + 1, RiseMath::Vec3Length(&result));
221 }
222 else
223 {
224 if (allobjects[1].distance > 10000.0f)
225 swprintf_s(str, 99, L"%CTAC %.3f kkm", thji, allobjects[1].distance * 0.001f);
226 else
227 swprintf_s(str, 99, L"%CTAC %.3f km", thji, allobjects[1].distance);
228 }
229
230 hi = Rendering::ColorARGB(255, 0, 255, 255); // cyan
231 DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
232 yText += yTextIncr;
233
234
235
236 if (bus->targetC == -2)
237 {
238 thji = '>';
240 }
241 else
242 thji = ' ';
243 // Cutter's Port
244 if (playerships[0].portassigned != -1 && playerships[0].reference == REF_DOCKENUMCPOC)
245 {
246 if (playerships[0].docked)
248 else
249 result = playerships[0].dockoffset - dockMarker;
250 if (playerships[0].portassigned == 6) // deluge
251 swprintf_s(str, 99, L"%CCPOCd %.3f km", thji, RiseMath::Vec3Length(&result));
252 else
253 swprintf_s(str, 99, L"%CCPOC%i %.3f km", thji, playerships[0].portassigned + 1, RiseMath::Vec3Length(&result));
254 }
255 else
256 {
257 if (allobjects[0].distance > 10000.0f)
258 swprintf_s(str, 99, L"%CCPOC %.3f kkm", thji, allobjects[0].distance * 0.001f);
259 else
260 swprintf_s(str, 99, L"%CCPOC %.3f km", thji, allobjects[0].distance);
261 }
262
263 hi = Rendering::ColorARGB(255, 0, 255, 255); // cyan
264 DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
265 yText += yTextIncr;
266 } // end of sv
267
268
270 DrawTextW(L" vvv MORE vvv", 22, yText, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 0));
271
273 //if (ourcockpit.nextgen)
274 //{
275 // RiseMath::Matrix transform;
276 // RiseMath::MatrixIdentity(&transform);
277 // bus->m_spriteVector->SetTransform(&transform);
278 //}
279
280 //bus->m_spriteVector->End();
281// }
282}
283
284void ContactList::FrameMove(float fElapsed)
285{
286 flashtime -= fElapsed;
287
288}
float GetArcDist(RiseMath::Vector3 from, RiseMath::Vector3 to, bool includeAltDiff)
@ REF_DOCKTAC
Definition ServerTypes.h:54
@ REF_DOCKENUMCPOC
Definition ServerTypes.h:53
@ REF_DOCKYSP
Definition ServerTypes.h:55
Definition Bus.h:20
float TargetDistanceKm
Definition Bus.h:502
float GroundSpeedKms
Definition Bus.h:179
char TimeToNextFix[6]
Definition Bus.h:505
short targetC
Definition Bus.h:480
long topscroll
Definition Bus.h:483
RiseMath::Vector3 lastWaypointLocation
Definition Bus.h:501
float scandist[MAX_SCAN]
Definition Bus.h:486
std::vector< Swaypoint > waypoint
Definition Bus.h:500
void AddCommand(const Command &command, bool onlyOne)
Definition Bus.cpp:5
short scanslot[MAX_SCAN]
Definition Bus.h:485
int WPtargetC
Definition Bus.h:499
long scanscroll
Definition Bus.h:483
float waypointDistanceKm
Definition Bus.h:482
void FrameMove(float fElapsed) override
void Render() override
float flashtime
Definition Instrument.h:709
ContactList(int prmX, int prmY, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts)
Bus * bus
Definition Instrument.h:22
bool cacheFixedText
Definition Instrument.h:26
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
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
@ Error
Definition Logger.h:28
s_network_objects playerships[MAX_SCAN]
Definition globals.cpp:112
RiseMath::Vector3 dockMarker
Definition globals.cpp:34
s_universe_object allobjects[maxstarC]
Definition globals.cpp:108
Scockpit ourcockpit
Definition globals.cpp:114
RiseMath::Vector3 dockInterface
Definition globals.cpp:35
constexpr PackedColor ColorARGB(unsigned a, unsigned r, unsigned g, unsigned b)
float Vec3Length(const Vector3 *a)
Definition ClientMath.h:95
std::string name
Definition Command.h:11
short scanDisplayVesselLimit
Definition globals.h:725
float power
Definition globals.h:599
bool spaceCapable
Definition globals.h:596
RiseMath::Vector3 dockoffset
Definition globals.h:511