SpatialFear.SFHUD

00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
//=============================================================================
// Spatial Fear
// Name: SFHUD
// Description: SpatialFear main HUD class.
//
// Author: Markus Nuebel
// Modified By: Chris Rogers
//=============================================================================
class SFHUD extends ChallengeHUD;

enum EHealthState
{
     HEALTH_GreenFast,
     HEALTH_GreenSlow,
     HEALTH_YellowFast,
     HEALTH_YellowSlow,
     HEALTH_RedFast,
     HEALTH_RedSlow,
     HEALTH_Critical,
     HEALTH_Undefined,
};

enum EArmorState
{
     ARMOR_Level5,
     ARMOR_Level4,
     ARMOR_Level3,
     ARMOR_Level2,
     ARMOR_Level1,
     ARMOR_Level0,
     ARMOR_Undefined,
};

// Style of damage protection
enum EDamageProtection
{
	DP_None,
	DP_Gravity,
	DP_Ballistic,	// shot
	DP_Chemical,	// Corroded
	DP_Fire,		// Burned
	DP_Radiation,	// Radiation
};

const constScreenMaxX     = 1280;
const constScreenMaxY     = 1024;

struct Region
{
     var() int X;
     var() int Y;
     var() int W;
     var() int H;
};

var SFFontInfo m_Fonts; // Private; Font factory
var bool m_bHideStatus; // Private: Enables/Disables HUD drawing
var Texture		m_texGreen;  // Private: Procedural green ring
var Texture     m_texYellow; // Private: Procedural yellow ring
var Texture     m_texRed; // Private: Procedural red ring
var Texture		m_arTexArmor[6]; // Private: textures for armor rings
var SFAnimatedTextureHelper m_oGreenHelper; // Private helper function to REALLY stop an animated texture, used for the green ring.
var SFAnimatedTextureHelper m_oYellowHelper; // Private helper function to REALLY stop an animated texture, used for the green yellow.
var SFAnimatedTextureHelper m_oRedHelper; // Private helper function to REALLY stop an animated texture, used for the green red.
var float     m_fFastRot; // Private: fast rotation speed: Default: 3000 msecs
var float     m_fSlowRot; // Private: fast rotation speed: Default: 5000 msecs
var EHealthState     m_eHealthState; // Private: current health state;
var Region     m_ScaledClippingRegion;
var float m_fFastRotation; // Private: Animated Texture MaxFrameRate for fast ring rotations.
var float m_fSlowRotation; // Private: Animated Texture MaxFrameRate for slow ring rotations.

// Canvas info
var float	m_fHUDScale; // Private: current HUD scale. Depends on screen resolution and user defined HUD size.
var int		m_nCanvasClipX;
var int		m_nCanvasClipY;

// Crosshair change
var globalconfig int	CrosshairCountSF;
var globalconfig string CrossHairsSF[20];

// HUD window manager
var SFHUDWindowMgr	m_oHUDWndMgr;

var bool			m_bItemBeltPopulated;



var float m_fFocusDistance;			// Private: distance to check for tip actors
var float m_fCommTipDistance;		// Private: distance to check for communication tip actors

var class <Actor> m_clsActorTipTrigger; // Private class, for which Actor tips should be displayed


// Smart vest upgrade modules
var int					m_nUpgradeIconWidth, m_nUpgradeIconHeight;
var SFIconWindow		m_winChemicalUpgrade;
var int					m_nChemUGX, m_nChemUGY;
var SFIconWindow		m_winFireUpgrade;
var int					m_nFireUGX, m_nFireUGY;
var SFIconWindow		m_winRadUpgrade;
var int					m_nRadUGX, m_nRadUGY;
var SFIconWindow		m_winComAvailable;
var int					m_nComUGX, m_nComUGY;
var int 				m_nComIconWidth, m_nComIconHeight;

// UseKeyTrigger hint
var int					m_nUseKeyUGX, m_nUseKeyUGY;
var int 				m_nUseKeyIconWidth, m_nUseKeyIconHeight;
var int					m_nUseKeyHintCounter;	// Used to not check the hint every frame
var SFIconWindow		m_winUseKeyNear;


// Communication tips
var class<Actor>	m_clsCommunicationTip;
var name			m_nameTipActor;
var string			m_strCommunicationTip;
var bool			m_bShowCommunicationTip;
// Communication
var SFCommunication	m_oAvailableCom;	// A communication will not travel!
var SFCommunication	m_oComWaitingLine;	// A communication will not travel!

// Communication Yes/No box
var string			m_strYesText;
var string			m_strNoText;

var SFPickupTracker		m_oPickupTracker;

// Window creation stuff
var	int						m_nTicksPassed;
var class<UWindowWindow>	m_clsWindow;
var int						m_nWinLeft,m_nWinTop,m_nWinWidth,m_nWinHeight;
var transient UWindowWindow			m_winMain;

var bool bFirstTime;

#exec OBJ LOAD FILE=..\Textures\LadrStatic.utx PACKAGE=Botpack.LadrStatic

function bool DrawSpeechArea( Canvas Canvas, float XL, float YL )
{
	local float YPos, Yadj;
	local float WackNumber;
	local int paneltype;

//log("DrawSpeechArea");
	YPos = FMax(YL*4 + 8, 70*Scale);
	Yadj = YPos + 7*Scale;
	YPos *=2;
	MinFaceAreaOffset = -1 * Yadj;
	Canvas.Style = ERenderStyle.STY_Translucent;
	Canvas.DrawColor = HUDColor * MessageFadeTime;

	Canvas.SetPos(FaceAreaOffset, 0);
	Canvas.DrawTile(texture'LadrStatic.Static_a00', Yadj, Yadj, 0, 0, texture'LadrStatic.Static_a00'.USize, texture'LadrStatic.Static_a00'.VSize);

	WackNumber = 512*Scale - 64 + FaceAreaOffset; // 256*Scale - (512*Scale - (768*Scale - 64 + FaceAreaOffset));
	if ( !PlayerOwner.Player.Console.bTyping )
	{
		paneltype = 0;
	}
	else
	{
		Canvas.StrLen("(>"@PlayerOwner.Player.Console.TypedStr$"_", XL, YL);
		if (XL < 768*Scale)
		{
			paneltype = 1;
		}
		else
		{
			paneltype = 2;
		}
	}

	Canvas.SetPos(Yadj + FaceAreaOffset, 0);
	Canvas.DrawTile(FP1[paneltype], 256*Scale - FaceAreaOffset, YPos, 0, 0, FP1[paneltype].USize, FP1[paneltype].VSize);
//log("Yadj + FaceAreaOffset" $ (Yadj + FaceAreaOffset) $ " FP1[paneltype] " $ FP1[paneltype]$ " 256*Scale - FaceAreaOffset " $ (256*Scale - FaceAreaOffset) $ "YPos " $ YPos $ "FP1[paneltype].USize " $ FP1[paneltype].USize $ " FP1[paneltype].VSize " $ FP1[paneltype].VSize);

	Yadj += 256 * Scale;
	Canvas.SetPos(Yadj, 0);
	Canvas.DrawTile(FP2[paneltype], WackNumber, YPos, 0, 0, FP2[paneltype].USize, FP2[paneltype].VSize);

	Canvas.SetPos(Yadj + WackNumber, 0);
	Canvas.DrawTile(FP3[paneltype], 64, YPos, 0, 0, FP3[paneltype].USize, FP3[paneltype].VSize);
}

simulated function HUDSetup(canvas canvas)
{
	local int FontSize;


	bResChanged = (Canvas.ClipX != OldClipX);
	OldClipX = Canvas.ClipX;

	PlayerOwner = PlayerPawn(Owner);
	if ( PlayerOwner.ViewTarget == None )
		PawnOwner = PlayerOwner;
	else if ( PlayerOwner.ViewTarget.bIsPawn )
		PawnOwner = Pawn(PlayerOwner.ViewTarget);
	else
		PawnOwner = PlayerOwner;

	// Setup the way we want to draw all HUD elements
	Canvas.Reset();

	Canvas.SpaceX=0;
	Canvas.bNoSmooth = True;

	FontSize = Min(3, HUDScale * Canvas.ClipX/500);
	Scale = (HUDScale * Canvas.ClipX)/1280.0;

	Canvas.Font = MyFonts.GetSmallFont( Canvas.ClipX );

	SolidHUDColor = FavoriteHUDColor * 15.9;
	if ( (Opacity == 16) || !Level.bHighDetailMode )
	{
		Style = ERenderStyle.STY_Normal;
		BaseColor = WhiteColor;
		HUDColor = SolidHUDColor;
	}
	else
	{
//log("translucent");
		Style = ERenderStyle.STY_Translucent;
		BaseColor = (16 * Opacity + 15) * UnitColor;
		HUDColor = FavoriteHUDColor * (Opacity + 0.9);
	}
	Canvas.DrawColor = BaseColor;
	Canvas.Style = Style;
	bLowRes = ( Canvas.ClipX < 400 );
	if ( bLowRes )
		WeaponScale = 1.0;
}

