(0b650589c) Merge branch 'dev' of github.com:Regalis11/Barotrauma-development into dev

This commit is contained in:
Joonas Rikkonen
2019-05-18 21:51:29 +03:00
parent 50f379086c
commit dfa584c2c5
8 changed files with 230 additions and 104 deletions

View File

@@ -287,13 +287,7 @@ namespace Barotrauma
{
if (GameSettings.ShowUserStatisticsPrompt)
{
//TODO: translate
var userStatsPrompt = new GUIMessageBox(
"Do you want to help us make Barotrauma better?",
"Do you allow Barotrauma to send usage statistics and error reports to the developers? The data is anonymous, " +
"does not contain any personal information and is only used to help us diagnose issues and improve Barotrauma.",
new string[] { "Yes", "No" });
userStatsPrompt.Buttons[0].OnClicked += (btn, userdata) =>
if (TextManager.ContainsTag("statisticspromptheader") && TextManager.ContainsTag("statisticsprompttext"))
{
var userStatsPrompt = new GUIMessageBox(
TextManager.Get("statisticspromptheader"),
@@ -324,17 +318,7 @@ namespace Barotrauma
GameSettings.SendUserStatistics = true;
GameAnalyticsManager.Init();
Config.SaveNewPlayerConfig();
return true;
};
userStatsPrompt.Buttons[0].OnClicked += userStatsPrompt.Close;
userStatsPrompt.Buttons[1].OnClicked += (btn, userdata) =>
{
GameSettings.ShowUserStatisticsPrompt = false;
GameSettings.SendUserStatistics = false;
Config.SaveNewPlayerConfig();
return true;
};
userStatsPrompt.Buttons[1].OnClicked += userStatsPrompt.Close;
}
}
else if (GameSettings.SendUserStatistics)
{
@@ -399,10 +383,10 @@ namespace Barotrauma
DebugConsole.Log("Selected content packages: " + string.Join(", ", SelectedPackages.Select(cp => cp.Name)));
}
#if DEBUG
/*#if DEBUG
GameSettings.ShowUserStatisticsPrompt = false;
GameSettings.SendUserStatistics = false;
#endif
#endif*/
InitUserStats();

View File

@@ -477,7 +477,7 @@ namespace Barotrauma
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice)) VoiceCaptureDevice = deviceNames[0];
#if (!OSX)
var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), VoiceCaptureDevice, deviceNames.Count);
var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TextManager.EnsureUTF8(VoiceCaptureDevice), deviceNames.Count);
foreach (string name in deviceNames)
{
deviceList.AddItem(TextManager.EnsureUTF8(name), name);
@@ -492,7 +492,7 @@ namespace Barotrauma
};
#else
var suavemente = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform),
TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), VoiceCaptureDevice))
TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TextManager.EnsureUTF8(VoiceCaptureDevice)))
{
ToolTip = TextManager.Get("CurrentDeviceToolTip.OSX"),
TextAlignment = Alignment.CenterX
@@ -507,7 +507,7 @@ namespace Barotrauma
if (VoiceCaptureDevice == deviceNames[0]) return true;
VoipCapture.ChangeCaptureDevice(deviceNames[0]);
suavemente.Text = TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), VoiceCaptureDevice);
suavemente.Text = TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TextManager.EnsureUTF8(VoiceCaptureDevice));
suavemente.Flash(Color.Blue);
return true;

View File

@@ -624,10 +624,22 @@ namespace Barotrauma
if (mouseOn && PlayerInput.LeftButtonClicked() && !messageBoxOpen)
{
//TODO: translate or replace
var messageBox = new GUIMessageBox("Mysteries lie ahead...", "This area is unreachable in this version of Barotrauma. Please wait for future updates!");
messageBoxOpen = true;
CoroutineManager.StartCoroutine(WaitForMessageBoxClosed(messageBox));
if (TextManager.ContainsTag("centerarealockedheader") && TextManager.ContainsTag("centerarealockedtext") )
{
var messageBox = new GUIMessageBox(
TextManager.Get("centerarealockedheader"),
TextManager.Get("centerarealockedtext"));
messageBoxOpen = true;
CoroutineManager.StartCoroutine(WaitForMessageBoxClosed(messageBox));
}
else
{
//if the message cannot be shown in the selected language,
//show the campaign roadmap (which mentions the center location not being reachable)
var messageBox = new GUIMessageBox(TextManager.Get("CampaignRoadMapTitle"), TextManager.Get("CampaignRoadMapText"));
messageBoxOpen = true;
CoroutineManager.StartCoroutine(WaitForMessageBoxClosed(messageBox));
}
}
}

View File

