Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_UploadSaveCallback.c
Go to the documentation of this file.
2 {
3  static const string SESSION_SAVE_NAME = "SCR_SaveFileManager_SessionSave";
4 
5  protected string m_sFileName;
6  protected ref SCR_UploadSaveCallback_PageParams m_PageParams;
7  protected ref SCR_ServerSaveUploadCallback m_UploadCallback;
8 
9  protected bool m_bHasData = false;
10 
11  override void OnSuccess(int code)
12  {
13  super.OnSuccess(code);
14 
15  PrintFormat("[SCR_ServerSaveRequestCallback] OnSuccess(): code=%1", code);
16 
17  if (code == 0)
18  return;
19 
20  m_bHasData = code == EBackendRequest.EBREQ_WORKSHOP_GetAsset;
21 
22  WorldSaveItem item;
23  WorldSaveManifest manifest = new WorldSaveManifest();
24 
25  bool isNew = GetGame().GetBackendApi().GetWorldSaveApi().GetTotalItemCount() == 0;
26  if (!isNew)
27  {
28  //--- Use existing Workshop item
29  array<WorldSaveItem> items = {};
30  GetGame().GetBackendApi().GetWorldSaveApi().GetPageItems(items);
31  item = items[0];
32 
33  if (m_bHasData)
34  item.FillManifest(manifest);
35  else
36  {
37  item.AskDetail(this);
38  return;
39  }
40  }
41 
42  //--- Define manifest params
43  manifest.m_sName = SESSION_SAVE_NAME;
44  manifest.m_sSummary = m_sFileName;
45  manifest.m_aFileNames = {m_sFileName};
46 
47  //--- Create new save from manifest
48  if (isNew)
49  {
50  item = GetGame().GetBackendApi().GetWorldSaveApi().CreateLocalWorldSave(manifest);
51  }
52 
53  //--- Upload file
54  m_UploadCallback = new SCR_ServerSaveUploadCallback();
55  GetGame().GetBackendApi().GetWorldSaveApi().UploadWorldSave(manifest, m_UploadCallback, item);
56  }
57  override void OnError(int code, int restCode, int apiCode)
58  {
59  super.OnError(code, restCode, apiCode);
60  PrintFormat("[SCR_ServerSaveRequestCallback] OnError: code=%1 ('%4'), restCode=%2, apiCode=%3", code, restCode, apiCode, GetGame().GetBackendApi().GetErrorCode(code));
61  }
62  override void OnTimeout()
63  {
64  super.OnTimeout();
65  Print("[SCR_ServerSaveRequestCallback] OnTimeout");
66  }
67  void SCR_ServerSaveRequestCallback(string fileName)
68  {
69  m_sFileName = fileName;
70 
71  m_PageParams = new SCR_UploadSaveCallback_PageParams();
72  m_PageParams.limit = 1;
73  GetGame().GetBackendApi().GetWorldSaveApi().RequestPage(this, m_PageParams, false);
74  }
75 };
77 {
78  override void OnPack()
79  {
80  StoreBoolean("owned", true);
81  StoreString("search", SCR_ServerSaveRequestCallback.SESSION_SAVE_NAME);
82  }
83 };
84 
86 {
87  override void OnSuccess(int code)
88  {
89  PrintFormat("[SCR_ServerSaveUploadCallback] OnSuccess(): code=%1", code);
90 
91  BaseChatComponent chatComponent = BaseChatComponent.Cast(GetGame().GetPlayerController().FindComponent(BaseChatComponent));
92  if (chatComponent)
93  chatComponent.SendMessage(string.Format("#load %1", SCR_ServerSaveRequestCallback.SESSION_SAVE_NAME), 0);
94  }
95  override void OnError(int code, int restCode, int apiCode)
96  {
97  PrintFormat("[SCR_ServerSaveUploadCallback] OnError: code=%1 ('%4'), restCode=%2, apiCode=%3", code, restCode, apiCode, GetGame().GetBackendApi().GetErrorCode(code));
98  }
99  override void OnTimeout()
100  {
101  Print("[SCR_ServerSaveUploadCallback] OnTimeout");
102  }
103 }
m_sFileName
protected string m_sFileName
Definition: ServerHostingUI.c:188
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_ServerSaveRequestCallback
Definition: SCR_UploadSaveCallback.c:1
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
SCR_UploadSaveCallback_PageParams
Definition: SCR_UploadSaveCallback.c:76
SCR_BackendCallback
Scripted backend callback class unifying backend response.
Definition: SCR_BackendCallback.c:21
BackendCallback
Base server browser callback.
Definition: SCR_ServerListComponent.c:4
SCR_ServerSaveUploadCallback
Definition: SCR_UploadSaveCallback.c:85