simulated function PostRender( canvas Canvas )
{
	local float XL, YL, XPos, YPos, FadeValue;
	local string Message;
	local int M, i, j, k, XOverflow;
	local float OldOriginX;

	HUDSetup(canvas);
	if ( (PawnOwner == None) || (PlayerOwner.PlayerReplicationInfo == None) )
		return;

	if ( bShowInfo )
	{
		ServerInfo.RenderInfo( Canvas );
		return;
	}

	Canvas.Font = m_Fonts.GetSmallFont( Canvas.ClipX );
	OldOriginX = Canvas.OrgX;
//log("OldOriginX: " $ OldOriginX );
	// Master message short queue control loop.
	Canvas.Font = m_Fonts.GetSmallFont( Canvas.ClipX );
	Canvas.StrLen("TEST", XL, YL);
	Canvas.SetClip(768*Scale - 10, Canvas.ClipY);
//log("SetClip: " $ 768*Scale - 10 );

//log("Canvas1: X " $ Canvas.OrgX $ "Canvas: Y " $ Canvas.OrgY );
	bDrawFaceArea = false;
	if ( !bHideFaces && !PlayerOwner.bShowScores && !bForceScores && !bHideHUD
			&& !PawnOwner.PlayerReplicationInfo.bIsSpectator && (Scale >= 0.4) )
	{
		DrawSpeechArea(Canvas, XL, YL);
		bDrawFaceArea = (FaceTexture != None) && (FaceTime > Level.TimeSeconds);
		if ( bDrawFaceArea )
		{
			if ( !bHideHUD && ((PawnOwner.PlayerReplicationInfo == None) || !PawnOwner.PlayerReplicationInfo.bIsSpectator) )
			{
//log("Moving origin");
				Canvas.SetOrigin( FMax(YL*4 + 8, 70*Scale) + 7*Scale + 6 + FaceAreaOffset, Canvas.OrgY );
			}
		}
	}
//log("Canvas2: X " $ Canvas.OrgX $ "Canvas: Y " $ Canvas.OrgY );

	for (i=0; i<4; i++)
	{
		if ( ShortMessageQueue[i].Message != None )
		{
//log("ShortMessageQueue[" $ i $ "].Message: " $ ShortMessageQueue[i].Message);
			j++;

			if ( bResChanged || (ShortMessageQueue[i].XL == 0) )
			{
				if ( ShortMessageQueue[i].Message.Default.bComplexString )
					Canvas.StrLen(ShortMessageQueue[i].Message.Static.AssembleString(
											self,
											ShortMessageQueue[i].Switch,
											ShortMessageQueue[i].RelatedPRI,
											ShortMessageQueue[i].StringMessage),
								   ShortMessageQueue[i].XL, ShortMessageQueue[i].YL);
				else
					Canvas.StrLen(ShortMessageQueue[i].StringMessage, ShortMessageQueue[i].XL, ShortMessageQueue[i].YL);
				Canvas.StrLen("TEST", XL, YL);
				ShortMessageQueue[i].numLines = 1;
				if ( ShortMessageQueue[i].YL > YL )
				{
					ShortMessageQueue[i].numLines++;
					for (k=2; k<4-i; k++)
					{
						if (ShortMessageQueue[i].YL > YL*k)
							ShortMessageQueue[i].numLines++;
					}
				}
			}

			// Keep track of the amount of lines a message overflows, to offset the next message with.
			Canvas.SetPos(6, 2 + YL * YPos);
			YPos += ShortMessageQueue[i].numLines;
			if ( YPos > 4 )
				break;

			if ( ShortMessageQueue[i].Message.Default.bComplexString )
			{
				// Use this for string messages with multiple colors.
				ShortMessageQueue[i].Message.Static.RenderComplexMessage(
					Canvas,
					ShortMessageQueue[i].XL,  YL,
					ShortMessageQueue[i].StringMessage,
					ShortMessageQueue[i].Switch,
					ShortMessageQueue[i].RelatedPRI,
					None,
					ShortMessageQueue[i].OptionalObject
					);
			}
			else
			{
				Canvas.DrawColor = ShortMessageQueue[i].Message.Default.DrawColor;
				Canvas.DrawText(ShortMessageQueue[i].StringMessage, False);
			}
		}
	}

	Canvas.DrawColor = WhiteColor;
	Canvas.SetClip(OldClipX, Canvas.ClipY);
	Canvas.SetOrigin(OldOriginX, Canvas.OrgY);

	if ( PlayerOwner.bShowScores || bForceScores )
	{
		if ( (PlayerOwner.Scoring == None) && (PlayerOwner.ScoringType != None) )
			PlayerOwner.Scoring = Spawn(PlayerOwner.ScoringType, PlayerOwner);
		if ( PlayerOwner.Scoring != None )
		{
			PlayerOwner.Scoring.OwnerHUD = self;
			PlayerOwner.Scoring.ShowScores(Canvas);
			if ( PlayerOwner.Player.Console.bTyping )
				DrawTypingPrompt(Canvas, PlayerOwner.Player.Console);
			return;
		}
	}

	YPos = FMax(YL*4 + 8, 70*Scale);
	if ( bDrawFaceArea )
		DrawTalkFace( Canvas,0, YPos );
	if (j > 0)
	{
		bDrawMessageArea = True;
		MessageFadeCount = 2;
	}
	else
		bDrawMessageArea = False;

	if ( !bHideCenterMessages )
	{
		// Master localized message control loop.
		for (i=0; i<10; i++)
		{
			if (LocalMessages[i].Message != None)
			{
				if (LocalMessages[i].Message.Default.bFadeMessage && Level.bHighDetailMode)
				{
					Canvas.Style = ERenderStyle.STY_Translucent;
					FadeValue = (LocalMessages[i].EndOfLife - Level.TimeSeconds);
					if (FadeValue > 0.0)
					{
						if ( bResChanged || (LocalMessages[i].XL == 0) )
						{
							if ( LocalMessages[i].Message.Static.GetFontSize(LocalMessages[i].Switch) == 1 )
								LocalMessages[i].StringFont = m_Fonts.GetBigFont( Canvas.ClipX );
							else // ==2
								LocalMessages[i].StringFont = m_Fonts.GetHugeFont( Canvas.ClipX );
							Canvas.Font = LocalMessages[i].StringFont;
							Canvas.StrLen(LocalMessages[i].StringMessage, LocalMessages[i].XL, LocalMessages[i].YL);
							LocalMessages[i].YPos = LocalMessages[i].Message.Static.GetOffset(LocalMessages[i].Switch, LocalMessages[i].YL, Canvas.ClipY);
						}
						Canvas.Font = LocalMessages[i].StringFont;
						Canvas.DrawColor = LocalMessages[i].DrawColor * (FadeValue/LocalMessages[i].LifeTime);
						Canvas.SetPos( 0.5 * (Canvas.ClipX - LocalMessages[i].XL), LocalMessages[i].YPos );
						Canvas.DrawText( LocalMessages[i].StringMessage, False );
					}
				}
				else
				{
					if ( bResChanged || (LocalMessages[i].XL == 0) )
					{
						if ( LocalMessages[i].Message.Static.GetFontSize(LocalMessages[i].Switch) == 1 )
							LocalMessages[i].StringFont = m_Fonts.GetBigFont( Canvas.ClipX );
						else // == 2
							LocalMessages[i].StringFont = m_Fonts.GetHugeFont( Canvas.ClipX );
						Canvas.Font = LocalMessages[i].StringFont;
						Canvas.StrLen(LocalMessages[i].StringMessage, LocalMessages[i].XL, LocalMessages[i].YL);
						LocalMessages[i].YPos = LocalMessages[i].Message.Static.GetOffset(LocalMessages[i].Switch, LocalMessages[i].YL, Canvas.ClipY);
					}
					Canvas.Font = LocalMessages[i].StringFont;
					Canvas.Style = ERenderStyle.STY_Normal;
					Canvas.DrawColor = LocalMessages[i].DrawColor;
					Canvas.SetPos( 0.5 * (Canvas.ClipX - LocalMessages[i].XL), LocalMessages[i].YPos );
					Canvas.DrawText( LocalMessages[i].StringMessage, False );
				}
			}
		}
	}
	Canvas.Style = ERenderStyle.STY_Normal;

	if ( !PlayerOwner.IsInState('PlayerChat') && !PlayerOwner.bBehindView && (PawnOwner.Weapon != None) && (Level.LevelAction == LEVACT_None) )
	{
		Canvas.DrawColor = WhiteColor;
		PawnOwner.Weapon.PostRender(Canvas);
		if ( !PawnOwner.Weapon.bOwnsCrossHair )
			DrawCrossHair(Canvas, 0,0 );
	}

	if ( (PawnOwner != Owner) && PawnOwner.bIsPlayer )
	{
		Canvas.Font = m_Fonts.GetSmallFont( Canvas.ClipX );
		Canvas.bCenter = true;
		Canvas.Style = ERenderStyle.STY_Normal;
		Canvas.DrawColor = CyanColor * TutIconBlink;
		Canvas.SetPos(4, Canvas.ClipY - 96 * Scale);
		Canvas.DrawText( LiveFeed$PawnOwner.PlayerReplicationInfo.PlayerName, true );
		Canvas.bCenter = false;
		Canvas.DrawColor = WhiteColor;
		Canvas.Style = Style;
	}

	if ( bStartUpMessage && (Level.TimeSeconds < 5) )
	{
		bStartUpMessage = false;
		PlayerOwner.SetProgressTime(7);
	}
	if ( (PlayerOwner.ProgressTimeOut > Level.TimeSeconds) && !bHideCenterMessages )
		DisplayProgressMessage(Canvas);

	// Display MOTD
	if ( MOTDFadeOutTime > 0.0 )
		DrawMOTD(Canvas);

	if( !bHideHUD )
	{
		if ( !PawnOwner.PlayerReplicationInfo.bIsSpectator )
		{
			Canvas.Style = Style;

			// Draw Health/Armor status
			DrawStatus(Canvas);

			// Display Weapons
			if ( !bHideAllWeapons )
				DrawWeapons(Canvas);
			else if ( Level.bHighDetailMode
					&& (PawnOwner == PlayerOwner) && (PlayerOwner.Handedness == 2) )
			{
				// if weapon bar hidden and weapon hidden, draw weapon name when it changes
				if ( PawnOwner.PendingWeapon != None )
				{
					WeaponNameFade = 1.0;
					Canvas.Font = m_Fonts.GetBigFont( Canvas.ClipX );
					Canvas.DrawColor = PawnOwner.PendingWeapon.NameColor;
					Canvas.SetPos(Canvas.ClipX - 360 * Scale, Canvas.ClipY - 64 * Scale);
					Canvas.DrawText(PawnOwner.PendingWeapon.ItemName, False);
				}
				else if ( (Level.NetMode == NM_Client)
						&& PawnOwner.IsA('TournamentPlayer') && (TournamentPlayer(PawnOwner).ClientPending != None) )
				{
					WeaponNameFade = 1.0;
					Canvas.Font = m_Fonts.GetBigFont( Canvas.ClipX );
					Canvas.DrawColor = TournamentPlayer(PawnOwner).ClientPending.NameColor;
					Canvas.SetPos(Canvas.ClipX - 360 * Scale, Canvas.ClipY - 64 * Scale);
					Canvas.DrawText(TournamentPlayer(PawnOwner).ClientPending.ItemName, False);
				}
				else if ( (WeaponNameFade > 0) && (PawnOwner.Weapon != None) )
				{
					Canvas.Font = m_Fonts.GetBigFont( Canvas.ClipX );
					Canvas.DrawColor = PawnOwner.Weapon.NameColor;
					if ( WeaponNameFade < 1 )
						Canvas.DrawColor = Canvas.DrawColor * WeaponNameFade;
					Canvas.SetPos(Canvas.ClipX - 360 * Scale, Canvas.ClipY - 64 * Scale);
					Canvas.DrawText(PawnOwner.Weapon.ItemName, False);
				}
			}
			// Display Frag count
			if ( !bAlwaysHideFrags && !bHideFrags )
				DrawFragCount(Canvas);
		}
		// Team Game Synopsis
		if ( !bHideTeamInfo )
			DrawGameSynopsis(Canvas);

		// Display Identification Info
		if ( PawnOwner == PlayerOwner )
			DrawIdentifyInfo(Canvas);

		if ( HUDMutator != None )
			HUDMutator.PostRender(Canvas);

		if ( (PlayerOwner.GameReplicationInfo != None) && (PlayerPawn(Owner).GameReplicationInfo.RemainingTime > 0) )
		{
			if ( TimeMessageClass == None )
				TimeMessageClass = class<CriticalEventPlus>(DynamicLoadObject("Botpack.TimeMessage", class'Class'));

			if ( (PlayerOwner.GameReplicationInfo.RemainingTime <= 300)
			  && (PlayerOwner.GameReplicationInfo.RemainingTime != LastReportedTime) )
			{
				LastReportedTime = PlayerOwner.GameReplicationInfo.RemainingTime;
				if ( PlayerOwner.GameReplicationInfo.RemainingTime <= 30 )
				{
					bTimeValid = ( bTimeValid || (PlayerOwner.GameReplicationInfo.RemainingTime > 0) );
					if ( PlayerOwner.GameReplicationInfo.RemainingTime == 30 )
						TellTime(5);
					else if ( bTimeValid && PlayerOwner.GameReplicationInfo.RemainingTime <= 10 )
						TellTime(16 - PlayerOwner.GameReplicationInfo.RemainingTime);
				}
				else if ( PlayerOwner.GameReplicationInfo.RemainingTime % 60 == 0 )
				{
					M = PlayerOwner.GameReplicationInfo.RemainingTime/60;
					TellTime(5 - M);
				}
			}
		}
	}
	if ( PlayerOwner.Player.Console.bTyping )
		DrawTypingPrompt(Canvas, PlayerOwner.Player.Console);

	if ( PlayerOwner.bBadConnectionAlert && (PlayerOwner.Level.TimeSeconds > 5) )
	{
		Canvas.Style = ERenderStyle.STY_Normal;
		Canvas.DrawColor = WhiteColor;
		Canvas.SetPos(Canvas.ClipX - (64*Scale), Canvas.ClipY / 2);
		Canvas.DrawIcon(texture'DisconnectWarn', Scale);
	}
}

