-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathAmmoBuilder.cpp
133 lines (106 loc) · 2.66 KB
/
AmmoBuilder.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
// AmmoBuilder.cpp : implementation file
//
#include "stdafx.h"
#include "WinDE.h"
#include "AmmoBuilder.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// AmmoBuilder dialog
AmmoBuilder::AmmoBuilder(CWnd* pParent /*=NULL*/)
: CDialog(AmmoBuilder::IDD, pParent)
{
//{{AFX_DATA_INIT(AmmoBuilder)
crew = 0;
hull = 0;
name = _T("");
price = 0;
quantity = 0;
range = 0;
sail = 0;
filename = _T("");
//}}AFX_DATA_INIT
}
void AmmoBuilder::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(AmmoBuilder)
DDX_Control(pDX, IDC_SHIPWRIGHTS, Shipwrights);
DDX_Text(pDX, IDC_CREW, crew);
DDX_Text(pDX, IDC_HULL, hull);
DDX_Text(pDX, IDC_NAME, name);
DDX_Text(pDX, IDC_PRICE, price);
DDX_Text(pDX, IDC_QUANTITY, quantity);
DDX_Text(pDX, IDC_RANGE, range);
DDX_Text(pDX, IDC_SAIL, sail);
DDX_Text(pDX, IDC_FILENAME, filename);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(AmmoBuilder, CDialog)
//{{AFX_MSG_MAP(AmmoBuilder)
ON_BN_CLICKED(IDC_CALC, OnCalc)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_REMOVE, OnRemove)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// AmmoBuilder message handlers
BOOL AmmoBuilder::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));
ammo_shops.InitList(ammo->shops, Shipwrights);
crew = ammo->crew_dam;
sail = ammo->sail_dam;
hull = ammo->hull_dam;
name = ammo->name;
price = ammo->price;
range =ammo->range;
quantity = ammo->max_quan;
filename = ammo->filename;
UpdateData(false);
return TRUE;
}
void AmmoBuilder::OnCalc()
{
UpdateData(true);
DlgCalcCoins dlg_coins(this);
if(dlg_coins.DoModal() == IDOK)
price = dlg_coins.total;
UpdateData(false);
}
void AmmoBuilder::OnAdd()
{
ammo_shops.Add(Shipwrights);
}
void AmmoBuilder::OnRemove()
{
ammo_shops.Remove(Shipwrights);
}
void AmmoBuilder::OnOK()
{
UpdateData(true);
CDialog::OnOK();
ammo_shops.Update(ammo->shops);
ammo->crew_dam = crew;
ammo->sail_dam = sail;
ammo->hull_dam = hull;
ammo->name = name;
ammo->price = price;
ammo->range = range;
ammo->max_quan = quantity;
ammo->filename = filename;
}
void AmmoBuilder::OnCancel()
{
CDialog::OnCancel();
}