@@ -435,6 +435,8 @@ namespace Barotrauma
saveTime = time.ToString();
}
string mapseed = doc.Root.GetAttributeString("mapseed", "unknown");
var saveFileFrame = new GUIFrame(new RectTransform(new Vector2(0.45f, 0.6f), loadGameContainer.RectTransform, Anchor.TopRight)
{
RelativeOffset = new Vector2(0.0f, 0.1f)

View File

@@ -74,15 +74,14 @@ namespace Barotrauma
outpostBtn.TextBlock.Font = GUI.LargeFont;
outpostBtn.TextBlock.AutoScale = true;
var tabButtonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.4f, 0.3f), topPanelContent.RectTransform, Anchor.BottomLeft), isHorizontal: true);
var tabButtonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.4f, 0.4f), topPanelContent.RectTransform, Anchor.BottomLeft), isHorizontal: true);
int i = 0;
var tabValues = Enum.GetValues(typeof(Tab));
foreach (Tab tab in tabValues)
{
var tabButton = new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), tabButtonContainer.RectTransform),
TextManager.Get(tab.ToString()),
textAlignment: Alignment.Center,
"",
style: i == 0 ? "GUISlopedTabButtonLeft" : (i == tabValues.Length - 1 ? "GUISlopedTabButtonRight" : "GUISlopedTabButtonMid"))
{
UserData = tab,
@@ -93,11 +92,32 @@ namespace Barotrauma
tabButton.RectTransform.MaxSize = new Point(
(int)(tabButton.Rect.Height * (buttonSprite.Sprite.size.X / buttonSprite.Sprite.size.Y)), int.MaxValue);
//the text needs to be positioned differently in the buttons at the edges due to the "slopes" in the button
if (i == 0 || i == tabValues.Length - 1)
{
new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.9f), tabButton.RectTransform, i == 0 ? Anchor.CenterLeft : Anchor.CenterRight) { RelativeOffset = new Vector2(0.05f, 0.0f) },
TextManager.Get(tab.ToString()), textColor: tabButton.TextColor, font: GUI.LargeFont, textAlignment: Alignment.Center, style: null)
{
UserData = "buttontext"
};
}
else
{
new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.9f), tabButton.RectTransform, Anchor.Center),
TextManager.Get(tab.ToString()), textColor: tabButton.TextColor, font: GUI.LargeFont, textAlignment: Alignment.Center, style: null)
{
UserData = "buttontext"
};
}
tabButtons.Add(tabButton);
tabButton.Font = GUI.LargeFont;
i++;
}
GUITextBlock.AutoScaleAndNormalize(tabButtons.Select(t => t.TextBlock));
GUITextBlock.AutoScaleAndNormalize(tabButtons.Select(t => t.GetChildByUserData("buttontext") as GUITextBlock));
tabButtons.FirstOrDefault().RectTransform.SizeChanged += () =>
{
GUITextBlock.AutoScaleAndNormalize(tabButtons.Select(t => t.GetChildByUserData("buttontext") as GUITextBlock));
};
// crew tab -------------------------------------------------------------------------

View File

@@ -83,11 +83,15 @@ namespace Barotrauma
Commonness = element.GetAttributeInt("commonness", 1);
SuccessMessage = TextManager.Get("MissionSuccess." + Identifier, true) ?? element.GetAttributeString("successmessage", "Mission completed successfully");
FailureMessage =
TextManager.Get("MissionFailure." + Identifier, true) ??
element.GetAttributeString("failuremessage", null) ??
TextManager.Get("missionfailed", returnNull: true) ??
"";
FailureMessage = TextManager.Get("MissionFailure." + Identifier, true) ?? "";
if (string.IsNullOrEmpty(FailureMessage) && TextManager.ContainsTag("missionfailed"))
{
FailureMessage = TextManager.Get("missionfailed", returnNull: true) ?? "";
}
if (string.IsNullOrEmpty(FailureMessage) && GameMain.Config.Language == "English")
{
FailureMessage = element.GetAttributeString("failuremessage", "");
}
SonarLabel = TextManager.Get("MissionSonarLabel." + Identifier, true) ?? element.GetAttributeString("sonarlabel", "");

View File

