(d9829ac) v0.9.4.0
This commit is contained in:
@@ -80,16 +80,7 @@ namespace Barotrauma
|
||||
{
|
||||
int width = 0; int height = 0; int channels = 0;
|
||||
byte[] textureData = null;
|
||||
Task loadTask = Task.Run(() =>
|
||||
{
|
||||
textureData = Texture2D.TextureDataFromStream(fileStream, out width, out height, out channels);
|
||||
});
|
||||
bool success = loadTask.Wait(10000);
|
||||
if (!success)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to load texture data from " + (path ?? "stream") + ": timed out");
|
||||
return null;
|
||||
}
|
||||
textureData = Texture2D.TextureDataFromStream(fileStream, out width, out height, out channels);
|
||||
if (preMultiplyAlpha)
|
||||
{
|
||||
PreMultiplyAlpha(ref textureData);
|
||||
@@ -104,6 +95,10 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if WINDOWS
|
||||
if (e is SharpDX.SharpDXException) { throw; }
|
||||
#endif
|
||||
|
||||
DebugConsole.ThrowError("Loading texture from stream failed!", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -89,11 +89,22 @@ namespace Barotrauma
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
public static Color GradientLerp(float t, params Color[] gradient)
|
||||
{
|
||||
if (t <= 0.0f) return gradient[0];
|
||||
if (t >= 1.0f) return gradient[gradient.Length - 1];
|
||||
System.Diagnostics.Debug.Assert(gradient.Length > 0, "Empty color array passed to the GradientLerp method");
|
||||
if (gradient.Length == 0)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Empty color array passed to the GradientLerp method.\n" + Environment.StackTrace);
|
||||
#endif
|
||||
GameAnalyticsManager.AddErrorEventOnce("ToolBox.GradientLerp:EmptyColorArray", GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
||||
"Empty color array passed to the GradientLerp method.\n" + Environment.StackTrace);
|
||||
return Color.Black;
|
||||
}
|
||||
|
||||
if (t <= 0.0f) { return gradient[0]; }
|
||||
if (t >= 1.0f) { return gradient[gradient.Length - 1]; }
|
||||
|
||||
float scaledT = t * (gradient.Length - 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user