Serialize complete screens.
This commit is contained in:
1 parent
b2102b11d9
commit
290f6d024e
21 files changed
+237
-28
No files matched your search
@@ -20,6 +20,8 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using Vocaluxe.Base.Fonts;
|
||||
using Vocaluxe.Screens;
|
||||
using VocaluxeLib;
|
||||
@@ -160,8 +162,19 @@ namespace Vocaluxe.Base
|
||||
public static void SaveTheme()
|
||||
{
|
||||
CTheme.SaveTheme();
|
||||
foreach (IMenu screen in _Screens)
|
||||
screen.SaveTheme();
|
||||
foreach (CMenu screen in _Screens)
|
||||
{
|
||||
if (screen.ThemePath == null || screen.ThemeName == "ScreenTest")
|
||||
continue;
|
||||
|
||||
TextWriter textWriter = new StreamWriter(@Path.Combine(screen.ThemePath, screen.ThemeName + "_test.xml"));
|
||||
Type[] screens = { typeof(CScreenHighscore), typeof(CScreenLoad), typeof(CScreenMain), typeof(CScreenNames), typeof(CScreenOptions),
|
||||
typeof(CScreenOptionsGame), typeof(CScreenOptionsLyrics), typeof(CScreenOptionsRecord), typeof(CScreenOptionsSound),
|
||||
typeof(CScreenOptionsTheme), typeof(CScreenOptionsVideo), typeof(CScreenOptionsVideoAdjustments), typeof(CScreenParty),
|
||||
typeof(CScreenPartyDummy), typeof(CScreenProfiles), typeof(CScreenScore), typeof(CScreenSing), typeof(CScreenSong) };
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(CMenu), screens);
|
||||
serializer.Serialize(textWriter, screen);
|
||||
}
|
||||
|
||||
foreach (IMenu popup in _PopupScreens)
|
||||
popup.SaveTheme();
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
}
|
||||
|
||||
class CScreenCredits : CMenu
|
||||
public class CScreenCredits : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -27,7 +27,7 @@ using VocaluxeLib.Songs;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenHighscore : CMenu
|
||||
public class CScreenHighscore : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -23,7 +23,7 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenLoad : CMenu
|
||||
public class CScreenLoad : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -22,7 +22,7 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenMain : CMenu
|
||||
public class CScreenMain : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -27,7 +27,7 @@ using VocaluxeLib.Profile;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenNames : CMenu
|
||||
public class CScreenNames : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -22,7 +22,7 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenOptions : CMenu
|
||||
public class CScreenOptions : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -22,7 +22,7 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenOptionsGame : CMenu
|
||||
public class CScreenOptionsGame : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -22,7 +22,7 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenOptionsLyrics : CMenu
|
||||
public class CScreenOptionsLyrics : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -25,7 +25,7 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenOptionsRecord : CMenu
|
||||
public class CScreenOptionsRecord : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -22,7 +22,7 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenOptionsSound : CMenu
|
||||
public class CScreenOptionsSound : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -23,7 +23,7 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenOptionsTheme : CMenu
|
||||
public class CScreenOptionsTheme : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -25,7 +25,7 @@ using VocaluxeLib.Draw;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenOptionsVideo : CMenu
|
||||
public class CScreenOptionsVideo : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -22,7 +22,7 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenOptionsVideoAdjustments : CMenu
|
||||
public class CScreenOptionsVideoAdjustments : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -23,7 +23,7 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenParty : CMenu
|
||||
public class CScreenParty : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Vocaluxe.Screens
|
||||
PlayerName
|
||||
}
|
||||
|
||||
class CScreenProfiles : CMenu
|
||||
public class CScreenProfiles : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -28,7 +28,7 @@ using VocaluxeLib.Songs;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenScore : CMenu
|
||||
public class CScreenScore : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -31,7 +31,7 @@ using VocaluxeLib.Songs;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenSing : CMenu
|
||||
public class CScreenSing : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
@@ -29,7 +29,7 @@ using VocaluxeLib.Songs;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenSong : CMenu
|
||||
public class CScreenSong : CMenu
|
||||
{
|
||||
private enum ESongOptionsView
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
class CScreenTest : CMenu
|
||||
public class CScreenTest : CMenu
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
|
||||
+203
-7
@@ -34,55 +34,251 @@ namespace VocaluxeLib.Menu
|
||||
public float Z;
|
||||
}
|
||||
|
||||
[XmlType("Screen")]
|
||||
public abstract class CMenu : IMenu
|
||||
{
|
||||
[XmlIgnore]
|
||||
private List<CInteraction> _Interactions;
|
||||
[XmlIgnore]
|
||||
private int _Selection;
|
||||
private string _ThemePath = String.Empty;
|
||||
[XmlIgnore]
|
||||
public string ThemePath { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected int _PartyModeID = -1;
|
||||
|
||||
[XmlIgnore]
|
||||
private int _PrevMouseX;
|
||||
[XmlIgnore]
|
||||
private int _PrevMouseY;
|
||||
|
||||
[XmlIgnore]
|
||||
private int _MouseDX;
|
||||
[XmlIgnore]
|
||||
private int _MouseDY;
|
||||
|
||||
[XmlIgnore]
|
||||
protected bool _Active;
|
||||
|
||||
[XmlElement("ScreenVersion")]
|
||||
protected abstract int _ScreenVersion { get; }
|
||||
public string ThemeName { get; private set; }
|
||||
[XmlAttributeAttribute(AttributeName = "Name")]
|
||||
public string ThemeName { get; set; }
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeBackgrounds;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeStatics;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeTexts;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeButtons;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeSongMenus;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeLyrics;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeSelectSlides;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeSingNotes;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeNameSelections;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeEqualizers;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemePlaylists;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeParticleEffects;
|
||||
[XmlIgnore]
|
||||
protected string[] _ThemeScreenSettings;
|
||||
|
||||
[XmlArray("Backgrounds")]
|
||||
public List<SThemeBackground> ThemeBackgrounds
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemeBackground> list = new List<SThemeBackground>();
|
||||
foreach (CBackground el in _Backgrounds)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("Statics")]
|
||||
public List<SThemeStatic> ThemeStatics
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemeStatic> list = new List<SThemeStatic>();
|
||||
foreach (CStatic el in _Statics)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("Texts")]
|
||||
public List<SThemeText> ThemeTexts
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemeText> list = new List<SThemeText>();
|
||||
foreach (CText el in _Texts)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("Buttons")]
|
||||
public List<SThemeButton> ThemeButtons
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemeButton> list = new List<SThemeButton>();
|
||||
foreach (CButton el in _Buttons)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("SongMenus")]
|
||||
public List<SThemeSongMenu> ThemeSongMenus
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemeSongMenu> list = new List<SThemeSongMenu>();
|
||||
foreach (CSongMenu el in _SongMenus)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("Lyrics")]
|
||||
public List<SThemeLyrics> ThemeLyrics
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemeLyrics> list = new List<SThemeLyrics>();
|
||||
foreach (CLyric el in _Lyrics)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("SelectSlides")]
|
||||
public List<SThemeSelectSlide> ThemeSelectSlides
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemeSelectSlide> list = new List<SThemeSelectSlide>();
|
||||
foreach (CSelectSlide el in _SelectSlides)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("SingNotes")]
|
||||
public List<SThemeSingBar> ThemeSingNotes
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemeSingBar> list = new List<SThemeSingBar>();
|
||||
foreach (CSingNotes el in _SingNotes)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("NameSelections")]
|
||||
public List<SThemeNameSelection> ThemeNameSelections
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemeNameSelection> list = new List<SThemeNameSelection>();
|
||||
foreach (CNameSelection el in _NameSelections)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("Equalizers")]
|
||||
public List<SThemeEqualizer> ThemeEqualizers
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemeEqualizer> list = new List<SThemeEqualizer>();
|
||||
foreach (CEqualizer el in _Equalizers)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("Playlists")]
|
||||
public List<SThemePlaylist> ThemePlaylists
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemePlaylist> list = new List<SThemePlaylist>();
|
||||
foreach (CPlaylist el in _Playlists)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("ParticleEffects")]
|
||||
public List<SThemeParticleEffect> ThemeParticleEffects
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SThemeParticleEffect> list = new List<SThemeParticleEffect>();
|
||||
foreach (CParticleEffect el in _ParticleEffects)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlArray("ScreenSettings")]
|
||||
public List<SScreenSetting> ThemeScreenSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SScreenSetting> list = new List<SScreenSetting>();
|
||||
foreach (CScreenSetting el in _ScreenSettings)
|
||||
if (el.ThemeLoaded)
|
||||
list.Add(el.GetTheme());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CButton> _Buttons { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CText> _Texts { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CBackground> _Backgrounds { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CStatic> _Statics { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CSelectSlide> _SelectSlides { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CSongMenu> _SongMenus { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CLyric> _Lyrics { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CSingNotes> _SingNotes { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CNameSelection> _NameSelections { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CEqualizer> _Equalizers { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CPlaylist> _Playlists { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CParticleEffect> _ParticleEffects { get; private set; }
|
||||
[XmlIgnore]
|
||||
protected COrderedDictionaryLite<CScreenSetting> _ScreenSettings { get; private set; }
|
||||
// ReSharper restore MemberCanBePrivate.Global
|
||||
|
||||
[XmlIgnore]
|
||||
protected SRectF _ScreenArea;
|
||||
[XmlIgnore]
|
||||
public SRectF ScreenArea
|
||||
{
|
||||
get { return _ScreenArea; }
|
||||
@@ -172,7 +368,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (versionCheck && skinIndex != -1)
|
||||
{
|
||||
_ThemePath = xmlPath;
|
||||
ThemePath = xmlPath;
|
||||
_LoadThemeBasics(xmlReader, skinIndex);
|
||||
|
||||
_LoadThemeElement<CBackground>(_ThemeBackgrounds, _AddBackground, xmlReader, skinIndex);
|
||||
@@ -193,11 +389,11 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public virtual void SaveTheme()
|
||||
{
|
||||
if (_ThemePath == "")
|
||||
if (ThemePath == "")
|
||||
return;
|
||||
|
||||
|
||||
string file = Path.Combine(_ThemePath, ThemeName + ".xml");
|
||||
string file = Path.Combine(ThemePath, ThemeName + ".xml");
|
||||
using (XmlWriter writer = XmlWriter.Create(file, CBase.Config.GetXMLSettings()))
|
||||
{
|
||||
writer.WriteStartDocument();
|
||||
@@ -270,7 +466,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
|
||||
//This is only test-stuff and will be removed later
|
||||
TextWriter textWriter = new StreamWriter(@Path.Combine(_ThemePath, ThemeName + "_test.xml"));
|
||||
TextWriter textWriter = new StreamWriter(@Path.Combine(ThemePath, ThemeName + "_test.xml"));
|
||||
|
||||
//Backgrounds
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(List<SThemeBackground>));
|
||||
@@ -465,7 +661,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public virtual void ReloadTheme(string xmlPath)
|
||||
{
|
||||
if (_ThemePath == "")
|
||||
if (ThemePath == "")
|
||||
return;
|
||||
|
||||
UnloadTextures();
|
||||
|
||||
Reference in new issue
Block a user