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:
@@ -32,7 +32,7 @@
|
||||
<Item name="Orange Jumpsuit" equip="true"/>
|
||||
<Item name="Headset" equip="true">
|
||||
<Item name="Battery Cell"/>
|
||||
</Item>
|
||||
</Item>
|
||||
</Items>
|
||||
</Job>
|
||||
|
||||
@@ -50,11 +50,11 @@
|
||||
<Item name="Blue Jumpsuit" equip="true"/>
|
||||
<Item name="Headset" equip="true">
|
||||
<Item name="Battery Cell"/>
|
||||
</Item>
|
||||
</Item>
|
||||
</Items>
|
||||
</Job>
|
||||
|
||||
<Job name="Security Officer" description="Security officers are are responsible for keeping the submarine safe from potential attackers. The creatures inhabiting the ocean aren't the only threat they need to worry about, as several of the renegade groups opposing the Europa Coalition are known to have sent infiltrators on board the vessels." maxnumber="2">
|
||||
<Job name="Security Officer" description="Security officers are responsible for keeping the submarine safe from potential attackers. The creatures inhabiting the ocean aren't the only threat they need to worry about, as several of the renegade groups opposing the Europa Coalition are known to have sent infiltrators on board the vessels." maxnumber="2">
|
||||
<Skills>
|
||||
<Skill name="Weapons" level="50,60"/>
|
||||
<Skill name="Medical" level="30,40"/>
|
||||
|
||||
@@ -217,6 +217,11 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
JobPrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Jobs));
|
||||
// Add any missing jobs from the prefab into Config.JobNamePreferences.
|
||||
foreach (JobPrefab job in JobPrefab.List)
|
||||
{
|
||||
if (!Config.JobNamePreferences.Contains(job.Name)) { Config.JobNamePreferences.Add(job.Name); }
|
||||
}
|
||||
StructurePrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Structure));
|
||||
TitleScreen.LoadState = 20.0f;
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -540,9 +540,12 @@ namespace Barotrauma
|
||||
|
||||
|
||||
int i = 1;
|
||||
foreach (JobPrefab job in JobPrefab.List)
|
||||
foreach (string jobName in GameMain.Config.JobNamePreferences)
|
||||
{
|
||||
GUITextBlock jobText = new GUITextBlock(new Rectangle(0, 0, 0, 20), i + ". " + job.Name+" ",
|
||||
JobPrefab job = JobPrefab.List.First(x => x.Name == jobName);
|
||||
if (job == null) { continue; }
|
||||
|
||||
GUITextBlock jobText = new GUITextBlock(new Rectangle(0, 0, 0, 20), i + ". " + job.Name + " ",
|
||||
"",Alignment.Left, Alignment.Right, jobList, false,
|
||||
GameMain.GraphicsWidth<1000 ? GUI.SmallFont : GUI.Font);
|
||||
jobText.UserData = job;
|
||||
@@ -1199,6 +1202,8 @@ namespace Barotrauma
|
||||
private void UpdateJobPreferences(GUIListBox listBox)
|
||||
{
|
||||
listBox.Deselect();
|
||||
List<string> jobNamePreferences = new List<string>();
|
||||
|
||||
for (int i = 0; i < listBox.children.Count; i++)
|
||||
{
|
||||
float a = (float)(i - 1) / 3.0f;
|
||||
@@ -1210,8 +1215,11 @@ namespace Barotrauma
|
||||
listBox.children[i].SelectedColor = color;
|
||||
|
||||
(listBox.children[i] as GUITextBlock).Text = (i+1) + ". " + (listBox.children[i].UserData as JobPrefab).Name;
|
||||
|
||||
jobNamePreferences.Add((listBox.children[i].UserData as JobPrefab).Name);
|
||||
}
|
||||
|
||||
|
||||
GameMain.Config.JobNamePreferences = jobNamePreferences;
|
||||
}
|
||||
|
||||
public bool TrySelectSub(string subName, string md5Hash, GUIListBox subList)
|
||||
|
||||
@@ -3,4 +3,14 @@
|
||||
<graphicsmode width="1280" height="720" fullscreen="false" vsync="false" />
|
||||
<contentpackage path="Data/ContentPackages/Vanilla 0.3.xml" />
|
||||
<keymapping Select="E" Use="0" Aim="1" Up="W" Down="S" Left="A" Right="D" Attack="R" Run="LeftShift" Crouch="LeftControl" Chat="Tab" CrewOrders="C" />
|
||||
<gameplay>
|
||||
<jobpreferences>
|
||||
<job name="Engineer" />
|
||||
<job name="Mechanic" />
|
||||
<job name="Captain" />
|
||||
<job name="Security Officer" />
|
||||
<job name="Medical Doctor" />
|
||||
<job name="Assistant" />
|
||||
</jobpreferences>
|
||||
</gameplay>
|
||||
</config>
|
||||
Reference in New Issue
Block a user