-
Notifications
You must be signed in to change notification settings - Fork 6
/
ToolTabNavigate.cpp
173 lines (141 loc) · 3.59 KB
/
ToolTabNavigate.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
// ToolTabNavigate.cpp : implementation file
//
#include "stdafx.h"
#include "sparkedit.h"
#include "ToolTabNavigate.h"
#include "Perspective.h"
#include "Render.h"
#include "BspManager.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CPerspective *g_pRenderWnd;
extern CRender gRender;
extern CBspManager gBspManager;
IMPLEMENT_DYNCREATE(CToolTabNavigate, CPropertyPage)
CToolTabNavigate::CToolTabNavigate() : CPropertyPage(CToolTabNavigate::IDD)
{
//{{AFX_DATA_INIT(CToolTabNavigate)
m_CameraSpeed = 0;
m_FindCoordX = 0.0f;
m_FindCoordY = 0.0f;
m_FindCoordZ = 0.0f;
m_SelectedBsp = -1;
//}}AFX_DATA_INIT
}
CToolTabNavigate::~CToolTabNavigate()
{
}
void CToolTabNavigate::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CToolTabNavigate)
DDX_Control(pDX, IDC_RENDER_MODE, m_RenderModeCombo);
DDX_Slider(pDX, IDC_TRAVEL_SPEED, m_CameraSpeed);
DDX_Text(pDX, IDC_FIND_COORD_X, m_FindCoordX);
DDX_Text(pDX, IDC_FIND_COORD_Y, m_FindCoordY);
DDX_Text(pDX, IDC_FIND_COORD_Z, m_FindCoordZ);
DDX_CBIndex(pDX, IDC_ACTIVE_BSP, m_SelectedBsp);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CToolTabNavigate, CPropertyPage)
//{{AFX_MSG_MAP(CToolTabNavigate)
ON_BN_CLICKED(IDC_FIND_COORD, OnFindCoord)
ON_BN_CLICKED(IDC_RESET_CAMERA, OnResetCamera)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_TRAVEL_SPEED, OnReleasedcaptureTravelSpeed)
ON_CBN_SELCHANGE(IDC_RENDER_MODE, OnSelchangeRenderMode)
ON_CBN_SELCHANGE(IDC_ACTIVE_BSP, OnSelchangeActiveBsp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CToolTabNavigate message handlers
void CToolTabNavigate::OnFindCoord()
{
UpdateData(TRUE);
gRender.SetFindCoord(m_FindCoordX, m_FindCoordY, m_FindCoordZ);
}
void CToolTabNavigate::OnResetCamera()
{
g_pRenderWnd->RefreshWindow();
}
void CToolTabNavigate::OnReleasedcaptureTravelSpeed(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
float scale = 1.0;
UpdateData(TRUE);
switch(m_CameraSpeed)
{
case 0:
scale = 0.1f;
break;
case 1:
scale = 0.2f;
break;
case 2:
scale = 0.4f;
break;
case 3:
scale = 0.8f;
break;
case 4:
scale = 1.5f;
break;
case 5:
scale = 2.5f;
break;
default:
scale = 1.5f;
break;
}
TRACE("scale = %f\n", scale);
g_pRenderWnd->SetCameraSpeed(scale);
}
BOOL CToolTabNavigate::OnInitDialog()
{
CSliderCtrl *pSlider;
CPropertyPage::OnInitDialog();
m_RenderModeCombo.SetCurSel(4);
pSlider = (CSliderCtrl*)GetDlgItem(IDC_TRAVEL_SPEED);
pSlider->SetRangeMin(0);
pSlider->SetRangeMax(5);
pSlider->SetTic(1);
pSlider->SetTic(2);
pSlider->SetTic(3);
pSlider->SetTic(4);
// pSlider->SetPos(4);
pSlider->SetTic(5);
m_CameraSpeed = 4;
Reset();
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CToolTabNavigate::OnSelchangeRenderMode()
{
int mode;
mode = m_RenderModeCombo.GetCurSel();
gRender.SetRenderMode((RENDER_MODE)mode);
g_pRenderWnd->SetFocus();
g_pRenderWnd->RedrawWindow();
}
void CToolTabNavigate::OnSelchangeActiveBsp()
{
UpdateData(TRUE);
gBspManager.ActivateBsp(m_SelectedBsp);
}
void CToolTabNavigate::Reset()
{
int i, bsp_count;
CComboBox *pBspList;
bsp_count = gBspManager.m_BspNames.GetSize();
pBspList = (CComboBox*)GetDlgItem(IDC_ACTIVE_BSP);
pBspList->ResetContent();
for(i=0; i<bsp_count; i++)
{
pBspList->AddString(gBspManager.m_BspNames[i]);
}
m_SelectedBsp = 0;
UpdateData(FALSE);
}