This repository has been archived by the owner on Feb 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmStore.frm
executable file
·751 lines (726 loc) · 25.1 KB
/
frmStore.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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
VERSION 5.00
Begin VB.Form frmStore
AutoRedraw = -1 'True
BackColor = &H00FF0000&
BorderStyle = 1 'Fixed Single
Caption = "Store"
ClientHeight = 6900
ClientLeft = 4185
ClientTop = 2010
ClientWidth = 11340
Icon = "frmStore.frx":0000
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6900
ScaleWidth = 11340
StartUpPosition = 2 'CenterScreen
Begin VB.PictureBox picCursor
Appearance = 0 'Flat
AutoRedraw = -1 'True
AutoSize = -1 'True
BackColor = &H80000001&
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 375
Left = 240
Picture = "frmStore.frx":030A
ScaleHeight = 375
ScaleWidth = 675
TabIndex = 1
Tag = "0"
Top = 2280
Width = 675
End
Begin VB.Label lblAmount
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "1"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Left = 7800
TabIndex = 28
Top = 4320
Width = 255
End
Begin VB.Label lblTotalCost
AutoSize = -1 'True
BackColor = &H000000FF&
BackStyle = 0 'Transparent
Caption = "9000"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Left = 8280
TabIndex = 27
Top = 5640
Width = 1020
End
Begin VB.Label lblCostPerUnit
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "5000"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Left = 8880
TabIndex = 26
Top = 3600
Width = 1020
End
Begin VB.Label lblCurrStock
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "99"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Left = 9000
TabIndex = 25
Top = 2760
Width = 510
End
Begin VB.Label lblTitle
BackStyle = 0 'Transparent
Caption = "Protip: Use the number keys and the backspace to change the amount of the item you want to buy."
BeginProperty Font
Name = "Verdana"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 615
Index = 7
Left = 5880
TabIndex = 24
Top = 4920
Width = 5205
WordWrap = -1 'True
End
Begin VB.Label lblTitle
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Amount:"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Index = 6
Left = 5880
TabIndex = 23
Top = 4320
Width = 1755
End
Begin VB.Label lblTitle
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Total Cost:"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Index = 8
Left = 5880
TabIndex = 22
Top = 5640
Width = 2235
End
Begin VB.Label lblTitle
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Cost Per Unit:"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Index = 5
Left = 5880
TabIndex = 21
Top = 3600
Width = 2865
End
Begin VB.Label lblTitle
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Current Stock:"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Index = 4
Left = 5880
TabIndex = 20
Top = 2760
Width = 3015
End
Begin VB.Label lblInternets
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "999999999"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Left = 8040
TabIndex = 19
Top = 1800
Width = 2295
End
Begin VB.Label lblTitle
Alignment = 2 'Center
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Internets:"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Index = 3
Left = 5880
TabIndex = 18
Top = 1800
Width = 2085
End
Begin VB.Label lblTitle
Alignment = 2 'Center
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Cost"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Index = 2
Left = 4200
TabIndex = 17
Top = 1440
Width = 915
End
Begin VB.Label lblItem
BackStyle = 0 'Transparent
Caption = "Potion"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 0
Left = 960
TabIndex = 16
Top = 2160
Width = 1995
End
Begin VB.Label lblItem
BackStyle = 0 'Transparent
Caption = "Hi-Potion"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 1
Left = 960
TabIndex = 15
Top = 2760
Width = 1995
End
Begin VB.Label lblItem
BackStyle = 0 'Transparent
Caption = "X-Potion"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 2
Left = 960
TabIndex = 14
Top = 3360
Width = 1995
End
Begin VB.Label lblItem
BackStyle = 0 'Transparent
Caption = "Ether"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 3
Left = 960
TabIndex = 13
Top = 3960
Width = 1995
End
Begin VB.Label lblItem
BackStyle = 0 'Transparent
Caption = "Turbo Ether"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 4
Left = 960
TabIndex = 12
Top = 4560
Width = 2595
End
Begin VB.Label lblItem
BackStyle = 0 'Transparent
Caption = "Phoenix Down"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 5
Left = 960
TabIndex = 11
Top = 5160
Width = 2835
End
Begin VB.Label lblItem
BackStyle = 0 'Transparent
Caption = "Elixir"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 6
Left = 960
TabIndex = 10
Top = 5760
Width = 1995
End
Begin VB.Label lblCost
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "50"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 0
Left = 4020
TabIndex = 9
Top = 2160
Width = 1035
End
Begin VB.Label lblTitle
Alignment = 2 'Center
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Items"
BeginProperty Font
Name = "Verdana"
Size = 20.25
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 480
Index = 1
Left = 960
TabIndex = 8
Top = 1440
Width = 1185
End
Begin VB.Label lblCost
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "500"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 1
Left = 4020
TabIndex = 7
Top = 2760
Width = 1035
End
Begin VB.Label lblCost
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "2000"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 2
Left = 4020
TabIndex = 6
Top = 3360
Width = 1035
End
Begin VB.Label lblCost
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "500"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 3
Left = 4020
TabIndex = 5
Top = 3960
Width = 1035
End
Begin VB.Label lblCost
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "2500"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 4
Left = 4020
TabIndex = 4
Top = 4560
Width = 1035
End
Begin VB.Label lblCost
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "100"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 5
Left = 4020
TabIndex = 3
Top = 5160
Width = 1035
End
Begin VB.Label lblCost
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "5000"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Index = 6
Left = 4020
TabIndex = 2
Top = 5760
Width = 1035
End
Begin VB.Label lblTitle
Alignment = 2 'Center
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Store"
BeginProperty Font
Name = "Verdana"
Size = 42
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 1005
Index = 0
Left = 4560
TabIndex = 0
Top = 120
Width = 2295
End
End
Attribute VB_Name = "frmStore"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'If the player presses up, the cursor moves up
If KeyCode = vbKeyUp Then
Call MoveCursor(-1)
'If the player presses down, the cursor moves down
ElseIf KeyCode = vbKeyDown Then
Call MoveCursor(1)
'If the player presses enter or space
ElseIf KeyCode = vbKeyReturn Or KeyCode = vbKeySpace Then
'The item is bought
Call BuyItem
'If the player presses B or Decimal(Numpad)
ElseIf KeyCode = vbKeyB Or KeyCode = vbKeyDecimal Then
'The store is closed and the player is returned to the field
Unload Me
'If the player presses a number key
ElseIf (KeyCode >= vbKey0 And KeyCode <= vbKey9) Or (KeyCode >= vbKeyNumpad0 And KeyCode <= vbKeyNumpad9) Then
'Finds the value of the number based on the KeyCode
If KeyCode >= vbKey0 And KeyCode <= vbKey9 Then
KeyCode = KeyCode - vbKey0
Else
KeyCode = KeyCode - vbKeyNumpad0
End If
'Uses the value to change the item amount
lblAmount.Caption = ChangeItemAmount(CByte(KeyCode))
'If the player presses backspace
ElseIf KeyCode = vbKeyBack Then
'The item amount is cleared
lblAmount.Caption = "0"
End If
'Updates the labels' values
Call LabelRefresh
End Sub
Private Sub Form_Load()
'Sets the cursor next to the first item label
picCursor.Tag = "0"
picCursor.Top = lblItem(0).Top + (lblItem(0).Height / 4)
picCursor.Left = lblItem(0).Left - picCursor.Width
'Sets the starting amount for the number of each item to buy to 1
lblAmount.Caption = "1"
'Updates the labels' values
Call LabelRefresh
End Sub
'Updates the information in the labels to reflect the change done in the calling routine
Sub LabelRefresh()
'Updates the amount of Internets the player has left
lblInternets.Caption = frmMenu.lblInternets.Caption
'Updates the amount of the currently selected item that the player has in their inventory
lblCurrStock.Caption = frmMenu.lblItemAmount(CInt(picCursor.Tag)).Caption
'Updates the cost per unit of the currently selected item
lblCostPerUnit.Caption = lblCost(CInt(picCursor.Tag)).Caption
'Calculates and shows the total cost for buying the item
lblTotalCost.Caption = CStr(CLng(lblCostPerUnit.Caption) * CLng(lblAmount.Caption))
'If the player can afford to buy the item
If CLng(lblTotalCost.Caption) <= CLng(lblInternets.Caption) Then
'Make the total cost label transparent (so that the red back color will be invisible and the blue form back color will be shown)
lblTotalCost.BackStyle = 0
'If the player can't afford it
Else
'Make the total cost label opaque (so that the red back color will be visible)
lblTotalCost.BackStyle = 1
End If
End Sub
'Moves the cursor through the label array
' Direction is the direction the cursor moves
' 1 will increase the tag's value (moves down corresponding with the control array's index)
' -1 will decrease the tag's value (moves up corresponding with the control array's index)
Sub MoveCursor(Direction As Integer)
'Cursor tag is adjusted in the desired direction
picCursor.Tag = CStr(CInt(picCursor.Tag) + Direction)
'If the tag exceeds the bounds of the array it is cycled
If CInt(picCursor.Tag) < lblItem.LBound Then
picCursor.Tag = CStr(lblItem.uBound)
ElseIf CInt(picCursor.Tag) > lblItem.uBound Then
picCursor.Tag = CStr(lblItem.LBound)
End If
'Changes the position of the cursor so that it is next to the new control
picCursor.Top = lblItem(CInt(picCursor.Tag)).Top + (lblItem(0).Height / 4)
picCursor.Left = lblItem(CInt(picCursor.Tag)).Left - picCursor.Width
End Sub
'Adds the item to the player's inventory and subtracts the cost
Sub BuyItem()
'If the total cost label is transparent (the user can afford the item)
If lblTotalCost.BackStyle = 0 Then
'The payment is made
frmMenu.lblInternets.Caption = CStr(CLng(frmMenu.lblInternets.Caption) - CLng(lblTotalCost.Caption))
'The item is added to the player's inventory
frmMenu.lblItemAmount(CInt(picCursor.Tag)).Caption = CStr(CByte(frmMenu.lblItemAmount(CInt(picCursor.Tag)).Caption) + CByte(lblAmount.Caption))
'Prevents the number of items the player has from exceeding the limit
Call EnforceStatCaps
End If
End Sub
'Changes the amount of each item that the player wants to buy
' Number is the number that is being concatenated
Function ChangeItemAmount(Number As Byte) As String
'Concatenates the new number to the end, takes only 2 digits, and returns the result
' The Cint() is to remove leading zeros
ChangeItemAmount = Right(CStr(CInt(lblAmount.Caption & CStr(Number))), 2)
End Function
Private Sub Form_Unload(Cancel As Integer)
'The player is returned to the field
frmField.Show
End Sub