Rise
The Vieneo Province
Loading...
Searching...
No Matches
CargoManagement.cpp
Go to the documentation of this file.
1#include <dinput.h>
2
3#include "../Instrument.h"
4#include "../../Bus.h"
5
6CargoManagement::CargoManagement(int prmX, int prmY, float prmXScale, float prmYScale, Bus* prmBus, Logger* prmLogger, DeviceObject* prmDevice, std::vector<Font*> prmFonts, int height) :
7 Instrument(prmX, prmY, prmXScale, prmYScale, prmBus, prmLogger, prmDevice, prmFonts), manifest(height)
8{
9 logger->AddToCallStack("CargoManagement::ctor");
10 defaultFont = 1;
11}
12
14{
15 logger->AddToCallStack("CargoManagement::Render");
16 float totalWeightLbs = 0.0f;
17 int totalSouls = 0;
18 manifest.rows.clear();
19
20 manifest.Add(L"MANIFEST WGT KG REGISTRY DESCRIPTION QUANTITY NOTES", 0xFF00FFFF);
21 manifest.Add(L"------------- ------ ------------ -------------------- -------- --------------------", 0xFF00FFFF);
22
23 WCHAR row[999];
24 WCHAR column[99];
25 switch (playerships[0].type)
26 {
27 case VehicleType::C98: swprintf_s(column, 99, L"C-98 MuVER"); break;
28 case VehicleType::E10: swprintf_s(column, 99, L"E-10 Saint"); break;
29 case VehicleType::P13: swprintf_s(column, 99, L"P-13 Prowler"); break;
30 case VehicleType::A4: swprintf_s(column, 99, L"A-4 Wanderer"); break;
31 case VehicleType::C2: swprintf_s(column, 99, L"C-2 Dasher"); break;
32 case VehicleType::T120: swprintf_s(column, 99, L"T-120 Steerhead"); break;
33 case VehicleType::T121: swprintf_s(column, 99, L"T-121 Steerhead"); break;
34 case VehicleType::E11: swprintf_s(column, 99, L"E-11 Saint"); break;
35 case VehicleType::T27: swprintf_s(column, 99, L"T-27 Mammoth"); break;
36 case VehicleType::C2A: swprintf_s(column, 99, L"C-2A Dasher"); break;
37 case VehicleType::W6Manx: swprintf_s(column, 99, L"W-6 Manx"); break;
38 case VehicleType::T19: swprintf_s(column, 99, L"T-19 Stratomaster"); break;
39 default: swprintf_s(column, 99, L"Unknown"); break;
40 }
41 swprintf_s(row, 999, L"Empty Weight %6.0f IVR %-6S %-18s %S", ourcockpit.emptyWeightLbs / Kg2Lbs, playerships[0].IVR, column, ourcockpit.owner);
42 manifest.Add(row, 0xFFAAAAAA);
43 totalWeightLbs += ourcockpit.emptyWeightLbs;
44
45 swprintf_s(row, 999, L"Fuel %6.0f Cap. %-6.0f", fuel / Kg2Lbs, ourcockpit.fuelmax / Kg2Lbs);
46 manifest.Add(row, 0xFFAAAAAA, "Fuel");
47 totalWeightLbs += fuel;
48
49#pragma region Avionics
50
51 swprintf_s(row, 999, L"Avionics Bays 8 VPT ");
52 totalWeightLbs += 16.0f;
53 if (playerships[0].transponder)
54 wcscat_s(row, 999, L"ON");
55 else if (ourcockpit.vdat.vpt <= 0)
56 wcscat_s(row, 999, L"INOP");
57 else
58 wcscat_s(row, 999, L"OFF");
59 manifest.Add(row, 0xFFAAAAAA, "Avionics", 6);
60
61 for (short t = 0; t < MAX_AVIOPERSHIP; t++)
62 {
63 switch (ourcockpit.vdat.avionictype[t])
64 {
65 case 1: // 320LRS
66 swprintf_s(row, 999, L" 13 320K-LRS ON");
67 totalWeightLbs += 28.0f;
68 manifest.Add(row, 0xFFAAAAAA);
69 break;
70 case 2: // 40SRS
71 swprintf_s(row, 999, L" 2 40K-SRS ON");
72 totalWeightLbs += 3.5f;
73 manifest.Add(row, 0xFFAAAAAA);
74 break;
75 case 3: // JVC Radio
76 swprintf_s(row, 999, L" 2 JVC Radio ");
78 wcscat_s(row, 999, L"OFF");
79 else
80 {
81 switch (bus->station)
82 {
83 case 1: wcscat_s(row, 999, L"FM1"); break;
84 case 2: wcscat_s(row, 999, L"FM2"); break;
85 case 3: wcscat_s(row, 999, L"FM3"); break;
86 case 4: wcscat_s(row, 999, L"FM4"); break;
87 case 5: wcscat_s(row, 999, L"FM5"); break;
88 }
89 }
90 totalWeightLbs += 4.75f;
91 manifest.Add(row, 0xFFAAAAAA, "Avionics", ourcockpit.vdat.avionictype[t]);
92 break;
93 case 4: // Remote Assay
94 swprintf_s(row, 999, L" 6 Remote Assay ");
96 wcscat_s(row, 999, L"ON");
97 else
98 wcscat_s(row, 999, L"OFF");
99 totalWeightLbs += 13.9f;
100 manifest.Add(row, 0xFFAAAAAA, "Avionics", ourcockpit.vdat.avionictype[t]);
101 break;
102 case 5: // Weather Radar
103 swprintf_s(row, 999, L" 8 Weather Radar ");
105 wcscat_s(row, 999, L"ON");
106 else
107 wcscat_s(row, 999, L"OFF");
108 totalWeightLbs += 17.8574f;
109 manifest.Add(row, 0xFFAAAAAA, "Avionics", ourcockpit.vdat.avionictype[t]);
110 break;
111 }
112 }
113
114#pragma endregion
115
116 bool hasWeapons = false;
117 for (short t = 0; t < MAX_WEAPPERSHIP; t++)
118 {
119 switch (ourcockpit.vdat.weapontype[t])
120 {
121 case 1:
122 if (!hasWeapons)
123 swprintf_s(row, 999, L"Weapons Bays 113 Fuzer Launcher %.0f%%", weapontimer[t] / weaponfuzerreadyC * 100.0f);
124 else
125 swprintf_s(row, 999, L" 113 Fuzer Launcher %.0f%%", weapontimer[t] / weaponfuzerreadyC * 100.0f);
126 hasWeapons = true;
127 totalWeightLbs += 248.0f;
128 manifest.Add(row, 0xFFAAAAAA);// , "Weapons", t);
129 break;
130 case 2:
131 if (!hasWeapons)
132 swprintf_s(row, 999, L"Weapons Bays 282 Sinker Launcher %.0f%%", weapontimer[t] / weaponsinkerreadyC * 100.0f);
133 else
134 swprintf_s(row, 999, L" 282 Sinker Launcher %.0f%%", weapontimer[t] / weaponsinkerreadyC * 100.0f);
135 hasWeapons = true;
136 totalWeightLbs += 619.5f;
137 manifest.Add(row, 0xFFAAAAAA);// , "Weapons", t);
138 break;
139 case 3:
140 const float tempWeightLbs = 102.5f + ourcockpit.vdat.weaponreload * 188.0f;
141 if (!hasWeapons)
142 swprintf_s(row, 999, L"Weapons Bays %6.0f Longarm Launcher %i Rounds %.0f%%", tempWeightLbs / Kg2Lbs, ourcockpit.vdat.weaponreload, weapontimer[t] / weaponlongarmreadyC * 100.0f);
143 else
144 swprintf_s(row, 999, L" %6.0f Longarm Launcher %i Rounds %.0f%%", tempWeightLbs / Kg2Lbs, ourcockpit.vdat.weaponreload, weapontimer[t] / weaponlongarmreadyC * 100.0f);
145 hasWeapons = true;
146 totalWeightLbs += tempWeightLbs;
147 manifest.Add(row, 0xFFAAAAAA);// , "Weapons", t);
148 break;
149 }
150 }
151
152 for (int i = 0; i < ourcockpit.bays; i++)
153 {
155 wcscpy_s(column, 99, L"Cargo Bed ");
156 else
157 swprintf_s(column, 99, L"Cargo Bay %-2i ", i + 1);
158 wcscpy_s(row, 999, column);
159
160 if (bus->CargoBays[i] != 0)
161 {
162 const Sscan cargobay = bus->Scanner.Get(bus->CargoBays[i]);
163 if (cargobay.initialized)
164 {
165 if (cargobay.scandata.modeX.weightLbs.is_set())
166 {
167 swprintf_s(column, 99, L"%6.0f ", cargobay.scandata.modeX.weightLbs.get() / Kg2Lbs);
168 wcscat_s(row, 999, column);
169 totalWeightLbs += cargobay.scandata.modeX.weightLbs.get();
170 }
171 else
172 {
173 logger->Log("WeightLbs not set on cargo bay!", Logger::Level::Error);
174 }
175
176 if (cargobay.scandata.modeAC.type >= 10 && cargobay.scandata.modeAC.type < 19)
177 swprintf_s(column, 99, L"ARJ-%-6S ", cargobay.scandata.modeAC.IVR);
178 else if (cargobay.scandata.modeX.pilot.is_set() && cargobay.scandata.modeX.pilot.get())
179 {
180 swprintf_s(column, 99, L"IVR %-6S* ", cargobay.scandata.modeAC.IVR);
181 totalSouls++;
182 }
183 else
184 swprintf_s(column, 99, L"IVR %-6S ", cargobay.scandata.modeAC.IVR);
185 wcscat_s(row, 999, column);
186
187 switch (cargobay.scandata.modeAC.type)
188 {
189 case VehicleType::C98: swprintf_s(column, 99, L"MuVER "); break;
190 case VehicleType::C2: swprintf_s(column, 99, L"C-2 "); break;
191 case VehicleType::ARJ_PAX: swprintf_s(column, 99, L"Pax "); break;
192 case VehicleType::ARJ_CARGOAFT: swprintf_s(column, 99, L"Crgo AFT "); break;
193 case VehicleType::ARJ_FUEL: swprintf_s(column, 99, L"AuxFuel "); break;
194 case VehicleType::ARJ_CARGOTOP: swprintf_s(column, 99, L"Crgo TOP "); break;
195 case VehicleType::ARJ_MUNITIONS: swprintf_s(column, 99, L"Munition "); break;
196 case VehicleType::C2A: swprintf_s(column, 99, L"C-2A "); break;
197 default: swprintf_s(column, 99, L"UNKNOWN "); break;
198 }
199 wcscat_s(row, 999, column);
200
202 {
203 if (cargobay.scandata.modeX.load_quantity.is_set() && cargobay.scandata.modeX.load_type.is_set() &&
204 cargobay.scandata.modeX.load_quantity.get() > 0)
205 swprintf_s(column, 99, L"Fuel %i kg ", cargobay.scandata.modeX.load_quantity.get());
206 else
207 swprintf_s(column, 99, L" ");
208 }
209 else if (cargobay.scandata.modeAC.type == VehicleType::ARJ_MUNITIONS)
210 {
211 if (cargobay.scandata.modeX.load_quantity.is_set() && cargobay.scandata.modeX.load_type.is_set() &&
212 cargobay.scandata.modeX.load_quantity.get() > 0)
213 {
214 switch (cargobay.scandata.modeX.load_type.get())
215 {
216 case CargoLoadType::None: swprintf_s(column, 99, L" "); break;
217 case CargoLoadType::WeaponLongarms: swprintf_s(column, 99, L"Longarm %i Rounds ", cargobay.scandata.modeX.load_quantity.get()); break;
218 default: swprintf_s(column, 99, L"UNKNOWN "); break;
219 }
220 }
221 else
222 swprintf_s(column, 99, L" ");
223 }
224 else
225 {
226 if (cargobay.scandata.modeX.load_type.is_set())
227 {
228 if (cargobay.scandata.modeX.load_quantity.is_set())
229 {
230 switch (cargobay.scandata.modeX.load_type.get())
231 {
232 case CargoLoadType::None: swprintf_s(column, 99, L" "); break;
233 case CargoLoadType::CargoRare: swprintf_s(column, 99, L"Rare %i MT ", cargobay.scandata.modeX.load_quantity.get()); break;
234 case CargoLoadType::CargoFood: swprintf_s(column, 99, L"Foodstuffs %i MT ", cargobay.scandata.modeX.load_quantity.get()); break;
235 case CargoLoadType::CargoCommon: swprintf_s(column, 99, L"Common %i MT ", cargobay.scandata.modeX.load_quantity.get()); break;
236 case CargoLoadType::CargoFuelOre: swprintf_s(column, 99, L"Fuel Ore %i MT ", cargobay.scandata.modeX.load_quantity.get()); break;
237 case CargoLoadType::CargoGoods: swprintf_s(column, 99, L"Consumer %i MT ", cargobay.scandata.modeX.load_quantity.get()); break;
238 case CargoLoadType::CargoFab: swprintf_s(column, 99, L"Fabricated %i MT ", cargobay.scandata.modeX.load_quantity.get()); break;
239 case CargoLoadType::Passengers: swprintf_s(column, 99, L"Ticketed %i ", cargobay.scandata.modeX.load_quantity.get());
240 totalSouls += cargobay.scandata.modeX.load_quantity.get();
241 break;
242 case CargoLoadType::Colonists: swprintf_s(column, 99, L"Laborers %i ", cargobay.scandata.modeX.load_quantity.get());
243 totalSouls += cargobay.scandata.modeX.load_quantity.get();
244 break;
245 case CargoLoadType::Prisoners: swprintf_s(column, 99, L"Prisoners %i ", cargobay.scandata.modeX.load_quantity.get());
246 totalSouls += cargobay.scandata.modeX.load_quantity.get();
247 break;
248 case CargoLoadType::Residential: swprintf_s(column, 99, L"Estate %ix ", cargobay.scandata.modeX.load_quantity.get()); break;
249 case CargoLoadType::Mining: swprintf_s(column, 99, L"Mine %ix ", cargobay.scandata.modeX.load_quantity.get()); break;
250 case CargoLoadType::Farmstead: swprintf_s(column, 99, L"Farmstead %ix ", cargobay.scandata.modeX.load_quantity.get()); break;
251 case CargoLoadType::Township: swprintf_s(column, 99, L"Township %ix ", cargobay.scandata.modeX.load_quantity.get()); break;
252 case CargoLoadType::Airfield: swprintf_s(column, 99, L"Airfield %ix ", cargobay.scandata.modeX.load_quantity.get()); break;
253 case CargoLoadType::Refinery: swprintf_s(column, 99, L"Refinery %ix ", cargobay.scandata.modeX.load_quantity.get()); break;
254 default: swprintf_s(column, 99, L"UNKNOWN "); break;
255 }
256 }
257 else
258 {
259 swprintf_s(column, 99, L"LOAD_QUANTITY ERROR ");
260 }
261 }
262 else
263 {
264 swprintf_s(column, 99, L" ");
265 }
266 }
267 column[21] = 0; // truncate since variable length with %i's
268 wcscat_s(row, 999, column);
269
270 if (cargobay.scandata.modeX.load_quantity.is_set() && cargobay.scandata.modeX.load_quantity.get() > 0)
271 {
272 swprintf_s(column, 99, L"%S", cargobay.scandata.modeX.load_dest);
273 wcscat_s(row, 999, column);
274 }
275 }
276 else
277 {
278 swprintf_s(column, 99, L"SCAN DATA NOT INITIALIZED");
279 wcscat_s(row, 999, column);
280 }
281 }
282
283 manifest.Add(row, 0xFFFFFFFF, "Bay", i);
284 }
285
286 if (playerships[0].groundvehicle)
287 swprintf_s(row, 999, L"Crew %6i %-12S %-20S Driver", ourcockpit.playerWeightKg, ourcockpit.handle, ourcockpit.character);
288 else
289 swprintf_s(row, 999, L"Crew %6i %-12S %-20S Pilot", ourcockpit.playerWeightKg, ourcockpit.handle, ourcockpit.character);
290 manifest.Add(row, 0xFFAAAAAA);// , "Crew", 0);
291 totalWeightLbs += ourcockpit.playerWeightKg * Kg2Lbs;
292 totalSouls++;
293
294 float stowageWeightLbs;
296 {
297 stowageWeightLbs = ourcockpit.stowageQuantity * 225.0f; // 185 average with carry-on + 40 lbs baggage average
298 totalSouls += ourcockpit.stowageQuantity;
299
300 swprintf_s(row, 999, L"Stowage %6.0f ", stowageWeightLbs / Kg2Lbs);
302 {
303 case CargoLoadType::Passengers: swprintf_s(column, 99, L"Pax Ticketed %i ", ourcockpit.stowageQuantity); break;
304 case CargoLoadType::Colonists: swprintf_s(column, 99, L"Pax Laborers %i ", ourcockpit.stowageQuantity); break;
305 case CargoLoadType::Prisoners: swprintf_s(column, 99, L"Pax Prisoners %i ", ourcockpit.stowageQuantity); break;
306 default: swprintf_s(column, 99, L"Pax UNKNOWN %i ", ourcockpit.stowageQuantity); break;
307 }
308 column[31] = 0; // truncate since variable length with %i's
309 wcscat_s(row, 999, column);
310
311 switch (ourcockpit.stowageDestination) // apparently just to support taxi
312 {
313 case 0: wcscpy_s(column, 99, L"Undeclared"); break;
314 case 1: wcscpy_s(column, 99, L"Deois Airport"); break;
315 case 2: wcscpy_s(column, 99, L"LA Eyeworks"); break;
316 case 3: wcscpy_s(column, 99, L"Fleet Bank"); break;
317 case 4: wcscpy_s(column, 99, L"ATI Tower"); break;
318 case 5: wcscpy_s(column, 99, L"Zana Zoom's"); break;
319 case 6: wcscpy_s(column, 99, L"UI Building"); break;
320 case REF_DOCKENUMCPOC: wcscpy_s(column, 99, L"CPOC"); break;
321 case REF_DOCKTAC: wcscpy_s(column, 99, L"TAC"); break;
322 case 12: wcscpy_s(column, 99, L"Arcridge"); break;
323 case 13: wcscpy_s(column, 99, L"Junk Ore Inc"); break;
324 case 14: wcscpy_s(column, 99, L"Deois Airport"); break; // ground traffic
325 case 15: wcscpy_s(column, 99, L"Law Offices"); break;
326 case 16: wcscpy_s(column, 99, L"Police Station"); break;
327 default: wcscpy_s(column, 99, L"UNKNOWN"); break;
328 }
329 wcscat_s(row, 999, column);
330 }
331 else
332 {
333 stowageWeightLbs = ourcockpit.stowageQuantity * 1000.0f * Kg2Lbs;
334 swprintf_s(row, 999, L"Stowage %6.0f ", stowageWeightLbs / Kg2Lbs);
336 {
337 case CargoLoadType::None: swprintf_s(column, 99, L" "); break;
338 case CargoLoadType::CargoRare: swprintf_s(column, 99, L"Cargo Rare %i MT ", ourcockpit.stowageQuantity); break;
339 case CargoLoadType::CargoFood: swprintf_s(column, 99, L"Cargo Foodstuffs %i MT ", ourcockpit.stowageQuantity); break;
340 case CargoLoadType::CargoCommon: swprintf_s(column, 99, L"Cargo Common %i MT ", ourcockpit.stowageQuantity); break;
341 case CargoLoadType::CargoFuelOre: swprintf_s(column, 99, L"Cargo Fuel Ore %i MT ", ourcockpit.stowageQuantity); break;
342 case CargoLoadType::CargoGoods: swprintf_s(column, 99, L"Cargo Consumer %i MT ", ourcockpit.stowageQuantity); break;
343 case CargoLoadType::CargoFab: swprintf_s(column, 99, L"Cargo Fabricated %i MT ", ourcockpit.stowageQuantity); break;
344 case CargoLoadType::Residential: swprintf_s(column, 99, L"Estate %ix ", ourcockpit.stowageQuantity); break;
345 case CargoLoadType::Mining: swprintf_s(column, 99, L"Mine %ix ", ourcockpit.stowageQuantity); break;
346 case CargoLoadType::Farmstead: swprintf_s(column, 99, L"Farmstead %ix ", ourcockpit.stowageQuantity); break;
347 case CargoLoadType::Township: swprintf_s(column, 99, L"Township %ix ", ourcockpit.stowageQuantity); break;
348 case CargoLoadType::Airfield: swprintf_s(column, 99, L"Airfield %ix ", ourcockpit.stowageQuantity); break;
349 case CargoLoadType::Refinery: swprintf_s(column, 99, L"Refinery %ix ", ourcockpit.stowageQuantity); break;
350 default: swprintf_s(column, 99, L"Cargo UNKNOWN %i MT ", ourcockpit.stowageQuantity); break;
351 }
352 column[31] = 0; // truncate since variable length with %i's
353 wcscat_s(row, 999, column);
354 }
355 manifest.Add(row, 0xFFAAAAAA);
356 totalWeightLbs += stowageWeightLbs;
357
358
360 for (UINT i = 0; i < ourcockpit.personalInventory.size(); i++)
361 {
362 float inventoryWeightLbs = 0.0f;
363 if (ourcockpit.personalInventory.at(i).type == 1) // General
364 {
365 switch (ourcockpit.personalInventory.at(i).subtype)
366 {
368 wcscpy_s(column, 99, L"Lock Pick Set"); inventoryWeightLbs = 1.48f; break;
370 wcscpy_s(column, 99, L"Binoculars"); inventoryWeightLbs = 3.2f; break;
371 case KitType::ATM:
372 wcscpy_s(column, 99, L"ATM"); inventoryWeightLbs = 209.0f; break;
374 wcscpy_s(column, 99, L"Night Vision"); inventoryWeightLbs = 3.2f; break;
376 wcscpy_s(column, 99, L"E-11 Upgrade Voucher"); inventoryWeightLbs = 0.0f; break;
378 wcscpy_s(column, 99, L"Sunglasses"); inventoryWeightLbs = 0.1f; break;
380 wcscpy_s(column, 99, L"Fireworks"); inventoryWeightLbs = 178.0f; break;
382 wcscpy_s(column, 99, L"Temp Runway Lights"); inventoryWeightLbs = 495.0f; break;
384 wcscpy_s(column, 99, L"Colony Up-link"); inventoryWeightLbs = 40.0f; break;
386 wcscpy_s(column, 99, L"First Aid Kit"); inventoryWeightLbs = 5.0f; break;
388 wcscpy_s(column, 99, L"Candy Cane"); inventoryWeightLbs = 0.1f; break;
389 case KitType::EVA_KIT:
390 wcscpy_s(column, 99, L"EVA Suit"); inventoryWeightLbs = 145.5f; break;
392 wcscpy_s(column, 99, L"Backpack"); inventoryWeightLbs = 3.6f; break;
394 wcscpy_s(column, 99, L"Cigarettes, Carton"); inventoryWeightLbs = 0.7f; break;
396 wcscpy_s(column, 99, L"Polaroid Picture"); inventoryWeightLbs = 0.0f; break;
397 case KitType::RVR:
398 wcscpy_s(column, 99, L"Runway Visual Range"); inventoryWeightLbs = 1500.0f; break;
399 case KitType::ILS: // GLS
400 wcscpy_s(column, 99, L"GBAS Landing System"); inventoryWeightLbs = 4300.0f; break;
401 default: wcscpy_s(column, 99, L"UNKNOWN PERSONAL INVENTORY"); inventoryWeightLbs = 0.0f; break;
402 }
403 }
404 else
405 {
406 wcscpy_s(column, 99, L"UNKNOWN TYPE"); inventoryWeightLbs = 0.0f;
407 }
408 if (i == 0)
409 swprintf_s(row, 999, L"Baggage %6.0f %s", inventoryWeightLbs / Kg2Lbs, column);
410 else
411 swprintf_s(row, 999, L" %6.0f %s", inventoryWeightLbs / Kg2Lbs, column);
412
413 manifest.Add(row, 0xFFAAAAAA, "Baggage", i);
414 totalWeightLbs += inventoryWeightLbs;
415 }
416 if (ourcockpit.personalInventory.empty())
417 swprintf_s(row, 999, L"Baggage %6.0f Cash (CR) %.0f", cash * 0.001f, cash);
418 else
419 swprintf_s(row, 999, L" %6.0f Cash (CR) %.0f", cash * 0.001f, cash);
420 manifest.Add(row, 0xFFAAAAAA);
421 totalWeightLbs += cash * 0.001f * Kg2Lbs; // cash is in kg
422
423
425 for (UINT i = 0; i < ourcockpit.vehicleInventory.size(); i++)
426 {
427 float inventoryWeightLbs = 0.0f;
428 if (ourcockpit.vehicleInventory.at(i).type == 1) // General
429 {
430 switch (ourcockpit.vehicleInventory.at(i).subtype)
431 {
433 wcscpy_s(column, 99, L"Lock Pick Set"); inventoryWeightLbs = 1.48f; break;
435 wcscpy_s(column, 99, L"Binoculars"); inventoryWeightLbs = 3.2f; break;
436 case KitType::ATM:
437 wcscpy_s(column, 99, L"ATM"); inventoryWeightLbs = 209.0f; break;
439 wcscpy_s(column, 99, L"Night Vision"); inventoryWeightLbs = 3.2f; break;
441 wcscpy_s(column, 99, L"E-11 Upgrade Voucher"); inventoryWeightLbs = 0.0f; break;
443 wcscpy_s(column, 99, L"Sunglasses"); inventoryWeightLbs = 0.1f; break;
445 wcscpy_s(column, 99, L"Fireworks"); inventoryWeightLbs = 178.0f; break;
447 wcscpy_s(column, 99, L"Temp Runway Lights"); inventoryWeightLbs = 495.0f; break;
449 wcscpy_s(column, 99, L"Colony Up-link"); inventoryWeightLbs = 40.0f; break;
451 wcscpy_s(column, 99, L"First Aid Kit"); inventoryWeightLbs = 5.0f; break;
453 wcscpy_s(column, 99, L"Candy Cane"); inventoryWeightLbs = 0.1f; break;
454 case KitType::EVA_KIT:
455 wcscpy_s(column, 99, L"EVA Suit"); inventoryWeightLbs = 145.5f; break;
457 wcscpy_s(column, 99, L"Backpack"); inventoryWeightLbs = 3.6f; break;
459 wcscpy_s(column, 99, L"Cigarettes, Carton"); inventoryWeightLbs = 0.7f; break;
461 wcscpy_s(column, 99, L"Polaroid Picture"); inventoryWeightLbs = 0.0f; break;
462 case KitType::RVR:
463 wcscpy_s(column, 99, L"Runway Visual Range"); inventoryWeightLbs = 1500.0f; break;
464 case KitType::ILS: // GLS
465 wcscpy_s(column, 99, L"GBAS Landing System"); inventoryWeightLbs = 4300.0f; break;
466 case KitType::NexRad:
467 wcscpy_s(column, 99, L"Doppler Radar"); inventoryWeightLbs = 30000.0f; break;
468 default: wcscpy_s(column, 99, L"UNKNOWN VEHICLE INVENTORY"); inventoryWeightLbs = 0.0f; break;
469 }
470 }
471 else if (ourcockpit.vehicleInventory.at(i).type == 2) // Avionics
472 {
473 switch (ourcockpit.vehicleInventory.at(i).subtype)
474 {
475 case 1: // 320LRS
476 wcscpy_s(column, 99, L"Long Range Scanner"); inventoryWeightLbs = 28.0f; break;
477 case 2: // 40SRS
478 wcscpy_s(column, 99, L"Short Range Scanner"); inventoryWeightLbs = 3.5f; break;
479 case 3: // JVC Radio
480 wcscpy_s(column, 99, L"JVC Radio"); inventoryWeightLbs = 4.75f; break;
481 case 4: // Remote Assay
482 wcscpy_s(column, 99, L"Remote Assay"); inventoryWeightLbs = 13.9f; break;
483 case 5: // Weather Radar
484 wcscpy_s(column, 99, L"Weather Radar"); inventoryWeightLbs = 17.8574f; break;
485 default: wcscpy_s(column, 99, L"UNKNOWN AVIONICS INVENTORY"); inventoryWeightLbs = 0.0f; break;
486 }
487 }
488 else // Weapons
489 {
490 switch (ourcockpit.vehicleInventory.at(i).subtype)
491 {
492 case 1:
493 wcscpy_s(column, 99, L"Fuzer Launcher"); inventoryWeightLbs = 248.0f; break;
494 case 2:
495 wcscpy_s(column, 99, L"Sinker Launcher"); inventoryWeightLbs = 619.5f; break;
496 case 3:
497 wcscpy_s(column, 99, L"Longarm Launcher"); inventoryWeightLbs = 102.5f; break;
498 default: wcscpy_s(column, 99, L"UNKNOWN WEAPONS INVENTORY"); inventoryWeightLbs = 0.0f; break;
499 }
500 }
501 if (i == 0)
502 swprintf_s(row, 999, L"Cabin %6.0f %s", inventoryWeightLbs / Kg2Lbs, column);
503 else
504 swprintf_s(row, 999, L" %6.0f %s", inventoryWeightLbs / Kg2Lbs, column);
505
506 manifest.Add(row, 0xFFAAAAAA, "Cabin", i);
507 totalWeightLbs += inventoryWeightLbs;
508 }
509
510
511 const float loadedC = (totalWeightLbs - ourcockpit.emptyWeightLbs) / (ourcockpit.maxGrossLbs - ourcockpit.emptyWeightLbs);
512 swprintf_s(row, 999, L"Total Weight %6.0f ", totalWeightLbs / Kg2Lbs);
513
514 if (totalWeightLbs >= 300000.0f)
515 wcscat_s(row, 999, L"Heavy ");
516 else
517 wcscat_s(row, 999, L" ");
518
519 if (totalSouls == 1)
520 swprintf_s(column, 99, L"%i Soul", totalSouls);
521 else
522 swprintf_s(column, 99, L"%i Souls", totalSouls);
523 wcscat_s(row, 999, column);
524
525 if (loadedC > 1.0f)
526 manifest.Add(row, Rendering::ColorARGB(255, 255, 0, 0));
527 else if (loadedC > 0.75f)
528 manifest.Add(row, Rendering::ColorARGB(255, 255, 255, 0));
529 else
530 manifest.Add(row, Rendering::ColorARGB(255, 0, 255, 0));
531
532 // Build all rows before choosing the window: inventory can change while scrolled.
534 if (manifest.offset > 0)
535 manifest.rows[0].text.replace(0, 13, L"^^^ MORE ^^^ ");
536 for (int i = 0; i < static_cast<int>(manifest.rows.size()); ++i)
537 {
538 const int screenRow = manifest.ScreenRow(i);
539 if (screenRow < 0) continue;
540 const auto& item = manifest.rows[i];
541 const int rowY = screenRow * CargoManifestList::LineHeight;
542 if (i == manifest.selected && !item.type.empty())
543 DrawTextW(std::wstring(78, L'\x2592').c_str(), 0, rowY, 0, DT_NOCLIP, 0xFF00A0A0);
544 DrawTextW(item.text.c_str(), 0, rowY, 0, DT_NOCLIP, item.color);
545 }
546 if (manifest.MoreBelow())
547 DrawTextW(L"vvv MORE vvv", 0, manifest.moreY, 0, DT_NOCLIP, 0xFF00FFFF);
548
549 const auto& selected = manifest.rows[manifest.selected];
550 if (!g_bTextInput)
551 {
552 if (selected.type == "Bay" && bus->CargoBays[selected.value] != 0)
553 {
554 DrawTextW(L"\x21e7+U Unload \x21e7+S Scan \x21e7+F Fuel", 0, manifest.controlsY, 0, DT_NOCLIP, 0xFF00A0A0, 0);
555 }
556 else if (selected.type == "Cabin")
557 {
558 DrawTextW(L"\x21e7+U Use \x21e7+S Swap \x21e7+T Transfer", 0, manifest.controlsY, 0, DT_NOCLIP, 0xFF00A0A0, 0);
559 }
560 else if (selected.type == "Baggage")
561 {
562 DrawTextW(L"\x21e7+U Use \x21e7+S Swap \x21e7+T Transfer", 0, manifest.controlsY, 0, DT_NOCLIP, 0xFF00A0A0, 0);
563 }
564 else if (selected.type == "Fuel")
565 {
566 DrawTextW(L"\x21e7+J Jettison", 0, manifest.controlsY, 0, DT_NOCLIP, 0xFF00A0A0, 0);
567 }
568 else if (selected.type == "Avionics" && selected.value == 3) // JVC Radio
569 {
570 DrawTextW(L"\x21e7+U Use \x21e7+\x2194 Freq", 0, manifest.controlsY, 0, DT_NOCLIP, 0xFF00A0A0, 0);
571 }
572 else if (selected.type == "Avionics") // All other avionics
573 {
574 DrawTextW(L"\x21e7+U Use", 0, manifest.controlsY, 0, DT_NOCLIP, 0xFF00A0A0, 0);
575 }
576 else if (manifest.selected == 0)
577 {
578 DrawTextW(L"\x21e7+\x2b07", 0, manifest.controlsY, 0, DT_NOCLIP, 0xFF00A0A0, 0);
579 }
580 else if (manifest.selected == static_cast<int>(manifest.rows.size()) - 1)
581 {
582 DrawTextW(L"\x21e7+\x2b06", 0, manifest.controlsY, 0, DT_NOCLIP, 0xFF00A0A0, 0);
583 }
584 else
585 {
586 DrawTextW(L"\x21e7+\x2195", 0, manifest.controlsY, 0, DT_NOCLIP, 0xFF00A0A0, 0);
587 }
588 }
589}
590
591bool CargoManagement::HandleKeyPress(short key, bool shift)
592{
593 logger->AddToCallStack("CargoManagement::HandleKeyPress");
594 if (!shift || key == 42) return false;
595 if (manifest.rows.empty()) return false;
596 if (key == DIK_UP || key == DIK_DOWN || key == DIK_NUMPAD8 || key == DIK_NUMPAD2)
597 {
598 // Follow the same Windows keyboard preferences as the GUI chat input.
599 UINT delay = 1;
600 DWORD speed = 31;
601 SystemParametersInfoW(SPI_GETKEYBOARDDELAY, 0, &delay, 0);
602 SystemParametersInfoW(SPI_GETKEYBOARDSPEED, 0, &speed, 0);
603 return manifest.HandleNavigationKey(key, shift, delay, speed);
604 }
605 const auto& selected = manifest.rows[manifest.selected];
606
607 switch (key)
608 {
609 case 205:
610 case 77:
611 case 52: // arrow right
612 if (selected.type == "Avionics" && selected.value == 3)
613 {
614 bus->station++;
615 if (bus->station > 5)
616 bus->station = 1;
617 Command command;
618 command.name = "RadioStation";
619 command.ivalues[0] = selected.value; // item type
620 bus->commandStream.emplace_back(command);
621 return true;
622 }
623 break;
624 case 203:
625 case 75:
626 case 51: // arrow left
627 if (selected.type == "Avionics" && selected.value == 3)
628 {
629 bus->station--;
630 if (bus->station < 1)
631 bus->station = 5;
632 Command command;
633 command.name = "RadioStation";
634 command.ivalues[0] = selected.value; // item type
635 bus->commandStream.emplace_back(command);
636 return true;
637 }
638 break;
639 case DIK_U:
640 if (selected.type == "Bay")
641 {
643 if (bus->CargoBays[selected.value] != 0)
644 {
645 Command command;
646 command.name = "UnloadCargoBay";
647 command.ivalues[0] = selected.value; // bay number starting with 0
648 command.ivalues[1] = bus->CargoBays[selected.value]; // vehicle ID
649 bus->commandStream.emplace_back(command);
650 return true;
651 }
652 }
653 else if (selected.type == "Cabin" || selected.type == "Baggage")
654 {
655 Command command;
656 command.name = "UseInventoryItem";
657 command.ivalues[0] = selected.value; // inventoryId
658 command.bValue = selected.type == "Baggage"; // onPerson
659 bus->commandStream.emplace_back(command);
660 return true;
661 }
662 else if (selected.type == "Avionics")
663 {
664 Command command;
665 command.name = "ToggleAvionics";
666 command.ivalues[0] = selected.value; // item type
667 bus->commandStream.emplace_back(command);
668 return true;
669 }
670 break;
671 case 31: // s
672 if (selected.type == "Bay")
673 {
674 if (bus->CargoBays[selected.value] != 0)
675 {
676 Command command;
677 command.name = "ChangeMfdPage";
678 command.sValue = "Scanner";
679 bus->commandStream.emplace_back(command);
680
681 command.name = "ScanCargoBay";
682 command.ivalues[0] = bus->CargoBays[selected.value]; // vehicle ID
683 bus->commandStream.emplace_back(command);
684 return true;
685 }
686 }
687 else if (selected.type == "Baggage")
688 {
689 Command command;
690 command.name = "SwapInventoryItem";
691 command.ivalues[0] = selected.value; // inventoryId
692 command.ivalues[1] = 0; // personal2vehicle
693 command.bValue = true; // was inVehicle
694 bus->commandStream.emplace_back(command);
695 return true;
696 }
697 else if (selected.type == "Cabin")
698 {
699 Command command;
700 command.name = "SwapInventoryItem";
701 command.ivalues[0] = selected.value; // inventoryId
702 command.ivalues[1] = 1; // vehicle2personal
703 command.bValue = false; // was onPerson
704 bus->commandStream.emplace_back(command);
705 return true;
706 }
707 break;
708 case 33: // f
709 if (selected.type == "Bay")
710 {
711 if (bus->CargoBays[selected.value] != 0)
712 {
713 temptarget = bus->CargoBays[selected.value]; // vehicle ID
714 g_bTextInput = 6;
715 outgoing[0] = 0; // clear buffer
716 sprintf_s(prompt, sizeof(prompt), "[±kg]");
717 return true;
718 }
719 }
720 break;
721 case 36: // j for jettison
722 if (selected.type == "Fuel")
723 {
724 g_bTextInput = 8;
725 outgoing[0] = 0; // clear buffer
726 sprintf_s(prompt, sizeof(prompt), "[-kg]");
727 return true;
728 }
729 break;
730 case 20: // t
731 if (selected.type == "Baggage")
732 {
733 Command command;
734 command.name = "TransferInventoryItem";
735 command.ivalues[0] = selected.value; // inventoryItemType
736 command.ivalues[1] = 0; // personal inventory
737 command.bValue = true; // onPerson
738 bus->commandStream.emplace_back(command);
739 return true;
740 }
741 if (selected.type == "Cabin")
742 {
743 Command command;
744 command.name = "TransferInventoryItem";
745 command.ivalues[0] = selected.value; // inventoryItemType
746 command.ivalues[1] = 1; // personal inventory
747 command.bValue = false; // onPerson
748 bus->commandStream.emplace_back(command);
749 return true;
750 }
751 }
752 return false;
753}
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
#define MAX_AVIOPERSHIP
@ 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
#define MAX_WEAPPERSHIP
@ Residential
@ Airfield
@ WeaponLongarms
@ PaxEnum
@ CargoFab
@ CargoCommon
@ Mining
@ Colonists
@ Passengers
@ Township
@ Farmstead
@ None
Definition ServerTypes.h:97
@ CargoRare
Definition ServerTypes.h:98
@ CargoGoods
@ Refinery
@ Prisoners
@ CargoFuelOre
@ CargoFood
Definition ServerTypes.h:99
@ CargoEnum
@ NexRad
@ Fireworks
@ LockPick
@ FirstAid
@ E11Upgrade
@ Binoculars
@ TemporaryRunwayLights
@ Polaroid
@ EVA_KIT
@ NightVision
@ ColonyUpLink
@ RVR
@ ATM
@ Sunglasses
@ Backpack
@ CartonOfCigarettes
@ ILS
@ CandyCane
@ REF_DOCKTAC
Definition ServerTypes.h:54
@ REF_DOCKENUMCPOC
Definition ServerTypes.h:53
Definition Bus.h:20
scanDb Scanner
Definition Bus.h:484
short station
Definition Bus.h:506
unsigned short CargoBays[MAX_BAYSPERSHIP]
Definition Bus.h:465
std::vector< Command > commandStream
Definition Bus.h:442
void Render() override
CargoManagement(int prmX, int prmY, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts, int height)
bool HandleKeyPress(short key, bool shift) override
CargoManifestList manifest
Definition Instrument.h:117
void Add(const wchar_t *text, std::uint32_t color, const std::string &type="", int value=0)
int ScreenRow(int row) const
std::vector< Row > rows
static constexpr int LineHeight
bool HandleNavigationKey(short key, bool shift, unsigned int keyboardDelay=1, unsigned int keyboardSpeed=31)
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
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
bool is_set() const
Definition Nullable.h:87
T get() const
Definition Nullable.h:80
Sscan Get(USHORT vehicleId) const
Definition scanDb.cpp:111
float weapontimer[2]
Definition globals.cpp:89
float fuel
Definition globals.cpp:90
char prompt[80]
Definition globals.cpp:62
s_network_objects playerships[MAX_SCAN]
Definition globals.cpp:112
unsigned short temptarget
Definition globals.cpp:72
float cash
Definition globals.cpp:93
Scockpit ourcockpit
Definition globals.cpp:114
char g_bTextInput
Definition globals.cpp:61
char outgoing[80]
Definition globals.cpp:60
#define weaponlongarmreadyC
Definition globals.h:79
#define weaponfuzerreadyC
Definition globals.h:77
#define weaponsinkerreadyC
Definition globals.h:78
#define Kg2Lbs
Definition globals.h:40
constexpr PackedColor ColorARGB(unsigned a, unsigned r, unsigned g, unsigned b)
std::string sValue
Definition Command.h:20
bool bValue
Definition Command.h:22
int ivalues[2]
Definition Command.h:21
std::string name
Definition Command.h:11
char weapontype[MAX_WEAPPERSHIP]
char avionictype[MAX_AVIOPERSHIP]
char weaponreload
bool remoteAssayPower
Definition globals.h:597
float maxGrossLbs
Definition globals.h:634
short texturelib
Definition globals.h:602
unsigned char stowageLoadType
Definition globals.h:695
char owner[13]
Definition globals.h:691
std::vector< InventoryHelper > vehicleInventory
Definition globals.h:698
unsigned char stowageDestination
Definition globals.h:695
char character[30]
Definition globals.h:689
float fuelmax
Definition globals.h:647
float emptyWeightLbs
Definition globals.h:633
std::vector< InventoryHelper > personalInventory
Definition globals.h:697
SVesselDC vdat
Definition globals.h:664
char handle[13]
Definition globals.h:690
unsigned char playerWeightKg
Definition globals.h:688
bool radioPower
Definition globals.h:597
unsigned char stowageQuantity
Definition globals.h:695
char bays
Definition globals.h:630
bool weatherRadarPower
Definition globals.h:597
unsigned char type
Definition scanDb.h:17
char IVR[6]
Definition scanDb.h:16
char load_dest[20]
Definition scanDb.h:33
Nullable< int > pilot
Definition scanDb.h:36
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
Sscandata scandata
Definition scanDb.h:49
SmodeAC modeAC
Definition scanDb.h:41
SmodeX modeX
Definition scanDb.h:43