// function
exec function bool openWindow(class<UWindowWindow> clsWindow, int nLeft, int nTop, int nWidht, int nHeight)
{
	local PlayerPawn P;
	local WindowConsole C;

	// Check for a pawn
	P = PlayerPawn(Owner);
	if (P==None)
	{
		class'SFUtils'.Static.sfError("SFHUD - openWindow: Cannot open a window on a non player actor.");
		return false;
	}

	// Get the console from the playerpawn
	C = WindowConsole(P.Player.Console);
	if (C==None)
	{
		class'SFUtils'.Static.sfError("SFHUD - openWindow: Cannot retrieve console reference.");
		return false;
	}

	// Check, if this console already has a root window
	if (!C.bCreatedRoot || C.Root==None)
	{
		// Tell the console to create the root
		C.CreateRootWindow(None);
	}

	// Hide the status and menu bars and all other windows, so that our window alone will show
	C.bQuickKeyEnable = true;

	// Launch the console
	C.LaunchUWindow();

	// Save the info needed by setupWindow
	m_clsWindow		= clsWindow;
	m_nWinLeft		= nLeft;
	m_nWinTop		= nTop;
	m_nWinWidth		= nWidht;
	m_nWinHeight	= nHeight;

	// tick counts down to zero and then calls setup window
	// by this time the console should be up and running
	m_nTicksPassed = 1;

	return true;
}

// This function sets up a window using the launched console
simulated function bool setupWindow ()
{
	local WindowConsole C;

	// Get created console window
	C = WindowConsole(PlayerPawn(Owner).Player.Console);

	// Create the new client window
	m_winMain = C.Root.CreateWindow(m_clsWindow, m_nWinLeft, m_nWinTop, m_nWinWidth, m_nWinHeight);

	if (None == m_winMain)
	{
		class'SFUtils'.Static.sfError("SFHUD - setupWindow: Cannot created window: " $ m_clsWindow.name);
		return false;
	}

	// We don't want to see the console, jus the client window
	if ( C.bShowConsole )
		C.HideConsole();

	// Make it show even when everything else is hidden through bQuickKeyEnable
	m_winMain.bLeaveOnScreen = True;

	// Check for Quicksave window
	if(m_winMain.isA('SFQuickSaveBox'))
		SFQuickSaveBox(m_winMain).m_oPlayer=SFPlayer(Owner);
	// Check for communication yes/no box
	if(m_winMain.isA('SFCommYesNo'))
		SFCommYesNo(m_winMain).m_oHUD=SFHUD(SFPlayer(Owner).myHUD);


	// Show the window
	m_winMain.ShowWindow();







	return true;
}

// Called every tick
simulated function Tick(float DeltaTime)
{
	if (m_nTicksPassed != 0)
	{
		if (m_nTicksPassed++ == 2)
		{
			// create configured window
			setupWindow();
			// Reset TicksPassed to 0
			m_nTicksPassed = 0;
		}
	}

	// Check for communication in line
	if(None != m_oComWaitingLine)
	{
		if(m_oHUDWndMgr.canCancelCurrentCom())
		{
			// Try again
			playCommunication();
			// Clear waiting line
			m_oComWaitingLine	= None;
		}

	}
}

exec function SFShowAll()
{
	m_oHUDWndMgr.bShowAll = !m_oHUDWndMgr.bShowAll;

	m_winChemicalUpgrade.show();
	m_winRadUpgrade.show();
	m_winFireUpgrade.show();
	m_winComAvailable.show();
	m_winUseKeyNear.show();

}

// All initialization stuff
simulated function PostBeginPlay()
{
     // Call to base class
     Super.PostBeginPlay();


     // Load needed textures (not any more - useless function)
     // loadTextures();

     // Setup font factory
     m_Fonts = spawn(class<SFFontInfo>(DynamicLoadObject("SpatialFear.SFFontInfo", class'Class')));

	 // Some inits
	 m_fHUDScale = Scale*StatusScale;


	if((None != Owner) && Owner.IsA('SFPlayer'))
	{
		 // Setup  the window manager
		 m_oHUDWndMgr = Spawn(class'SFHUDWindowMgr');
		 m_oHUDWndMgr.init(SFPlayer(Owner), m_fHUDScale);


		// Setup smart vest upgrade modules
		// Chemical upgrade
		m_winChemicalUpgrade = PlayerPawn(Owner).Spawn(class'SFIconWindow');
		if(None != m_winChemicalUpgrade)
		{
			m_winChemicalUpgrade.init(m_fHUDScale, m_nChemUGX, m_nChemUGY, m_nUpgradeIconWidth, m_nUpgradeIconHeight, Pawn(Owner));
			m_winChemicalUpgrade.setTexture(Texture'SFResource1.Icons.ChemModIco');
			m_winChemicalUpgrade.setSingleFadeReverse(3.0f);
		}
		// Fire upgrade
		m_winFireUpgrade = PlayerPawn(Owner).Spawn(class'SFIconWindow');
		if(None != m_winFireUpgrade)
		{
			m_winFireUpgrade.init(m_fHUDScale, m_nFireUGX, m_nFireUGY, m_nUpgradeIconWidth, m_nUpgradeIconHeight, Pawn(Owner));
			m_winFireUpgrade.setTexture(Texture'SFResource1.Icons.FireModIco');
			m_winFireUpgrade.setSingleFadeReverse(3.0f);
		}
		// Radiation upgrade
		m_winRadUpgrade	= PlayerPawn(Owner).Spawn(class'SFIconWindow');
		if(None != m_winRadUpgrade)
		{
			m_winRadUpgrade.init(m_fHUDScale, m_nRadUGX, m_nRadUGY, m_nUpgradeIconWidth, m_nUpgradeIconHeight, Pawn(Owner));
			m_winRadUpgrade.setTexture(Texture'SFResource1.Icons.RadModIco');
			m_winRadUpgrade.setSingleFadeReverse(3.0f);
		}
		// The "communication available" icon
		m_winComAvailable = PlayerPawn(Owner).Spawn(class'SFIconWindow');
		m_winComAvailable.init(m_fHUDScale, 14, 832, 256, 256, Pawn(Owner));
		m_winComAvailable.m_nDisplaySize	= 256;
		// m_winComAvailable.setTexture(Texture'SFResource1.CaptainBtn.comm_a00');
		m_winComAvailable.setTexture(Texture'SFInterface.HUD.MSet_Comm_a00');
		m_winComAvailable.m_sndOpen=Sound'SFResource1.Window.IncommingCapMsg';
		m_winComAvailable.m_fOpenSoundVol=2.0;


		// The "UseKeyTrigger Near" icon
		m_winUseKeyNear = PlayerPawn(Owner).Spawn(class'SFIconWindow');
		m_winUseKeyNear.init(m_fHUDScale, m_nUseKeyUGX, m_nUseKeyUGY, m_nUsekeyIconWidth, m_nUseKeyIconHeight, Pawn(Owner));
		m_winUseKeyNear.m_nDisplaySize	= 64;
		m_winUseKeyNear.setTexture(Texture'SFResource1.Icons.UseKeyHint');
		m_winUseKeyNear.hide();

		// Create the pickup tracker
		m_oPickupTracker	= Spawn(class'SFPickupTracker');
	}

	bShowInfo=false;
}

