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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user