Removed outdated xml loading stuff

This commit is contained in:
Florian Küpper committed 2017-09-02 18:00:06 +02:00
1 parent f48e6862b1
commit c5bfd46865
24 files changed
-1215

No files matched your search

-3
View File
@@ -105,9 +105,6 @@ or from the console:
load playlist from this path.
Example:
Vocaluxe.exe -PlaylistFolder D:\MyPlaylists
-OldTheme yes : Try to load theme that is created for vocaluxe 0.2 or older (or some pre-release version of 0.3). Enter theme editor and save your theme to convert every file to new syntax. This will be removed in a future version.
Complete example:
Vocaluxe.exe -ConfigFile MyConfig.xml -ScoreFile C:\Vocaluxe\Highscores\MyHighscoreDB.sqlite -SongFolder D:\MySongCollection -PlaylistFolder D:\MyPlaylists
-6
View File
@@ -187,7 +187,6 @@ namespace Vocaluxe.Base
}
public static SConfig Config;
public static bool LoadOldThemeFiles;
public static event OnSongMenuChanged SongMenuChanged;
//Folders
@@ -710,11 +709,6 @@ namespace Vocaluxe.Base
ProfileFolders.Clear();
ProfileFolders.Add(value);
break;
case "oldtheme":
if (value == "yes")
LoadOldThemeFiles = true;
break;
}
}
}
-5
View File
@@ -156,11 +156,6 @@ namespace Vocaluxe.Base
return CConfig.GetMaxNumMics();
}
public bool GetLoadOldThemeFiles()
{
return CConfig.LoadOldThemeFiles;
}
public void AddSongMenuListener(OnSongMenuChanged onSongMenuChanged)
{
CConfig.SongMenuChanged += onSongMenuChanged;
-1
View File
@@ -61,7 +61,6 @@ namespace VocaluxeLib
bool IsMicConfigured(int playerNr);
int GetMaxNumMics();
bool GetLoadOldThemeFiles();
void AddSongMenuListener(OnSongMenuChanged onSongMenuChanged);
void RemoveSongMenuListener(OnSongMenuChanged onSongMenuChanged);
}
-46
View File
@@ -20,7 +20,6 @@ using System.Xml.Serialization;
using System.Diagnostics;
using System.Collections.Generic;
using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -88,51 +87,6 @@ namespace VocaluxeLib.Menu
#endregion Constructors
#region public
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Type", ref _Theme.Type);
bool vid = xmlReader.GetValue(item + "/Video", out _Theme.VideoName, String.Empty);
bool tex = xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
ThemeLoaded &= vid || tex || _Theme.Type == EBackgroundTypes.None;
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
bool success = true;
success &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
success &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
success &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
success &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
if (_Theme.Type != EBackgroundTypes.None)
ThemeLoaded &= success;
}
_Theme.Color.Color = Color;
int i = 1;
while (xmlReader.ItemExists(item + "/SlideShow" + i))
{
string slideShow;
xmlReader.GetValue(item + "/SlideShow" + i, out slideShow, String.Empty);
if (slideShow != "")
_Theme.SlideShowTextures.Add(slideShow);
i++;
}
if (ThemeLoaded)
{
_Theme.Name = elementName;
LoadSkin();
}
return ThemeLoaded;
}
public void Resume()
{
-88
View File
@@ -15,11 +15,9 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Diagnostics;
using System.Xml.Serialization;
using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -154,92 +152,6 @@ namespace VocaluxeLib.Menu
_SelReflectionSpace = button._SelReflectionSpace;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinSelected", out _Theme.SkinSelected, String.Empty);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
}
if (xmlReader.GetValue(item + "/SColor", out _Theme.SelColor.Name, String.Empty))
ThemeLoaded &= _Theme.SelColor.Get(_PartyModeID, out SelColor);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref SelColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref SelColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref SelColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref SelColor.A);
}
ThemeLoaded &= Text.LoadTheme(item, "Text", xmlReader, true);
Text.Z = Rect.Z;
if (xmlReader.ItemExists(item + "/SText"))
{
ThemeLoaded &= _SelText.LoadTheme(item, "SText", xmlReader, true);
_SelText.Z = Rect.Z;
}
else
_SelText = null;
//Reflections
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(_ReflectionHeight, _ReflectionSpace);
}
else
{
_Reflection = false;
_Theme.Reflection = null;
}
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(_SelReflectionHeight, _SelReflectionSpace);
}
else
{
_SelReflection = false;
_Theme.SelReflection = null;
}
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.Color.Color = Color;
_Theme.SelColor.Color = SelColor;
_ReadSubThemeElements();
LoadSkin();
}
return ThemeLoaded;
}
private void _ReadSubThemeElements()
{
_Theme.Text = (SThemeText)Text.GetTheme();
-68
View File
@@ -15,10 +15,8 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Diagnostics;
using System.Xml.Serialization;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -97,72 +95,6 @@ namespace VocaluxeLib.Menu
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/NumBars", ref _Theme.NumBars);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Space", ref _Theme.Space);
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Style", ref _Theme.Style);
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/DrawNegative", ref _Theme.DrawNegative);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
}
if (xmlReader.GetValue(item + "/MaxColor", out _Theme.MaxColor.Name, String.Empty))
ThemeLoaded &= _Theme.MaxColor.Get(_PartyModeID, out MaxColor);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxR", ref MaxColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxG", ref MaxColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxB", ref MaxColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxA", ref MaxColor.A);
}
//Reflection
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(ReflectionHeight, ReflectionSpace);
}
else
{
Reflection = false;
_Theme.Reflection = null;
}
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.Color.Color = Color;
_Theme.MaxColor.Color = MaxColor;
LoadSkin();
}
return ThemeLoaded;
}
public void Update(float[] weights, float volume)
{
if (weights == null || weights.Length == 0 || _Bars == null)
-42
View File
@@ -18,7 +18,6 @@
using System;
using System.Xml.Serialization;
using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -105,47 +104,6 @@ namespace VocaluxeLib.Menu
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out _Color);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _Color.A);
}
if (xmlReader.GetValue(item + "/SColor", out _Theme.ProcessedColor.Name, String.Empty))
ThemeLoaded &= _Theme.ProcessedColor.Get(_PartyModeID, out _ColorProcessed);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref _ColorProcessed.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref _ColorProcessed.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref _ColorProcessed.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref _ColorProcessed.A);
}
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.Color.Color = _Color;
_Theme.ProcessedColor.Color = _ColorProcessed;
LoadSkin();
}
return ThemeLoaded;
}
public void SetLine(CSongLine line)
{
_Line = line;
-136
View File
@@ -138,20 +138,6 @@ namespace VocaluxeLib.Menu
private delegate void AddElementHandler<in T>(T element, String key);
private void _LoadThemeElement<T>(IEnumerable<string> elements, AddElementHandler<T> addElementHandler, CXmlReader xmlReader) where T : IThemeable
{
if (elements != null)
{
foreach (string elName in elements)
{
var element = (T)Activator.CreateInstance(typeof(T), PartyModeID);
if (element.LoadTheme("//root/" + ThemeName, elName, xmlReader))
addElementHandler(element, elName);
else
CBase.Log.LogError("Can't load " + typeof(T).Name.Substring(1) + " \"" + elName + "\" in screen " + ThemeName);
}
}
}
private class CLoadThemeErrorHandler : CXmlDeserializer.CXmlDefaultErrorHandler
{
@@ -175,12 +161,6 @@ namespace VocaluxeLib.Menu
public virtual void LoadTheme(string xmlPath)
{
if (CBase.Config.GetLoadOldThemeFiles())
{
LoadThemeOld(xmlPath);
return;
}
ThemePath = xmlPath;
string file = Path.Combine(xmlPath, ThemeName + ".xml");
@@ -262,61 +242,6 @@ namespace VocaluxeLib.Menu
_ScreenSettings.Add(name, screenSetting);
}
public void LoadThemeOld(string xmlPath)
{
string file = Path.Combine(xmlPath, ThemeName + ".xml");
CXmlReader xmlReader = CXmlReader.OpenFile(file);
if (xmlReader == null)
return;
bool versionCheck = _CheckVersion(_ScreenVersion, xmlReader);
if (versionCheck)
{
ThemePath = xmlPath;
_LoadThemeBasics(xmlReader);
_LoadThemeElement<CBackground>(_ThemeBackgrounds, _AddBackground, xmlReader);
_LoadThemeElement<CStatic>(_ThemeStatics, _AddStatic, xmlReader);
_LoadThemeElement<CText>(_ThemeTexts, _AddText, xmlReader);
_LoadThemeElement<CButton>(_ThemeButtons, _AddButton, xmlReader);
_LoadThemeElement<CSelectSlide>(_ThemeSelectSlides, _AddSelectSlide, xmlReader);
foreach (string elName in _ThemeSongMenus)
{
ISongMenu element = CSongMenuFactory.CreateSongMenu(PartyModeID);
if (element.LoadTheme("//root/" + ThemeName, elName, xmlReader))
_AddSongMenu(element, elName);
else
CBase.Log.LogError("Can't load songmenu \"" + elName + "\" in screen " + ThemeName);
}
_LoadThemeElement<CSongMenuFramework>(_ThemeSongMenus, _AddSongMenu, xmlReader);
_LoadThemeElement<CLyric>(_ThemeLyrics, _AddLyric, xmlReader);
_LoadThemeElement<CSingNotes>(_ThemeSingNotes, _AddSingNote, xmlReader);
_LoadThemeElement<CNameSelection>(_ThemeNameSelections, _AddNameSelection, xmlReader);
_LoadThemeElement<CEqualizer>(_ThemeEqualizers, _AddEqualizer, xmlReader);
_LoadThemeElement<CPlaylist>(_ThemePlaylists, _AddPlaylist, xmlReader);
_LoadThemeElement<CParticleEffect>(_ThemeParticleEffects, _AddParticleEffect, xmlReader);
_LoadThemeElement<CScreenSetting>(_ThemeScreenSettings, _AddScreenSetting, xmlReader);
}
Theme.Informations.ScreenName = ThemeName;
Theme.Informations.ScreenVersion = _ScreenVersion;
Theme.Backgrounds = new List<SThemeBackground>();
Theme.Statics = new List<SThemeStatic>();
Theme.Texts = new List<SThemeText>();
Theme.Buttons = new List<SThemeButton>();
Theme.SongMenus = new List<SThemeSongMenu>();
Theme.Lyrics = new List<SThemeLyrics>();
Theme.SelectSlides = new List<SThemeSelectSlide>();
Theme.SingNotes = new List<SThemeSingBar>();
Theme.NameSelections = new List<SThemeNameSelection>();
Theme.Equalizers = new List<SThemeEqualizer>();
Theme.Playlists = new List<SThemePlaylist>();
Theme.ParticleEffects = new List<SThemeParticleEffect>();
Theme.ScreenSettings = new List<SThemeScreenSetting>();
}
private static void _AddThemeablesToList<T, TT>(ICollection<TT> themeList, IEnumerable<T> objects) where T : IThemeable
{
themeList.Clear();
@@ -536,67 +461,6 @@ namespace VocaluxeLib.Menu
}
#region Theme Handling
private bool _CheckVersion(int reqVersion, CXmlReader xmlReader)
{
int actualVersion = 0;
xmlReader.TryGetIntValue("//root/" + ThemeName + "/ScreenVersion", ref actualVersion);
if (actualVersion == reqVersion)
return true;
string msg = "Can't load screen file of screen \"" + ThemeName + "\", ";
if (actualVersion < reqVersion)
msg += "the file ist outdated! ";
else
msg += "the file is for newer program versions! ";
msg += "Current screen version is " + reqVersion;
CBase.Log.LogError(msg);
return false;
}
private void _LoadThemeBasics(CXmlReader xmlReader)
{
// Backgrounds
var background = new CBackground(PartyModeID);
int i = 1;
while (background.LoadTheme("//root/" + ThemeName, "Background" + i, xmlReader))
{
_AddBackground(background);
background = new CBackground(PartyModeID);
i++;
}
// Statics
var stat = new CStatic(PartyModeID);
i = 1;
while (stat.LoadTheme("//root/" + ThemeName, "Static" + i, xmlReader))
{
_AddStatic(stat);
stat = new CStatic(PartyModeID);
i++;
}
// Texts
var text = new CText(PartyModeID);
i = 1;
while (text.LoadTheme("//root/" + ThemeName, "Text" + i, xmlReader))
{
_AddText(text);
text = new CText(PartyModeID);
i++;
}
// ParticleEffects
var partef = new CParticleEffect(PartyModeID);
i = 1;
while (partef.LoadTheme("//root/" + ThemeName, "ParticleEffect" + i, xmlReader))
{
_AddParticleEffect(partef);
partef = new CParticleEffect(PartyModeID);
i++;
}
}
private void _ReloadThemeEditMode()
{
CBase.Themes.Reload();
-60
View File
@@ -15,13 +15,11 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml.Serialization;
using VocaluxeLib.Draw;
using VocaluxeLib.Profile;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -152,64 +150,6 @@ namespace VocaluxeLib.Menu
UpdateList(0);
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinEmptyTile", out _Theme.SkinEmptyTile, String.Empty);
if (xmlReader.GetValue(item + "/ColorEmptyTile", out _Theme.ColorEmptyTile.Name, String.Empty))
ThemeLoaded &= _Theme.ColorEmptyTile.Get(_PartyModeID, out _ColorEmptyTile);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _ColorEmptyTile.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _ColorEmptyTile.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _ColorEmptyTile.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _ColorEmptyTile.A);
}
ThemeLoaded &= xmlReader.GetValue(item + "/SkinTileSelected", out _Theme.SkinTileSelected, String.Empty);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/W", ref _Theme.Tiles.W);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/H", ref _Theme.Tiles.H);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/NumW", ref _Theme.Tiles.NumW);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/NumH", ref _Theme.Tiles.NumH);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/SpaceW", ref _Theme.Tiles.SpaceW);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/SpaceH", ref _Theme.Tiles.SpaceH);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/Space", ref _Theme.Tiles.Name.Space);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/H", ref _Theme.Tiles.Name.Height);
ThemeLoaded &= xmlReader.GetValue(item + "/Tiles/Name/Font", out _Theme.Tiles.Name.Font, "Normal");
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Tiles/Name/Style", ref _Theme.Tiles.Name.Style);
if (xmlReader.GetValue(item + "/Tiles/Name/Color", out _Theme.Tiles.Name.Color.Name, String.Empty))
ThemeLoaded &= _Theme.Tiles.Name.Color.Get(_PartyModeID, out _ColorNameTile);
else
{
if (xmlReader.TryGetFloatValue(item + "/Tiles/Name/R", ref _ColorNameTile.R))
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/G", ref _ColorNameTile.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/B", ref _ColorNameTile.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/A", ref _ColorNameTile.A);
}
}
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.Tiles.Name.Color.Color = _ColorNameTile;
_Theme.ColorEmptyTile.Color = _ColorEmptyTile;
LoadSkin();
}
return ThemeLoaded;
}
public void Draw()
{
int i = 0;
-37
View File
@@ -20,7 +20,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Serialization;
using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -127,42 +126,6 @@ namespace VocaluxeLib.Menu
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
}
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Type", ref _Theme.Type);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Size", ref _Theme.Size);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/MaxNumber", ref _Theme.MaxNumber);
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.Color.Color = Color;
LoadSkin();
}
return ThemeLoaded;
}
public void Update()
{
bool doSpawn = false;
-62
View File
@@ -20,7 +20,6 @@ using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml.Serialization;
using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -270,67 +269,6 @@ namespace VocaluxeLib.Menu
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackground", out _Theme.SkinBackground, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundSelected", out _Theme.SkinBackgroundSelected, String.Empty);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/ColorBackground", out _Theme.ColorBackground.Name, String.Empty))
ThemeLoaded &= _Theme.ColorBackground.Get(_PartyModeID, out _BackgroundColor);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundR", ref _BackgroundColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundG", ref _BackgroundColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundB", ref _BackgroundColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundA", ref _BackgroundColor.A);
}
if (xmlReader.GetValue(item + "/SColorBackground", out _Theme.SelColorBackground.Name, String.Empty))
ThemeLoaded &= _Theme.SelColorBackground.Get(_PartyModeID, out _BackgroundSelColor);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundR", ref _BackgroundSelColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundG", ref _BackgroundSelColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundB", ref _BackgroundSelColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundA", ref _BackgroundSelColor.A);
}
ThemeLoaded &= _Text1.LoadTheme(item, "TextPart1", xmlReader);
CStatic tmpStatic = new CStatic(_PartyModeID);
ThemeLoaded &= tmpStatic.LoadTheme(item, "StaticCover", xmlReader);
ThemeLoaded &= _StaticPlaylistHeader.LoadTheme(item, "StaticPlaylistHeader", xmlReader);
ThemeLoaded &= _StaticPlaylistFooter.LoadTheme(item, "StaticPlaylistFooter", xmlReader);
ThemeLoaded &= _ButtonPlaylistName.LoadTheme(item, "ButtonPlaylistName", xmlReader);
ThemeLoaded &= _ButtonPlaylistSing.LoadTheme(item, "ButtonPlaylistSing", xmlReader);
ThemeLoaded &= _ButtonPlaylistClose.LoadTheme(item, "ButtonPlaylistClose", xmlReader);
ThemeLoaded &= _ButtonPlaylistSave.LoadTheme(item, "ButtonPlaylistSave", xmlReader);
ThemeLoaded &= _ButtonPlaylistDelete.LoadTheme(item, "ButtonPlaylistDelete", xmlReader);
ThemeLoaded &= _SelectSlideGameMode.LoadTheme(item, "SelectSlideGameMode", xmlReader);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/EntryHeight", ref _Theme.EntryHeight);
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.ColorBackground.Color = _BackgroundColor;
_Theme.SelColorBackground.Color = _BackgroundSelColor;
_Theme.StaticCover = (SThemeStatic)tmpStatic.GetTheme();
_ReadSubThemeElements();
LoadSkin();
}
return ThemeLoaded;
}
private void _ReadSubThemeElements()
{
_Theme.Text1 = (SThemeText)_Text1.GetTheme();
-14
View File
@@ -18,7 +18,6 @@
using System;
using System.Xml.Serialization;
using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -71,19 +70,6 @@ namespace VocaluxeLib.Menu
_Theme = theme;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
_ThemeLoaded &= xmlReader.GetValue(item + "/Value", out _Theme.Value, String.Empty);
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Type", ref _Theme.Type);
if (_ThemeLoaded)
_Theme.Name = elementName;
return _ThemeLoaded;
}
public object GetValue()
{
switch (_Theme.Type)
-117
View File
@@ -22,7 +22,6 @@ using System.Diagnostics;
using System.Drawing;
using System.Xml.Serialization;
using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -270,122 +269,6 @@ namespace VocaluxeLib.Menu
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowLeft", out _Theme.SkinArrowLeft, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowRight", out _Theme.SkinArrowRight, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinSelected", out _Theme.SkinSelected, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowLeftSelected", out _Theme.SkinArrowLeftSelected, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowRightSelected", out _Theme.SkinArrowRightSelected, String.Empty);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out _Color);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _Color.A);
}
if (xmlReader.GetValue(item + "/SColor", out _Theme.SelColor.Name, String.Empty))
ThemeLoaded &= _Theme.SelColor.Get(_PartyModeID, out _SelColor);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref _SelColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref _SelColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref _SelColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref _SelColor.A);
}
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftX", ref RectArrowLeft.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftY", ref RectArrowLeft.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftZ", ref RectArrowLeft.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftW", ref RectArrowLeft.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftH", ref RectArrowLeft.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightX", ref RectArrowRight.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightY", ref RectArrowRight.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightZ", ref RectArrowRight.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightW", ref RectArrowRight.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightH", ref RectArrowRight.H);
if (xmlReader.GetValue(item + "/ArrowColor", out _Theme.ArrowColor.Name, String.Empty))
ThemeLoaded &= _Theme.ArrowColor.Get(_PartyModeID, out _ColorArrow);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowR", ref _ColorArrow.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowG", ref _ColorArrow.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowB", ref _ColorArrow.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowA", ref _ColorArrow.A);
}
if (xmlReader.GetValue(item + "/ArrowSColor", out _Theme.ArrowSelColor.Name, String.Empty))
ThemeLoaded &= _Theme.ArrowSelColor.Get(_PartyModeID, out _SelColorArrow);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSR", ref _SelColorArrow.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSG", ref _SelColorArrow.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSB", ref _SelColorArrow.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSA", ref _SelColorArrow.A);
}
if (xmlReader.GetValue(item + "/TextColor", out _Theme.TextColor.Name, String.Empty))
ThemeLoaded &= _Theme.TextColor.Get(_PartyModeID, out _TextColor);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextR", ref _TextColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextG", ref _TextColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextB", ref _TextColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextA", ref _TextColor.A);
}
if (xmlReader.GetValue(item + "/TextSColor", out _Theme.TextSelColor.Name, String.Empty))
ThemeLoaded &= _Theme.TextSelColor.Get(_PartyModeID, out _SelTextColor);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSR", ref _SelTextColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSG", ref _SelTextColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSB", ref _SelTextColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSA", ref _SelTextColor.A);
}
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextH", ref _Theme.TextH);
xmlReader.TryGetFloatValue(item + "/TextRelativeX", ref _Theme.TextRelativeX);
xmlReader.TryGetFloatValue(item + "/TextRelativeY", ref _Theme.TextRelativeY);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextMaxW", ref _Theme.TextMaxW);
ThemeLoaded &= xmlReader.GetValue(item + "/TextFont", out _Theme.TextFont, "Normal");
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/TextStyle", ref _Theme.TextStyle);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/NumVisible", ref _Theme.NumVisible);
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.ArrowColor.Color = _ColorArrow;
_Theme.ArrowSelColor.Color = _SelColorArrow;
_Theme.Color.Color = _Color;
_Theme.RectArrowLeft = RectArrowLeft;
_Theme.RectArrowRight = RectArrowRight;
_Theme.SelColor.Color = _SelColor;
_Theme.TextColor.Color = _TextColor;
_Theme.TextSelColor.Color = _SelTextColor;
LoadSkin();
}
return ThemeLoaded;
}
private void _Invalidate()
{
_NeedsRevalidate = true;
-48
View File
@@ -15,11 +15,9 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Diagnostics;
using System.Xml.Serialization;
using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -113,52 +111,6 @@ namespace VocaluxeLib.Menu
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
}
_Theme.Color.Color = 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(ReflectionHeight, ReflectionSpace);
}
else
{
Reflection = false;
_Theme.Reflection = null;
}
if (ThemeLoaded)
{
_Theme.Name = elementName;
LoadSkin();
}
return ThemeLoaded;
}
public void Draw()
{
Draw(Aspect);
-74
View File
@@ -18,7 +18,6 @@
using System;
using System.Drawing;
using System.Xml.Serialization;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -294,79 +293,6 @@ namespace VocaluxeLib.Menu
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
return LoadTheme(xmlPath, elementName, xmlReader, false);
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader, bool buttonText)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Y);
if (!buttonText)
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Z);
xmlReader.TryGetFloatValue(item + "/MaxW", ref _Theme.MaxWidth);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
}
if (xmlReader.GetValue(item + "/SColor", out _Theme.SelColor.Name, String.Empty))
ThemeLoaded &= _Theme.SelColor.Get(_PartyModeID, out SelColor);
else
{
if (xmlReader.TryGetFloatValue(item + "/SR", ref SelColor.R))
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref SelColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref SelColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref SelColor.A);
}
}
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Align", ref _Align);
xmlReader.TryGetEnumValue(item + "/ResizeAlign", ref _ResizeAlign);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.FontHeight);
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Style", ref _Theme.FontStyle);
ThemeLoaded &= xmlReader.GetValue(item + "/Font", out _Theme.FontFamily);
ThemeLoaded &= xmlReader.GetValue(item + "/Text", out _Theme.Text);
if (xmlReader.ItemExists(item + "/Reflection") && !buttonText)
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref _ReflectionSpace);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref _ReflectionHeight);
_Theme.Reflection = new SReflection(_ReflectionHeight, _ReflectionSpace);
}
else
_Theme.Reflection = null;
// Set values
_Theme.Name = elementName;
_Theme.Align = _Align;
_Theme.Color.Color = Color;
_Theme.ResizeAlign = _ResizeAlign;
_Theme.SelColor.Color = SelColor;
_ButtonText = buttonText;
_PositionNeedsUpdate = true;
if (ThemeLoaded)
LoadSkin();
return ThemeLoaded;
}
public void Draw()
{
_Draw(false);
-2
View File
@@ -25,8 +25,6 @@ namespace VocaluxeLib.Menu
object GetTheme();
bool ThemeLoaded { get; }
bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader);
void UnloadSkin();
void LoadSkin();
void ReloadSkin();
-46
View File
@@ -20,7 +20,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Xml.Serialization;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu.SingNotes
{
@@ -101,51 +100,6 @@ namespace VocaluxeLib.Menu.SingNotes
public bool ThemeLoaded { get; private set; }
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.GetValue(item + "/SkinLeft", out _Theme.SkinLeft, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinMiddle", out _Theme.SkinMiddle, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinRight", out _Theme.SkinRight, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundLeft", out _Theme.SkinBackgroundLeft, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundMiddle", out _Theme.SkinBackgroundMiddle, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundRight", out _Theme.SkinBackgroundRight, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinGoldenStar", out _Theme.SkinGoldenStar, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinToneHelper", out _Theme.SkinToneHelper, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinPerfectNoteStar", out _Theme.SkinPerfectNoteStart, String.Empty);
int i = 0;
_BarPos = new SRectF[CBase.Settings.GetMaxNumPlayer(),CBase.Settings.GetMaxNumPlayer()];
for (int numplayer = 0; numplayer < CBase.Settings.GetMaxNumPlayer(); numplayer++)
{
for (int player = 0; player <= numplayer; player++)
{
_BarPos[player, numplayer] = new SRectF();
string target = "/BarPositions/P" + (player + 1) + "N" + (numplayer + 1);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "X", ref _BarPos[player, numplayer].X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Y", ref _BarPos[player, numplayer].Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Z", ref _BarPos[player, numplayer].Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "W", ref _BarPos[player, numplayer].W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "H", ref _BarPos[player, numplayer].H);
_Theme.BarPos[i].Name = "P" + (player + 1) + "N" + (numplayer + 1);
_Theme.BarPos[i].Rect = _BarPos[player, numplayer];
i++;
}
}
if (ThemeLoaded)
{
_Theme.Name = elementName;
LoadSkin();
}
return ThemeLoaded;
}
public void Init(int numPlayers)
{
PlayerNotes.Clear();
@@ -15,12 +15,10 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Diagnostics;
using System.Xml.Serialization;
using VocaluxeLib.PartyModes;
using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu.SongMenu
{
@@ -201,80 +199,6 @@ namespace VocaluxeLib.Menu.SongMenu
{
return _Theme;
}
public virtual bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
ThemeLoaded = true;
ThemeLoaded &= xmlReader.GetValue(item + "/CoverBackground", out _Theme.CoverBackground, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/CoverBigBackground", out _Theme.CoverBigBackground, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/DuetIcon", out _Theme.DuetIcon, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/VideoIcon", out _Theme.VideoIcon, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/MedleyCalcIcon", out _Theme.MedleyCalcIcon, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/MedleyTagIcon", out _Theme.MedleyTagIcon, String.Empty);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out _ColorInternal);
else
{
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _ColorInternal.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _ColorInternal.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _ColorInternal.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _ColorInternal.A);
}
_Theme.Color.Color = _ColorInternal;
#region SongMenuTileBoard
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumW", ref _Theme.SongMenuTileBoard.NumW);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumH", ref _Theme.SongMenuTileBoard.NumH);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/SpaceW", ref _Theme.SongMenuTileBoard.SpaceW);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/SpaceH", ref _Theme.SongMenuTileBoard.SpaceH);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumWsmall", ref _Theme.SongMenuTileBoard.NumWsmall);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumHsmall", ref _Theme.SongMenuTileBoard.NumHsmall);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectX", ref _Theme.SongMenuTileBoard.TileRect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectY", ref _Theme.SongMenuTileBoard.TileRect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectZ", ref _Theme.SongMenuTileBoard.TileRect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectW", ref _Theme.SongMenuTileBoard.TileRect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectH", ref _Theme.SongMenuTileBoard.TileRect.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallX", ref _Theme.SongMenuTileBoard.TileRectSmall.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallY", ref _Theme.SongMenuTileBoard.TileRectSmall.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallZ", ref _Theme.SongMenuTileBoard.TileRectSmall.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallW", ref _Theme.SongMenuTileBoard.TileRectSmall.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallH", ref _Theme.SongMenuTileBoard.TileRectSmall.H);
#endregion SongMenuTileBoard
#region SongMenuList
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuList/ListLength", ref _Theme.SongMenuList.ListLength);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/SpaceW", ref _Theme.SongMenuList.SpaceW);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/SpaceH", ref _Theme.SongMenuList.SpaceH);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRect/X", ref _Theme.SongMenuList.TileRect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRect/Y", ref _Theme.SongMenuList.TileRect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRect/Z", ref _Theme.SongMenuList.TileRect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRect/W", ref _Theme.SongMenuList.TileRect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRect/H", ref _Theme.SongMenuList.TileRect.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectSmall/X", ref _Theme.SongMenuList.TileRectSmall.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectSmall/Y", ref _Theme.SongMenuList.TileRectSmall.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectSmall/Z", ref _Theme.SongMenuList.TileRectSmall.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectSmall/W", ref _Theme.SongMenuList.TileRectSmall.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectSmall/H", ref _Theme.SongMenuList.TileRectSmall.H);
#endregion SongMenuList
if (ThemeLoaded)
{
_Theme.Name = elementName;
LoadSkin();
Init();
}
return ThemeLoaded;
}
#endregion Theme
public virtual void Init()
@@ -22,7 +22,6 @@ using System.Windows.Forms;
using VocaluxeLib.Draw;
using VocaluxeLib.PartyModes;
using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu.SongMenu
{
@@ -128,39 +127,6 @@ namespace VocaluxeLib.Menu.SongMenu
_SubElements.AddRange(new IMenuElement[] {_Artist, _Title, _SongLength, _DuetIcon, _VideoIcon, _MedleyCalcIcon, _MedleyTagIcon});
}
public override bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
bool themeLoaded = true;
themeLoaded &= base.LoadTheme(xmlPath, elementName, xmlReader);
themeLoaded &= _Artist.LoadTheme(item + "/SongMenuList", "TextArtist", xmlReader);
themeLoaded &= _Title.LoadTheme(item + "/SongMenuList", "TextTitle", xmlReader);
themeLoaded &= _SongLength.LoadTheme(item + "/SongMenuList", "TextSongLength", xmlReader);
themeLoaded &= _CoverBig.LoadTheme(item + "/SongMenuList", "StaticCoverBig", xmlReader);
themeLoaded &= _TextBG.LoadTheme(item + "/SongMenuList", "StaticTextBG", xmlReader);
themeLoaded &= _DuetIcon.LoadTheme(item + "/SongMenuList", "StaticDuetIcon", xmlReader);
themeLoaded &= _VideoIcon.LoadTheme(item + "/SongMenuList", "StaticVideoIcon", xmlReader);
themeLoaded &= _MedleyCalcIcon.LoadTheme(item + "/SongMenuList", "StaticMedleyCalcIcon", xmlReader);
themeLoaded &= _MedleyTagIcon.LoadTheme(item + "/SongMenuList", "StaticMedleyTagIcon", xmlReader);
if (themeLoaded)
{
_Theme.Name = elementName;
_ReadSubTheme();
_SubElements.Clear();
_SubElements.AddRange(new IMenuElement[] { _Artist, _Title, _SongLength, _DuetIcon, _VideoIcon, _MedleyCalcIcon, _MedleyTagIcon });
LoadSkin();
Init();
}
return themeLoaded;
}
private void _ReadSubTheme()
{
_Theme.SongMenuList.TextArtist = (SThemeText)_Artist.GetTheme();
@@ -132,39 +132,6 @@ namespace VocaluxeLib.Menu.SongMenu
_Tiles[tileNr].Selected = true;
}
public override bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
bool themeLoaded = true;
themeLoaded &= base.LoadTheme(xmlPath, elementName, xmlReader);
themeLoaded &= _Artist.LoadTheme(item + "/SongMenuTileBoard", "TextArtist", xmlReader);
themeLoaded &= _Title.LoadTheme(item + "/SongMenuTileBoard", "TextTitle", xmlReader);
themeLoaded &= _SongLength.LoadTheme(item + "/SongMenuTileBoard", "TextSongLength", xmlReader);
themeLoaded &= _CoverBig.LoadTheme(item + "/SongMenuTileBoard", "StaticCoverBig", xmlReader);
themeLoaded &= _TextBG.LoadTheme(item + "/SongMenuTileBoard", "StaticTextBG", xmlReader);
themeLoaded &= _DuetIcon.LoadTheme(item + "/SongMenuTileBoard", "StaticDuetIcon", xmlReader);
themeLoaded &= _VideoIcon.LoadTheme(item + "/SongMenuTileBoard", "StaticVideoIcon", xmlReader);
themeLoaded &= _MedleyCalcIcon.LoadTheme(item + "/SongMenuTileBoard", "StaticMedleyCalcIcon", xmlReader);
themeLoaded &= _MedleyTagIcon.LoadTheme(item + "/SongMenuTileBoard", "StaticMedleyTagIcon", xmlReader);
if (themeLoaded)
{
_Theme.Name = elementName;
_ReadSubTheme();
_SubElements.Clear();
_SubElements.AddRange(new IMenuElement[] {_Artist, _Title, _SongLength, _DuetIcon, _VideoIcon, _MedleyCalcIcon, _MedleyTagIcon});
LoadSkin();
Init();
}
return themeLoaded;
}
private void _ReadSubTheme()
{
_Theme.SongMenuTileBoard.TextArtist = (SThemeText)_Artist.GetTheme();
-2
View File
@@ -114,8 +114,6 @@
<Compile Include="XmlStructs.cs" />
<Compile Include="Xml\CTypeExtensions.cs" />
<Compile Include="Xml\CXmlDeserializer.cs" />
<Compile Include="Xml\CXMLReader.cs" />
<Compile Include="Xml\CXmlReaderBase.cs" />
<Compile Include="Xml\CXmlSerializer.cs" />
<Compile Include="Enums.cs" />
<Compile Include="Menu\IMenu.cs" />
-137
View File
@@ -1,137 +0,0 @@
#region license
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Collections.Generic;
using System.Xml.XPath;
namespace VocaluxeLib.Xml
{
public class CXmlReader : CXmlReaderBase
{
private readonly XPathNavigator _Navigator;
private readonly String _FilePath;
public string FilePath
{
get { return _FilePath; }
}
//Private method. Use OpenFile factory method to get an instance
private CXmlReader(string uri)
{
_FilePath = uri;
var xmlDoc = new XPathDocument(uri);
_Navigator = xmlDoc.CreateNavigator();
}
public XPathNavigator Navigator
{
get { return _Navigator; }
}
public static CXmlReader OpenFile(string fileName)
{
try
{
return new CXmlReader(fileName);
}
catch (Exception e)
{
CBase.Log.LogError("Can't open XML file: " + fileName + ": " + e.Message);
return null;
}
}
public override bool GetValue(string xPath, out string value, string defaultValue = "")
{
int resultCt = 0;
string val = string.Empty;
_Navigator.MoveToRoot();
XPathNodeIterator iterator = _Navigator.Select(xPath);
while (iterator.MoveNext())
{
val = iterator.Current.Value;
resultCt++;
}
if (resultCt != 1)
{
value = defaultValue;
return false;
}
value = val;
return true;
}
public override bool GetAttribute(string xPath, string attribute, out string value)
{
_Navigator.MoveToRoot();
XPathNodeIterator iterator = _Navigator.Select(xPath);
if (iterator.MoveNext())
{
value = iterator.Current.GetAttribute(attribute, "");
return true;
}
value = null;
return false;
}
public List<string> GetNames(string xPath)
{
var values = new List<string>();
_Navigator.MoveToRoot();
XPathNodeIterator iterator = _Navigator.Select(xPath);
while (iterator.MoveNext())
values.Add(iterator.Current.LocalName);
return values;
}
public IEnumerable<string> GetAttributes(string xPath, string attribute)
{
var values = new List<string>();
_Navigator.MoveToRoot();
XPathNodeIterator iterator = _Navigator.Select(xPath);
while (iterator.MoveNext())
values.Add(iterator.Current.GetAttribute(attribute, ""));
return values;
}
public bool GetValues(string xPath, ref List<string> values)
{
_Navigator.MoveToRoot();
XPathNodeIterator iterator = _Navigator.Select(xPath);
while (iterator.MoveNext())
values.Add(iterator.Current.Value);
return true;
}
public bool ItemExists(string xPath)
{
_Navigator.MoveToRoot();
return _Navigator.Select(xPath).MoveNext();
}
}
}
-78
View File
@@ -1,78 +0,0 @@
#region license
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
namespace VocaluxeLib.Xml
{
/// <summary>
/// Base class that provides basic methods for reading xml, while the actual XML implementation is still abstract to allow different implementations
/// </summary>
public abstract class CXmlReaderBase
{
public abstract bool GetValue(string xPath, out string value, string defaultValue = "");
public abstract bool GetAttribute(string xPath, string attribute, out string value);
public bool TryGetBoolValue(string xPath, out bool value, bool defaultValue = false)
{
value = defaultValue;
string val;
return GetValue(xPath, out val) && bool.TryParse(val, out value);
}
public bool TryGetIntValue(string xPath, ref int value, int? defaultValue = null)
{
string val;
bool ok = GetValue(xPath, out val) && int.TryParse(val, out value);
if (!ok && defaultValue.HasValue)
value = defaultValue.Value;
return ok;
}
public bool TryGetFloatValue(string xPath, ref float value)
{
string val;
return GetValue(xPath, out val, value.ToString()) && CHelper.TryParse(val, out value);
}
public bool TryGetEnumValue<T>(string xPath, ref T value) where T : struct
{
string val;
return GetValue(xPath, out val, Enum.GetName(typeof(T), value)) && CHelper.TryParse(val, out value, true);
}
public bool TryGetIntValueRange(string xPath, ref int value, int min = 0, int max = 100)
{
return TryGetIntValue(xPath, ref value) && value.IsInRange(min, max);
}
/// <summary>
/// Gets a normalized (0&lt;=x&lt;=1) float value
/// </summary>
/// <param name="xPath"></param>
/// <param name="value"></param>
/// <param name="defaultValue"></param>
/// <returns>True if exists and is normalized</returns>
public bool TryGetNormalizedFloatValue(string xPath, ref float value, float defaultValue = 0)
{
bool ok = TryGetFloatValue(xPath, ref value) && value.IsInRange(0f, 1f);
if (!ok)
value = defaultValue;
return ok;
}
}
}