// Activates the display of the "near UseKeyTrigger" icon

simulated function showAvailableUseKey()
{
	if(!m_winUseKeyNear.isVisible() && ! m_winUseKeyNear.IsFadingIn())
	{
		m_winUseKeyNear.setSingleFadeReverse(0.7f);
		m_winUseKeyNear.show();
	}

}

// Deactivates the display of the "near UseKeyTrigger" icon
simulated function hideAvailableUseKey()
{
	if(m_winUseKeyNear.IsVisible() && !m_winUseKeyNear.IsFadingOut())
		m_winUseKeyNear.setSingleFade(0.7f);
}

// Activates the display of the "available communication" icon
simulated function showAvailableCom()
{
	m_winComAvailable.setSingleFadeReverse(3.0f);
	m_winComAvailable.show();
}

// Deactivates the display of the "available communication" icon
simulated function hideAvailableCom()
{
	m_winComAvailable.setSingleFade(3.0f);
}

// Cancels any open communication window
simulated function CancelComm()
{
	m_oHUDWndMgr.cancelComm();
}

// Pauses the communication due to a message box display
simulated function PauseComm()
{
	m_oHUDWndMgr.pauseCommunication();
}

// Resumes a communication with a passed in answer
simulated function ResumeComm(bool bYesNo)
{
	m_oHUDWndMgr.resumeCommunication(bYesNo);
}

// Brings up the weapon select window
simulated function showWeaponSelection(SFPickup oPickup)
{
	m_oHUDWndMgr.showWeaponSelection(oPickup);
}

// Base class override, to use SF crosshairs instead of UT's
simulated function ChangeCrosshair(int d)
{
	Crosshair = Crosshair + d;
	if ( Crosshair >= CrossHairCountSF )
		Crosshair = 0;
	else
	if ( Crosshair < 0 )
		Crosshair = CrossHairCountSF-1;

	//class'SFUtils'.Static.sfLogEx(5, "SFHUD - ChangeCrosshair: d " $ d $ " Crosshair: " $ Crosshair );
}

// Base class override, to use SF crosshairs instead of UT's
simulated function Texture LoadCrosshair(int c)
{
	local int nSFCrosshair;

	nSFCrosshair = c;

	//class'SFUtils'.Static.sfLogEx(5, "SFHUD - LoadCrosshair: " $ c $ " Name: " $ CrossHairs[c]);

	// Check for limits
	if ( c >= CrossHairCountSF )
		nSFCrosshair = 0;
	else
	if ( c < 0 )

		nSFCrosshair = CrossHairCountSF-1;







	CrossHairTextures[c] = Texture(DynamicLoadObject(CrossHairsSF[nSFCrosshair], class'Texture'));
	return CrossHairTextures[c];
}

// Base class override to handle crosshairs of different size an
// to repalce the original ones
simulated function DrawCrossHair( canvas Canvas, int X, int Y)
{
	local float XScale, PickDiff;
	local float XLength;
	local texture T;

	// Used to cope with original UT crosshairs
 	if (Crosshair>=CrosshairCountSF)
		Crosshair = CrosshairCountSF-1;

	T = CrossHairTextures[Crosshair];
	if( T == None )
		T = LoadCrosshair(Crosshair);

	if ( Canvas.ClipX < 512 )
		XScale = 0.5;
	else
		XScale = FMax(1, int(0.1 + Canvas.ClipX/640.0));
	PickDiff = Level.TimeSeconds - PickupTime;
	if ( PickDiff < 0.4 )
	{
		if ( PickDiff < 0.2 )
			XScale *= (1 + 5 * PickDiff);
		else
			XScale *= (3 - 5 * PickDiff);
	}
	XLength = XScale * T.VSize;

	Canvas.bNoSmooth = False;
	if ( PlayerOwner.Handedness == -1 )
		Canvas.SetPos(0.503 * (Canvas.ClipX - XLength), 0.504 * (Canvas.ClipY - XLength));
	else if ( PlayerOwner.Handedness == 1 )
		Canvas.SetPos(0.497 * (Canvas.ClipX - XLength), 0.496 * (Canvas.ClipY - XLength));
	else
		Canvas.SetPos(0.5 * (Canvas.ClipX - XLength), 0.5 * (Canvas.ClipY - XLength));
	Canvas.Style = ERenderStyle.STY_Translucent;
	Canvas.DrawColor = 15 * CrosshairColor;


	Canvas.DrawTile(T, XLength, XLength, 0, 0, T.USize, T.VSize);
	Canvas.bNoSmooth = True;
	Canvas.Style = Style;
}

// Entry point for string messages.
// Overwritten to provide our own message classes
simulated function Message( PlayerReplicationInfo PRI, coerce string Msg, name MsgType )
{
	local int i;
	local Class<LocalMessage> MessageClass;

	switch (MsgType)
	{
		case 'Say':
		case 'TeamSay':
			MessageClass = class'SayMessagePlus';

			break;
		case 'CriticalEvent':

			MessageClass = class'CriticalStringPlus';
			LocalizedMessage( MessageClass, 0, None, None, None, Msg );
			return;
		case 'DeathMessage':
			MessageClass = class'RedSayMessagePlus';
			break;
		case 'SFTrigger':
			MessageClass = class'SFTriggerMessage';
			break;
		case 'Pickup':
			PickupTime = Level.TimeSeconds;
		default:
			MessageClass = class'StringMessagePlus';
			break;
	}

	if ( ClassIsChildOf(MessageClass, class'SayMessagePlus') ||
				     ClassIsChildOf(MessageClass, class'TeamSayMessagePlus') )
	{
		FaceTexture = PRI.TalkTexture;
		if ( FaceTexture != None )
			FaceTime = Level.TimeSeconds + 3;
		if ( Msg == "" )
			return;
	}
	for (i=0; i<4; i++)
	{
		if ( ShortMessageQueue[i].Message == None )
		{
			// Add the message here.
			ShortMessageQueue[i].Message = MessageClass;
			ShortMessageQueue[i].Switch = 0;
			ShortMessageQueue[i].RelatedPRI = PRI;
			ShortMessageQueue[i].OptionalObject = None;
			ShortMessageQueue[i].EndOfLife = MessageClass.Default.Lifetime + Level.TimeSeconds;
			if ( MessageClass.Default.bComplexString )
				ShortMessageQueue[i].StringMessage = Msg;
			else
				ShortMessageQueue[i].StringMessage = MessageClass.Static.AssembleString(self,0,PRI,Msg);
			return;

		}
	}

	// No empty slots.  Force a message out.
	for (i=0; i<3; i++)
		CopyMessage(ShortMessageQueue[i], ShortMessageQueue[i+1]);

	ShortMessageQueue[3].Message = MessageClass;
	ShortMessageQueue[3].Switch = 0;
	ShortMessageQueue[3].RelatedPRI = PRI;
	ShortMessageQueue[3].OptionalObject = None;
	ShortMessageQueue[3].EndOfLife = MessageClass.Default.Lifetime + Level.TimeSeconds;
	if ( MessageClass.Default.bComplexString )
		ShortMessageQueue[3].StringMessage = Msg;
	else
		ShortMessageQueue[3].StringMessage = MessageClass.Static.AssembleString(self,0,PRI,Msg);
}


// Advises the item belt to activate the current item
simulated function activateItem()
{
	m_oHUDWndMgr.activateItem();
}

// Select next item in active item belt

simulated function nextItem()
{
	m_oHUDWndMgr.nextItem();
}


// Select previous item in active item belt
simulated function prevItem()
{
	m_oHUDWndMgr.prevItem();
}

// Show hide the passive item window
simulated function passiveItem()
{
	m_oHUDWndMgr.passiveItem();
}

