Rise
The Vieneo Province
WaypointDialog.cpp
Go to the documentation of this file.
1 #include "WaypointDialog.h"
2 
3 #include <clocale>
4 
5 #include "../MathUtilities.h"
6 #include "InformationDialog.h"
7 
9 {
10  logger->AddToCallStack("WaypointDialog::ctor");
11  active = false;
12  windowdefaultlocation = D3DXVECTOR3(128, 828, 0);
13  defaultwidth = 764;
14  defaultheight = 5 * 16;
15  tabs = 1;
17 
18  actions = 11;
30  actionenabled[0] = false;
31  actionenabled[1] = true;
32  actionenabled[2] = true;
33  actionenabled[3] = true;
34  actionenabled[4] = true;
35  actionenabled[5] = true;
36  actionenabled[6] = true;
37  actionenabled[7] = true;
38  actionenabled[8] = true;
39  actionenabled[9] = true;
40  actionenabled[10] = true;
41 
42  showfields = true;
43  fields = 5;
44  fieldtype[0] = FIELD_ICON; // icon
45  fieldwidth[0] = 25; // pixels
46 // fieldcontent[0]=1; // unused
47  fieldtype[1] = FIELD_VARTEXT; // variable width text
48  fieldwidth[1] = gui->FONT_WIDTH * 31; // 32-null
50  sortfield = 1; // description
51  sortdirection = 1; // ascending?
52  fieldtype[2] = FIELD_VARTEXT; // variable width text
53  fieldwidth[2] = gui->FONT_WIDTH * 18; // n 00.000 w 000.000
55  fieldsortable[2] = false;
56  fieldtype[3] = FIELD_VARTEXT; // variable width text
57  fieldwidth[3] = gui->FONT_WIDTH * 10; // 999.999 km
59  fieldtype[4] = FIELD_ICON; // icon
60  fieldwidth[4] = 25; // pixels
61 
62  usesHUD = true;
63  HUD.Init(&gui->g_DialogResourceManager, true, L"Textures\\GUI\\dxutcontrols.png");
64  HUD.SetCallback(&WaypointDialog::DialogCallback, this);
65  HUD.SetFont(0, L"DejaVu Sans Mono", 12, FW_NORMAL);
66  HUD.AddEditBox(IDC_FIELDEDIT, L"", 1, 1, 1, 1, false);
67  HUD.GetEditBox(IDC_FIELDEDIT)->SetVisible(false);
68 
69  icon = 7;
71 
72  //linedsp is calculated from height
73  //linetot is equal to waypoints->WPtargetS
74 
76  ptrBus = gui->game->bus;
78  linetop = 0;
79  lineact = 0;
80 }
81 
82 void CALLBACK WaypointDialog::DialogCallback(UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext)
83 {
84  WaypointDialog* wpd = static_cast<WaypointDialog*>(pUserContext);
85  logger->AddToCallStack("WaypointDialog::DialogCallback");
86 
87  // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
88  switch (nControlID)
89  {
90  case IDC_FIELDEDIT: // when I submit the waypoint
91  {
92  if (nEvent == EVENT_EDITBOX_STRING)
93  {
94  long field = wpd->editfield;
95  if (wpd->linecursel < 0 || wpd->linecursel >= static_cast<long>(wpd->ptrBus->waypoint.size()))
96  {
97  char msg[199];
98  sprintf_s(msg, 199, "Editing waypoint that doesn't exist in collection: %i (%i) %i", wpd->linecursel, wpd->ptrBus->waypoint.size(), field);
99  logger->Log(msg, Logger::Level::Error);
100  if (wpd->HUD.GetEditBox(IDC_FIELDEDIT)->GetVisible())
101  logger->Log("IDC_FIELDEDIT was visible!", Logger::Level::Debug);
102  else
103  logger->Log("IDC_FIELDEDIT was NOT visible!", Logger::Level::Debug);
104  wpd->linecursel = 0;
105  field = 0;
106  }
107 
108  if (field == 1) // description
109  {
110  sprintf_s(wpd->ptrBus->waypoint.at(wpd->linecursel).text, 80, "%S", dynamic_cast<CDXUTEditBox*>(pControl)->GetText());
111  if (wpd->linecursel == 0) // temporary
112  {
113  wpd->ptrWaypoints->Upload(wpd->ptrBus->waypoint.at(0));
114  wpd->ptrWaypoints->Delete(0);
115  }
116  else
117  {
118  wpd->ptrWaypoints->Upload(wpd->ptrBus->waypoint.at(wpd->linecursel));
119  }
120  }
121  else if (field == 2) // latlng
122  {
123  char ns[3], ew[4];
124  float nsdeg, ewdeg;
125  char input[99];
126  sprintf_s(input, 99, "%S", dynamic_cast<CDXUTEditBox*>(pControl)->GetText());
127  int count = sscanf_s(input, "%[NnSs ]%f%[EeWw ]%f", ns, 3, &nsdeg, ew, 4, &ewdeg);
128  if (count == 4)
129  {
130  float lattemp = D3DXToRadian(nsdeg);
131  float lngtemp = D3DXToRadian(ewdeg);
132  bool letfailed = true;
133  if (ns[0] == 'N' || ns[0] == 'n')
134  {
135  letfailed = false;
136  }
137  else if (ns[0] == 'S' || ns[0] == 's')
138  {
139  lattemp = -lattemp;
140  letfailed = false;
141  }
142 
143  if (ew[0] == ' ')
144  ew[0] = ew[1];
145  if (ew[0] == 'E' || ew[0] == 'e')
146  {
147  letfailed = false;
148  }
149  else if (ew[0] == 'W' || ew[0] == 'w')
150  {
151  lngtemp = -lngtemp;
152  letfailed = false;
153  }
154  if (fabsf(nsdeg) > 90.0f || fabsf(ewdeg) > 180.0f)
155  letfailed = true;
156 
157  if (!letfailed)
158  {
159  D3DXVECTOR3 result;
160  result.y = cosf(-lngtemp)*cosf(lattemp);
161  result.x = sinf(-lngtemp)*cosf(lattemp);
162  result.z = sinf(lattemp);
163  D3DXVec3Normalize(&result, &result);
164  D3DXVec3Scale(&result, &result, -radiusC);
165 
166  wpd->ptrBus->waypoint.at(wpd->linecursel).location = result;
167  wpd->ptrBus->waypoint.at(wpd->linecursel).latlng.x = nsdeg;
168  wpd->ptrBus->waypoint.at(wpd->linecursel).latlng.y = ewdeg;
169  wpd->ptrBus->waypoint.at(wpd->linecursel).source = 5; // keyed lat long
170  wpd->ptrBus->waypoint.at(wpd->linecursel).protectionLevel = 5; // private
171  }
172  }
173  else
174  {
175  int tcpu, tcpv;
176  int index = 0;
177  if (strlen(input) > 3 && (input[2] == 'n' || input[2] == 'N')) index = 3;
178  if (strlen(input) > 4 && input[3] == ' ') index = 4;
179  count = sscanf_s(&input[index], "%4d%4d", &tcpu, &tcpv);
180  if (count == 2)
181  {
182  D3DXVECTOR3 planar = wpd->ptrViewscreen->CalculatePlanar(tcpu - 3038, tcpv - 2038);
183  const D3DXVECTOR2 latLng = CalculateLatLng(planar);
184  D3DXVec3Scale(&planar, &planar, radiusC);
185 
186  wpd->ptrBus->waypoint.at(wpd->linecursel).location = planar;
187  wpd->ptrBus->waypoint.at(wpd->linecursel).latlng.x = latLng.x;
188  wpd->ptrBus->waypoint.at(wpd->linecursel).latlng.y = latLng.y;
189  wpd->ptrBus->waypoint.at(wpd->linecursel).source = 6; // keyed APN
190  }
191  }
192  }
193 
194  wpd->ClearEdit();
196  wpd->UpdateMenu(-1);
197  }
198  else if (nEvent == EVENT_EDITBOX_CANCEL)
199  {
200  wpd->ClearEdit();
201  }
202  }
203  break;
204  }
205 }
206 
208 {
209  logger->AddToCallStack("WaypointDialog::UpdateMenu");
210 
211  if (!active)
212  return;
213 
214 //#ifdef _DEBUG
215 // swprintf_s(msgbartext, sizeof msgbartext, L"DirectTo %.3f", ptrBus->DebugFloat8);
216 //#endif
217 
218  const long oldlinecursel = linecursel;
220  if (oldlinecursel != linecursel &&
221  linecursel != -1 && (linecursel<linetop || linecursel>(linetop + linedsp)))
222  linetop = linecursel - linedsp; // center it
223 
224  linetot = ptrBus->waypoint.size();
225 
226  // 17-4<(18-1) = 13<17 (17-(18-1)=0
227  if ((linetot - linetop) < linedsp) // 8-3 is 5 OK, 8-4 is 4 NO, needs to be 5
228  linetop = static_cast<short>(linetot) - linedsp;
229  if (linetop < 0)
230  linetop = 0;
231 
232  if (editline != -1 && (editline >= (linedsp + linetop) || editline < linetop))
233  ClearEdit();
234 
235  if (linecursel > -1) // has one selected
236  {
237  if (lineact == linecursel)
238  {
239  actiontoggle[0] = true; // depressed activate button
240  actionenabled[0] = false; // disabled activate button
241  }
242  else
243  {
244  actiontoggle[0] = false;
245  actionenabled[0] = true; // enable activate button
246  }
247 
249  if (playerships[0].reference == REF_ONGROUND && linecursel == 0)
250  actionenabled[1] = true; // mark
251  else
252  actionenabled[1] = false;
253 
254  // delete
255  actionenabled[2] = linecursel > 0; // not the temporary waypoint
256 
257  if (linecursel == 0) // temporary waypoint
258  {
259  for (auto i = 5; i < 11; i++)
260  {
261  actiontoggle[i] = false;
262  actionenabled[i] = false;
263  }
264  }
265  else // all other waypoints
266  {
267  for (auto i = 5; i < 11; i++)
268  {
269  const unsigned char actionLevel = i - 5; // 0-5
270  const unsigned char waypointLevel = ptrBus->waypoint.at(linecursel).protectionLevel;
271  const unsigned char type = ptrBus->waypoint.at(linecursel).type;
272  actiontoggle[i] = (actionLevel == waypointLevel);
273 
274  // only allow one down from current but any above but not current ... don't let them share airborne fixes or FAF since they buy those
275  actionenabled[i] = (actionLevel >= waypointLevel - 1) && actionLevel != waypointLevel && type == 0;
276  }
277 
278  if (ptrBus->waypoint.at(linecursel).uniqueid == 451) // Deois Zana Zoom (Taxi Fares)
279  {
282  else if (lineact == linecursel)
283  {
285  {
288  }
289  }
290  }
291  else if (ptrBus->waypoint.at(linecursel).uniqueid == 716) // Deois Airport Taxi Stand
293  }
294  }
295  else
296  {
297  actionenabled[0] = false; // activate
298  actiontoggle[0] = false;
299  actionenabled[1] = false; // mark
300  actionenabled[2] = false; // delete
301 
302  for (int i = 5; i < 11; i++)
303  {
304  actiontoggle[i] = false;
305  actionenabled[i] = false;
306  }
307  }
308 
309  // actionenabled[4]=playerships[0].simulator;
310 
311  if (linetot == 0 && tab != 0) // must not be first folder and must be empty
312  actionenabled[3] = true; // remove folder
313  else
314  actionenabled[3] = false;
315 
316  actionenabled[4] = false;
317 
318  for (long t = 0; t < linedsp; t++)
319  {
320  if ((linetop + t) >= linetot)
321  {
322  fieldline[t][0][0] = 0;
323  wcscpy_s(fieldline[t][1], HELP_SIZE, L"");
324  wcscpy_s(fieldline[t][2], HELP_SIZE, L"");
325  wcscpy_s(fieldline[t][3], HELP_SIZE, L"");
326  wcscpy_s(fieldline[t][4], HELP_SIZE, L"");
327  }
328  else
329  {
330  if ((linetop + t) < 0 || (linetop + t) >= static_cast<long>(ptrBus->waypoint.size()))
331  throw std::exception("Trying to update menu with a waypoint that doesn't exist in collection!");
332  if ((linetop + t) == 0) // temporary waypoint
333  {
334  if (ptrBus->waypoint.at(linetop + t).location.x != 0.0f)
335  swprintf_s(fieldline[t][1], HELP_SIZE, L"Unsaved waypoint, click here to rename and save!");
336  else
337  swprintf_s(fieldline[t][1], HELP_SIZE, L"Unused slot for temporary waypoints...");
338  }
339  else
340  {
341  swprintf_s(fieldline[t][1], HELP_SIZE, L"%S", ptrBus->waypoint.at(linetop + t).text);
342  fieldline[t][1][34] = 0; // truncate
343  }
344 
345  switch (ptrBus->waypoint.at(linetop + t).type)
346  {
347  case 1: // IAF
348  fieldline[t][0][0] = 13;
349  break;
350  case 2: // TDZ
351  fieldline[t][0][0] = 20;
352  break;
353  case 3: // Fix
354  fieldline[t][0][0] = 15;
355  break;
356  default: // standard waypoint
357  fieldline[t][0][0] = 0;
358  break;
359  }
360 
361 
362  // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
363  switch (ptrBus->waypoint.at(linetop + t).source)
364  {
365  case 0: fieldline[t][4][0] = 12; break; // unknown
366  case 1: fieldline[t][4][0] = 1; break; // marked
367  case 2: fieldline[t][4][0] = 2; break; // keyed
368  case 3: fieldline[t][4][0] = 19; break; // received/shared
369  case 4: fieldline[t][4][0] = 11; break; // purchased
370  case 5: fieldline[t][4][0] = 2; break; // keyed
371  case 6: fieldline[t][4][0] = 2; break; // keyed
372  }
373 
374  if (ptrBus->waypoint.at(linetop + t).location.x != 0.0f)
375  {
376  D3DXVECTOR3 result = ptrBus->waypoint.at(linetop + t).location;
377  const float f_temp = GetArcDist(playerships[0].position, result, true);
378  result = -result;
379 
380  float tlng = 0.0f;
381  const float tlat = -D3DXToDegree(atanf(result.z / sqrtf(result.x*result.x + result.y*result.y)));
382 
383  if (result.x <= 0 && result.y > 0)
384  tlng = -D3DXToDegree(atanf(result.x / result.y)); // PM to EP
385  else if (result.x < 0 && result.y <= 0)
386  tlng = D3DXToDegree(atanf(result.y / result.x)) + 90.0f; // EP to IDL
387  else if (result.x >= 0 && result.y < 0)
388  tlng = -D3DXToDegree(atanf(result.x / result.y)) - 180.0f; // IDL to WP
389  else if (result.x > 0 && result.y >= 0) // west?
390  tlng = D3DXToDegree(atanf(result.y / result.x)) - 90.0f; // WP to PM
391  WCHAR northsouth, eastwest;
392  if (tlat < 0.0f)
393  northsouth = gui->strings[L_LIST_NORTH].c_str()[0];
394  else
395  northsouth = gui->strings[L_LIST_SOUTH].c_str()[0];
396  if (tlng < 0.0f)
397  eastwest = gui->strings[L_LIST_WEST].c_str()[0];
398  else
399  eastwest = gui->strings[L_LIST_EAST].c_str()[0];
400 
401  swprintf_s(fieldline[t][2], HELP_SIZE, L"%c %06.3f %c %07.3f", northsouth, fabsf(tlat), eastwest, fabsf(tlng));
402  if (f_temp > 10000.0f)
403  swprintf_s(fieldline[t][3], HELP_SIZE, L"%.3f k%s", f_temp*0.001f, gui->strings[L_LIST_KM].c_str());
404  else
405  swprintf_s(fieldline[t][3], HELP_SIZE, L"%.3f %s", f_temp, gui->strings[L_LIST_KM].c_str());
406  }
407  else
408  {
409  wcscpy_s(fieldline[t][2], HELP_SIZE, gui->strings[L_LIST_UNUSED].c_str());
410  wcscpy_s(fieldline[t][3], HELP_SIZE, gui->strings[L_LIST_UNUSED].c_str());
411  }
412  }
413  }
414 
416 }
417 
419 {
420  logger->AddToCallStack("WaypointDialog::ActionIconClick L_ACTION_ACTIVATE");
421 
422  if (linecursel < 0 || linecursel >= static_cast<long>(ptrBus->waypoint.size()))
423  {
424  char msg[99];
425  sprintf_s(msg, 99, "Found the problem going to set WPtargetC (%i) and lineact (%i) to linecursel (%i) actionenabled %i",
427  logger->Log(msg, Logger::Level::Error);
430  return;
431  }
432 
433  if (ptrBus->WPtargetC >= 0 && ptrBus->WPtargetC < static_cast<long>(ptrBus->waypoint.size()))
435 
437  if (ptrBus->WPtargetC < 0 || ptrBus->WPtargetC >= static_cast<long>(ptrBus->waypoint.size()))
438  {
439  char msg[99];
440  sprintf_s(msg, 99, "Found the problem WPtargetC %i because of lineact and linecursel!", ptrBus->WPtargetC);
441  logger->Log(msg, Logger::Level::Error);
443  ptrBus->WPtargetC = 0;
444  }
445 
446  float waypointId = 0.0f;
447  if (ptrBus->WPtargetC >= 0 && ptrBus->WPtargetC < static_cast<long>(ptrBus->waypoint.size()))
448  waypointId = static_cast<float>(ptrBus->waypoint.at(ptrBus->WPtargetC).id);
449 
450  SClientPacket outpacket;
451  outpacket.type = 37; // Waypoint management
452  outpacket.f_x = 0.0f; // set
453  outpacket.f_y = waypointId;
454  outpacket.f_z = 0.0f;
455  outpacket.f_w = 0.0f;
456  gui->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
457 
458  UpdateMenu(-1);
459 
462 
463  ptrBus->nodes.clear();
464  ptrBus->turnByTurnDirty = true;
465 }
466 
468 {
469  logger->AddToCallStack("WaypointDialog::ActionIconClick");
470 
471  if (actionenabled[icon_id])
472  {
473  if (action[icon_id] == (L_ACTION_MARK - L_ACTION_MARK))
474  {
475  logger->AddToCallStack("WaypointDialog::ActionIconClick L_ACTION_MARK");
476 
477  if (linecursel < 0 || linecursel >= static_cast<long>(ptrBus->waypoint.size()))
478  throw std::exception("Trying to ActionIconClick a waypoint that doesn't exist in collection!");
479 
480  ptrBus->waypoint.at(linecursel).heading = -1; // directionless
481  ptrBus->waypoint.at(linecursel).location = playerships[0].position;
482  ptrBus->waypoint.at(linecursel).orientation = playerships[0].orientation;
483  ptrBus->waypoint.at(linecursel).type = 0; // waypoint
484  ptrBus->waypoint.at(linecursel).velocity = playerships[0].velocity;
485  ptrBus->waypoint.at(linecursel).source = 1; // marked
486  ptrBus->waypoint.at(linecursel).reference = playerships[0].reference;
487  ptrBus->waypoint.at(linecursel).protectionLevel = 5; // private
488  UpdateMenu(-1);
489  }
490  else if (action[icon_id] == (L_ACTION_ACTIVATE - L_ACTION_MARK))
491  {
493  }
494  else if (action[icon_id] == (L_ACTION_DELETE - L_ACTION_MARK))
495  {
496  logger->AddToCallStack("WaypointDialog::ActionIconClick L_ACTION_DELETE");
497 
499  linecursel -= 1;
500  UpdateMenu(-1);
501  }
502  else if (action[icon_id] == (L_ACTION_WP_PUBLIC - L_ACTION_MARK))
503  {
504  logger->AddToCallStack("WaypointDialog::ActionIconClick L_ACTION_WP_PUBLIC");
505 
506  ptrBus->waypoint.at(linecursel).protectionLevel = 0;
507  SClientPacket outpacket;
508  outpacket.type = 37; // Waypoint management
509  outpacket.f_x = 3.0f; // protection
510  outpacket.f_y = static_cast<float>(ptrBus->waypoint.at(linecursel).id);
511  outpacket.f_z = 0.0f; // public
512  outpacket.f_w = 0.0f;
513  gui->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
514  UpdateMenu(-1);
515  }
516  else if (action[icon_id] == (L_ACTION_WP_NOENEMIES - L_ACTION_MARK))
517  {
518  logger->AddToCallStack("WaypointDialog::ActionIconClick L_ACTION_WP_NOENEMIES");
519 
520  ptrBus->waypoint.at(linecursel).protectionLevel = 1;
521  SClientPacket outpacket;
522  outpacket.type = 37; // Waypoint management
523  outpacket.f_x = 3.0f; // protection
524  outpacket.f_y = static_cast<float>(ptrBus->waypoint.at(linecursel).id);
525  outpacket.f_z = 1.0f; // no enemies
526  outpacket.f_w = 0.0f;
527  gui->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
528  UpdateMenu(-1);
529  }
530  else if (action[icon_id] == (L_ACTION_WP_ALLIES - L_ACTION_MARK))
531  {
532  logger->AddToCallStack("WaypointDialog::ActionIconClick L_ACTION_WP_ALLIES");
533 
534  ptrBus->waypoint.at(linecursel).protectionLevel = 2;
535  SClientPacket outpacket;
536  outpacket.type = 37; // Waypoint management
537  outpacket.f_x = 3.0f; // protection
538  outpacket.f_y = static_cast<float>(ptrBus->waypoint.at(linecursel).id);
539  outpacket.f_z = 2.0f; // allies
540  outpacket.f_w = 0.0f;
541  gui->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
542  UpdateMenu(-1);
543  }
544  else if (action[icon_id] == (L_ACTION_WP_ALLIANCE - L_ACTION_MARK))
545  {
546  logger->AddToCallStack("WaypointDialog::ActionIconClick L_ACTION_WP_ALLIANCE");
547 
548  ptrBus->waypoint.at(linecursel).protectionLevel = 3;
549  SClientPacket outpacket;
550  outpacket.type = 37; // Waypoint management
551  outpacket.f_x = 3.0f; // protection
552  outpacket.f_y = static_cast<float>(ptrBus->waypoint.at(linecursel).id);
553  outpacket.f_z = 3.0f; // alliance
554  outpacket.f_w = 0.0f;
555  gui->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
556  UpdateMenu(-1);
557  }
558  else if (action[icon_id] == (L_ACTION_WP_PARTNERS - L_ACTION_MARK))
559  {
560  logger->AddToCallStack("WaypointDialog::ActionIconClick L_ACTION_WP_PARTNERS");
561 
562  ptrBus->waypoint.at(linecursel).protectionLevel = 4;
563  SClientPacket outpacket;
564  outpacket.type = 37; // Waypoint management
565  outpacket.f_x = 3.0f; // protection
566  outpacket.f_y = static_cast<float>(ptrBus->waypoint.at(linecursel).id);
567  outpacket.f_z = 4.0f; // partners
568  outpacket.f_w = 0.0f;
569  gui->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
570  UpdateMenu(-1);
571  }
572  else if (action[icon_id] == (L_ACTION_WP_PRIVATE - L_ACTION_MARK))
573  {
574  logger->AddToCallStack("WaypointDialog::ActionIconClick L_ACTION_WP_PRIVATE");
575 
576  ptrBus->waypoint.at(linecursel).protectionLevel = 5;
577  SClientPacket outpacket;
578  outpacket.type = 37; // Waypoint management
579  outpacket.f_x = 3.0f; // protection
580  outpacket.f_y = static_cast<float>(ptrBus->waypoint.at(linecursel).id);
581  outpacket.f_z = 5.0f; // private
582  outpacket.f_w = 0.0f;
583  gui->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
584  UpdateMenu(-1);
585  }
586  }
587 }
588 
590 {
591  if (actionenabled[0])
593 }
594 
595 void WaypointDialog::Draw(D3DXVECTOR3* tracked)
596 {
597 }
598 
600 {
601  logger->AddToCallStack("WaypointDialog::ClearEdit");
602 
603  if (editline != -1)
604  {
605  HUD.GetEditBox(IDC_FIELDEDIT)->SetVisible(false);
606  editline = editfield = -1;
607  gui->Editing = false;
608  }
609 }
610 
611 void WaypointDialog::DragDropItem(short destTab)
612 {
613  char msg[199];
614  sprintf_s(msg, 199, "WaypointDialog::DragDropItem(%i): %i", destTab, gui->dragt);
615  logger->AddToCallStack(msg);
616 
617  if (gui->dragt == D_COMMUNICATIONS) // from communications
618  {
620  {
621  sprintf_s(msg, 199, "Ha! This is where we were crapping out on dragline: %i", gui->dragline);
622  logger->Log(msg, Logger::Level::Error);
623  return;
624  }
625 
626  const wchar_t* c_str = gui->chatchannel[dialogs[D_COMMUNICATIONS]->activetab].chatline.at(gui->dragline).c_str();
627  // tokenized waypoint reception
628  if (wcsncmp(c_str, L"TC_WAYPOINT,", 12) != 0) return;
629 
630  // deserialize
631  WCHAR waypointName[80];
632  int uniqueId;
633  float locationx, locationy, locationz;
634  setlocale(LC_ALL, "English");
635  swscanf_s(c_str, L"TC_WAYPOINT,%d,%f,%f,%f,%[^\n]", &uniqueId, &locationx, &locationy, &locationz, waypointName, 80);
636  gui->SetLocale();
637  Swaypoint tempwaypoint;
638  tempwaypoint.uniqueid = uniqueId;
639  tempwaypoint.location = D3DXVECTOR3(locationx, locationy, locationz);
640  sprintf_s(tempwaypoint.text, sizeof tempwaypoint.text, "%S", waypointName);
641  tempwaypoint.source = 3; // received
642  tempwaypoint.reference = -2; // all ground based
643  tempwaypoint.group = static_cast<unsigned char>(destTab);
644  tempwaypoint.protectionLevel = 5; // private
645  tempwaypoint.type = 0; // user waypoint
646  tempwaypoint.id = 0; // add
647  tempwaypoint.heading = -1;
648  tempwaypoint.latlng = D3DXVECTOR2(0, 0); // computed
649  tempwaypoint.length = 0; // unused
650  D3DXQuaternionIdentity(&tempwaypoint.orientation); // zero
651  tempwaypoint.pairedwith = 0; // none
652  tempwaypoint.velocity = centerC; // zero
653 
654  gui->game->viewscreen->ptrWaypoints->Upload(tempwaypoint);
655 
657  }
658 }
659 
661 {
662  logger->AddToCallStack("WaypointDialog::Update");
663 
664  if (gui->g_bLeftClick && editline != -1)
665  {
666  if (!HUD.GetEditBox(IDC_FIELDEDIT)->m_bHasFocus)
667  ClearEdit();
668  }
669 }
#define radiusC
Definition: globals.h:88
short FONT_WIDTH
Definition: gui.h:713
bool DismissHelp(int helpId, int nControlID=GUI_UNDERSTOOD)
void DoubleClickLine() override
Networking * networking
Definition: gui.h:855
short actions
Definition: DialogBase.h:49
long editfield
Definition: DialogBase.h:79
D3DXVECTOR3 position
Definition: globals.h:549
float GetArcDist(D3DXVECTOR3 from, D3DXVECTOR3 to, bool includeAltDiff)
Definition: MathUtilities.h:37
D3DXQUATERNION orientation
Definition: globals.h:558
void SendToServer(void *pData, DWORD dwSize, bool bGuaranteed, PacketOrdering order=ORDERING_NONE) const
Definition: Networking.cpp:59
short linedsp
Definition: DialogBase.h:72
std::vector< std::wstring > chatline
Definition: chat.h:47
GameClass * game
Definition: gui.h:857
D3DXVECTOR2 CalculateLatLng(D3DXVECTOR3 position)
Definition: MathUtilities.h:17
void Draw(D3DXVECTOR3 *tracked) override
InformationDialog * informationDialog
Definition: gui.h:789
void SetLocale() const
Definition: gui.cpp:1449
s_network_objects playerships[MAX_SCAN]
Definition: globals.cpp:174
waypoints * ptrWaypoints
Definition: Viewscreen.h:290
bool actionenabled[MAX_ACTION]
Definition: DialogBase.h:77
short fieldcontent[MAX_FIELDS]
Definition: DialogBase.h:48
short dialogid
Definition: DialogBase.h:101
void Upload(Swaypoint swaypoint) const
Definition: waypoints.cpp:186
short tabs
Definition: DialogBase.h:62
void DragDropItem(short destTab) override
bool usesHUD
Definition: DialogBase.h:56
WaypointDialog(short id)
void SendEvent(EventType eventType, float extent=0.0f) const
Definition: Networking.cpp:111
short dragt
Definition: gui.h:716
short defaultwidth
Definition: DialogBase.h:51
int linecursel
Definition: DialogBase.h:73
bool showfields
Definition: DialogBase.h:45
waypoints * ptrWaypoints
short activetab
Definition: DialogBase.h:62
CDXUTDialogResourceManager g_DialogResourceManager
Definition: gui.h:752
WCHAR fieldline[MAX_LINES][MAX_FIELDS][HELP_SIZE]
Definition: DialogBase.h:94
short text
Definition: DialogBase.h:69
char sortdirection
Definition: DialogBase.h:65
static DialogBase * dialogs[D_ENUMERATION]
Definition: DialogBase.h:39
short fieldwidth[MAX_FIELDS]
Definition: DialogBase.h:46
bool actiontoggle[MAX_ACTION]
Definition: DialogBase.h:77
Viewscreen * viewscreen
Definition: GameClass.h:111
Networking * networking
Definition: GameClass.h:107
bool PopUpHelp(short helpId, bool allowDismiss=true, bool isLearnMore=false)
short tabusedefaultlang[MAX_TAB]
Definition: DialogBase.h:50
bool g_bLeftClick
Definition: gui.h:714
static Logger * logger
Definition: DialogBase.h:41
short defaultheight
Definition: DialogBase.h:51
Definition: gui.h:84
int lineact
Definition: DialogBase.h:73
bool Editing
Definition: gui.h:778
D3DXVECTOR3 CalculatePlanar(short u, short v)
long dragline
Definition: gui.h:717
static short CheckWidth(short dialogid)
int linetop
Definition: DialogBase.h:73
void Sort(short sortfield, char sortdirection, int *linecursel, int *lineact) const
Definition: waypoints.cpp:25
short action[MAX_ACTION]
Definition: DialogBase.h:49
Definition: gui.h:34
bool fieldsortable[MAX_FIELDS]
Definition: DialogBase.h:96
void ClearEdit() override
const D3DXVECTOR3 centerC
D3DXVECTOR3 velocity
Definition: globals.h:540
Sound * sound
Definition: gui.h:856
CHATCHANNEL chatchannel[MAX_TAB]
Definition: gui.h:768
bool active
Definition: DialogBase.h:71
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition: Logger.cpp:11
CDXUTDialog HUD
Definition: DialogBase.h:98
short icon
Definition: DialogBase.h:53
void ActionIconClick(long icon_id) override
bool turnByTurnDirty
Definition: Bus.h:398
void UpdateMenu(short tab) override
static HMI * gui
Definition: DialogBase.h:40
long editline
Definition: DialogBase.h:79
short sortfield
Definition: DialogBase.h:64
float Play(int soundEnum)
Definition: Sound.cpp:577
std::vector< Snode > nodes
Definition: Bus.h:397
#define HELP_SIZE
Definition: gui.h:17
static void CALLBACK DialogCallback(UINT nEvent, int nControlID, CDXUTControl *pControl, void *pUserContext)
std::vector< Swaypoint > waypoint
Definition: Bus.h:391
D3DXVECTOR3 windowdefaultlocation
Definition: DialogBase.h:52
Viewscreen * ptrViewscreen
std::wstring strings[L_ENUMERATION]
Definition: gui.h:749
int WPtargetC
Definition: Bus.h:390
void AddToCallStack(const char *msg)
Definition: Logger.cpp:86
Bus * bus
Definition: GameClass.h:112
void Delete(int index) const
Definition: waypoints.cpp:100
int linetot
Definition: DialogBase.h:73
short fieldtype[MAX_FIELDS]
Definition: DialogBase.h:47
D3DXVECTOR3 lastWaypointLocation
Definition: Bus.h:392
short fields
Definition: DialogBase.h:44
void Update() override