Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DSConfig.c
Go to the documentation of this file.
1 
5 class SCR_DSConfig : DSConfig
6 {
7  protected const string DEFAULT_FILE_NAME = "GeneratedServerConfig";
8  //protected string m_sConfigName = "Server config";
9 
10  protected ref array<ref SCR_WidgetListEntry> m_aDSConfigEntries = {};
11  //protected ref SCR_DSGameProperties m_gameProperties = new SCR_DSGameProperties();
12 
13  //------------------------------------------------------------------------------------------------
14  // API
15  //------------------------------------------------------------------------------------------------
16 
17  //------------------------------------------------------------------------------------------------
18  void SCR_DSConfig()
19  {
20  game = new DSGameConfig();
21  game.gameProperties = new SCR_DSGameProperties();
22  game.mods = {};
23  }
24 
25  //------------------------------------------------------------------------------------------------
27  void StoreFullJson(array<ref SCR_WidgetListEntry> entries, array<ref DSMod> modList, WorkshopItem scenarioMod)
28  {
29  m_aDSConfigEntries = entries;
30 
31  // Config
32  bindAddress = FindValue("bindAddress");
33  bindPort = StringToNumber(FindValue("bindPort"));
34  publicAddress = FindValue("publicAddress");
35  publicPort = StringToNumber(FindValue("publicPort"));
36 
37  // Game
38  game.name = FindValue("name");
39  game.maxPlayers = StringToNumber(FindValue("maxPlayers"));
40  game.password = FindValue("password");
41  game.passwordAdmin = FindValue("passwordAdmin");
42  game.visible = SCR_JsonApiStructHandler.StringToBool(FindValue("visible"));
43  game.crossPlatform = SCR_JsonApiStructHandler.StringToBool(FindValue("crossPlatform"));
44 
45  // Game properties
46  SCR_DSGameProperties gamePropertiesSCr = SCR_DSGameProperties.Cast(game.gameProperties);
47 
48  if (gamePropertiesSCr)
49  {
50  gamePropertiesSCr.battlEye = SCR_JsonApiStructHandler.StringToBool(FindValue("battlEye"));
51  gamePropertiesSCr.disableThirdPerson = SCR_JsonApiStructHandler.StringToBool(FindValue("disableThirdPerson"));
52  gamePropertiesSCr.VONDisableUI = SCR_JsonApiStructHandler.StringToBool(FindValue("VONDisableUI"));
53  gamePropertiesSCr.VONDisableDirectSpeechUI = SCR_JsonApiStructHandler.StringToBool(FindValue("VONDisableDirectSpeechUI"));
54  gamePropertiesSCr.VONCanTransmitCrossFaction = SCR_JsonApiStructHandler.StringToBool(FindValue("VONCanTransmitCrossFaction"));
55  gamePropertiesSCr.serverMaxViewDistance = StringToNumber(FindValue("serverMaxViewDistance"));
56  gamePropertiesSCr.networkViewDistance = StringToNumber(FindValue("networkViewDistance"));
57  gamePropertiesSCr.serverMinGrassDistance = StringToNumber(FindValue("serverMinGrassDistance"));
58  }
59 
60  // Scenario
61  game.scenarioId = FindValue("scenarioId");
62 
63  // Mods
64  game.mods = modList;
65 
66  /*if (!game.name.IsEmpty())
67  m_sConfigName = game.name;*/
68 
69  // Scenario mod
70  if (scenarioMod)
71  {
72  game.hostedScenarioModId = scenarioMod.Id();
73 
74  // Check mod in list
75  bool inList = false;
76 
77  for (int i = 0, count = game.mods.Count(); i < count; i++)
78  {
79  if (game.mods[i].modId == scenarioMod.Id())
80  {
81  inList = true;
82  break;
83  }
84  }
85 
86  // Add to the list
87  if (!inList)
88  {
89  DSMod scenarioDSMod = new DSMod();
90  scenarioDSMod.modId = scenarioMod.Id();
91  scenarioDSMod.name = scenarioMod.Name();
92  scenarioDSMod.version = scenarioMod.GetActiveRevision().GetVersion();
93 
94 
95  game.mods.Insert(scenarioDSMod);
96  }
97  }
98  }
99 
100  //------------------------------------------------------------------------------------------------
101  string GetConfigName()
102  {
103  string name = FindValue("fileName");
104  if (name != "")
105  return name;
106 
107  name = FindValue("name");
108  if (name != "")
109  return name;
110 
111  return DEFAULT_FILE_NAME;
112  }
113 
114  //------------------------------------------------------------------------------------------------
115  // Protected
116  //------------------------------------------------------------------------------------------------
117 
118  //------------------------------------------------------------------------------------------------
120  protected string FindValue(string propertyName, string groupTag = "")
121  {
122  string nameTrimmed = "";
123 
124  for (int i = 0, count = m_aDSConfigEntries.Count(); i < count; i++)
125  {
126  nameTrimmed = m_aDSConfigEntries[i].GetPropertyName();
127  nameTrimmed = nameTrimmed.Trim();
128 
129  if (groupTag == "")
130  {
131  // Has given property name
132  if (nameTrimmed == propertyName)
133  return m_aDSConfigEntries[i].ValueAsString();
134  }
135  else
136  {
137  // Has propery and group
138  if (nameTrimmed == propertyName && m_aDSConfigEntries[i].GetGroupTag() == groupTag)
139  return m_aDSConfigEntries[i].ValueAsString();
140  }
141  }
142 
143  return "";
144  }
145 
146  //------------------------------------------------------------------------------------------------
147  protected float StringToNumber(string str)
148  {
149  if (str.IsEmpty())
150  return 0;
151 
152  return str.ToFloat();
153  }
154 }
155 
156 //------------------------------------------------------------------------------------------------
157 class SCR_DSGameProperties : DSGameProperties
158 {
159  bool disableThirdPerson = false;
160  bool VONDisableUI = false;
166 
167  //------------------------------------------------------------------------------------------------
169  {
170  RegV("serverMaxViewDistance");
171  RegV("networkViewDistance");
172  RegV("serverMinGrassDistance");
173  }
174 
175  //------------------------------------------------------------------------------------------------
176  override void OnPack()
177  {
178  super.OnPack();
179 
180  UnregV("disableThirdPerson");
181  StoreBoolean("disableThirdPerson", disableThirdPerson);
182  UnregV("VONDisableUI");
183  StoreBoolean("VONDisableUI", VONDisableUI);
184  UnregV("VONDisableDirectSpeechUI");
185  StoreBoolean("VONDisableDirectSpeechUI", VONDisableDirectSpeechUI);
186  UnregV("VONCanTransmitCrossFaction");
187  StoreBoolean("VONCanTransmitCrossFaction", VONCanTransmitCrossFaction);
188  }
189 
190  //------------------------------------------------------------------------------------------------
191  override void OnExpand()
192  {
193  RegV("disableThirdPerson");
194  RegV("VONDisableUI");
195  RegV("VONDisableDirectSpeechUI");
196  RegV("VONCanTransmitCrossFaction");
197  }
198 }
SCR_DSGameProperties
void SCR_DSGameProperties()
Definition: SCR_DSConfig.c:168
serverMinGrassDistance
int serverMinGrassDistance
Definition: SCR_DSConfig.c:165
OnExpand
override void OnExpand()
Definition: SCR_DSConfig.c:191
serverMaxViewDistance
float serverMaxViewDistance
Definition: SCR_DSConfig.c:163
disableThirdPerson
SCR_DSConfig disableThirdPerson
VONDisableUI
bool VONDisableUI
Definition: SCR_DSConfig.c:160
SCR_JsonApiStructHandler
Handler for json api struct values.
Definition: SCR_JsonApiStructHandler.c:8
SCR_DSConfig
Definition: SCR_DSConfig.c:5
OnPack
override void OnPack()
Definition: SCR_DSConfig.c:176
VONCanTransmitCrossFaction
bool VONCanTransmitCrossFaction
Definition: SCR_DSConfig.c:162
networkViewDistance
int networkViewDistance
Definition: SCR_DSConfig.c:164
VONDisableDirectSpeechUI
bool VONDisableDirectSpeechUI
Definition: SCR_DSConfig.c:161