Introduce example for a more flexible deserialization

Also make the CoverGenerator themes serializeable
Rest is automatic reformatting.
This commit is contained in:
Flamefire committed 2014-10-01 00:54:04 +02:00
1 parent 467b619f0a
commit 6ebbf7df6f
33 files changed
+428 -397

No files matched your search

+31 -27
View File
@@ -5,37 +5,41 @@
<Folder>Blue</Folder> <Folder>Blue</Folder>
<Author>flokuep</Author> <Author>flokuep</Author>
</Info> </Info>
<MissingCover> <!--Cover definitions when a category is missing a cover-->
<!--Cover definitions when a category is missing a cover--> <CoverGenerator1>
<!--Possible types are: Default, Artist, Letter, Edition, Genre, Language, Year, Decade, Date --> <!--Possible types are: Default, Artist, Letter, Edition, Genre, Language, Year, Decade, Date -->
<Default> <Type>Default</Type>
<Text> <Text>
<!--<Text>: Text to be shown, %TEXT% will be replace by the category name--> <!--<Text>: Text to be shown, %TEXT% will be replace by the category name-->
<Text>%TEXT%</Text> <Text>%TEXT%</Text>
<!--<Font>: Text font name--> <Font>
<Font>Outline</Font> <Name>Normal</Name>
<!--<Style>: Text style: Normal, Italic, Bold, BoldItalic--> <!--<Style>: Text style: Normal, Italic, Bold, BoldItalic-->
<Style>Bold</Style> <Style>Bold</Style>
<!--<Size> Maximum size of the text in px--> <!--<Size> Maximum size of the text in px-->
<Size>500</Size> <Size>500</Size>
<!--<Color>: Text color from ColorScheme (high priority)--> </Font>
<!--or <R>, <G>, <B>, <A> (lower priority)--> <!--<Color>: Text color from ColorScheme (high priority)-->
<!--or <R>, <G>, <B>, <A> (lower priority)-->
<Color>
<R>1</R><G>1</G><B>1</B><A>0.8</A> <R>1</R><G>1</G><B>1</B><A>0.8</A>
<!--<Margin>: Spacing of the text from the borders of the image in px--> </Color>
<Margin>24</Margin> <!--<Margin>: Spacing of the text from the borders of the image in px-->
<MarginLeft>24</MarginLeft> <Margin>
<!--<Indent>: Indentation of the text for multiple lines--> <Default>24</Default>
<Indent>100</Indent> <Left>24</Left>
</Text> </Margin>
<Background> <!--<Indent>: Indentation of the text for multiple lines-->
<R>1</R><G>1</G><B>1</B><A>1</A> <Indent>100</Indent>
</Background> </Text>
<!--<Image>: Background image for the cover--> <BackgroundColor>
<Image>EmptyCover.png</Image> <R>1</R><G>1</G><B>1</B><A>1</A>
<!--<ShowFirstCover>Whether the first cover of a category should be shown(optional)--> </BackgroundColor>
<ShowFirstCover>true</ShowFirstCover> <!--<Image>: Background image for the cover-->
<!--<ImageAlpha>Alpha value of the image in case the first cover is shown(optional)--> <Image>EmptyCover.png</Image>
<ImageAlpha>0.75</ImageAlpha> <!--<ShowFirstCover>Whether the first cover of a category should be shown(optional)-->
</Default> <ShowFirstCover>true</ShowFirstCover>
</MissingCover> <!--<ImageAlpha>Alpha value of the image in case the first cover is shown(optional)-->
<ImageAlpha>0.75</ImageAlpha>
</CoverGenerator1>
</root> </root>
+2 -1
View File
@@ -28,6 +28,7 @@ using Vocaluxe.Lib.Sound.Record;
using Vocaluxe.Lib.Webcam; using Vocaluxe.Lib.Webcam;
using VocaluxeLib; using VocaluxeLib;
using VocaluxeLib.Profile; using VocaluxeLib.Profile;
using VocaluxeLib.Xml;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
@@ -840,7 +841,7 @@ namespace Vocaluxe.Base
break; break;
case "oldtheme": case "oldtheme":
if(value == "yes") if (value == "yes")
LoadOldThemeFiles = true; LoadOldThemeFiles = true;
break; break;
} }
+42 -40
View File
@@ -23,24 +23,23 @@ using System.Threading.Tasks;
using VocaluxeLib; using VocaluxeLib;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Songs; using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
struct SCoverTheme struct SThemeCover
{ {
public string Name; public string Name, Folder;
public string Folder; public string FilePath;
public string File;
} }
static class CCover static class CCover
{ {
private const string _NoCoverName = "No Cover"; private const string _NoCoverName = "No Cover";
private const string _NoCoverNameAlt = "NoCover"; private const string _NoCoverNameAlt = "NoCover";
private const string _DefaultTypeName = "Default";
private static readonly Dictionary<string, CTextureRef> _Covers = new Dictionary<string, CTextureRef>(); private static readonly Dictionary<string, CTextureRef> _Covers = new Dictionary<string, CTextureRef>();
private static readonly Dictionary<string, CNoCoverGenerator> _NoCoverThemes = new Dictionary<string, CNoCoverGenerator>(); private static readonly Dictionary<ECoverGeneratorType, CNoCoverGenerator> _NoCoverGenerators = new Dictionary<ECoverGeneratorType, CNoCoverGenerator>();
private static readonly List<SCoverTheme> _CoverThemes = new List<SCoverTheme>(); private static readonly List<SThemeCover> _CoverThemes = new List<SThemeCover>();
public static CTextureRef NoCover { get; private set; } public static CTextureRef NoCover { get; private set; }
@@ -105,9 +104,10 @@ namespace Vocaluxe.Base
CTextureRef texture = CDraw.CopyTexture(NoCover); CTextureRef texture = CDraw.CopyTexture(NoCover);
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
Bitmap coverBmp = _NoCoverThemes[_SongSortingToType(sorting)].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null); ECoverGeneratorType type = _SongSortingToType(sorting);
if (coverBmp == null) Bitmap coverBmp = !_NoCoverGenerators.ContainsKey(type)?null:_NoCoverGenerators[type].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null);
coverBmp = _NoCoverThemes[_DefaultTypeName].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null); if (coverBmp == null && _NoCoverGenerators.ContainsKey(ECoverGeneratorType.Default))
coverBmp = _NoCoverGenerators[ECoverGeneratorType.Default].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null);
if (coverBmp != null) if (coverBmp != null)
CDraw.EnqueueTextureUpdate(texture, coverBmp); CDraw.EnqueueTextureUpdate(texture, coverBmp);
}); });
@@ -147,23 +147,23 @@ namespace Vocaluxe.Base
} }
_Covers.Clear(); _Covers.Clear();
} }
lock (_NoCoverThemes) lock (_NoCoverGenerators)
{ {
_NoCoverThemes.Clear(); _NoCoverGenerators.Clear();
} }
} }
/// <summary> /// <summary>
/// Returns a SCoverTheme by cover-theme-name /// Returns a SCoverTheme by cover-theme-name
/// </summary> /// </summary>
private static SCoverTheme _CoverTheme(string coverThemeName) private static SThemeCover _CoverTheme(string coverThemeName)
{ {
for (int i = 0; i < _CoverThemes.Count; i++) for (int i = 0; i < _CoverThemes.Count; i++)
{ {
if (_CoverThemes[i].Name == coverThemeName) if (_CoverThemes[i].Name == coverThemeName)
return _CoverThemes[i]; return _CoverThemes[i];
} }
return new SCoverTheme(); return new SThemeCover();
} }
/// <summary> /// <summary>
@@ -182,14 +182,14 @@ namespace Vocaluxe.Base
if (xmlReader != null) if (xmlReader != null)
{ {
var coverTheme = new SCoverTheme(); var coverTheme = new SThemeCover();
xmlReader.GetValue("//root/Info/Name", out coverTheme.Name, String.Empty); xmlReader.GetValue("//root/Info/Name", out coverTheme.Name, String.Empty);
xmlReader.GetValue("//root/Info/Folder", out coverTheme.Folder, String.Empty); xmlReader.GetValue("//root/Info/Folder", out coverTheme.Folder, String.Empty);
if (coverTheme.Folder != "" && coverTheme.Name != "") if (coverTheme.Folder != "" && coverTheme.Name != "")
{ {
coverTheme.File = file; coverTheme.FilePath = xmlReader.FilePath;
_CoverThemes.Add(coverTheme); _CoverThemes.Add(coverTheme);
} }
@@ -202,7 +202,7 @@ namespace Vocaluxe.Base
/// </summary> /// </summary>
private static void _LoadCovers(string coverThemeName) private static void _LoadCovers(string coverThemeName)
{ {
SCoverTheme coverTheme = _CoverTheme(coverThemeName); SThemeCover coverTheme = _CoverTheme(coverThemeName);
if (String.IsNullOrEmpty(coverTheme.Name)) if (String.IsNullOrEmpty(coverTheme.Name))
return; return;
@@ -224,51 +224,53 @@ namespace Vocaluxe.Base
_LoadNoCoverThemes(coverTheme); _LoadNoCoverThemes(coverTheme);
} }
private static string _SongSortingToType(ESongSorting sorting) private static ECoverGeneratorType _SongSortingToType(ESongSorting sorting)
{ {
switch (sorting) switch (sorting)
{ {
case ESongSorting.TR_CONFIG_NONE: case ESongSorting.TR_CONFIG_NONE:
return _DefaultTypeName; return ECoverGeneratorType.Default;
case ESongSorting.TR_CONFIG_FOLDER: case ESongSorting.TR_CONFIG_FOLDER:
return "Folder"; return ECoverGeneratorType.Folder;
case ESongSorting.TR_CONFIG_ARTIST: case ESongSorting.TR_CONFIG_ARTIST:
return "Artist"; return ECoverGeneratorType.Artist;
case ESongSorting.TR_CONFIG_ARTIST_LETTER: case ESongSorting.TR_CONFIG_ARTIST_LETTER:
case ESongSorting.TR_CONFIG_TITLE_LETTER: case ESongSorting.TR_CONFIG_TITLE_LETTER:
return "Letter"; return ECoverGeneratorType.Letter;
case ESongSorting.TR_CONFIG_EDITION: case ESongSorting.TR_CONFIG_EDITION:
return "Edition"; return ECoverGeneratorType.Edition;
case ESongSorting.TR_CONFIG_GENRE: case ESongSorting.TR_CONFIG_GENRE:
return "Genre"; return ECoverGeneratorType.Genre;
case ESongSorting.TR_CONFIG_LANGUAGE: case ESongSorting.TR_CONFIG_LANGUAGE:
return "Language"; return ECoverGeneratorType.Language;
case ESongSorting.TR_CONFIG_YEAR: case ESongSorting.TR_CONFIG_YEAR:
return "Year"; return ECoverGeneratorType.Year;
case ESongSorting.TR_CONFIG_DECADE: case ESongSorting.TR_CONFIG_DECADE:
return "Decade"; return ECoverGeneratorType.Decade;
case ESongSorting.TR_CONFIG_DATEADDED: case ESongSorting.TR_CONFIG_DATEADDED:
return "Date"; return ECoverGeneratorType.Date;
default: default:
throw new ArgumentOutOfRangeException("sorting"); throw new ArgumentOutOfRangeException("sorting");
} }
} }
private static void _LoadNoCoverThemes(SCoverTheme coverTheme) private static void _LoadNoCoverThemes(SThemeCover coverTheme)
{ {
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.File)); CXMLReader xmlReader = CXMLReader.OpenFile(coverTheme.FilePath);
List<String> types = new List<string>();
foreach (ESongSorting sorting in Enum.GetValues(typeof(ESongSorting)))
types.Add(_SongSortingToType(sorting));
string coverPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder); string coverPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder);
lock (_NoCoverThemes) lock (_NoCoverGenerators)
{ {
foreach (string type in types) int i = 1;
{ while(xmlReader.ItemExists("//root/CoverGenerator"+i)){
if (_NoCoverThemes.ContainsKey(type)) SThemeCoverGenerator theme;
continue; if (xmlReader.Read("//root/CoverGenerator" + i, out theme))
CNoCoverGenerator el = new CNoCoverGenerator(xmlReader, "//root/MissingCover/" + type, coverPath); {
_NoCoverThemes.Add(type, el); if (_NoCoverGenerators.ContainsKey(theme.Type))
continue;
CNoCoverGenerator el = new CNoCoverGenerator(theme, coverPath);
_NoCoverGenerators.Add(theme.Type, el);
}
i++;
} }
} }
} }
+1
View File
@@ -20,6 +20,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using VocaluxeLib; using VocaluxeLib;
using VocaluxeLib.Xml;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
+23 -70
View File
@@ -36,20 +36,10 @@ namespace Vocaluxe.Base
class CNoCoverGenerator class CNoCoverGenerator
{ {
private readonly bool _Valid; private readonly bool _Valid;
private readonly string _Text; private readonly SThemeCoverGenerator _Theme;
private readonly SColorF _BGColor;
private readonly SColorF _TextColor;
private readonly int _TextMarginLeft;
private readonly int _TextMarginRight;
private readonly int _TextMarginTop;
private readonly int _TextMarginBottom;
private readonly int _TextIndent;
private readonly int _TextSize;
private readonly string _Font;
private readonly EStyle _Style;
private readonly string _Image; private readonly string _Image;
private readonly bool _ShowFirstCover; private readonly SColorF _TextColor;
private readonly float _ImageAlpha; private readonly SColorF _BGColor;
private const int _LineSpace = 5; private const int _LineSpace = 5;
/// <summary> /// <summary>
@@ -59,52 +49,15 @@ namespace Vocaluxe.Base
private static readonly char[] _SplitCharAfter = {':', '/', '-', ' ', ')', '.', '*', ','}; private static readonly char[] _SplitCharAfter = {':', '/', '-', ' ', ')', '.', '*', ','};
private static readonly char[] _SplitCharBefore = {'('}; private static readonly char[] _SplitCharBefore = {'('};
public CNoCoverGenerator(CXMLReader xmlReader, string xPath, string basePath) public CNoCoverGenerator(SThemeCoverGenerator theme, string basePath)
{ {
_Valid = xmlReader.ItemExists(xPath); _Theme = theme;
if (!_Valid) _Valid = true;
return; _Valid &= _Theme.Text.Color.Get(-1, out _TextColor);
_Valid &= xmlReader.GetValue(xPath + "/Text/Text", out _Text); _Valid &= _Theme.BackgroundColor.Get(-1, out _BGColor);
_Valid &= xmlReader.GetValue(xPath + "/Text/Font", out _Font);
_Valid &= xmlReader.TryGetEnumValue(xPath + "/Text/Style", ref _Style);
_Valid &= xmlReader.TryGetIntValue(xPath + "/Text/Size", ref _TextSize);
string colorName;
if (xmlReader.GetValue(xPath + "/Text/Color", out colorName))
_Valid &= CBase.Theme.GetColor(colorName, CBase.Theme.GetSkinIndex(-1), out _TextColor);
else
_Valid &= xmlReader.TryGetColorFromRGBA(xPath + "/Text", ref _TextColor);
int tmpMargin = 0;
bool marginSet = xmlReader.TryGetIntValue(xPath + "/Text/Margin", ref tmpMargin);
if (marginSet)
{
_TextMarginLeft = tmpMargin;
_TextMarginRight = tmpMargin;
_TextMarginTop = tmpMargin;
_TextMarginBottom = tmpMargin;
}
_Valid &= xmlReader.TryGetIntValue(xPath + "/Text/MarginLeft", ref _TextMarginLeft) || marginSet;
_Valid &= xmlReader.TryGetIntValue(xPath + "/Text/MarginRight", ref _TextMarginRight) || marginSet;
_Valid &= xmlReader.TryGetIntValue(xPath + "/Text/MarginTop", ref _TextMarginTop) || marginSet;
_Valid &= xmlReader.TryGetIntValue(xPath + "/Text/MarginBottom", ref _TextMarginBottom) || marginSet;
if (!xmlReader.TryGetIntValue(xPath + "/Text/Indent", ref _TextIndent))
_TextIndent = 6 * (_TextMarginLeft + _TextMarginRight) / 2;
if (xmlReader.GetValue(xPath + "/Background/Color", out colorName))
_Valid &= CBase.Theme.GetColor(colorName, CBase.Theme.GetSkinIndex(-1), out _BGColor);
else
_Valid &= xmlReader.TryGetColorFromRGBA(xPath + "/Background", ref _BGColor);
_Valid &= xmlReader.GetValue(xPath + "/Image", out _Image);
string tmp;
if (xmlReader.GetValue(xPath + "/ShowFirstCover", out tmp))
Boolean.TryParse(tmp, out _ShowFirstCover);
else
_ShowFirstCover = false;
_ImageAlpha = !xmlReader.TryGetFloatValue(xPath + "/ImageAlpha", ref _ImageAlpha) ? 0.5f : _ImageAlpha.Clamp(0f, 1f);
if (_Valid) if (_Valid)
{ {
// ReSharper disable AssignNullToNotNullAttribute _Image = Path.Combine(basePath, _Theme.Image);
_Image = Path.Combine(basePath, _Image);
// ReSharper restore AssignNullToNotNullAttribute
_Valid = File.Exists(_Image); _Valid = File.Exists(_Image);
} }
} }
@@ -153,11 +106,11 @@ namespace Vocaluxe.Base
g.Clear(_BGColor.AsColor()); g.Clear(_BGColor.AsColor());
ImageAttributes ia = null; ImageAttributes ia = null;
if (_ShowFirstCover && !String.IsNullOrEmpty(firstCoverPath) && File.Exists(firstCoverPath)) if (_Theme.ShowFirstCover && !String.IsNullOrEmpty(firstCoverPath) && File.Exists(firstCoverPath))
{ {
using (Bitmap bmp2 = new Bitmap(firstCoverPath)) using (Bitmap bmp2 = new Bitmap(firstCoverPath))
g.DrawImage(bmp2, bmpBackground.GetRect(), 0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel); g.DrawImage(bmp2, bmpBackground.GetRect(), 0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel);
ColorMatrix cm = new ColorMatrix {Matrix33 = _ImageAlpha}; ColorMatrix cm = new ColorMatrix {Matrix33 = _Theme.ImageAlpha};
ia = new ImageAttributes(); ia = new ImageAttributes();
ia.SetColorMatrix(cm); ia.SetColorMatrix(cm);
} }
@@ -182,7 +135,7 @@ namespace Vocaluxe.Base
{ {
pen.LineJoin = LineJoin.Round; pen.LineJoin = LineJoin.Round;
pen.Alignment = PenAlignment.Outset; pen.Alignment = PenAlignment.Outset;
float top = (bmpSize.Height - _TextMarginBottom - _TextMarginTop - maxHeight * lineCount) / 2 + _TextMarginTop; float top = (bmpSize.Height - _Theme.Text.Margin.Bottom - _Theme.Text.Margin.Top - maxHeight * lineCount) / 2 + _Theme.Text.Margin.Top;
int nextLineEl = 0; int nextLineEl = 0;
for (int i = 0; i < lineCount; i++) for (int i = 0; i < lineCount; i++)
{ {
@@ -199,16 +152,16 @@ namespace Vocaluxe.Base
{ {
//Center Text if this is the only line or the middle line //Center Text if this is the only line or the middle line
float width = _GetWidth(elements, firstEl, nextLineEl - 1); float width = _GetWidth(elements, firstEl, nextLineEl - 1);
left = (bmpSize.Width - _TextMarginLeft - _TextMarginRight - width) / 2 + _TextMarginLeft; left = (bmpSize.Width - _Theme.Text.Margin.Left - _Theme.Text.Margin.Right - width) / 2 + _Theme.Text.Margin.Left;
} }
else if (i == lineCount - 1) else if (i == lineCount - 1)
{ {
//Place last line at right //Place last line at right
float width = _GetWidth(elements, firstEl, nextLineEl - 1); float width = _GetWidth(elements, firstEl, nextLineEl - 1);
left = bmpSize.Width - width - _TextMarginRight; left = bmpSize.Width - width - _Theme.Text.Margin.Right;
} }
else else
left = _TextMarginLeft; left = _Theme.Text.Margin.Left;
//g.DrawString(line, fo, new SolidBrush(_TextColor.AsColor()), left, top, StringFormat.GenericTypographic); //g.DrawString(line, fo, new SolidBrush(_TextColor.AsColor()), left, top, StringFormat.GenericTypographic);
path.AddString(line, fo.FontFamily, (int)fo.Style, emSize, new PointF(left, top), StringFormat.GenericTypographic); path.AddString(line, fo.FontFamily, (int)fo.Style, emSize, new PointF(left, top), StringFormat.GenericTypographic);
top += maxHeight + _LineSpace; top += maxHeight + _LineSpace;
@@ -222,7 +175,7 @@ namespace Vocaluxe.Base
{ {
if (!_Valid) if (!_Valid)
return null; return null;
text = CLanguage.Translate(_Text.Replace("%TEXT%", text)); text = CLanguage.Translate(_Theme.Text.Text.Replace("%TEXT%", text));
using (Bitmap bmpImage = new Bitmap(_Image)) using (Bitmap bmpImage = new Bitmap(_Image))
{ {
Bitmap bmp = new Bitmap(bmpImage.Width, bmpImage.Height, PixelFormat.Format32bppArgb); Bitmap bmp = new Bitmap(bmpImage.Width, bmpImage.Height, PixelFormat.Format32bppArgb);
@@ -238,7 +191,7 @@ namespace Vocaluxe.Base
if (text != "") if (text != "")
{ {
CFont font = new CFont(_Font, _Style, bmp.Height - _TextMarginTop - _TextMarginBottom); CFont font = new CFont(_Theme.Text.Font);
Font fo = CFonts.GetSystemFont(font); Font fo = CFonts.GetSystemFont(font);
IEnumerable<string> textParts = _SplitText(text); IEnumerable<string> textParts = _SplitText(text);
List<CTextElement> elements = textParts.Select(line => new CTextElement(line, g, fo)).ToList(); List<CTextElement> elements = textParts.Select(line => new CTextElement(line, g, fo)).ToList();
@@ -269,14 +222,14 @@ namespace Vocaluxe.Base
/// <returns>Factor for resizing the text (Maximizing this factor means maximizing the height)</returns> /// <returns>Factor for resizing the text (Maximizing this factor means maximizing the height)</returns>
private float _DistributeText(List<CTextElement> elements, int width, int height) private float _DistributeText(List<CTextElement> elements, int width, int height)
{ {
int availableWidth = width - _TextMarginLeft - _TextMarginRight; int availableWidth = width - _Theme.Text.Margin.Left - _Theme.Text.Margin.Right;
int availableHeight = height - _TextMarginTop - _TextMarginBottom; int availableHeight = height - _Theme.Text.Margin.Top - _Theme.Text.Margin.Bottom;
float textHeight = elements.Select(el => el.Height).Max(); float textHeight = elements.Select(el => el.Height).Max();
//Try 1 line: //Try 1 line:
float textWidth = _GetWidth(elements, 0); float textWidth = _GetWidth(elements, 0);
int maxHeight = Math.Min(availableHeight, _TextSize); int maxHeight = Math.Min(availableHeight, (int)_Theme.Text.Font.Size);
float factorH = maxHeight / textHeight; float factorH = maxHeight / textHeight;
float factorW = availableWidth / textWidth; float factorW = availableWidth / textWidth;
if (factorH <= factorW) if (factorH <= factorW)
@@ -289,8 +242,8 @@ namespace Vocaluxe.Base
//Only 1 element -> 1 line //Only 1 element -> 1 line
return factor1; return factor1;
} }
availableWidth -= _TextIndent; availableWidth -= _Theme.Text.Indent;
maxHeight = Math.Min(availableHeight / 2 - _LineSpace, _TextSize); maxHeight = Math.Min(availableHeight / 2 - _LineSpace, (int)_Theme.Text.Font.Size);
factorH = maxHeight / textHeight; factorH = maxHeight / textHeight;
if (factorH <= factor1) if (factorH <= factor1)
return factor1; //Cannot get any bigger with more lines return factor1; //Cannot get any bigger with more lines
@@ -311,7 +264,7 @@ namespace Vocaluxe.Base
float factor2 = factorW; float factor2 = factorW;
//Try 3 lines //Try 3 lines
maxHeight = Math.Min(availableHeight / 3 - 2 * _LineSpace, _TextSize); maxHeight = Math.Min(availableHeight / 3 - 2 * _LineSpace, (int)_Theme.Text.Font.Size);
factorH = maxHeight / textHeight; factorH = maxHeight / textHeight;
if (elements.Count == 2 || factorH <= Math.Max(factor1, factor2)) if (elements.Count == 2 || factorH <= Math.Max(factor1, factor2))
{ {
+1 -1
View File
@@ -23,6 +23,7 @@ using System.Reflection;
using VocaluxeLib; using VocaluxeLib;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.PartyModes; using VocaluxeLib.PartyModes;
using VocaluxeLib.Xml;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
@@ -99,7 +100,6 @@ namespace Vocaluxe.Base
pair.Value.PartyMode.SaveScreens(); pair.Value.PartyMode.SaveScreens();
} }
public static List<SPartyModeInfos> GetPartyModeInfos() public static List<SPartyModeInfos> GetPartyModeInfos()
{ {
var infos = new List<SPartyModeInfos>(); var infos = new List<SPartyModeInfos>();
+1
View File
@@ -23,6 +23,7 @@ using System.Xml;
using Vocaluxe.Base.Fonts; using Vocaluxe.Base.Fonts;
using VocaluxeLib; using VocaluxeLib;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
+1
View File
@@ -24,6 +24,7 @@ using System.Linq;
using System.Xml; using System.Xml;
using VocaluxeLib; using VocaluxeLib;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Xml;
namespace Vocaluxe.Base.Fonts namespace Vocaluxe.Base.Fonts
{ {
+1
View File
@@ -24,6 +24,7 @@ using Vocaluxe.Base;
using VocaluxeLib; using VocaluxeLib;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Songs; using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace Vocaluxe.Lib.Playlist namespace Vocaluxe.Lib.Playlist
{ {
+10 -2
View File
@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml.Serialization;
namespace VocaluxeLib namespace VocaluxeLib
{ {
@@ -8,6 +9,13 @@ namespace VocaluxeLib
void FontChanged(); void FontChanged();
} }
public struct SThemeFont
{
public string Name;
public EStyle Style;
public float Size;
}
public class CFont public class CFont
{ {
private string _Name; private string _Name;
@@ -59,11 +67,11 @@ namespace VocaluxeLib
_Height = 25f; _Height = 25f;
} }
public CFont(CFont font) public CFont(SThemeFont font)
{ {
_Name = font.Name; _Name = font.Name;
_Style = font.Style; _Style = font.Style;
_Height = font.Height; _Height = font.Size;
} }
public CFont(string fontFamily, EStyle style, float h) public CFont(string fontFamily, EStyle style, float h)
+6 -10
View File
@@ -21,6 +21,7 @@ using System.Xml.Serialization;
using System.Diagnostics; using System.Diagnostics;
using System.Collections.Generic; using System.Collections.Generic;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
@@ -36,16 +37,11 @@ namespace VocaluxeLib.Menu
[XmlType("Background")] [XmlType("Background")]
public struct SThemeBackground public struct SThemeBackground
{ {
[XmlAttributeAttribute(AttributeName = "Name")] [XmlAttribute(AttributeName = "Name")] public string Name;
public string Name; [XmlElement("Type")] public EBackgroundTypes Type;
[XmlElement("Type")] [XmlArray] public List<string> SlideShowTextures;
public EBackgroundTypes Type; [XmlElement("Video")] public string VideoName;
[XmlArray] [XmlElement("Skin")] public string TextureName;
public List<string> SlideShowTextures;
[XmlElement("Video")]
public string VideoName;
[XmlElement("Skin")]
public string TextureName;
public SThemeColor Color; public SThemeColor Color;
} }
+10 -19
View File
@@ -19,33 +19,25 @@ using System;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
[XmlType("Button")] [XmlType("Button")]
public struct SThemeButton public struct SThemeButton
{ {
[XmlAttributeAttribute(AttributeName = "Name")] [XmlAttribute(AttributeName = "Name")] public string Name;
public string Name;
[XmlElement("Skin")] [XmlElement("Skin")] public string TextureName;
public string TextureName; [XmlElement("SkinSelected")] public string SelTextureName;
[XmlElement("SkinSelected")]
public string SelTextureName;
public SRectF Rect; public SRectF Rect;
[XmlElement("Color")] [XmlElement("Color")] public SThemeColor Color;
public SThemeColor Color; [XmlElement("SelColor")] public SThemeColor SelColor;
[XmlElement("SelColor")] [XmlElement("Text")] public SThemeText Text;
public SThemeColor SelColor; [XmlElement("SText")] public SThemeText SText;
[XmlElement("Text")]
public SThemeText Text;
[XmlElement("SText")]
public SThemeText SText;
public bool STextSpecified; public bool STextSpecified;
[XmlElement("Reflection")] [XmlElement("Reflection")] public SReflection Reflection;
public SReflection Reflection; [XmlElement("SelReflection")] public SReflection SelReflection;
[XmlElement("SelReflection")]
public SReflection SelReflection;
} }
public class CButton : IMenuElement public class CButton : IMenuElement
@@ -257,7 +249,6 @@ namespace VocaluxeLib.Menu
return _ThemeLoaded; return _ThemeLoaded;
} }
public void Draw(bool forceDraw = false) public void Draw(bool forceDraw = false)
{ {
if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme && !forceDraw) if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme && !forceDraw)
+12 -21
View File
@@ -18,6 +18,7 @@
using System; using System;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
@@ -29,30 +30,20 @@ namespace VocaluxeLib.Menu
[XmlType("Equalizer")] [XmlType("Equalizer")]
public struct SThemeEqualizer public struct SThemeEqualizer
{ {
[XmlAttributeAttribute(AttributeName = "Name")] [XmlAttribute(AttributeName = "Name")] public string Name;
public string Name;
[XmlElement("Skin")] [XmlElement("Skin")] public string TextureName;
public string TextureName;
[XmlElement("Rect")] [XmlElement("Rect")] public SRectF Rect;
public SRectF Rect;
[XmlElement("NumBars")] [XmlElement("NumBars")] public int NumBars;
public int NumBars; [XmlElement("Space")] public float Space;
[XmlElement("Space")] [XmlElement("Style")] public EEqualizerStyle Style;
public float Space; [XmlElement("DrawNegative")] public EOffOn DrawNegative;
[XmlElement("Style")]
public EEqualizerStyle Style;
[XmlElement("DrawNegative")]
public EOffOn DrawNegative;
[XmlElement("Color")] [XmlElement("Color")] public SThemeColor Color;
public SThemeColor Color; [XmlElement("MaxColor")] public SThemeColor MaxColor;
[XmlElement("MaxColor")] [XmlElement("Reflection")] public SReflection Reflection;
public SThemeColor MaxColor;
[XmlElement("Reflection")]
public SReflection Reflection;
} }
public class CEqualizer : IMenuElement public class CEqualizer : IMenuElement
@@ -273,7 +264,7 @@ namespace VocaluxeLib.Menu
Rect = _Theme.Rect; Rect = _Theme.Rect;
Space = _Theme.Space; Space = _Theme.Space;
Reflection = _Theme.Reflection.Enabled; Reflection = _Theme.Reflection.Enabled;
if(Reflection) if (Reflection)
{ {
ReflectionHeight = _Theme.Reflection.Height; ReflectionHeight = _Theme.Reflection.Height;
ReflectionSpace = _Theme.Reflection.Space; ReflectionSpace = _Theme.Reflection.Space;
+7 -10
View File
@@ -19,22 +19,19 @@ using System;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using VocaluxeLib.Songs; using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
[XmlType("Lyric")] [XmlType("Lyric")]
public struct SThemeLyrics public struct SThemeLyrics
{ {
[XmlAttributeAttribute(AttributeName = "Name")] [XmlAttribute(AttributeName = "Name")] public string Name;
public string Name;
[XmlElement("Rect")] [XmlElement("Rect")] public SRectF Rect;
public SRectF Rect;
[XmlElement("Color")] [XmlElement("Color")] public SThemeColor Color;
public SThemeColor Color; [XmlElement("SColor")] public SThemeColor SColor;
[XmlElement("SColor")]
public SThemeColor SColor;
} }
public class CLyric : IMenuElement public class CLyric : IMenuElement
@@ -192,7 +189,7 @@ namespace VocaluxeLib.Menu
private void _SetText(CSongNote note) private void _SetText(CSongNote note)
{ {
_Text.Text = note.Text; _Text.Text = note.Text;
_Text.Font.Style = (note.Type == ENoteType.Freestyle)? EStyle.BoldItalic:EStyle.Bold; _Text.Font.Style = (note.Type == ENoteType.Freestyle) ? EStyle.BoldItalic : EStyle.Bold;
} }
public void Clear() public void Clear()
@@ -338,7 +335,7 @@ namespace VocaluxeLib.Menu
float tz = _Text.Z; float tz = _Text.Z;
SRectF normalRect = _Text.Rect; SRectF normalRect = _Text.Rect;
_Text.Font.Height *= 1f+ p * 0.4f; _Text.Font.Height *= 1f + p * 0.4f;
_Text.X -= (_Text.Rect.W - normalRect.W) / 2f; _Text.X -= (_Text.Rect.W - normalRect.W) / 2f;
_Text.Y -= (_Text.Rect.H - normalRect.H) / 2f; _Text.Y -= (_Text.Rect.H - normalRect.H) / 2f;
_Text.Z -= 0.1f; _Text.Z -= 0.1f;
+1
View File
@@ -25,6 +25,7 @@ using System.Xml.Serialization;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Menu.SingNotes; using VocaluxeLib.Menu.SingNotes;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
+23 -39
View File
@@ -22,56 +22,39 @@ using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Profile; using VocaluxeLib.Profile;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
[XmlType("NameSelection")] [XmlType("NameSelection")]
public struct SThemeNameSelection public struct SThemeNameSelection
{ {
[XmlAttributeAttribute(AttributeName = "Name")] [XmlAttribute(AttributeName = "Name")] public string Name;
public string Name; [XmlElement("Rect")] public SRectF Rect;
[XmlElement("Rect")] [XmlElement("SkinEmptyTile")] public string TextureEmptyTileName;
public SRectF Rect; [XmlElement("ColorEmptyTile")] public SThemeColor ColorEmptyTile;
[XmlElement("SkinEmptyTile")] [XmlElement("SkinTileSelected")] public string TextureTileSelectedName;
public string TextureEmptyTileName; [XmlElement("Tiles")] public SThemeNameSelectionTiles Tiles;
[XmlElement("ColorEmptyTile")]
public SThemeColor ColorEmptyTile;
[XmlElement("SkinTileSelected")]
public string TextureTileSelectedName;
[XmlElement("Tiles")]
public SThemeNameSelectionTiles Tiles;
} }
public struct SThemeNameSelectionTiles public struct SThemeNameSelectionTiles
{ {
[XmlElement("W")] [XmlElement("W")] public int W;
public int W; [XmlElement("H")] public int H;
[XmlElement("H")] [XmlElement("NumW")] public int NumW;
public int H; [XmlElement("NumH")] public int NumH;
[XmlElement("NumW")] [XmlElement("SpaceW")] public float SpaceW;
public int NumW; [XmlElement("SpaceH")] public float SpaceH;
[XmlElement("NumH")] [XmlElement("Name")] public SThemeNameSelectionName Name;
public int NumH;
[XmlElement("SpaceW")]
public float SpaceW;
[XmlElement("SpaceH")]
public float SpaceH;
[XmlElement("Name")]
public SThemeNameSelectionName Name;
} }
public struct SThemeNameSelectionName public struct SThemeNameSelectionName
{ {
[XmlElement("Space")] [XmlElement("Space")] public float Space;
public float Space; [XmlElement("H")] public float Height;
[XmlElement("H")] [XmlElement("Font")] public string Font;
public float Height; [XmlElement("Style")] public EStyle Style;
[XmlElement("Font")] [XmlElement("Color")] public SThemeColor Color;
public string Font;
[XmlElement("Style")]
public EStyle Style;
[XmlElement("Color")]
public SThemeColor Color;
} }
public class CNameSelection : IMenuElement public class CNameSelection : IMenuElement
@@ -119,7 +102,6 @@ namespace VocaluxeLib.Menu
public SColorF ColorEmptyTile; public SColorF ColorEmptyTile;
public int Offset; public int Offset;
private int _ActualSelection = -1; private int _ActualSelection = -1;
public int Selection = -1; public int Selection = -1;
@@ -517,9 +499,11 @@ namespace VocaluxeLib.Menu
{ {
for (int j = 0; j < _Theme.Tiles.NumW; j++) for (int j = 0; j < _Theme.Tiles.NumW; j++)
{ {
var rect = new SRectF(Rect.X + j * (_Theme.Tiles.W + _Theme.Tiles.SpaceW), Rect.Y + i * (_Theme.Tiles.H + _Theme.Tiles.SpaceH), _Theme.Tiles.W, _Theme.Tiles.H, Rect.Z); var rect = new SRectF(Rect.X + j * (_Theme.Tiles.W + _Theme.Tiles.SpaceW), Rect.Y + i * (_Theme.Tiles.H + _Theme.Tiles.SpaceH), _Theme.Tiles.W, _Theme.Tiles.H,
Rect.Z);
var tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, ColorEmptyTile, rect) {Aspect = EAspect.Crop}; var tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, ColorEmptyTile, rect) {Aspect = EAspect.Crop};
var tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.Tiles.Name.Space, rect.Z, _Theme.Tiles.Name.Height, rect.W, EAlignment.Center, _Theme.Tiles.Name.Style, var tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.Tiles.Name.Space, rect.Z, _Theme.Tiles.Name.Height, rect.W, EAlignment.Center,
_Theme.Tiles.Name.Style,
_Theme.Tiles.Name.Font, _Theme.Tiles.Name.Color.Color, ""); _Theme.Tiles.Name.Font, _Theme.Tiles.Name.Color.Color, "");
_Tiles.Add(new CTile(tileStatic, tileText, -1)); _Tiles.Add(new CTile(tileStatic, tileText, -1));
} }
+8 -16
View File
@@ -21,27 +21,21 @@ using System.Diagnostics;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
[XmlType("ParticleEffect")] [XmlType("ParticleEffect")]
public struct SThemeParticleEffect public struct SThemeParticleEffect
{ {
[XmlAttributeAttribute(AttributeName = "Name")] [XmlAttribute(AttributeName = "Name")] public string Name;
public string Name;
[XmlElement("Skin")] [XmlElement("Skin")] public string TextureName;
public string TextureName; [XmlElement("Rect")] public SRectF Rect;
[XmlElement("Rect")] [XmlElement("Color")] public SThemeColor Color;
public SRectF Rect; [XmlElement("Type")] public EParticleType Type;
[XmlElement("Color")] [XmlElement("Size")] public float Size;
public SThemeColor Color; [XmlElement("MaxNumber")] public int MaxNumber;
[XmlElement("Type")]
public EParticleType Type;
[XmlElement("Size")]
public float Size;
[XmlElement("MaxNumber")]
public int MaxNumber;
} }
public enum EParticleType public enum EParticleType
@@ -159,8 +153,6 @@ namespace VocaluxeLib.Menu
_MaxAge = maxage; _MaxAge = maxage;
_Rotation = (float)(CBase.Game.GetRandomDouble() * 360.0); _Rotation = (float)(CBase.Game.GetRandomDouble() * 360.0);
} }
#endregion Constructors #endregion Constructors
public void Update() public void Update()
+25 -41
View File
@@ -21,6 +21,7 @@ using System.Windows.Forms;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using VocaluxeLib.Songs; using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
@@ -57,48 +58,31 @@ namespace VocaluxeLib.Menu
[XmlType("Playlist")] [XmlType("Playlist")]
public struct SThemePlaylist public struct SThemePlaylist
{ {
[XmlAttributeAttribute(AttributeName = "Name")] [XmlAttribute(AttributeName = "Name")] public string Name;
public string Name;
[XmlElement("Rect")] [XmlElement("Rect")] public SRectF Rect;
public SRectF Rect;
[XmlElement("EntryHeight")] [XmlElement("EntryHeight")] public float EntryHeight;
public float EntryHeight;
[XmlElement("SkinBackground")] [XmlElement("SkinBackground")] public string TextureBackgroundName;
public string TextureBackgroundName; [XmlElement("SkinBackgroundSelected")] public string SelTextureBackgroundName;
[XmlElement("SkinBackgroundSelected")]
public string SelTextureBackgroundName;
[XmlElement("ColorBackground")] [XmlElement("ColorBackground")] public SThemeColor ColorBackground;
public SThemeColor ColorBackground; [XmlElement("SColorBackground")] public SThemeColor SelColorBackground;
[XmlElement("SColorBackground")]
public SThemeColor SelColorBackground;
[XmlElement("Text1")] [XmlElement("Text1")] public SThemeText SText1;
public SThemeText SText1;
[XmlElement("StaticCover")] [XmlElement("StaticCover")] public SThemeStatic SStaticCover;
public SThemeStatic SStaticCover; [XmlElement("StaticPlaylistHeader")] public SThemeStatic SStaticPlaylistHeader;
[XmlElement("StaticPlaylistHeader")] [XmlElement("StaticPlaylistFooter")] public SThemeStatic SStaticPlaylistFooter;
public SThemeStatic SStaticPlaylistHeader;
[XmlElement("StaticPlaylistFooter")]
public SThemeStatic SStaticPlaylistFooter;
[XmlElement("ButtonPlaylistName")] [XmlElement("ButtonPlaylistName")] public SThemeButton SButtonPlaylistName;
public SThemeButton SButtonPlaylistName; [XmlElement("ButtonPlaylistClose")] public SThemeButton SButtonPlaylistClose;
[XmlElement("ButtonPlaylistClose")] [XmlElement("ButtonPlaylistSave")] public SThemeButton SButtonPlaylistSave;
public SThemeButton SButtonPlaylistClose; [XmlElement("ButtonPlaylistDelete")] public SThemeButton SButtonPlaylistDelete;
[XmlElement("ButtonPlaylistSave")] [XmlElement("ButtonPlaylistSing")] public SThemeButton SButtonPlaylistSing;
public SThemeButton SButtonPlaylistSave;
[XmlElement("ButtonPlaylistDelete")]
public SThemeButton SButtonPlaylistDelete;
[XmlElement("ButtonPlaylistSing")]
public SThemeButton SButtonPlaylistSing;
[XmlElement("SelectSlideGameMode")] [XmlElement("SelectSlideGameMode")] public SThemeSelectSlide SSelectSlideGameMode;
public SThemeSelectSlide SSelectSlideGameMode;
} }
public class CPlaylist : IMenuElement public class CPlaylist : IMenuElement
@@ -187,7 +171,7 @@ namespace VocaluxeLib.Menu
public SColorF BackgroundSelColor; public SColorF BackgroundSelColor;
public CButton ButtonPlaylistName; public CButton ButtonPlaylistName;
public CButton ButtonPlaylistClose; public CButton ButtonPlaylistClose;
public CButton ButtonPlaylistSave; public CButton ButtonPlaylistSave;
public CButton ButtonPlaylistDelete; public CButton ButtonPlaylistDelete;
public CButton ButtonPlaylistSing; public CButton ButtonPlaylistSing;
@@ -353,7 +337,7 @@ namespace VocaluxeLib.Menu
_ThemeLoaded &= ButtonPlaylistSave.LoadTheme(item, "ButtonPlaylistSave", xmlReader, skinIndex); _ThemeLoaded &= ButtonPlaylistSave.LoadTheme(item, "ButtonPlaylistSave", xmlReader, skinIndex);
_ThemeLoaded &= ButtonPlaylistDelete.LoadTheme(item, "ButtonPlaylistDelete", xmlReader, skinIndex); _ThemeLoaded &= ButtonPlaylistDelete.LoadTheme(item, "ButtonPlaylistDelete", xmlReader, skinIndex);
_ThemeLoaded &=SelectSlideGameMode.LoadTheme(item, "SelectSlideGameMode", xmlReader, skinIndex); _ThemeLoaded &= SelectSlideGameMode.LoadTheme(item, "SelectSlideGameMode", xmlReader, skinIndex);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/EntryHeight", ref _Theme.EntryHeight); _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/EntryHeight", ref _Theme.EntryHeight);
if (_ThemeLoaded) if (_ThemeLoaded)
@@ -366,11 +350,11 @@ namespace VocaluxeLib.Menu
_Theme.SStaticCover = StaticCover.GetTheme(); _Theme.SStaticCover = StaticCover.GetTheme();
_Theme.SStaticPlaylistFooter = StaticPlaylistFooter.GetTheme(); _Theme.SStaticPlaylistFooter = StaticPlaylistFooter.GetTheme();
_Theme.SStaticPlaylistHeader = StaticPlaylistHeader.GetTheme(); _Theme.SStaticPlaylistHeader = StaticPlaylistHeader.GetTheme();
_Theme.SButtonPlaylistName =ButtonPlaylistName.GetTheme(); _Theme.SButtonPlaylistName = ButtonPlaylistName.GetTheme();
_Theme.SButtonPlaylistSing =ButtonPlaylistSing.GetTheme(); _Theme.SButtonPlaylistSing = ButtonPlaylistSing.GetTheme();
_Theme.SButtonPlaylistClose =ButtonPlaylistClose.GetTheme(); _Theme.SButtonPlaylistClose = ButtonPlaylistClose.GetTheme();
_Theme.SButtonPlaylistSave =ButtonPlaylistSave.GetTheme(); _Theme.SButtonPlaylistSave = ButtonPlaylistSave.GetTheme();
_Theme.SButtonPlaylistDelete =ButtonPlaylistDelete.GetTheme(); _Theme.SButtonPlaylistDelete = ButtonPlaylistDelete.GetTheme();
LoadTextures(); LoadTextures();
} }
+4 -6
View File
@@ -19,6 +19,7 @@ using System;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
@@ -33,12 +34,9 @@ namespace VocaluxeLib.Menu
[XmlType("ScreenSetting")] [XmlType("ScreenSetting")]
public struct SScreenSetting public struct SScreenSetting
{ {
[XmlAttributeAttribute(AttributeName = "Name")] [XmlAttribute(AttributeName = "Name")] public string Name;
public string Name; [XmlElement("Value")] public string Value;
[XmlElement("Value")] [XmlElement("Type")] public ESettingType Type;
public string Value;
[XmlElement("Type")]
public ESettingType Type;
} }
// ReSharper disable ClassNeverInstantiated.Global // ReSharper disable ClassNeverInstantiated.Global
+1
View File
@@ -20,6 +20,7 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Xml.Serialization; using System.Xml.Serialization;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
+4 -8
View File
@@ -19,16 +19,15 @@ using System;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
[XmlType("Static")] [XmlType("Static")]
public struct SThemeStatic public struct SThemeStatic
{ {
[XmlAttributeAttribute(AttributeName = "Name")] [XmlAttribute(AttributeName = "Name")] public string Name;
public string Name; [XmlElement("Skin")] public string TextureName;
[XmlElement("Skin")]
public string TextureName;
public SThemeColor Color; public SThemeColor Color;
public SRectF Rect; public SRectF Rect;
public SReflection Reflection; public SReflection Reflection;
@@ -73,10 +72,7 @@ namespace VocaluxeLib.Menu
public EAspect Aspect = EAspect.Stretch; public EAspect Aspect = EAspect.Stretch;
public CStatic() public CStatic() {}
{
}
public CStatic(int partyModeID) public CStatic(int partyModeID)
{ {
+1
View File
@@ -18,6 +18,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Xml.Serialization; using System.Xml.Serialization;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
+1
View File
@@ -16,6 +16,7 @@
#endregion #endregion
using System.Xml; using System.Xml;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu namespace VocaluxeLib.Menu
{ {
+1
View File
@@ -21,6 +21,7 @@ using System.Diagnostics;
using System.Xml.Serialization; using System.Xml.Serialization;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Songs; using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu.SingNotes namespace VocaluxeLib.Menu.SingNotes
{ {
+1
View File
@@ -17,6 +17,7 @@
using System.Xml; using System.Xml;
using VocaluxeLib.PartyModes; using VocaluxeLib.PartyModes;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu.SongMenu namespace VocaluxeLib.Menu.SongMenu
{ {
+12 -39
View File
@@ -23,34 +23,26 @@ using System.Xml.Serialization;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.PartyModes; using VocaluxeLib.PartyModes;
using VocaluxeLib.Songs; using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu.SongMenu namespace VocaluxeLib.Menu.SongMenu
{ {
[XmlType("SongMenu")] [XmlType("SongMenu")]
public struct SThemeSongMenu public struct SThemeSongMenu
{ {
[XmlAttributeAttribute(AttributeName = "Name")] [XmlAttribute(AttributeName = "Name")] public string Name;
public string Name;
[XmlElement("CoverBackground")] [XmlElement("CoverBackground")] public string CoverBackgroundName;
public string CoverBackgroundName; [XmlElement("CoverBigBackground")] public string CoverBigBackgroundName;
[XmlElement("CoverBigBackground")] [XmlElement("DuetIcon")] public string DuetIconName;
public string CoverBigBackgroundName; [XmlElement("VideoIcon")] public string VideoIconName;
[XmlElement("DuetIcon")] [XmlElement("MedleyCalcIcon")] public string MedleyCalcIcon;
public string DuetIconName; [XmlElement("MedleyTagIcon")] public string MedleyTagIcon;
[XmlElement("VideoIcon")] [XmlElement("Color")] public SThemeColor Color;
public string VideoIconName;
[XmlElement("MedleyCalcIcon")]
public string MedleyCalcIcon;
[XmlElement("MedleyTagIcon")]
public string MedleyTagIcon;
[XmlElement("Color")]
public SThemeColor Color;
//public SThemeSongMenuBook songMenuBook; //public SThemeSongMenuBook songMenuBook;
//public SThemeSongMenuDreidel songMenuDreidel; //public SThemeSongMenuDreidel songMenuDreidel;
//public SThemeSongMenuList songMenuList; //public SThemeSongMenuList songMenuList;
[XmlElement("SongMenuTileBoard")]
public SThemeSongMenuTileBoard SongMenuTileBoard; public SThemeSongMenuTileBoard SongMenuTileBoard;
public SThemeSongMenu(SThemeSongMenu theme) public SThemeSongMenu(SThemeSongMenu theme)
@@ -69,65 +61,48 @@ namespace VocaluxeLib.Menu.SongMenu
public struct SThemeSongMenuTileBoard public struct SThemeSongMenuTileBoard
{ {
[XmlElement("NumW")]
/// <summary> /// <summary>
/// Number of tiles horizontal /// Number of tiles horizontal
/// </summary> /// </summary>
public int NumW; public int NumW;
[XmlElement("NumH")]
/// <summary> /// <summary>
/// Number of tiles vertical /// Number of tiles vertical
/// </summary> /// </summary>
public int NumH; public int NumH;
[XmlElement("NumWsmall")]
/// <summary> /// <summary>
/// Number of tiles horizontal in small-modus /// Number of tiles horizontal in small-modus
/// </summary> /// </summary>
public int NumWsmall; public int NumWsmall;
[XmlElement("NumHsmall")]
/// <summary> /// <summary>
/// Number of tiles vertical in small-modus /// Number of tiles vertical in small-modus
/// </summary> /// </summary>
public int NumHsmall; public int NumHsmall;
[XmlElement("SpaceW")]
/// <summary> /// <summary>
/// Space between tiles horizontal /// Space between tiles horizontal
/// </summary> /// </summary>
public float SpaceW; public float SpaceW;
[XmlElement("SpaceH")]
/// <summary> /// <summary>
/// Space between tiles vertical /// Space between tiles vertical
/// </summary> /// </summary>
public float SpaceH; public float SpaceH;
[XmlElement("TileRect")]
public SRectF TileRect; public SRectF TileRect;
[XmlElement("TileRectSmall")]
public SRectF TileRectSmall; public SRectF TileRectSmall;
[XmlElement("TextArtist")]
public SThemeText TextArtist; public SThemeText TextArtist;
[XmlElement("TextTitle")]
public SThemeText TextTitle; public SThemeText TextTitle;
[XmlElement("TextSongLength")]
public SThemeText TextSongLength; public SThemeText TextSongLength;
[XmlElement("StaticCoverBig")]
public SThemeStatic StaticCoverBig; public SThemeStatic StaticCoverBig;
[XmlElement("StaticTextBG")]
public SThemeStatic StaticTextBG; public SThemeStatic StaticTextBG;
[XmlElement("StaticDuetIcon")]
public SThemeStatic StaticDuetIcon; public SThemeStatic StaticDuetIcon;
[XmlElement("StaticVideoIcon")]
public SThemeStatic StaticVideoIcon; public SThemeStatic StaticVideoIcon;
[XmlElement("StaticMedleyCalcIcon")]
public SThemeStatic StaticMedleyCalcIcon; public SThemeStatic StaticMedleyCalcIcon;
[XmlElement("StaticMedleyTagIcon")]
public SThemeStatic StaticMedleyTagIcon; public SThemeStatic StaticMedleyTagIcon;
} }
@@ -278,7 +253,6 @@ namespace VocaluxeLib.Menu.SongMenu
return _ThemeLoaded; return _ThemeLoaded;
} }
#endregion Theme #endregion Theme
public virtual void Init() public virtual void Init()
@@ -294,10 +268,10 @@ namespace VocaluxeLib.Menu.SongMenu
} }
public virtual void OnShow() {} public virtual void OnShow() {}
public virtual void OnHide() public virtual void OnHide()
{ {
if(CBase.Graphics.GetNextScreen() != EScreens.ScreenNames) if (CBase.Graphics.GetNextScreen() != EScreens.ScreenNames)
_ResetPreview(); _ResetPreview();
} }
@@ -373,7 +347,6 @@ namespace VocaluxeLib.Menu.SongMenu
_ColorInternal = CBase.Theme.GetColor(_Theme.Color.Name, _PartyModeID); _ColorInternal = CBase.Theme.GetColor(_Theme.Color.Name, _PartyModeID);
else else
_ColorInternal = _Theme.Color.Color; _ColorInternal = _Theme.Color.Color;
} }
public void ReloadTextures() public void ReloadTextures()
@@ -23,6 +23,7 @@ using System.Xml;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.PartyModes; using VocaluxeLib.PartyModes;
using VocaluxeLib.Songs; using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu.SongMenu namespace VocaluxeLib.Menu.SongMenu
{ {
+1
View File
@@ -18,6 +18,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Xml; using System.Xml;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Profile namespace VocaluxeLib.Profile
{ {
+48
View File
@@ -26,6 +26,44 @@ using VocaluxeLib.Songs;
namespace VocaluxeLib namespace VocaluxeLib
{ {
public enum ECoverGeneratorType
{
Default,
Folder,
Artist,
Letter,
Edition,
Genre,
Language,
Year,
Decade,
Date
}
public struct SMargin
{
public int Default;
public int Left, Right, Top, Bottom;
}
public struct SThemeCoverGeneratorText
{
public string Text;
public SThemeFont Font;
public SThemeColor Color;
public SMargin Margin;
public int Indent;
}
public struct SThemeCoverGenerator
{
public ECoverGeneratorType Type;
public SThemeCoverGeneratorText Text;
public SThemeColor BackgroundColor;
public string Image;
public float ImageAlpha;
public bool ShowFirstCover;
}
#region Drawing #region Drawing
public struct SColorF public struct SColorF
@@ -82,6 +120,16 @@ namespace VocaluxeLib
Color = new SColorF(theme.Color); Color = new SColorF(theme.Color);
Name = theme.Name; Name = theme.Name;
} }
public bool Get(int partyModeId, out SColorF color)
{
if (String.IsNullOrEmpty(Name))
{
color = Color;
return true;
}
return CBase.Theme.GetColor(Name, CBase.Theme.GetSkinIndex(partyModeId), out color);
}
} }
public struct SRectF public struct SRectF
+3 -1
View File
@@ -103,7 +103,8 @@
<Compile Include="Menu\CText.cs" /> <Compile Include="Menu\CText.cs" />
<Compile Include="Menu\CScreenSetting.cs" /> <Compile Include="Menu\CScreenSetting.cs" />
<Compile Include="Draw\CTextureRef.cs" /> <Compile Include="Draw\CTextureRef.cs" />
<Compile Include="CXMLReader.cs" /> <Compile Include="Xml\CXmlDeserializer.cs" />
<Compile Include="Xml\CXMLReader.cs" />
<Compile Include="Enums.cs" /> <Compile Include="Enums.cs" />
<Compile Include="Menu\IMenu.cs" /> <Compile Include="Menu\IMenu.cs" />
<Compile Include="Menu\IMenuElement.cs" /> <Compile Include="Menu\IMenuElement.cs" />
@@ -139,6 +140,7 @@
<Compile Include="Utils\CWavFile.cs" /> <Compile Include="Utils\CWavFile.cs" />
<Compile Include="Utils\Player\CSongPlayer.cs" /> <Compile Include="Utils\Player\CSongPlayer.cs" />
<Compile Include="Utils\Player\CSoundPlayer.cs" /> <Compile Include="Utils\Player\CSoundPlayer.cs" />
<Compile Include="Xml\CXmlReaderBase.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>
@@ -19,9 +19,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml.XPath; using System.Xml.XPath;
namespace VocaluxeLib namespace VocaluxeLib.Xml
{ {
public class CXMLReader public class CXMLReader : CXmlDeserializer
{ {
private readonly XPathNavigator _Navigator; private readonly XPathNavigator _Navigator;
private readonly String _FilePath; private readonly String _FilePath;
@@ -57,49 +57,6 @@ namespace VocaluxeLib
} }
} }
public bool TryGetEnumValue<T>(string xPath, ref T value)
where T : struct
{
string val;
if (GetValue(xPath, out val, Enum.GetName(typeof(T), value)))
return CHelper.TryParse(val, out value, true);
return false;
}
public bool TryGetIntValue(string xPath, ref int value)
{
string val;
if (GetValue(xPath, out val, value.ToString()))
return int.TryParse(val, out value);
return false;
}
public bool TryGetIntValueRange(string xPath, ref int value, int min = 0, int max = 100)
{
bool result = TryGetIntValue(xPath, ref value);
if (result)
value = value.Clamp(min, max);
return result;
}
public bool TryGetFloatValue(string xPath, ref float value)
{
string val;
return GetValue(xPath, out val, value.ToString()) && CHelper.TryParse(val, out value);
}
/// <summary>
/// Gets a normalized (0&lt;=x&lt;=1) float value
/// </summary>
/// <param name="xPath"></param>
/// <param name="value"></param>
/// <returns>True if exists and is normalized</returns>
public bool TryGetNormalizedFloatValue(string xPath, ref float value)
{
string val;
return GetValue(xPath, out val, value.ToString()) && CHelper.TryParse(val, out value) && value.IsInRange(0f, 1f);
}
public bool TryGetColorFromRGBA(string xPath, ref SColorF value) public bool TryGetColorFromRGBA(string xPath, ref SColorF value)
{ {
bool result = true; bool result = true;
@@ -110,7 +67,7 @@ namespace VocaluxeLib
return result; return result;
} }
public bool GetValue(string xPath, out string value, string defaultValue = "") public override bool GetValue(string xPath, out string value, string defaultValue = "")
{ {
int resultCt = 0; int resultCt = 0;
string val = string.Empty; string val = string.Empty;
@@ -133,6 +90,19 @@ namespace VocaluxeLib
return true; 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 = "";
return false;
}
public List<string> GetNames(string xPath) public List<string> GetNames(string xPath)
{ {
var values = new List<string>(); var values = new List<string>();
+68
View File
@@ -0,0 +1,68 @@
using System.Linq;
namespace VocaluxeLib.Xml
{
public abstract class CXmlDeserializer : CXmlReaderBase
{
public bool Read(string xPath, out SThemeFont el)
{
el = new SThemeFont();
bool ok = true;
ok &= GetValue(xPath + "/Name", out el.Name);
ok &= TryGetFloatValue(xPath + "/Size", ref el.Size);
ok &= TryGetEnumValue(xPath + "/Style", ref el.Style);
return ok;
}
public bool Read(string xPath, out SMargin el)
{
el = new SMargin();
bool ok = true;
bool defOk = TryGetIntValue(xPath + "/Default", ref el.Default);
ok &= TryGetIntValue(xPath + "/Left", ref el.Left, el.Default);
ok &= TryGetIntValue(xPath + "/Right", ref el.Right, el.Default);
ok &= TryGetIntValue(xPath + "/Top", ref el.Top, el.Default);
ok &= TryGetIntValue(xPath + "/Bottom", ref el.Bottom, el.Default);
return ok || defOk;
}
public bool Read(string xPath, out SThemeCoverGeneratorText el)
{
el = new SThemeCoverGeneratorText();
bool ok = true;
ok &= GetValue(xPath + "/Text", out el.Text);
ok &= Read(xPath + "/Font", out el.Font);
ok &= Read(xPath + "/Color", out el.Color);
ok &= Read(xPath + "/Margin", out el.Margin);
if (ok)
TryGetIntValue(xPath + "/Indent", ref el.Indent, 6 * (el.Margin.Left + el.Margin.Right) / 2);
return ok;
}
public bool Read(string xPath, out SThemeColor el)
{
el = new SThemeColor();
bool ok = true;
ok &= TryGetNormalizedFloatValue(xPath + "/R", ref el.Color.R);
ok &= TryGetNormalizedFloatValue(xPath + "/G", ref el.Color.G);
ok &= TryGetNormalizedFloatValue(xPath + "/B", ref el.Color.B);
ok &= TryGetNormalizedFloatValue(xPath + "/A", ref el.Color.A);
if (!ok)
ok = GetValue(xPath, out el.Name) && !el.Name.Contains('<');
return ok;
}
public bool Read(string xPath, out SThemeCoverGenerator el)
{
el = new SThemeCoverGenerator();
bool ok = true;
ok &= TryGetEnumValue(xPath + "/Type", ref el.Type);
ok &= Read(xPath + "/Text", out el.Text);
ok &= Read(xPath + "/BackgroundColor", out el.BackgroundColor);
ok &= GetValue(xPath + "/Image", out el.Image);
TryGetNormalizedFloatValue(xPath + "/ImageAlpha", ref el.ImageAlpha, 0.5f);
TryGetBoolValue(xPath + "/ShowFirstCover", out el.ShowFirstCover);
return ok;
}
}
}
+61
View File
@@ -0,0 +1,61 @@
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;
}
}
}