Merge branch 'master' into dedicated-server

# Conflicts:
#	BarotraumaClient/Source/GameSettings.cs
#	BarotraumaClient/Source/Screens/NetLobbyScreen.cs
This commit is contained in:
juanjp600
2017-06-23 10:21:02 -03:00
16 changed files with 288 additions and 92 deletions
+5
View File
@@ -218,6 +218,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;
+58 -8
View File
@@ -18,7 +18,17 @@ namespace Barotrauma
{
private GUIFrame settingsFrame;
private GUIButton applyButton;
private float soundVolume, musicVolume;
private WindowMode windowMode;
public List<string> jobNamePreferences;
private KeyOrMouse[] keyMapping;
private bool unsavedSettings;
public GUIFrame SettingsFrame
{
get
@@ -28,12 +38,6 @@ namespace Barotrauma
}
}
private float soundVolume, musicVolume;
private WindowMode windowMode;
private KeyOrMouse[] keyMapping;
public KeyOrMouse KeyBind(InputType inputType)
{
return keyMapping[(int)inputType];
@@ -53,9 +57,20 @@ namespace Barotrauma
get { return windowMode; }
set { windowMode = value; }
}
public List<string> JobNamePreferences
{
get { return jobNamePreferences; }
set
{
// Begin saving coroutine. Remove any existing save coroutines if one is running.
if (CoroutineManager.IsCoroutineRunning("saveCoroutine")) { CoroutineManager.StopCoroutines("saveCoroutine"); }
CoroutineManager.StartCoroutine(ApplyUnsavedChanges(), "saveCoroutine");
private bool unsavedSettings;
jobNamePreferences = value;
}
}
public bool UnsavedSettings
{
get
@@ -65,6 +80,7 @@ namespace Barotrauma
private set
{
unsavedSettings = value;
if (applyButton != null)
{
//applyButton.Selected = unsavedSettings;
@@ -100,7 +116,16 @@ namespace Barotrauma
{
GraphicsWidth = 1024;
GraphicsHeight = 678;
MasterServerUrl = "";
SelectedContentPackage = ContentPackage.list.Any() ? ContentPackage.list[0] : new ContentPackage("");
JobNamePreferences = new List<string>();
foreach (JobPrefab job in JobPrefab.List)
{
JobNamePreferences.Add(job.Name);
}
return;
}
@@ -170,6 +195,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;
}
}
@@ -253,6 +285,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);
}
@@ -462,6 +505,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");
@@ -527,11 +527,17 @@ 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.Find(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);
GameMain.GraphicsWidth<1000 ? GUI.SmallFont : GUI.Font);
jobText.UserData = job;
GUIButton infoButton = new GUIButton(new Rectangle(0, 2, 15, 15), "?", "", jobText);
@@ -1165,6 +1171,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;
@@ -1174,10 +1182,13 @@ namespace Barotrauma
listBox.children[i].Color = color;
listBox.children[i].HoverColor = color;
listBox.children[i].SelectedColor = color;
(listBox.children[i] as GUITextBlock).Text = (i+1) + ". " + (listBox.children[i].UserData as JobPrefab).Name;
(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)