Revert "Remove bounds from DrawTextureReflection because it was never used"
This reverts commit f5f1a91481.
Conflicts:
Vocaluxe/Base/CMain.cs
Vocaluxe/Screens/CScreenSing.cs
VocaluxeLib/IBasic.cs
VocaluxeLib/Menu/CStatic.cs
VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs
This commit is contained in:
1 parent
125be98466
commit
25653ee55f
8 files changed
+97
-32
No files matched your search
@@ -391,11 +391,12 @@ namespace Vocaluxe.Base
|
||||
/// <param name="textureRef"></param>
|
||||
/// <param name="rect">(Original) rectangle to draw the reflection for</param>
|
||||
/// <param name="color"></param>
|
||||
/// <param name="bounds"></param>
|
||||
/// <param name="space">Spacing between the rect and the reflection</param>
|
||||
/// <param name="height">Height of the reflection</param>
|
||||
public static void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, float space, float height)
|
||||
public static void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, SRectF bounds, float space, float height)
|
||||
{
|
||||
_Draw.DrawTextureReflection(textureRef, rect, color, space, height);
|
||||
_Draw.DrawTextureReflection(textureRef, rect, color, bounds, space, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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, rspace, rheight);
|
||||
CDraw.DrawTextureReflection(texture, rect, color, rect, rspace, rheight);
|
||||
}
|
||||
|
||||
public float GetWidth(char chr)
|
||||
|
||||
@@ -552,7 +552,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// <param name="height">The height of the reflection</param>
|
||||
public void DrawRectReflection(SColorF color, SRectF rect, float space, float height)
|
||||
{
|
||||
DrawTextureReflection(_BlankTexture, rect, color, space, height);
|
||||
DrawTextureReflection(_BlankTexture, rect, color, rect, space, height);
|
||||
}
|
||||
#endregion Basic Draw Methods
|
||||
|
||||
@@ -755,30 +755,63 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// <param name="textureRef">The texture of which a reflection should be drawn</param>
|
||||
/// <param name="rect">A SRectF struct containing the destination coordinates</param>
|
||||
/// <param name="color">A SColorF struct containing a color which the texture will be colored in</param>
|
||||
/// <param name="bounds">A SRectF struct containing which part of the texture should be drawn</param>
|
||||
/// <param name="space">The space between the texture and the reflection</param>
|
||||
/// <param name="height">The height of the reflection</param>
|
||||
public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, float space, float height)
|
||||
public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, SRectF bounds, 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(color.A) < float.Epsilon || height <= 0f)
|
||||
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)
|
||||
return;
|
||||
|
||||
if (height > rect.H)
|
||||
height = rect.H;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
@@ -435,7 +435,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, float space, float height) {}
|
||||
public void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, float space, float height) {}
|
||||
|
||||
public int GetTextureCount()
|
||||
{
|
||||
|
||||
@@ -627,24 +627,43 @@ namespace Vocaluxe.Lib.Draw
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
|
||||
public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, float space, float height)
|
||||
public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, SRectF bounds, float space, float height)
|
||||
{
|
||||
COGLTexture texture;
|
||||
if (!_GetTexture(textureRef, out texture))
|
||||
return;
|
||||
|
||||
if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(color.A) < float.Epsilon || height <= float.Epsilon)
|
||||
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 <= float.Epsilon)
|
||||
return;
|
||||
|
||||
if (height > rect.H)
|
||||
height = rect.H;
|
||||
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;
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.Name);
|
||||
|
||||
const float x1 = 0;
|
||||
float x2 = texture.WidthRatio;
|
||||
float y1 = (rect.H - height) / rect.H * texture.HeightRatio;
|
||||
float y2 = texture.HeightRatio;
|
||||
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;
|
||||
|
||||
|
||||
float rx1 = rect.X;
|
||||
@@ -652,6 +671,18 @@ namespace Vocaluxe.Lib.Draw
|
||||
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;
|
||||
|
||||
GL.Enable(EnableCap.Blend);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Texture);
|
||||
@@ -664,6 +695,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
GL.Translate(-0.5f, -0.5f, 0);
|
||||
}
|
||||
|
||||
|
||||
GL.Begin(BeginMode.Quads);
|
||||
|
||||
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
|
||||
@@ -684,6 +716,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
GL.End();
|
||||
|
||||
|
||||
GL.PopMatrix();
|
||||
|
||||
GL.Disable(EnableCap.Blend);
|
||||
|
||||
@@ -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, float space, float height);
|
||||
void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, float space, float height);
|
||||
}
|
||||
}
|
||||
@@ -273,7 +273,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (_Reflection)
|
||||
{
|
||||
CBase.Drawing.DrawTextureReflection(texture, Rect, Color, _ReflectionSpace, _ReflectionHeight);
|
||||
CBase.Drawing.DrawTextureReflection(texture, Rect, Color, Rect, _ReflectionSpace, _ReflectionHeight);
|
||||
Text.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H);
|
||||
}
|
||||
else
|
||||
@@ -287,7 +287,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (_Reflection)
|
||||
{
|
||||
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, _ReflectionSpace, _ReflectionHeight);
|
||||
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight);
|
||||
Text.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H);
|
||||
}
|
||||
else
|
||||
@@ -301,7 +301,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (_Reflection)
|
||||
{
|
||||
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, _ReflectionSpace, _ReflectionHeight);
|
||||
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight);
|
||||
_SelText.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -180,19 +180,17 @@ namespace VocaluxeLib.Menu
|
||||
public void Draw(EAspect aspect, float scale = 1f, float zModify = 0f, bool forceDraw = false)
|
||||
{
|
||||
CTextureRef texture = Texture;
|
||||
SRectF rect = Rect.Scale(scale);
|
||||
rect.Z += zModify;
|
||||
if (texture != null)
|
||||
rect = CHelper.FitInBounds(rect, texture.OrigAspect, aspect);
|
||||
|
||||
SRectF bounds = Rect.Scale(scale);
|
||||
bounds.Z += zModify;
|
||||
SRectF rect = texture == null ? bounds : CHelper.FitInBounds(bounds, 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);
|
||||
CBase.Drawing.DrawTexture(texture, rect, color, bounds);
|
||||
if (Reflection)
|
||||
CBase.Drawing.DrawTextureReflection(texture, rect, color, ReflectionSpace, ReflectionHeight);
|
||||
CBase.Drawing.DrawTextureReflection(texture, rect, color, bounds, ReflectionSpace, ReflectionHeight);
|
||||
}
|
||||
else
|
||||
CBase.Drawing.DrawRect(color, rect);
|
||||
|
||||
Reference in new issue
Block a user