forked from syntax53/Nightmare-Redux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmExpCalc.frm
468 lines (411 loc) · 12.5 KB
/
frmExpCalc.frm
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmExpCalc
BorderStyle = 1 'Fixed Single
Caption = "Exp Calculator"
ClientHeight = 4665
ClientLeft = 45
ClientTop = 435
ClientWidth = 4215
Icon = "frmExpCalc.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
ScaleHeight = 4665
ScaleWidth = 4215
Begin VB.CommandButton cmdNote
Caption = "Note"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 3300
TabIndex = 13
Top = 4440
Width = 795
End
Begin VB.TextBox txtEndLVL
Alignment = 2 'Center
Height = 315
Left = 3600
MaxLength = 3
TabIndex = 9
Text = "255"
Top = 720
Width = 555
End
Begin VB.TextBox txtStartLVL
Alignment = 2 'Center
Height = 315
Left = 2760
MaxLength = 3
TabIndex = 8
Text = "2"
Top = 720
Width = 555
End
Begin VB.ComboBox cmbRace
Height = 315
Left = 1800
Sorted = -1 'True
Style = 2 'Dropdown List
TabIndex = 3
Top = 300
Width = 1515
End
Begin VB.ComboBox cmbClass
Height = 315
Left = 60
Sorted = -1 'True
Style = 2 'Dropdown List
TabIndex = 2
Top = 300
Width = 1635
End
Begin VB.TextBox txtCalcEXPTable
Alignment = 2 'Center
Height = 315
Left = 1080
MaxLength = 4
TabIndex = 5
Top = 720
Width = 615
End
Begin VB.CommandButton cmdCalcExp
Caption = "&Calc."
Height = 555
Left = 3420
TabIndex = 4
Top = 60
Width = 735
End
Begin MSComctlLib.ListView lvCalcExp
Height = 3315
Left = 60
TabIndex = 10
Top = 1080
Width = 4095
_ExtentX = 7223
_ExtentY = 5847
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = 0 'False
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 0
End
Begin VB.Label Label5
Alignment = 2 'Center
AutoSize = -1 'True
Caption = "to"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 3375
TabIndex = 12
Top = 780
Width = 195
End
Begin VB.Label Label4
Caption = "LVL Range:"
Height = 195
Left = 1800
TabIndex = 7
Top = 780
Width = 915
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "Thanks to Locke Cole for the exp calc function"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 165
Left = 60
TabIndex = 11
Top = 4440
Width = 2880
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "Race"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 1800
TabIndex = 1
Top = 60
Width = 1515
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "Class"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 60
TabIndex = 0
Top = 60
Width = 1635
End
Begin VB.Label Label39
Caption = "Exp Table %:"
Height = 195
Left = 60
TabIndex = 6
Top = 780
Width = 1035
End
End
Attribute VB_Name = "frmExpCalc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Base 0
Private Declare Function CalcExpNeeded Lib "lltmmudxp" (ByVal Level As Integer, ByVal Chart As Integer) As Currency
Public Sub CalcBy(nClass As Long, nRace As Long, nLevel As Long)
Dim x As Integer, bSuccess As Boolean
On Error GoTo Error:
bSuccess = True
For x = 0 To cmbClass.ListCount - 1
If cmbClass.ItemData(x) = nClass Then
cmbClass.ListIndex = x
Exit For
End If
Next x
If x = cmbClass.ListCount Then bSuccess = False
For x = 0 To cmbRace.ListCount - 1
If cmbRace.ItemData(x) = nRace Then
cmbRace.ListIndex = x
Exit For
End If
Next x
If x = cmbRace.ListCount Then bSuccess = False
txtStartLVL.Text = nLevel - 1
txtEndLVL.Text = nLevel + 50
If bSuccess Then
Call cmdCalcExp_Click
On Error Resume Next
Set lvCalcExp.SelectedItem = lvCalcExp.ListItems(2)
lvCalcExp.SelectedItem.EnsureVisible
lvCalcExp.SetFocus
End If
out:
Exit Sub
Error:
Call HandleError("CalcBy")
Resume out:
End Sub
Private Sub cmdNote_Click()
MsgBox "Clicking on a line will copy the experience value for that level to your clipboard.", vbInformation
End Sub
Private Sub Form_Load()
Dim nStatus As Integer
On Error GoTo Error:
Me.Left = ReadINI("Windows", "ExpCalcLeft")
Me.Top = ReadINI("Windows", "ExpCalcTop")
cmbClass.clear
nStatus = BTRCALL(BGETFIRST, ClassPosBlock, Classdatabuf, Len(Classdatabuf), ByVal ClassKeyBuffer, KEY_BUF_LEN, 0)
If nStatus = 0 Then
Do While nStatus = 0
Call ClassRowToStruct(Classdatabuf.buf)
cmbClass.AddItem ClipNull(Classrec.Name)
cmbClass.ItemData(cmbClass.NewIndex) = Classrec.Number
nStatus = BTRCALL(BGETNEXT, ClassPosBlock, Classdatabuf, Len(Classdatabuf), ByVal ClassKeyBuffer, KEY_BUF_LEN, 0)
Loop
Else
MsgBox "Error getting first class: " & BtrieveErrorCode(nStatus)
End If
cmbClass.AddItem "custom", 0
cmbClass.ListIndex = 0
cmbRace.clear
nStatus = BTRCALL(BGETFIRST, RacePosBlock, Racedatabuf, Len(Racedatabuf), ByVal RaceKeyBuffer, KEY_BUF_LEN, 0)
If nStatus = 0 Then
Do While nStatus = 0
Call RaceRowToStruct(Racedatabuf.buf)
cmbRace.AddItem ClipNull(Racerec.Name)
cmbRace.ItemData(cmbRace.NewIndex) = Racerec.Number
nStatus = BTRCALL(BGETNEXT, RacePosBlock, Racedatabuf, Len(Racedatabuf), ByVal RaceKeyBuffer, KEY_BUF_LEN, 0)
Loop
Else
MsgBox "Error getting first Race: " & BtrieveErrorCode(nStatus)
End If
cmbRace.AddItem "custom", 0
cmbRace.ListIndex = 0
txtStartLVL.Text = ReadINI("Options", "ExpCalcStartLevel")
txtEndLVL.Text = ReadINI("Options", "ExpCalcEndLevel")
If Val(txtEndLVL.Text) < 10 Then txtEndLVL.Text = 255
Exit Sub
Error:
Call HandleError
Resume Next
End Sub
Private Sub CalcExp()
Dim nClassExp As Integer, nRaceExp As Integer, nStatus As Integer, nRecord As Integer
On Error GoTo Error:
If cmbClass.ListIndex > 0 Then
nRecord = cmbClass.ItemData(cmbClass.ListIndex)
nStatus = BTRCALL(BGETEQUAL, ClassPosBlock, Classdatabuf, Len(Classdatabuf), nRecord, KEY_BUF_LEN, 0)
Call ClassRowToStruct(Classdatabuf.buf)
If nStatus = 0 Then
nClassExp = Classrec.Exp + 100
Else
MsgBox "Error getting class: " & BtrieveErrorCode(nStatus)
Exit Sub
End If
End If
If cmbRace.ListIndex > 0 Then
nRecord = cmbRace.ItemData(cmbRace.ListIndex)
nStatus = BTRCALL(BGETEQUAL, RacePosBlock, Racedatabuf, Len(Racedatabuf), nRecord, KEY_BUF_LEN, 0)
Call RaceRowToStruct(Racedatabuf.buf)
If nStatus = 0 Then
nRaceExp = Racerec.ExpChart
Else
MsgBox "Error getting Race: " & BtrieveErrorCode(nStatus)
Exit Sub
End If
End If
txtCalcEXPTable.Text = nClassExp + nRaceExp
Exit Sub
Error:
Call HandleError
End Sub
Private Sub cmbClass_Click()
Call CalcExp
End Sub
Private Sub cmbRace_Click()
Call CalcExp
End Sub
Private Sub cmdCalcExp_Click()
Dim sExp As String, nExp As Currency, x As Long
Dim oLI As ListItem, nLastExp As Currency
On Error GoTo Error:
lvCalcExp.ListItems.clear
lvCalcExp.ColumnHeaders.clear
lvCalcExp.ColumnHeaders.add , , "LVL", 500
lvCalcExp.ColumnHeaders.add , , "Experience", 1600
lvCalcExp.ColumnHeaders.add , , "Needed", 1400
If Val(txtStartLVL.Text) < 2 Then
txtStartLVL.Text = 2
ElseIf Val(txtStartLVL.Text) > 500 Then
txtStartLVL.Text = 500
End If
If Val(txtEndLVL.Text) < 10 Then
txtEndLVL.Text = 10
ElseIf Val(txtEndLVL.Text) > 999 Then
txtEndLVL.Text = 999
End If
For x = Val(txtStartLVL.Text) To Val(txtEndLVL.Text)
nExp = CalcExpNeeded(x, CInt(txtCalcEXPTable.Text))
sExp = CStr(nExp * 10000)
Set oLI = lvCalcExp.ListItems.add()
oLI.Text = x
oLI.SubItems(1) = PutCommas(sExp)
oLI.SubItems(2) = PutCommas(Val(sExp) - nLastExp)
nLastExp = Val(sExp)
Set oLI = Nothing
Next
Exit Sub
Error:
Call HandleError
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call WriteINI("Windows", "ExpCalcLeft", Me.Left)
Call WriteINI("Windows", "ExpCalcTop", Me.Top)
Call WriteINI("Options", "ExpCalcStartLevel", Val(txtStartLVL.Text))
Call WriteINI("Options", "ExpCalcEndLevel", Val(txtEndLVL.Text))
End Sub
Private Sub lvCalcExp_ItemClick(ByVal Item As MSComctlLib.ListItem)
Dim sArr() As String, x As Integer, sExp As String
On Error GoTo Error:
If InStr(1, Item.ListSubItems(1).Text, ",") > 0 Then
sArr() = Split(Item.ListSubItems(1).Text, ",")
Else
ReDim sArr(0)
sArr(0) = Item.ListSubItems(1).Text
End If
For x = 0 To UBound(sArr())
sExp = sExp & sArr(x)
Next x
Clipboard.clear
Clipboard.SetText sExp
out:
Exit Sub
Error:
Call HandleError("lvCalcExp_ItemClick")
Resume out:
End Sub
Private Sub txtCalcEXPTable_GotFocus()
Call SelectAll(txtCalcEXPTable)
End Sub
Private Sub txtCalcEXPTable_KeyPress(KeyAscii As Integer)
KeyAscii = NumberKeysOnly(KeyAscii)
End Sub
Private Sub txtCalcEXPTable_KeyUp(KeyCode As Integer, Shift As Integer)
Dim sStr As String, nPos As Integer, nSel As Integer
On Error GoTo Error:
nPos = txtCalcEXPTable.SelStart
sStr = txtCalcEXPTable.Text
nSel = txtCalcEXPTable.SelLength
cmbClass.ListIndex = 0
cmbRace.ListIndex = 0
txtCalcEXPTable.Text = sStr
txtCalcEXPTable.SelStart = nPos
txtCalcEXPTable.SelLength = nSel
Exit Sub
Error:
Call HandleError
End Sub
Private Sub txtEndLVL_GotFocus()
Call SelectAll(txtEndLVL)
End Sub
Private Sub txtEndLVL_KeyPress(KeyAscii As Integer)
KeyAscii = NumberKeysOnly(KeyAscii)
End Sub
Private Sub txtStartLVL_GotFocus()
Call SelectAll(txtStartLVL)
End Sub
Private Sub txtStartLVL_KeyPress(KeyAscii As Integer)
KeyAscii = NumberKeysOnly(KeyAscii)
End Sub