-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSettings_Viewer.cpp
128 lines (107 loc) · 3.5 KB
/
Settings_Viewer.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
#include "stdafx.h"
#include "Axis3.h"
#include "Settings_Viewer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
CSettingViewer::CSettingViewer(CWnd* pParent /*=NULL*/)
: CDialogEx(CSettingViewer::IDD, pParent)
{
m_bItemViewScale = GetSettingNum(_T("ViewerScaleItems"));
m_bMultiViewScale = GetSettingNum(_T("ViewerScaleMultis"));
m_dwItemBGColor = GetSettingNum(_T("ViewerBGColor"));
}
void CSettingViewer::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Check(pDX, IDC_ITEMVIEW_SCALE, m_bItemViewScale);
DDX_Check(pDX, IDC_MULTIVIEW_SCALE, m_bMultiViewScale);
DDX_Control(pDX, IDC_VIEWERBG_COLOR, m_csBGColor);
}
BEGIN_MESSAGE_MAP(CSettingViewer, CDialogEx)
ON_BN_CLICKED(IDC_RESET_ITEM_CACHE, OnResetItemCache)
ON_BN_CLICKED(IDC_RESET_MULTI_CACHE, OnResetMultiCache)
ON_BN_CLICKED(IDC_RESET_MAP_CACHE, OnResetMapCache)
ON_BN_CLICKED(IDC_VIEWERBG_COLOR, OnBGColor)
ON_BN_CLICKED(IDC_ITEMVIEW_SCALE, OnScaleItems)
ON_BN_CLICKED(IDC_MULTIVIEW_SCALE, OnScaleMultis)
ON_BN_CLICKED(IDC_RESET_BGCOL, OnResetBGColor)
ON_WM_PAINT()
END_MESSAGE_MAP()
BOOL CSettingViewer::OnInitDialog()
{
CDialogEx::OnInitDialog();
Axis->DBLng.BeginTransaction();
SetWindowText(CMsg(_T("Viewer Settings")));
GetDlgItem(IDC_RESET_ITEM_CACHE)->SetWindowText(CMsg(_T("Reset Item Cache")));
GetDlgItem(IDC_RESET_MULTI_CACHE)->SetWindowText(CMsg(_T("Reset Multi Cache")));
GetDlgItem(IDC_RESET_MAP_CACHE)->SetWindowText(CMsg(_T("Reset Map Cache")));
GetDlgItem(IDC_ITEMVIEW_SCALE)->SetWindowText(CMsg(_T("Scale Items in Viewer")));
GetDlgItem(IDC_MULTIVIEW_SCALE)->SetWindowText(CMsg(_T("Scale Multis in Viewer")));
GetDlgItem(IDC_VIEWERBGCOL)->SetWindowText(CMsg(_T("Background Color")));
Axis->DBLng.CommitTransaction();
UpdateData(false);
return TRUE;
}
void CSettingViewer::OnResetItemCache()
{
if ( AfxMessageBox(CMsg(_T("Are you sure you want to reset the Items cache?")), MB_OKCANCEL | MB_ICONQUESTION) == IDCANCEL )
return;
ClearDirectory(_T("%1/Art/Static/"));
}
void CSettingViewer::OnResetMultiCache()
{
if (AfxMessageBox(CMsg(_T("Are you sure you want to reset the Multis cache?")), MB_OKCANCEL | MB_ICONQUESTION) == IDCANCEL)
return;
ClearDirectory(_T("%1/Art/Multi/"));
}
void CSettingViewer::OnResetMapCache()
{
if (AfxMessageBox(CMsg(_T("Are you sure you want to reset the Maps cache?")), MB_OKCANCEL | MB_ICONQUESTION) == IDCANCEL)
return;
ClearDirectory(_T("%1/Art/Map/"));
}
void CSettingViewer::OnResetBGColor()
{
ClearSetting(_T("ViewerBGColor"));
m_dwItemBGColor = GetSettingNum(_T("ViewerBGColor"));
SendMessage(WM_PAINT);
}
void CSettingViewer::OnScaleItems()
{
UpdateData();
SetSettingNum(_T("ViewerScaleItems"), m_bItemViewScale);
}
void CSettingViewer::OnScaleMultis()
{
UpdateData();
SetSettingNum(_T("ViewerScaleMultis"), m_bMultiViewScale);
}
void CSettingViewer::OnBGColor()
{
CColorDialog colors;
if ( colors.DoModal() == IDOK )
m_dwItemBGColor = colors.GetColor();
SendMessage( WM_PAINT );
SetSettingNum(_T("ViewerBGColor"), m_dwItemBGColor);
}
void CSettingViewer::OnPaint()
{
CPaintDC dc(this);
CDC * pDC = m_csBGColor.GetDC();
CRgn rgn;
CRect rect;
m_csBGColor.GetWindowRect( &rect );
CBrush * pNewBrush = new (CBrush);
pNewBrush->CreateSolidBrush( (COLORREF) m_dwItemBGColor );
CBrush * pOldBrush = pDC->SelectObject(pNewBrush);
CRect cr;
m_csBGColor.GetClientRect(&cr);
rgn.CreateRectRgnIndirect(cr);
pDC->SelectClipRgn(&rgn);
pDC->FillRect(cr, pNewBrush);
pDC->SelectObject(pOldBrush);
delete (pNewBrush);
rgn.DeleteObject();
m_csBGColor.ReleaseDC( pDC );
}