-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCannonBuilder.cpp
More file actions
151 lines (116 loc) · 3 KB
/
CannonBuilder.cpp
File metadata and controls
151 lines (116 loc) · 3 KB
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
// CannonBuilder.cpp : implementation file
//
#include "stdafx.h"
#include "WinDE.h"
#include "CannonBuilder.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CannonBuilder dialog
CannonBuilder::CannonBuilder(CWnd* pParent /*=NULL*/)
: CDialog(CannonBuilder::IDD, pParent)
{
//{{AFX_DATA_INIT(CannonBuilder)
accuracy = 0;
name = _T("");
vnum = 0;
price = 0;
power = 0;
range = 0;
filename = _T("");
//}}AFX_DATA_INIT
}
void CannonBuilder::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CannonBuilder)
DDX_Control(pDX, IDC_SHIPWRIGHTS, Shipwrights);
DDX_Text(pDX, IDC_ACCURACY, accuracy);
DDV_MinMaxInt(pDX, accuracy, 0, 100);
DDX_Text(pDX, IDC_NAME, name);
DDX_Text(pDX, IDC_OBJECT, vnum);
DDX_Text(pDX, IDC_PRICE, price);
DDX_Text(pDX, IDC_POWER, power);
DDX_Text(pDX, IDC_RANGE, range);
DDV_MinMaxInt(pDX, range, 0, 10);
DDX_Text(pDX, IDC_FILENAME, filename);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CannonBuilder, CDialog)
//{{AFX_MSG_MAP(CannonBuilder)
ON_BN_CLICKED(IDC_REMOVE, OnRemove)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_CALC, OnCalculator)
ON_BN_CLICKED(IDC_OBJ_LIST, OnObjectList)
ON_BN_CLICKED(IDOK, OnOK)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CannonBuilder message handlers
void CannonBuilder::OnAdd()
{
UpdateData(true);
shop_list.Add(Shipwrights);
UpdateData(false);
}
void CannonBuilder::OnCalculator()
{
UpdateData(true);
DlgCalcCoins dlg_coins(this);
if(dlg_coins.DoModal() == IDOK)
price = dlg_coins.total;
UpdateData(false);
}
void CannonBuilder::OnRemove()
{
shop_list.Remove(Shipwrights);
}
void CannonBuilder::OnObjectList()
{
UpdateData(true);
DlgVnumList vnum_list(this);
vnum_list.type = OBJECT;
if(vnum_list.DoModal() == IDOK)
vnum = vnum_list.vnum;
UpdateData(false);
}
void CannonBuilder::OnOK()
{
UpdateData(true);
if(cannon)
{
cannon->name = name;
cannon->value = price;
cannon->accuracy = accuracy;
cannon->power = power;
cannon->range = range;
cannon->obj_vnum = vnum;
cannon->filename = filename;
shop_list.Update(cannon->shops);
}
CDialog::OnOK();
}
BOOL CannonBuilder::OnInitDialog()
{
CDialog::OnInitDialog();
CRect rect;
DWORD dwStyle = ::SendMessage(Shipwrights, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
dwStyle |= LVS_EX_FULLROWSELECT;
::SendMessage(Shipwrights, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle);
Shipwrights.GetClientRect(rect);
Shipwrights.InsertColumn(0, "Vnum", LVCFMT_LEFT, rect.Width()/5);
Shipwrights.InsertColumn(1, "Name", LVCFMT_LEFT, rect.Width()-(rect.Width()/5));
shop_list.InitList(cannon->shops, Shipwrights);
name = cannon->name;
price = cannon->value;
accuracy = cannon->accuracy;
power = cannon->power;
range = cannon->range;
vnum = cannon->obj_vnum;
filename = cannon->filename;
UpdateData(false);
return TRUE;
}