// Draws the animated rings representing your current health status.
simulated function drawHealthStatus(Canvas Canvas)
{
	local bool                    bSpeedUp;
	local bool                    bSlowDown;
	local EHealthState          eHealthState;
	local int					nYPos;
	local int					nXPos;

	// Some inits
	bSpeedUp	= false;
	bSlowDown	= false;

	Canvas.DrawColor	= Canvas.DrawColor * 0.8f;
	nYPos				= 832*m_fHUDScale;
//	nYPos				= Canvas.ClipY -(191*m_fHUDScale);
//	nXPos				= 32*m_fHUDScale;
	nXPos				= 14*m_fHUDScale;

	// Get the current health state
	eHealthState = getHealthState();

/*
     // Check health state difference and update speed of animated textures
     if(((eHealthState == HEALTH_GreenFast) || (eHealthState == HEALTH_RedFast) || (eHealthState == HEALTH_YellowFast))
          && ((m_eHealthState == HEALTH_GreenSlow) || (m_eHealthState == HEALTH_RedSlow) || (m_eHealthState == HEALTH_YellowSlow) || (m_eHealthState == HEALTH_Critical)))
          // Getting faster
          bSpeedUp     = true;

     if(((eHealthState == HEALTH_GreenSlow) || (eHealthState == HEALTH_RedSlow) || (eHealthState == HEALTH_YellowSlow))
          && ((m_eHealthState == HEALTH_GreenFast) || (m_eHealthState == HEALTH_RedFast) || (m_eHealthState == HEALTH_YellowFast) || (m_eHealthState == HEALTH_Critical)))
          // Getting slower
          bSlowDown     = true;
*/

	Canvas.Style = ERenderStyle.STY_Translucent;

// No longer using the rings
/* 
		// Select appropriate texture
		switch(eHealthState)
		{
		case HEALTH_GreenFast:
			m_oGreenHelper.startAnimation(m_fFastRotation);
			m_oYellowHelper.stopAnimation();
			m_oRedHelper.stopAnimation();

			Canvas.SetPos(nXPos, nYPos);

			Canvas.DrawTile(m_texRed, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);

			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(m_texYellow, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(m_texGreen, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);
			break;
		case HEALTH_GreenSlow:
			m_oGreenHelper.startAnimation(m_fSlowRotation);
			m_oYellowHelper.stopAnimation();
			m_oRedHelper.stopAnimation();

			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(m_texRed, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(m_texYellow, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(m_texGreen, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);
			break;
		case HEALTH_YellowFast:
			m_oYellowHelper.startAnimation(m_fFastRotation);
			m_oRedHelper.stopAnimation();

			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(m_texRed, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(m_texYellow, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);
			break;
		case HEALTH_YellowSlow:
			m_oYellowHelper.startAnimation(m_fSlowRotation);
			m_oRedHelper.stopAnimation();

			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(m_texRed, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(m_texYellow, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);
			break;
		case HEALTH_RedFast:
			m_oRedHelper.startAnimation(m_fFastRotation);

			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(m_texRed, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);
			break;
		case HEALTH_RedSlow:
			m_oRedHelper.startAnimation(m_fSlowRotation);

			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(m_texRed, 128*m_fHUDScale, 128*m_fHUDScale, 0, 0, 128.0, 128.0);
			break;
		case HEALTH_Critical:

			// Nothing to drawn here.

			break;

		}
*/


		// Select appropriate texture
		switch(eHealthState)
		{

		case HEALTH_GreenFast:
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(Texture(DynamicLoadObject("SFInterface.HUD.Health_Ammo_6", class'Texture')), 256*m_fHUDScale, 128*m_fHUDScale, 0, 0, 256.0, 128.0);
			break;
		case HEALTH_GreenSlow:
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(Texture(DynamicLoadObject("SFInterface.HUD.Health_Ammo_5", class'Texture')), 256*m_fHUDScale, 128*m_fHUDScale, 0, 0, 256.0, 128.0);
			break;
		case HEALTH_YellowFast:
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(Texture(DynamicLoadObject("SFInterface.HUD.Health_Ammo_4", class'Texture')), 256*m_fHUDScale, 128*m_fHUDScale, 0, 0, 256.0, 128.0);
			break;
		case HEALTH_YellowSlow:
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(Texture(DynamicLoadObject("SFInterface.HUD.Health_Ammo_3", class'Texture')), 256*m_fHUDScale, 128*m_fHUDScale, 0, 0, 256.0, 128.0);
			break;
		case HEALTH_RedFast:
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(Texture(DynamicLoadObject("SFInterface.HUD.Health_Ammo_2", class'Texture')), 256*m_fHUDScale, 128*m_fHUDScale, 0, 0, 256.0, 128.0);
			break;
		case HEALTH_RedSlow:
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(Texture(DynamicLoadObject("SFInterface.HUD.Health_Ammo_1", class'Texture')), 256*m_fHUDScale, 128*m_fHUDScale, 0, 0, 256.0, 128.0);
			break;
		case HEALTH_Critical:
			Canvas.SetPos(nXPos, nYPos);
			Canvas.DrawTile(Texture(DynamicLoadObject("SFInterface.HUD.Health_Ammo_0", class'Texture')), 256*m_fHUDScale, 128*m_fHUDScale, 0, 0, 256.0, 128.0);
			break;
		}

    // Update health state
    m_eHealthState     = eHealthState;

}

// Draws the different rings representing your current armor status.
simulated function drawArmorStatus(Canvas Canvas)
{
	local Color			colOld;
	local EArmorState	eArmorState;
	local Texture		texArmorRing;
	local int			nYPos;
	local int			nXPos;

	// Some inits
	Canvas.Style		= ERenderStyle.STY_Translucent;


	colOld				= Canvas.DrawColor ;

	Canvas.DrawColor.R	= 255;
	Canvas.DrawColor.G	= 255;
	Canvas.DrawColor.B	= 255;
	Canvas.DrawColor.A	= 255;
	nYPos				= 832*m_fHUDScale;
	nXPos				= 14*m_fHUDScale;

	// Get the current armor state
	eArmorState = getArmorState();

	// Select appropriate texture
	switch(eArmorState)
	{
	case ARMOR_LEVEL5:
		texArmorRing	= Texture(DynamicLoadObject("SFInterface.HUD.Armor_3", class'Texture'));
		break;
	case ARMOR_LEVEL4:
		texArmorRing	= Texture(DynamicLoadObject("SFInterface.HUD.Armor_2", class'Texture'));
		break;
	case ARMOR_LEVEL3:
		texArmorRing	= Texture(DynamicLoadObject("SFInterface.HUD.Armor_2", class'Texture'));
		break;
	case ARMOR_LEVEL2:
		texArmorRing	= Texture(DynamicLoadObject("SFInterface.HUD.Armor_1", class'Texture'));
		break;
	case ARMOR_LEVEL1:
		texArmorRing	= Texture(DynamicLoadObject("SFInterface.HUD.Armor_1", class'Texture'));
		break;
	case ARMOR_LEVEL0:
		texArmorRing	= Texture(DynamicLoadObject("SFInterface.HUD.Armor_0", class'Texture'));
		break;
	default:
		texArmorRing	= None;
	}

	// Draw the texture
	if(None != texArmorRing)
	{
		Canvas.SetPos(nXPos, nYPos);
		Canvas.DrawTile(texArmorRing, 256*m_fHUDScale, 128*m_fHUDScale, 0, 0, 256.0, 128.0);
	}

	// Restore draw color
	Canvas.DrawColor	= colOld;

}

// Draws the flashlight bar
simulated function drawFlashlightStatus(Canvas Canvas)
{
	local Color		colOld;
	local Texture	texFlashlightBar;
	local int		nYPos, nXPos, FlashlightState, nXReveal;
	local float		FlashlightLevel;

	Canvas.Style		= ERenderStyle.STY_Translucent;
	colOld				= Canvas.DrawColor ;

	Canvas.DrawColor.R	= 255;
	Canvas.DrawColor.G	= 255;
	Canvas.DrawColor.B	= 255;
	Canvas.DrawColor.A	= 255;
	nYPos				= 832*m_fHUDScale;
	nXPos				= 14*m_fHUDScale;

	FlashlightState = m_oHUDWndMgr.GetFlashlightState();
	FlashlightLevel = m_oHUDWndMgr.GetFlashlightLevel();

	if(FlashlightState == 0)
	{
		return;
	}
	  else if(FlashlightState == 1)
	{
		texFlashlightBar = Texture(DynamicLoadObject("SFInterface.HUD.Flashlight_off", class'Texture'));
	}
	  else if(FlashlightLevel > 0.6)
	{
		texFlashlightBar = Texture(DynamicLoadObject("SFInterface.HUD.Flashlight_high", class'Texture'));
	}
	  else if(FlashlightLevel > 0.4)
	{
		texFlashlightBar = Texture(DynamicLoadObject("SFInterface.HUD.Flashlight_med", class'Texture'));
	}
	  else
	{
		texFlashlightBar = Texture(DynamicLoadObject("SFInterface.HUD.Flashlight_low", class'Texture'));
	}

	if(None != texFlashlightBar)
	{
		nXReveal = (FlashlightLevel * 138) + 51;

		Canvas.SetPos(nXPos, nYPos);
		Canvas.DrawTile(texFlashlightBar, nXReveal*m_fHUDScale, 128*m_fHUDScale, 0, 0, nXReveal, 128.0);
	}

	Canvas.DrawColor = colOld;
}

// Base class override, to provide our own ammo rendering
simulated function DrawAmmo(Canvas Canvas)
{
	local int		X,Y;
	local SFPlayer	oPlayer;

	// Some inits
	oPlayer = SFPlayer(Owner);
	if(None == oPlayer)
		return;

	// Check for weapon
	if((None == oPlayer.Weapon) || (oPlayer.Weapon.IsA('SFNullGun')))
		return;

	// Do not show counter for meele weapon
	if(oPlayer.Weapon.bMeleeWeapon)
		return;

	Canvas.Style = Style;
	Canvas.DrawColor.R=220;
	Canvas.DrawColor.G=100;
	Canvas.DrawColor.B=30;

	Y = 1080 * m_fHUDScale;
	if ( bHideAllWeapons )
		X = 0.5 * Canvas.ClipX + 128 * Scale;
	else
		X = 53 * m_fHUDScale;

	if ( (PawnOwner.Weapon == None) || (PawnOwner.Weapon.AmmoType == None) )
		return;


	// Canvas.DrawColor = WhiteColor;
	DrawBigNum(Canvas, PawnOwner.Weapon.AmmoType.AmmoAmount, X * Scale, Y * Scale, 0.65);
}

