-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAirg.cpp
More file actions
1027 lines (917 loc) · 43.7 KB
/
Copy pathAirg.cpp
File metadata and controls
1027 lines (917 loc) · 43.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "../../include/NavKit/module/Airg.h"
#include <filesystem>
#include <fstream>
#include <numbers>
#include <CommCtrl.h>
#include <iomanip>
#include <SDL.h>
#include <sstream>
#include <string>
#include "../../include/NavKit/Resource.h"
#include "../../include/NavKit/model/ReasoningGrid.h"
#include "../../include/NavKit/model/VisionData.h"
#include "../../include/NavKit/module/Grid.h"
#include "../../include/NavKit/module/Logger.h"
#include "../../include/NavKit/module/Menu.h"
#include "../../include/NavKit/module/NavKitSettings.h"
#include "../../include/NavKit/module/Navp.h"
#include "../../include/NavKit/module/SceneMesh.h"
#include "../../include/NavKit/module/PersistedSettings.h"
#include "../../include/NavKit/module/Renderer.h"
#include "../../include/NavKit/module/Rpkg.h"
#include "../../include/NavKit/module/SceneExtract.h"
#include "../../include/NavKit/util/FileUtil.h"
#include "../../include/NavKit/util/GridGenerator.h"
#include "../../include/ResourceLib_HM3/ResourceConverter.h"
#include "../../include/ResourceLib_HM3/ResourceGenerator.h"
#include "../../include/ResourceLib_HM3/ResourceLib_HM3.h"
#include "../../include/ResourceLib_HM3/Generated/HM3/ZHMGen.h"
Airg::Airg()
: airgName("Load Airg")
, lastLoadAirgFile(airgName)
, saveAirgName("Save Airg")
, lastSaveAirgFile(saveAirgName)
, airgLoaded(false)
, airgLoading(false)
, airgBuilding(false)
, connectWaypointModeEnabled(false)
, showAirg(true)
, showAirgIndices(false)
, showRecastDebugInfo(false)
, cellColorSource(OFF)
, airgResourceConverter(HM3_GetConverterForResource("AIRG"))
, airgResourceGenerator(HM3_GetGeneratorForResource("AIRG"))
, reasoningGrid(new ReasoningGrid())
, selectedWaypointIndex(-1)
, doAirgHitTest(false)
, buildingVisionAndDeadEndData(false) {}
Airg::~Airg() = default;
HWND Airg::hAirgDialog = nullptr;
std::string Airg::selectedRpkgAirg{};
std::map<std::string, std::string> Airg::airgHashIoiStringMap;
std::mutex Airg::airgHashIoiStringMapMutex;
GLuint Airg::airgTriVao = 0;
GLuint Airg::airgTriVbo = 0;
GLuint Airg::airgLineVao = 0;
GLuint Airg::airgLineVbo = 0;
int Airg::airgTriCount = 0;
int Airg::airgLineCount = 0;
bool Airg::airgDirty = true;
GLuint Airg::airgHitTestVao = 0;
GLuint Airg::airgHitTestVbo = 0;
int Airg::airgHitTestCount = 0;
bool Airg::airgHitTestDirty = true;
static std::string formatFloat(const float val) {
std::stringstream ss;
ss << std::fixed << std::setprecision(2) << val;
return ss.str();
}
INT_PTR CALLBACK Airg::airgDialogProc(const HWND hDlg, const UINT message, const WPARAM wParam, const LPARAM lParam) {
Grid& grid = Grid::getInstance();
switch (message) {
case WM_INITDIALOG: {
UpdateDialogControls(hDlg);
return TRUE;
}
case WM_HSCROLL: {
const float oldSpacing = grid.spacing;
if (reinterpret_cast<HWND>(lParam) == GetDlgItem(hDlg, IDC_SLIDER_SPACING)) {
const int pos = SendMessage(reinterpret_cast<HWND>(lParam), TBM_GETPOS, 0, 0);
grid.spacing = 0.1f + (pos * 0.05f);
SetDlgItemText(hDlg, IDC_STATIC_SPACING_VAL, formatFloat(grid.spacing).c_str());
if (oldSpacing != grid.spacing) {
grid.saveSpacing(grid.spacing);
UpdateDialogControls(hDlg);
airgDirty = true;
}
} else if (reinterpret_cast<HWND>(lParam) == GetDlgItem(hDlg, IDC_SLIDER_XOFFSET)) {
const int pos = SendMessage(reinterpret_cast<HWND>(lParam), TBM_GETPOS, 0, 0);
grid.xOffset = -grid.spacing + (pos * 0.05f);
SetDlgItemText(hDlg, IDC_STATIC_XOFFSET_VAL, formatFloat(grid.xOffset).c_str());
airgDirty = true;
} else if (reinterpret_cast<HWND>(lParam) == GetDlgItem(hDlg, IDC_SLIDER_ZOFFSET)) {
const int pos = SendMessage(reinterpret_cast<HWND>(lParam), TBM_GETPOS, 0, 0);
grid.yOffset = -grid.spacing + (pos * 0.05f);
SetDlgItemText(hDlg, IDC_STATIC_ZOFFSET_VAL, formatFloat(grid.yOffset).c_str());
airgDirty = true;
}
return TRUE;
}
case WM_COMMAND: {
if (LOWORD(wParam) == IDC_BUTTON_RESET_DEFAULTS) {
Logger::log(NK_INFO, "Resetting Airg Default settings");
resetDefaults();
UpdateDialogControls(hDlg);
airgDirty = true;
}
return TRUE;
}
case WM_CLOSE:
DestroyWindow(hDlg);
return TRUE;
case WM_DESTROY:
hAirgDialog = nullptr;
return TRUE;
default: ;
}
return FALSE;
}
void Airg::showAirgDialog() {
if (hAirgDialog) {
SetForegroundWindow(hAirgDialog);
return;
}
const HINSTANCE hInstance = GetModuleHandle(nullptr);
const HWND hParentWnd = Renderer::hwnd;
hAirgDialog = CreateDialogParam(
hInstance,
MAKEINTRESOURCE(IDD_AIRG_MENU),
hParentWnd,
airgDialogProc,
reinterpret_cast<LPARAM>(this)
);
if (hAirgDialog) {
if (HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON))) {
SendMessage(hAirgDialog, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(hIcon));
SendMessage(hAirgDialog, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(hIcon));
}
RECT parentRect, dialogRect;
GetWindowRect(hParentWnd, &parentRect);
GetWindowRect(hAirgDialog, &dialogRect);
const int parentWidth = parentRect.right - parentRect.left;
const int parentHeight = parentRect.bottom - parentRect.top;
const int dialogWidth = dialogRect.right - dialogRect.left;
const int dialogHeight = dialogRect.bottom - dialogRect.top;
const int newX = parentRect.left + (parentWidth - dialogWidth) / 2;
const int newY = parentRect.top + (parentHeight - dialogHeight) / 2;
SetWindowPos(hAirgDialog, nullptr, newX, newY, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
ShowWindow(hAirgDialog, SW_SHOW);
}
}
void Airg::UpdateDialogControls(const HWND hDlg) {
const Grid& grid = Grid::getInstance();
const HWND hSliderSpacing = GetDlgItem(hDlg, IDC_SLIDER_SPACING);
const HWND hSliderX = GetDlgItem(hDlg, IDC_SLIDER_XOFFSET);
const HWND hSliderZ = GetDlgItem(hDlg, IDC_SLIDER_ZOFFSET);
// --- Spacing Slider ---
SendMessage(hSliderSpacing, TBM_SETRANGE, TRUE, MAKELONG(0, 78));
const int spacingPos = static_cast<int>((grid.spacing - 0.1f) / 0.05f);
SendMessage(hSliderSpacing, TBM_SETPOS, TRUE, spacingPos);
SetDlgItemText(hDlg, IDC_STATIC_SPACING_VAL, formatFloat(grid.spacing).c_str());
// --- X and Z Offset Sliders ---
const int range = static_cast<int>((grid.spacing * 2) / 0.05f);
// X Offset
SendMessage(hSliderX, TBM_SETRANGE, TRUE, MAKELONG(0, range));
const int xPos = static_cast<int>((grid.xOffset + grid.spacing) / 0.05f);
SendMessage(hSliderX, TBM_SETPOS, TRUE, xPos);
SetDlgItemText(hDlg, IDC_STATIC_XOFFSET_VAL, formatFloat(grid.xOffset).c_str());
// Z Offset
SendMessage(hSliderZ, TBM_SETRANGE, TRUE, MAKELONG(0, range));
const int zPos = static_cast<int>((grid.yOffset + grid.spacing) / 0.05f);
SendMessage(hSliderZ, TBM_SETPOS, TRUE, zPos);
SetDlgItemText(hDlg, IDC_STATIC_ZOFFSET_VAL, formatFloat(grid.yOffset).c_str());
}
void Airg::resetDefaults() {
Grid& grid = Grid::getInstance();
grid.spacing = 2.25;
grid.xOffset = 0;
grid.yOffset = 0;
}
void Airg::setLastLoadFileName(const char* fileName) {
if (std::filesystem::exists(fileName) && !std::filesystem::is_directory(fileName)) {
airgName = fileName;
lastLoadAirgFile = airgName;
airgLoaded = false;
Menu::updateMenuState();
airgName = airgName.substr(airgName.find_last_of("/\\") + 1);
}
}
void Airg::setLastSaveFileName(const char* fileName) {
saveAirgName = fileName;
lastSaveAirgFile = saveAirgName;
saveAirgName = saveAirgName.substr(saveAirgName.find_last_of("/\\") + 1);
}
void Airg::loadAirgFromFile(const std::string& fileName) {
setLastLoadFileName(fileName.c_str());
std::string fileNameStr = fileName;
std::string extension = airgName.substr(airgName.length() - 4, airgName.length());
std::ranges::transform(extension, extension.begin(), ::toupper);
if (extension == "JSON") {
delete reasoningGrid;
reasoningGrid = new ReasoningGrid();
Logger::log(NK_INFO, "Loading Airg.Json file: '%s'...", fileNameStr.c_str());
backgroundWorker.emplace(&Airg::loadAirg, this, fileNameStr, true);
} else if (extension == "AIRG") {
delete reasoningGrid;
reasoningGrid = new ReasoningGrid();
Logger::log(NK_INFO, "Loading Airg file: '%s'...", fileNameStr.c_str());
backgroundWorker.emplace(&Airg::loadAirg, this, fileNameStr, false);
}
airgDirty = true;
}
void Airg::handleOpenAirgClicked() {
if (const char* fileName = openAirgFileDialog(lastLoadAirgFile.data())) {
loadedAirgText = fileName;
loadAirgFromFile(fileName);
}
}
void Airg::handleSaveAirgClicked() {
if (char* fileName = openSaveAirgFileDialog(lastLoadAirgFile.data())) {
setLastSaveFileName(fileName);
const auto fileNameString = std::string{fileName};
std::string extension = fileNameString.substr(fileNameString.length() - 4, fileNameString.length());
std::ranges::transform(extension, extension.begin(), ::toupper);
std::string msg = "Saving Airg";
if (extension == "JSON") {
msg += ".json";
}
msg += " file: '";
msg += fileName;
msg += "'...";
Logger::log(NK_INFO, msg.data());
backgroundWorker.emplace(&Airg::saveAirg, this, fileName, extension == "JSON");
}
}
bool Airg::canLoad() const {
return !airgLoading && airgSaveState.empty();
}
bool Airg::canSave() const {
return airgLoaded && airgSaveState.empty();
}
bool Airg::canBuildAirg() const {
const Navp& navp = Navp::getInstance();
return navp.navpLoaded && !airgLoading && airgSaveState.empty() && !airgBuilding;
}
void Airg::handleBuildAirgClicked() {
if (const Navp& navp = Navp::getInstance(); Navp::getTotalAreaCount(navp.navMesh) > 65535) {
Logger::log(
NK_ERROR,
"Loaded NAVP has too many areas. Ensure the scene has PF Seed Points and has a fully contained boundary.");
}
airgLoaded = false;
Menu::updateMenuState();
airgBuilding = true;
delete reasoningGrid;
reasoningGrid = new ReasoningGrid();
airgDirty = true;
airgHitTestDirty = true;
Logger::log(NK_INFO, "Building Airg from Airg");
backgroundWorker.emplace(&Airg::buildAirg, this);
}
bool Airg::canEnterConnectWaypointMode() const {
return airgLoaded && selectedWaypointIndex != -1;
}
void Airg::handleConnectWaypointClicked() {
connectWaypointModeEnabled = !connectWaypointModeEnabled;
if (connectWaypointModeEnabled) {
Logger::log(NK_INFO, "Entering Connect Waypoint mode. Start waypoint: %d", selectedWaypointIndex);
} else {
Logger::log(NK_INFO, "Exiting Connect Waypoint mode.");
}
Menu::updateMenuState();
}
void Airg::finalizeSave() {
if (airgSaveState.size() == 2) {
airgSaveState.clear();
}
}
void Airg::connectWaypoints(const int startWaypointIndex, const int endWaypointIndex) {
Waypoint& startWaypoint = reasoningGrid->m_WaypointList[startWaypointIndex];
for (int direction = 0; direction < 8; ++direction) {
if (startWaypoint.nNeighbors[direction] == endWaypointIndex) {
Logger::log(NK_INFO, "Waypoints already connected.");
return;
}
}
connectWaypointModeEnabled = false;
Menu::updateMenuState();
if (startWaypointIndex == -1 || endWaypointIndex == -1) {
Logger::log(NK_INFO, "Exiting Connect Waypoint mode.");
return;
}
Waypoint& endWaypoint = reasoningGrid->m_WaypointList[endWaypointIndex];
const Vec3 startPos = {startWaypoint.vPos.x, startWaypoint.vPos.y, startWaypoint.vPos.z};
const Vec3 endPos = {endWaypoint.vPos.x, endWaypoint.vPos.y, endWaypoint.vPos.z};
const Vec3 waypointDirectionVec = endPos - startPos;
const Vec3 directionNormalized = waypointDirectionVec / waypointDirectionVec.GetMagnitude();
float maxParallelization = -2;
int bestDirection = -1;
for (int direction = 0; direction < 8; direction++) {
float dx = 0, dy = 0;
if (direction == 1 || direction == 2 || direction == 3) {
dx = 1;
} else if (direction == 5 || direction == 6 || direction == 7) {
dx = -1;
}
if (direction == 7 || direction == 0 || direction == 1) {
dy = -1;
} else if (direction == 3 || direction == 4 || direction == 5) {
dy = 1;
}
Vec3 directionVec = {dx, dy, 0.0f};
if (const float dot = directionNormalized.Dot(directionVec); dot > maxParallelization) {
maxParallelization = dot;
bestDirection = direction;
}
}
startWaypoint.nNeighbors[bestDirection] = endWaypointIndex;
endWaypoint.nNeighbors[(bestDirection + 4) % 8] = startWaypointIndex;
Logger::log(NK_INFO,
("Connected waypoints: " + std::to_string(startWaypointIndex) + " and " + std::to_string(
endWaypointIndex)).c_str());
Logger::log(NK_INFO, "Exiting Connect Waypoint mode.");
}
char* Airg::openAirgFileDialog(const char* lastAirgFolder) {
nfdu8filteritem_t filters[2] = {{"Airg files", "airg"}, {"Airg.json files", "airg.json"}};
return FileUtil::openNfdLoadDialog(filters, 2);
}
char* Airg::openSaveAirgFileDialog(char* lastAirgFolder) {
nfdu8filteritem_t filters[2] = {{"Airg files", "airg"}, {"Airg.json files", "airg.json"}};
return FileUtil::openNfdSaveDialog(filters, 2, "output");
}
void Airg::addWaypointGeometry(std::vector<AirgVertex>& triVerts, std::vector<AirgVertex>& lineVerts,
const Waypoint& waypoint, const bool selected, const glm::vec4& color,
const bool forceFan) {
const float r = 0.1f;
const float z = waypoint.vPos.z + 0.03f;
const glm::vec3 center(waypoint.vPos.x, z, -waypoint.vPos.y);
constexpr glm::vec3 normal(0.0f, 1.0f, 0.0f);
constexpr float step = std::numbers::pi_v<float> / 4.0f;
if (selected || forceFan) {
for (int i = 0; i < 8; i++) {
const float a1 = static_cast<float>(i) * step;
const float a2 = static_cast<float>(i + 1) * step;
const glm::vec3 p1(waypoint.vPos.x + cosf(a1) * r, z, -(waypoint.vPos.y + sinf(a1) * r));
const glm::vec3 p2(waypoint.vPos.x + cosf(a2) * r, z, -(waypoint.vPos.y + sinf(a2) * r));
triVerts.push_back({center, normal, color});
triVerts.push_back({p2, normal, color});
triVerts.push_back({p1, normal, color});
}
} else {
// Line Loop
for (int i = 0; i < 8; i++) {
const float a1 = static_cast<float>(i) / 8.0f * std::numbers::pi * 2;
const float a2 = static_cast<float>(i + 1) / 8.0f * std::numbers::pi * 2;
const glm::vec3 p1(waypoint.vPos.x + cosf(a1) * r, z, -(waypoint.vPos.y + sinf(a1) * r));
const glm::vec3 p2(waypoint.vPos.x + cosf(a2) * r, z, -(waypoint.vPos.y + sinf(a2) * r));
lineVerts.push_back({p1, glm::vec3(0, 1, 0), color});
lineVerts.push_back({p2, glm::vec3(0, 1, 0), color});
}
}
}
int Airg::visibilityDataSize(const ReasoningGrid* reasoningGrid, const int waypointIndex) {
const int offset1 = reasoningGrid->m_WaypointList[waypointIndex].nVisionDataOffset;
int offset2;
if (waypointIndex < (reasoningGrid->m_WaypointList.size() - 1)) {
offset2 = reasoningGrid->m_WaypointList[waypointIndex + 1].nVisionDataOffset;
} else {
offset2 = reasoningGrid->m_pVisibilityData.size();
}
return offset2 - offset1;
}
void Airg::buildAirg(Airg* airg) {
GridGenerator::getInstance().build();
airg->airgBuilding = false;
airg->airgLoaded = true;
airgDirty = true;
airgHitTestDirty = true;
Menu::updateMenuState();
}
void Airg::renderAirg() {
if (selectedWaypointIndex >= reasoningGrid->m_WaypointList.size()) {
selectedWaypointIndex = -1;
}
static int lastSelectedWaypoint = -1;
static int lastCellColorSource = -1;
static float lastSpacing = -1.0f;
static float lastXOffset = -1.0f;
static float lastYOffset = -1.0f;
if (Grid& grid = Grid::getInstance(); selectedWaypointIndex != lastSelectedWaypoint ||
cellColorSource != lastCellColorSource ||
grid.spacing != lastSpacing ||
grid.xOffset != lastXOffset ||
grid.yOffset != lastYOffset) {
airgDirty = true;
lastSelectedWaypoint = selectedWaypointIndex;
lastCellColorSource = cellColorSource;
lastSpacing = grid.spacing;
lastXOffset = grid.xOffset;
lastYOffset = grid.yOffset;
}
if (airgDirty) {
std::vector<AirgVertex> triVerts;
std::vector<AirgVertex> lineVerts;
for (int i = 0; i < reasoningGrid->m_WaypointList.size(); i++) {
const Waypoint& waypoint = reasoningGrid->m_WaypointList[i];
bool selected = (i == selectedWaypointIndex);
// Grid Cells Logic
if (cellColorSource != OFF) {
float minX = reasoningGrid->m_Properties.vMin.x;
float minY = reasoningGrid->m_Properties.vMin.y;
float x = waypoint.xi * reasoningGrid->m_Properties.fGridSpacing + reasoningGrid->m_Properties.
fGridSpacing / 2 + minX;
float y = waypoint.yi * reasoningGrid->m_Properties.fGridSpacing + reasoningGrid->m_Properties.
fGridSpacing / 2 + minY;
float z = waypoint.vPos.z + 0.01f;
// Boundary
glm::vec4 boundaryColor(0.8, 0.8, 0.8, 0.6);
glm::vec3 p1(x - reasoningGrid->m_Properties.fGridSpacing / 2, z,
-(y - reasoningGrid->m_Properties.fGridSpacing / 2));
glm::vec3 p2(x - reasoningGrid->m_Properties.fGridSpacing / 2, z,
-(y + reasoningGrid->m_Properties.fGridSpacing / 2));
glm::vec3 p3(x + reasoningGrid->m_Properties.fGridSpacing / 2, z,
-(y + reasoningGrid->m_Properties.fGridSpacing / 2));
glm::vec3 p4(x + reasoningGrid->m_Properties.fGridSpacing / 2, z,
-(y - reasoningGrid->m_Properties.fGridSpacing / 2));
lineVerts.push_back({p1, glm::vec3(0, 1, 0), boundaryColor});
lineVerts.push_back({p2, glm::vec3(0, 1, 0), boundaryColor});
lineVerts.push_back({p2, glm::vec3(0, 1, 0), boundaryColor});
lineVerts.push_back({p3, glm::vec3(0, 1, 0), boundaryColor});
lineVerts.push_back({p3, glm::vec3(0, 1, 0), boundaryColor});
lineVerts.push_back({p4, glm::vec3(0, 1, 0), boundaryColor});
lineVerts.push_back({p4, glm::vec3(0, 1, 0), boundaryColor});
lineVerts.push_back({p1, glm::vec3(0, 1, 0), boundaryColor});
if (cellColorSource == VISION_DATA) {
const unsigned int colorRgb = (waypoint.nLayerIndex << 6) | 0x80000000;
unsigned char a = (colorRgb >> 24) & 0xFF;
unsigned char b = (colorRgb >> 16) & 0xFF;
unsigned char g = (colorRgb >> 8) & 0xFF;
unsigned char r = colorRgb & 0xFF;
glm::vec4 color(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
triVerts.push_back({p1, glm::vec3(0, 1, 0), color});
triVerts.push_back({p2, glm::vec3(0, 1, 0), color});
triVerts.push_back({p3, glm::vec3(0, 1, 0), color});
triVerts.push_back({p1, glm::vec3(0, 1, 0), color});
triVerts.push_back({p3, glm::vec3(0, 1, 0), color});
triVerts.push_back({p4, glm::vec3(0, 1, 0), color});
} else {
std::vector<uint8_t> data;
float size = 0;
if (cellColorSource == AIRG_BITMAP) {
size = 25;
for (int k = 0; k < 25; k++) {
data.push_back(waypoint.cellBitmap[k] * 255);
}
} else if (cellColorSource == LAYER) { // Render Vision Data
size = visibilityDataSize(reasoningGrid, i);
data = reasoningGrid->getWaypointVisionData(i);
}
float bw = reasoningGrid->m_Properties.fGridSpacing / sqrt(size);
int numBoxesPerSide = reasoningGrid->m_Properties.fGridSpacing / bw;
for (int byi = 0; byi < numBoxesPerSide; byi++) {
for (int bxi = 0; bxi < numBoxesPerSide; bxi++) {
float bx = x - reasoningGrid->m_Properties.fGridSpacing / 2 + bxi * bw;
float byRaw = (cellColorSource == AIRG_BITMAP)
? -(y - reasoningGrid->m_Properties.fGridSpacing / 2 + (byi + 1) * bw)
: -y - reasoningGrid->m_Properties.fGridSpacing / 2 + byi * bw;
uint8_t val = data[numBoxesPerSide * byi + bxi];
float c = val / 255.0f;
glm::vec4 cellColor = (cellColorSource == AIRG_BITMAP)
? glm::vec4(c, c, c, 0.3)
: glm::vec4(0.0, c, 0.0, 0.3);
float zChange = selected ? 0.001 : 0.01;
float zc = waypoint.vPos.z + zChange;
glm::vec3 cp1(bx, zc, byRaw);
glm::vec3 cp2(bx, zc, byRaw + bw);
glm::vec3 cp3(bx + bw, zc, byRaw + bw);
glm::vec3 cp4(bx + bw, zc, byRaw);
triVerts.push_back({cp1, glm::vec3(0, 1, 0), cellColor});
triVerts.push_back({cp2, glm::vec3(0, 1, 0), cellColor});
triVerts.push_back({cp3, glm::vec3(0, 1, 0), cellColor});
triVerts.push_back({cp1, glm::vec3(0, 1, 0), cellColor});
triVerts.push_back({cp3, glm::vec3(0, 1, 0), cellColor});
triVerts.push_back({cp4, glm::vec3(0, 1, 0), cellColor});
}
}
}
}
// Waypoint
glm::vec4 wpColor(0, 0, 1, 0.5);
addWaypointGeometry(triVerts, lineVerts, waypoint, selected, wpColor);
// Neighbors
for (int neighborIndex = 0; neighborIndex < waypoint.nNeighbors.size(); neighborIndex++) {
if (waypoint.nNeighbors[neighborIndex] != 65535 && waypoint.nNeighbors[neighborIndex] < reasoningGrid->
m_WaypointList.size()) {
const Waypoint& neighbor = reasoningGrid->m_WaypointList[waypoint.nNeighbors[neighborIndex]];
glm::vec3 pStart(waypoint.vPos.x, waypoint.vPos.z + 0.01f, -waypoint.vPos.y);
glm::vec3 pEnd(neighbor.vPos.x, neighbor.vPos.z + 0.01f, -neighbor.vPos.y);
lineVerts.push_back({pStart, glm::vec3(0, 1, 0), wpColor});
lineVerts.push_back({pEnd, glm::vec3(0, 1, 0), wpColor});
}
}
}
if (airgTriVao == 0) {
glGenVertexArrays(1, &airgTriVao);
}
if (airgTriVbo == 0) {
glGenBuffers(1, &airgTriVbo);
}
glBindVertexArray(airgTriVao);
glBindBuffer(GL_ARRAY_BUFFER, airgTriVbo);
glBufferData(GL_ARRAY_BUFFER, triVerts.size() * sizeof(AirgVertex), triVerts.data(), GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(AirgVertex), (void*)offsetof(AirgVertex, pos));
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(AirgVertex), (void*)offsetof(AirgVertex, normal));
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(AirgVertex), (void*)offsetof(AirgVertex, color));
airgTriCount = triVerts.size();
if (airgLineVao == 0) {
glGenVertexArrays(1, &airgLineVao);
}
if (airgLineVbo == 0) {
glGenBuffers(1, &airgLineVbo);
}
glBindVertexArray(airgLineVao);
glBindBuffer(GL_ARRAY_BUFFER, airgLineVbo);
glBufferData(GL_ARRAY_BUFFER, lineVerts.size() * sizeof(AirgVertex), lineVerts.data(), GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(AirgVertex), (void*)offsetof(AirgVertex, pos));
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(AirgVertex), (void*)offsetof(AirgVertex, normal));
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(AirgVertex), (void*)offsetof(AirgVertex, color));
airgLineCount = lineVerts.size();
glBindVertexArray(0);
airgDirty = false;
}
Renderer& renderer = Renderer::getInstance();
renderer.shader.use();
renderer.shader.setMat4("view", renderer.view);
renderer.shader.setMat4("projection", renderer.projection);
renderer.shader.setMat4("model", glm::mat4(1.0f));
renderer.shader.setBool("useFlatColor", true);
renderer.shader.setBool("useVertexColor", true);
if (airgTriCount > 0) {
glBindVertexArray(airgTriVao);
glDrawArrays(GL_TRIANGLES, 0, airgTriCount);
}
if (airgLineCount > 0) {
glBindVertexArray(airgLineVao);
glDrawArrays(GL_LINES, 0, airgLineCount);
}
glBindVertexArray(0);
renderer.shader.setBool("useVertexColor", false);
if (showAirgIndices) {
int numWaypoints = reasoningGrid->m_WaypointList.size();
for (size_t i = 0; i < numWaypoints; i++) {
const Waypoint& waypoint = reasoningGrid->m_WaypointList[i];
renderer.drawText(std::to_string(i), {waypoint.vPos.x, waypoint.vPos.z + 0.1f, -waypoint.vPos.y},
{1, .7f, .7f}, 20);
}
}
}
void Airg::renderAirgForHitTest() const {
if (showAirg && airgLoaded) {
if (airgHitTestDirty) {
std::vector<AirgVertex> triVerts;
std::vector<AirgVertex> lineVerts; // Unused for hit test, but needed for helper
const int numWaypoints = reasoningGrid->m_WaypointList.size();
for (size_t i = 0; i < numWaypoints; i++) {
const Waypoint& waypoint = reasoningGrid->m_WaypointList[i];
const float r = static_cast<float>(AIRG_WAYPOINT) / 255.0f;
const float g = static_cast<float>(i >> 8 & 0xFF) / 255.0f;
const float b = static_cast<float>(i & 0xFF) / 255.0f;
glm::vec4 color(r, g, b, 1.0f);
addWaypointGeometry(triVerts, lineVerts, waypoint, true, color, true);
}
if (airgHitTestVao == 0) {
glGenVertexArrays(1, &airgHitTestVao);
}
if (airgHitTestVbo == 0) {
glGenBuffers(1, &airgHitTestVbo);
}
glBindVertexArray(airgHitTestVao);
glBindBuffer(GL_ARRAY_BUFFER, airgHitTestVbo);
glBufferData(GL_ARRAY_BUFFER, triVerts.size() * sizeof(AirgVertex), triVerts.data(), GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(AirgVertex), (void*)offsetof(AirgVertex, pos));
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(AirgVertex), (void*)offsetof(AirgVertex, normal));
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(AirgVertex), (void*)offsetof(AirgVertex, color));
airgHitTestCount = triVerts.size();
glBindVertexArray(0);
airgHitTestDirty = false;
}
const Renderer& renderer = Renderer::getInstance();
renderer.shader.use();
renderer.shader.setMat4("view", renderer.view);
renderer.shader.setMat4("projection", renderer.projection);
renderer.shader.setMat4("model", glm::mat4(1.0f));
renderer.shader.setBool("useFlatColor", true);
renderer.shader.setBool("useVertexColor", true);
glBindVertexArray(airgHitTestVao);
glDrawArrays(GL_TRIANGLES, 0, airgHitTestCount);
glBindVertexArray(0);
renderer.shader.setBool("useVertexColor", false);
}
}
void Airg::setSelectedAirgWaypointIndex(const int index) {
if (connectWaypointModeEnabled) {
connectWaypointModeEnabled = false;
Logger::log(NK_INFO, "Exiting Connect Waypoint mode.");
}
if (index == -1 && selectedWaypointIndex != -1) {
Logger::log(NK_INFO, ("Deselected waypoint: " + std::to_string(selectedWaypointIndex)).c_str());
}
airgDirty = true;
selectedWaypointIndex = index;
if (index != -1 && index < reasoningGrid->m_WaypointList.size()) {
const Waypoint waypoint = reasoningGrid->m_WaypointList[index];
std::string msg = "Selected Airg Waypoint " + std::to_string(index);
for (int i = 0; i < waypoint.nNeighbors.size(); i++) {
const int neighborIndex = waypoint.nNeighbors[i];
if (neighborIndex != 65535) {
msg += ": Neighbor " + std::to_string(i) + ": " + std::to_string(neighborIndex);
}
}
Logger::log(NK_INFO, msg.c_str());
Logger::log(NK_INFO,
("Waypoint position: X: " + std::to_string(waypoint.vPos.x) + " Y: " +
std::to_string(waypoint.vPos.y) + " Z: " + std::to_string(waypoint.vPos.z) + " XI: " +
std::to_string(waypoint.xi) + " YI: " + std::to_string(waypoint.yi) + " ZI: " + std::to_string(
waypoint.zi)).c_str());
msg = " Vision Data Offset: " + std::to_string(waypoint.nVisionDataOffset);
msg += " Layer Index: " + std::to_string(waypoint.nLayerIndex);
const int nextWaypointOffset = (index + 1) < reasoningGrid->m_WaypointList.size()
? reasoningGrid->m_WaypointList[index + 1].nVisionDataOffset
: reasoningGrid->m_pVisibilityData.size();
const int visibilityDataSize = nextWaypointOffset - waypoint.nVisionDataOffset;
msg += " Visibility Data size: " + std::to_string(visibilityDataSize);
const std::vector<uint8_t> waypointVisibilityData = reasoningGrid->getWaypointVisionData(index);
if (!waypointVisibilityData.empty()) {
std::string waypointVisibilityDataString;
char numHex[3];
msg += " Visibility Data Type: " + std::to_string(waypointVisibilityData[0]); // +" Visibility data:";
Logger::log(NK_INFO, msg.c_str());
for (int count = 2; count < waypointVisibilityData.size(); count++) {
const uint8_t num = waypointVisibilityData[count];
sprintf(numHex, "%02X", num);
if (numHex[0] == '0' && numHex[1] == '0') {
numHex[0] = '~';
numHex[1] = '~';
}
waypointVisibilityDataString += std::string{numHex};
waypointVisibilityDataString += " ";
if ((count - 1) % 8 == 0) {
waypointVisibilityDataString += " ";
}
if ((count - 1) % 96 == 0) {
//Logger::log(RC_LOG_PROGRESS, (" " + waypointVisibilityDataString).c_str());
waypointVisibilityDataString = "";
}
}
}
//Logger::log(RC_LOG_PROGRESS, (" " + waypointVisibilityDataString).c_str());
const unsigned int colorRgb = (waypoint.nLayerIndex << 6) | 0xC0000000;
const std::string hexColor = std::format("{:x}", colorRgb);
Logger::log(NK_INFO, ("Layer Index RGB " + hexColor).c_str());
}
Menu::updateMenuState();
}
void Airg::saveAirg(Airg* airg, const std::string& fileName, const bool isJson) {
airg->airgSaveState.push_back(true);
std::string outputFileName = std::filesystem::path(fileName).string();
const std::time_t startTime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::string msg = "Saving Airg to file at ";
msg += std::ctime(&startTime);
Logger::log(NK_INFO, msg.data());
const auto start = std::chrono::high_resolution_clock::now();
std::string tempJsonFile = fileName;
tempJsonFile += ".temp.json";
if (!isJson) {
outputFileName = std::filesystem::path(tempJsonFile).string();
}
std::filesystem::remove(outputFileName);
// Write the airg to JSON file
std::ofstream fileOutputStream(outputFileName);
airg->reasoningGrid->writeJson(fileOutputStream);
fileOutputStream.close();
if (!isJson) {
airg->airgResourceGenerator->FromJsonFileToResourceFile(tempJsonFile.data(), std::string{fileName}.c_str(),
false);
std::filesystem::remove(tempJsonFile);
}
const auto end = std::chrono::high_resolution_clock::now();
const auto duration = std::chrono::duration_cast<std::chrono::seconds>(end - start);
msg = "Finished saving Airg to " + std::string{fileName} + " in ";
msg += std::to_string(duration.count());
msg += " seconds";
Logger::log(NK_INFO, msg.data());
airg->airgSaveState.push_back(true);
}
void Airg::loadAirg(Airg* airg, const std::string& fileName, const bool isFromJson) {
airg->airgLoading = true;
airg->airgLoaded = false;
Menu::updateMenuState();
const std::time_t start_time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::string msg = "Loading Airg from file at ";
msg += std::ctime(&start_time);
Logger::log(NK_INFO, msg.data());
const auto start = std::chrono::high_resolution_clock::now();
std::string jsonFileName = fileName;
if (!isFromJson) {
const std::string nameWithoutExtension = jsonFileName.substr(0, jsonFileName.length() - 5);
jsonFileName = nameWithoutExtension + ".temp.airg.json";
airg->airgResourceConverter->FromResourceFileToJsonFile(fileName.data(), jsonFileName.data());
}
airg->reasoningGrid->readJson(jsonFileName.data());
Grid::getInstance().saveSpacing(airg->reasoningGrid->m_Properties.fGridSpacing);
if (!isFromJson) {
std::filesystem::remove(jsonFileName);
}
int lastVisionDataSize = 0;
int count = 1;
int total = 0;
std::map<int, int> visionDataOffsetCounts;
for (int i = 1; i < airg->reasoningGrid->m_WaypointList.size(); i++) {
const Waypoint w1 = airg->reasoningGrid->m_WaypointList[i - 1];
const Waypoint w2 = airg->reasoningGrid->m_WaypointList[i];
int visionDataSize = w2.nVisionDataOffset - w1.nVisionDataOffset;
total += visionDataSize;
if (lastVisionDataSize != visionDataSize) {
lastVisionDataSize = visionDataSize;
Logger::log(NK_INFO,
("Vision Data Offset[" + std::to_string(i - 1) + "]: " +
std::to_string(w1.nVisionDataOffset) + " Vision Data Offset[" + std::to_string(i) + "]: "
+ std::to_string(w2.nVisionDataOffset) + " Difference : " +
std::to_string(lastVisionDataSize) + " Count: " + std::to_string(count)).c_str());
if (visionDataOffsetCounts.contains(visionDataSize)) {
const int cur = visionDataOffsetCounts[visionDataSize];
visionDataOffsetCounts[visionDataSize] = cur + 1;
} else {
visionDataOffsetCounts[visionDataSize] = 1;
}
count = 1;
} else {
count++;
}
}
const int finalVisionDataSize = airg->reasoningGrid->m_pVisibilityData.size() - airg->reasoningGrid->m_WaypointList[
airg->reasoningGrid->m_WaypointList.size() - 1].nVisionDataOffset;
Logger::log(NK_DEBUG,
("Vision Data Offset[" + std::to_string(airg->reasoningGrid->m_WaypointList.size() - 1) + "]: " +
std::to_string(
airg->reasoningGrid->m_WaypointList[airg->reasoningGrid->m_WaypointList.size() - 1].
nVisionDataOffset) + " Max Visibility: " + std::to_string(
airg->reasoningGrid->m_pVisibilityData.size()) + " Difference : " + std::to_string(
finalVisionDataSize)).c_str());
total += finalVisionDataSize;
Logger::log(NK_DEBUG,
("Total: " + std::to_string(total) + " Max Visibility: " + std::to_string(
airg->reasoningGrid->m_pVisibilityData.size())).c_str());
Logger::log(NK_DEBUG, "Visibility data offset map:");
for (const auto& pair : visionDataOffsetCounts) {
VisionData visionData = VisionData::GetVisionDataType(pair.first);
Logger::log(NK_DEBUG,
("Offset difference: " + std::to_string(pair.first) + " Color: " + visionData.getName() +
" Count: " + std::to_string(pair.second)).c_str());
}
const auto end = std::chrono::high_resolution_clock::now();
const auto duration = std::chrono::duration_cast<std::chrono::seconds>(end - start);
msg = "Finished loading Airg in ";
msg += std::to_string(duration.count());
msg += " seconds";
Logger::log(NK_INFO, msg.data());
Logger::log(NK_INFO,
("Waypoint count: " + std::to_string(airg->reasoningGrid->m_WaypointList.size()) +
", Visibility Data size: " + std::to_string(airg->reasoningGrid->m_pVisibilityData.size()) +
", Visibility Data points per waypoint: " + std::to_string(
static_cast<double>(airg->reasoningGrid->m_pVisibilityData.size()) / static_cast<double>(airg
->reasoningGrid->m_WaypointList.size()))).c_str());
airg->airgLoading = false;
airg->airgLoaded = true;
airgDirty = true;
airgHitTestDirty = true;
Grid::getInstance().loadBoundsFromAirg();
Menu::updateMenuState();
}
void Airg::updateAirgDialogControls(const HWND hwnd) {
const auto hWndComboBox = GetDlgItem(hwnd, IDC_COMBOBOX_AIRG);
SendMessage(hWndComboBox, CB_RESETCONTENT, 0, 0);
if (!airgHashIoiStringMap.empty()) {
std::vector<std::pair<std::string, std::string>> sorted_hash_ioi_string_pairs(
airgHashIoiStringMap.begin(), airgHashIoiStringMap.end());
auto comparator = [](const std::pair<std::string, std::string>& a,
const std::pair<std::string, std::string>& b) {
if (a.second != b.second) {
return a.second < b.second;
}
return a.first < b.first;
};
std::ranges::sort(sorted_hash_ioi_string_pairs, comparator);
for (auto& [hash, ioiString] : sorted_hash_ioi_string_pairs) {
std::string listItemString;
if (!ioiString.empty()) {
listItemString = ioiString;
} else {
listItemString = hash;
}
SendMessage(hWndComboBox, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(listItemString.c_str()));
if (selectedRpkgAirg.empty()) {
selectedRpkgAirg = ioiString;
}
}
SendMessage(hWndComboBox, CB_SETCURSEL, 0, 0);
}
}
void Airg::extractAirgFromRpkgs(const std::string& hash) {
if (!Rpkg::extractResourcesFromRpkgs({hash}, AIRG)) {
const std::string fileName = NavKitSettings::getInstance().outputFolder + "\\airg\\" + hash + ".AIRG";
Logger::log(NK_INFO, ("Loading airg from file: " + fileName).c_str());
getInstance().loadAirgFromFile(fileName);
}
}
INT_PTR CALLBACK Airg::extractAirgDialogProc(const HWND hDlg, const UINT message, const WPARAM wParam,
const LPARAM lParam) {
Airg* pAirg = nullptr;
if (message == WM_INITDIALOG) {
pAirg = reinterpret_cast<Airg*>(lParam);
SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(pAirg));
} else {
pAirg = reinterpret_cast<Airg*>(GetWindowLongPtr(hDlg, DWLP_USER));
}
if (!pAirg) {
return FALSE;
}
switch (message) {
case WM_INITDIALOG:
updateAirgDialogControls(hDlg);
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == CBN_SELCHANGE) {
const int ItemIndex = SendMessage(reinterpret_cast<HWND>(lParam), CB_GETCURSEL,
0, 0);
char ListItem[256];
SendMessage(reinterpret_cast<HWND>(lParam), CB_GETLBTEXT, static_cast<WPARAM>(ItemIndex), (LPARAM)ListItem);
selectedRpkgAirg = ListItem;
return TRUE;
}
if (const UINT commandId = LOWORD(wParam); commandId == IDC_BUTTON_LOAD_AIRG_FROM_RPKG) {
for (auto& [hash, ioiString] : airgHashIoiStringMap) {
if (hash == selectedRpkgAirg) {
getInstance().loadedAirgText = hash;
} else if (ioiString == selectedRpkgAirg) {
getInstance().loadedAirgText = ioiString;
} else {
continue;
}
extractAirgFromRpkgs(hash);
}
DestroyWindow(hDlg);
return TRUE;
} else if (commandId == IDCANCEL) {
DestroyWindow(hDlg);
return TRUE;
}
return TRUE;
case WM_CLOSE:
DestroyWindow(hDlg);
return TRUE;
case WM_DESTROY:
hAirgDialog = nullptr;
return TRUE;
default: ;
}
return FALSE;
}
void Airg::showExtractAirgDialog() {
if (hAirgDialog) {
SetForegroundWindow(hAirgDialog);
return;
}
HINSTANCE hInstance = nullptr;
if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCSTR)&Airg::extractAirgDialogProc, &hInstance)) {
Logger::log(NK_ERROR, "GetModuleHandleEx failed.");
return;
}
const HWND hParentWnd = Renderer::hwnd;
hAirgDialog = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_EXTRACT_AIRG_DIALOG), hParentWnd,