Merge branch 'Better_Graphics_Handling' into Automatic_Covers

Conflicts:
	Vocaluxe/Base/CCover.cs
	Vocaluxe/Base/CGraphics.cs
	Vocaluxe/Base/Fonts/CFontStyle.cs
	Vocaluxe/Base/Fonts/CGlyph.cs
	VocaluxeLib/Menu/CText.cs
	VocaluxeLib/Structs.cs
This commit is contained in:
Flamefire committed 2014-09-25 19:43:21 +02:00
commit dd1231ad34
603 files changed
+25356 -25970

No files matched your search

+86 -104
View File
@@ -17,20 +17,28 @@
using System;
using System.Drawing;
using System.Xml;
using System.Xml.Serialization;
namespace VocaluxeLib.Menu
{
struct SThemeText
[XmlType("Text")]
public struct SThemeText
{
public string Name;
[XmlAttribute(AttributeName = "Name")] public string Name;
public string Text;
public string ColorName;
public string SelColorName; //for Buttons
public string FontFamily;
public EStyle FontStyle;
public float FontHeight;
[XmlElement("X")] public float X;
[XmlElement("Y")] public float Y;
[XmlElement("Z")] public float Z;
[XmlElement("H")] public float FontHeight;
[XmlElement("MaxW")] public float MaxWidth;
public SThemeColor Color;
public SThemeColor SColor; //for Buttons
[XmlElement("Align")] public EAlignment Align;
[XmlElement("ResizeAlign")] public EHAlignment ResizeAlign;
[XmlElement("Style")] public EStyle FontStyle;
[XmlElement("Font")] public string FontFamily;
[XmlElement("Text")] public string Text;
public SReflection Reflection;
}
public class CText : IMenuElement, IFontObserver
@@ -45,6 +53,11 @@ namespace VocaluxeLib.Menu
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
private bool _ButtonText;
private bool _PositionNeedsUpdate = true;
@@ -287,6 +300,17 @@ namespace VocaluxeLib.Menu
ReflectionHeight = rheight;
}
public CText(SThemeText theme, int partyModeID, bool buttonText = false)
{
_PartyModeID = partyModeID;
_TranslationID = partyModeID;
_Theme = theme;
_ButtonText = buttonText;
LoadTextures();
}
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex)
{
return LoadTheme(xmlPath, elementName, xmlReader, skinIndex, false);
@@ -305,8 +329,8 @@ namespace VocaluxeLib.Menu
xmlReader.TryGetFloatValue(item + "/MaxW", ref _MaxWidth);
if (xmlReader.GetValue(item + "/Color", out _Theme.ColorName, String.Empty))
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.ColorName, skinIndex, out Color);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.Color.Name, skinIndex, out Color);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
@@ -315,8 +339,8 @@ namespace VocaluxeLib.Menu
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
}
if (xmlReader.GetValue(item + "/SColor", out _Theme.SelColorName, String.Empty))
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.SelColorName, skinIndex, out SelColor);
if (xmlReader.GetValue(item + "/SColor", out _Theme.SColor.Name, String.Empty))
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.SColor.Name, skinIndex, out SelColor);
else
{
if (xmlReader.TryGetFloatValue(item + "/SR", ref SelColor.R))
@@ -332,7 +356,6 @@ namespace VocaluxeLib.Menu
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.FontHeight);
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Style", ref _Theme.FontStyle);
_ThemeLoaded &= xmlReader.GetValue(item + "/Font", out _Theme.FontFamily);
Font = new CFont(_Theme.FontFamily, _Theme.FontStyle, _Theme.FontHeight);
_ThemeLoaded &= xmlReader.GetValue(item + "/Text", out _Theme.Text, String.Empty);
@@ -340,10 +363,22 @@ namespace VocaluxeLib.Menu
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref ReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref ReflectionHeight);
_Theme.Reflection = new SReflection(true, ReflectionHeight, ReflectionSpace);
}
else
_Theme.Reflection = new SReflection(false, 0f, 0f);
// Set values
_Theme.Name = elementName;
_Theme.Align = _Align;
_Theme.Color.Color = Color;
_Theme.ResizeAlign = _ResizeAlign;
_Theme.SColor.Color = SelColor;
_Theme.MaxWidth = _MaxWidth;
_Theme.X = _X;
_Theme.Y = _Y;
_Theme.Z = _Z;
_ButtonText = buttonText;
_PositionNeedsUpdate = true;
@@ -352,90 +387,6 @@ namespace VocaluxeLib.Menu
return _ThemeLoaded;
}
public bool SaveTheme(XmlWriter writer)
{
if (_ThemeLoaded || _ButtonText)
{
writer.WriteStartElement(_Theme.Name);
writer.WriteComment("<X>, <Y>: Text position");
writer.WriteElementString("X", X.ToString("#0"));
writer.WriteElementString("Y", Y.ToString("#0"));
if (!_ButtonText)
{
writer.WriteComment("<Z>: Text position");
writer.WriteElementString("Z", Z.ToString("#0.00"));
}
writer.WriteComment("<H>: Text height");
writer.WriteElementString("H", _Theme.FontHeight.ToString("#0"));
writer.WriteComment("<MaxW>: Maximum text width (if exists)");
if (MaxWidth > 0)
writer.WriteElementString("MaxW", MaxWidth.ToString("#0"));
writer.WriteComment("<Color>: Text color from ColorScheme (high priority)");
writer.WriteComment("or <R>, <G>, <B>, <A> (lower priority)");
if (!String.IsNullOrEmpty(_Theme.ColorName))
writer.WriteElementString("Color", _Theme.ColorName);
else
{
writer.WriteElementString("R", Color.R.ToString("#0.00"));
writer.WriteElementString("G", Color.G.ToString("#0.00"));
writer.WriteElementString("B", Color.B.ToString("#0.00"));
writer.WriteElementString("A", Color.A.ToString("#0.00"));
}
writer.WriteComment("<SColor>: Selected Text color from ColorScheme (high priority)");
writer.WriteComment("or <SR>, <SG>, <SB>, <SA> (lower priority)");
if (!String.IsNullOrEmpty(_Theme.SelColorName))
writer.WriteElementString("SColor", _Theme.SelColorName);
else
{
writer.WriteElementString("SR", SelColor.R.ToString("#0.00"));
writer.WriteElementString("SG", SelColor.G.ToString("#0.00"));
writer.WriteElementString("SB", SelColor.B.ToString("#0.00"));
writer.WriteElementString("SA", SelColor.A.ToString("#0.00"));
}
writer.WriteComment("<Align>: Text align horizontal: " + CHelper.ListStrings(Enum.GetNames(typeof(EAlignment))));
writer.WriteElementString("Align", Enum.GetName(typeof(EAlignment), Align));
writer.WriteComment("<ResizeAlign>: Text align vertical (on downsizing): " + CHelper.ListStrings(Enum.GetNames(typeof(EHAlignment))));
writer.WriteElementString("ResizeAlign", Enum.GetName(typeof(EHAlignment), ResizeAlign));
writer.WriteComment("<Style>: Text style: " + CHelper.ListStrings(Enum.GetNames(typeof(EStyle))));
writer.WriteElementString("Style", Enum.GetName(typeof(EStyle), _Theme.FontStyle));
writer.WriteComment("<Font>: Text font name");
writer.WriteElementString("Font", _Theme.FontFamily);
writer.WriteComment("<Text>: Nothing or translation tag");
writer.WriteElementString("Text", CBase.Language.TranslationExists(_Theme.Text) ? _Theme.Text : string.Empty);
if (!_ButtonText)
{
writer.WriteComment("<Reflection> If exists:");
writer.WriteComment(" <Space>: Reflection Space");
writer.WriteComment(" <Height>: Reflection Height");
}
if (ReflectionHeight > 0 && !_ButtonText)
{
writer.WriteStartElement("Reflection");
writer.WriteElementString("Space", ReflectionSpace.ToString("#0"));
writer.WriteElementString("Height", ReflectionHeight.ToString("#0"));
writer.WriteEndElement();
}
writer.WriteEndElement();
return true;
}
return false;
}
public void Draw(bool forceDraw = false)
{
if (!forceDraw && !Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme)
@@ -453,7 +404,7 @@ namespace VocaluxeLib.Menu
CBase.Fonts.DrawTextReflection(_Text, Font, Rect.X, Rect.Y, Z, color, ReflectionSpace, ReflectionHeight);
if (Selected && (CBase.Settings.GetProgramState() == EProgramState.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.DrawRect(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(Rect.X, Rect.Y, Rect.W, Rect.H, Z));
}
public void Draw(float begin, float end)
@@ -469,7 +420,7 @@ namespace VocaluxeLib.Menu
}
if (Selected && (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(X, Y, Rect.W, Rect.H, Z));
CBase.Drawing.DrawRect(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)
@@ -496,11 +447,34 @@ namespace VocaluxeLib.Menu
public void LoadTextures()
{
if (!String.IsNullOrEmpty(_Theme.ColorName))
Color = CBase.Theme.GetColor(_Theme.ColorName, _PartyModeID);
if (!String.IsNullOrEmpty(_Theme.Color.Name))
Color = CBase.Theme.GetColor(_Theme.Color.Name, _PartyModeID);
else
Color = new SColorF(_Theme.Color.Color);
if (!String.IsNullOrEmpty(_Theme.SelColorName))
SelColor = CBase.Theme.GetColor(_Theme.SelColorName, _PartyModeID);
if (!String.IsNullOrEmpty(_Theme.SColor.Name))
SelColor = CBase.Theme.GetColor(_Theme.SColor.Name, _PartyModeID);
else
SelColor = new SColorF(_Theme.SColor.Color);
_X = _Theme.X;
_Y = _Theme.Y;
_Z = _Theme.Z;
_MaxWidth = _Theme.MaxWidth;
_Align = _Theme.Align;
_ResizeAlign = _Theme.ResizeAlign;
Font = new CFont(_Theme.FontFamily, _Theme.FontStyle, _Theme.FontHeight);
if (_Theme.Reflection.Enabled)
{
ReflectionSpace = _Theme.Reflection.Space;
ReflectionHeight = _Theme.Reflection.Height;
}
Text = _Theme.Text;
Selected = false;
_ThemeLoaded = true;
}
public void ReloadTextures()
@@ -509,11 +483,19 @@ namespace VocaluxeLib.Menu
LoadTextures();
}
public SThemeText GetTheme()
{
return _Theme;
}
#region ThemeEdit
public void MoveElement(int stepX, int stepY)
{
X += stepX;
Y += stepY;
_Theme.X = X;
_Theme.Y = Y;
}
public void ResizeElement(int stepW, int stepH)