From f5f1a9148149e17a9856e0b4c35e439802c26f39 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Mon, 22 Sep 2014 15:44:20 +0200 Subject: [PATCH] Remove bounds from DrawTextureReflection because it was never used --- Vocaluxe/Base/CDraw.cs | 5 +- Vocaluxe/Base/CMain.cs | 4 +- Vocaluxe/Base/Fonts/CFont.cs | 2 +- Vocaluxe/Lib/Draw/CDirect3D.cs | 58 +++++-------------- Vocaluxe/Lib/Draw/CDrawWinForm.cs | 2 +- Vocaluxe/Lib/Draw/IDraw.cs | 2 +- Vocaluxe/Screens/CScreenSing.cs | 7 +-- VocaluxeLib/IBasic.cs | 2 +- VocaluxeLib/Menu/CButton.cs | 6 +- VocaluxeLib/Menu/CStatic.cs | 15 ++--- .../Menu/SongMenu/CSongMenuTileBoard.cs | 11 ++-- 11 files changed, 37 insertions(+), 77 deletions(-) diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs index 9152a043..7cb2e463 100644 --- a/Vocaluxe/Base/CDraw.cs +++ b/Vocaluxe/Base/CDraw.cs @@ -403,12 +403,11 @@ namespace Vocaluxe.Base /// /// (Original) rectangle to draw the reflection for /// - /// /// Spacing between the rect and the reflection /// Height of the reflection - public static void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, SRectF bounds, float space, float height) + public static void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, float space, float height) { - _Draw.DrawTextureReflection(textureRef, rect, color, bounds, space, height); + _Draw.DrawTextureReflection(textureRef, rect, color, space, height); } } } \ No newline at end of file diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index e68ecf53..a67fce16 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -423,9 +423,9 @@ namespace Vocaluxe.Base CDraw.DrawTexture(texture, rect, color, bounds, mirrored); } - public void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, float reflectionSpace, float reflectionHeight) + public void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, float reflectionSpace, float reflectionHeight) { - CDraw.DrawTextureReflection(texture, rect, color, bounds, reflectionSpace, reflectionHeight); + CDraw.DrawTextureReflection(texture, rect, color, reflectionSpace, reflectionHeight); } public CTextureRef AddTexture(string fileName) diff --git a/Vocaluxe/Base/Fonts/CFont.cs b/Vocaluxe/Base/Fonts/CFont.cs index a9c31e7a..844c8247 100644 --- a/Vocaluxe/Base/Fonts/CFont.cs +++ b/Vocaluxe/Base/Fonts/CFont.cs @@ -104,7 +104,7 @@ namespace Vocaluxe.Base.Fonts CTextureRef texture; SRectF rect; GetOrAddGlyph(chr).GetTextureAndRect(x, y, z, out texture, out rect); - CDraw.DrawTextureReflection(texture, rect, color, rect, rspace, rheight); + CDraw.DrawTextureReflection(texture, rect, color, rspace, rheight); } public float GetWidth(char chr) diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 06918b96..9c123131 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -568,7 +568,7 @@ namespace Vocaluxe.Lib.Draw /// The height of the reflection public void DrawRectReflection(SColorF color, SRectF rect, float space, float height) { - DrawTextureReflection(_BlankTexture, rect, color, rect, space, height); + DrawTextureReflection(_BlankTexture, rect, color, space, height); } #endregion Basic Draw Methods @@ -619,7 +619,7 @@ namespace Vocaluxe.Lib.Draw //Calculate the position const float x1 = 0; float x2 = texture.WidthRatio; - const float y1 = 0; + float y1 = 0; float y2 = texture.HeightRatio; //Calculate the size @@ -634,8 +634,9 @@ namespace Vocaluxe.Lib.Draw if (mirrored) { - //y1 = -y1; - y2 = -y2; + float tmp = y2; + y2 = y1; + y1 = tmp; } var vert = new STexturedColoredVertex[4]; vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb()); @@ -770,63 +771,30 @@ namespace Vocaluxe.Lib.Draw /// The texture of which a reflection should be drawn /// A SRectF struct containing the destination coordinates /// A SColorF struct containing a color which the texture will be colored in - /// A SRectF struct containing which part of the texture should be drawn /// The space between the texture and the reflection /// The height of the reflection - public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, SRectF bounds, float space, float height) + public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, float space, float height) { CD3DTexture texture; if (!_GetTexture(textureRef, out texture)) return; - if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(bounds.H) < float.Epsilon || Math.Abs(bounds.W) < float.Epsilon || - Math.Abs(color.A) < float.Epsilon || height <= 0f) + if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(color.A) < float.Epsilon || height <= 0f) return; - if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X) - return; - - if (bounds.Y > rect.Y + rect.H || bounds.Y + bounds.H < rect.Y) - return; - - if (height > bounds.H) - height = bounds.H; - - float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio; - float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio; - float y1 = (bounds.Y - rect.Y + rect.H - height) / rect.H * texture.HeightRatio; - float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio; - - if (x1 < 0) - x1 = 0f; - - if (x2 > texture.WidthRatio) - x2 = texture.WidthRatio; - - if (y1 < 0) - y1 = 0f; - - if (y2 > texture.HeightRatio) - y2 = texture.HeightRatio; + if (height > rect.H) + height = rect.H; + const float x1 = 0; + float x2 = texture.WidthRatio; + float y1 = (rect.H - height) / rect.H * texture.HeightRatio; + float y2 = texture.HeightRatio; float rx1 = rect.X; float rx2 = rect.X + rect.W; float ry1 = rect.Y + rect.H + space; float ry2 = rect.Y + rect.H + space + height; - if (rx1 < bounds.X) - rx1 = bounds.X; - - if (rx2 > bounds.X + bounds.W) - rx2 = bounds.X + bounds.W; - - if (ry1 < bounds.Y + space) - ry1 = bounds.Y + space; - - if (ry2 > bounds.Y + bounds.H + space + height) - ry2 = bounds.Y + bounds.H + space + height; - //Align the pixels because Direct3D expects the pixels to be the left top corner rx1 -= 0.5f; ry1 -= 0.5f; diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs index 81825158..1828dea1 100644 --- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs +++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs @@ -434,7 +434,7 @@ namespace Vocaluxe.Lib.Draw public void DrawTexture(CTextureRef texture, SRectF rect, SColorF color, float begin, float end) {} - public void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, float space, float height) {} + public void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, float space, float height) {} public int GetTextureCount() { diff --git a/Vocaluxe/Lib/Draw/IDraw.cs b/Vocaluxe/Lib/Draw/IDraw.cs index a20f873e..8a912cc2 100644 --- a/Vocaluxe/Lib/Draw/IDraw.cs +++ b/Vocaluxe/Lib/Draw/IDraw.cs @@ -56,6 +56,6 @@ namespace Vocaluxe.Lib.Draw void DrawTexture(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored = false); void DrawTexture(CTextureRef texture, SRectF rect, SColorF color, float begin, float end); - void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, float space, float height); + void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, float space, float height); } } \ No newline at end of file diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 5918df48..6c857553 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -466,11 +466,10 @@ namespace Vocaluxe.Screens background = _Background; if (background != null) { - var bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH); - RectangleF rect; + var bounds = new SRectF(0, 0, CSettings.RenderW, CSettings.RenderH, 0); + SRectF rect; CHelper.SetRect(bounds, out rect, background.OrigAspect, aspect); - CDraw.DrawTexture(background, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, 0f), - background.Color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f)); + CDraw.DrawTexture(background, rect, background.Color); } else if (_SlideShow != null) _SlideShow.Draw(); diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index 58537174..27c93374 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -143,7 +143,7 @@ namespace VocaluxeLib void DrawTexture(CTextureRef texture, SRectF rect); void DrawTexture(CTextureRef texture, SRectF rect, SColorF color); void DrawTexture(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored = false); - void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, float reflectionSpace, float reflectionHeight); + void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, float reflectionSpace, float reflectionHeight); CTextureRef AddTexture(string fileName); void RemoveTexture(ref CTextureRef texture); diff --git a/VocaluxeLib/Menu/CButton.cs b/VocaluxeLib/Menu/CButton.cs index 52c8b7e2..34955eae 100644 --- a/VocaluxeLib/Menu/CButton.cs +++ b/VocaluxeLib/Menu/CButton.cs @@ -300,7 +300,7 @@ namespace VocaluxeLib.Menu if (_Reflection) { - CBase.Drawing.DrawTextureReflection(texture, Rect, Color, Rect, _ReflectionSpace, _ReflectionHeight); + CBase.Drawing.DrawTextureReflection(texture, Rect, Color, _ReflectionSpace, _ReflectionHeight); Text.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H); } else @@ -314,7 +314,7 @@ namespace VocaluxeLib.Menu if (_Reflection) { - CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight); + CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, _ReflectionSpace, _ReflectionHeight); Text.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H); } else @@ -328,7 +328,7 @@ namespace VocaluxeLib.Menu if (_Reflection) { - CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight); + CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, _ReflectionSpace, _ReflectionHeight); _SelText.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H); } else diff --git a/VocaluxeLib/Menu/CStatic.cs b/VocaluxeLib/Menu/CStatic.cs index 222ffc76..31861b76 100644 --- a/VocaluxeLib/Menu/CStatic.cs +++ b/VocaluxeLib/Menu/CStatic.cs @@ -193,22 +193,19 @@ namespace VocaluxeLib.Menu public void Draw(EAspect aspect, float scale = 1f, float zModify = 0f, bool forceDraw = false) { CTextureRef texture = Texture; - SRectF bounds = Rect.Scale(scale); - SRectF rect; - if (aspect != EAspect.Stretch && texture != null) - CHelper.SetRect(bounds, out rect, texture.OrigAspect, aspect); - else - rect = bounds; - rect.Z = Rect.Z + zModify; + SRectF rect = Rect.Scale(scale); + rect.Z += zModify; + if (texture != null) + CHelper.SetRect(rect, out rect, texture.OrigAspect, aspect); var color = new SColorF(Color.R, Color.G, Color.B, Color.A * Alpha); if (Visible || forceDraw || (CBase.Settings.GetProgramState() == EProgramState.EditTheme)) { if (texture != null) { - CBase.Drawing.DrawTexture(texture, rect, color, bounds); + CBase.Drawing.DrawTexture(texture, rect, color); if (Reflection) - CBase.Drawing.DrawTextureReflection(texture, rect, color, bounds, ReflectionSpace, ReflectionHeight); + CBase.Drawing.DrawTextureReflection(texture, rect, color, ReflectionSpace, ReflectionHeight); } else CBase.Drawing.DrawColor(color, rect); diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index a0efaa6f..2fc8ce76 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -473,14 +473,11 @@ namespace VocaluxeLib.Menu.SongMenu { if (vidtex.Color.A < 1) _CoverBig.Draw(EAspect.Crop); - var bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H); - RectangleF rect; - CHelper.SetRect(bounds, out rect, vidtex.OrigAspect, EAspect.Crop); - var vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z); - var vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f); + SRectF rect; + CHelper.SetRect(_CoverBig.Rect, out rect, vidtex.OrigAspect, EAspect.Crop); - CBase.Drawing.DrawTexture(vidtex, vidRect, vidtex.Color, vidRectBounds); - CBase.Drawing.DrawTextureReflection(vidtex, vidRect, vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); + CBase.Drawing.DrawTexture(vidtex, rect); + CBase.Drawing.DrawTextureReflection(vidtex, rect, vidtex.Color, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); } else _CoverBig.Draw(EAspect.Crop);