// Overwrite of status drawing method
simulated function DrawStatus(Canvas Canvas)
{
     local SFPlayer		Player;
     local int			ArmorAmount,CurAbs,i;
     local inventory	Inv,BestArmor;

     // Make sure we're dealing with a player here
     Player     = SFPlayer(Owner);
     if(None == Player)
          return;

     Canvas.reset();
     Canvas.Font = m_Fonts.GetSmallFont( Canvas.ClipX );
     Canvas.DrawColor.R = 255;
     Canvas.DrawColor.G = 255;
     Canvas.DrawColor.B = 255;

	 // Time:
	 /*
	Canvas.SetPos( 10, 10);
	// Draw text and no CR
	Canvas.DrawText( "Time: " $ Level.Hour $ ":" $ Level.Minute $ ":" $ Level.Second, False );
	*/

     // Some inits
	 m_nCanvasClipX	= Canvas.ClipX;
	 m_nCanvasClipY	= Canvas.ClipY;
	 m_fHUDScale	= (HUDScale * (Canvas.ClipX+Canvas.ClipY))/(1280.0f+960.0f) * StatusScale;
//     m_fHUDScale	= Scale*StatusScale;

	 // Pass the rendering call to the window manager
	 m_oHUDWndMgr.render(Canvas, m_fHUDScale);

     // Check if display is disabled
     if (m_bHideStatus )
          return;

	 // Render the smart vest upgrades
	 m_winChemicalUpgrade.render(Canvas, m_fHUDScale);
	 m_winRadUpgrade.render(Canvas, m_fHUDScale);
	 m_winFireUpgrade.render(Canvas, m_fHUDScale);
	 m_winComAvailable.render(Canvas, m_fHUDScale);
	 m_winUseKeyNear.render(Canvas, m_fHUDScale);



     // Draw visor elements
	 if(Player.m_bVisorUnitUpgrade)

	 {
		 // Health state
	     drawHealthStatus(Canvas);

		 // Armor state
		 drawArmorStatus(Canvas);

		 // Flashlight
		 drawFlashlightStatus(Canvas);

		 // Ammo
		 if (!bHideAmmo)
			 DrawAmmo(Canvas);
	 }


	 // Draw the item  windows
	 if(!m_bItemBeltPopulated)
	 {
		 populateItemBelt();
		 m_bItemBeltPopulated=true;
	 }

	 // Draw the actor tip of any reachable use key trigger
	 /*
	 Not supported in this release
	 if(Player.m_bVisorUnitUpgrade)
		drawActorTip(Canvas);
	*/

	 // Draw the near UseKeyTrigger hint
	 if(Player.m_bVisorUnitUpgrade)
		drawUseKeyHint(Canvas);

	 // During a captains communication show
	// any highlighted actors
	if(m_bShowCommunicationTip)
		drawCommunicationTip(Canvas);

}

/*
// Retrieves the armor state according to the current armor level
simulated function EArmorState getArmorState()
{
     local TournamentPlayer Player;
	 local Inventory		inv;
     local int				nArmor, i;

     // We need to make sure we're dealing with a player
     Player= TournamentPlayer(Owner);

     if(None == Player)
          return ARMOR_Undefined;

	 // Some inits
     nArmor	= 0;
     i		= 0;

	 // Calculate armor
     for( Inv=Owner.Inventory; Inv!=None; Inv=Inv.Inventory )
     {
          if (Inv.bIsAnArmor)
               nArmor += Inv.Charge;
          else
          {
               i++;
               if ( i > 100 )
                    break; // can occasionally get temporary loops in netplay
          }
     }

     // Some fast early outs here
     if(99 < nArmor)
          return      ARMOR_LEVEL6;
     if(84 < nArmor)
          return      ARMOR_LEVEL5;
     if(69 < nArmor)
          return      ARMOR_LEVEL4;
     if(54 < nArmor)
          return      ARMOR_LEVEL3;
     if(39 < nArmor)
          return      ARMOR_LEVEL2;

     if(24 < nArmor)
          return      ARMOR_LEVEL1;
     if(9 < nArmor)
          return      ARMOR_LEVEL0;

     return ARMOR_Undefined;
}
*/
// Retrieves the armor state according to the current level of the
// ballistic protection of the smartvest
simulated function EArmorState getArmorState()
{
     local SFPlayer		oPlayer;

     // We need to make sure we're dealing with a player
     oPlayer= SFPlayer(Owner);

     if(None == oPlayer)
          return ARMOR_Undefined;
	 if(None == oPlayer.m_oSmartVest)
          return ARMOR_Undefined;

	if(0.7 <= oPlayer.m_oSmartVest.m_fBallisticProtection)
		return ARMOR_LEVEL5;
	if(0.6 <= oPlayer.m_oSmartVest.m_fBallisticProtection)
		return ARMOR_LEVEL4;

	if(0.5 <= oPlayer.m_oSmartVest.m_fBallisticProtection)
		return ARMOR_LEVEL3;
	if(0.4 <= oPlayer.m_oSmartVest.m_fBallisticProtection)
		return ARMOR_LEVEL2;
	if(0.3 <= oPlayer.m_oSmartVest.m_fBallisticProtection)
		return ARMOR_LEVEL1;
	if(0.2 <= oPlayer.m_oSmartVest.m_fBallisticProtection)
		return ARMOR_LEVEL0;

     return ARMOR_Undefined;
}

// Retrieves the health state according to the current health level
simulated function EHealthState getHealthState()
{
     local     TournamentPlayer Player;
     local     int     nHealth;

     // We need to make sure we're dealing with a player
     Player= TournamentPlayer(Owner);

     if(None == Player)
          return HEALTH_Undefined;

     // Get health value
     nHealth = Player.Health;

     // Some fast early outs here
     if(84 < nHealth)
          return      HEALTH_GreenFast;
     if(69 < nHealth)
          return      HEALTH_GreenSlow;
     if(54 < nHealth)
          return      HEALTH_YellowFast;
     if(39 < nHealth)
          return      HEALTH_YellowSlow;
     if(24 < nHealth)
          return      HEALTH_RedFast;
     if( 9 < nHealth)
          return      HEALTH_RedSlow;
     if(0 < nHealth)




          return      HEALTH_Critical;

     return HEALTH_Undefined;
}

// Queues a captains communication
simulated function queueCommunication(SFCommunication oComm)
{
	// Check for valid actor
	if(None == oComm)
		return;

	// Check if communication was already seen
	if(oComm.m_bProcessed)
		return;


	// Save the communication handle
	m_oAvailableCom	= oComm;

	// Display the icon
	showAvailableCom();
}

// Plays a stored captains communication
exec function playCommunication()
{
	local SFCommunication 	oCurrentComm;

	// Check if there is a communication
	if((None == m_oAvailableCom) && (None == m_oComWaitingLine))
		return;

	// Check manager for currently playing communication
	if(!m_oHUDWndMgr.canCancelCurrentCom())
	{
		// Place in line and exit
		if(None != m_oAvailableCom)
		{




			m_oComWaitingLine	= m_oAvailableCom;
			m_oAvailableCom		= None;

		}

		return;
	}

	// Select communication to deal with
	if(None != m_oComWaitingLine)
	{
		oCurrentComm		= m_oComWaitingLine;
		m_oComWaitingLine	= None;
	}
	else
	{
		oCurrentComm	= m_oAvailableCom;
		m_oAvailableCom	= None;
	}


	if(!oCurrentComm.m_bProcessed)
	{
		// Inform the window manager about this event
		m_oHUDWndMgr.playCommunication(oCurrentComm);
		// Mark the communication as being read
		oCurrentComm.markAsCompleted();


		// Add to list
		SFPlayer(Owner).addNewCommunication(oCurrentComm);
	}


	// Hide the icon
	hideAvailableCom();

}

// Plays a received communication directly
exec function playCommunicationDirect(SFCommunication oComm)
{
	if(!oComm.m_bProcessed)
	{

		// Check manager for currently playing communication
		if(!m_oHUDWndMgr.canCancelCurrentCom())
		{
			// Place in line and exit
			m_oComWaitingLine	= oComm;
			return;
		}

		// Inform the window manager about this event
		m_oHUDWndMgr.playCommunication(oComm);
		// Mark the communication as being read
		oComm.markAsCompleted();

		// Add to list
		SFPlayer(Owner).addNewCommunication(oComm);
	}
}

// Activates the weapon description window
simulated function showWeaponPickup(TournamentWeapon oWeapon)
{
	// Check, if the weapon was already seen
	if(!m_oPickupTracker.isUnknown(oWeapon.class))
		return;

	// Inform the window manager about this event
	m_oHUDWndMgr.showWeaponDesc(oWeapon);


}


// Introduces the weapon description window by showing

// it next to a communication window
simulated function showWeaponDesc(TournamentWeapon oWeapon)
{
	// Inform the window manager about this event
	m_oHUDWndMgr.showWeaponDesc(oWeapon, true);

}

// Hides the weapon description window, after
// having introduced it (see above)
simulated function hideWeaponDesc()
{
	// Inform the window manager about this event
	m_oHUDWndMgr.hideWeaponDesc();

}

// Inserts the item into it's belt



simulated function insertIntoBelt(SFPickup oPickup)
{
	m_oHUDWndMgr.insertItemIntoBelt(oPickup);
}

// Activates the item description window
simulated function showItemPickup(Inventory oItem)
{
	// Check, if the item was already seen
	if(!m_oPickupTracker.isUnknown(oItem.class))
		return;

	// Inform the window manager about this event
	m_oHUDWndMgr.showItemDesc(oItem);
}

// Removes a used item from the active item belt
simulated function removeFromActiveItemBelt(SFPickup oItem)
{
	m_oHUDWndMgr.removeActiveItem(oItem);
}

// Removes a used item from the active item belt
simulated function removeItemFromBelt(SFPickup oItem)
{
	m_oHUDWndMgr.removeItemFromBelt(oItem);
}

