some small improvements in text drawing

This commit is contained in:
Alexander Eckart committed 2012-03-16 20:54:35 +01:00
1 parent 3f2b83d0c6
commit f20a149617
4 files changed
+24 -15

No files matched your search

+13 -1
View File
@@ -12,6 +12,7 @@ using System.Xml;
using System.Xml.XPath;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Menu;
namespace Vocaluxe.Base
{
@@ -551,7 +552,18 @@ namespace Vocaluxe.Base
}
}
}
public static RectangleF GetTextBounds(CText text)
{
return GetTextBounds(text, text.Height);
}
public static RectangleF GetTextBounds(CText text, float height)
{
Height = height;
return new RectangleF(text.X, text.Y, GetTextWidth(CLanguage.Translate(text.Text)), GetTextHeight(CLanguage.Translate(text.Text)));
}
public static float GetTextWidth(string text)
{
float dx = 0;
+1 -1
View File
@@ -511,7 +511,7 @@ namespace Vocaluxe.Lib.Draw
CFonts.Height = Height;
CFonts.SetFont(text.Fon);
CFonts.Style = text.Style;
return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(text.Text));
return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text)));
}
#region Basic Draw Methods
+6 -13
View File
@@ -394,15 +394,18 @@ namespace Vocaluxe.Menu
if (!ForceDraw && !Visible && CSettings.GameState != EGameState.EditTheme)
return;
CFonts.SetFont(Fon);
CFonts.Style = Style;
float h = Height;
float y = Y;
RectangleF bounds = CDraw.GetTextBounds(this);
RectangleF bounds = CFonts.GetTextBounds(this);
while (bounds.Width > Bounds.W)
{
h -= 0.2f;
y += 0.1f;
bounds = CDraw.GetTextBounds(this, h);
bounds = CFonts.GetTextBounds(this, h);
}
float x = X;
@@ -424,8 +427,7 @@ namespace Vocaluxe.Menu
SColorF color = new SColorF(CurrentColor.R, CurrentColor.G, CurrentColor.B, CurrentColor.A * Alpha);
CFonts.SetFont(Fon);
CFonts.Style = Style;
CFonts.DrawText(CLanguage.Translate(Text), h, x, y, Z, color);
if (Reflection)
@@ -437,9 +439,6 @@ namespace Vocaluxe.Menu
{
CDraw.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f * CGraphics.GlobalAlpha), new SRectF(x, y, bounds.Width, bounds.Height, Z));
}
CFonts.SetFont("Normal");
CFonts.Style = EStyle.Normal;
}
public void Draw(float begin, float end)
@@ -478,9 +477,6 @@ namespace Vocaluxe.Menu
{
CDraw.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(x, Y, bounds.Width, bounds.Height, Z));
}
CFonts.SetFont("Normal");
CFonts.Style = EStyle.Normal;
}
public void DrawRelative(float x, float y)
@@ -542,9 +538,6 @@ namespace Vocaluxe.Menu
{
CDraw.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f * CGraphics.GlobalAlpha), new SRectF(x, y, bounds.Width, bounds.Height, Z));
}
CFonts.SetFont("Normal");
CFonts.Style = EStyle.Normal;
}
public void UnloadTextures()
+4
View File
@@ -140,7 +140,11 @@ namespace Vocaluxe.Screens
base.DrawFG();
if (CSettings.VersionRevision != ERevision.Release)
{
CFonts.SetFont("Normal");
CFonts.Style = EStyle.Normal;
CDraw.DrawText(CSettings.GetFullVersionText(), 10, 680, 40);
}
return true;
}