(4675d2f8d) Fixed the bottom of the background ice texture not rendering correctly on high resolutions. Fixes #1595

This commit is contained in:
Joonas Rikkonen
2019-06-11 21:50:01 +03:00
parent 3cc9abed76
commit 8f4cbad15c
@@ -142,24 +142,27 @@ namespace Barotrauma
backgroundPos.Y = -backgroundPos.Y; backgroundPos.Y = -backgroundPos.Y;
backgroundPos *= 0.05f; backgroundPos *= 0.05f;
if (level.GenerationParams.BackgroundTopSprite != null)
if (backgroundPos.Y < 1024)
{ {
if (backgroundPos.Y < 0 && level.GenerationParams.BackgroundTopSprite != null) int backgroundSize = (int)level.GenerationParams.BackgroundTopSprite.size.Y;
if (backgroundPos.Y < backgroundSize)
{ {
var backgroundTop = level.GenerationParams.BackgroundTopSprite; if (backgroundPos.Y < 0)
backgroundTop.SourceRect = new Rectangle((int)backgroundPos.X, (int)backgroundPos.Y, 1024, (int)Math.Min(-backgroundPos.Y, 1024)); {
backgroundTop.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(GameMain.GraphicsWidth, Math.Min(-backgroundPos.Y, GameMain.GraphicsHeight)), var backgroundTop = level.GenerationParams.BackgroundTopSprite;
color: level.BackgroundTextureColor); backgroundTop.SourceRect = new Rectangle((int)backgroundPos.X, (int)backgroundPos.Y, backgroundSize, (int)Math.Min(-backgroundPos.Y, backgroundSize));
} backgroundTop.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(GameMain.GraphicsWidth, Math.Min(-backgroundPos.Y, GameMain.GraphicsHeight)),
if (backgroundPos.Y > -1024 && level.GenerationParams.BackgroundSprite != null) color: level.BackgroundTextureColor);
{ }
var background = level.GenerationParams.BackgroundSprite; if (-backgroundPos.Y < GameMain.GraphicsHeight && level.GenerationParams.BackgroundSprite != null)
background.SourceRect = new Rectangle((int)backgroundPos.X, (int)Math.Max(backgroundPos.Y, 0), 1024, 1024); {
background.DrawTiled(spriteBatch, var background = level.GenerationParams.BackgroundSprite;
(backgroundPos.Y < 0) ? new Vector2(0.0f, (int)-backgroundPos.Y) : Vector2.Zero, background.SourceRect = new Rectangle((int)backgroundPos.X, (int)Math.Max(backgroundPos.Y, 0), backgroundSize, backgroundSize);
new Vector2(GameMain.GraphicsWidth, (int)Math.Ceiling(1024 - backgroundPos.Y)), background.DrawTiled(spriteBatch,
color: level.BackgroundTextureColor); (backgroundPos.Y < 0) ? new Vector2(0.0f, (int)-backgroundPos.Y) : Vector2.Zero,
new Vector2(GameMain.GraphicsWidth, (int)Math.Min(Math.Ceiling(backgroundSize - backgroundPos.Y), backgroundSize)),
color: level.BackgroundTextureColor);
}
} }
} }