-
Notifications
You must be signed in to change notification settings - Fork 477
/
OptionsUI.cpp
61 lines (56 loc) · 1.85 KB
/
OptionsUI.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
#include "OptionsUI.h"
#include "wtl.h"
#include "resource.h"
#include <Common\StdString.h>
class COptionsDlg :
public CDialogImpl<COptionsDlg>
{
public:
enum { IDD = IDD_Options };
BEGIN_MSG_MAP(COptionsDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDOK, OnOkCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
END_MSG_MAP()
COptionsDlg(uint32_t ControlIndex, CONTROL & ControlInfo, N64CONTROLLER & Controller) :
m_ControlIndex(ControlIndex),
m_ControlInfo(ControlInfo),
m_Controller(Controller)
{
}
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
CenterWindow(GetParent());
SetWindowText(stdstr_f("Options - Player %d", m_ControlIndex + 1).ToUTF16().c_str());
CButton(GetDlgItem(IDC_REAL_N64_RANGE)).SetCheck(m_Controller.RealN64Range ? BST_CHECKED : BST_UNCHECKED);
return TRUE;
}
LRESULT OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
bool bChanged = false;
bool RealN64Range = CButton(GetDlgItem(IDC_REAL_N64_RANGE)).GetCheck() == BST_CHECKED;
if (RealN64Range != m_Controller.RealN64Range)
{
m_Controller.RealN64Range = RealN64Range;
bChanged = true;
}
if (bChanged)
{
GetParent().SendMessage(PSM_CHANGED);
}
EndDialog(wID);
return 0;
}
LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
EndDialog(wID);
return 0;
}
uint32_t m_ControlIndex;
CONTROL & m_ControlInfo;
N64CONTROLLER & m_Controller;
};
void ConfigOption(uint32_t ControlIndex, CONTROL & ControlInfo, N64CONTROLLER & Controller)
{
COptionsDlg(ControlIndex, ControlInfo, Controller).DoModal();
}