Rise
The Vieneo Province
Loading...
Searching...
No Matches
Scanner.cpp
Go to the documentation of this file.
1#include "../Instrument.h"
2#include "../../Bus.h"
4
5Scanner::Scanner(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("Scanner::ctor");
9 defaultFont = 0;
10
11}
12
14{
15 logger->AddToCallStack("Scanner::Render");
17 {
18 DrawTextW(L"NO DATA IN BUFFER - USE \"SHIFT+S\" TO SCAN", 0, 0, 0, DT_NOCLIP, 0xFFA0A0A0);
19 return;
20 }
21
23 if (!scan.initialized) // waiting for data from the server
24 {
25 DrawTextW(L"SCAN IN PROGRESS", 0, 0, 0, DT_NOCLIP, 0xFFA0A0A0);
26 return;
27 }
28
29 int x = 196;
30 WCHAR str[99];
32 swprintf_s(str, 99, L"ARJ-%S", scan.scandata.modeAC.IVR);
33 else
34 swprintf_s(str, 99, L"IVR %S", scan.scandata.modeAC.IVR);
35 DrawTextW(str, 194, 0, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255), 2);
36
37 if (scan.scandata.modeAC.hullname[0])
38 {
45 swprintf_s(str, 99, L"USV %S", scan.scandata.modeAC.hullname);
46 else
47 swprintf_s(str, 99, L"%S", scan.scandata.modeAC.hullname);
48 DrawTextW(str, x, 30, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255), 0);
49 }
50
51 WCHAR column[99];
52
53 x = 0;
54 int y = 90;
55 //if (targetC >= 0 && scan.scandata.modeAC.vehicleId == playerships[viewscreen->scanslot[targetC]].vehicleId)
56 {
57 // Don't have to worry about the DIHV
58 // Cash is to anything that can have a player
60 DrawTextW(L"Shift+C Cash", x, y += 15, 0, DT_NOCLIP, 0xFF00A0A0, 0);
61 // Fuel is any vehicle or fuel-type-ARJ
64 DrawTextW(L"Shift+F Fuel", x, y += 15, 0, DT_NOCLIP, 0xFF00A0A0, 0);
65 // Weapons is any vehicle or munitions-type-ARJ
68 DrawTextW(L"Shift+W Weapon", x, y += 15, 0, DT_NOCLIP, 0xFF00A0A0, 0);
71 DrawTextW(L"Shift+L Load", x, y += 15, 0, DT_NOCLIP, 0xFF00A0A0, 0);
72 }
73
74 // next is picture and mode S data!
75 y = 170;
76 for (UINT i = 0; i < scan.children.size(); i++)
77 {
78 const Sscandata child = scan.children.at(i);
79
80 if (child.modeAC.type >= 10 && child.modeAC.type < 19)
81 swprintf_s(column, 99, L"ARJ-%S ", child.modeAC.IVR);
82 else
83 swprintf_s(column, 99, L"IVR %S ", child.modeAC.IVR);
84
85 DrawTextW(column, x, y, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255), 0);
86
87 if (i == 8)
88 {
89 x = 100; y = 170;
90 }
91 else
92 {
93 y += 15;
94 }
95 }
96
97 if (img)
98 img->Draw();
99
100 // extended data
101 x = 0;
102 y = -5;
103 switch (scan.scandata.modeAC.type)
104 {
105 case VehicleType::C98: swprintf_s(column, 99, L"C-98 MuVER"); break;
106 case VehicleType::E10: swprintf_s(column, 99, L"E-10 Saint"); break;
107 case VehicleType::P13: swprintf_s(column, 99, L"P-13 Prowler"); break;
108 case VehicleType::A4: swprintf_s(column, 99, L"A-4 Wanderer"); break;
109 case VehicleType::C2: swprintf_s(column, 99, L"C-2 Dasher"); break;
110 case VehicleType::T120: swprintf_s(column, 99, L"T-120 Steerhead"); break;
111 case VehicleType::T121: swprintf_s(column, 99, L"T-121 Steerhead"); break;
112 case VehicleType::E11: swprintf_s(column, 99, L"E-11 Saint"); break;
113 case VehicleType::ARJ_PAX: swprintf_s(column, 99, L"Passenger"); break;
114 case VehicleType::ARJ_CARGOAFT: swprintf_s(column, 99, L"Cargo AFT"); break;
115 case VehicleType::ARJ_FUEL: swprintf_s(column, 99, L"Auxiliary Fuel"); break;
116 case VehicleType::ARJ_CARGOTOP: swprintf_s(column, 99, L"Cargo TOP"); break;
117 case VehicleType::ARJ_MUNITIONS: swprintf_s(column, 99, L"Munitions"); break;
118 case VehicleType::T27: swprintf_s(column, 99, L"T-27 Mammoth"); break;
119 case VehicleType::C2A: swprintf_s(column, 99, L"C-2A Dasher"); break;
120 case VehicleType::W6Manx: swprintf_s(column, 99, L"W-6 Manx"); break;
121 case VehicleType::T19: swprintf_s(column, 99, L"T-19 Stratomaster"); break;
122 default: swprintf_s(column, 99, L"UNKNOWN "); break;
123 }
124 swprintf_s(str, 99, L" Type: %s", column);
125 DrawTextW(str, x, y += 10, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255), 1);
126 swprintf_s(str, 99, L"Registered to: %S", scan.scandata.modeAC.owner);
127 DrawTextW(str, x, y += 10, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255), 1);
128
129 if (scan.scandata.modeAC.type != VehicleType::C2 &&
136 scan.scandata.modeX = { };
137
138 if (scan.scandata.modeX.weightLbs.is_set())
139 {
140 swprintf_s(str, 99, L" Weight: %.0f kg", scan.scandata.modeX.weightLbs.get() / Kg2Lbs);
141 DrawTextW(str, x, y += 10, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255), 1);
142 }
143
144 if (scan.scandata.modeX.fuel_tank.is_set())
145 {
146 swprintf_s(str, 99, L" Fuel Tank: %.0f kg", scan.scandata.modeX.fuel_tank.get());
147 DrawTextW(str, x, y += 10, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255), 1);
148 }
149
150 if (scan.scandata.modeX.load_type.is_set())
151 {
152 switch (scan.scandata.modeX.load_type.get())
153 {
154 case CargoLoadType::None: swprintf_s(column, 99, L"None"); break;
155 case CargoLoadType::CargoRare: swprintf_s(column, 99, L"Rare"); break;
156 case CargoLoadType::CargoFood: swprintf_s(column, 99, L"Foodstuffs"); break;
157 case CargoLoadType::CargoCommon: swprintf_s(column, 99, L"Common"); break;
158 case CargoLoadType::CargoFuelOre: swprintf_s(column, 99, L"Fuel Ore"); break;
159 case CargoLoadType::CargoGoods: swprintf_s(column, 99, L"Consumer"); break;
160 case CargoLoadType::CargoFab: swprintf_s(column, 99, L"Fabricated"); break;
161 case CargoLoadType::CargoEnum: swprintf_s(column, 99, L"Fuel"); break;
162 case CargoLoadType::Passengers: swprintf_s(column, 99, L"Ticketed"); break;
163 case CargoLoadType::Colonists: swprintf_s(column, 99, L"Laborers"); break;
164 case CargoLoadType::Prisoners: swprintf_s(column, 99, L"Prisoners"); break;
165 case CargoLoadType::Residential: swprintf_s(column, 99, L"Estate"); break;
166 case CargoLoadType::Mining: swprintf_s(column, 99, L"Mine"); break;
167 case CargoLoadType::Farmstead: swprintf_s(column, 99, L"Farmstead"); break;
168 case CargoLoadType::Township: swprintf_s(column, 99, L"Township"); break;
169 case CargoLoadType::Airfield: swprintf_s(column, 99, L"Airfield"); break;
170 case CargoLoadType::WeaponLongarms: swprintf_s(column, 99, L"Longarms"); break;
171 default: swprintf_s(column, 99, L"UNKNOWN"); break;
172 }
173 swprintf_s(str, 99, L" Load Type: %s", column);
174 DrawTextW(str, x, y += 10, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255), 1);
175 }
176
178 {
179 switch (scan.scandata.modeAC.type)
180 {
181 case VehicleType::ARJ_CARGOAFT: swprintf_s(column, 99, L"%i MT", scan.scandata.modeX.load_quantity.get()); break;
182 case VehicleType::ARJ_CARGOTOP: swprintf_s(column, 99, L"%i MT", scan.scandata.modeX.load_quantity.get()); break;
183 case VehicleType::ARJ_FUEL: swprintf_s(column, 99, L"%i kg", scan.scandata.modeX.load_quantity.get()); break;
184 default: swprintf_s(column, 99, L"%i", scan.scandata.modeX.load_quantity.get()); break;
185 }
186 swprintf_s(str, 99, L"Load Quantity: %s", column);
187 DrawTextW(str, x, y += 10, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255), 1);
188 }
189
190 swprintf_s(str, 99, L" Destination: %S", scan.scandata.modeX.load_dest);
191 DrawTextW(str, x, y += 10, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255), 1);
192
194 WCHAR northsouth, eastwest;
195 if (latlng.x < 0.0f)
196 northsouth = 'N';// bus->gui->strings[L_LIST_NORTH].c_str()[0];
197 else
198 northsouth = 'S';// gui->strings[L_LIST_SOUTH].c_str()[0];
199 if (latlng.y < 0.0f)
200 eastwest = 'W';// gui->strings[L_LIST_WEST].c_str()[0];
201 else
202 eastwest = 'E';// gui->strings[L_LIST_EAST].c_str()[0];
203 swprintf_s(str, 99, L" Location: %c %06.3f %c %07.3f", northsouth, fabsf(latlng.x), eastwest, fabsf(latlng.y));
204 DrawTextW(str, x, y += 10, 0, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255), 1);
205}
206
207void Scanner::FrameMove(float fElapsed)
208{
209 if (bus->Scanner.CurrentScanTarget == 0)
210 return;
211
213 if (!scan.initialized)
214 return;
215
216 if (currentType == scan.scandata.modeAC.type)
217 return;
218
220
221 if (img)
222 img->Evict();
223
224 switch (currentType)
225 {
226 case VehicleType::T27:
227 img = new Sprite(logger, pDevice, "Textures/Scans/t27.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
228 break;
229 case VehicleType::C98:
230 img = new Sprite(logger, pDevice, "Textures/Scans/c98.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
231 break;
232 case VehicleType::E10:
233 img = new Sprite(logger, pDevice, "Textures/Scans/e10.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
234 break;
235 case VehicleType::P13:
236 img = new Sprite(logger, pDevice, "Textures/Scans/p13.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
237 break;
238 case VehicleType::A4:
239 img = new Sprite(logger, pDevice, "Textures/Scans/a4.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
240 break;
241 case VehicleType::C2:
242 img = new Sprite(logger, pDevice, "Textures/Scans/c2.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
243 break;
245 img = new Sprite(logger, pDevice, "Textures/Scans/t120.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
246 break;
248 img = new Sprite(logger, pDevice, "Textures/Scans/t121.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
249 break;
250 case VehicleType::E11:
251 img = new Sprite(logger, pDevice, "Textures/Scans/e11.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
252 break;
254 img = new Sprite(logger, pDevice, "Textures/Scans/passenger.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
255 break;
257 img = new Sprite(logger, pDevice, "Textures/Scans/cargoaft.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
258 break;
260 img = new Sprite(logger, pDevice, "Textures/Scans/auxfuel.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
261 break;
263 img = new Sprite(logger, pDevice, "Textures/Scans/cargotop.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
264 break;
266 img = new Sprite(logger, pDevice, "Textures/Scans/munition.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
267 break;
268 case VehicleType::C2A:
269 img = new Sprite(logger, pDevice, "Textures/Scans/c2a.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
270 break;
272 img = new Sprite(logger, pDevice, "Textures/Scans/w6.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
273 break;
274 case VehicleType::T19:
275 img = new Sprite(logger, pDevice, "Textures/Scans/t19.png", x + 197, y + 80, 0.3f, 0, 0, 1024, 1024, 0xFF3a88fe, 0.215f, 0.215f);
276 break;
277 }
278}
279
280bool Scanner::HandleKeyPress(short key, bool shift)
281{
282 logger->AddToCallStack("Scanner::HandleKeyPress");
283 if (!shift) return false;
284 if (!bus->Scanner.CurrentScanTarget) return false;
285
286 switch (key)
287 {
288 case 203:
289 case 75: // arrow left
290 {
291 Command command;
292 command.name = "RestorePage";
293 command.sValue = "MFD";
294 bus->commandStream.emplace_back(command);
295 return true;
296 }
297 //case 200:
298 //case 72: // arrow up
299 // uiRow--;
300 // if (uiRow < 0)
301 // uiRow = 0;
302 // return true;
303 //case 22: // u
304 // /// @todo need to make sure bay doors are open
305 // if (uiRow >= 0 && uiRow < ourcockpit.bays && bus->CargoBays[uiRow] != 0)
306 // {
307 // Command command;
308 // command.name = "UnloadCargoBay";
309 // command.ivalues[0] = uiRow; // bay number starting with 0
310 // command.ivalues[1] = bus->CargoBays[uiRow]; // vehicle ID
311 // bus->commandStream.emplace_back(command);
312 // }
313 // return true;
314 case 33: // f
315 {
316 temptarget = bus->Scanner.CurrentScanTarget; // vehicle ID
317 g_bTextInput = 6;
318 outgoing[0] = 0; // clear buffer
319 sprintf_s(prompt, sizeof(prompt), "[±kg]");
320 return true;
321 }
322 case 46: // c
323 {
324 temptarget = bus->Scanner.CurrentScanTarget; // vehicle ID
325 g_bTextInput = 5;
326 outgoing[0] = 0; // clear buffer
327 sprintf_s(prompt, sizeof(prompt), "[CR]");
328 return true;
329 }
330 case 17: // w
331 {
332 Command command;
333 command.name = "TransferWeapon";
334 command.ivalues[0] = bus->Scanner.CurrentScanTarget; // vehicle ID
335 bus->commandStream.emplace_back(command);
336 return true;
337 }
338 }
339 return false;
340}
RiseMath::Vector2 CalculateLatLng(RiseMath::Vector3 position)
@ ARJ_ENUM
Definition ServerTypes.h:79
@ W6Manx
Definition ServerTypes.h:84
@ ARJ_CARGOAFT
Definition ServerTypes.h:72
@ ARJ_FUEL
Definition ServerTypes.h:73
@ C98
Definition ServerTypes.h:61
@ C2
Definition ServerTypes.h:66
@ C2A
Definition ServerTypes.h:81
@ ARJ_MUNITIONS
Definition ServerTypes.h:75
@ T19
Definition ServerTypes.h:87
@ P13
Definition ServerTypes.h:64
@ ARJ_PAX
Definition ServerTypes.h:70
@ E10
Definition ServerTypes.h:63
@ T120
Definition ServerTypes.h:67
@ T27
Definition ServerTypes.h:82
@ E11
Definition ServerTypes.h:68
@ A4
Definition ServerTypes.h:65
@ T121
Definition ServerTypes.h:89
@ ARJ_CARGOTOP
Definition ServerTypes.h:74
@ Residential
@ Airfield
@ WeaponLongarms
@ CargoFab
@ CargoCommon
@ Mining
@ Colonists
@ Passengers
@ Township
@ Farmstead
@ None
Definition ServerTypes.h:97
@ CargoRare
Definition ServerTypes.h:98
@ CargoGoods
@ Prisoners
@ CargoFuelOre
@ CargoFood
Definition ServerTypes.h:99
@ CargoEnum
Definition Bus.h:20
scanDb Scanner
Definition Bus.h:484
std::vector< Command > commandStream
Definition Bus.h:442
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 AddToCallStack(const char *msg)
Definition Logger.cpp:355
bool is_set() const
Definition Nullable.h:87
T get() const
Definition Nullable.h:80
void Render() override
Definition Scanner.cpp:13
Sprite * img
Definition Instrument.h:162
int currentType
Definition Instrument.h:163
Scanner(int prmX, int prmY, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts)
Definition Scanner.cpp:5
bool HandleKeyPress(short key, bool shift) override
Definition Scanner.cpp:280
void FrameMove(float fElapsed) override
Definition Scanner.cpp:207
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
void Evict()
Definition Sprite.cpp:45
int CurrentScanTarget
Definition scanDb.h:66
Sscan Get(USHORT vehicleId) const
Definition scanDb.cpp:111
char prompt[80]
Definition globals.cpp:62
unsigned short temptarget
Definition globals.cpp:72
char g_bTextInput
Definition globals.cpp:61
char outgoing[80]
Definition globals.cpp:60
#define Kg2Lbs
Definition globals.h:40
constexpr PackedColor ColorARGB(unsigned a, unsigned r, unsigned g, unsigned b)
std::string sValue
Definition Command.h:20
int ivalues[2]
Definition Command.h:21
std::string name
Definition Command.h:11
RiseMath::Vector3 location
Definition scanDb.h:20
unsigned char type
Definition scanDb.h:17
char hullname[23]
Definition scanDb.h:18
char IVR[6]
Definition scanDb.h:16
char owner[13]
Definition scanDb.h:21
char load_dest[20]
Definition scanDb.h:33
Nullable< float > fuel_tank
Definition scanDb.h:35
Nullable< unsigned short > load_quantity
Definition scanDb.h:32
Nullable< float > weightLbs
Definition scanDb.h:34
Nullable< unsigned char > load_type
Definition scanDb.h:31
Definition scanDb.h:47
bool initialized
Definition scanDb.h:48
std::vector< Sscandata > children
Definition scanDb.h:50
Sscandata scandata
Definition scanDb.h:49
SmodeAC modeAC
Definition scanDb.h:41
SmodeX modeX
Definition scanDb.h:43