-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockDlgProc.cpp
302 lines (275 loc) · 9.02 KB
/
DockDlgProc.cpp
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
#include "VesselBuilder1.h"
#include "resource.h"
#include "LaserManager.h"
#include "DialogControl.h"
#include "DockManager.h"
#include "AnimationManager.h"
#pragma comment(lib, "comctl32.lib")
#define LogV(x,...) VB1->Log->Log(x,##__VA_ARGS__)
void DialogControl::UpdateDockDialog(HWND hWnd) {
if (CurrentSelection.idx >= DckMng->GetDockCount()) { return; }
char cbuf[256] = { '\0' };
sprintf(cbuf, "%s", DckMng->GetDockName(CurrentSelection.idx).c_str());
SetDlgItemText(hWnd, IDC_EDIT_DOCKNAME, (LPCSTR)cbuf);
VECTOR3 pos, dir, rot;
DckMng->GetDockParams(CurrentSelection.idx, pos, dir, rot);
SetDlgItemsTextVector3(hWnd, IDC_EDIT_DOCKPOSX, IDC_EDIT_DOCKPOSY, IDC_EDIT_DOCKPOSZ, pos);
SetDlgItemsTextVector3(hWnd, IDC_EDIT_DOCKDIRX, IDC_EDIT_DOCKDIRY, IDC_EDIT_DOCKDIRZ, dir);
SetDlgItemsTextVector3(hWnd, IDC_EDIT_DOCKROTX, IDC_EDIT_DOCKROTY, IDC_EDIT_DOCKROTZ, rot);
bool jett = DckMng->IsDockJettisonable(CurrentSelection.idx);
if (jett) {
SendDlgItemMessage(hWnd, IDC_CHECK_DOCKJETT, BM_SETCHECK, BST_CHECKED, 0);
}
else {
SendDlgItemMessage(hWnd, IDC_CHECK_DOCKJETT, BM_SETCHECK, BST_UNCHECKED, 0);
}
if (DockLaserMap[CurrentSelection.idx] != NULL) {
SendDlgItemMessage(hWnd, IDC_CHECK_HIGHLIGHT_DOCK, BM_SETCHECK, BST_CHECKED, 0);
}
else {
SendDlgItemMessage(hWnd, IDC_CHECK_HIGHLIGHT_DOCK, BM_SETCHECK, BST_UNCHECKED, 0);
}
SendDlgItemMessage(hWnd, IDC_COMBO_DCKSDANI, CB_RESETCONTENT, 0, 0);
for (UINT i = 0; i < AnimMng->GetAnimDefsCount(); i++) {
int index = SendDlgItemMessage(hWnd, IDC_COMBO_DCKSDANI, CB_ADDSTRING, 0, (LPARAM)AnimMng->GetAnimName(i).c_str());
SendDlgItemMessage(hWnd, IDC_COMBO_DCKSDANI, CB_SETITEMDATA, index, (LPARAM)i);
}
bool sd;
double sd_distance;
UINT sd_anim;
DckMng->GetSoftDockParams(CurrentSelection.idx, sd, sd_distance, sd_anim);
SetCheckBox(hWnd, IDC_CHECK_DCKENABLSD, sd);
if (sd) {
SetDlgItemDouble(hWnd, IDC_EDIT_DCKSDDIST, sd_distance, 3);
int index = ComboFindItemData(GetDlgItem(hWnd, IDC_COMBO_DCKSDANI), (void*)sd_anim);
SendDlgItemMessage(hWnd, IDC_COMBO_DCKSDANI, CB_SETCURSEL, index, 0);
}
else {
SetDlgItemText(hWnd, IDC_EDIT_DCKSDDIST, (LPCSTR)"");
SendDlgItemMessage(hWnd, IDC_COMBO_DCKSDANI, CB_SETCURSEL, 0, 0);
}
//if (SB1->DockBeaconsActive) {
// SB1->UpdateDockBeaconsPos();
//}
return;
}
void DialogControl::DockNotify(HWND hWnd, WPARAM wParam, LPARAM lParam) {
switch (LOWORD(wParam))
{
case IDC_SPIN_DOCKROLL:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
double spd = 1 * RAD;
VECTOR3 axis = _V(0, 0, 1);
double angle = spd*(double)lpd->iDelta;
DckMng->RotateDock(CurrentSelection.idx, axis, angle);
UpdateDockDialog(hWnd);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKROLL, UDM_SETPOS, 0, 0);
}
break;
}
case IDC_SPIN_DOCKYAW:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
double spd = 1 * RAD;
VECTOR3 axis = _V(0, -1, 0);
double angle = spd*(double)lpd->iDelta;
DckMng->RotateDock(CurrentSelection.idx, axis, angle);
UpdateDockDialog(hWnd);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKYAW, UDM_SETPOS, 0, 0);
}
break;
}
case IDC_SPIN_DOCKPITCH:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
double spd = 1 * RAD;
VECTOR3 axis = _V(1, 0, 0);
double angle = spd*(double)lpd->iDelta;
DckMng->RotateDock(CurrentSelection.idx, axis, angle);
UpdateDockDialog(hWnd);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKPITCH, UDM_SETPOS, 0, 0);
}
break;
}
case IDC_SPIN_DOCKPOSX:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
double spd = 0.25;
VECTOR3 shift = _V(spd*(double)lpd->iDelta, 0, 0);
DckMng->MoveDock(CurrentSelection.idx, shift);
UpdateDockDialog(hWnd);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKPOSX, UDM_SETPOS, 0, 0);
}
break;
}
case IDC_SPIN_DOCKPOSY:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
double spd = 0.25;
VECTOR3 shift = _V(0,spd*(double)lpd->iDelta, 0);
DckMng->MoveDock(CurrentSelection.idx, shift);
UpdateDockDialog(hWnd);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKPOSY, UDM_SETPOS, 0, 0);
}
break;
}
case IDC_SPIN_DOCKPOSZ:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
double spd = 0.25;
VECTOR3 shift = _V(0, 0, spd*(double)lpd->iDelta);
DckMng->MoveDock(CurrentSelection.idx, shift);
UpdateDockDialog(hWnd);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKPOSZ, UDM_SETPOS, 0, 0);
}
break;
}
}
return;
}
BOOL DialogControl::DockDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_INITDIALOG:
{
//EnableWindow(GetDlgItem(hWnd, IDC_EDIT_DOCKNAME), false);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKPITCH, UDM_SETRANGE32, -10000, 10000);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKROLL, UDM_SETRANGE32, -10000, 10000);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKYAW, UDM_SETRANGE32, -10000, 10000);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKPOSX, UDM_SETRANGE32, -10000, 10000);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKPOSY, UDM_SETRANGE32, -10000, 10000);
SendDlgItemMessage(hWnd, IDC_SPIN_DOCKPOSZ, UDM_SETRANGE32, -10000, 10000);
break;
}
case WM_COMMAND:
{
switch (LOWORD(wParam)) {
case IDC_BUTTON_DELETEDOCKDEF:
{
if (DockLaserMap[CurrentSelection.idx] != NULL) {
VB1->Laser->DeleteLaser(DockLaserMap[CurrentSelection.idx]);
}
DckMng->DeleteDockDef(CurrentSelection.idx);
UpdateTree(hDlg, DOCK, CurrentSelection.config);
break;
}
case IDC_BTN_DOCKPASTEV:
{
if (VB1->vclip.valid) {
SetDlgItemsTextVector3(hWnd, IDC_EDIT_DOCKPOSX, IDC_EDIT_DOCKPOSY, IDC_EDIT_DOCKPOSZ, VB1->vclip.pos);
SetDlgItemsTextVector3(hWnd, IDC_EDIT_DOCKDIRX, IDC_EDIT_DOCKDIRY, IDC_EDIT_DOCKDIRZ, VB1->vclip.dir);
SetDlgItemsTextVector3(hWnd, IDC_EDIT_DOCKROTX, IDC_EDIT_DOCKROTY, IDC_EDIT_DOCKROTZ, VB1->vclip.rot);
}
break;
}
case IDC_BUTTON_DOCKPOS_SET:
{
// if (SB1->DockBeaconsActive) {
// SB1->DeleteDockBeacons();
// SendDlgItemMessage(hWnd, IDC_CHECK_HIGHLIGHT_DOCK, BM_SETCHECK, BST_UNCHECKED, 0);
// }
VECTOR3 pos = GetDlgItemsVector3(hWnd, IDC_EDIT_DOCKPOSX, IDC_EDIT_DOCKPOSY, IDC_EDIT_DOCKPOSZ);
DckMng->SetDockPos(CurrentSelection.idx, pos);
UpdateDockDialog(hWnd);
break;
}
case IDC_BUTTON_DOCKDIR_SET:
{
// if (SB1->DockBeaconsActive) {
// SB1->DeleteDockBeacons();
// SendDlgItemMessage(hWnd, IDC_CHECK_HIGHLIGHT_DOCK, BM_SETCHECK, BST_UNCHECKED, 0);
// }
VECTOR3 dir = GetDlgItemsVector3(hWnd, IDC_EDIT_DOCKDIRX, IDC_EDIT_DOCKDIRY, IDC_EDIT_DOCKDIRZ);
normalise(dir);
DckMng->SetDockDir(CurrentSelection.idx, dir);
UpdateDockDialog(hWnd);
break;
}
case IDC_BUTTON_DOCKROT_SET:
{
// if (SB1->DockBeaconsActive) {
// SB1->DeleteDockBeacons();
// SendDlgItemMessage(hWnd, IDC_CHECK_HIGHLIGHT_DOCK, BM_SETCHECK, BST_UNCHECKED, 0);
// }
VECTOR3 rot = GetDlgItemsVector3(hWnd, IDC_EDIT_DOCKROTX, IDC_EDIT_DOCKROTY, IDC_EDIT_DOCKROTZ);
normalise(rot);
DckMng->SetDockRot(CurrentSelection.idx, rot);
UpdateDockDialog(hWnd);
break;
}
case IDC_CHECK_HIGHLIGHT_DOCK:
{
if (HIWORD(wParam) == BN_CLICKED) {
LRESULT getcheck = SendDlgItemMessage(hWnd, IDC_CHECK_HIGHLIGHT_DOCK, BM_GETCHECK, 0, 0);
if (getcheck == BST_CHECKED) {
DockLaserMap[CurrentSelection.idx] = VB1->Laser->CreateLaserL(DckMng->GetDockPosPtr(CurrentSelection.idx), DckMng->GetDockAntiDirPtr(CurrentSelection.idx), DckMng->GetDockAntiRotPtr(CurrentSelection.idx), LASER_GREEN_TEX, LASER_BLUE_TEX);
}
else {
VB1->Laser->DeleteLaser(DockLaserMap[CurrentSelection.idx]);
}
}
break;
}
case IDC_CHECK_DOCKJETT:
{
if (HIWORD(wParam) == BN_CLICKED) {
LRESULT getcheck = SendDlgItemMessage(hWnd, IDC_CHECK_DOCKJETT, BM_GETCHECK, 0, 0);
if (getcheck == BST_CHECKED) {
DckMng->SetIsDockJettisonable(CurrentSelection.idx, true);
}
else {
DckMng->SetIsDockJettisonable(CurrentSelection.idx, false);
}
}
break;
}
case IDC_BUTTON_DOCKNAMESET:
{
char cbuf[256] = { '\0' };
GetDlgItemText(hWnd, IDC_EDIT_DOCKNAME, cbuf, 256);
string newname(cbuf);
DckMng->SetDockName(CurrentSelection.idx, newname);
TVITEM tvi;
tvi.mask = TVIF_TEXT;
tvi.pszText = (LPSTR)cbuf;
tvi.cchTextMax = strlen(cbuf);
tvi.hItem = CurrentSelection.hitem;
SendDlgItemMessage(hDlg, IDC_TREE1, TVM_SETITEM, 0, (LPARAM)&tvi);
break;
}
case IDC_BUTTON_DCKSDSET:
{
bool check = IsCheckBoxChecked(hWnd, IDC_CHECK_DCKENABLSD);
double dist = 0;
UINT anim = 0;
if (check) {
dist = GetDlgItemDouble(hWnd, IDC_EDIT_DCKSDDIST);
int index = SendDlgItemMessage(hWnd, IDC_COMBO_DCKSDANI, CB_GETCURSEL, 0, 0);
anim = SendDlgItemMessage(hWnd, IDC_COMBO_DCKSDANI, CB_GETITEMDATA, index, 0);
}
DckMng->SetSoftDockParams(CurrentSelection.idx, check, dist, anim);
break;
}
}
break;
}
case WM_NOTIFY:
{
DockNotify(hWnd, wParam, lParam);
break;
}
}
return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}