Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ServerConfigAdvancedComponent.c
Go to the documentation of this file.
2{
3 protected const string HOST_LOCALY = "lan";
4 protected const string BIND_IP = "bindAddress";
5 protected const string BIND_PORT = "bindPort";
6 protected const string PUBLIC_IP = "publicAddress";
7 protected const string PUBLIC_PORT = "publicPort";
8
13
14 protected bool m_bWasPortEdited = false;
15
16 // Invokers
18
19 //------------------------------------------------------------------------------------------------
27
28 //-------------------------------------------------------------------------------------------
29 override void HandlerAttached(Widget w)
30 {
31 super.HandlerAttached(w);
32
33 // Find widges
35
38 m_HostLocalyCheck.GetSpinBox().m_OnChanged.Insert(OnHostLocalyChanged);
39
42 m_PublicPortEdit.GetEditBoxComponent().m_OnWriteModeLeave.Insert(OnPublicPortChanged);
43
46 m_BindPortEdit.GetEditBoxComponent().m_OnChanged.Insert(OnBindPortChanged);
47 }
48
49 //-------------------------------------------------------------------------------------------
50 protected void OnHostLocalyChanged(SCR_SpinBoxComponent spinBox, int option)
51 {
52 bool selected = option == 1;
53
54 // Set public ip to local
55 m_PublicAddress.SetInteractive(!selected);
56
57 if (selected) // True
58 {
59 // Set public ip to local
60 m_PublicAddress.SetValue(SCR_WidgetEditFormatIP.LAN_VALUE);
61 }
62 else
63 {
64 // Clear public ip edit
65 m_PublicAddress.SetValue("");
66 }
67 }
68
69 //-------------------------------------------------------------------------------------------
70 protected void OnBindPortChanged(SCR_EditBoxComponent edit, string text)
71 {
72 // Registed port edited
73 if (!m_bWasPortEdited && !text.IsEmpty())
74 {
75 m_bWasPortEdited = true;
76 }
77 else if (m_bWasPortEdited && text.IsEmpty())
78 {
79 m_bWasPortEdited = false;
80 }
81 }
82
83 //-------------------------------------------------------------------------------------------
84 protected void OnPublicPortChanged(string text)
85 {
86 // Edit bind by public port
88 m_BindPortEdit.ClearInvalidInput();
89
91 m_OnPortChanged.Invoke(m_PublicPortEdit.ValueAsString());
92 }
93
94 //-------------------------------------------------------------------------------------------
96 void FillFromDSConfig(notnull SCR_DSConfig config)
97 {
98 FindEntry(HOST_LOCALY).SetValue(SCR_JsonApiStructHandler.BoolToString(config.publicAddress == SCR_WidgetEditFormatIP.LAN_VALUE));
99 FindEntry(PUBLIC_IP).SetValue(config.publicAddress);
100 FindEntry(PUBLIC_PORT).SetValue(config.publicPort.ToString());
101 FindEntry(BIND_IP).SetValue(config.bindAddress);
102 FindEntry(BIND_PORT).SetValue(config.bindPort.ToString());
103 }
104
105 //-------------------------------------------------------------------------------------------
106 void SetIPPort(DSConfig config)
107 {
108 FindEntry(PUBLIC_IP).SetValue(config.publicAddress);
109 FindEntry(PUBLIC_PORT).SetValue(config.publicPort.ToString());
110 FindEntry(BIND_IP).SetValue(config.bindAddress);
111 FindEntry(BIND_PORT).SetValue(config.bindPort.ToString());
112 }
113
114 //-------------------------------------------------------------------------------------------
115 void SetPorts(string port)
116 {
117 m_PublicPortEdit.SetValue(port);
118 m_BindPortEdit.SetValue(port);
119 }
120}
void DSConfig()
Definition DSConfig.c:83
ScriptInvokerBase< ScriptInvokerStringMethod > ScriptInvokerString
SCR_WidgetListEntry FindEntry(string propertyName, string groupTag="")
Find variable of given property name and group tag - no group tag find any variable of given property...
Handler for json api struct values.
static string BoolToString(bool boolean)
void OnBindPortChanged(SCR_EditBoxComponent edit, string text)
void OnHostLocalyChanged(SCR_SpinBoxComponent spinBox, int option)
void FillFromDSConfig(notnull SCR_DSConfig config)
Fill all entries with values from given DS config.
Configurable widget list entry for various value that can be typed - numbers, strings,...
void SetValue(string str)
Configurable widget list entry selection specific for spinbox.