Debian Codegraph @

editor/PathPadDialog.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 // PathPadDialog.cpp : implementation file
20 //
21
22 #include "stdafx.h"
23 #include "editor.h"
24 #include "PathPadDialog.h"
25 #include "EditLineDialog.h"
26 #include "epath.h"
27 #include "object.h"
28 #include "room.h"
29 #include "FindIntersection.h"
30 #include "ebnode.h"
31 #include "boa.h"
32 #include "object.h"
33
34 #ifdef _DEBUG
35 #define new DEBUG_NEW
36 #undef THIS_FILE
37 static char THIS_FILE[] = __FILE__;
38 #endif
39
40 /////////////////////////////////////////////////////////////////////////////
41 // CPathPadDialog dialog
42
43 CPathPadDialog::CPathPadDialog(CWnd *pParent /*=NULL*/) : CKeypadDialog(CPathPadDialog::IDD, pParent) {
44 //{{AFX_DATA_INIT(CPathPadDialog)
45 // NOTE: the ClassWizard will add member initialization here
46 //}}AFX_DATA_INIT
47 }
48
49 void CPathPadDialog::DoDataExchange(CDataExchange *pDX) {
50 CDialog::DoDataExchange(pDX);
51 //{{AFX_DATA_MAP(CPathPadDialog)
52 // NOTE: the ClassWizard will add DDX and DDV calls here
53 //}}AFX_DATA_MAP
54 }
55
56 BEGIN_MESSAGE_MAP(CPathPadDialog, CDialog)
57 //{{AFX_MSG_MAP(CPathPadDialog)
58 ON_EN_KILLFOCUS(IDC_CURRENT_NODE_EDIT, OnKillfocusCurrentNodeEdit)
59 ON_BN_CLICKED(IDC_PATHPAD_ADD_PATH, OnPathpadAddPath)
60 ON_BN_CLICKED(IDC_PATHPAD_INSERT_NODE, OnPathpadInsertNode)
61 ON_BN_CLICKED(IDC_PATHPAD_DELETE_NODE, OnPathpadDeleteNode)
62 ON_BN_CLICKED(IDC_PATHPAD_MOVE_FORWARD, OnPathpadMoveForward)
63 ON_BN_CLICKED(IDC_PATHPAD_MOVE_BACKWARD, OnPathpadMoveBackward)
64 ON_BN_CLICKED(IDC_PATHPAD_MOVE_LEFT, OnPathpadMoveLeft)
65 ON_BN_CLICKED(IDC_PATHPAD_MOVE_RIGHT, OnPathpadMoveRight)
66 ON_CBN_SELENDOK(IDC_PATHPAD_PULLDOWN, OnSelendokPathpadPulldown)
67 ON_BN_CLICKED(IDC_PATHPAD_CENTER_VIEW, OnPathpadCenterView)
68 ON_BN_CLICKED(IDC_PATHPAD_MOVE_DOWN, OnPathpadMoveDown)
69 ON_BN_CLICKED(IDC_PATHPAD_MOVE_UP, OnPathpadMoveUp)
70 ON_BN_CLICKED(IDC_PATHPAD_PREV_NODE, OnPathpadPrevNode)
71 ON_BN_CLICKED(IDC_PATHPAD_NEXT_NODE, OnPathpadNextNode)
72 ON_BN_CLICKED(IDC_DELETE_PATH, OnDeletePath)
73 ON_BN_CLICKED(IDC_SHOW_NODES_CHECK, OnShowNodesCheck)
74 ON_WM_HELPINFO()
75 ON_BN_CLICKED(IDC_PATH_MOVE_OBJECT_BUTTON, OnPathMoveObjectButton)
76 ON_BN_CLICKED(IDC_PATH_REORIENT_VIEWER_BUTTON, OnPathReorientViewerButton)
77 ON_EN_KILLFOCUS(IDC_PATH_INC_TEXT, OnKillfocusPathIncText)
78 ON_WM_PAINT()
79 ON_BN_CLICKED(IDC_PATH_MOVE_NODE_TO_CURRENT_OBJECT, OnPathMoveNodeToCurrentObject)
80 ON_BN_CLICKED(IDC_PATH_MOVE_OBJ_NO_ORIENT, OnPathMoveObjNoOrient)
81 ON_BN_CLICKED(IDC_PATH_VERIFY_BUTTON, OnPathVerifyButton)
82 ON_BN_CLICKED(IDC_AIN_AUTO_EDGE_NODE, OnAinAutoEdgeNode)
83 ON_BN_CLICKED(IDC_AIN_BACK, OnAinBack)
84 ON_BN_CLICKED(IDC_AIN_CREATE_NODE_AT_VIEWER, OnAinCreateNodeAtViewer)
85 ON_BN_CLICKED(IDC_AIN_CREATE_NODES, OnAinCreateNodes)
86 ON_CBN_SELENDOK(IDC_AIN_CURRENT_NODE, OnSelendokAinCurrentNode)
87 ON_BN_CLICKED(IDC_AIN_DELETE_EDGE, OnAinDeleteEdge)
88 ON_BN_CLICKED(IDC_AIN_DELETE_NODE, OnAinDeleteNode)
89 ON_BN_CLICKED(IDC_AIN_DOWN, OnAinDown)
90 ON_BN_CLICKED(IDC_AIN_FORWARD, OnAinForward)
91 ON_BN_CLICKED(IDC_AIN_INSERT_NODE_ON_EDGE, OnAinInsertNodeOnEdge)
92 ON_BN_CLICKED(IDC_AIN_LEFT, OnAinLeft)
93 ON_BN_CLICKED(IDC_AIN_MAKE_EDGE, OnAinMakeEdge)
94 ON_EN_KILLFOCUS(IDC_AIN_MOVE_AMOUNT, OnKillfocusAinMoveAmount)
95 ON_BN_CLICKED(IDC_AIN_MOVE_NODE_TO_VIEWER, OnAinMoveNodeToViewer)
96 ON_BN_CLICKED(IDC_AIN_MPNS, OnAinMpns)
97 ON_CBN_SELENDOK(IDC_AIN_OTHER_NODE, OnSelendokAinOtherNode)
98 ON_BN_CLICKED(IDC_AIN_RESET_ROOM_NODES, OnAinResetRoomNodes)
99 ON_BN_CLICKED(IDC_AIN_RIGHT, OnAinRight)
100 ON_BN_CLICKED(IDC_AIN_SEL_NODE_EDGES, OnAinSelNodeEdges)
101 ON_BN_CLICKED(IDC_AIN_SEL_ROOM, OnAinSelRoom)
102 ON_BN_CLICKED(IDC_AIN_UP, OnAinUp)
103 ON_BN_CLICKED(IDC_AIN_SEL_ROOM_AND_NEXT_ROOMS, OnAinSelRoomAndNextRooms)
104 ON_BN_CLICKED(IDC_AIN_VERIFY_LEVEL, OnAinVerifyLevel)
105 ON_BN_CLICKED(IDC_AIN_VERIFY_ROOM, OnAinVerifyRoom)
106 ON_BN_CLICKED(IDC_AIN_VIEW_ALL_NODES, OnAinViewAllNodes)
107 ON_BN_CLICKED(IDC_AIN_VIEW_NONE, OnAinViewNone)
108 ON_BN_CLICKED(IDC_AIN_VIEW_ROOM, OnAinViewRoom)
109 ON_BN_CLICKED(IDC_AIN_VIEW_ROOM_AND_NEXT_ROOMS, OnAinViewRoomAndNextRooms)
110 ON_CBN_SETFOCUS(IDC_AIN_CURRENT_NODE, OnSetfocusAinCurrentNode)
111 ON_CBN_SETFOCUS(IDC_AIN_OTHER_NODE, OnSetfocusAinOtherNode)
112 ON_BN_CLICKED(IDC_IENAV_BUTTON, OnIenavButton)
113 ON_BN_CLICKED(IDC_MVTN_BUTTON, OnMvtnButton)
114 ON_BN_CLICKED(IDC_AER_BUTTON, OnAerButton)
115 ON_BN_CLICKED(IDC_ONTVGP_BUTTON, OnOntvgpButton)
116 //}}AFX_MSG_MAP
117 END_MESSAGE_MAP()
118
119 /////////////////////////////////////////////////////////////////////////////
120 // CPathPadDialog message handlers
121
122 void CPathPadDialog::OnKillfocusCurrentNodeEdit() {
123 CEdit *ebox;
124 char str[20];
125 int curpath = D3EditState.current_path;
126
127 if (Num_game_paths < 1) {
128 MessageBox("There are no paths to operate on.");
129 return;
130 }
131
132 ebox = (CEdit *)GetDlgItem(IDC_CURRENT_NODE_EDIT);
133 ebox->GetWindowText(str, 20);
134
135 // Do the base 1 to base 0 conversion
136 D3EditState.current_node = atoi(str) - 1;
137
138 if (D3EditState.current_node >= GamePaths[curpath].num_nodes)
139 D3EditState.current_node = GamePaths[curpath].num_nodes - 1;
140 else if (D3EditState.current_node < 0)
141 D3EditState.current_node = 0;
142
143 UpdateDialog();
144 }
145
146 void CPathPadDialog::OnPathpadAddPath() {
147
148 int curnode;
149 char *namestr;
150 int pathnum;
151 int dup_test;
152
153 pathnum = AllocGamePath();
154 if (pathnum < 0) {
155 return;
156 }
157
158 CEditLineDialog dlg("Enter path name", this);
159 int ret = dlg.DoModal();
160
161 if (ret == IDCANCEL) {
162 FreeGamePath(pathnum);
163 return;
164 }
165
166 namestr = (char *)dlg.GetText();
167 dup_test = FindGamePathName(namestr);
168 if (dup_test != -1) {
169 OutrageMessageBox("PATH NOT CREATED: A path named %s already exists.", namestr);
170 FreeGamePath(pathnum);
171 return;
172 }
173 strcpy(GamePaths[pathnum].name, namestr);
174
175 curnode = InsertNodeIntoPath(pathnum, -1, 0);
176 if (curnode < 0)
177 return;
178
179 D3EditState.current_path = pathnum;
180 D3EditState.current_node = curnode;
181 World_changed = 1;
182 UpdateDialog();
183 }
184
185 void CPathPadDialog::OnPathpadInsertNode() {
186 int curpath = D3EditState.current_path;
187 int curnode = D3EditState.current_node;
188
189 if (Num_game_paths < 1) {
190 MessageBox("There are no paths to operate on.");
191 return;
192 }
193
194 curnode = InsertNodeIntoPath(curpath, curnode, 0);
195 if (curnode < 0)
196 return;
197
198 D3EditState.current_node = curnode;
199 World_changed = 1;
200 UpdateDialog();
201 }
202
203 void CPathPadDialog::OnPathpadDeleteNode() {
204 int curpath = D3EditState.current_path;
205 int curnode = D3EditState.current_node;
206
207 if (Num_game_paths < 1) {
208 MessageBox("There are no paths to operate on.");
209 return;
210 }
211
212 if (GamePaths[curpath].num_nodes == 1) {
213 MessageBox("This is the only node in this path. If you wish to delete this path, click the 'Delete Path' button.");
214 return;
215 }
216
217 DeleteNodeFromPath(curpath, curnode);
218
219 // If this was the ending node, move it back one
220 if (curnode == GamePaths[curpath].num_nodes)
221 D3EditState.current_node = curnode - 1;
222
223 State_changed = 1;
224 UpdateDialog();
225 }
226
227 void CPathPadDialog::OnPathpadMoveForward() {
228 if (Num_game_paths < 1) {
229 MessageBox("There are no paths to operate on.");
230 return;
231 }
232
233 int p = D3EditState.current_path;
234 int n = D3EditState.current_node;
235
236 vector delta_movement = Viewer_object->orient.fvec * D3EditState.node_movement_inc;
237
238 MovePathNode(p, n, &delta_movement);
239
240 World_changed = 1;
241 UpdateDialog();
242 }
243
244 void CPathPadDialog::OnPathpadMoveBackward() {
245 if (Num_game_paths < 1) {
246 MessageBox("There are no paths to operate on.");
247 return;
248 }
249
250 int p = D3EditState.current_path;
251 int n = D3EditState.current_node;
252
253 vector delta_movement = Viewer_object->orient.fvec * -D3EditState.node_movement_inc;
254
255 MovePathNode(p, n, &delta_movement);
256
257 World_changed = 1;
258 UpdateDialog();
259 }
260
261 void CPathPadDialog::OnPathpadMoveLeft() {
262 if (Num_game_paths < 1) {
263 MessageBox("There are no paths to operate on.");
264 return;
265 }
266
267 int p = D3EditState.current_path;
268 int n = D3EditState.current_node;
269
270 vector delta_movement = Viewer_object->orient.rvec * -D3EditState.node_movement_inc;
271
272 MovePathNode(p, n, &delta_movement);
273
274 World_changed = 1;
275 UpdateDialog();
276 }
277
278 void CPathPadDialog::OnPathpadMoveRight() {
279 if (Num_game_paths < 1) {
280 MessageBox("There are no paths to operate on.");
281 return;
282 }
283
284 int p = D3EditState.current_path;
285 int n = D3EditState.current_node;
286
287 vector delta_movement = Viewer_object->orient.rvec * D3EditState.node_movement_inc;
288
289 MovePathNode(p, n, &delta_movement);
290
291 World_changed = 1;
292 UpdateDialog();
293 }
294
295 void CPathPadDialog::OnSelendokPathpadPulldown() {
296 int i, cur;
297 char name[200];
298
299 cur = SendDlgItemMessage(IDC_PATHPAD_PULLDOWN, CB_GETCURSEL, 0, 0);
300 SendDlgItemMessage(IDC_PATHPAD_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
301
302 i = FindGamePathName(name);
303
304 D3EditState.current_path = i;
305 D3EditState.current_node = 0;
306
307 State_changed = 1;
308 UpdateDialog();
309 }
310
311 void CPathPadDialog::OnPathpadCenterView() {
312 if (Num_game_paths < 1) {
313 MessageBox("There are no paths to operate on.");
314 return;
315 }
316
317 int p = D3EditState.current_path;
318 int n = D3EditState.current_node;
319
320 game_path *gp = &GamePaths[p];
321
322 vector attempted_pos;
323 vector subvec = {0.0, 0.0, 0.0}; // changed for now
324
325 attempted_pos = gp->pathnodes[n].pos - subvec;
326
327 fvi_query fq;
328 fvi_info hit_info;
329
330 fq.p0 = &GamePaths[p].pathnodes[n].pos;
331 fq.startroom = GamePaths[p].pathnodes[n].roomnum;
332 fq.p1 = &attempted_pos;
333 fq.rad = 0.0f;
334 fq.thisobjnum = -1;
335 fq.ignore_obj_list = NULL;
336 fq.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS;
337
338 int hit = fvi_FindIntersection(&fq, &hit_info);
339
340 if (hit != HIT_NONE)
341 Int3(); // what does it mean that we hit something?
342
343 ObjSetPos(Viewer_object, &hit_info.hit_pnt, hit_info.hit_room, NULL, false);
344
345 World_changed = 1;
346 UpdateDialog();
347 }
348
349 void CPathPadDialog::OnPathpadMoveDown() {
350 if (Num_game_paths < 1) {
351 MessageBox("There are no paths to operate on.");
352 return;
353 }
354
355 int p = D3EditState.current_path;
356 int n = D3EditState.current_node;
357
358 vector delta_movement = Viewer_object->orient.uvec * -D3EditState.node_movement_inc;
359
360 MovePathNode(p, n, &delta_movement);
361
362 World_changed = 1;
363 UpdateDialog();
364 }
365
366 void CPathPadDialog::OnPathpadMoveUp() {
367 if (Num_game_paths < 1) {
368 MessageBox("There are no paths to operate on.");
369 return;
370 }
371
372 int p = D3EditState.current_path;
373 int n = D3EditState.current_node;
374
375 vector delta_movement = Viewer_object->orient.uvec * D3EditState.node_movement_inc;
376
377 MovePathNode(p, n, &delta_movement);
378
379 World_changed = 1;
380 UpdateDialog();
381 }
382
383 void CPathPadDialog::OnPathpadPrevNode() {
384 if (Num_game_paths < 1)
385 return;
386
387 int p = D3EditState.current_path;
388 int n = D3EditState.current_node;
389
390 n--;
391
392 if (n < 0)
393 n = GamePaths[p].num_nodes - 1;
394
395 D3EditState.current_node = n;
396
397 World_changed = 1;
398 UpdateDialog();
399 }
400
401 void CPathPadDialog::OnPathpadNextNode() {
402 if (Num_game_paths < 1)
403 return;
404
405 int p = D3EditState.current_path;
406 int n = D3EditState.current_node;
407
408 n++;
409
410 n %= GamePaths[p].num_nodes;
411 D3EditState.current_node = n;
412
413 World_changed = 1;
414 UpdateDialog();
415 }
416
417 void CPathPadDialog::UpdateDialog() {
418 int n = D3EditState.current_path;
419 char str[50];
420 CEdit *ebox;
421
422 SendDlgItemMessage(IDC_PATHPAD_PULLDOWN, CB_RESETCONTENT, 0, 0);
423
424 for (int i = 0; i < MAX_GAME_PATHS; i++) {
425 if (GamePaths[i].used)
426 SendDlgItemMessage(IDC_PATHPAD_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GamePaths[i].name);
427 }
428 SendDlgItemMessage(IDC_PATHPAD_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)GamePaths[n].name);
429
430 ebox = (CEdit *)GetDlgItem(IDC_CURRENT_NODE_EDIT);
431 sprintf(str, "%d", D3EditState.current_node + 1);
432 ebox->SetWindowText(str);
433
434 ebox = (CEdit *)GetDlgItem(IDC_PATH_INC_TEXT);
435 sprintf(str, "%f", D3EditState.node_movement_inc);
436 ebox->SetWindowText(str);
437
438 if (n < Num_game_paths && D3EditState.current_node < GamePaths[n].num_nodes) {
439 ebox = (CEdit *)GetDlgItem(IDC_PATHPAD_CUR_NODE_ROOM);
440 if (!ROOMNUM_OUTSIDE(GamePaths[n].pathnodes[D3EditState.current_node].roomnum))
441 sprintf(str, "Current Mine Room: %d", GamePaths[n].pathnodes[D3EditState.current_node].roomnum);
442 else
443 sprintf(str, "Current Terrain Cell: %d", (0x7FFFFFFF & GamePaths[n].pathnodes[D3EditState.current_node].roomnum));
444 ebox->SetWindowText(str);
445 }
446
447 ebox = (CEdit *)GetDlgItem(IDC_PATHPAD_NUM_NODES);
448 sprintf(str, "Number of nodes: %d", GamePaths[n].num_nodes);
449 ebox->SetWindowText(str);
450
451 CheckDlgButton(IDC_SHOW_NODES_CHECK, Show_paths ? 1 : 0);
452 }
453
454 void CPathPadDialog::OnDeletePath() {
455 int ret;
456 int n = D3EditState.current_path;
457
458 if (Num_game_paths < 1)
459 return;
460
461 ret = MessageBox("Are you sure you want to delete this path?", GamePaths[n].name, MB_YESNO);
462 if (ret == IDNO)
463 return;
464
465 FreeGamePath(n);
466
467 D3EditState.current_path = GetNextPath(n);
468 World_changed = 1;
469 UpdateDialog();
470 }
471
472 void CPathPadDialog::OnShowNodesCheck() {
473 int c = IsDlgButtonChecked(IDC_SHOW_NODES_CHECK);
474
475 if (c)
476 Show_paths = 1;
477 else
478 Show_paths = 0;
479
480 TV_changed = 1;
481 }
482
483 BOOL CPathPadDialog::OnHelpInfo(HELPINFO *pHelpInfo) {
484 WinHelp(HID_PATHSTAB, HELP_CONTEXT);
485 return TRUE;
486 // return CDialog::OnHelpInfo(pHelpInfo);
487 }
488
489 void CPathPadDialog::OnPathMoveObjectButton() {
490 if (Num_game_paths < 1) {
491 MessageBox("There are no paths to operate on.");
492 return;
493 }
494
495 if (Cur_object_index != -1) // we have a selected object
496 {
497
498 int p = D3EditState.current_path;
499 int n = D3EditState.current_node;
500
501 game_path *gp = &GamePaths[p];
502
503 ObjSetPos(&Objects[Cur_object_index], &gp->pathnodes[n].pos, gp->pathnodes[n].roomnum, NULL, false);
504
505 matrix node_orient;
506
507 vm_VectorToMatrix(&node_orient, &gp->pathnodes[n].fvec, &gp->pathnodes[n].uvec, NULL);
508 ObjSetOrient(&Objects[Cur_object_index], &node_orient);
509
510 World_changed = 1;
511 }
512 }
513
514 void CPathPadDialog::OnPathReorientViewerButton() {
515 if (Num_game_paths < 1) {
516 MessageBox("There are no paths to operate on.");
517 return;
518 }
519
520 int p = D3EditState.current_path;
521 int n = D3EditState.current_node;
522
523 game_path *gp = &GamePaths[p];
524
525 matrix node_orient;
526
527 vm_VectorToMatrix(&node_orient, &gp->pathnodes[n].fvec, &gp->pathnodes[n].uvec, NULL);
528 ObjSetOrient(Viewer_object, &node_orient);
529
530 World_changed = 1;
531 UpdateDialog();
532 }
533
534 void CPathPadDialog::OnKillfocusPathIncText() {
535 CEdit *ebox;
536 char str[20];
537
538 ebox = (CEdit *)GetDlgItem(IDC_PATH_INC_TEXT);
539 ebox->GetWindowText(str, 20);
540
541 // Do the base 1 to base 0 conversion
542 sscanf(str, "%f", &D3EditState.node_movement_inc);
543
544 if (D3EditState.node_movement_inc <= 0.0f || D3EditState.node_movement_inc > 32000.0f)
545 D3EditState.node_movement_inc = 1.0f;
546
547 UpdateDialog();
548 }
549
550 void CPathPadDialog::OnPaint() {
551 CPaintDC dc(this); // device context for painting
552
553 UpdateDialog();
554 }
555
556 void CPathPadDialog::OnPathMoveNodeToCurrentObject() {
557 if (Num_game_paths < 1) {
558 MessageBox("There are no paths to operate on.");
559 return;
560 }
561
562 if (Cur_object_index != -1) // we have a selected object
563 {
564
565 int p = D3EditState.current_path;
566 int n = D3EditState.current_node;
567
568 game_path *gp = &GamePaths[p];
569 MovePathNodeToPos(p, n, &Objects[Cur_object_index].pos);
570
571 World_changed = 1;
572 UpdateDialog();
573 }
574 }
575
576 void CPathPadDialog::OnPathMoveObjNoOrient() {
577 if (Num_game_paths < 1) {
578 MessageBox("There are no paths to operate on.");
579 return;
580 }
581
582 if (Cur_object_index != -1) // we have a selected object
583 {
584
585 int p = D3EditState.current_path;
586 int n = D3EditState.current_node;
587
588 game_path *gp = &GamePaths[p];
589
590 ObjSetPos(&Objects[Cur_object_index], &gp->pathnodes[n].pos, gp->pathnodes[n].roomnum, NULL, false);
591
592 // matrix node_orient;
593
594 World_changed = 1;
595 UpdateDialog();
596 }
597 }
598
599 void CPathPadDialog::OnPathVerifyButton() {}
600
601 int BNode_current_id = 0;
602 int BNode_current_room = 0;
603 int BNode_other_id = 0;
604 int BNode_other_room = 0;
605
606 float BNode_move_amount = 1.0f;
607
608 void CPathPadDialog::OnAinAutoEdgeNode() {
609 EBNode_AutoEdgeNode(BNode_current_id, BNode_current_room);
610 EBNode_VerifyGraph();
611 World_changed = 1;
612 }
613
614 void CPathPadDialog::OnAinBack() {
615 vector diff = -Viewer_object->orient.fvec * BNode_move_amount;
616
617 EBNode_Move(true, BNode_current_room, BNode_current_id, &diff);
618 World_changed = 1;
619 }
620
621 void CPathPadDialog::OnAinCreateNodeAtViewer() {
622 int node = EBNode_AddNode(Viewer_object->roomnum, &Viewer_object->pos, true, true);
623
624 if (node != -1) {
625 World_changed = 1;
626 }
627
628 // EBNode_VerifyGraph();
629 }
630
631 void CPathPadDialog::OnAinCreateNodes() {
632 MakeBOA();
633 EBNode_MakeFirstPass();
634 World_changed = 1;
635 }
636
637 void CPathPadDialog::OnSelendokAinCurrentNode() {
638 int cur;
639 char name[200];
640
641 cur = SendDlgItemMessage(IDC_AIN_CURRENT_NODE, CB_GETCURSEL, 0, 0);
642 SendDlgItemMessage(IDC_AIN_CURRENT_NODE, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
643
644 if (sscanf(name, "Room %d, Node %d", &BNode_current_room, &BNode_current_id) != 2) {
645 sscanf(name, "Region %d, Node %d", &BNode_current_room, &BNode_current_id);
646 BNode_current_room += Highest_room_index + 1;
647 }
648
649 BNode_current_id--;
650 }
651
652 void CPathPadDialog::OnAinDeleteEdge() {
653 EBNode_RemoveEdge(BNode_current_id, BNode_current_room, BNode_other_id, BNode_other_room);
654 World_changed = 1;
655
656 EBNode_VerifyGraph();
657 }
658
659 void CPathPadDialog::OnAinDeleteNode() {
660 EBNode_RemoveNode(BNode_current_room, BNode_current_id);
661 World_changed = 1;
662
663 EBNode_VerifyGraph();
664 }
665
666 void CPathPadDialog::OnAinDown() {
667 vector diff = -Viewer_object->orient.uvec * BNode_move_amount;
668
669 EBNode_Move(true, BNode_current_room, BNode_current_id, &diff);
670 World_changed = 1;
671 }
672
673 void CPathPadDialog::OnAinForward() {
674 vector diff = Viewer_object->orient.fvec * BNode_move_amount;
675
676 EBNode_Move(true, BNode_current_room, BNode_current_id, &diff);
677 World_changed = 1;
678 }
679
680 void CPathPadDialog::OnAinInsertNodeOnEdge() {
681 EBNode_InsertNodeOnEdge(BNode_current_id, BNode_current_room, BNode_other_id, BNode_other_room);
682 EBNode_VerifyGraph();
683 World_changed = 1;
684 }
685
686 void CPathPadDialog::OnAinLeft() {
687 vector diff = -Viewer_object->orient.rvec * BNode_move_amount;
688
689 EBNode_Move(true, BNode_current_room, BNode_current_id, &diff);
690 World_changed = 1;
691 }
692
693 void CPathPadDialog::OnAinMakeEdge() {
694 EBNode_AddEdge(BNode_current_id, BNode_current_room, BNode_other_id, BNode_other_room);
695 EBNode_VerifyGraph();
696 World_changed = 1;
697 }
698
699 void CPathPadDialog::OnKillfocusAinMoveAmount() {
700 CEdit *ebox;
701 char str[20];
702
703 ebox = (CEdit *)GetDlgItem(IDC_AIN_MOVE_AMOUNT);
704 ebox->GetWindowText(str, 20);
705 sscanf(str, "%f", &BNode_move_amount);
706
707 UpdateDialog();
708 }
709
710 void CPathPadDialog::OnAinMoveNodeToViewer() {
711 vector diff = Viewer_object->pos;
712
713 EBNode_Move(false, BNode_current_room, BNode_current_id, &diff);
714 World_changed = 1;
715 }
716
717 void CPathPadDialog::OnAinMpns() {
718 // TODO: Add your control notification handler code here
719 }
720
721 void CPathPadDialog::OnSelendokAinOtherNode() {
722 int cur;
723 char name[200];
724
725 cur = SendDlgItemMessage(IDC_AIN_OTHER_NODE, CB_GETCURSEL, 0, 0);
726 SendDlgItemMessage(IDC_AIN_OTHER_NODE, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
727
728 if (sscanf(name, "Room %d, Node %d", &BNode_other_room, &BNode_other_id) != 2) {
729 sscanf(name, "Region %d, Node %d", &BNode_other_room, &BNode_other_id);
730 BNode_other_room += Highest_room_index + 1;
731 }
732
733 BNode_other_id--;
734 }
735
736 void CPathPadDialog::OnAinResetRoomNodes() {
737 // TODO: Add your control notification handler code here
738 EBNode_VerifyGraph();
739 }
740
741 void CPathPadDialog::OnAinRight() {
742 vector diff = Viewer_object->orient.rvec * BNode_move_amount;
743
744 EBNode_Move(true, BNode_current_room, BNode_current_id, &diff);
745 World_changed = 1;
746 }
747
748 #define EBVIEW_ROOM 1
749 #define EBVIEW_ROOM_AND_NEXT_ROOMS 2
750 #define EBVIEW_CUR_EDGES 3
751
752 char ENode_view_type = EBVIEW_ROOM;
753
754 void CPathPadDialog::OnAinSelNodeEdges() {
755 ENode_view_type = EBVIEW_CUR_EDGES;
756 ResetNodesForComboBox(IDC_AIN_CURRENT_NODE, ENode_view_type);
757 ResetNodesForComboBox(IDC_AIN_OTHER_NODE, ENode_view_type);
758 }
759
760 void CPathPadDialog::OnAinSelRoom() {
761 ENode_view_type = EBVIEW_ROOM;
762 ResetNodesForComboBox(IDC_AIN_CURRENT_NODE, ENode_view_type);
763 ResetNodesForComboBox(IDC_AIN_OTHER_NODE, ENode_view_type);
764 }
765
766 void CPathPadDialog::OnAinSelRoomAndNextRooms() {
767 ENode_view_type = EBVIEW_ROOM_AND_NEXT_ROOMS;
768 ResetNodesForComboBox(IDC_AIN_CURRENT_NODE, ENode_view_type);
769 ResetNodesForComboBox(IDC_AIN_OTHER_NODE, ENode_view_type);
770 }
771
772 void CPathPadDialog::OnAinUp() {
773 vector diff = Viewer_object->orient.uvec * BNode_move_amount;
774
775 EBNode_Move(true, BNode_current_room, BNode_current_id, &diff);
776 World_changed = 1;
777 }
778
779 void CPathPadDialog::OnAinVerifyLevel() { EBNode_VerifyGraph(); }
780
781 void CPathPadDialog::OnAinVerifyRoom() {
782 EBNode_ClearLevel();
783 World_changed = 1;
784 }
785
786 void CPathPadDialog::OnAinViewAllNodes() {
787 EBN_draw_type = EBDRAW_LEVEL;
788 World_changed = 1;
789 }
790
791 void CPathPadDialog::OnAinViewNone() {
792 EBN_draw_type = EBDRAW_NONE;
793 World_changed = 1;
794 }
795
796 void CPathPadDialog::OnAinViewRoom() {
797 EBN_draw_type = EBDRAW_ROOM;
798 World_changed = 1;
799 }
800
801 void CPathPadDialog::OnAinViewRoomAndNextRooms() {
802 EBN_draw_type = EBDRAW_ROOM_AND_NEXT_ROOMS;
803 World_changed = 1;
804 }
805
806 void CPathPadDialog::ResetNodesForComboBox(int handle, char selection_type) {
807 char message[25];
808 SendDlgItemMessage(handle, CB_RESETCONTENT, 0, 0);
809 bool f_add = false;
810
811 int num_next_rooms = 0;
812 int next_rooms[1000];
813
814 if (Viewer_object->roomnum >= 0 && Viewer_object->roomnum <= Highest_room_index &&
815 Rooms[Viewer_object->roomnum].used) {
816 if (selection_type == EBVIEW_ROOM || selection_type == EBVIEW_ROOM_AND_NEXT_ROOMS) {
817 for (int i = 0; i < Rooms[Viewer_object->roomnum].bn_info.num_nodes; i++) {
818 f_add = true;
819
820 sprintf(message, "Room %d, Node %d", Viewer_object->roomnum, i + 1);
821 SendDlgItemMessage(handle, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)message);
822 }
823
824 if (selection_type == EBVIEW_ROOM_AND_NEXT_ROOMS) {
825 int i;
826 int j;
827 int k;
828
829 for (i = 0; i < Rooms[Viewer_object->roomnum].num_portals; i++) {
830 bool f_found = false;
831
832 for (j = 0; j < num_next_rooms; j++) {
833 if (next_rooms[j] == Rooms[Viewer_object->roomnum].portals[i].croom) {
834 f_found = true;
835 break;
836 }
837 }
838
839 if (!f_found && Rooms[Viewer_object->roomnum].portals[i].croom >= 0 &&
840 !(Rooms[Rooms[Viewer_object->roomnum].portals[i].croom].flags & RF_EXTERNAL)) {
841 for (k = 0; k < Rooms[Rooms[Viewer_object->roomnum].portals[i].croom].bn_info.num_nodes; k++) {
842 sprintf(message, "Room %d, Node %d", Rooms[Viewer_object->roomnum].portals[i].croom, k + 1);
843 SendDlgItemMessage(handle, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)message);
844 }
845 }
846 }
847 }
848
849 if (f_add) {
850 sprintf(message, "Room %d, Node %d", Viewer_object->roomnum, 0 + 1);
851 SendDlgItemMessage(handle, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)message);
852 } else {
853 strcpy(message, "No Nodes in room");
854 SendDlgItemMessage(handle, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)message);
855 }
856 }
857 } else if (ROOMNUM_OUTSIDE(Viewer_object->roomnum)) {
858 if (selection_type == EBVIEW_ROOM || selection_type == EBVIEW_ROOM_AND_NEXT_ROOMS) {
859 int room = BOA_INDEX(Viewer_object->roomnum);
860 int tr = room - Highest_room_index - 1;
861 bn_list *bnlist = BNode_GetBNListPtr(Viewer_object->roomnum);
862
863 for (int i = 0; i < bnlist->num_nodes; i++) {
864 f_add = true;
865
866 sprintf(message, "Region %d, Node %d", tr, i + 1);
867 SendDlgItemMessage(handle, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)message);
868 }
869
870 if (selection_type == EBVIEW_ROOM_AND_NEXT_ROOMS) {
871 int i;
872 int j;
873 int k;
874
875 for (i = 0; i < BOA_num_connect[tr]; i++) {
876 bool f_found = false;
877
878 for (j = 0; j < num_next_rooms; j++) {
879 if (next_rooms[j] == BOA_connect[tr][i].roomnum) {
880 f_found = true;
881 break;
882 }
883 }
884
885 if (!f_found && BOA_connect[tr][i].roomnum >= 0 && !(Rooms[BOA_connect[tr][i].roomnum].flags & RF_EXTERNAL)) {
886 for (k = 0; k < Rooms[BOA_connect[tr][i].roomnum].bn_info.num_nodes; k++) {
887 sprintf(message, "Room %d, Node %d", BOA_connect[tr][i].roomnum, k + 1);
888 SendDlgItemMessage(handle, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)message);
889 }
890 }
891 }
892 }
893
894 if (f_add) {
895 sprintf(message, "Region %d, Node %d", tr, 0 + 1);
896 SendDlgItemMessage(handle, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)message);
897 } else {
898 strcpy(message, "No Nodes in region");
899 SendDlgItemMessage(handle, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)message);
900 }
901 }
902 }
903 }
904
905 void CPathPadDialog::OnSetfocusAinCurrentNode() { ResetNodesForComboBox(IDC_AIN_CURRENT_NODE, ENode_view_type); }
906
907 void CPathPadDialog::OnSetfocusAinOtherNode() { ResetNodesForComboBox(IDC_AIN_OTHER_NODE, ENode_view_type); }
908
909 void CPathPadDialog::OnIenavButton() {
910 int node = EBNode_InsertNodeOnEdge(BNode_current_id, BNode_current_room, BNode_other_id, BNode_other_room);
911 if (node >= 0) {
912 vector diff = Viewer_object->pos;
913
914 EBNode_Move(false, BNode_current_room, node, &diff);
915 World_changed = 1;
916 }
917 }
918
919 void CPathPadDialog::OnMvtnButton() {
920 vector pos;
921 int roomnum;
922
923 bn_list *bnlist = BNode_GetBNListPtr(BNode_current_room);
924 if (!bnlist)
925 return;
926
927 pos = bnlist->nodes[BNode_current_id].pos;
928
929 if (BNode_current_room >= 0 && BNode_current_room <= Highest_room_index) {
930 roomnum = BNode_current_room;
931 } else {
932 roomnum = GetTerrainRoomFromPos(&pos);
933 }
934
935 BNode_current_id,
936
937 ObjSetPos(Viewer_object, &pos, roomnum, NULL, false);
938 World_changed = 1;
939 }
940
941 void CPathPadDialog::OnAerButton() {
942 bn_list *bnlist = BNode_GetBNListPtr(BNode_current_room);
943 if (!bnlist)
944 return;
945
946 for (int i = 0; i < bnlist->num_nodes; i++) {
947 EBNode_AutoEdgeNode(i, BNode_current_room);
948 }
949
950 EBNode_VerifyGraph();
951 World_changed = 1;
952 }
953
954 void CPathPadDialog::OnOntvgpButton() {
955 if (Num_game_paths < 1) {
956 MessageBox("There are no paths to operate on.");
957 return;
958 }
959
960 if (Cur_object_index != -1) // we have a selected object
961 {
962
963 int p = D3EditState.current_path;
964 int n = D3EditState.current_node;
965
966 game_path *gp = &GamePaths[p];
967
968 gp->pathnodes[n].fvec = Viewer_object->orient.fvec;
969 gp->pathnodes[n].uvec = Viewer_object->orient.uvec;
970
971 World_changed = 1;
972 UpdateDialog();
973 }
974 }