-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOfficialCharacterSheet.vb
5272 lines (4216 loc) · 209 KB
/
OfficialCharacterSheet.vb
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
Imports GCA5Engine
Imports C1.C1Preview
Imports System.Drawing
Imports System.Reflection
'Any such DLL needs to add References to:
'
' System.Drawing (System.Drawing; v4.X)
' C1.C1Report.4 (ComponentOne Reports; v4.X)
' GCA5Engine
' GCA5.Interfaces.DLL
'
'in order to work as a print sheet.
'
Public Class OfficialCharacterSheet
Implements GCA5.Interfaces.IPrinterSheet
Private Const Hand As Integer = 1
Private Const Ranged As Integer = 2
Private ShadeAltLines As Boolean = True
Private LineBefore As Boolean = True
Private MarginLeft, MarginRight, MarginTop, MarginBottom As Double
Private PageWidth, PageHeight As Double
Private MyStyles As Collection
Private MyOptions As GCA5Engine.SheetOptionsManager
Private ShowHidden() As Boolean
Private ShowComponents() As Boolean
Private Fields As ArrayList '0 based
Private IconColLeft As Double
Private IconColWidth As Double
Private IndentStepSize As Double = 0.125
Private ComponentDrawCol As Integer
Private BrokenEffectCol As Integer
Private FooterHeight As Double = 0.25
Private SpacerHeight As Double = 1 / 16
Private PointsBoxHeight = 1.25
Private SpeedRangeTableHeight As Double = 3.25
Private pointBoxWidth As Double = 7 / 16
Private numCols As Integer = 0
Private PointsCol As Integer = 0
Private ColLefts(0) As Double
Private ColWidths(0) As Double
Private ColAligns(0) As AlignHorzEnum
Private AltColLefts(0) As Double 'for combos
Private AltColWidths(0) As Double 'for combos
Private MaxWidth As Double = 0
Private SubHeads(0) As String
Private HasOverflow As Boolean = False
Private HasOverflowWeapons As Boolean = False
Private OverflowFrom(LastItemType) As Integer
Private WeaponOverflowFrom(Ranged) As Integer
Private GrimoireOverflowFrom As Integer
Private MyChar As GCACharacter
Public Property Character As GCACharacter
Get
Return MyChar
End Get
Set(value As GCACharacter)
MyChar = value
End Set
End Property
Private WithEvents MyPrintDoc As C1.C1Preview.C1PrintDocument
Public Property PrintDoc As C1.C1Preview.C1PrintDocument
Get
Return MyPrintDoc
End Get
Set(value As C1.C1Preview.C1PrintDocument)
MyPrintDoc = value
End Set
End Property
Public ReadOnly Property Name() As String Implements GCA5.Interfaces.IPrinterSheet.Name
Get
Return "GURPS 4th Edition Official Character Sheet"
End Get
End Property
Public ReadOnly Property Description() As String Implements GCA5.Interfaces.IPrinterSheet.Description
Get
Dim tmp As String
tmp = "Prints a close approximation of the official character sheet released for GURPS 4th Edition."
tmp = tmp & vbCrLf & vbCrLf
tmp = tmp & "Note: On A4 paper, this sheet will not print correctly with left and right margins greater than about 20mm. Use the smallest margins you can to get the best results."
Return tmp
End Get
End Property
Public ReadOnly Property Version() As String Implements GCA5.Interfaces.IPrinterSheet.Version
Get
'Return "1.0.0.13"
Return AutoFindVersion()
End Get
End Property
Public Function AutoFindVersion() As String
Dim longFormVersion As String = ""
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
'Provide the current application domain evidence for the assembly.
'Load the assembly from the application directory using a simple name.
currentDomain.Load("OfficialCharacterSheet")
'Make an array for the list of assemblies.
Dim assems As [Assembly]() = currentDomain.GetAssemblies()
'List the assemblies in the current application domain.
'Echo("List of assemblies loaded in current appdomain:")
Dim assem As [Assembly]
'Dim co As New ArrayList
For Each assem In assems
If assem.FullName.StartsWith("OfficialCharacterSheet") Then
Dim parts(0) As String
parts = assem.FullName.Split(",")
'name and version are the first two parts
longFormVersion = parts(1)
'Version=1.2.3.4
parts = longFormVersion.Split("=")
Return parts(1)
End If
Next assem
Return longFormVersion
End Function
Public Sub New()
'For testing, I'm creating an Options object with different
'values than those I'm using for the defaults for the
'IPrinterSheet routines.
MyOptions = New GCA5Engine.SheetOptionsManager(Name)
CreateOptions(MyOptions)
MyOptions.Value("SheetFont") = New Font("Arial Narrow", 10)
MyOptions.Value("SheetTextColor") = Color.Red
End Sub
Public Sub UpgradeOptions(Options As GCA5Engine.SheetOptionsManager) Implements GCA5.Interfaces.IPrinterSheet.UpgradeOptions
'This is called only when a particular plug-in is loaded the first time,
'and before SetOptions.
'I don't do anything with this.
End Sub
Public Sub CreateOptions(Options As GCA5Engine.SheetOptionsManager) Implements GCA5.Interfaces.IPrinterSheet.CreateOptions
'This is the routine where all the Options we want to use are created,
'and where the UI for the Preferences dialog is filled out.
'
'This is equivalent to CharacterSheetOptions from previous implementations
Dim ok As Boolean
Dim newOption As GCA5Engine.SheetOption
Dim i As Integer
Dim descFormat As New SheetOptionDisplayFormat
descFormat.BackColor = SystemColors.Info
descFormat.CaptionLocalBackColor = SystemColors.Info
'* Description block at top *
newOption = New GCA5Engine.SheetOption
newOption.Name = "Header_Description"
newOption.Type = GCA5Engine.OptionType.Header
newOption.UserPrompt = Name & " " & Version
newOption.DisplayFormat = descFormat
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "Description"
newOption.Type = GCA5Engine.OptionType.Caption
newOption.UserPrompt = Description
newOption.DisplayFormat = descFormat
ok = Options.AddOption(newOption)
'* Fonts *
newOption = New GCA5Engine.SheetOption
newOption.Name = "Header_Fonts"
newOption.Type = GCA5Engine.OptionType.Header
newOption.UserPrompt = "Font and Text Options"
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "SheetFont"
newOption.Type = GCA5Engine.OptionType.Font
newOption.UserPrompt = "Font for the form text items"
newOption.DefaultValue = New Font("Times New Roman", 10)
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "SheetTextColor"
newOption.Type = GCA5Engine.OptionType.Color
newOption.UserPrompt = "Color for the form text items"
newOption.DefaultValue = Color.Black
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "UserFont"
newOption.Type = GCA5Engine.OptionType.Font
newOption.UserPrompt = "Font for the user text items"
newOption.DefaultValue = New Font("Arial Narrow", 10)
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "UserTextColor"
newOption.Type = GCA5Engine.OptionType.Color
newOption.UserPrompt = "Color for the user text items"
newOption.DefaultValue = Color.Green
ok = Options.AddOption(newOption)
'NEW 2015 05 25, 2015 05 27
newOption = New GCA5Engine.SheetOption
newOption.Name = "UserBonusesFont"
newOption.Type = GCA5Engine.OptionType.Font
newOption.UserPrompt = "Font for the lines showing 'Included' and 'Conditional' bonuses in trait listings"
newOption.DefaultValue = New Font("Times New Roman", 8)
ok = Options.AddOption(newOption)
'END NEW
'NEW 2015 05 25
newOption = New GCA5Engine.SheetOption
newOption.Name = "UserBonusesColor"
newOption.Type = GCA5Engine.OptionType.Color
newOption.UserPrompt = "Color for the lines showing 'Included' and 'Conditional' bonuses in trait listings"
newOption.DefaultValue = Color.Black
ok = Options.AddOption(newOption)
'END NEW
'* Item Display *
newOption = New GCA5Engine.SheetOption
newOption.Name = "Header_Display"
newOption.Type = GCA5Engine.OptionType.Header
newOption.UserPrompt = "Display Options"
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "LineBefore"
newOption.Type = GCA5Engine.OptionType.YesNo
newOption.UserPrompt = "Draw a dotted line before each new item in a listing of items."
newOption.DefaultValue = True
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "ShadeAltLines"
newOption.Type = GCA5Engine.OptionType.YesNo
newOption.UserPrompt = "Shade alternate lines in listings of items."
newOption.DefaultValue = True
ok = Options.AddOption(newOption)
'Weapon tables
newOption = New GCA5Engine.SheetOption
newOption.Name = "AllowDynamicSizingOfWeaponBlocks"
newOption.Type = GCA5Engine.OptionType.YesNo
newOption.UserPrompt = "Allow Dynamic Sizing. Sacrifice any free space from one weapon table to allow more weapon modes to appear in an overflowing weapon table."
newOption.DefaultValue = True
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "SacrificeNotesForWeapons"
newOption.Type = GCA5Engine.OptionType.YesNo
newOption.UserPrompt = "If more room is needed for the weapon tables, sacrifice the Character Notes block for it. (This will only be used if Allow Dynamic Sizing is also being used.)"
newOption.DefaultValue = True
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "ProtectionNotEquipment"
newOption.Type = GCA5Engine.OptionType.YesNo
newOption.UserPrompt = "Print the Protection paper-doll on page 2, bumping Equipment to the Overflow pages."
newOption.DefaultValue = False
ok = Options.AddOption(newOption)
'* Hidden Items *
newOption = New GCA5Engine.SheetOption
newOption.Name = "Header_Hidden"
newOption.Type = GCA5Engine.OptionType.Header
newOption.UserPrompt = "Show Hidden Traits"
ok = Options.AddOption(newOption)
Dim a1(LastItemType - 1) As Boolean
Dim t1(LastItemType - 1) As String
For i = 1 To LastItemType
a1(i - 1) = False
t1(i - 1) = ReturnListNameNew(i)
Next
newOption = New GCA5Engine.SheetOption
newOption.Name = "ShowHidden"
newOption.Type = OptionType.ListArray
newOption.UserPrompt = "Check the sections for which you'd like to display traits that are normally hidden."
newOption.DefaultValue = a1
newOption.List = t1
ok = Options.AddOption(newOption)
'* Component Items *
newOption = New GCA5Engine.SheetOption
newOption.Name = "Header_Components"
newOption.Type = OptionType.Header
newOption.UserPrompt = "Show Component Traits"
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "Caption_Components"
newOption.Type = OptionType.Caption
newOption.UserPrompt = "Components are the traits that make up meta-traits and templates. If you would like to have them listed under their owning trait, turn that on here."
ok = Options.AddOption(newOption)
Dim a2(LastItemType - 1) As Boolean
Dim t2(LastItemType - 1) As String
For i = 1 To LastItemType
a2(i - 1) = False
t2(i - 1) = ReturnListNameNew(i)
Next
newOption = New GCA5Engine.SheetOption
newOption.Name = "ShowComponents"
newOption.Type = OptionType.ListArray
newOption.UserPrompt = "Check the sections for which you'd like to display any component traits."
newOption.DefaultValue = a2
newOption.List = t2
ok = Options.AddOption(newOption)
End Sub
Public Function GeneratePrinterDocument(GCAParty As Party, PageSettings As C1PageSettings, Options As GCA5Engine.SheetOptionsManager) As C1.C1Preview.C1PrintDocument Implements GCA5.Interfaces.IPrinterSheet.GeneratePrinterDocument
Dim i As Integer
'Notify(Name & " " & Version, Priority.Green)
'Set our Options to the stored values we've just been given
MyOptions = Options
MyChar = GCAParty.Current
MyPrintDoc = New C1.C1Preview.C1PrintDocument
MyPrintDoc.TagOpenParen = "[["
MyPrintDoc.TagCloseParen = "]]"
'Initialize some page values
'I think in inches. Note that some values returned from the engine won't be in the units set here
MyPrintDoc.DefaultUnit = C1.C1Preview.UnitTypeEnum.Inch
MyPrintDoc.ResolvedUnit = UnitTypeEnum.Inch
'this is required, because I manually place everything, and generate my own page breaks
MyPrintDoc.AllowNonReflowableDocs = True
MyPrintDoc.Style.Font = MyOptions.Value("SheetFont")
MyPrintDoc.Style.TextColor = MyOptions.Value("SheetTextColor")
MyPrintDoc.PageLayout.PageSettings.PaperKind = PageSettings.PaperKind
MyPrintDoc.PageLayout.PageSettings.Landscape = PageSettings.Landscape
MyPrintDoc.PageLayout.PageSettings.TopMargin = PageSettings.TopMargin ' 0.5
MyPrintDoc.PageLayout.PageSettings.BottomMargin = PageSettings.BottomMargin '0.5
MyPrintDoc.PageLayout.PageSettings.LeftMargin = PageSettings.LeftMargin '0.5
MyPrintDoc.PageLayout.PageSettings.RightMargin = PageSettings.RightMargin '0.75
'The document settings for these values will be in inches for US page types, and in
'millimeters for international types, and possibly other values for ANSI types and whatnot,
'so we need to get the values in the measurement system we want, and we do that here.
MarginLeft = MyPrintDoc.PageLayout.PageSettings.LeftMargin.ConvertUnit(UnitTypeEnum.Inch)
MarginRight = MyPrintDoc.PageLayout.PageSettings.RightMargin.ConvertUnit(UnitTypeEnum.Inch)
MarginTop = MyPrintDoc.PageLayout.PageSettings.TopMargin.ConvertUnit(UnitTypeEnum.Inch)
MarginBottom = MyPrintDoc.PageLayout.PageSettings.BottomMargin.ConvertUnit(UnitTypeEnum.Inch)
PageWidth = MyPrintDoc.PageLayout.PageSettings.Width.ConvertUnit(UnitTypeEnum.Inch)
PageHeight = MyPrintDoc.PageLayout.PageSettings.Height.ConvertUnit(UnitTypeEnum.Inch)
If MyChar Is Nothing Then
Dim boxWidth, boxHeight, boxLeft, boxTop As Double
Dim ld As C1.C1Preview.LineDef
MyPrintDoc.StartDoc()
boxLeft = MarginLeft
boxTop = MarginTop
boxWidth = PageWidth - MarginRight - boxLeft
boxHeight = PageHeight - MarginBottom - boxTop
ld = New C1.C1Preview.LineDef(0.06, Color.AliceBlue, Drawing2D.DashStyle.Dash)
MyPrintDoc.RenderDirectRectangle(boxLeft, boxTop, boxWidth, boxHeight, ld)
Dim EmptyPageStyle As Style = MyPrintDoc.Style.Children.Add()
EmptyPageStyle.Font = New Font(MyPrintDoc.Style.Font.Name, 24, FontStyle.Bold)
EmptyPageStyle.TextAlignVert = AlignVertEnum.Center
EmptyPageStyle.TextAlignHorz = AlignHorzEnum.Center
MyPrintDoc.RenderDirectText(boxLeft, boxTop, "There are no characters loaded.", boxWidth, boxHeight, EmptyPageStyle)
MyPrintDoc.EndDoc()
Return MyPrintDoc
End If
'initialize some working values
MyStyles = New Collection
HasOverflow = False
HasOverflowWeapons = False
'since we'll be using a list of display fields, which are 0 based,
'rather than our normal trait lists which are 1 based, we can't
'use the default 0 value as an indicator of No value, so we need
'to set our No value to -1 instead
For i = 1 To LastItemType
OverflowFrom(i) = -1
Next
For i = 1 To Ranged
WeaponOverflowFrom(i) = -1
Next
GrimoireOverflowFrom = -1
ShadeAltLines = MyOptions.Value("ShadeAltLines")
LineBefore = MyOptions.Value("LineBefore")
ShowHidden = MyOptions.Value("ShowHidden")
ShowComponents = MyOptions.Value("ShowComponents")
CreateStyles()
CreateFooter()
'Start working
MyPrintDoc.StartDoc()
PrintPage1()
MyPrintDoc.NewPage()
PrintPage2()
If HasOverflow Then
MyPrintDoc.NewPage()
PrintPageOverflowTraits()
End If
If HasOverflowWeapons Then
MyPrintDoc.NewPage()
PrintPageOverflowWeapons()
End If
If MyChar.ItemsByType(Spells).Count > 0 Then
MyPrintDoc.NewPage()
PrintPageGrimoire()
End If
MyPrintDoc.EndDoc()
Return MyPrintDoc
End Function
Private Sub PrintPage1()
Dim boxWidth, boxHeight, boxLeft, boxTop As Double
Dim col2Left, col2part2Left As Double
'Dim ld As C1.C1Preview.LineDef
boxLeft = MarginLeft
boxTop = MarginTop
boxWidth = PageWidth - MarginRight - boxLeft
boxHeight = PageHeight - MarginBottom - boxTop
'ld = New C1.C1Preview.LineDef(0.06, Color.AliceBlue, Drawing2D.DashStyle.Dash)
'MyPrintDoc.RenderDirectRectangle(boxLeft, boxTop, boxWidth, boxHeight, ld)
'***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
'***** Top Half of Page
'***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
'*
'* Print Graphic Header Block
'*
PrintSectionPage1Header()
'*****
'***** Left side of page
'*****
boxTop = PrintSectionAttributes()
'*
'* Print Basics
'*
boxTop = boxTop + SpacerHeight
boxTop = PrintSectionBasics(boxTop)
'*
'* Print Encumbrance & Move
'*
boxTop = boxTop + SpacerHeight
boxTop = PrintSectionMove(boxTop)
'ld = New C1.C1Preview.LineDef(0.06, Color.AliceBlue, Drawing2D.DashStyle.Dash)
'MyPrintDoc.RenderDirectLine(MarginLeft, boxTop, PageWidth - MarginRight, boxTop, ld)
'*****
'***** Right side of page
'*****
'*
'* Print Languages
'*
col2Left = MarginLeft + 3.625
boxLeft = col2Left
boxTop = PrintSectionLanguages(boxLeft)
'*
'* Print DR
'*
boxTop = boxTop + SpacerHeight
PrintSectionDR(boxLeft, boxTop)
'*
'* Print TL & Cultures
'*
boxLeft = boxLeft + 11 / 16 + SpacerHeight
col2part2Left = boxLeft
boxTop = PrintSectionCultures(boxLeft, boxTop)
'*
'* Print Parry & Block
'*
boxLeft = col2Left
boxTop = boxTop + SpacerHeight
PrintSectionParryBlock(boxLeft, boxTop)
'*
'* Print Reactions
'*
boxLeft = col2part2Left
boxTop = PrintSectionReactions(boxLeft, boxTop)
'***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
'***** Bottom Half of Page
'***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
PrintSectionAdsDisads(boxTop)
PrintSectionSkills(col2Left, boxTop)
''TESTING
''The purpose of this block is to create a section that mimics the direct rendering
''done in the Stats block above, but with specific render objects, so that it's possible
''to have access to the object being rendered.
''
''This is necessary so we can set the UserData for the render object, which will allow
''us to track and find data fields, so that we can use edit controls on the Sheet View.
'Dim Col1AttributeBoxWidth, Col2AttributeBoxWidth, Col1AttributeOffset, Col2AttributeOffset As Double
'Dim stat As String = ""
'Dim i As Integer = 0
'Dim tmp As String = ""
'Dim AttributeCenterStyle As Style = MyStyles("AttributeCenterStyle")
'ld = New C1.C1Preview.LineDef(0.01, Color.Green, Drawing2D.DashStyle.Solid)
'boxWidth = 7.5 / 16 '0.25
'boxHeight = 7.5 / 16 + 1 / 32 '0.25
'Col1AttributeBoxWidth = 0.5
'Col2AttributeBoxWidth = 0.625
'Col1AttributeOffset = 1 / 16
'Col2AttributeOffset = 0.675
''* ST line
'boxLeft = MarginLeft + Col1AttributeBoxWidth '0.5
'boxTop = MarginTop + 14 / 16 '13 / 16 '2
'stat = "ST"
'i = MyChar.ItemPositionByNameAndExt(stat, Stats)
'Dim rr As New RenderRectangle(boxWidth, boxHeight, ld, Brushes.CornflowerBlue)
'rr.UserData = "Testing"
'MyPrintDoc.RenderDirect(boxLeft, boxTop, rr)
'Dim rt As New RenderText(MyChar.Items.Item(i).Score, AttributeCenterStyle)
'rt.UserData = "Testing2"
'MyPrintDoc.RenderDirect(boxLeft, boxTop, rt, boxWidth, boxHeight)
''END TESTING
End Sub
Private Sub PrintPage2()
Dim curTop As Double
Dim col2Left As Double
Dim curBottom As Double
'left side for Hand block is indented to allow for logo
Dim HandBlockLeft As Double = MarginLeft + 1 + 11 / 16
Dim RangedBlockLeft As Double = MarginLeft
'set our default heights, and get our desired heights, for our weapon blocks
Dim DefaultHeightHandBlock As Double = 1 + 1 / 16 + 1 / 8
Dim DefaultHeightRangedBlock As Double = 2 + 1 / 16
Dim UseThisHandBlockHeight As Double = DefaultHeightHandBlock
Dim UseThisRangedBlockHeight As Double = DefaultHeightRangedBlock
'if we can use the notes block, this will have how much room we get from that
Dim ExtraAvailableSpace As Double = 0
Dim NotesSacrificed As Boolean = False
If MyOptions.Value("AllowDynamicSizingOfWeaponBlocks") Then
'hand block can't be too short because of the logo on the left
Dim MinHandBlockHeight As Double = 0.5 + 0.1875 + 0.1875
Dim DesiredHeightHandBlock As Double = GetWeaponSectionDesiredHeight(Hand, HandBlockLeft, MinHandBlockHeight)
Dim DesiredHeightRangedBlock As Double = GetWeaponSectionDesiredHeight(Ranged, RangedBlockLeft)
'now, see if we can fit all weapons, or at least overflow fewer, by adjusting block heights
If DesiredHeightHandBlock < DefaultHeightHandBlock AndAlso DesiredHeightRangedBlock < DefaultHeightRangedBlock Then
'the defaults are fine, don't need to do anything else
Else
'it doesn't all fit in the given space, see what we can move around
If DesiredHeightHandBlock < DefaultHeightHandBlock Then
'we have room that we can take from the Hand block
UseThisRangedBlockHeight = UseThisRangedBlockHeight + (DefaultHeightHandBlock - DesiredHeightHandBlock)
UseThisHandBlockHeight = DesiredHeightHandBlock
If UseThisRangedBlockHeight < DesiredHeightRangedBlock Then
'still need more room
If MyOptions.Value("SacrificeNotesForWeapons") Then
ExtraAvailableSpace = PageHeight - MarginBottom - FooterHeight
ExtraAvailableSpace = ExtraAvailableSpace - (MarginTop + DefaultHeightHandBlock + SpacerHeight + DefaultHeightRangedBlock + SpacerHeight + SpeedRangeTableHeight + SpacerHeight + PointsBoxHeight)
If ExtraAvailableSpace < 0 Then ExtraAvailableSpace = 0
NotesSacrificed = True
End If
UseThisRangedBlockHeight = UseThisRangedBlockHeight + ExtraAvailableSpace
End If
ElseIf DesiredHeightRangedBlock < DefaultHeightRangedBlock Then
'we have room that we can take from the Ranged block
UseThisHandBlockHeight = UseThisHandBlockHeight + (DefaultHeightRangedBlock - DesiredHeightRangedBlock)
UseThisRangedBlockHeight = DesiredHeightRangedBlock
If UseThisHandBlockHeight < DesiredHeightHandBlock Then
'still need more room
If MyOptions.Value("SacrificeNotesForWeapons") Then
ExtraAvailableSpace = PageHeight - MarginBottom - FooterHeight
ExtraAvailableSpace = ExtraAvailableSpace - (MarginTop + DefaultHeightHandBlock + SpacerHeight + DefaultHeightRangedBlock + SpacerHeight + SpeedRangeTableHeight + SpacerHeight + PointsBoxHeight)
If ExtraAvailableSpace < 0 Then ExtraAvailableSpace = 0
NotesSacrificed = True
End If
UseThisHandBlockHeight = UseThisHandBlockHeight + ExtraAvailableSpace
End If
Else
'we don't have any spare room in either block
If MyOptions.Value("SacrificeNotesForWeapons") Then
ExtraAvailableSpace = PageHeight - MarginBottom - FooterHeight
ExtraAvailableSpace = ExtraAvailableSpace - (MarginTop + DefaultHeightHandBlock + SpacerHeight + DefaultHeightRangedBlock + SpacerHeight + SpeedRangeTableHeight + SpacerHeight + PointsBoxHeight)
If ExtraAvailableSpace < 0 Then ExtraAvailableSpace = 0
NotesSacrificed = True
End If
'see if one benefits entirely from the extra space we have.
If ExtraAvailableSpace > 0 Then
If DesiredHeightHandBlock <= DefaultHeightHandBlock + ExtraAvailableSpace Then
'we have enough room for this one.
UseThisHandBlockHeight = DesiredHeightHandBlock
'leave any left over for ranged
ExtraAvailableSpace = (DefaultHeightHandBlock + ExtraAvailableSpace) - UseThisHandBlockHeight
UseThisRangedBlockHeight = UseThisRangedBlockHeight + ExtraAvailableSpace
ElseIf DesiredHeightRangedBlock <= DefaultHeightRangedBlock + ExtraAvailableSpace Then
'we have enough room for this one.
UseThisRangedBlockHeight = DesiredHeightRangedBlock
'leave any left over for ranged
ExtraAvailableSpace = (DefaultHeightRangedBlock + ExtraAvailableSpace) - UseThisRangedBlockHeight
UseThisHandBlockHeight = UseThisHandBlockHeight + ExtraAvailableSpace
Else
'nothing fits well, just split it.
UseThisRangedBlockHeight = UseThisRangedBlockHeight + ExtraAvailableSpace / 2
'leave any left over for ranged
ExtraAvailableSpace = (DefaultHeightRangedBlock + ExtraAvailableSpace) - UseThisRangedBlockHeight
UseThisHandBlockHeight = UseThisHandBlockHeight + ExtraAvailableSpace
End If
End If
End If
End If
End If
'widths of speed/range + hit locations
col2Left = MarginLeft + (1.75) + 1 / 16 + (1 + 4 / 16) + 1 / 16
PrintSectionPage2Header(UseThisHandBlockHeight)
curTop = PrintSectionHandWeapons(HandBlockLeft, MarginTop, UseThisHandBlockHeight)
curTop = curTop + SpacerHeight
curTop = PrintSectionRangedWeapons(RangedBlockLeft, curTop, UseThisRangedBlockHeight)
curTop = curTop + SpacerHeight
If MyOptions.Value("ProtectionNotEquipment") Then
'print protection here instead of equipment
HasOverflow = True
OverflowFrom(Equipment) = 0
PrintSectionProtection(col2Left, curTop)
Else
'print equipment
PrintSectionEquipment(col2Left, curTop)
End If
PrintSectionSpeedRangeTable(MarginLeft, curTop)
curTop = PrintSectionHitLocationTable(MarginLeft + 1.75 + 1 / 16, curTop)
curTop = curTop + SpacerHeight
curTop = PrintSectionInfoBox(MarginLeft + 1.75 + 1 / 16, curTop)
curBottom = PrintSectionPointsSummary()
curBottom = curBottom - SpacerHeight
If NotesSacrificed Then Return 'Don't print notes, we took away the space for it
curTop = curTop + SpacerHeight
PrintSectionCharacterNotes(curTop, curBottom - curTop)
End Sub
Private Sub PrintPageOverflowTraits()
Dim i As Integer
Dim curTop As Double
Dim col1Left As Double
Dim col2Left As Double
Dim ColWidth As Double
Dim maxHeight As Double
Dim workHeight As Double
Dim PrintingColumn1 As Boolean = True
Dim LeftSide As Double
workHeight = PageHeight - MarginBottom - FooterHeight - MarginTop
curTop = MarginTop
ColWidth = ((PageWidth - MarginRight - MarginLeft) / 2) - 1 / 32
col1Left = MarginLeft
col2Left = MarginLeft + ColWidth + 1 / 16
maxHeight = workHeight
For i = 1 To LastItemType
If OverflowFrom(i) > -1 Then
Do
If PrintingColumn1 Then LeftSide = col1Left Else LeftSide = col2Left
curTop = PrintOverflowTraits(i, LeftSide, curTop, ColWidth, maxHeight, OverflowFrom(i))
curTop = curTop + 1 / 16
maxHeight = workHeight - (curTop - MarginTop)
If OverflowFrom(i) > -1 Then
'still didn't finish
If Not PrintingColumn1 Then MyPrintDoc.NewPage()
PrintingColumn1 = Not PrintingColumn1
curTop = MarginTop
maxHeight = workHeight
Else
'finished
Exit Do
End If
Loop
End If
Next
End Sub
Private Sub PrintPageOverflowWeapons()
Dim i As Integer
Dim curTop As Double
Dim maxHeight As Double
Dim workHeight As Double
workHeight = PageHeight - MarginBottom - FooterHeight - MarginTop
curTop = MarginTop
maxHeight = workHeight
For i = 1 To Ranged
If WeaponOverflowFrom(i) > -1 Then
Do
curTop = PrintOverflowWeapons(i, curTop, maxHeight, WeaponOverflowFrom(i))
curTop = curTop + 1 / 16
maxHeight = workHeight - (curTop - MarginTop)
If WeaponOverflowFrom(i) > -1 Then
'still didn't finish
MyPrintDoc.NewPage()
curTop = MarginTop
maxHeight = workHeight
Else
'finished
Exit Do
End If
Loop
End If
Next
End Sub
Private Sub PrintPageGrimoire()
Dim workHeight As Double
workHeight = PageHeight - MarginBottom - FooterHeight - MarginTop
GrimoireOverflowFrom = 0
Do
PrintOverflowGrimoire(MarginTop, workHeight, GrimoireOverflowFrom)
If GrimoireOverflowFrom > -1 Then
'still didn't finish
MyPrintDoc.NewPage()
Else
'finished
Exit Do
End If
Loop
End Sub
Private Function PrintSectionSpeedRangeTable(LeftSide As Double, TopSide As Double) As Double
Dim boxWidth, boxHeight, boxLeft, boxTop As Double
Dim curTop As Double
Dim curRow As Integer
Dim maxHeight As Double
Dim rowHeight As Double
Dim BaseFont As New Font("Times New Roman", 10)
Dim HeaderFont As New Font("Times New Roman", 10, FontStyle.Bold)
Dim SubHeaderFont As New Font("Times New Roman", 9)
Dim SubHeaderBoldFont As New Font("Times New Roman", 9, FontStyle.Bold)
Dim TableCenterStyle As Style = MyPrintDoc.Style.Children.Add()
TableCenterStyle.Font = BaseFont
TableCenterStyle.TextAlignHorz = AlignHorzEnum.Center
Dim TableRightStyle As Style = MyPrintDoc.Style.Children.Add()
TableRightStyle.Font = BaseFont
TableRightStyle.TextAlignHorz = AlignHorzEnum.Right
Dim TableLeftStyle As Style = MyPrintDoc.Style.Children.Add()
TableLeftStyle.Font = BaseFont
TableLeftStyle.TextAlignHorz = AlignHorzEnum.Left
Dim ld As New C1.C1Preview.LineDef(0.01, MyOptions.Value("SheetTextColor"), Drawing2D.DashStyle.Solid)
Dim ldShade As New C1.C1Preview.LineDef(0.01, Color.LightGray, Drawing2D.DashStyle.Solid)
Dim ldLine As New C1.C1Preview.LineDef(0.01, MyOptions.Value("SheetTextColor"), Drawing2D.DashStyle.Dot)
boxLeft = LeftSide
boxWidth = 1.75
boxTop = TopSide
boxHeight = SpeedRangeTableHeight
maxHeight = boxHeight
rowHeight = GetHeight("X", HeaderFont)
curTop = boxTop
MyPrintDoc.RenderDirectText(boxLeft + 1 / 32, curTop, "SPEED/RANGE TABLE", boxWidth, HeaderFont, MyOptions.Value("SheetTextColor"), AlignHorzEnum.Left)
curTop = curTop + rowHeight
maxHeight = boxHeight - (curTop - boxTop)
MyPrintDoc.RenderDirectText(boxLeft + 1 / 32, curTop, "For complete table, see p. 550.", boxWidth, SubHeaderFont, MyOptions.Value("SheetTextColor"), AlignHorzEnum.Left)
curTop = curTop + GetHeight("X", SubHeaderFont)
maxHeight = boxHeight - (curTop - boxTop)
curTop = curTop + rowHeight / 2
maxHeight = boxHeight - (curTop - boxTop)
Dim Mods() As Integer = {0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15}
Dim Vals() As Integer = {2, 3, 5, 7, 10, 15, 20, 30, 50, 70, 100, 150, 200, 300, 500, 700}
Dim Shades() As Integer = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}
Dim Widths() As Double = {0.65, 5 / 8, boxWidth - 0.65 - 5 / 8}
rowHeight = GetHeight("X", SubHeaderBoldFont)
MyPrintDoc.RenderDirectText(boxLeft, curTop, "Speed/", Widths(0), SubHeaderBoldFont, MyOptions.Value("SheetTextColor"), AlignHorzEnum.Center)
MyPrintDoc.RenderDirectText(boxLeft + Widths(0), curTop, "Linear", boxWidth - Widths(0), SubHeaderBoldFont, MyOptions.Value("SheetTextColor"), AlignHorzEnum.Center)
curTop = curTop + rowHeight
maxHeight = boxHeight - (curTop - boxTop)
MyPrintDoc.RenderDirectText(boxLeft, curTop, "Range", Widths(0), SubHeaderBoldFont, MyOptions.Value("SheetTextColor"), AlignHorzEnum.Center)
MyPrintDoc.RenderDirectText(boxLeft + Widths(0), curTop, "Measurement", boxWidth - Widths(0), SubHeaderBoldFont, MyOptions.Value("SheetTextColor"), AlignHorzEnum.Center)
curTop = curTop + rowHeight
maxHeight = boxHeight - (curTop - boxTop)
MyPrintDoc.RenderDirectText(boxLeft, curTop, "Modifier", Widths(0), SubHeaderBoldFont, MyOptions.Value("SheetTextColor"), AlignHorzEnum.Center)
MyPrintDoc.RenderDirectText(boxLeft + Widths(0), curTop, "(range/speed)", boxWidth - Widths(0), SubHeaderBoldFont, MyOptions.Value("SheetTextColor"), AlignHorzEnum.Center)
curTop = curTop + rowHeight
maxHeight = boxHeight - (curTop - boxTop)
rowHeight = GetHeight("X", TableCenterStyle)
For curRow = 0 To 15
If Shades(curRow) Then
MyPrintDoc.RenderDirectRectangle(boxLeft, curTop, boxWidth, rowHeight, ldShade, Color.LightGray)
End If
If LineBefore Then
MyPrintDoc.RenderDirectLine(boxLeft, curTop, boxLeft + boxWidth, curTop, ldLine)
End If
If curRow = 0 Then
MyPrintDoc.RenderDirectText(boxLeft + Widths(0) + Widths(1) + 1 / 32, curTop, "or less", Widths(2) - 1 / 32, rowHeight, TableLeftStyle)
End If
MyPrintDoc.RenderDirectText(boxLeft, curTop, Mods(curRow), Widths(0) / 2, rowHeight, TableRightStyle)
MyPrintDoc.RenderDirectText(boxLeft + Widths(0), curTop, Vals(curRow) & " yd", Widths(1), rowHeight, TableRightStyle)
curTop = curTop + rowHeight
maxHeight = boxHeight - (curTop - boxTop)
Next
MyPrintDoc.RenderDirectRectangle(boxLeft, boxTop, boxWidth, boxHeight, ld)
Return boxTop + boxHeight
End Function
Private Function PrintSectionHitLocationTable(LeftSide As Double, TopSide As Double) As Double
Dim boxWidth, boxHeight, boxLeft, boxTop As Double
Dim curTop As Double
Dim curRow As Integer
Dim maxHeight As Double
Dim rowHeight As Double
Dim BaseFont As New Font("Times New Roman", 10)
Dim HeaderFont As New Font("Times New Roman", 10, FontStyle.Bold)
Dim SubHeaderFont As New Font("Times New Roman", 9)
Dim SubHeaderBoldFont As New Font("Times New Roman", 9, FontStyle.Bold)
Dim TableCenterStyle As Style = MyPrintDoc.Style.Children.Add()
TableCenterStyle.Font = BaseFont
TableCenterStyle.TextAlignHorz = AlignHorzEnum.Center
Dim TableRightStyle As Style = MyPrintDoc.Style.Children.Add()
TableRightStyle.Font = BaseFont
TableRightStyle.TextAlignHorz = AlignHorzEnum.Right
Dim TableLeftStyle As Style = MyPrintDoc.Style.Children.Add()
TableLeftStyle.Font = BaseFont
TableLeftStyle.TextAlignHorz = AlignHorzEnum.Left
Dim ld As New C1.C1Preview.LineDef(0.01, MyOptions.Value("SheetTextColor"), Drawing2D.DashStyle.Solid)
Dim ldShade As New C1.C1Preview.LineDef(0.01, Color.LightGray, Drawing2D.DashStyle.Solid)
Dim ldLine As New C1.C1Preview.LineDef(0.01, MyOptions.Value("SheetTextColor"), Drawing2D.DashStyle.Dot)
boxLeft = LeftSide
boxWidth = 1 + 4 / 16
boxTop = TopSide
boxHeight = 2
maxHeight = boxHeight
rowHeight = GetHeight("X", HeaderFont)
curTop = boxTop
MyPrintDoc.RenderDirectText(boxLeft + 1 / 32, curTop, "HIT LOCATION", boxWidth, HeaderFont, MyOptions.Value("SheetTextColor"), AlignHorzEnum.Left)
curTop = curTop + rowHeight
maxHeight = boxHeight - (curTop - boxTop)
curTop = curTop + rowHeight / 2 - 1 / 32
maxHeight = boxHeight - (curTop - boxTop)
Dim Mods() As Integer = {0, -2, -3, -4, -5, -5, -7}
Dim Vals() As String = {"Torso", "Arm/Leg", "Groin", "Hand", "Face", "Neck", "Skull"}
Dim Shades() As Integer = {1, 1, 0, 0, 1, 1, 0}
Dim Widths() As Double = {10 / 16, boxWidth - 10 / 16}
rowHeight = GetHeight("X", SubHeaderBoldFont)
MyPrintDoc.RenderDirectText(boxLeft, curTop, "Modifier", Widths(0), SubHeaderBoldFont, MyOptions.Value("SheetTextColor"), AlignHorzEnum.Center)
MyPrintDoc.RenderDirectText(boxLeft + Widths(0), curTop, "Location", boxWidth - Widths(0), SubHeaderBoldFont, MyOptions.Value("SheetTextColor"), AlignHorzEnum.Left)
curTop = curTop + rowHeight
maxHeight = boxHeight - (curTop - boxTop)
rowHeight = GetHeight("X", TableCenterStyle)
For curRow = 0 To 6