Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RewindComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/GameMode/Components", description: "")]
3 {
4 }
5 
6 class SCR_RewindComponent : SCR_BaseGameModeComponent
7 {
8  [Attribute(ESaveType.EDITOR.ToString(), UIWidgets.ComboBox, "Save file type.", enums: ParamEnumArray.FromEnum(ESaveType))]
9  protected ESaveType m_eSaveType;
10 
11  [Attribute(desc: "Name of the save file. Optional, leave empty to use default.")]
12  protected string m_sCustomName;
13 
14  //------------------------------------------------------------------------------------------------
16  static SCR_RewindComponent GetInstance()
17  {
18  BaseGameMode gameMode = GetGame().GetGameMode();
19  if (gameMode)
20  return SCR_RewindComponent.Cast(gameMode.FindComponent(SCR_RewindComponent));
21  else
22  return null;
23  }
24 
25  //------------------------------------------------------------------------------------------------
28  {
29  return Replication.IsServer() && GetGame().GetSaveManager().FileExists(m_eSaveType, m_sCustomName);
30  }
31 
32  //------------------------------------------------------------------------------------------------
35  {
36  if (Replication.IsServer() && !HasRewindPoint())
37  GetGame().GetSaveManager().Save(m_eSaveType, m_sCustomName);
38  }
39 
40  //------------------------------------------------------------------------------------------------
43  {
44  if (Replication.IsServer())
45  GetGame().GetSaveManager().Delete(m_eSaveType, m_sCustomName);
46  }
47 
48  //------------------------------------------------------------------------------------------------
50  void Rewind()
51  {
52  if (Replication.IsServer())
53  GetGame().GetSaveManager().RestartAndLoad(m_eSaveType, m_sCustomName);
54  }
55 
56  //------------------------------------------------------------------------------------------------
57  protected void OnSaved(ESaveType type, string fileName)
58  {
59  if (type == ESaveType.USER)
60  GetGame().GetCallqueue().CallLater(DeleteRewindPoint, 1); //--- Cannot call instantly, session storage is still locked by saving a file
61  }
62 
63  //------------------------------------------------------------------------------------------------
64  override void OnPostInit(IEntity owner)
65  {
66  if (!SCR_Global.IsEditMode(owner))
67  GetGame().GetSaveManager().GetOnSaved().Insert(OnSaved);
68  }
69 }
70 
72 {
73  protected ESaveType m_eSaveType;
74  protected string m_sCustomName;
75 
76  //------------------------------------------------------------------------------------------------
77  override void OnConfirm()
78  {
79  SCR_RewindComponent.GetInstance().Rewind();
80  }
81 
82  //------------------------------------------------------------------------------------------------
86  void SCR_RewindDialog(ESaveType saveType, string customName)
87  {
88  m_eSaveType = saveType;
89  m_sCustomName = customName;
90  SCR_ConfigurableDialogUi.CreateFromPreset(SCR_CommonDialogs.DIALOGS_CONFIG, "rewind", this);
91  }
92 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SCR_RewindComponentClass
Definition: SCR_RewindComponent.c:2
Rewind
void Rewind()
Rewind to existing rewind point of this session.
Definition: SCR_RewindComponent.c:50
GetInstance
SCR_TextsTaskManagerComponentClass ScriptComponentClass GetInstance()
Definition: SCR_TextsTaskManagerComponent.c:50
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CommonDialogs
Definition: CommonDialogs.c:5
m_sCustomName
protected string m_sCustomName
Definition: SCR_RewindComponent.c:12
HasRewindPoint
bool HasRewindPoint()
Definition: SCR_RewindComponent.c:27
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
SCR_RewindComponentClass SCR_BaseGameModeComponentClass Attribute(ESaveType.EDITOR.ToString(), UIWidgets.ComboBox, "Save file type.", enums:ParamEnumArray.FromEnum(ESaveType))] protected ESaveType m_eSaveType
DeleteRewindPoint
void DeleteRewindPoint()
Remove existing rewind point for this session.
Definition: SCR_RewindComponent.c:42
SCR_RewindDialog
Definition: SCR_RewindComponent.c:71
ESaveType
ESaveType
Definition: ESaveType.c:1
OnPostInit
override void OnPostInit(IEntity owner)
Editable Mine.
Definition: SCR_RewindComponent.c:64
SCR_Global
Definition: Functions.c:6
CreateRewindPoint
void CreateRewindPoint()
Create a rewind point for this session.
Definition: SCR_RewindComponent.c:34
SCR_ConfigurableDialogUi
Definition: SCR_ConfigurableDialogUI.c:13
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
OnSaved
protected void OnSaved(ESaveType type, string fileName)
Definition: SCR_RewindComponent.c:57
SCR_BaseGameModeComponentClass
Definition: SCR_BaseGameModeComponent.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_BaseGameModeComponent
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_BaseGameModeComponent.c:199