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