Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RoomPasswordVerification.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
5 //------------------------------------------------------------------------------------------------
7 {
8  protected string FALLBACK_ERROR = "#AR-Password_FailMessage";
9  protected string FALLBACK_TIMEOUT = "#AR-Password_TimeoutMessage";
10 
11  protected Room m_Room;
12  protected SCR_ConfigurableDialogUi m_Dialog;
13  protected SCR_LoadingOverlay m_LoadingOverlay;
14 
15  protected ref SCR_BackendCallback m_Callback = new SCR_BackendCallback();
16 
17  protected ref ScriptInvokerRoom m_OnVerified = new ScriptInvokerRoom();
18  protected ref ScriptInvokerString m_OnFailVerification = new ScriptInvokerString();
19 
20  //------------------------------------------------------------------------------------------------
21  ScriptInvokerRoom GetOnVerified()
22  {
23  return m_OnVerified;
24  }
25 
26  //------------------------------------------------------------------------------------------------
27  ScriptInvokerString GetOnFailVerification()
28  {
29  return m_OnFailVerification;
30  }
31 
32  //------------------------------------------------------------------------------------------------
34  void SetupDialog(notnull SCR_ConfigurableDialogUi dialog, notnull Room room, string message = "")
35  {
36  m_Dialog = dialog;
37  m_Room = room;
38 
39  // Callbacks
40  dialog.m_OnConfirm.Insert(OnPasswordConfirm);
41  //dialog.m_OnCancel.Insert(PasswordClearInvokers);
42 
43 
44  // Display dialog message - TODO: Check what is this for?
45  SCR_EditboxDialogUi editDialog = SCR_EditboxDialogUi.Cast(dialog);
46  if (editDialog)
47  editDialog.SetWarningMessage(message);
48  }
49 
50  //------------------------------------------------------------------------------------------------
51  protected void InitCheck()
52  {
53  // Show loading
54  if (m_LoadingOverlay)
55  m_LoadingOverlay.SetShown(true);
56  else
57  m_LoadingOverlay = SCR_LoadingOverlay.ShowForWidget(GetGame().GetWorkspace(), string.Empty);
58 
59  m_Callback.GetEventOnResponse().Insert(OnPasswordCheckResponse);
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  void CheckRejoinAuthorization(Room room)
64  {
65  if (!room)
66  {
67  Debug.Error("Room instance expected! Null found in room");
68  return;
69  }
70  m_Room = room;
71 
72  InitCheck();
73  m_Room.CheckAuthorization(m_Callback);
74 
75  }
76 
77  //------------------------------------------------------------------------------------------------
79  protected void OnPasswordConfirm()
80  {
81  if (!m_Room)
82  {
83  Debug.Error("Room instance expected! Null found in m_Room");
84  return;
85  }
86 
87  InitCheck();
88 
89  SCR_EditboxDialogUi editboxDialog = SCR_EditboxDialogUi.Cast(m_Dialog);
90 
91  // Get edit box value
92  string value = editboxDialog.GetEditbox().GetValue();
93 
94  // Try join with password
95  m_Room.VerifyPassword(value, m_Callback);
96  }
97 
98  //------------------------------------------------------------------------------------------------
100  protected void OnPasswordCheckResponse(SCR_BackendCallback callback)
101  {
102  // Hide loading
103  if (m_LoadingOverlay)
104  m_LoadingOverlay.SetShown(false);
105 
106  // Clear
107  ClearInvokers();
108 
109  // Reaction
110  switch (callback.GetResponseType())
111  {
112  case EBackendCallbackResponse.SUCCESS:
113  {
114  // Invoke verification with successful password struct
115  m_OnVerified.Invoke(m_Room);
116  break;
117  }
118 
119  case EBackendCallbackResponse.ERROR:
120  {
121  //JoinProcess_PasswordDialogOpen(FALLBACK_ERROR);
122  m_OnFailVerification.Invoke(FALLBACK_ERROR);
123  break;
124  }
125 
126  case EBackendCallbackResponse.TIMEOUT:
127  {
128  //JoinProcess_PasswordDialogOpen(FALLBACK_TIMEOUT);
129  m_OnFailVerification.Invoke(FALLBACK_TIMEOUT);
130  break;
131  }
132  }
133  }
134 
135  //------------------------------------------------------------------------------------------------
136  protected void ClearInvokers()
137  {
138  m_Callback.GetEventOnResponse().Remove(OnPasswordCheckResponse);
139  if(m_Dialog && m_Dialog.m_OnConfirm)
140  m_Dialog.m_OnConfirm.Remove(OnPasswordConfirm);
141  }
142 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_EditboxDialogUi
Configurable editbox dialog base.
Definition: SCR_EditboxDialogUI.c:3
m_Callback
protected ref CampaignCallback m_Callback
Definition: SCR_PlayerProfileManagerComponent.c:25
SCR_LoadingOverlay
Definition: SCR_LoadingOverlay.c:49
SCR_BackendCallback
Scripted backend callback class unifying backend response.
Definition: SCR_BackendCallback.c:21
m_LoadingOverlay
protected SCR_LoadingOverlay m_LoadingOverlay
Definition: SCR_BackendImageComponent.c:250
ScriptInvokerString
ScriptInvokerBase< ScriptInvokerStringMethod > ScriptInvokerString
Definition: SCR_ScriptInvokerHelper.c:75
SCR_RoomPasswordVerification
Definition: SCR_RoomPasswordVerification.c:6
SCR_ConfigurableDialogUi
Definition: SCR_ConfigurableDialogUI.c:13
EBackendCallbackResponse
EBackendCallbackResponse
Basic callback responses.
Definition: SCR_BackendCallback.c:12
m_Room
protected Room m_Room
Definition: ServerBrowserMenuCallbacks.c:2
callback
DownloadConfigCallback callback
ScriptInvokerRoom
ScriptInvokerBase< ScriptInvokerRoomMethod > ScriptInvokerRoom
Definition: ServerBrowserMenuUI.c:8