-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathBaseConflict.Classes.Gamestates.pas
8093 lines (7159 loc) · 265 KB
/
BaseConflict.Classes.Gamestates.pas
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
unit BaseConflict.Classes.Gamestates;
interface
uses
// ----------- Delphi -------------
System.Types,
System.UITypes,
System.SysUtils,
System.Classes,
System.Math,
System.Generics.Defaults,
System.Generics.Collections,
System.DateUtils,
Winapi.ActiveX,
Winapi.ShellAPI,
Winapi.Windows,
Vcl.Clipbrd,
Vcl.Dialogs,
Vcl.Forms,
Vcl.Taskbar,
RegularExpressions,
// --------- ThirdParty -----------
IdCoderMIME,
FMOD.Studio.Common,
FMOD.Studio.Classes,
steamclientpublic,
steam_api,
// --------- Engine ------------
Engine.Core,
Engine.Core.Types,
Engine.Core.Lights,
Engine.GFXApi,
Engine.GUI,
Engine.Input,
Engine.Log,
Engine.Helferlein,
Engine.Helferlein.Windows,
Engine.Helferlein.DataStructures,
Engine.Math,
Engine.Math.Collision3D,
Engine.Mesh,
Engine.Animation,
Engine.Network,
Engine.Network.RPC,
Engine.ParticleEffects,
Engine.Script,
Engine.Serializer,
Engine.Serializer.Json,
Engine.Terrain,
Engine.PostEffects,
{$IFDEF DEBUG}
Engine.GUI.Editor,
Engine.Terrain.Editor,
{$ENDIF}
Engine.AnimatedBackground,
Engine.DataQuery,
Engine.dXML,
Engine.Vertex,
Engine.Preloader,
Engine.Debug,
// ---------- Game ----------
BaseConflict.Game,
BaseConflict.Game.Client,
BaseConflict.Classes.MiniMap,
BaseConflict.Classes.Client,
BaseConflict.Classes.Gamestates.GUI,
BaseConflict.Entity,
BaseConflict.Map,
BaseConflict.Map.Client,
BaseConflict.Constants.Cards,
BaseConflict.Constants,
BaseConflict.Constants.Client,
BaseConflict.Constants.Scenario,
BaseConflict.Globals,
BaseConflict.Globals.Client,
BaseConflict.Types.Shared,
BaseConflict.Types.Client,
BaseConflict.Settings.Client,
BaseConflict.EntityComponents.Shared,
BaseConflict.EntityComponents.Client,
BaseConflict.EntityComponents.Client.Debug,
BaseConflict.EntityComponents.Client.Visuals,
BaseConflict.EntityComponents.Client.GUI,
BaseConflict.Api,
BaseConflict.Api.Account,
BaseConflict.Api.Cards,
BaseConflict.Api.Chat,
BaseConflict.Api.Types,
BaseConflict.Api.Scenarios,
BaseConflict.Api.Matchmaking,
BaseConflict.Api.Messages,
BaseConflict.Api.Profile,
BaseConflict.Api.Shop,
BaseConflict.Api.Quests,
BaseConflict.Api.Deckbuilding,
BaseConflict.Api.Shared,
BaseConflict.Api.Game;
type
/// //////////////////////////////////////////////////////////////////////////
/// Helper classes
/// //////////////////////////////////////////////////////////////////////////
TGameForm = class(TForm)
public
CursorInRenderpanel : Boolean;
end;
/// //////////////////////////////////////////////////////////////////////////
/// Meta classes for gamestates
/// //////////////////////////////////////////////////////////////////////////
{$M+}
{$RTTI EXPLICIT METHODS([vcPublic, vcPublished, vcPrivate]) PROPERTIES([vcPublic, vcPublished, vcPrivate]) FIELDS([vcPrivate, vcProtected, vcPublic])}
TGameState = class;
TGameStateManager = class;
/// <summary> A game state component is a reusable part of a game state, such as a setting view.
/// There are passive game state components, which are always active and can be used at the same time
/// with other components like the chatsystem. </summary>
TGameStateComponent = class abstract(TEntityComponent)
protected
FParent : TGameState;
FActive, FPassive, FDefault, FInitialized : Boolean;
property IsInitialized : Boolean read FInitialized;
property IsDefault : Boolean read FDefault;
procedure Initialize; virtual;
function GetActive : Boolean;
procedure SetActive(const Value : Boolean);
/// <summary> Will only be called if IsInitialized. </summary>
procedure GUIEventHandler(const Sender : RGUIEvent); virtual;
procedure OnQueueError(ErrorCode : EnumErrorCode); virtual;
public
/// <summary> The gamestate which this component is attached to. </summary>
property Parent : TGameState read FParent;
/// <summary> Determines whether this component has the user focus at the moment.
/// Passive components are always active. </summary>
property Active : Boolean read GetActive;
/// <summary> Activates this component, deactivating all other active and not passive components. </summary>
procedure Activate; virtual;
/// <summary> Deactivates this component. </summary>
procedure Deactivate; virtual;
/// <summary> Called when the parent TGameState has been entered. </summary>
procedure ParentEntered; virtual;
/// <summary> Called when the parent TGameState has been left. </summary>
procedure ParentLeft; virtual;
/// <summary> Creates a new game state component attached to a gamestate. </summary>
constructor Create(Owner : TEntity; Parent : TGameState; IsDefault : Boolean = False); reintroduce;
/// <summary> Called each frame. Regardless of active or not. </summary>
procedure Idle; virtual;
end;
CGameStateComponent = class of TGameStateComponent;
/// <summary> This class covers a large state of the game, such as Login, Mainmenu, Loading, Ingame.
/// A gamestate can have some components to be juiced up with functionality. </summary>
TGameState = class
protected
FOwner : TGameStateManager;
FStateEntity : TEntity;
FComponents : TList<TGameStateComponent>;
/// <summary> Adds a new game state component to this gamestate. Called by components. </summary>
procedure AddGameStateComponent(Component : TGameStateComponent);
procedure EnterState; virtual;
/// <summary> If this is active, it will be idled. </summary>
procedure Idle; virtual;
procedure LeaveState; virtual;
/// <summary> Distributes GUI events to active GamestateComponents. </summary>
procedure GUIEventHandlerRecursion(const Sender : RGUIEvent);
/// <summary> Override this to manage the gui events. </summary>
procedure GUIEventHandler(const Sender : RGUIEvent); virtual;
procedure OnQueueError(ErrorCode : EnumErrorCode); virtual;
public
property Owner : TGameStateManager read FOwner;
constructor Create(Owner : TGameStateManager);
/// <summary> Activates one component and deactivates the rest. Called by components. </summary>
procedure SetComponentActive(Component : CGameStateComponent; Disable : Boolean = False);
function GetComponent<T : TGameStateComponent>() : T;
destructor Destroy; override;
end;
EnumDialogIdentifier = (
diNone,
// passive
diPassiveDialogs,
diAscension,
diCardDetails,
diCollectionCardDetail,
diDeckCardSkin,
diDeckDelete,
diDeckIcon,
diDeckslotPurchase,
diFeedback,
diFriendInvite,
diMatchmakingScenario,
diMatchmakingScenarioDifficulty,
diPlayerIcon,
diReferAFriend,
diSettings,
diShopItem,
diShopPurchase,
// exclusive
diActiveDialogs,
diPreloading,
diGenericLoading,
diIdleLegions,
diTutorialVideos,
diStatisticsLoading,
diPlayerLevelUpOverview,
diPlayerLevelUp,
diRanking,
diDraftbox,
diNotification,
diMatchmakingDeck,
diMetaTutorial
);
SetDialogIdentifier = set of EnumDialogIdentifier;
ProcDialogVisibilityChanged = procedure(Visible : Boolean) of object;
TDialogManager = class
private
const
PASSIVE_DIALOGS = [diPassiveDialogs .. diActiveDialogs];
SOUNDLESS_DIALOGS = [diPreloading];
var
// dialog changes are deferred one frame to prevent inframe callings of dialogs and so sounds playing
FDirty : SetDialogIdentifier;
FOpenDialogs : SetDialogIdentifier;
FCallbacks : array [EnumDialogIdentifier] of TList<ProcDialogVisibilityChanged>;
procedure Notify(DialogIdentifier : EnumDialogIdentifier; Open : Boolean);
procedure UpdateShownDialog;
procedure SetDirty(DialogIdentifiers : SetDialogIdentifier);
strict private
FShownDialog : EnumDialogIdentifier;
procedure SetShownDialog(const Value : EnumDialogIdentifier); virtual;
published
property ShownDialog : EnumDialogIdentifier read FShownDialog write SetShownDialog;
[dXMLDependency('.ShownDialog')]
function IsAnyDialogVisible : Boolean;
public
[dXMLDependency('.ShownDialog')]
function IsDialogVisible(DialogIdentifier : EnumDialogIdentifier) : Boolean;
procedure OpenDialog(DialogIdentifier : EnumDialogIdentifier);
procedure CloseDialog(DialogIdentifier : EnumDialogIdentifier);
procedure ToggleDialog(DialogIdentifier : EnumDialogIdentifier);
procedure BindDialog(DialogIdentifier : EnumDialogIdentifier; Open : Boolean);
procedure CloseAllDialogs;
procedure Subscribe(DialogIdentifier : EnumDialogIdentifier; Callback : ProcDialogVisibilityChanged);
procedure UnSubscribe(DialogIdentifier : EnumDialogIdentifier; Callback : ProcDialogVisibilityChanged);
procedure Idle;
destructor Destroy; override;
end;
EnumClientState = (csNone, csMainMenu, csCoreGame, csLoadCoreGame, csLoginQueue, csLoginSteam, csReconnect, csServerDown, csMaintenance);
EnumMenuMusic = (mmNone, mmIntro, mmMenu, mmDeckbuilding, mmLoading);
EnumWebsites = (weGame, weCompany, weFMod, weDiscord, weYoutube, weTwitter, weFacebook, wePatchNotes, weWiki, weTranslation, wePublisher, weGuide, weSteamForum, weScill, weScillTournament, weTournament, weSteamChat);
EnumWindowMode = (wmClient, wmIngame);
/// <summary> This is the global manager of the game, which handles all gamestates. </summary>
TGameStateManager = class
protected
FOnShutdown : ProcCallback;
FCurrentState : string;
FCurrentStates : TStack<TGameState>;
FStates : TObjectDictionary<string, TGameState>;
FGameWindow : TGameForm;
FWindowMode : EnumWindowMode;
FWindowInitialized, FAllowClose : Boolean;
FLastClickable : integer;
FMenuMusicEvent : TFMODEventInstance;
FCurrentMenuMusic : EnumMenuMusic;
FClientWarmingSteps : integer;
property GameWindow : TGameForm read FGameWindow;
function GetIsStaging : Boolean;
function GetGameState<T : TGameState>(const GameStateName : string) : T;
function CurrentGameState : TGameState;
/// <summary> Redirect GUI events to the current game state. </summary>
procedure GUIEventCallback(const Sender : RGUIEvent);
procedure OnQueueError(ErrorCode : EnumErrorCode);
strict private
FErrorCaption, FErrorMessage, FLoadingCaption, FLoadingMessage, FErrorConfirm : string;
FExitDialogVisible, FIsErrorDialogOpen, FIsLoading : Boolean;
FIsApiReady : Boolean;
FClientState : EnumClientState;
FDialogManager : TDialogManager;
procedure SetDialogManager(const Value : TDialogManager); virtual;
procedure SetErrorConfirm(const Value : string); virtual;
procedure SetLoadingCaption(const Value : string); virtual;
procedure SetLoadingMessage(const Value : string); virtual;
procedure SetClientState(const Value : EnumClientState); virtual;
procedure SetIsLoading(const Value : Boolean); virtual;
procedure SetIsApiReady(const Value : Boolean); virtual;
procedure SetExitDialogVisible(const Value : Boolean); virtual;
procedure SetIsErrorDialogOpen(const Value : Boolean); virtual;
procedure SetErrorCaption(const Value : string); virtual;
procedure SetErrorMessage(const Value : string); virtual;
published
property State : EnumClientState read FClientState write SetClientState;
property ExitDialogVisible : Boolean read FExitDialogVisible write SetExitDialogVisible;
property IsStaging : Boolean read GetIsStaging;
property ErrorCaption : string read FErrorCaption write SetErrorCaption;
property ErrorMessage : string read FErrorMessage write SetErrorMessage;
property ErrorConfirm : string read FErrorConfirm write SetErrorConfirm;
property IsErrorDialogOpen : Boolean read FIsErrorDialogOpen write SetIsErrorDialogOpen;
procedure ShowErrorConfirm(const ErrorCaption, ErrorMessage, ErrorConfirm : string);
procedure ShowError(const ErrorCaption, ErrorMessage : string);
procedure ShowErrorcodeRaw(ErrorCode : integer);
procedure ShowErrorcode(ErrorCode : EnumErrorCode);
property IsApiReady : Boolean read FIsApiReady write SetIsApiReady;
property IsLoading : Boolean read FIsLoading write SetIsLoading;
property LoadingCaption : string read FLoadingCaption write SetLoadingCaption;
property LoadingMessage : string read FLoadingMessage write SetLoadingMessage;
property DialogManager : TDialogManager read FDialogManager write SetDialogManager;
procedure Close;
procedure CloseForcePrompt;
procedure CloseNoPrompt;
procedure Minimize;
procedure BrowseTo(Website : EnumWebsites);
public const
CLIENT_DEFAULT_DIMENSIONS : RIntVector2 = (X : 1280; Y : 720);
public
property OnShutdown : ProcCallback read FOnShutdown write FOnShutdown;
/// <summary> The last state pushed by changegamestate. </summary>
property CurrentState : string read FCurrentState;
/// <summary> Allocate memory and prepare instance for use.</summary>
constructor Create(GameWindow : TGameForm);
/// <summary> Add new gamestate to list and make them available for use.
/// This will not activate the new state!</summary>
procedure AddNewGameState(GameState : TGameState; GameStateName : string);
procedure RemoveGameState(GameStateName : string);
/// <summary> Creates all api managers. </summary>
procedure CreateManager;
/// <summary> Frees all api managers. </summary>
procedure CleanManager;
procedure SwitchMenuMusic(NewMusic : EnumMenuMusic);
/// <summary> Returns whether the application can be closed. </summary>
function CanProgramClose : Boolean;
function IsWindowMode(WindowMode : EnumWindowMode) : Boolean;
function IsGameWindow : Boolean;
function IsClientWindow : Boolean;
function IsFullscreen : Boolean;
procedure SetClientWindow;
procedure SetIngameWindow;
function TargetMonitor : TMonitor;
procedure UpdateWindowPosition;
procedure BringToFront;
procedure ShowWindow;
procedure HideWindow;
procedure UpdateSoundSettings(Option : EnumClientOption = coGeneralNone);
procedure UpdateSettingsOption(Option : EnumClientOption);
/// <summary> Will change the current gamestate to gamestate with given name.
/// Change gamestate will leave and pop all current stacked states
/// The new gamestate has to be registered before use.</summary>
procedure ChangeGameState(GameStateName : string);
/// <summary> Idle all gamestates current on stack</summary>
procedure Idle;
/// <summary> Free allocated memory and free all added gamestates!</summary>
destructor Destroy; override;
end;
/// ////////////////////////////////////////////////////////////////////
/// Implemented gamestate components
/// //////////////////////////////////////////////////////////////////////////
EnumScenario = (esNone, es1vE, es2vE, es1v1, es2v2, es3v3, es4v4, esRanked1v1, esRanked2v2, esDuel, esDuel2v2, esDuel3v3, esDuel4v4, esTutorial, esSpecial);
SetScenario = set of EnumScenario;
/// <summary> Manages the process to start a game: Gamemode, Teambuilding/planning, Queue </summary>
TGameStateComponentMatchMaking = class(TGameStateComponent)
private
const
SCENARIO_MAPPING : array [EnumScenario] of string = (
'', // esNone
SCENARIO_PVE_ATTACK_SOLO, // es1vE
SCENARIO_PVE_ATTACK_DUO, // es2vE
SCENARIO_PVP_1VS1, // es1v1
SCENARIO_PVP_2VS2, // es2v2
SCENARIO_PVP_3VS3_TWO_LANE, // es3v3
SCENARIO_PVP_4VS4_TWO_LANE, // es4v4
SCENARIO_PVP_1VS1_RANKED, // esRanked1v1
SCENARIO_PVP_2VS2_RANKED, // esRanked2v2
SCENARIO_PVP_DUEL_1VS1, // esDuel
SCENARIO_PVP_DUEL_2VS2, // esDuel2v2
SCENARIO_PVP_DUEL_3VS3_TWO_LANE, // esDuel3v3
SCENARIO_PVP_DUEL_4VS4_TWO_LANE, // esDuel4v4
SCENARIO_PVE_TUTORIAL, // esTutorial
SCENARIO_PVE_DEFAULT // esSpecial
);
SCENARIOS_WITH_AUTO_LEAGUE : SetScenario = [es1v1, es2v2, es3v3, es4v4, esRanked1v1, esRanked2v2];
SCENARIOS_WITH_LEAGUE_SELECTION : SetScenario = [es1vE, es2vE, esDuel, esDuel2v2, esDuel3v3, esDuel4v4, esSpecial];
SCENARIOS_WITH_SCENARIO_SELECTION : SetScenario = [esDuel, esDuel2v2, esDuel3v3, esDuel4v4, esSpecial];
SCENARIOS_AGAINST_AI : SetScenario = [es1vE, es2vE, esSpecial];
SCENARIOS_DUEL : SetScenario = [esDuel, esDuel2v2, esDuel3v3, esDuel4v4];
CURRENT_PLAYER_ONLINE_UPDATE_INTERVAL_QUEUE = 1000;
ENTER_QUEUE_BLOCK_TIMEROUT = 5000;
MAINTENANCE_LEAVE_QUEUE_INTERVAL = 5000;
protected
FCurrentPlayerUpdateTimer, FEnterQueueBlockTimeout, FMaintenanceLeaveQueueTimer : TTimer;
FMatchmakingTeamAlreadyReset : Boolean;
procedure Initialize; override;
procedure OnQueueError(ErrorCode : EnumErrorCode); override;
procedure OnGameFound(Game : TGameMetaInfo);
procedure OnQueueEntered(Sender : TMatchmakingTeam; Queue : TMatchmakingQueue);
procedure OnQueueLeft(Sender : TMatchmakingQueue; Leaver : TPerson);
procedure OnServerQueueError;
procedure OnScenarioChanged;
procedure SanitizeGameData(Game : TGameMetaInfo);
procedure UpdateScenarioSelection;
function GetScenario(PredefinedScenario : EnumScenario) : TScenario;
function GetEnumScenario(Scenario : TScenario) : EnumScenario;
strict private
// general
function GetScenarioManager : TScenarioManager;
procedure SetScenarioManager(const Value : TScenarioManager); virtual;
function GetManager : TMatchmakingManager;
procedure SetManager(const Value : TMatchmakingManager); virtual;
strict private
// team
FScenarios : TUltimateList<TScenario>;
FChosenScenario : EnumScenario;
FLastChosenDifficulty : integer;
procedure SetChosenScenario(const Value : EnumScenario); virtual;
strict private
// queue
FInQueue : Boolean;
FQueue : TMatchmakingQueue;
FIsEnteringQueue : Boolean;
procedure SetIsEnteringQueue(const Value : Boolean); virtual;
procedure SetInQueue(const Value : Boolean); virtual;
procedure SetQueue(const Value : TMatchmakingQueue); virtual;
published
// general
property Manager : TMatchmakingManager read GetManager write SetManager;
property Scenarios : TScenarioManager read GetScenarioManager write SetScenarioManager;
property ScenarioSelection : TUltimateList<TScenario> read FScenarios;
// scenario
property ChosenScenario : EnumScenario read FChosenScenario write SetChosenScenario;
[dXMLDependency('.ChosenScenario')]
function HasAutoLeague : Boolean;
[dXMLDependency('.ChosenScenario')]
function HasLeagueSelection : Boolean;
[dXMLDependency('.ChosenScenario')]
function HasScenarioSelection : Boolean;
[dXMLDependency('.ChosenScenario')]
function IsDuel : Boolean;
[dXMLDependency('.ChosenScenario')]
function IsPvE : Boolean;
[dXMLDependency('.Scenarios.Scenarios', '.Scenarios.Rankings')]
function Ranked1vs1 : TScenarioInstance;
[dXMLDependency('.Scenarios.Scenarios', '.Scenarios.Rankings')]
function Ranked2vs2 : TScenarioInstance;
// team
[dXMLDependency('.Manager.CurrentTeam.Invites')]
function PendingInvites : integer;
procedure ChooseScenarioInstance(const ScenarioInstance : TScenarioInstance);
procedure ChooseScenario(const Scenario : TScenario);
// queue
property IsEnteringQueue : Boolean read FIsEnteringQueue write SetIsEnteringQueue;
property InQueue : Boolean read FInQueue write SetInQueue;
property Queue : TMatchmakingQueue read FQueue write SetQueue;
procedure EnterQueue;
procedure LeaveQueue;
// tutorial
procedure StartTutorialGame;
// spectate
procedure SpectateFriend(Friend : TPerson);
public
procedure ParentEntered; override;
procedure ParentLeft; override;
procedure Idle; override;
destructor Destroy; override;
end;
/// <summary> Manages the after game party. </summary>
TGameStateComponentStatistics = class(TGameStateComponent)
protected
FIdleTimer : TTimer;
FOldGameData : TGameMetaInfo;
procedure OnDataReady;
procedure Initialize; override;
strict private
FIsIdleBlocked : Boolean;
FIdleTimerBlock : integer;
procedure SetIsIdleBlocked(const Value : Boolean); virtual;
procedure SetIdleTimerBlock(const Value : integer); virtual;
function GetGameData : TGameMetaInfo;
procedure SetGameData(const Value : TGameMetaInfo); virtual;
published
property GameData : TGameMetaInfo read GetGameData write SetGameData;
// idle legions
property IsIdleBlocked : Boolean read FIsIdleBlocked write SetIsIdleBlocked;
property IdleTimerBlock : integer read FIdleTimerBlock write SetIdleTimerBlock;
procedure ClearGameData;
public
procedure ParentEntered; override;
procedure ParentLeft; override;
/// <summary> NILSAFE | Loads the new game data. </summary>
procedure Show;
procedure Idle; override;
destructor Destroy; override;
end;
EnumGraphicsQuality = (gqVeryLow, gqLow, gqMedium, gqHigh, gqVeryHigh, gqCustom);
EnumShadowQuality = (sqOff, sqVeryLow, sqLow, sqMedium, sqHigh, sqUltraHigh);
EnumTextureQuality = (tqMaximum, tqHigh, tqMedium, tqLow, tqMinimum);
EnumClickPrecision = (cpPrecise, cpExtended, cpWide);
EnumDisplayMode = (dmBorderlessFullscreenWindow, dmWindowed);
EnumMenuResolution = (mr1024x576, mr1280x720, mr1600x900, mr1920x1080, mr2560x1440, mrCustom);
EnumMenuScaling = (msDownscaling, msFullscreen, msDisabled);
TSettingsWrapper = class
strict private
FBlockUpdate : integer;
protected const
GRAPHICS_PRESET_SHADOW_QUALITY : array [gqVeryLow .. gqVeryHigh] of EnumShadowQuality =
(sqOff, sqLow, sqMedium, sqHigh, sqUltraHigh);
GRAPHICS_PRESET_ACTIVE_OPTIONS_VERY_LOW = [];
GRAPHICS_PRESET_ACTIVE_OPTIONS_LOW = GRAPHICS_PRESET_ACTIVE_OPTIONS_VERY_LOW + [coGraphicsPostEffectFXAA];
GRAPHICS_PRESET_ACTIVE_OPTIONS_MEDIUM = GRAPHICS_PRESET_ACTIVE_OPTIONS_LOW + [coGraphicsGUIBlurBackgrounds,
coGraphicsPostEffectGlow, coGraphicsPostEffectUnsharpMasking, coGraphicsPostEffectDistortion];
GRAPHICS_PRESET_ACTIVE_OPTIONS_HIGH = GRAPHICS_PRESET_ACTIVE_OPTIONS_MEDIUM + [coGraphicsDeferredShading, coGraphicsPostEffectToon];
GRAPHICS_PRESET_ACTIVE_OPTIONS_VERY_HIGH = GRAPHICS_PRESET_ACTIVE_OPTIONS_HIGH + [coGraphicsPostEffectSSAO];
MENU_RESOLUTIONS : array [EnumMenuResolution] of RIntVector2 =
((X : 1024; Y : 576),
(X : 1280; Y : 720),
(X : 1600; Y : 900),
(X : 1920; Y : 1080),
(X : 2560; Y : 1440),
(X : 0; Y : 0));
protected
/// <summary> Reads properties from settings. </summary>
procedure Refresh;
/// <summary> Publishes settings to GUI. </summary>
procedure Sync;
procedure DetermineMenuResolution;
procedure DetermineShadowQualityFromSettings;
procedure DetermineGraphicsQualityFromSettings(Sync : Boolean = False);
procedure DetermineCurrentLanguage;
procedure BeginUpdate;
procedure EndUpdate;
strict private
FShadowQuality : EnumShadowQuality;
FTextureQuality : EnumTextureQuality;
FHealthbarMode : EnumHealthbarMode;
FDropZoneMode : EnumDropZoneMode;
FClickPrecision : EnumClickPrecision;
FGraphicsQuality : EnumGraphicsQuality;
FDisplayMode : EnumDisplayMode;
FMenuResolution : EnumMenuResolution;
FMenuScaling : EnumMenuScaling;
FAvailableLanguages : TUltimateList<RSteamLanguage>;
FCurrentLanguage : RSteamLanguage;
procedure SetCurrentLanguage(const Value : RSteamLanguage); virtual;
procedure SetAvailableLanguages(const Value : TUltimateList<RSteamLanguage>); virtual;
procedure SetMenuScaling(const Value : EnumMenuScaling); virtual;
procedure SetMenuResolution(const Value : EnumMenuResolution); virtual;
procedure SetDisplayMode(const Value : EnumDisplayMode); virtual;
procedure SetGraphicsQuality(const Value : EnumGraphicsQuality); virtual;
procedure SetClickPrecision(const Value : EnumClickPrecision); virtual;
procedure SetDropZoneMode(const Value : EnumDropZoneMode); virtual;
procedure SetTextureQuality(const Value : EnumTextureQuality); virtual;
procedure SetHealthbarMode(const Value : EnumHealthbarMode); virtual;
procedure SetShadowQuality(const Value : EnumShadowQuality); virtual;
strict private
FKeyToBind : EnumKeybinding;
FNewKeybinding : RBinding;
FNewKeybindingIndex : integer;
FBindableKeys : TUltimateList<EnumKeybinding>;
procedure SetNewKeybinding(const Value : RBinding); virtual;
procedure SetKeyToBind(const Value : EnumKeybinding); virtual;
published
property GraphicsQuality : EnumGraphicsQuality read FGraphicsQuality write SetGraphicsQuality;
property TextureQuality : EnumTextureQuality read FTextureQuality write SetTextureQuality;
property DisplayMode : EnumDisplayMode read FDisplayMode write SetDisplayMode;
property ShadowQuality : EnumShadowQuality read FShadowQuality write SetShadowQuality;
property HealthBarMode : EnumHealthbarMode read FHealthbarMode write SetHealthbarMode;
property DropZoneMode : EnumDropZoneMode read FDropZoneMode write SetDropZoneMode;
property ClickPrecision : EnumClickPrecision read FClickPrecision write SetClickPrecision;
property MenuResolution : EnumMenuResolution read FMenuResolution write SetMenuResolution;
property MenuScaling : EnumMenuScaling read FMenuScaling write SetMenuScaling;
property AvailableLanguages : TUltimateList<RSteamLanguage> read FAvailableLanguages write SetAvailableLanguages;
property CurrentLanguage : RSteamLanguage read FCurrentLanguage write SetCurrentLanguage;
property BindableKeys : TUltimateList<EnumKeybinding> read FBindableKeys;
property KeyToBind : EnumKeybinding read FKeyToBind write SetKeyToBind;
property NewBinding : RBinding read FNewKeybinding write SetNewKeybinding;
[dXMLDependency('.KeyToBind')]
function KeyToBindString : string;
[dXMLDependency('.NewBinding')]
function IsRebindValid : Boolean;
procedure RebindKey(Key : EnumKeybinding; Alt : Boolean);
procedure DeleteKey(Key : EnumKeybinding; Alt : Boolean);
procedure ApplyRebinding;
procedure CancelRebinding;
procedure RevertCategory(Category : EnumOptionType);
public
constructor Create;
function GetBoolean(Option : EnumClientOption) : Boolean;
procedure SetBoolean(Option : EnumClientOption; Value : Boolean);
function GetInteger(Option : EnumClientOption) : integer;
procedure SetInteger(Option : EnumClientOption; Value : integer);
function GetKeybinding(Binding : EnumKeybinding) : RBinding;
function GetAltKeybinding(Binding : EnumKeybinding) : RBinding;
class procedure WriteShadowQualityToSettings(const Value : EnumShadowQuality);
class procedure WriteGraphicsQualityToSettings(const Value : EnumGraphicsQuality);
procedure Idle;
destructor Destroy; override;
end;
RFPSLogData = record
Timestamp : int64;
FPS : integer;
end;
/// <summary> Manages the settings menu. Used in mainmenu and ingame. </summary>
TGameStateComponentSettings = class(TGameStateComponent)
protected
FSettings : TSettingsWrapper;
procedure Initialize; override;
procedure OnDialogOpen(Open : Boolean);
published
[XEvent(eiClientOption, epLast, etTrigger, esGlobal)]
function OnClientOption(ChangedOption : RParam) : Boolean;
strict private
FCategory : EnumOptionType;
procedure SetCategory(const Value : EnumOptionType); virtual;
published
property Category : EnumOptionType read FCategory write SetCategory;
procedure DeactivateAndSaveSettings;
procedure DeactivateAndDiscardSettings;
public
constructor Create(Owner : TEntity; Parent : TGameState);
procedure ParentEntered; override;
procedure ParentLeft; override;
procedure Idle; override;
destructor Destroy; override;
end;
/// <summary> Manages the feedback form in the alpha. </summary>
TGameStateComponentFeedback = class(TGameStateComponent)
protected
procedure Initialize; override;
strict private
FFeedback : string;
published
procedure SetFeedback(const Value : string); virtual;
property Feedback : string read FFeedback write SetFeedback;
procedure SendFeedback;
public
procedure ParentEntered; override;
procedure ParentLeft; override;
constructor Create(Owner : TEntity; Parent : TGameState);
destructor Destroy; override;
end;
/// <summary> Manages the inventory (Lootboxes, etc.) of the user. </summary>
TGameStateComponentInventory = class(TGameStateComponent)
protected
FLastDraftbox : TDraftbox;
procedure Initialize; override;
procedure OnDraftboxOpen(Open : Boolean);
procedure UpdateDraftboxDialog(CurrentDraftBox : TDraftbox);
strict private
FLootbox : TLootbox;
FChosenDraftBoxChoice : TDraftBoxChoice;
FOpenedBoosterPack : TLootbox;
procedure SetOpenedBoosterPack(const Value : TLootbox); virtual;
function GetShop : TShop;
procedure SetChosenDraftBoxChoice(const Value : TDraftBoxChoice); virtual;
procedure SetLootbox(const Value : TLootbox); virtual;
published
property Shop : TShop read GetShop;
property Lootbox : TLootbox read FLootbox write SetLootbox;
[dXMLDependency('.Lootbox')]
function IsLootboxVisible : Boolean;
procedure ShowLootbox(const Lootbox : TLootbox);
procedure HideLootbox;
// Draft boxes
[dXMLDependency('.Draftbox')]
function HasDraftbox : Boolean;
[dXMLDependency('.Shop.Inventory.Opened')]
function Draftbox : TDraftbox;
property ChosenDraftBoxChoice : TDraftBoxChoice read FChosenDraftBoxChoice write SetChosenDraftBoxChoice;
procedure Draft;
// Booster packs
[dXMLDependency('.Shop.Inventory.Opened')]
function NextBoosterPack : TLootbox;
[dXMLDependency('.Shop.Inventory.Opened')]
function BoosterPackCount : integer;
property OpenedBoosterPack : TLootbox read FOpenedBoosterPack write SetOpenedBoosterPack;
procedure OpenNextBoosterPack;
public
procedure ParentEntered; override;
procedure ParentLeft; override;
destructor Destroy; override;
end;
/// <summary> Manages the deckbuilding. </summary>
TGameStateComponentDeckbuilding = class(TGameStateComponent)
protected
procedure Initialize; override;
procedure ApplyFilters;
procedure OnPlayerCardsChange(Sender : TUltimateList<TCardInstance>; Item : TArray<TCardInstance>; Action : EnumListAction; Indices : TArray<integer>);
strict private// global
function GetShop : TShop;
procedure SetShop(const Value : TShop); virtual;
function GetDeckManager : TDeckManager;
procedure SetDeckManager(const Value : TDeckManager); virtual;
function GetCardManager : TCardManager;
procedure SetCardManager(const Value : TCardManager); virtual;
strict private// decklist
FDeckToDelete : TDeck;
procedure SetDeckToDelete(const Value : TDeck); virtual;
function GetDecklist : TUltimateList<TDeck>;
strict private// deckeditor
FNewDeckName : string;
FEditedDeck : TDeck;
FDeckCard : TDeckCard;
FGridSize : integer;
FCardpoolCards : TUltimateList<TCardInstance>;
FCardpool : TPaginator<TCardInstance>;
FCardpoolFilter : TPaginatorCardFilter<TCardInstance>;
FSacrificeGridSize : integer;
FCardInstanceWithRewards : TCardInstanceWithRewards;
FSacrificeList, FSacrificePoolCards, FSacrificePoolCurrentObjects : TUltimateList<TCardInstance>;
FSacrificePool : TPaginator<TCardInstance>;
procedure UpdateSacrificePool;
procedure UpdateCardDetails;
procedure SetSacrificePool(const Value : TPaginator<TCardInstance>); virtual;
procedure AscendRaw(WithCrystals : Boolean);
procedure SetDeckCard(const Value : TDeckCard); virtual;
procedure SetCardInstanceWithRewards(const Value : TCardInstanceWithRewards); virtual;
procedure SetEditedDeck(const Value : TDeck); virtual;
procedure SetNewDeckName(const Value : string); virtual;
procedure SetGridSize(const Value : integer); virtual;
procedure SetCardPool(const Value : TPaginator<TCardInstance>); virtual;
procedure SetCardpoolCards(const Value : TUltimateList<TCardInstance>); virtual;
procedure SetCardPoolFilter(const Value : TPaginatorCardFilter<TCardInstance>); virtual;
published
property Shop : TShop read GetShop write SetShop;
property DeckManager : TDeckManager read GetDeckManager write SetDeckManager;
property CardManager : TCardManager read GetCardManager write SetCardManager;
// decklist ------------------------------------------------------------------------------------------------
property DeckToDelete : TDeck read FDeckToDelete write SetDeckToDelete;
property Decks : TUltimateList<TDeck> read GetDecklist;
procedure EditDeck(Deck : TDeck);
procedure AddDeck;
procedure PrepareDeleteDeck(Deck : TDeck);
procedure DeletePreparedDeck;
// deckeditor ----------------------------------------------------------------------------------------------
property Deck : TDeck read FEditedDeck write SetEditedDeck;
procedure AddCard(const CardInstance : TCardInstance);
procedure CloseIfInDeckeditor;
// deck card skin
property DeckCard : TDeckCard read FDeckCard write SetDeckCard;
procedure ChooseSkin(const Skin : TCardSkin);
// deckname
property NewDeckName : string read FNewDeckName write SetNewDeckName;
procedure SaveNewDeckName;
procedure CancelNewDeckName;
// choose deckicon dialog
procedure ChooseDeckIcon(const IconUID : string);
// cardpool
property GridSize : integer read FGridSize write SetGridSize;
property CardpoolCurrentObjects : TUltimateList<TCardInstance> read FCardpoolCards write SetCardpoolCards;
property Cardpool : TPaginator<TCardInstance> read FCardpool write SetCardPool;
property CardpoolFilter : TPaginatorCardFilter<TCardInstance> read FCardpoolFilter write SetCardPoolFilter;
procedure ResetFilter;
/// <summary> The card shown in the detailview. </summary>
property Card : TCardInstanceWithRewards read FCardInstanceWithRewards write SetCardInstanceWithRewards;
procedure ShowCardDetails(const Card : TCardInstance);
procedure CloseCardDetails;
property SacrificeList : TUltimateList<TCardInstance> read FSacrificeList;
[dXMLDependency('.Card', '.SacrificeList')]
function SacrificeListValue : integer;
[dXMLDependency('.Card', '.SacrificeList')]
function SacrificeListExperienceValue : integer;
property SacrificePoolCurrentObjects : TUltimateList<TCardInstance> read FSacrificePoolCurrentObjects;
property SacrificePool : TPaginator<TCardInstance> read FSacrificePool write SetSacrificePool;
procedure PickMaterial(Card : TCardInstance);
procedure RemoveMaterial(Card : TCardInstance);
[dXMLDependency('.Card', '.SacrificeList')]
function AscensionCreditCost : RCost;
[dXMLDependency('.Card', '.SacrificeList')]
function AscensionCrystalCost : RCost;
[dXMLDependency('.Card.CardInstance.IsLeagueUpgradable', '.AscensionCreditCost')]
function CanAscendWithSacrificeList : Boolean;
[dXMLDependency('.Shop.Balances', '.Card.CardInstance.IsLeagueUpgradable', '.AscensionCreditCost')]
function CanAscendWithCredits : Boolean;
[dXMLDependency('.Shop.Balances', '.Card.CardInstance.IsLeagueUpgradable', '.AscensionCost')]
function CanAscendWithCrystals : Boolean;
procedure Ascend;
procedure AscendWithCredits;
procedure AscendWithCrystals;
procedure PushCardXP;
public
procedure ParentEntered; override;
procedure ParentLeft; override;
destructor Destroy; override;
end;
EnumPurchaseState = (psNone, psProcessing, psSuccess, psAborted, psFailed);
/// <summary> Manages the shop in the main menu. </summary>
TGameStateComponentShop = class(TGameStateComponent)
protected
procedure Initialize; override;
procedure ApplyFilters;
procedure OnGainReward(Rewards : TArray<RReward>);
procedure OnShopItemsChange(Sender : TUltimateList<TShopItem>; Item : TArray<TShopItem>; Action : EnumListAction; Indices : TArray<integer>);
strict private
FChosenShopItem : TShopItem;
FShopItemList : TUltimateList<TShopItem>;
FShopItems : TPaginator<TShopItem>;
FShopItemFilter : TPaginatorShopFilter<TShopItem>;
FPurchaseState : EnumPurchaseState;
FBonuscode : string;
function GetShop : TShop;
function GetDeckslotShopItemCredits : TShopItem;
function GetDeckslotShopItemCrystals : TShopItem;
procedure SetPurchaseState(const Value : EnumPurchaseState); virtual;
procedure SetChosenShopItem(const Value : TShopItem); virtual;
procedure SetShop(const Value : TShop); virtual;
procedure SetShopItems(const Value : TPaginator<TShopItem>); virtual;
procedure SetShopItemFilter(const Value : TPaginatorShopFilter<TShopItem>); virtual;
published
property Shop : TShop read GetShop write SetShop;
// shop item list
property ShopItemsCurrentObjects : TUltimateList<TShopItem> read FShopItemList;
property ShopItems : TPaginator<TShopItem> read FShopItems write SetShopItems;
property ShopItemFilter : TPaginatorShopFilter<TShopItem> read FShopItemFilter write SetShopItemFilter;
procedure ResetFilter;
// shop item selection
property ChosenShopItem : TShopItem read FChosenShopItem write SetChosenShopItem;
procedure SelectShopItem(const ShopItem : TShopItem);
// purchasing
property PurchaseState : EnumPurchaseState read FPurchaseState write SetPurchaseState;
procedure BuyOffer(const Offer : TShopItemOffer);
procedure BuyOfferTimes(const Offer : TShopItemOffer; Times : integer);
procedure ConfirmPurchaseDialog;
// bonus code
procedure SetBonuscode(const Value : string); virtual;
property Bonuscode : string read FBonuscode write SetBonuscode;
procedure RedeemBonuscode;
// first crystal purchase reward
[dXMLDependency('.Shop.Items.PurchasesCount')]
function FirstCrystalsBought : Boolean;
// deckslots
[dXMLDependency('.Shop.Items', '.Shop.Items.PurchasesCount')]
property DeckslotShopItemCredits : TShopItem read GetDeckslotShopItemCredits;
[dXMLDependency('.Shop.Items')]
property DeckslotShopItemCrystals : TShopItem read GetDeckslotShopItemCrystals;
public
procedure ParentEntered; override;
procedure ParentLeft; override;
destructor Destroy; override;
end;
EnumNotificationType = (ntNone, ntCardUnlock, ntFriendRequest, ntReward, ntLootlist, ntMessage);
TGameStateComponentNotification = class;
TNotification = class abstract
protected
FNotificationType : EnumNotificationType;
FOwner : TGameStateComponentNotification;
procedure OnShown; virtual;
published
property NotificationType : EnumNotificationType read FNotificationType;
public
constructor Create(Owner : TGameStateComponentNotification);
end;
TNotificationCardUnlock = class(TNotification)
protected
procedure OnShown; override;
strict private
FCard : TCard;
published
property Card : TCard read FCard;
procedure ToShop;
public
constructor Create(Owner : TGameStateComponentNotification; const Card : TCard);
end;
TNotificationReward = class(TNotification)
protected
procedure OnShown; override;
strict private
FRewards : TArray<RReward>;
FRewardCount : integer;
FHasWideItems : Boolean;
published
property Rewards : TArray<RReward> read FRewards;
property RewardCount : integer read FRewardCount;
property HasWideItems : Boolean read FHasWideItems;
public
constructor Create(Owner : TGameStateComponentNotification; const Rewards : TArray<RReward>);
end;
TNotificationLootlist = class(TNotification)
protected
procedure OnShown; override;
strict private
FIdentifier : string;
FStarterDeckColor : EnumEntityColor;
published
property Identifier : string read FIdentifier;
// hacked for now as we are only using lootlists for starterdecks
property StarterDeckColor : EnumEntityColor read FStarterDeckColor;
public
constructor Create(Owner : TGameStateComponentNotification; const Identifier : string);
end;
TNotificationFriendRequest = class(TNotification)
strict private
FRequester : TPerson;
published
// we use the person here, as the TFriendRequest can be freed while notification is still shown
property Requester : TPerson read FRequester;
public
constructor Create(Owner : TGameStateComponentNotification; const Request : TFriendRequest);
end;
TNotificationMessage = class(TNotification)
strict private
FMessage : TMessage;
published
property Msg : TMessage read FMessage;
public
constructor Create(Owner : TGameStateComponentNotification; const Msg : TMessage);
end;
/// <summary> Manages messages like unlocks sent to the user </summary>
TGameStateComponentNotification = class(TGameStateComponent)
protected
FBlock : integer;
FBlockTimer : TTimer;
procedure AddNotification(Notification : TNotification);
procedure OnNotificationOpen(Open : Boolean);
procedure OnNewMessage(const Msg : TMessage);
function IsBlocked : Boolean;
procedure Initialize; override;
strict private
FNotifications : TUltimateObjectList<TNotification>;
published
property Notifications : TUltimateObjectList<TNotification> read FNotifications;
[dXMLDependency('.Notifications')]
function HasNotification : Boolean;
[dXMLDependency('.Notifications')]
function Notification : TNotification;
procedure Close;
public
procedure ParentEntered; override;
procedure ParentLeft; override;
/// <summary> Blocks the next n notifications. </summary>