The ordering of job preferences in net lobby are saved in config.xml.
- Added a coroutine which will save the current settings to the config.xml file if no further changes to the preferences are applied after 10 seconds. -The default ordering is now Engineer, Mechanic, Captain, Security, Doctor and Assistant.
This commit is contained in:
@@ -23,6 +23,8 @@ namespace Barotrauma
|
||||
|
||||
private WindowMode windowMode;
|
||||
|
||||
public List<string> jobNamePreferences;
|
||||
|
||||
private KeyOrMouse[] keyMapping;
|
||||
|
||||
private bool unsavedSettings;
|
||||
@@ -56,6 +58,12 @@ namespace Barotrauma
|
||||
|
||||
public ContentPackage SelectedContentPackage { get; set; }
|
||||
|
||||
public List<string> JobNamePreferences
|
||||
{
|
||||
get { return jobNamePreferences; }
|
||||
set { UnsavedSettings = true; jobNamePreferences = value; }
|
||||
}
|
||||
|
||||
public string MasterServerUrl { get; set; }
|
||||
public bool AutoCheckUpdates { get; set; }
|
||||
public bool WasGameUpdated { get; set; }
|
||||
@@ -73,6 +81,13 @@ namespace Barotrauma
|
||||
private set
|
||||
{
|
||||
unsavedSettings = value;
|
||||
// Beging saving coroutine. Remove any existing save coroutines if one is running.
|
||||
if (CoroutineManager.IsCoroutineRunning("saveCoroutine")) { CoroutineManager.StopCoroutines("saveCoroutine"); }
|
||||
if (unsavedSettings == true)
|
||||
{
|
||||
CoroutineManager.StartCoroutine(ApplyUnsavedChanges(), "saveCoroutine");
|
||||
}
|
||||
|
||||
if (applyButton != null)
|
||||
{
|
||||
//applyButton.Selected = unsavedSettings;
|
||||
@@ -124,6 +139,12 @@ namespace Barotrauma
|
||||
|
||||
SelectedContentPackage = ContentPackage.list.Any() ? ContentPackage.list[0] : new ContentPackage("");
|
||||
|
||||
JobNamePreferences = new List<string>();
|
||||
foreach (JobPrefab job in JobPrefab.List)
|
||||
{
|
||||
JobNamePreferences.Add(job.Name);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -208,6 +229,13 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "gameplay":
|
||||
JobNamePreferences = new List<string>();
|
||||
foreach (XElement ele in subElement.Element("jobpreferences").Elements("job"))
|
||||
{
|
||||
JobNamePreferences.Add(ToolBox.GetAttributeString(ele, "name", ""));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,6 +319,17 @@ namespace Barotrauma
|
||||
|
||||
}
|
||||
|
||||
var gameplay = new XElement("gameplay");
|
||||
|
||||
var jobPreferences = new XElement("jobpreferences");
|
||||
foreach (string jobName in JobNamePreferences)
|
||||
{
|
||||
jobPreferences.Add(new XElement("job", new XAttribute("name", jobName)));
|
||||
}
|
||||
|
||||
gameplay.Add(jobPreferences);
|
||||
doc.Root.Add(gameplay);
|
||||
|
||||
doc.Save(filePath);
|
||||
}
|
||||
|
||||
@@ -500,6 +539,13 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
private IEnumerable<object> ApplyUnsavedChanges()
|
||||
{
|
||||
yield return new WaitForSeconds(10.0f);
|
||||
|
||||
Save("config.xml");
|
||||
}
|
||||
|
||||
private bool ApplyClicked(GUIButton button, object userData)
|
||||
{
|
||||
Save("config.xml");
|
||||
|
||||
Reference in New Issue
Block a user