Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ConnectionUICommon.c
Go to the documentation of this file.
2{
3 static const string ICON_SERVICES_ISSUES = "connection-issues";
4 static const string ICON_CONNECTION = "connection";
5 static const string ICON_DISCONNECTION = "disconnection";
6
7 static const string MESSAGE_SERVICES_ISSUES = "#AR-CoreMenus_Tooltips_UnavailableServices";
8 static const string MESSAGE_CONNECTING = "#AR-Workshop_Connecting";
9 static const string MESSAGE_DISCONNECTION = "#AR-CoreMenus_Tooltips_NoConnection";
10
11 static const string MESSAGE_VERBOSE_DISCONNECTION = "#AR-Workshop_WarningNoConnection";
12 static const string MESSAGE_VERBOSE_TIMEOUT = "#AR-Workshop_Dialog_Error_ConnectionTimeout2";
13
14 // Connection state related methods
15 //------------------------------------------------------------------------------------------------
17 static bool SetConnectionButtonEnabled(SCR_InputButtonComponent button, string serviceName, bool forceDisabled = false, bool animate = true)
18 {
19 if (!button)
20 return false;
21
22 bool serviceActive = SCR_ServicesStatusHelper.IsServiceActive(serviceName);
23 bool enabled = serviceActive && !forceDisabled;
24 button.SetEnabled(enabled, animate);
25
26 if (forceDisabled && serviceActive)
27 {
28 button.ResetTexture();
29 return true;
30 }
31
32 SetConnectionButtonTexture(button, enabled);
33
34 return true;
35 }
36
37 //------------------------------------------------------------------------------------------------
39 static bool ForceConnectionButtonEnabled(SCR_InputButtonComponent button, bool enabled, bool animate = true)
40 {
41 if (!button)
42 return false;
43
44 button.SetEnabled(enabled, animate);
45 SetConnectionButtonTexture(button, enabled);
46
47 return true;
48 }
49
50 //------------------------------------------------------------------------------------------------
51 protected static void SetConnectionButtonTexture(SCR_InputButtonComponent button, bool enabled)
52 {
53 if (!button)
54 return;
55
56 if (enabled)
57 {
58 button.ResetTexture();
59 return;
60 }
61
62 button.SetTexture(UIConstants.ICONS_IMAGE_SET, GetConnectionIssuesIcon(), UIColors.CopyColor(UIColors.WARNING_DISABLED));
63 }
64
65 //------------------------------------------------------------------------------------------------
67 {
69 {
70 case SCR_ECommStatus.FAILED: return ICON_SERVICES_ISSUES;
71 case SCR_ECommStatus.NOT_EXECUTED: return ICON_SERVICES_ISSUES;
72 case SCR_ECommStatus.RUNNING: return ICON_CONNECTION;
73 }
74
76 return ICON_SERVICES_ISSUES;
77
78 return string.Empty;
79 }
80
81 //------------------------------------------------------------------------------------------------
83 {
85 {
86 case SCR_ECommStatus.FAILED: return MESSAGE_SERVICES_ISSUES;
87 case SCR_ECommStatus.NOT_EXECUTED: return MESSAGE_SERVICES_ISSUES;
88 case SCR_ECommStatus.RUNNING: return MESSAGE_CONNECTING;
89 }
90
92 return MESSAGE_SERVICES_ISSUES;
93
94 return string.Empty;
95 }
96}
SCR_ECommStatus
This class may become obsolete on BackendAPI update.
static string GetConnectionIssuesMessage()
static string GetConnectionIssuesIcon()
static void SetConnectionButtonTexture(SCR_InputButtonComponent button, bool enabled)
override void SetEnabled(bool enabled, bool animate=true)
void SetTexture(string imagePath, string image=string.Empty, Color color=Color.FromInt(Color.WHITE), SCR_EButtonSize buttonType=SCR_EButtonSize.KEYBOARD_MEDIUM)
static bool IsServiceActive(string serviceName)
static SCR_ECommStatus GetLastReceivedCommStatus()