First try to implement serialisation (for statics).
This commit is contained in:
1 parent
abe8987748
commit
6b958527ce
3 files changed
+78
-2
No files matched your search
@@ -21,6 +21,7 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Menu.SingNotes;
|
||||
using VocaluxeLib.Menu.SongMenu;
|
||||
@@ -267,6 +268,17 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
//This is only test-stuff and will be removed later
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(List<SThemeStatic>));
|
||||
TextWriter textWriter = new StreamWriter(@Path.Combine(_ThemePath, ThemeName + "_test.xml"));
|
||||
|
||||
List<SThemeStatic> staticsThemes = new List<SThemeStatic>();
|
||||
foreach (CStatic st in _Statics)
|
||||
staticsThemes.Add(st.GetTheme());
|
||||
|
||||
serializer.Serialize(textWriter, staticsThemes);
|
||||
textWriter.Close();
|
||||
}
|
||||
|
||||
public virtual void ReloadTextures()
|
||||
|
||||
@@ -16,17 +16,24 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using VocaluxeLib.Draw;
|
||||
|
||||
namespace VocaluxeLib.Menu
|
||||
{
|
||||
struct SThemeStatic
|
||||
[XmlType("Static")]
|
||||
public struct SThemeStatic
|
||||
{
|
||||
[XmlAttributeAttribute(AttributeName = "Name")]
|
||||
public string Name;
|
||||
[XmlElement("Skin")]
|
||||
public string TextureName;
|
||||
[XmlElement("ColorName")]
|
||||
public string ColorName;
|
||||
public SColorF Color;
|
||||
public SRectF Rect;
|
||||
public SReflection Reflection;
|
||||
}
|
||||
|
||||
public class CStatic : IMenuElement
|
||||
@@ -63,6 +70,11 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public EAspect Aspect = EAspect.Stretch;
|
||||
|
||||
public CStatic()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public CStatic(int partyModeID)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
@@ -114,6 +126,8 @@ namespace VocaluxeLib.Menu
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref Rect.W);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref Rect.H);
|
||||
|
||||
_Theme.Rect = new SRectF(Rect);
|
||||
|
||||
if (xmlReader.GetValue(item + "/Color", out _Theme.ColorName, String.Empty))
|
||||
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.ColorName, skinIndex, out Color);
|
||||
else
|
||||
@@ -124,14 +138,20 @@ namespace VocaluxeLib.Menu
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
|
||||
}
|
||||
|
||||
_Theme.Color = new SColorF(Color);
|
||||
|
||||
if (xmlReader.ItemExists(item + "/Reflection"))
|
||||
{
|
||||
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 (_ThemeLoaded)
|
||||
{
|
||||
@@ -229,6 +249,11 @@ namespace VocaluxeLib.Menu
|
||||
LoadTextures();
|
||||
}
|
||||
|
||||
public SThemeStatic GetTheme()
|
||||
{
|
||||
return _Theme;
|
||||
}
|
||||
|
||||
#region ThemeEdit
|
||||
public void MoveElement(int stepX, int stepY)
|
||||
{
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Serialization;
|
||||
using VocaluxeLib.Songs;
|
||||
|
||||
namespace VocaluxeLib
|
||||
@@ -27,9 +29,13 @@ namespace VocaluxeLib
|
||||
#region Drawing
|
||||
public struct SColorF
|
||||
{
|
||||
[XmlElement("R")]
|
||||
public float R;
|
||||
[XmlElement("G")]
|
||||
public float G;
|
||||
[XmlElement("B")]
|
||||
public float B;
|
||||
[XmlElement("A")]
|
||||
public float A;
|
||||
|
||||
public SColorF(float r, float g, float b, float a)
|
||||
@@ -48,19 +54,27 @@ namespace VocaluxeLib
|
||||
A = color.A;
|
||||
}
|
||||
|
||||
[Pure]
|
||||
public Color AsColor()
|
||||
{
|
||||
return Color.FromArgb((int)(A * 255), (int)(R * 255), (int)(G * 255), (int)(B * 255));
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot()]
|
||||
public struct SRectF
|
||||
{
|
||||
[XmlElement("X")]
|
||||
public float X;
|
||||
[XmlElement("Y")]
|
||||
public float Y;
|
||||
[XmlElement("W")]
|
||||
public float W;
|
||||
[XmlElement("H")]
|
||||
public float H;
|
||||
[XmlElement("Z")]
|
||||
public float Z;
|
||||
[XmlIgnore]
|
||||
public float Rotation; //0..360°
|
||||
|
||||
public SRectF(float x, float y, float w, float h, float z)
|
||||
@@ -84,6 +98,31 @@ namespace VocaluxeLib
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot("Reflection")]
|
||||
public struct SReflection
|
||||
{
|
||||
[XmlAttributeAttribute(AttributeName = "Enabled")]
|
||||
public bool Enabled;
|
||||
[XmlElement("Height")]
|
||||
public float Height;
|
||||
[XmlElement("Space")]
|
||||
public float Space;
|
||||
|
||||
public SReflection(bool enabled, float height, float space)
|
||||
{
|
||||
Enabled = enabled;
|
||||
Height = height;
|
||||
Space = space;
|
||||
}
|
||||
|
||||
public SReflection(SReflection refl)
|
||||
{
|
||||
Enabled = refl.Enabled;
|
||||
Height = refl.Height;
|
||||
Space = refl.Space;
|
||||
}
|
||||
}
|
||||
|
||||
public struct SPoint3F
|
||||
{
|
||||
public float X;
|
||||
|
||||
Reference in new issue
Block a user