Merge branch 'develop' of git://github.com/flokuep/Vocaluxe into Better_Graphics_Handling

Conflicts:
	Vocaluxe/COSFunctions.cs
	VocaluxeLib/CHelper.cs
	VocaluxeLib/Menu/CStatic.cs
	VocaluxeLib/Structs.cs
This commit is contained in:
Flamefire committed 2014-09-25 18:49:18 +02:00
commit c156fa69ab
550 files changed
+22434 -23687

No files matched your search

+110 -96
View File
@@ -17,19 +17,35 @@
using System;
using System.Xml;
using System.Xml.Serialization;
using VocaluxeLib.Draw;
namespace VocaluxeLib.Menu
{
struct SThemeButton
[XmlType("Button")]
public struct SThemeButton
{
[XmlAttributeAttribute(AttributeName = "Name")]
public string Name;
public string ColorName;
public string SelColorName;
[XmlElement("Skin")]
public string TextureName;
[XmlElement("SkinSelected")]
public string SelTextureName;
public SRectF Rect;
[XmlElement("Color")]
public SThemeColor Color;
[XmlElement("SelColor")]
public SThemeColor SelColor;
[XmlElement("Text")]
public SThemeText Text;
[XmlElement("SText")]
public SThemeText SText;
public bool STextSpecified;
[XmlElement("Reflection")]
public SReflection Reflection;
[XmlElement("SelReflection")]
public SReflection SelReflection;
}
public class CButton : IMenuElement
@@ -44,9 +60,8 @@ namespace VocaluxeLib.Menu
public SColorF Color;
public SColorF SelColor;
private bool _IsSelText;
public readonly CText Text;
private readonly CText _SelText;
public CText Text;
private CText _SelText;
private bool _Reflection;
private float _ReflectionSpace;
@@ -97,6 +112,11 @@ namespace VocaluxeLib.Menu
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public CButton(int partyModeID)
{
_PartyModeID = partyModeID;
@@ -106,13 +126,25 @@ namespace VocaluxeLib.Menu
EditMode = false;
}
public CButton(SThemeButton theme, int partyModeID, bool buttonText = false)
{
_PartyModeID = partyModeID;
_Theme = theme;
Text = new CText(_Theme.Text, _PartyModeID, buttonText);
_SelText = new CText(_Theme.SText, _PartyModeID, buttonText);
Selected = false;
EditMode = false;
LoadTextures();
}
public CButton(CButton button)
{
_PartyModeID = button._PartyModeID;
_Theme = new SThemeButton
{
ColorName = button._Theme.ColorName,
SelColorName = button._Theme.SelColorName,
TextureName = button._Theme.TextureName,
SelTextureName = button._Theme.SelTextureName
};
@@ -152,8 +184,8 @@ namespace VocaluxeLib.Menu
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref Rect.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref Rect.H);
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);
@@ -162,8 +194,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.SelColor.Name, String.Empty))
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.SelColor.Name, skinIndex, out SelColor);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref SelColor.R);
@@ -176,7 +208,7 @@ namespace VocaluxeLib.Menu
Text.Z = Rect.Z;
if (xmlReader.ItemExists(item + "/SText"))
{
_IsSelText = true;
_Theme.STextSpecified = true;
_ThemeLoaded &= _SelText.LoadTheme(item, "SText", xmlReader, skinIndex, true);
_SelText.Z = Rect.Z;
}
@@ -188,103 +220,44 @@ namespace VocaluxeLib.Menu
_Reflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref _ReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref _ReflectionHeight);
_Theme.Reflection = new SReflection(true, _ReflectionHeight, _ReflectionSpace);
}
else
{
_Reflection = false;
_Theme.Reflection = new SReflection(false, 0f, 0f);
}
if (xmlReader.ItemExists(item + "/SReflection"))
{
_SelReflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Space", ref _SelReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Height", ref _SelReflectionHeight);
_Theme.SelReflection = new SReflection(true, _SelReflectionHeight, _SelReflectionSpace);
}
else
{
_SelReflection = false;
_Theme.SelReflection = new SReflection(false, 0f, 0f);
}
if (_ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.Rect = new SRectF(Rect);
_Theme.Color.Color = new SColorF(Color);
_Theme.SelColor.Color = new SColorF(SelColor);
_Theme.Text = Text.GetTheme();
_Theme.SText = _SelText.GetTheme();
LoadTextures();
}
return _ThemeLoaded;
}
public bool SaveTheme(XmlWriter writer)
{
if (_ThemeLoaded)
{
writer.WriteStartElement(_Theme.Name);
writer.WriteComment("<Skin>: Texture name");
writer.WriteElementString("Skin", _Theme.TextureName);
writer.WriteComment("<SkinSelected>: Texture name for selected button");
writer.WriteElementString("SkinSelected", _Theme.SelTextureName);
writer.WriteComment("<X>, <Y>, <Z>, <W>, <H>: Button position, width and height");
writer.WriteElementString("X", Rect.X.ToString("#0"));
writer.WriteElementString("Y", Rect.Y.ToString("#0"));
writer.WriteElementString("Z", Rect.Z.ToString("#0.00"));
writer.WriteElementString("W", Rect.W.ToString("#0"));
writer.WriteElementString("H", Rect.H.ToString("#0"));
writer.WriteComment("<Color>: Button 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 button 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"));
}
Text.SaveTheme(writer);
if (_IsSelText)
_SelText.SaveTheme(writer);
writer.WriteComment("<Reflection> If exists:");
writer.WriteComment(" <Space>: Reflection Space");
writer.WriteComment(" <Height>: Reflection Height");
if (_Reflection)
{
writer.WriteStartElement("Reflection");
writer.WriteElementString("Space", _ReflectionSpace.ToString("#0"));
writer.WriteElementString("Height", _ReflectionHeight.ToString("#0"));
writer.WriteEndElement();
}
writer.WriteComment("<SReflection> If exists:");
writer.WriteComment(" <Space>: Reflection Space of selected button");
writer.WriteComment(" <Height>: Reflection Height of selected button");
if (_SelReflection)
{
writer.WriteStartElement("SReflection");
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 (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme && !forceDraw)
@@ -306,7 +279,7 @@ namespace VocaluxeLib.Menu
else
Text.DrawRelative(Rect.X, Rect.Y);
}
else if (!_IsSelText)
else if (!_Theme.STextSpecified)
{
texture = Texture ?? CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID);
@@ -320,7 +293,7 @@ namespace VocaluxeLib.Menu
else
Text.DrawRelative(Rect.X, Rect.Y);
}
else if (_IsSelText)
else if (_Theme.STextSpecified)
{
texture = SelTexture ?? CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID);
@@ -348,13 +321,43 @@ namespace VocaluxeLib.Menu
public void LoadTextures()
{
Text = new CText(_Theme.Text, _PartyModeID);
Text.LoadTextures();
if (!String.IsNullOrEmpty(_Theme.ColorName))
Color = CBase.Theme.GetColor(_Theme.ColorName, _PartyModeID);
if (_Theme.STextSpecified)
{
_SelText = new CText(_Theme.SText, _PartyModeID);
_SelText.LoadTextures();
}
if (!String.IsNullOrEmpty(_Theme.SelColorName))
SelColor = CBase.Theme.GetColor(_Theme.SelColorName, _PartyModeID);
if (!String.IsNullOrEmpty(_Theme.Color.Name))
Color = CBase.Theme.GetColor(_Theme.Color.Name, _PartyModeID);
else
Color = _Theme.Color.Color;
if (!String.IsNullOrEmpty(_Theme.SelColor.Name))
SelColor = CBase.Theme.GetColor(_Theme.SelColor.Name, _PartyModeID);
else
SelColor = _Theme.SelColor.Color;
Rect = _Theme.Rect;
_Reflection = _Theme.Reflection.Enabled;
if (_Reflection)
{
_ReflectionHeight = _Theme.Reflection.Height;
_ReflectionSpace = _Theme.Reflection.Space;
}
_SelReflection = _Theme.Reflection.Enabled;
if (_SelReflection)
{
_SelReflectionHeight = _Theme.SelReflection.Height;
_SelReflectionSpace = _Theme.SelReflection.Space;
}
if (_Theme.Rect.Z < Text.Z)
Text.Z = _Theme.Rect.Z;
}
public void ReloadTextures()
@@ -363,11 +366,19 @@ namespace VocaluxeLib.Menu
LoadTextures();
}
public SThemeButton GetTheme()
{
return _Theme;
}
#region ThemeEdit
public void MoveElement(int stepX, int stepY)
{
Rect.X += stepX;
Rect.Y += stepY;
_Theme.Rect.X += stepX;
_Theme.Rect.Y += stepY;
}
public void ResizeElement(int stepW, int stepH)
@@ -379,6 +390,9 @@ namespace VocaluxeLib.Menu
Rect.H += stepH;
if (Rect.H <= 0)
Rect.H = 1;
_Theme.Rect.W = Rect.W;
_Theme.Rect.H = Rect.H;
}
#endregion ThemeEdit
}