// Called to populate the active item belt from
// all items contained in the inventory
simulated function populateItemBelt()
{
	local Inventory Inv;
	local SFPickup	oPickup;

	// Reset the belts
	m_oHUDWndMgr.resetActiveItemBelt();
	m_oHUDWndMgr.resetPassiveItemBelt();

	// Check all inventory items
	for ( Inv=Owner.Inventory; Inv!=None; Inv=Inv.Inventory )
	{
		if(Inv.IsA('SFPickup'))
		{
			oPickup = SFPickup(Inv);
			class'SFUtils'.Static.sfLogEx(15, "SFHUD - populateItemBelt: Found SFPickup: " $ oPickup.name);

			if(oPickup.bIsActiveItem)
			{
				class'SFUtils'.Static.sfLogEx(15, "SFHUD - populateItemBelt: Inserting active: " $ oPickup.name);
				m_oHUDWndMgr.insertActiveItem(oPickup);
			}

			if(oPickup.bIsPassiveItem)

			{

				class'SFUtils'.Static.sfLogEx(15, "SFHUD - populateItemBelt: Inserting passive: " $ oPickup.name);
				m_oHUDWndMgr.insertPassiveItem(oPickup);
			}

		}
	}
}


simulated function DrawClippedActor( Canvas C, float XB, float YB, float X, float Y, Actor A, bool WireFrame, rotator RotOffset, vector LocOffset )
{
     local vector MeshLoc;
     local float FOV;

     FOV = PlayerPawn(Owner).FOVAngle * Pi / 180;

     MeshLoc.X = 4 / tan(FOV/2);



     MeshLoc.Y = 0;
     MeshLoc.Z = 0;

     A.SetRotation(RotOffset);
     A.SetLocation(MeshLoc + LocOffset);

	C.DrawClippedActor(A, WireFrame, X, Y, XB, YB, True);
}

// Retrieves the currently focused actor
simulated function Actor getFocusedActor(class <Actor>clsActorType)
{
	local vector vecLook, vecEyePos;
	local Actor Actor, actWinner;
	local float fScore, fHiScore;

	// Find out where the camera is, and where it's direction
	vecEyePos		= Owner.Location;
	vecEyePos.Z	+= Pawn(Owner).EyeHeight;
	vecLook		= vector(Pawn(Owner).ViewRotation);

	// Iterate through all actors closer than m_fFocusDistance UUs

	fHiScore = 0;
//	foreach VisibleCollidingActors(clsActorType, Actor, m_fFocusDistance, vecEyePos)
	foreach VisibleActors(clsActorType, Actor, m_fFocusDistance, vecEyePos)
	{
		// The dot product the two normal to get the cosine of the
		// angle between them
		fScore = Normal(Actor.Location - vecEyePos) dot vecLook;


		// Ignore actors too far to the sides (too low scores):





		if (fScore >= 0.9)
		{
			// See if this candidate is an improvement:
			if (fScore > fHiScore)
			{
				fHiScore	= fScore;
				actWinner	= Actor;
			}
		}
	}

	return actWinner;
}

// Retrieves the currently visible actor, classified by it's name
simulated function Actor getVisibleActorByName(name ActorName)
{
	local Actor Actor;

	foreach VisibleActors(class'Actor', Actor, m_fCommTipDistance, Owner.Location)
	{
		if(ActorName == Actor.name)
			return Actor;
	}

	return None;
}

// Retrieves the first visible actor of the passed in
// class
simulated function Actor getVisibleActorByClass(class <Actor>clsActorType)
{

	local Actor Actor;

//	foreach VisibleCollidingActors(clsActorType, Actor, m_fFocusDistance, vecEyePos)
	foreach VisibleActors(clsActorType, Actor, m_fCommTipDistance, Owner.Location)
	{
		if(Actor.IsA(clsActorType.name))
			return Actor;
	}

	return None;

}

// Retrieves the first actor in a certain radius of the passed in class
simulated function Actor getRadiusActorByClass(class <Actor>clsActorType)
{
	local Actor Actor;

//	foreach VisibleCollidingActors(clsActorType, Actor, m_fFocusDistance, vecEyePos)
	foreach RadiusActors(clsActorType, Actor, SFGameInfo(Level.Game).nUseKeyRange, Owner.Location)
	{
		if(Actor.IsA(clsActorType.name) )
			return Actor;
	}

	return None;
}


// Calculates the 2D screen coordinates for a 3D target position
simulated function vector mapLocationToScreen(vector vecTargetPos, Canvas Canvas, float fTextWidth)
{
	local vector	vecResult, vecEyePos;
	local rotator	rotLook, rotFocus;
	local float		fTanFOV, fYaw, fPitch, fScaleDist;

	// Calculate the current point of view
	vecEyePos		= Owner.Location;
	vecEyePos.Z		+= Pawn(Owner).EyeHeight;

	// Find out where we're facing, but his time as a 'rotator' providing
	// angles rather than a vector:
	// (The conversion to vector and back is just a suboptimal but robust
	// way to make sure we get nice signed values for the pitch, instead
	// of wrap-around from 0 to 65535 at the horizon).

	// Find the look direction, conversion to vector and back to
	// rotator prevents for negative rotator values
	rotLook = rotator(vector(Pawn(Owner).ViewRotation));

	// Angle between camera and target position
	rotFocus = rotator(vecTargetPos - vecEyePos);

	// Now find out how much the target angles are offset from the
	// look angles. (And while we're at it, convert to radians, since
	// that's what Unreal's trig functions work with):
	// Difference angle /64000 results in 0-1 range. convert  to radians by multiplying with 2*PI
	fYaw	= (rotFocus.yaw		-rotLook.yaw)	* Pi / 32768.0;
	fPitch	= (rotFocus.pitch	-rotLook.pitch) * Pi / 32768.0;

	// The field of view obviously affects how things are projected
	// to the screen, as does the canvas resolution.
	// In fact, the two can be combined into a single scaling factor
	// that tells us all we need to know.
	fScaleDist = (Canvas.ClipX/2) / tan(Pawn(Owner).FOVangle * Pi / 360.0);




	// Screen pos regarding to distance to screen, determined as scaling distance
	vecResult.x = Canvas.ClipX/2 + tan(fYaw)	* fScaleDist;
	vecResult.y = Canvas.ClipY/2 - tan(fPitch)	* fScaleDist;

	return vecResult;
}


// Draws an icon on the HUD, when near a UseKeyTrigger
simulated function bool drawUseKeyHint(Canvas Canvas)
{
	local Actor		actFocused;
	local vector	X,Y,Z, XTrig, YTrig, ZTrig, XMov, YMov, ZMov;
	local vector	XProj;
	local vector	vecActorDir, vecPawnDir;
	local float		fAngle, fAngle2;
	local SFUseKeyTrigger	oTrig;
	local SFMover			oMov;
	local SFPickup			oPickup;
	local bool		bFound;
	local bool		bHasLineOfSight;
	local bool		bShowHint;
	local float		fTreshold;

	if(3<m_nUseKeyHintCounter)
	{
		// Check for usekeys
		m_nUseKeyHintCounter = 0;
	}
	else
	{
		// Do not check for usekeys
		m_nUseKeyHintCounter++;
		return false;
	}

	// Some inits
	bFound		= false;
	bShowHint	= false;
	// Find Target actor
	actFocused	= getRadiusActorByClass(class'SFUseKeyTrigger');

	// Draw the tip on it
	if ((actFocused != None))
	{
		// Get player orientation
		GetAxes(Pawn(Owner).Rotation, X,Y,Z);
		oTrig			= SFUseKeyTrigger(actFocused);

		//if(oTrig.bShowHUDHint && !oTrig.m_bTriggerNoMore && (Pawn(Owner).LineOfSightTo(actFocused) || oTrig.bIgnoreLineOfSightForHUDHint))
		if(oTrig.bShowHUDHint && !oTrig.m_bTriggerNoMore) // && ( bHasLineOfSight || oTrig.bDirectional ))
		{
			bFound	= true;

			if(oTrig.bNeedsLineOfSight)
				bHasLineOfSight	= Pawn(Owner).LineOfSightTo(oTrig);
			else
				bHasLineOfSight	=	true;

			bShowHint=bHasLineOfSight;

/*
Removed, because the FOV check is no longer wanted.

			// Calc the direction and angle to the actor
			vecActorDir	= actFocused.Location-Owner.Location;
			fAngle		= Normal(X) dot Normal(vecActorDir);

			// Is infront?
			fTreshold	= (1.0f- ((m_fUseKeyHintDistance - VSize(vecActorDir)+oTrig.CollisionRadius)/m_fUseKeyHintDistance)) *0.7f;

			if(fAngle >= fTreshold)
			{
				// Actor is infront of player, now check if player is in front of actor

				if(!oTrig.bDirectional && bHasLineOfSight)
				{
					bShowHint=true;
				}
				else
				{
					// Check direction of trigger

					// Calc the direction and angle to the trigger
					actFocused.GetAxes(actFocused.Rotation, XTrig,YTrig,ZTrig);
					vecPawnDir	= Owner.Location-actFocused.Location;
					fAngle		= Normal(XTrig) dot Normal(vecPawnDir);

					fTreshold	= (1.0f- ((m_fUseKeyHintDistance - VSize(vecActorDir)+Owner.CollisionRadius)/m_fUseKeyHintDistance)) *0.7f;
					if(fAngle > fTreshold)
					{
						bShowHint = true;
					}
				}
			}
*/
		}
	}

	// End here, if UseKey was found
	if(bShowHint)

	{
		showAvailableUseKey();
		return true;
	}

	// Find Target actor (SFMover)
	actFocused	= getRadiusActorByClass(class'SFMover');

	// Draw the tip on it
	if ((actFocused != None))
	{
		// Get player orientation
		GetAxes(Pawn(Owner).Rotation, X,Y,Z);
		oMov			= SFMOver(actFocused);

//		if(oMov.bShowHUDHint && (oMov.IgnoreBumping || oMov.IgnoreTrigger) && ( bHasLineOfSight || oMov.bDirectional))
		if(oMov.bShowHUDHint && (oMov.IgnoreBumping || oMov.IgnoreTrigger))
		{
			bFound	= true;

			bShowHint=true;
/*
Removed, because FOV check is no longer wanted.

			// Calc the direction and angle to the actor
			vecActorDir	= actFocused.Location-Owner.Location;
			vecActorDir.Z	= 0.0f;
			XProj			= X;
			XProj.Z			= 0.0f;
			fAngle			= Normal(XProj) dot Normal(vecActorDir);

			// Is infront?
			fTreshold	= (1.0f- ((m_fUseKeyHintDistance - VSize(vecActorDir)+oMov.CollisionRadius)/m_fUseKeyHintDistance)) *0.7f;
			log("SFMover fAngle " $ fAngle $ " Treshold: " $ fTreshold);
			if(fAngle > fTreshold)
			{
				if(!oMov.bDirectional)
					// No need to to a reverse check ,if the player is in front of the actor
					bShowHint=true;
				else
				{
					// Actor is infront of player, now check if player is in front of actor
					// Check direction of trigger

					// Calc the direction and angle to the trigger
					actFocused.GetAxes(actFocused.Rotation, XMov,YMov,ZMov);

					vecPawnDir		= Owner.Location-actFocused.Location;
					vecPawnDir.Z	= 0.0f;
					XProj			= XMov;
					XProj.Z			= 0.0f;
					fAngle		= Normal(XProj) dot Normal(vecPawnDir);
					fTreshold	= (1.0f- ((m_fUseKeyHintDistance - VSize(vecPawnDir)+Owner.CollisionRadius)/m_fUseKeyHintDistance)) *0.7f;

					if(fAngle > fTreshold)
					{
						bShowHint=true;
					}
				}
			}
*/
		}
	}

	// End here, if UseKey was found
	if(bShowHint)
	{
		showAvailableUseKey();
		return true;
	}

	// Find Target actor (SFMover)
	actFocused	= getRadiusActorByClass(class'SFPickup');

	// Draw the tip on it
	if ((actFocused != None))
	{
		oPickup			= SFPickup(actFocused);

		if(oPickup.bManualPickup)
		{
			bHasLineOfSight	= Pawn(Owner).LineOfSightTo(oPickup);
			if(bHasLineOfSight)
				bFound	= true;

			bShowHint=bHasLineOfSight;
		}
	}

	if(bShowHint)
		showAvailableUseKey();
	else
		hideAvailableUseKey();

	return bFound;



}

