-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFollowMeDlg.cpp
236 lines (212 loc) · 5.59 KB
/
FollowMeDlg.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
#include "VesselBuilder1.h"
#include "resource.h"
#include "DialogControl.h"
#include "FollowMeDlg.h"
#pragma comment(lib, "comctl32.lib")
extern HINSTANCE hDLL;
BOOL CALLBACK FollowMeDlgProcHook(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
FollowMeDlg *FollowMeDLG = (uMsg == WM_INITDIALOG ? (FollowMeDlg*)lParam : (FollowMeDlg*)oapiGetDialogContext(hWnd));
return FollowMeDLG->DlgProc(hWnd, uMsg, wParam, lParam);
}
FollowMeDlg::FollowMeDlg(VesselBuilder1 *_VB1) {
VB1 = _VB1;
open = false;
hDlg = NULL;
}
FollowMeDlg::~FollowMeDlg() {
VB1 = NULL;
hDlg = NULL;
open = false;
}
void FollowMeDlg::Open(HINSTANCE hDLL) {
hDlg = oapiOpenDialogEx(hDLL, IDD_DIALOG_FOLLOWME, FollowMeDlgProcHook, DLG_CAPTIONHELP | DLG_CAPTIONCLOSE, this);
open = true;
}
void FollowMeDlg::Close() {
open = false;
oapiCloseDialog(hDlg);
hDlg = NULL;
}
bool FollowMeDlg::IsOpen() {
return open;
}
void FollowMeDlg::UpdatePosDirRot() {
char cbuf[256] = { '\0' };
sprintf(cbuf, "%.5f %.5f %.5f", VB1->follow_me_pos.x, VB1->follow_me_pos.y, VB1->follow_me_pos.z);
SetDlgItemText(hDlg, IDC_EDIT_FMPOS, (LPCSTR)cbuf);
sprintf(cbuf, "%.3f %.3f %.3f", VB1->follow_me_dir.x, VB1->follow_me_dir.y, VB1->follow_me_dir.z);
SetDlgItemText(hDlg, IDC_EDIT_FMDIR, (LPCSTR)cbuf);
sprintf(cbuf, "%.3f %.3f %.3f", VB1->follow_me_rot.x, VB1->follow_me_rot.y, VB1->follow_me_rot.z);
SetDlgItemText(hDlg, IDC_EDIT_FMROT, (LPCSTR)cbuf);
return;
}
BOOL FollowMeDlg::DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_INITDIALOG:
{
InitCommonControls();
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_FMPOS), false);
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_FMDIR), false);
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_FMROT), false);
SendDlgItemMessage(hWnd, IDC_SPIN_FMX, UDM_SETRANGE32, -10000, 10000);
SendDlgItemMessage(hWnd, IDC_SPIN_FMY, UDM_SETRANGE32, -10000, 10000);
SendDlgItemMessage(hWnd, IDC_SPIN_FMZ, UDM_SETRANGE32, -10000, 10000);
SendDlgItemMessage(hWnd, IDC_SPIN_FMPITCH, UDM_SETRANGE32, -10000, 10000);
SendDlgItemMessage(hWnd, IDC_SPIN_FMROLL, UDM_SETRANGE32, -10000, 10000);
SendDlgItemMessage(hWnd, IDC_SPIN_FMYAW, UDM_SETRANGE32, -10000, 10000);
SendDlgItemMessage(hWnd, IDC_SLIDER_FMSPEED, TBM_SETRANGE, (WPARAM)false, MAKELPARAM(1, 100));
UpdatePosDirRot();
break;
}
case WM_COMMAND:
{
switch (LOWORD(wParam)) {
case ID_EXIT:
{
VB1->DeleteFollowMe();
break;
}
case IDC_FMRESET:
{
VB1->ResetFollowMe();
break;
}
case ID_COPYVS:
{
VB1->vclip.pos = VB1->follow_me_pos;
VB1->vclip.dir = VB1->follow_me_dir;
VB1->vclip.rot = VB1->follow_me_rot;
VB1->vclip.valid = true;
break;
}
case IDC_CHECK_FOLLWOMESUPERPREC:
{
if (HIWORD(wParam) == BN_CLICKED) {
VB1->ToggleFollowMeSuprePrecision();
}
break;
}
}
break;
}
case WM_NOTIFY:
{
switch (LOWORD(wParam))
{
case IDC_SPIN_FMX:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
if (lpd->iDelta > 0) {
VB1->MoveFollowMe(_V(1, 0, 0));
}
else if (lpd->iDelta < 0) {
VB1->MoveFollowMe(_V(-1, 0, 0));
}
UpdatePosDirRot();
SendDlgItemMessage(hWnd, IDC_SPIN_FMX, UDM_SETPOS, 0, 0);
}
break;
}
case IDC_SPIN_FMY:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
if (lpd->iDelta > 0) {
VB1->MoveFollowMe(_V(0, 1, 0));
}
else if (lpd->iDelta < 0) {
VB1->MoveFollowMe(_V(0, -1, 0));
}
UpdatePosDirRot();
SendDlgItemMessage(hWnd, IDC_SPIN_FMY, UDM_SETPOS, 0, 0);
}
break;
}
case IDC_SPIN_FMZ:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
if (lpd->iDelta > 0) {
VB1->MoveFollowMe(_V(0, 0, 1));
}
else if (lpd->iDelta < 0) {
VB1->MoveFollowMe(_V(0, 0, -1));
}
UpdatePosDirRot();
SendDlgItemMessage(hWnd, IDC_SPIN_FMZ, UDM_SETPOS, 0, 0);
}
break;
}
case IDC_SPIN_FMPITCH:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
if (lpd->iDelta > 0) {
VB1->RotateFollowMe(_V(-1, 0, 0));
}
else if (lpd->iDelta < 0) {
VB1->RotateFollowMe(_V(1, 0, 0));
}
UpdatePosDirRot();
SendDlgItemMessage(hWnd, IDC_SPIN_FMPITCH, UDM_SETPOS, 0, 0);
}
break;
}
case IDC_SPIN_FMYAW:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
if (lpd->iDelta > 0) {
VB1->RotateFollowMe(_V(0, 1, 0));
}
else if (lpd->iDelta < 0) {
VB1->RotateFollowMe(_V(0, -1, 0));
}
UpdatePosDirRot();
SendDlgItemMessage(hWnd, IDC_SPIN_FMYAW, UDM_SETPOS, 0, 0);
}
break;
}
case IDC_SPIN_FMROLL:
{
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
{
LPNMUPDOWN lpd = (LPNMUPDOWN)lParam;
if (lpd->iDelta > 0) {
VB1->RotateFollowMe(_V(0, 0, -1));
}
else if (lpd->iDelta < 0) {
VB1->RotateFollowMe(_V(0, 0, 1));
}
UpdatePosDirRot();
SendDlgItemMessage(hWnd, IDC_SPIN_FMROLL, UDM_SETPOS, 0, 0);
}
break;
}
//case IDC_SLIDER_FMSPEED:
//{
// LRESULT result = SendDlgItemMessage(hWnd, IDC_SLIDER_FMSPEED, TBM_GETPOS, 0, 0);
// sprintf(oapiDebugString(), "%i", result);
// break;
//}
break;
}
}
case WM_HSCROLL:
{
if (lParam == (LPARAM)GetDlgItem(hWnd, IDC_SLIDER_FMSPEED)) {
LRESULT result = SendDlgItemMessage(hWnd, IDC_SLIDER_FMSPEED, TBM_GETPOS, 0, 0);
VB1->follow_me_translation_speed = (double)result*50;
VB1->follow_me_rotation_speed = (double)result*RAD*50;
break;
}
}
}
return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}