(d9829ac) v0.9.4.0

This commit is contained in:
Regalis
2019-10-24 18:05:42 +02:00
parent 9aa12bcac2
commit b39922a074
319 changed files with 12516 additions and 6815 deletions
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using System.Xml;
using System.IO;
using Barotrauma.Extensions;
#if CLIENT
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Tutorials;
@@ -205,7 +206,7 @@ namespace Barotrauma
{
voiceChatVolume = MathHelper.Clamp(value, 0.0f, 1.0f);
#if CLIENT
GameMain.SoundManager?.SetCategoryGainMultiplier("voip", voiceChatVolume * 20.0f, 0);
GameMain.SoundManager?.SetCategoryGainMultiplier("voip", voiceChatVolume * 30.0f, 0);
#endif
}
}
@@ -215,7 +216,7 @@ namespace Barotrauma
get { return microphoneVolume; }
set
{
microphoneVolume = MathHelper.Clamp(value, 0.1f, 5.0f);
microphoneVolume = MathHelper.Clamp(value, 0.2f, 10.0f);
}
}
public string Language
@@ -224,26 +225,45 @@ namespace Barotrauma
set { TextManager.Language = value; }
}
public readonly HashSet<ContentPackage> SelectedContentPackages = new HashSet<ContentPackage>();
public readonly List<ContentPackage> SelectedContentPackages = new List<ContentPackage>();
public void SelectContentPackage(ContentPackage contentPackage)
{
if (!SelectedContentPackages.Contains(contentPackage))
{
SelectedContentPackages.Add(contentPackage);
ContentPackage.SortContentPackages();
}
}
public void DeselectContentPackage(ContentPackage contentPackage)
{
if (SelectedContentPackages.Contains(contentPackage))
{
SelectedContentPackages.Remove(contentPackage);
ContentPackage.SortContentPackages();
}
}
private HashSet<string> selectedContentPackagePaths = new HashSet<string>();
public string MasterServerUrl { get; set; }
public string RemoteContentUrl { get; set; }
public bool AutoCheckUpdates { get; set; }
public bool WasGameUpdated { get; set; }
private string defaultPlayerName;
public string DefaultPlayerName
private string playerName;
public string PlayerName
{
get
{
return defaultPlayerName ?? "";
return string.IsNullOrWhiteSpace(playerName) ? Steam.SteamManager.GetUsername() : playerName;
}
set
{
if (defaultPlayerName != value)
if (playerName != value)
{
defaultPlayerName = value;
playerName = value;
}
}
}
@@ -421,11 +441,11 @@ namespace Barotrauma
GraphicsWidth = 1024;
GraphicsHeight = 768;
MasterServerUrl = "";
SelectedContentPackages.Add(ContentPackage.List.Any() ? ContentPackage.List[0] : new ContentPackage(""));
SelectContentPackage(ContentPackage.List.Any() ? ContentPackage.List[0] : new ContentPackage(""));
jobPreferences = new List<string>();
foreach (JobPrefab job in JobPrefab.List)
foreach (string job in JobPrefab.List.Keys)
{
jobPreferences.Add(job.Identifier);
jobPreferences.Add(job);
}
return;
}
@@ -435,6 +455,7 @@ namespace Barotrauma
SetDefaultBindings(doc, legacy: false);
MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", MasterServerUrl);
RemoteContentUrl = doc.Root.GetAttributeString("remotecontenturl", RemoteContentUrl);
WasGameUpdated = doc.Root.GetAttributeBool("wasgameupdated", WasGameUpdated);
VerboseLogging = doc.Root.GetAttributeBool("verboselogging", VerboseLogging);
SaveDebugConsoleLogs = doc.Root.GetAttributeBool("savedebugconsolelogs", SaveDebugConsoleLogs);
@@ -465,6 +486,7 @@ namespace Barotrauma
doc.Root.Add(
new XAttribute("language", TextManager.Language),
new XAttribute("masterserverurl", MasterServerUrl),
new XAttribute("remotecontenturl", RemoteContentUrl),
new XAttribute("autocheckupdates", AutoCheckUpdates),
new XAttribute("musicvolume", musicVolume),
new XAttribute("soundvolume", soundVolume),
@@ -556,7 +578,7 @@ namespace Barotrauma
doc.Root.Add(gameplay);
var playerElement = new XElement("player",
new XAttribute("name", defaultPlayerName ?? ""),
new XAttribute("name", playerName ?? ""),
new XAttribute("headindex", CharacterHeadIndex),
new XAttribute("gender", CharacterGender),
new XAttribute("race", CharacterRace),
@@ -653,6 +675,7 @@ namespace Barotrauma
{
var missingPackagePaths = new List<string>();
var incompatiblePackages = new List<ContentPackage>();
var invalidPackages = new List<ContentPackage>();
SelectedContentPackages.Clear();
foreach (string path in contentPackagePaths)
{
@@ -664,24 +687,35 @@ namespace Barotrauma
}
else if (!matchingContentPackage.IsCompatible())
{
DebugConsole.NewMessage(
$"Content package \"{matchingContentPackage.Name}\" is not compatible with this version of Barotrauma (game version: {GameMain.Version}, content package version: {matchingContentPackage.GameVersion})",
Color.Red);
incompatiblePackages.Add(matchingContentPackage);
}
else if (!matchingContentPackage.CheckValidity(out List<string> errorMessages))
{
DebugConsole.NewMessage(
$"Content package \"{matchingContentPackage.Name}\" is invalid: " + string.Join(", ", errorMessages),
Color.Red);
invalidPackages.Add(matchingContentPackage);
//never consider the vanilla content package invalid
//(otherwise a player might brick the game by, for example, deleting vanilla content files)
if (matchingContentPackage == GameMain.VanillaContent)
{
SelectedContentPackages.Add(matchingContentPackage);
}
}
else
{
SelectedContentPackages.Add(matchingContentPackage);
}
}
ContentPackage.SortContentPackages();
TextManager.LoadTextPacks(SelectedContentPackages);
foreach (ContentPackage contentPackage in SelectedContentPackages)
{
bool packageOk = contentPackage.VerifyFiles(out List<string> errorMessages);
if (!packageOk)
{
DebugConsole.ThrowError("Error in content package \"" + contentPackage.Name + "\":\n" + string.Join("\n", errorMessages));
continue;
}
foreach (ContentFile file in contentPackage.Files)
{
ToolBox.IsProperFilenameCase(file.Path);
@@ -691,7 +725,7 @@ namespace Barotrauma
EnsureCoreContentPackageSelected();
//save to get rid of the invalid selected packages in the config file
if (missingPackagePaths.Count > 0 || incompatiblePackages.Count > 0) { SaveNewPlayerConfig(); }
if (missingPackagePaths.Count > 0 || incompatiblePackages.Count > 0 || invalidPackages.Count > 0) { SaveNewPlayerConfig(); }
//display error messages after all content packages have been loaded
//to make sure the package that contains text files has been loaded before we attempt to use TextManager
@@ -699,10 +733,15 @@ namespace Barotrauma
{
DebugConsole.ThrowError(TextManager.GetWithVariable("ContentPackageNotFound", "[packagepath]", missingPackagePath));
}
foreach (ContentPackage invalidPackage in invalidPackages)
{
DebugConsole.ThrowError(TextManager.GetWithVariable("InvalidContentPackage", "[packagename]", invalidPackage.Name), createMessageBox: true);
}
foreach (ContentPackage incompatiblePackage in incompatiblePackages)
{
DebugConsole.ThrowError(TextManager.GetWithVariables(incompatiblePackage.GameVersion <= new Version(0, 0, 0, 0) ? "IncompatibleContentPackageUnknownVersion" : "IncompatibleContentPackage",
new string[3] { "[packagename]", "[packageversion]", "[gameversion]" }, new string[3] { incompatiblePackage.Name, incompatiblePackage.GameVersion.ToString(), GameMain.Version.ToString() }));
new string[3] { "[packagename]", "[packageversion]", "[gameversion]" }, new string[3] { incompatiblePackage.Name, incompatiblePackage.GameVersion.ToString(), GameMain.Version.ToString() }),
createMessageBox: true);
}
}
@@ -712,14 +751,14 @@ namespace Barotrauma
if (GameMain.VanillaContent != null)
{
SelectedContentPackages.Add(GameMain.VanillaContent);
SelectContentPackage(GameMain.VanillaContent);
}
else
{
var availablePackage = ContentPackage.List.FirstOrDefault(cp => cp.IsCompatible() && cp.CorePackage);
if (availablePackage != null)
{
SelectedContentPackages.Add(availablePackage);
SelectContentPackage(availablePackage);
}
}
}
@@ -837,7 +876,9 @@ namespace Barotrauma
doc.Root.Add(keyMappingElement);
for (int i = 0; i < keyMapping.Length; i++)
{
if (keyMapping[i].MouseButton == null)
var key = keyMapping[i];
if (key == null) { continue; }
if (key.MouseButton == null)
{
keyMappingElement.Add(new XAttribute(((InputType)i).ToString(), keyMapping[i].Key));
}
@@ -857,7 +898,7 @@ namespace Barotrauma
doc.Root.Add(gameplay);
var playerElement = new XElement("player",
new XAttribute("name", defaultPlayerName ?? ""),
new XAttribute("name", playerName ?? ""),
new XAttribute("headindex", CharacterHeadIndex),
new XAttribute("gender", CharacterGender),
new XAttribute("race", CharacterRace),
@@ -945,7 +986,7 @@ namespace Barotrauma
XElement playerElement = doc.Root.Element("player");
if (playerElement != null)
{
defaultPlayerName = playerElement.GetAttributeString("name", defaultPlayerName);
playerName = playerElement.GetAttributeString("name", playerName);
CharacterHeadIndex = playerElement.GetAttributeInt("headindex", CharacterHeadIndex);
if (Enum.TryParse(playerElement.GetAttributeString("gender", "none"), true, out Gender g))
{
@@ -1041,7 +1082,7 @@ namespace Barotrauma
switch (subElement.Name.ToString().ToLowerInvariant())
{
case "contentpackage":
string path = System.IO.Path.GetFullPath(subElement.GetAttributeString("path", ""));
string path = Path.GetFullPath(subElement.GetAttributeString("path", ""));
selectedContentPackagePaths.Add(path);
break;
}
@@ -1102,7 +1143,7 @@ namespace Barotrauma
VoiceSetting = VoiceMode.Disabled;
VoiceCaptureDevice = null;
NoiseGateThreshold = -45;
windowMode = WindowMode.Fullscreen;
windowMode = WindowMode.BorderlessWindowed;
losMode = LosMode.Transparent;
useSteamMatchmaking = true;
requireSteamAuthentication = true;
@@ -1123,9 +1164,9 @@ namespace Barotrauma
DynamicRangeCompressionEnabled = true;
VoipAttenuationEnabled = true;
voiceChatVolume = 0.5f;
microphoneVolume = 1.0f;
microphoneVolume = 5.0f;
AutoCheckUpdates = true;
defaultPlayerName = string.Empty;
playerName = string.Empty;
HUDScale = 1;
InventoryScale = 1;
AutoUpdateWorkshopItems = true;