-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBeaconDlgProc.cpp
148 lines (139 loc) · 4.53 KB
/
BeaconDlgProc.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
#include "VesselBuilder1.h"
#include "resource.h"
#include "DialogControl.h"
#include "LightsManager.h"
void DialogControl::UpdateBeaconsDialog(HWND hWnd) {
UINT idx = CurrentSelection.idx;
if (idx >= LightsMng->GetBeaconCount()) { return; }
char namebuf[256] = { '\0' };
sprintf(namebuf, LightsMng->GetBeaconName(idx).c_str());
SetDlgItemText(hWnd, IDC_EDIT_BCNNAME, namebuf);
DWORD shape;
VECTOR3 pos, col;
double size, falloff, period, duration, tofs;
LightsMng->GetBeaconParams(idx, shape, pos, col, size, falloff, period, duration, tofs);
int index = ComboFindItemData(GetDlgItem(hWnd, IDC_COMBO_BCNSHAPE), shape);
if (index != -1) { SendDlgItemMessage(hWnd, IDC_COMBO_BCNSHAPE, CB_SETCURSEL, index, 0); }
SetDlgItemsTextVector3(hWnd, IDC_EDIT_BCNPOSX, IDC_EDIT_BCNPOSY, IDC_EDIT_BCNPOSZ, pos);
SetDlgItemsTextVector3(hWnd, IDC_EDIT_BCNCOLR, IDC_EDIT_BCNCOLG, IDC_EDIT_BCNCOLB, col);
SetDlgItemDouble(hWnd, IDC_EDIT_BCNSIZE, size, 2);
SetDlgItemDouble(hWnd, IDC_EDIT_BCNFALLOFF, falloff, 2);
SetDlgItemDouble(hWnd, IDC_EDIT_BCNPERIOD, period, 2);
SetDlgItemDouble(hWnd, IDC_EDIT_BCNDURATION, duration, 2);
SetDlgItemDouble(hWnd, IDC_EDIT_BCNTOFS, tofs, 2);
if (LightsMng->IsBeaconActive(idx)) {
SetDlgItemText(hWnd, IDC_EDIT_BCNNOW, "ON");
}
else {
SetDlgItemText(hWnd, IDC_EDIT_BCNNOW, "OFF");
}
return;
}
BOOL DialogControl::BeaconsDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_INITDIALOG:
{
SendDlgItemMessage(hWnd, IDC_COMBO_BCNSHAPE, CB_RESETCONTENT, 0, 0);
SendDlgItemMessage(hWnd, IDC_COMBO_BCNSHAPE, CB_INSERTSTRING, 0, (LPARAM)"COMPACT");
SendDlgItemMessage(hWnd, IDC_COMBO_BCNSHAPE, CB_SETITEMDATA, 0, (LPARAM)BEACONSHAPE_COMPACT);
SendDlgItemMessage(hWnd, IDC_COMBO_BCNSHAPE, CB_INSERTSTRING, 1, (LPARAM)"DIFFUSE");
SendDlgItemMessage(hWnd, IDC_COMBO_BCNSHAPE, CB_SETITEMDATA, 1, (LPARAM)BEACONSHAPE_DIFFUSE);
SendDlgItemMessage(hWnd, IDC_COMBO_BCNSHAPE, CB_INSERTSTRING, 2, (LPARAM)"STAR");
SendDlgItemMessage(hWnd, IDC_COMBO_BCNSHAPE, CB_SETITEMDATA, 2, (LPARAM)BEACONSHAPE_STAR);
SendDlgItemMessage(hWnd, IDC_EDIT_BCNNOW, EM_SETREADONLY, true, 0);
break;
}
case WM_COMMAND:
{
UINT idx = CurrentSelection.idx;
switch (LOWORD(wParam)) {
case IDC_BUTTON_BCNNAMESET:
{
char cbuf[256] = { '\0' };
GetDlgItemText(hWnd, IDC_EDIT_BCNNAME, cbuf, 256);
string name(cbuf);
LightsMng->SetBeaconName(idx, name);
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_COMBO_BCNSHAPE:
{
if (HIWORD(wParam) == CBN_SELCHANGE) {
int index = SendDlgItemMessage(hWnd, IDC_COMBO_BCNSHAPE, CB_GETCURSEL, 0, 0);
DWORD shape = (DWORD)SendDlgItemMessage(hWnd, IDC_COMBO_BCNSHAPE, CB_GETITEMDATA, index, 0);
LightsMng->SetBeaconShape(idx, shape);
}
break;
}
case IDC_BUTTON_BCNPOSSET:
{
VECTOR3 pos = GetDlgItemsVector3(hWnd, IDC_EDIT_BCNPOSX, IDC_EDIT_BCNPOSY, IDC_EDIT_BCNPOSZ);
LightsMng->SetBeaconPos(idx, pos);
break;
}
case IDC_BUTTON_BCNPASTEV:
{
if (VB1->vclip.valid) {
SetDlgItemsTextVector3(hWnd, IDC_EDIT_BCNPOSX, IDC_EDIT_BCNPOSY, IDC_EDIT_BCNPOSZ, VB1->vclip.pos);
}
break;
}
case IDC_BUTTON_BCNCOLSET:
{
VECTOR3 col = GetDlgItemsVector3(hWnd, IDC_EDIT_BCNCOLR, IDC_EDIT_BCNCOLG, IDC_EDIT_BCNCOLB);
LightsMng->SetBeaconCol(idx, col);
break;
}
case IDC_BUTTON_BCNSIZESET:
{
double size = GetDlgItemDouble(hWnd, IDC_EDIT_BCNSIZE);
LightsMng->SetBeaconSize(idx, size);
break;
}
case IDC_BUTTON_BCNFALLOFFSET:
{
double falloff = GetDlgItemDouble(hWnd, IDC_EDIT_BCNFALLOFF);
LightsMng->SetBeaconFalloff(idx, falloff);
break;
}
case IDC_BUTTON_BCNPERIODSET:
{
double period = GetDlgItemDouble(hWnd, IDC_EDIT_BCNPERIOD);
LightsMng->SetBeaconPeriod(idx, period);
break;
}
case IDC_BUTTON_BCNDURATIONSET:
{
double duration = GetDlgItemDouble(hWnd, IDC_EDIT_BCNDURATION);
LightsMng->SetBeaconDuration(idx, duration);
break;
}
case IDC_BUTTON_BCNTOFSSET:
{
double tofs = GetDlgItemDouble(hWnd, IDC_EDIT_BCNTOFS);
LightsMng->SetBeaconTofs(idx, tofs);
break;
}
case IDC_BUTTON_BCNTOGGLE:
{
LightsMng->ToggleBeaconActive(idx);
UpdateBeaconsDialog(hWnd);
break;
}
case IDC_BUTTON_BCNDEL:
{
LightsMng->DeleteBeaconDef(idx);
UpdateTree(hDlg, BEACONS, CurrentSelection.config);
break;
}
}
break;
}
}
return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}