Simpler CText.Draw...
Bugfix CMenu._IsMouseOver
This commit is contained in:
1 parent
fa22096914
commit
95ff3cd7a3
3 files changed
+41
-128
No files matched your search
@@ -41,17 +41,17 @@ namespace Vocaluxe.Screens
|
|||||||
base.Init();
|
base.Init();
|
||||||
const string test = " ÖÄÜabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890";
|
const string test = " ÖÄÜabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890";
|
||||||
SColorF color = new SColorF(1, 0, 0, 1);
|
SColorF color = new SColorF(1, 0, 0, 1);
|
||||||
CText text = new CText(10, 50, 1, 200, 0, EAlignment.Left, EStyle.Normal, "Normal", color, "Normal Text" + test, -1, 26, 0);
|
CText text = new CText(10, 50, 1, 32, 0, EAlignment.Left, EStyle.Normal, "Normal", color, "Normal Text" + test, -1, 26, 0);
|
||||||
_AddText(text);
|
_AddText(text);
|
||||||
text = new CText(10, 90, 1, 32, 0, EAlignment.Left, EStyle.Bold, "Normal", color, "Bold Text" + test, -1, 26, 0);
|
text = new CText(10, 90, 1, 32, 0, EAlignment.Left, EStyle.Bold, "Normal", color, "Bold Text" + test, -1, 26, 0);
|
||||||
_AddText(text);
|
_AddText(text);
|
||||||
text = new CText(10, 130, 1, 32, 0, EAlignment.Left, EStyle.Italic, "Normal", color, "Italic Text" + test, -1, 26, 0);
|
text = new CText(10, 130, 1, 32, 0, EAlignment.Left, EStyle.Italic, "Normal", color, "Italic Text" + test, -1, 26, 0);
|
||||||
_AddText(text);
|
_AddText(text);
|
||||||
text = new CText(10, 170, 1, 32, 0, EAlignment.Left, EStyle.Normal, "Outline", color, "Normal Text" + test, -1, 26, 0);
|
text = new CText(10, 170, 1, 100, 0, EAlignment.Left, EStyle.Normal, "Outline", color, "Normal Text" + test, -1, 26, 0);
|
||||||
_AddText(text);
|
_AddText(text);
|
||||||
text = new CText(10, 210, 1, 32, 0, EAlignment.Left, EStyle.Bold, "Outline", color, "Bold Text" + test, -1, 26, 0);
|
text = new CText(10, 210, 1, 200, 0, EAlignment.Left, EStyle.Bold, "Outline", color, "Bold Text" + test, -1, 26, 0);
|
||||||
_AddText(text);
|
_AddText(text);
|
||||||
text = new CText(10, 250, 1, 32, 0, EAlignment.Left, EStyle.Italic, "Outline", color, "Italic Text" + test, -1, 26, 0);
|
text = new CText(10, 250, 1, 300, 0, EAlignment.Left, EStyle.Italic, "Outline", color, "Italic Text" + test, -1, 26, 0);
|
||||||
_AddText(text);
|
_AddText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
-13
@@ -999,7 +999,7 @@ namespace VocaluxeLib.Menu
|
|||||||
|
|
||||||
private bool _IsMouseOver(int x, int y, CInteraction interact)
|
private bool _IsMouseOver(int x, int y, CInteraction interact)
|
||||||
{
|
{
|
||||||
bool result = CHelper.IsInBounds(_GetRect(interact.Num), x, y);
|
bool result = CHelper.IsInBounds(_GetRect(interact), x, y);
|
||||||
if (result)
|
if (result)
|
||||||
return true;
|
return true;
|
||||||
if (interact.Type == EType.SelectSlide)
|
if (interact.Type == EType.SelectSlide)
|
||||||
@@ -1581,45 +1581,50 @@ namespace VocaluxeLib.Menu
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SRectF _GetRect(int interaction)
|
private SRectF _GetRect(CInteraction interaction)
|
||||||
{
|
{
|
||||||
SRectF result = new SRectF();
|
SRectF result = new SRectF();
|
||||||
switch (_Interactions[interaction].Type)
|
switch (interaction.Type)
|
||||||
{
|
{
|
||||||
case EType.Button:
|
case EType.Button:
|
||||||
return _Buttons[_Interactions[interaction].Num].Rect;
|
return _Buttons[interaction.Num].Rect;
|
||||||
|
|
||||||
case EType.SelectSlide:
|
case EType.SelectSlide:
|
||||||
return _SelectSlides[_Interactions[interaction].Num].Rect;
|
return _SelectSlides[interaction.Num].Rect;
|
||||||
|
|
||||||
case EType.Static:
|
case EType.Static:
|
||||||
return _Statics[_Interactions[interaction].Num].Rect;
|
return _Statics[interaction.Num].Rect;
|
||||||
|
|
||||||
case EType.Text:
|
case EType.Text:
|
||||||
return _Texts[_Interactions[interaction].Num].Rect;
|
return _Texts[interaction.Num].Rect;
|
||||||
|
|
||||||
case EType.SongMenu:
|
case EType.SongMenu:
|
||||||
return _SongMenus[_Interactions[interaction].Num].Rect;
|
return _SongMenus[interaction.Num].Rect;
|
||||||
|
|
||||||
case EType.Lyric:
|
case EType.Lyric:
|
||||||
return _Lyrics[_Interactions[interaction].Num].Rect;
|
return _Lyrics[interaction.Num].Rect;
|
||||||
|
|
||||||
case EType.NameSelection:
|
case EType.NameSelection:
|
||||||
return _NameSelections[_Interactions[interaction].Num].Rect;
|
return _NameSelections[interaction.Num].Rect;
|
||||||
|
|
||||||
case EType.Equalizer:
|
case EType.Equalizer:
|
||||||
return _Equalizers[_Interactions[interaction].Num].Rect;
|
return _Equalizers[interaction.Num].Rect;
|
||||||
|
|
||||||
case EType.Playlist:
|
case EType.Playlist:
|
||||||
return _Playlists[_Interactions[interaction].Num].Rect;
|
return _Playlists[interaction.Num].Rect;
|
||||||
|
|
||||||
case EType.ParticleEffect:
|
case EType.ParticleEffect:
|
||||||
return _ParticleEffects[_Interactions[interaction].Num].Rect;
|
return _ParticleEffects[interaction.Num].Rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SRectF _GetRect(int interaction)
|
||||||
|
{
|
||||||
|
return _GetRect(_Interactions[interaction]);
|
||||||
|
}
|
||||||
|
|
||||||
private void _AddInteraction(int num, EType type)
|
private void _AddInteraction(int num, EType type)
|
||||||
{
|
{
|
||||||
_Interactions.Add(new CInteraction(num, type));
|
_Interactions.Add(new CInteraction(num, type));
|
||||||
|
|||||||
+19
-111
@@ -463,72 +463,30 @@ namespace VocaluxeLib.Menu
|
|||||||
// Update Text
|
// Update Text
|
||||||
Text = Text;
|
Text = Text;
|
||||||
|
|
||||||
if (_PositionNeedsUpdate)
|
|
||||||
_UpdateTextPosition();
|
|
||||||
|
|
||||||
CBase.Fonts.SetFont(Font);
|
CBase.Fonts.SetFont(Font);
|
||||||
CBase.Fonts.SetStyle(Style);
|
CBase.Fonts.SetStyle(Style);
|
||||||
|
|
||||||
SColorF currentColor = new SColorF(Color);
|
SColorF currentColor = (Selected) ? SelColor : Color;
|
||||||
if (Selected)
|
|
||||||
currentColor = new SColorF(SelColor);
|
|
||||||
|
|
||||||
SColorF color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha);
|
SColorF color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha);
|
||||||
|
|
||||||
CBase.Fonts.DrawText(_Text, Rect.H, Rect.X, Rect.Y, Z, color);
|
CBase.Fonts.DrawText(_Text, Rect.H, Rect.X, Rect.Y, Z, color);
|
||||||
|
|
||||||
if (ReflectionHeight > 0)
|
if (ReflectionHeight > 0)
|
||||||
{
|
CBase.Fonts.DrawTextReflection(_Text, Rect.H, Rect.X, Rect.Y, Z, color, ReflectionSpace, ReflectionHeight);
|
||||||
float factor = 0f;
|
|
||||||
switch (HAlign)
|
|
||||||
{
|
|
||||||
case EHAlignment.Top:
|
|
||||||
factor = (Height - Rect.H) * 1.5f;
|
|
||||||
break;
|
|
||||||
case EHAlignment.Center:
|
|
||||||
factor = (Height - Rect.H) * 1.0f;
|
|
||||||
break;
|
|
||||||
case EHAlignment.Bottom:
|
|
||||||
factor = (Height - Rect.H) * 0.5f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
CBase.Fonts.DrawTextReflection(_Text, Rect.H, Rect.X, Rect.Y, Z, color, ReflectionSpace + factor, ReflectionHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme))
|
if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme))
|
||||||
{
|
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(Rect.X, Rect.Y, Rect.W, Rect.H, Z));
|
||||||
CBase.Drawing.DrawColor(
|
|
||||||
new SColorF(0.5f, 1f, 0.5f, 0.5f * CBase.Graphics.GetGlobalAlpha()),
|
|
||||||
new SRectF(Rect.X, Rect.Y, Rect.W, Rect.H, Z)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(float begin, float end)
|
public void Draw(float begin, float end)
|
||||||
{
|
{
|
||||||
RectangleF bounds = CBase.Fonts.GetTextBounds(this);
|
|
||||||
|
|
||||||
float x = X;
|
|
||||||
switch (Align)
|
|
||||||
{
|
|
||||||
case EAlignment.Center:
|
|
||||||
x = X - bounds.Width / 2;
|
|
||||||
break;
|
|
||||||
case EAlignment.Right:
|
|
||||||
x = X - bounds.Width;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SColorF currentColor = new SColorF(Color);
|
|
||||||
if (Selected)
|
|
||||||
currentColor = new SColorF(SelColor);
|
|
||||||
|
|
||||||
SColorF color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha);
|
|
||||||
|
|
||||||
CBase.Fonts.SetFont(Font);
|
CBase.Fonts.SetFont(Font);
|
||||||
CBase.Fonts.SetStyle(Style);
|
CBase.Fonts.SetStyle(Style);
|
||||||
|
|
||||||
CBase.Fonts.DrawText(Text, Height, x, Y, Z, color, begin, end);
|
SColorF currentColor = (Selected) ? SelColor : Color;
|
||||||
|
SColorF color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha);
|
||||||
|
|
||||||
|
CBase.Fonts.DrawText(Text, Rect.H, Rect.X, Rect.Y, Z, color, begin, end);
|
||||||
|
|
||||||
if (ReflectionHeight > 0)
|
if (ReflectionHeight > 0)
|
||||||
{
|
{
|
||||||
@@ -536,72 +494,22 @@ namespace VocaluxeLib.Menu
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme))
|
if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme))
|
||||||
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(x, Y, bounds.Width, bounds.Height, Z));
|
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(X, Y, Rect.W, Rect.H, Z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawRelative(float rx, float ry, float reflectionHeight = 0f, float reflectionSpace = 0f, float rectHeight = 0f)
|
public void DrawRelative(float rx, float ry, float reflectionHeight = 0f, float reflectionSpace = 0f, float rectHeight = 0f)
|
||||||
{
|
{
|
||||||
// Update Text
|
var oldReflectionSpace = ReflectionSpace;
|
||||||
Text = Text;
|
var oldReflectionHeight = ReflectionHeight;
|
||||||
|
ReflectionSpace = (rectHeight - Y - Rect.H) * 2 + reflectionSpace;
|
||||||
float h = Height;
|
ReflectionHeight = reflectionHeight - (rectHeight - Y) + Rect.H;
|
||||||
|
X += rx;
|
||||||
float x = X + rx;
|
Y += ry;
|
||||||
float y = Y + ry;
|
Draw(true);
|
||||||
|
ReflectionSpace = oldReflectionSpace;
|
||||||
CBase.Fonts.SetFont(Font);
|
ReflectionHeight = oldReflectionHeight;
|
||||||
CBase.Fonts.SetStyle(Style);
|
X -= rx;
|
||||||
|
Y -= ry;
|
||||||
RectangleF bounds = CBase.Fonts.GetTextBounds(this);
|
|
||||||
|
|
||||||
if (bounds.Width > MaxWidth && MaxWidth > 0f && bounds.Width > 0f)
|
|
||||||
{
|
|
||||||
float factor = MaxWidth / bounds.Width;
|
|
||||||
float step = h * (1 - factor);
|
|
||||||
h *= factor;
|
|
||||||
switch (HAlign)
|
|
||||||
{
|
|
||||||
case EHAlignment.Center:
|
|
||||||
y += step * 0.50f;
|
|
||||||
break;
|
|
||||||
case EHAlignment.Bottom:
|
|
||||||
y += step;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
bounds = CBase.Fonts.GetTextBounds(this, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Align)
|
|
||||||
{
|
|
||||||
case EAlignment.Center:
|
|
||||||
x = x - bounds.Width / 2;
|
|
||||||
break;
|
|
||||||
case EAlignment.Right:
|
|
||||||
x = x - bounds.Width;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SColorF currentColor = (Selected) ? SelColor : Color;
|
|
||||||
|
|
||||||
SColorF color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha);
|
|
||||||
|
|
||||||
CBase.Fonts.SetFont(Font);
|
|
||||||
CBase.Fonts.SetStyle(Style);
|
|
||||||
|
|
||||||
CBase.Fonts.DrawText(_Text, h, x, y, Z, color);
|
|
||||||
|
|
||||||
if (reflectionHeight > 0)
|
|
||||||
{
|
|
||||||
float space = (rectHeight - Y - bounds.Height) * 2f + reflectionSpace;
|
|
||||||
float height = reflectionHeight - (rectHeight - Y) + bounds.Height;
|
|
||||||
|
|
||||||
CBase.Fonts.DrawTextReflection(_Text, h, x, y, Z, color, space, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme))
|
|
||||||
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f * CBase.Graphics.GetGlobalAlpha()), new SRectF(x, y, bounds.Width, bounds.Height, Z));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnloadTextures() {}
|
public void UnloadTextures() {}
|
||||||
|
|||||||
Reference in new issue
Block a user