-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfrmResults.frm
1654 lines (1474 loc) · 57 KB
/
frmResults.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
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.2#0"; "mscomctl.OCX"
Object = "{20D5284F-7B23-4F0A-B8B1-6C9D18B64F1C}#1.0#0"; "exlimiter.ocx"
Begin VB.Form frmResults
Caption = "Results (click to jump)"
ClientHeight = 2595
ClientLeft = 660
ClientTop = 945
ClientWidth = 5145
Icon = "frmResults.frx":0000
LinkTopic = "Form1"
ScaleHeight = 2595
ScaleWidth = 5145
Begin VB.Timer timWindowMove
Enabled = 0 'False
Interval = 250
Left = 4500
Top = 2040
End
Begin VB.Timer timWait
Enabled = 0 'False
Interval = 500
Left = 4560
Top = 1620
End
Begin VB.Frame fraTree
BorderStyle = 0 'None
Height = 2595
Left = 0
TabIndex = 0
Top = 0
Width = 4395
Begin VB.CommandButton cmdFind
Caption = "&Next"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 3420
TabIndex = 10
Top = 0
Width = 555
End
Begin VB.CommandButton cmdFind
Caption = "&Find"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 2880
TabIndex = 9
Top = 0
Width = 555
End
Begin VB.CommandButton cmdQ
Caption = "?"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4080
TabIndex = 8
Top = 0
Width = 255
End
Begin VB.CommandButton cmdCollapse
Caption = "&Expand"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 900
TabIndex = 7
Top = 0
Width = 855
End
Begin VB.CheckBox chkHideTextblocks
Caption = "Simple"
Height = 195
Left = 1920
TabIndex = 6
Top = 60
Width = 855
End
Begin VB.CommandButton cmdCollapse
Caption = "&Collapse"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 0
TabIndex = 5
Top = 0
Width = 855
End
Begin MSComctlLib.TreeView tvwResults
Height = 2295
Left = 0
TabIndex = 1
Top = 300
Width = 4395
_ExtentX = 7752
_ExtentY = 4048
_Version = 393217
HideSelection = 0 'False
Indentation = 529
LabelEdit = 1
LineStyle = 1
Style = 7
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Begin exlimiter.EL EL1
Left = 4440
Top = 900
_ExtentX = 1270
_ExtentY = 1270
End
Begin MSComctlLib.ImageList ilImages
Left = 4500
Top = 120
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
MaskColor = 12632256
_Version = 393216
End
Begin VB.Frame fraLV
BorderStyle = 0 'None
Height = 2595
Left = 0
TabIndex = 2
Top = 0
Width = 4395
Begin MSComctlLib.ListView lvResults
Height = 2355
Left = 0
TabIndex = 3
Top = 270
Width = 4395
_ExtentX = 7752
_ExtentY = 4154
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = 0 'False
FullRowSelect = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 0
End
Begin VB.Label lblCaption
Height = 255
Left = 45
TabIndex = 4
Top = 0
Width = 4275
End
End
Begin VB.Menu mnuExpand
Caption = "ExpandCollapse"
Visible = 0 'False
Begin VB.Menu mnuExpandItem
Caption = "Collapse Branch"
Index = 0
End
Begin VB.Menu mnuExpandItem
Caption = "Expand Branch"
Index = 1
End
End
End
Attribute VB_Name = "frmResults"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' NOTE: this is the ugliest code i think i've ever created
' -syntax
Option Explicit
Option Base 0
'ntreemode = 1 == execution tree
'ntreemode = 2 == regualar textblock line
'ntreemode = 3 == room command
'ntreemode = 4 == greet text
Public objFormOwner As Form
Public nDefaultMap As Long
Dim nLastNode As Long
Dim sFind As String
Dim nTreeMode As Integer
Dim nNest As Integer
Dim nNestMax As Integer
Dim ScannedTB() As Boolean
Dim nWindowState As Integer
Public nLastPosTop As Long
Public nLastPosLeft As Long
Public nLastPosMoved As Long
Public nLastPosMonitor As Long
Public nLastTimerTop As Long
Public nLastTimerLeft As Long
Private Sub Form_Load()
On Error GoTo error:
With EL1
.CenterOnLoad = True
.FormInQuestion = Me
.MinWidth = 300
.MinHeight = 200 + (TITLEBAR_OFFSET / 10)
.EnableLimiter = True
End With
lvResults.ColumnHeaders.clear
lvResults.ColumnHeaders.Add 1, "Location", "Location/Execution Matches", 3500
chkHideTextblocks.Value = ReadINI("Settings", "HideTextblockResults")
Me.Top = Val(ReadINI("Settings", "ResultsTop", , ((Screen.Height - Me.Height) / 2)))
Me.Left = Val(ReadINI("Settings", "ResultsLeft", , ((Screen.Width - Me.Width) / 2)))
timWindowMove.Enabled = True
'
'nTmp = ReadINI("Settings", "ResultsTop")
'Me.Top = IIf(nTmp > 1, nTmp, frmMain.Top)
'
'nTmp = ReadINI("Settings", "ResultsLeft")
'Me.Left = IIf(nTmp > 1, nTmp, frmMain.Left)
'
'nTmp = ReadINI("Settings", "ResultsWidth")
'Me.Width = IIf(nTmp > 4335, nTmp, 4335)
'
'nTmp = ReadINI("Settings", "ResultsHeight")
'Me.Height = IIf(nTmp > 3465, nTmp, 3465)
Exit Sub
error:
Call HandleError("Form_Load")
End Sub
Private Sub chkHideTextblocks_Click()
On Error GoTo error:
If tvwResults.Nodes.Count < 1 Then Exit Sub
If nTreeMode = 1 Then 'ntreemode = 1 == execution tree
Call CreateExecutionTree(Val(tvwResults.Nodes(1).Tag))
ElseIf nTreeMode = 2 Then 'ntreemode = 2 == regualar textblock line
Call CreateCommandTree(Val(tvwResults.Nodes(1).Tag), False, False)
ElseIf nTreeMode = 3 Then 'ntreemode = 3 == room command
Call CreateCommandTree(Val(tvwResults.Nodes(1).Tag), True, False)
ElseIf nTreeMode = 4 Then 'ntreemode = 4 == greet text
Call CreateCommandTree(Val(tvwResults.Nodes(1).Tag), False, True)
End If
Exit Sub
error:
Call HandleError("chkHideTextblocks_Click")
End Sub
Private Sub cmdCollapse_Click(Index As Integer)
Dim x As Integer, bExpanded As Boolean
On Error GoTo error:
If tvwResults.Nodes.Count < 1 Then Exit Sub
Me.MousePointer = vbHourglass
DoEvents
Call LockWindowUpdate(Me.hWnd)
If Index = 1 Then bExpanded = True
For x = 1 To tvwResults.Nodes.Count
tvwResults.Nodes(x).Expanded = bExpanded
Next x
tvwResults.Nodes(1).Expanded = True
out:
Me.MousePointer = vbDefault
Call LockWindowUpdate(0&)
Exit Sub
error:
Call HandleError("cmdCollapse_Click")
Resume out:
End Sub
Private Sub cmdFind_Click(Index As Integer)
Dim sTemp As String, nStartNode As Long, x As Long
If tvwResults.Nodes.Count < 1 Then Exit Sub
If Index = 0 Or sFind = "" Then
sTemp = InputBox("Enter text to search for.", "Search for text", sFind)
If sTemp = "" Then Exit Sub
sFind = sTemp
nStartNode = 1
Else
nStartNode = tvwResults.SelectedItem.Index + 1
End If
For x = nStartNode To tvwResults.Nodes.Count
If InStr(1, LCase(tvwResults.Nodes(x)), LCase(sFind)) > 0 Then
tvwResults.SelectedItem = tvwResults.Nodes(x)
Exit For
End If
Next x
If x = tvwResults.Nodes.Count + 1 Then
MsgBox "Not Found.", vbInformation
End If
End Sub
Private Sub cmdQ_Click()
MsgBox "Clicking on ""[Link To] Textblock X"" lines will copy that textblock's raw data to your clipboard.", vbInformation
End Sub
Public Sub SetupResultsWindow(ByVal bTreeMode As Boolean, ByRef objSetFormOwner As Form, _
Optional ByVal nSetDefaultMap As Long)
On Error GoTo error:
If FormIsLoaded("frmResults") Then Unload Me
Load Me
DoEvents
Set objFormOwner = objSetFormOwner
'If Not bNoOnTopofOwner Or objFormOwner Is frmMap Then
' Call SetOwner(Me.hwnd, objFormOwner.hwnd)
'' If objFormOwner Is frmMap Then
'' If frmMap.chkMapOptions(6).Value = 0 Then Call SetTopMostWindow(frmMap.hwnd, True)
'' End If
'End If
If nSetDefaultMap > 0 Then nDefaultMap = nSetDefaultMap
If Me.WindowState = vbMinimized Then
Me.WindowState = vbNormal
End If
If Not Me.WindowState = vbMaximized Then
If Me.Visible Then
If bTreeMode And fraTree.Visible = False Then
Call WriteINI("Settings", "ResultsTop", Me.Top)
Call WriteINI("Settings", "ResultsLeft", Me.Left)
Call WriteINI("Settings", "ResultsWidth", Me.Width)
Call WriteINI("Settings", "ResultsHeight", Me.Height)
Me.Top = ReadINI("Settings", "ResultsTreeTop")
Me.Left = ReadINI("Settings", "ResultsTreeLeft")
Me.Width = ReadINI("Settings", "ResultsTreeWidth")
Me.Height = ReadINI("Settings", "ResultsTreeHeight")
ElseIf Not bTreeMode And fraLV.Visible = False Then
Call WriteINI("Settings", "ResultsTreeTop", Me.Top)
Call WriteINI("Settings", "ResultsTreeLeft", Me.Left)
Call WriteINI("Settings", "ResultsTreeWidth", Me.Width)
Call WriteINI("Settings", "ResultsTreeHeight", Me.Height)
Me.Top = ReadINI("Settings", "ResultsTop")
Me.Left = ReadINI("Settings", "ResultsLeft")
Me.Width = ReadINI("Settings", "ResultsWidth")
Me.Height = ReadINI("Settings", "ResultsHeight")
End If
Else
If bTreeMode Then
Me.Top = ReadINI("Settings", "ResultsTreeTop")
Me.Left = ReadINI("Settings", "ResultsTreeLeft")
Me.Width = ReadINI("Settings", "ResultsTreeWidth")
Me.Height = ReadINI("Settings", "ResultsTreeHeight")
Else
Me.Top = ReadINI("Settings", "ResultsTop")
Me.Left = ReadINI("Settings", "ResultsLeft")
Me.Width = ReadINI("Settings", "ResultsWidth")
Me.Height = ReadINI("Settings", "ResultsHeight")
End If
End If
End If
If bTreeMode Then
fraTree.Visible = True
fraLV.Visible = False
Else
fraTree.Visible = False
fraLV.Visible = True
End If
out:
Exit Sub
error:
Call HandleError("SetupResultsWindow")
Resume out:
End Sub
Private Sub Form_Resize()
On Error Resume Next
If Me.WindowState = vbMinimized Then Exit Sub
nWindowState = Me.WindowState
lvResults.Width = Me.Width - 100
lvResults.Height = Me.Height - TITLEBAR_OFFSET - 650 - 250
lvResults.ColumnHeaders(1).Width = lvResults.Width - 500
fraLV.Width = Me.Width - 130
fraLV.Height = Me.Height + TITLEBAR_OFFSET - 250
tvwResults.Width = Me.Width - 130
tvwResults.Height = Me.Height - TITLEBAR_OFFSET - 700 - 250
fraTree.Width = Me.Width - 130
fraTree.Height = Me.Height + TITLEBAR_OFFSET - 250
CheckPosition Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Call WriteINI("Settings", "HideTextblockResults", chkHideTextblocks.Value)
Call WriteINI("Settings", "ResultsTop", Me.Top)
Call WriteINI("Settings", "ResultsLeft", Me.Left)
If Not Me.WindowState = vbMinimized And Not Me.WindowState = vbMaximized Then
If fraTree.Visible Then
Call WriteINI("Settings", "ResultsTreeTop", Me.Top)
Call WriteINI("Settings", "ResultsTreeLeft", Me.Left)
Call WriteINI("Settings", "ResultsTreeWidth", Me.Width)
Call WriteINI("Settings", "ResultsTreeHeight", Me.Height)
Else
Call WriteINI("Settings", "ResultsTop", Me.Top)
Call WriteINI("Settings", "ResultsLeft", Me.Left)
Call WriteINI("Settings", "ResultsWidth", Me.Width)
Call WriteINI("Settings", "ResultsHeight", Me.Height)
End If
End If
If Not objFormOwner Is Nothing Then
If App.LogMode <> 0 Then
If Not bAppTerminating Then objFormOwner.SetFocus
End If
Set objFormOwner = Nothing
End If
End Sub
Private Sub lvResults_Click()
On Error GoTo error:
If objFormOwner Is Nothing Then Set objFormOwner = frmMain
If lvResults.SelectedItem Is Nothing Then Exit Sub
frmMain.bDontSetMainFocus = True
Call frmMain.GotoLocation(lvResults.SelectedItem, , objFormOwner)
'objFormOwner.SetFocus
frmMain.bDontSetMainFocus = False
Exit Sub
error:
Call HandleError("lvResults_Click")
End Sub
Private Sub lvResults_KeyUp(KeyCode As Integer, Shift As Integer)
Call lvResults_Click
End Sub
Public Sub CreateExecutionTree(ByVal nTextblockNumber As Long)
On Error GoTo error:
Dim NodX As Node, imgX As ListImage
If tabTBInfo.RecordCount = 0 Then Exit Sub
tabTBInfo.Index = "pkTBInfo"
tabTBInfo.Seek "=", nTextblockNumber
If tabTBInfo.NoMatch Then
MsgBox "Textblock " & nTextblockNumber & " not found."
GoTo out:
End If
chkHideTextblocks.Enabled = True
nTreeMode = 1
If Me.Visible Then
Me.MousePointer = vbHourglass
DoEvents
Call LockWindowUpdate(Me.hWnd)
End If
tvwResults.Nodes.clear
nLastNode = 0
ilImages.ListImages.clear
Set imgX = ilImages.ListImages.Add(1, "STAR", LoadResPicture("STAR", vbResBitmap))
Set imgX = ilImages.ListImages.Add(2, "ARROW", LoadResPicture("ARROW", vbResBitmap))
Set imgX = ilImages.ListImages.Add(3, "PAPER", LoadResPicture("PAPER", vbResBitmap))
Set imgX = ilImages.ListImages.Add(4, "MONSTER", LoadResPicture("MONSTER", vbResBitmap))
Set imgX = ilImages.ListImages.Add(5, "ROOM", LoadResPicture("ROOM", vbResBitmap))
Set imgX = ilImages.ListImages.Add(6, "BOLT", LoadResPicture("BOLT", vbResBitmap))
Set imgX = ilImages.ListImages.Add(7, "MONEY", LoadResPicture("MONEY", vbResBitmap))
Set imgX = ilImages.ListImages.Add(8, "ITEM", LoadResPicture("ITEM", vbResBitmap))
ilImages.MaskColor = vbMagenta
tvwResults.ImageList = ilImages
Erase ScannedTB()
ReDim ScannedTB(1)
Set NodX = tvwResults.Nodes.Add(, , "NODE1", "Textblock " & nTextblockNumber & " is executed by ...", 3)
NodX.Expanded = True
NodX.Tag = nTextblockNumber
nNest = 0
nNestMax = 500
Call AddExecutionNode(nTextblockNumber, 1)
out:
On Error Resume Next
Me.MousePointer = vbDefault
Call LockWindowUpdate(0&)
DoEvents
timWait.Enabled = True
Set NodX = Nothing
Set imgX = Nothing
Exit Sub
error:
Call HandleError("CreateExecutionTree")
Resume out:
End Sub
Private Sub AddExecutionNode(ByVal nTextblockNumber As Long, ByVal nCurrentNode As Integer)
Dim sLook As String, sChar As String, sTest As String, sSuffix As String
Dim x As Integer, y1 As Integer, y2 As Integer, z As Integer, nValue As Long, x2 As Integer
Dim NodX As Node, nodY As Node
Dim sLoc As String, sTemp As String
On Error GoTo error:
If chkHideTextblocks.Value = 1 Then
If nTextblockNumber > UBound(ScannedTB()) Then
ReDim Preserve ScannedTB(nTextblockNumber)
End If
If ScannedTB(nTextblockNumber) = True Then GoTo out:
ScannedTB(nTextblockNumber) = True
Else
If nCurrentNode > 1 Then
' If tvwResults.Nodes(nCurrentNode).Parent.Key = "NODE1" Then
' Erase ScannedTB()
' ReDim ScannedTB(1)
' End If
' If nTextblockNumber > UBound(ScannedTB()) Then
' ReDim Preserve ScannedTB(nTextblockNumber)
' End If
' If ScannedTB(nTextblockNumber) = True Then
' Set nodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
' "NODE" & tvwResults.Nodes.Count + 1, "Loop detected (Reference to Textblock " & nTextblockNumber & ", but already scanned in tree.)", 1)
' nodX.Tag = 0
' nodX.Expanded = True
' GoTo out:
' End If
' ScannedTB(nTextblockNumber) = True
Set nodY = tvwResults.Nodes(nCurrentNode)
If nCurrentNode > 1 Then
Do
If Not nodY.Parent.Key = "NODE1" Then
Set nodY = nodY.Parent
If InStr(1, nodY.Text, "Textblock " & nTextblockNumber) > 0 Then
Set NodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, "Loop detected (" & "Textblock " & nTextblockNumber & ") ... quitting.", 1)
NodX.Tag = 0
NodX.Expanded = True
GoTo out:
End If
Else
Exit Do
End If
Loop
End If
End If
End If
nNest = nNest + 1
If nNest > nNestMax Then
If nNestMax + 1 = nNest Then
z = MsgBox("MMUD Explorer has nested through " & nNestMax & " textblocks so far, continue for another 500 blocks?", vbYesNo + vbDefaultButton1)
If z = vbYes And nNestMax < 30000 Then
nNestMax = nNestMax + 500
Else
Set NodX = tvwResults.Nodes.Add("NODE" & 1, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, "Too many references ... quitting.", 1)
NodX.Tag = 0
NodX.Expanded = True
Exit Sub
End If
Else
Exit Sub
End If
End If
tabTBInfo.Index = "pkTBInfo"
tabTBInfo.Seek "=", nTextblockNumber
If tabTBInfo.NoMatch Then
Exit Sub
End If
sLoc = tabTBInfo.Fields("Called From")
If Len(sLoc) < 5 Then Exit Sub
sTest = LCase(sLoc)
For z = 1 To 6
x = 1
Select Case z
Case 1: sLook = "room "
Case 2: sLook = "monster #"
Case 3: sLook = "textblock #"
Case 4: sLook = "textblock(rndm) #"
Case 5: sLook = "item #"
Case 6: sLook = "spell #"
End Select
checknext:
sSuffix = ""
If Not InStr(x, sTest, sLook) = 0 Then
x = InStr(x, sTest, sLook) 'sets x to the position of the string we're looking for
' If z = 10 Then
' y1 = x + 1
' GoTo nonumber:
' End If
y1 = x + Len(sLook) 'len of string searching (to position y1 at first number)
y2 = 0
nextnumber:
sChar = Mid(sTest, y1 + y2, 1)
Select Case sChar
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "/":
If Not y1 + y2 - 1 = Len(sTest) Then
y2 = y2 + 1
GoTo nextnumber:
End If
Case "+": 'end of string
Exit Sub
Case "(": 'precent
x2 = InStr(y1 + y2, sTest, ")")
If Not x2 = 0 Then
sSuffix = " " & Mid(sTest, y1 + y2, x2 - y1 - y2 + 1)
End If
Case Else:
End Select
If y2 = 0 Then
'if there were no numbers after the string
x = y1
GoTo checknext:
End If
If Not z = 1 Or z = 10 Then 'not room or group
nValue = Val(Mid(sTest, y1, y2))
End If
nonumber:
Select Case z
Case 1: '"room "
sTemp = GetRoomName(Mid(sTest, y1, y2), , , False)
If chkHideTextblocks.Value = 1 Then
For x = 1 To tvwResults.Nodes.Count
If InStr(1, tvwResults.Nodes(x).Text, "Room: " & sTemp) > 0 Then
GoTo out:
End If
Next x
End If
Set NodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, "Room: " & sTemp & sSuffix, 5)
NodX.Tag = Mid(sTest, y1, y2)
NodX.Expanded = True
NodX.Bold = True
Case 2: '"monster #"
Set NodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, "Monster: " & GetMonsterName(nValue, False) & sSuffix, 4)
NodX.Tag = nValue
NodX.Expanded = True
NodX.Bold = True
Case 3, 4: '"textblock #"
If chkHideTextblocks.Value = 0 Then
' Set nodY = tvwResults.Nodes(nCurrentNode)
' If nCurrentNode > 1 Then
' Do
' If Not nodY.Parent.Key = "NODE1" Then
' Set nodY = nodY.Parent
' If InStr(1, nodY.Text, "Textblock " & nValue) > 0 Then
' Set nodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
' "NODE" & tvwResults.Nodes.Count + 1, "Loop detected (" & "Textblock " & nValue & ") ... quitting.", 1)
' nodX.Tag = 0
' nodX.Expanded = True
' GoTo out:
' End If
' Else
' Exit Do
' End If
' Loop
' End If
sTemp = GetTextblockTrigger(nValue, nTextblockNumber)
Set NodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, "Textblock " & nValue & sSuffix _
& IIf(sTemp = "", "", " " & sTemp), 3)
NodX.Tag = nValue
NodX.Expanded = True
Call AddExecutionNode(nValue, tvwResults.Nodes.Count)
Else
Call AddExecutionNode(nValue, 1)
End If
' Case 4: '"textblock(rndm) #"
' Set nodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
' "NODE" & tvwResults.Nodes.Count + 1, "Textblock " & nValue & sSuffix & " (random)", 3)
' nodX.Tag = nValue
' nodX.Expanded = True
' Call AddExecutionNode(nValue, tvwResults.Nodes.Count)
Case 5: '"item #"
Set NodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, "Item: " & GetItemName(nValue, False) & sSuffix, "ARROW")
NodX.Tag = nValue
NodX.Expanded = True
NodX.Bold = True
Case 6: '"spell #"
Set NodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, "Spell: " & GetSpellName(nValue, False) & sSuffix, "ARROW")
NodX.Tag = nValue
NodX.Expanded = True
NodX.Bold = True
End Select
x = y1
GoTo checknext:
End If
Next z
out:
On Error Resume Next
Set NodX = Nothing
Set nodY = Nothing
Exit Sub
error:
Call HandleError("AddNode")
Resume out:
End Sub
Public Sub CreateCommandTree(ByVal nTextblockNumber As Long, _
ByVal bRoomCommands As Boolean, ByVal bGreetText As Boolean)
On Error GoTo error:
Dim NodX As Node, imgX As ListImage
If tabTBInfo.RecordCount = 0 Then Exit Sub
tabTBInfo.Index = "pkTBInfo"
tabTBInfo.Seek "=", nTextblockNumber
If tabTBInfo.NoMatch Then
MsgBox "Textblock " & nTextblockNumber & " not found."
GoTo out:
End If
chkHideTextblocks.Enabled = True
If bRoomCommands Then
nTreeMode = 3
ElseIf bGreetText Then
nTreeMode = 4
Else
nTreeMode = 2
End If
If Me.Visible Then
Me.MousePointer = vbHourglass
DoEvents
Call LockWindowUpdate(Me.hWnd)
End If
tvwResults.Nodes.clear
nLastNode = 0
ilImages.ListImages.clear
Set imgX = ilImages.ListImages.Add(1, "STAR", LoadResPicture("STAR", vbResBitmap))
Set imgX = ilImages.ListImages.Add(2, "ARROW", LoadResPicture("ARROW", vbResBitmap))
Set imgX = ilImages.ListImages.Add(3, "PAPER", LoadResPicture("PAPER", vbResBitmap))
Set imgX = ilImages.ListImages.Add(4, "MONSTER", LoadResPicture("MONSTER", vbResBitmap))
Set imgX = ilImages.ListImages.Add(5, "ROOM", LoadResPicture("ROOM", vbResBitmap))
Set imgX = ilImages.ListImages.Add(6, "BOLT", LoadResPicture("BOLT", vbResBitmap))
Set imgX = ilImages.ListImages.Add(7, "MONEY", LoadResPicture("MONEY", vbResBitmap))
Set imgX = ilImages.ListImages.Add(8, "ITEM", LoadResPicture("ITEM", vbResBitmap))
Set imgX = ilImages.ListImages.Add(9, "REDARROW", LoadResPicture("REDARROW", vbResBitmap))
ilImages.MaskColor = vbMagenta
tvwResults.ImageList = ilImages
Erase ScannedTB()
ReDim ScannedTB(1)
Set NodX = tvwResults.Nodes.Add(, , "NODE1", "Textblock " & nTextblockNumber & " has the following commands ...", 3)
NodX.Expanded = True
NodX.Tag = nTextblockNumber
nNest = 0
nNestMax = 500
Call AddCommandNode(nTextblockNumber, 1, bRoomCommands, False, bGreetText)
'MsgBox tvwResults.Nodes.Count
out:
On Error Resume Next
Me.MousePointer = vbDefault
Call LockWindowUpdate(0&)
DoEvents
timWait.Enabled = True
Set NodX = Nothing
Set imgX = Nothing
Exit Sub
error:
Call HandleError("CreateTree")
Resume out:
End Sub
Private Sub AddCommandNode(ByVal nTextblockNumber As Long, ByVal nCurrentNode As Integer, _
ByVal bRoomCommands As Boolean, ByVal bRandom As Boolean, ByVal bGreetText As Boolean)
Dim sChar As String
Dim x As Integer, y As Integer, y2 As Integer, z As Integer, nValue As Long, nValue2 As Long, x2 As Integer
Dim NodX As Node, nodY As Node, sTextblockData As String, sLine As String, nNode As Long
Dim sCommand As String, nDataPos As Integer, nLinePos As Integer, nTotalLines As Integer, nCurrLine As Integer
Dim sLineCommand As String, nMap As Long, nRoom As Long, nPercent1 As Long, nPercent2 As Long
Dim nRepeats As Long, sLastCommand As String, nRepeatNode As Long
On Error GoTo error:
If nCurrentNode > 1 Then
Set nodY = tvwResults.Nodes(nCurrentNode)
If nCurrentNode > 1 Then
Do
If Not nodY.Parent.Key = "NODE1" Then
Set nodY = nodY.Parent
If InStr(1, nodY.Text, "Textblock " & nTextblockNumber) > 0 Then
Set NodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, "Loop detected (" & "Textblock " & nTextblockNumber & ") ... quitting.", 1)
NodX.Tag = 0
NodX.Expanded = True
GoTo out:
ElseIf InStr(1, nodY.Text, "random: " & nTextblockNumber) > 0 Then
Set NodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, "Loop detected (" & "random: " & nTextblockNumber & ") ... quitting.", 1)
NodX.Tag = 0
NodX.Expanded = True
GoTo out:
End If
Else
Exit Do
End If
Loop
End If
End If
nNest = nNest + 1
If nNest > nNestMax Then
If nNestMax + 1 = nNest Then
z = MsgBox("MMUD Explorer has nested through " & nNestMax & " textblocks so far, continue for another 500 blocks?", vbYesNo + vbDefaultButton1)
If z = vbYes And nNestMax < 30000 Then
nNestMax = nNestMax + 500
Else
Set NodX = tvwResults.Nodes.Add("NODE" & 1, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, "Too many references ... quitting.", 1)
NodX.Tag = 0
NodX.Expanded = True
Exit Sub
End If
Else
Exit Sub
End If
End If
'If nTextblockNumber = 9379 Then
' Debug.Print ""
'End If
tabTBInfo.Index = "pkTBInfo"
tabTBInfo.Seek "=", nTextblockNumber
If tabTBInfo.NoMatch Then
Set NodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, "Textblock not found, could be because it required items not in the game.", 1)
NodX.Tag = 0
NodX.Expanded = True
Exit Sub
End If
If tabTBInfo.Fields("Action") = Chr(0) Then
GoTo nada:
End If
sTextblockData = tabTBInfo.Fields("Action")
'get total number of lines, only really concerned if it's > 1 so we exit before continuing
nTotalLines = 0
nDataPos = 1
x2 = InStr(nDataPos, sTextblockData, Chr(10))
If x2 > 0 Then
Do While (nDataPos < Len(sTextblockData) + 1) And nTotalLines < 2
x2 = InStr(nDataPos, sTextblockData, Chr(10))
If x2 = 0 Then
If Len(sTextblockData) - nDataPos > 1 Then nTotalLines = nTotalLines + 1
Exit Do
End If
If Not x2 = nDataPos Then
nTotalLines = nTotalLines + 1
End If
nDataPos = x2 + 1
Loop
Else
nTotalLines = 1
End If
nDataPos = 0
If Not bGreetText And Not bRoomCommands And Not bRandom Then GoTo no_commands:
'get first command
nDataPos = 1
nDataPos = InStr(nDataPos, sTextblockData, ":")
If nDataPos = 0 Then GoTo nada:
sCommand = Mid(sTextblockData, 1, nDataPos - 1)
no_commands:
nPercent1 = 0
nPercent2 = 0
nDataPos = nDataPos + 1
Do While nDataPos < Len(sTextblockData) 'loops through lines
If bRandom Then
nPercent2 = nPercent1
nPercent1 = Val(sCommand)
sCommand = (nPercent1 - nPercent2) & "%"
End If
sCommand = Replace(sCommand, "*", "")
sCommand = Replace(sCommand, "|", " OR ")
If bRoomCommands Or bGreetText Then
Set NodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, IIf(bRandom = True, "", "Command: ") & sCommand, 1)
NodX.Expanded = True
nNode = tvwResults.Nodes.Count
ElseIf bRandom Then
Set NodX = tvwResults.Nodes.Add("NODE" & nCurrentNode, tvwChild, _
"NODE" & tvwResults.Nodes.Count + 1, sCommand, 1)
NodX.Expanded = True
nNode = tvwResults.Nodes.Count
Else