@@ -337,6 +337,79 @@ namespace Barotrauma
keyMapping[(int)InputType.SelectNextCharacter] = new KeyOrMouse(Keys.Z);
keyMapping[(int)InputType.SelectPreviousCharacter] = new KeyOrMouse(Keys.X);
}
}
public void CheckBindings(bool useDefaults)
{
foreach (InputType inputType in Enum.GetValues(typeof(InputType)))
{
var binding = keyMapping[(int)inputType];
if (binding == null)
{
switch (inputType)
{
case InputType.Deselect:
if (useDefaults)
{
binding = new KeyOrMouse(1);
}
else
{
// Legacy support
var selectKey = keyMapping[(int)InputType.Select];
if (selectKey != null && selectKey.Key != Keys.None)
{
binding = new KeyOrMouse(selectKey.Key);
}
}
break;
case InputType.Shoot:
if (useDefaults)
{
binding = new KeyOrMouse(0);
}
else
{
// Legacy support
var useKey = keyMapping[(int)InputType.Use];
if (useKey != null && useKey.MouseButton.HasValue)
{
binding = new KeyOrMouse(useKey.MouseButton.Value);
}
}
break;
default:
break;
}
if (binding == null)
{
DebugConsole.ThrowError("Key binding for the input type \"" + inputType + " not set!");
binding = new KeyOrMouse(Keys.D1);
}
keyMapping[(int)inputType] = binding;
}
}
}
#region Load DefaultConfig
private void LoadDefaultConfig(bool setLanguage = true)
{
XDocument doc = XMLExtensions.TryLoadXml(savePath);
if (setLanguage || string.IsNullOrEmpty(Language))
{
Language = doc.Root.GetAttributeString("language", "English");
}
MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", "");
AutoCheckUpdates = doc.Root.GetAttributeBool("autocheckupdates", true);
WasGameUpdated = doc.Root.GetAttributeBool("wasgameupdated", false);
VerboseLogging = doc.Root.GetAttributeBool("verboselogging", false);
SaveDebugConsoleLogs = doc.Root.GetAttributeBool("savedebugconsolelogs", false);
QuickStartSubmarineName = doc.Root.GetAttributeString("quickstartsub", "");
if (legacy)
{
@@ -605,6 +678,54 @@ namespace Barotrauma
}
#endregion
#region Save DefaultConfig
private void SaveNewDefaultConfig()
{
XDocument doc = new XDocument();
if (doc.Root == null)
{
doc.Add(new XElement("config"));
}
doc.Root.Add(
new XAttribute("language", TextManager.Language),
new XAttribute("masterserverurl", MasterServerUrl),
new XAttribute("autocheckupdates", AutoCheckUpdates),
new XAttribute("musicvolume", musicVolume),
new XAttribute("soundvolume", soundVolume),
new XAttribute("voicechatvolume", voiceChatVolume),
new XAttribute("verboselogging", VerboseLogging),
new XAttribute("savedebugconsolelogs", SaveDebugConsoleLogs),
new XAttribute("enablesplashscreen", EnableSplashScreen),
new XAttribute("usesteammatchmaking", useSteamMatchmaking),
new XAttribute("quickstartsub", QuickStartSubmarineName),
new XAttribute("requiresteamauthentication", requireSteamAuthentication),
new XAttribute("aimassistamount", aimAssistAmount));
if (!ShowUserStatisticsPrompt)
{
doc.Root.Add(new XAttribute("senduserstatistics", sendUserStatistics));
}
if (WasGameUpdated)
{
doc.Root.Add(new XAttribute("wasgameupdated", true));
}
if (!SelectedContentPackages.Any())
{
var availablePackage = ContentPackage.List.FirstOrDefault(cp => cp.IsCompatible() && cp.CorePackage);
if (availablePackage != null)
{
SelectedContentPackages.Add(availablePackage);
}
}
//save to get rid of the invalid selected packages in the config file
if (missingPackagePaths.Count > 0 || incompatiblePackages.Count > 0) { SaveNewPlayerConfig(); }
}
#endregion
#region Save DefaultConfig
private void SaveNewDefaultConfig()
{
@@ -750,6 +871,7 @@ namespace Barotrauma
if (!fileFound)
{
ShowLanguageSelectionPrompt = true;
ShowUserStatisticsPrompt = true;
SaveNewPlayerConfig();
}
}
@@ -820,58 +942,6 @@ namespace Barotrauma
{
VoiceSetting = voiceSetting;
}
foreach (ContentFile file in contentPackage.Files)
{
ToolBox.IsProperFilenameCase(file.Path);
}
}
if (!SelectedContentPackages.Any())
{
var availablePackage = ContentPackage.List.FirstOrDefault(cp => cp.IsCompatible() && cp.CorePackage);
if (availablePackage != null)
{
SelectedContentPackages.Add(availablePackage);
}
}
//save to get rid of the invalid selected packages in the config file
if (missingPackagePaths.Count > 0 || incompatiblePackages.Count > 0) { SaveNewPlayerConfig(); }
}
#endregion
#region Save DefaultConfig
private void SaveNewDefaultConfig()
{
XDocument doc = new XDocument();
if (doc.Root == null)
{
doc.Add(new XElement("config"));
}
doc.Root.Add(
new XAttribute("language", TextManager.Language),
new XAttribute("masterserverurl", MasterServerUrl),
new XAttribute("autocheckupdates", AutoCheckUpdates),
new XAttribute("musicvolume", musicVolume),
new XAttribute("soundvolume", soundVolume),
new XAttribute("voicechatvolume", voiceChatVolume),
new XAttribute("verboselogging", VerboseLogging),
new XAttribute("savedebugconsolelogs", SaveDebugConsoleLogs),
new XAttribute("enablesplashscreen", EnableSplashScreen),
new XAttribute("usesteammatchmaking", useSteamMatchmaking),
new XAttribute("quickstartsub", QuickStartSubmarineName),
new XAttribute("requiresteamauthentication", requireSteamAuthentication),
new XAttribute("aimassistamount", aimAssistAmount));
if (!ShowUserStatisticsPrompt)
{
doc.Root.Add(new XAttribute("senduserstatistics", sendUserStatistics));
}
if (WasGameUpdated)
{
doc.Root.Add(new XAttribute("wasgameupdated", true));
}
useSteamMatchmaking = doc.Root.GetAttributeBool("usesteammatchmaking", useSteamMatchmaking);
@@ -940,7 +1010,22 @@ namespace Barotrauma
foreach (XElement subElement in doc.Root.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
gSettings = new XElement("graphicssettings");
doc.Root.Add(gSettings);
}
gSettings.ReplaceAttributes(
new XAttribute("particlelimit", ParticleLimit),
new XAttribute("lightmapscale", LightMapScale),
new XAttribute("specularity", SpecularityEnabled),
new XAttribute("chromaticaberration", ChromaticAberrationEnabled),
new XAttribute("losmode", LosMode),
new XAttribute("hudscale", HUDScale),
new XAttribute("inventoryscale", InventoryScale));
foreach (ContentPackage contentPackage in SelectedContentPackages)
{
if (contentPackage.Path.Contains(vanillaContentPackagePath))
{
case "contentpackage":
string path = System.IO.Path.GetFullPath(subElement.GetAttributeString("path", ""));
@@ -1054,6 +1139,7 @@ namespace Barotrauma
new XAttribute("autocheckupdates", AutoCheckUpdates),
new XAttribute("musicvolume", musicVolume),
new XAttribute("soundvolume", soundVolume),
new XAttribute("voicechatvolume", voiceChatVolume),
new XAttribute("verboselogging", VerboseLogging),
new XAttribute("savedebugconsolelogs", SaveDebugConsoleLogs),
new XAttribute("enablesplashscreen", EnableSplashScreen),

View File

@@ -119,23 +119,40 @@ namespace Barotrauma
}
}
if (GameMain.GameSession != null && Character.Controlled != null)
if (GameMain.GameSession != null)
{
if (Character.Controlled.HasEquippedItem("clownmask") &&
Character.Controlled.HasEquippedItem("clowncostume"))
#if CLIENT
if (Character.Controlled != null) { CheckMidRoundAchievements(Character.Controlled); }
#else
foreach (Client client in GameMain.Server.ConnectedClients)
{
UnlockAchievement(Character.Controlled, "clowncostume");
}
if (Submarine.MainSub != null && Character.Controlled.Submarine == null)
{
float dist = 500 / Physics.DisplayToRealWorldRatio;
if (Vector2.DistanceSquared(Character.Controlled.WorldPosition, Submarine.MainSub.WorldPosition) >
dist * dist)
if (client.Character != null)
{
UnlockAchievement(Character.Controlled, "crewaway");
CheckMidRoundAchievements(client.Character);
}
}
}
#endif
}
}
private static void CheckMidRoundAchievements(Character c)
{
if (c == null || c.Removed) { return; }
if (c.HasEquippedItem("clownmask") &&
c.HasEquippedItem("clowncostume"))
{
UnlockAchievement(c, "clowncostume");
}
if (Submarine.MainSub != null && c.Submarine == null)
{
float dist = 500 / Physics.DisplayToRealWorldRatio;
if (Vector2.DistanceSquared(c.WorldPosition, Submarine.MainSub.WorldPosition) >
dist * dist)
{
UnlockAchievement(c, "crewaway");
}
}
}
@@ -214,7 +231,8 @@ namespace Barotrauma
}
if (character.HasEquippedItem("clownmask") &&
character.HasEquippedItem("clowncostume"))
character.HasEquippedItem("clowncostume") &&
causeOfDeath.Killer != character)
{
UnlockAchievement(causeOfDeath.Killer, "killclown");
}