// Draws an actor tip to the canvas
simulated function drawActorTip(Canvas Canvas)
{
	local Actor		actFocused;
	local vector	X,Y,Z;
	local vector	vecScreenPos;
	local string	strActorTip;
	local vector	vecActorDir;
	local float		fOffset;
	local float		XL, YL;
	local float		fAngle;

	// Find Target actor
//	actFocused	= GetFocusedActor(class'Weapon');
	actFocused	= GetFocusedActor(m_clsActorTipTrigger);


	// Draw the tip on it
	if (actFocused != None)
	{
		// Get player orientation

		GetAxes(Pawn(Owner).Rotation, X,Y,Z);

		// Calc the direction and angle to the actor

		vecActorDir	= actFocused.Location-Owner.Location;
		fAngle		= Normal(X) dot Normal(vecActorDir);

		if(fAngle > 0.1f)
		{

			if(actFocused.IsA('SFUseKeyTrigger'))
				strActorTip			= SFUseKeyTrigger(actFocused).ActorTip;
			else
				strActorTip			= string(actFocused.Name);

			if(Len(strActorTip) < 1)
				return;

			Canvas.reset();
			Canvas.DrawColor	= WhiteColor;
			Canvas.Style		= ERenderStyle.STY_Translucent;
			Canvas.Font			= MyFonts.GetSmallFont( Canvas.ClipX );

			// Retrieve text sizes
			Canvas.StrLen(strActorTip, XL, YL );

			// Calculate the screen pos
			vecScreenPos		= mapLocationToScreen(actFocused.Location, Canvas, XL);

			// Display over actor
			fOffset			= actFocused.CollisionHeight*m_fHUDScale*2.5f;
			vecScreenpos.y -= fOffset;
			vecScreenpos.x -= XL/2;
			Canvas.SetPos(vecScreenpos.x, vecScreenpos.y);
			Canvas.DrawText(strActorTip);
		}
	}
}

// Draws an actor tip to the canvas
// This is called from the Captain communication to
// point out some things
simulated function drawCommunicationTip(Canvas Canvas)
{
	local Actor		actCaptTip;
	local vector	X,Y,Z;
	local vector	vecActorDir;
	local vector	vecScreenPos;
	local string	strActorTip;
	local float		fOffset;
	local float		XL, YL;
	local float		fAngle;

	// Get player orientation
	GetAxes(Pawn(Owner).Rotation, X,Y,Z);

	// Find Target actor
	actCaptTip	= getVisibleActorByName(m_nameTipActor);

	if(None == actCaptTip)
		return;

	// Calc the direction and angle to the actor
	vecActorDir	= actCaptTip.Location-Owner.Location;
	fAngle		= Normal(X) dot Normal(vecActorDir);

	// Draw the tip on it
	if ((actCaptTip != None) && (fAngle > 0.1f))
	{
		// This has be set by a communication
		strActorTip			= m_strCommunicationTip;



		if(Len(strActorTip) < 1)
			return;

		// Retrieve text sizes
		Canvas.StrLen(strActorTip, XL, YL );

		Canvas.reset();
		Canvas.DrawColor	= WhiteColor;
		Canvas.Style		= ERenderStyle.STY_Translucent;
		Canvas.Font		= MyFonts.GetSmallFont( Canvas.ClipX );
		vecScreenPos		= mapLocationToScreen(actCaptTip.Location, Canvas, XL);

		// Display over actor
		fOffset			= actCaptTip.CollisionHeight*m_fHUDScale*3.5f;
		vecScreenpos.y -= fOffset;
		vecScreenpos.x -= XL/2-actCaptTip.CollisionRadius;
		Canvas.SetPos(vecScreenpos.x, vecScreenpos.y);
		Canvas.DrawTextClipped(strActorTip);
	}
}

// Overwrite of parent class function to use our font
simulated function DrawDigit(Canvas Canvas, int d, int Step, float UpScale, out byte bMinus )
{
	if ( bMinus == 1 )
	{
		Canvas.CurX -= Step;
		Canvas.DrawTile(Texture'SFInterface.HUD.SFHudElements1', UpScale*25, 64*UpScale, 0, 64, 25.0, 64.0);
		bMinus = 0;
	}
	if ( d == 1 )
		Canvas.CurX -= 0.625 * Step;
	else
		Canvas.CurX -= 0.25 * Step;		
	Canvas.DrawTile(Texture'SFInterface.HUD.SFHudElements1', UpScale*25, 64*UpScale, d*25, 0, 25.0, 64.0);
	Canvas.CurX += 7*UpScale;
}


// Cleanup goes here
event Destroyed()
{
	// Call to base class
	Super.Destroyed();

	if(None != m_oHUDWndMgr)
		m_oHUDWndMgr.terminate();

	// Release references
	m_texGreen		= None;
	m_texYellow		= None;
	m_texRed		= None;
	m_Fonts			= None;
	m_oHUDWndMgr	= None;
	m_arTexArmor[0]	= None;
	m_arTexArmor[1]	= None;
	m_arTexArmor[2]	= None;
	m_arTexArmor[3]	= None;
	m_arTexArmor[4]	= None;
	m_arTexArmor[5]	= None;

}

// Get rid of some ChallengeHUD stuff.
simulated function DrawFragCount(Canvas Canvas) {}
simulated function DrawWeapons(Canvas Canvas) {}
simulated function DrawGameSynopsis(Canvas Canvas){}
simulated function bool DrawIdentifyInfo(canvas Canvas) {}

defaultproperties
{
     m_fFastRot=1000.000000
     m_fSlowRot=6000.000000
     m_fFastRotation=12.000000
     m_fSlowRotation=5.000000
     CrosshairCountSF=9
     CrossHairsSF(0)="SFResource1.crshair01"
     CrossHairsSF(1)="SFResource1.crshair03"
     CrossHairsSF(2)="SFResource1.crshair06"
     CrossHairsSF(3)="SFResource1.crshair07"
     CrossHairsSF(4)="SFResource1.crshair08"
     CrossHairsSF(5)="SFResource1.crshair11"
     CrossHairsSF(6)="SFResource1.crshair15"
     CrossHairsSF(7)="SFResource1.crshair22"
     CrossHairsSF(8)="SFResource1.crshair23"
     m_fFocusDistance=200.000000
     m_fCommTipDistance=400.000000
     m_clsActorTipTrigger=Class'SpatialFear.SFUseKeyTrigger'
     m_nUpgradeIconWidth=64
     m_nUpgradeIconHeight=64
     m_nChemUGX=24
     m_nChemUGY=900
     m_nFireUGX=78
     m_nFireUGY=920
     m_nRadUGX=132
     m_nRadUGY=900
     m_nComUGX=64
     m_nComUGY=802
     m_nComIconWidth=128
     m_nComIconHeight=128
     m_nUseKeyUGX=610
     m_nUseKeyUGY=850
     m_nUseKeyIconWidth=64
     m_nUseKeyIconHeight=64
     m_strYesText="Yes"
     m_strNoText="No"
     bFirstTime=True
}

class file time: 12/7/2003 3:58:24 PM - creation time: 12/7/2003 4:03:44 PM
Created with UnCodeX