(9801d8289) Added: Handling of error cases when video is not found
This commit is contained in:
@@ -935,10 +935,63 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
element.Value = lines[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
doc.Save(destinationPath);
|
||||||
|
},
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/"));
|
||||||
|
return new string[][]
|
||||||
|
{
|
||||||
|
files.Where(f => Path.GetExtension(f)==".txt").ToArray(),
|
||||||
|
files.Where(f => Path.GetExtension(f)==".xml").ToArray()
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
|
||||||
|
commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) =>
|
||||||
|
{
|
||||||
|
if (args.Length < 2) return;
|
||||||
|
string sourcePath = args[0];
|
||||||
|
string destinationPath = args[1];
|
||||||
|
|
||||||
|
var sourceDoc = XMLExtensions.TryLoadXml(sourcePath);
|
||||||
|
var destinationDoc = XMLExtensions.TryLoadXml(destinationPath);
|
||||||
|
|
||||||
|
XElement destinationElement = destinationDoc.Root.Elements().First();
|
||||||
|
foreach (XElement element in sourceDoc.Root.Elements())
|
||||||
|
{
|
||||||
|
if (destinationDoc.Root.Element(element.Name) == null)
|
||||||
|
{
|
||||||
|
element.Value = "!!!!!!!!!!!!!" + element.Value;
|
||||||
|
destinationElement.AddAfterSelf(element);
|
||||||
|
}
|
||||||
XNode nextNode = destinationElement.NextNode;
|
XNode nextNode = destinationElement.NextNode;
|
||||||
while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode;
|
while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode;
|
||||||
destinationElement = nextNode as XElement;
|
destinationElement = nextNode as XElement;
|
||||||
}
|
}
|
||||||
|
destinationDoc.Save(destinationPath);
|
||||||
|
},
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray();
|
||||||
|
return new string[][]
|
||||||
|
{
|
||||||
|
files,
|
||||||
|
files
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
|
||||||
|
commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) =>
|
||||||
|
{
|
||||||
|
string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt";
|
||||||
|
List<string> lines = new List<string>();
|
||||||
|
foreach (MapEntityPrefab me in MapEntityPrefab.List)
|
||||||
|
{
|
||||||
|
lines.Add("<EntityName." + me.Identifier + ">" + me.Name + "</" + me.Identifier + ".Name>");
|
||||||
|
lines.Add("<EntityDescription." + me.Identifier + ">" + me.Description + "</" + me.Identifier + ".Description>");
|
||||||
|
}
|
||||||
}, isCheat: false));
|
}, isCheat: false));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1064,6 +1117,24 @@ namespace Barotrauma
|
|||||||
if (args.Length == 0) return;
|
if (args.Length == 0) return;
|
||||||
LocalizationCSVtoXML.Convert(args[0]);
|
LocalizationCSVtoXML.Convert(args[0]);
|
||||||
}));
|
}));
|
||||||
|
#if DEBUG
|
||||||
|
commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) =>
|
||||||
|
{
|
||||||
|
if (args.Length != 1) return;
|
||||||
|
TextManager.CheckForDuplicates(args[0]);
|
||||||
|
}));
|
||||||
|
|
||||||
|
commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) =>
|
||||||
|
{
|
||||||
|
TextManager.WriteToCSV();
|
||||||
|
NPCConversation.WriteToCSV();
|
||||||
|
}));
|
||||||
|
|
||||||
|
commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) =>
|
||||||
|
{
|
||||||
|
if (args.Length == 0) return;
|
||||||
|
LocalizationCSVtoXML.Convert(args[0]);
|
||||||
|
}));
|
||||||
|
|
||||||
commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) =>
|
commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Barotrauma.Media;
|
using Barotrauma.Media;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -112,7 +113,7 @@ namespace Barotrauma
|
|||||||
currentVideo = null;
|
currentVideo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool OKButtonClicked(GUIButton button, object userData)
|
private bool DisposeVideo(GUIButton button, object userData)
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
callbackOnStop?.Invoke();
|
callbackOnStop?.Invoke();
|
||||||
@@ -127,6 +128,15 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void LoadContent(string contentPath, XElement videoElement, string contentId, bool startPlayback, bool hasButton, Action callback = null)
|
public void LoadContent(string contentPath, XElement videoElement, string contentId, bool startPlayback, bool hasButton, Action callback = null)
|
||||||
{
|
{
|
||||||
|
callbackOnStop = callback;
|
||||||
|
|
||||||
|
if (!File.Exists(contentPath))
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("No video found at: " + contentPath);
|
||||||
|
DisposeVideo(null, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentVideo != null)
|
if (currentVideo != null)
|
||||||
{
|
{
|
||||||
currentVideo.Dispose();
|
currentVideo.Dispose();
|
||||||
@@ -165,14 +175,12 @@ namespace Barotrauma
|
|||||||
title.Text = TextManager.Get(contentId);
|
title.Text = TextManager.Get(contentId);
|
||||||
title.RectTransform.NonScaledSize = new Point(resolution.X, 30);
|
title.RectTransform.NonScaledSize = new Point(resolution.X, 30);
|
||||||
|
|
||||||
callbackOnStop = callback;
|
|
||||||
|
|
||||||
if (hasButton)
|
if (hasButton)
|
||||||
{
|
{
|
||||||
var okButton = new GUIButton(new RectTransform(new Point(160, 50), videoFrame.RectTransform, Anchor.BottomCenter, Pivot.TopCenter) { AbsoluteOffset = new Point(0, -10) },
|
var okButton = new GUIButton(new RectTransform(new Point(160, 50), videoFrame.RectTransform, Anchor.BottomCenter, Pivot.TopCenter) { AbsoluteOffset = new Point(0, -10) },
|
||||||
TextManager.Get("OK"))
|
TextManager.Get("OK"))
|
||||||
{
|
{
|
||||||
OnClicked = OKButtonClicked
|
OnClicked = DisposeVideo
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,6 +193,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//video = new Video(GameMain.Instance.GraphicsDevice, GameMain.SoundManager, "Content/splashscreen.mp4", 1280, 720);
|
||||||
video = new Video(GameMain.Instance.GraphicsDevice, GameMain.SoundManager, contentPath, (uint)resolution.X, (uint)resolution.Y);
|
video = new Video(GameMain.Instance.GraphicsDevice, GameMain.SoundManager, contentPath, (uint)resolution.X, (uint)resolution.Y);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@@ -1374,6 +1374,9 @@ namespace Barotrauma.Networking
|
|||||||
case ServerNetObject.CLIENT_LIST:
|
case ServerNetObject.CLIENT_LIST:
|
||||||
ReadClientList(inc);
|
ReadClientList(inc);
|
||||||
break;
|
break;
|
||||||
|
case ServerNetObject.CLIENT_LIST:
|
||||||
|
ReadClientList(inc);
|
||||||
|
break;
|
||||||
case ServerNetObject.CHAT_MESSAGE:
|
case ServerNetObject.CHAT_MESSAGE:
|
||||||
ChatMessage.ClientRead(inc);
|
ChatMessage.ClientRead(inc);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1186,6 +1186,19 @@ namespace Barotrauma
|
|||||||
return (int)Math.Ceiling(ConvertUnits.ToDisplayUnits(colliderSize) / Structure.WallSectionSize);
|
return (int)Math.Ceiling(ConvertUnits.ToDisplayUnits(colliderSize) / Structure.WallSectionSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected override void OnStateChanged(AIState from, AIState to)
|
||||||
|
{
|
||||||
|
latchOntoAI?.DeattachFromBody();
|
||||||
|
Character.AnimController.ReleaseStuckLimbs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetMinimumPassableHoleCount()
|
||||||
|
{
|
||||||
|
return (int)Math.Ceiling(ConvertUnits.ToDisplayUnits(colliderSize) / Structure.WallSectionSize);
|
||||||
|
}
|
||||||
|
|
||||||
private bool CanPassThroughHole(Structure wall, int sectionIndex)
|
private bool CanPassThroughHole(Structure wall, int sectionIndex)
|
||||||
{
|
{
|
||||||
int requiredHoleCount = GetMinimumPassableHoleCount();
|
int requiredHoleCount = GetMinimumPassableHoleCount();
|
||||||
|
|||||||
@@ -1041,6 +1041,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
CheckValidity();
|
CheckValidity();
|
||||||
|
|
||||||
|
CheckValidity();
|
||||||
|
|
||||||
UpdateNetPlayerPosition(deltaTime);
|
UpdateNetPlayerPosition(deltaTime);
|
||||||
CheckDistFromCollider();
|
CheckDistFromCollider();
|
||||||
UpdateCollisionCategories();
|
UpdateCollisionCategories();
|
||||||
@@ -1352,17 +1354,6 @@ namespace Barotrauma
|
|||||||
SetInitialLimbPositions();
|
SetInitialLimbPositions();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UpdateProjSpecific(deltaTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckValidity()
|
|
||||||
{
|
|
||||||
CheckValidity(Collider);
|
|
||||||
foreach (Limb limb in limbs)
|
|
||||||
{
|
|
||||||
if (limb.body == null || !limb.body.Enabled) { continue; }
|
|
||||||
CheckValidity(limb.body);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void UpdateProjSpecific(float deltaTime);
|
partial void UpdateProjSpecific(float deltaTime);
|
||||||
|
|||||||
@@ -188,6 +188,9 @@ namespace Barotrauma.Items.Components
|
|||||||
if (nodes.Count > 0 && nodes[0] == nodePos) break;
|
if (nodes.Count > 0 && nodes[0] == nodePos) break;
|
||||||
if (nodes.Count > 1 && nodes[nodes.Count - 1] == nodePos) break;
|
if (nodes.Count > 1 && nodes[nodes.Count - 1] == nodePos) break;
|
||||||
|
|
||||||
|
if (nodes.Count > 0 && nodes[0] == nodePos) break;
|
||||||
|
if (nodes.Count > 1 && nodes[nodes.Count - 1] == nodePos) break;
|
||||||
|
|
||||||
//make sure we place the node at the correct end of the wire (the end that's closest to the new node pos)
|
//make sure we place the node at the correct end of the wire (the end that's closest to the new node pos)
|
||||||
int newNodeIndex = 0;
|
int newNodeIndex = 0;
|
||||||
if (nodes.Count > 1)
|
if (nodes.Count > 1)
|
||||||
|
|||||||
@@ -192,6 +192,9 @@ namespace Barotrauma
|
|||||||
Hull hull = Hull.FindHull(ConvertUnits.ToDisplayUnits(explosionPos), null, false);
|
Hull hull = Hull.FindHull(ConvertUnits.ToDisplayUnits(explosionPos), null, false);
|
||||||
bool underWater = hull == null || explosionPos.Y < hull.Surface;
|
bool underWater = hull == null || explosionPos.Y < hull.Surface;
|
||||||
|
|
||||||
|
Hull hull = Hull.FindHull(ConvertUnits.ToDisplayUnits(explosionPos), null, false);
|
||||||
|
bool underWater = hull == null || explosionPos.Y < hull.Surface;
|
||||||
|
|
||||||
explosionPos = ConvertUnits.ToSimUnits(explosionPos);
|
explosionPos = ConvertUnits.ToSimUnits(explosionPos);
|
||||||
|
|
||||||
Dictionary<Limb, float> distFactors = new Dictionary<Limb, float>();
|
Dictionary<Limb, float> distFactors = new Dictionary<Limb, float>();
|
||||||
|
|||||||
@@ -72,6 +72,18 @@ namespace Barotrauma
|
|||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector2 LinearVelocity
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float AngularVelocity
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
public readonly float Timestamp;
|
public readonly float Timestamp;
|
||||||
public readonly UInt16 ID;
|
public readonly UInt16 ID;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user